Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3720541
D8070.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D8070.diff
View Options
diff --git a/native/cpp/CommonCpp/NativeModules/CMakeLists.txt b/native/cpp/CommonCpp/NativeModules/CMakeLists.txt
--- a/native/cpp/CommonCpp/NativeModules/CMakeLists.txt
+++ b/native/cpp/CommonCpp/NativeModules/CMakeLists.txt
@@ -10,6 +10,7 @@
set(NATIVE_HDRS
"CommCoreModule.h"
"CommUtilsModule.h"
+ "CommConstants.h"
"MessageStoreOperations.h"
"ThreadStoreOperations.h"
"ReportStoreOperations.h"
@@ -19,6 +20,7 @@
set(NATIVE_SRCS
"CommCoreModule.cpp"
"CommUtilsModule.cpp"
+ "CommConstants.cpp"
)
add_library(comm-modules-native
diff --git a/native/cpp/CommonCpp/NativeModules/CommConstants.h b/native/cpp/CommonCpp/NativeModules/CommConstants.h
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/CommConstants.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include <jsi/jsi.h>
+#include <memory>
+#include <unordered_map>
+
+namespace comm {
+
+namespace jsi = facebook::jsi;
+
+class CommConstants : public jsi::HostObject {
+private:
+ std::unordered_map<std::string, std::unique_ptr<jsi::Object>> constantsCache;
+ jsi::Array prepareNativeMessageTypesArray(jsi::Runtime &rt);
+
+public:
+ CommConstants();
+ jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &name) override;
+ std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
+};
+} // namespace comm
diff --git a/native/cpp/CommonCpp/NativeModules/CommConstants.cpp b/native/cpp/CommonCpp/NativeModules/CommConstants.cpp
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/CommConstants.cpp
@@ -0,0 +1,44 @@
+#include "CommConstants.h"
+#include "PersistentStorageUtilities/MessageOperationsUtilities/MessageSpecs.h"
+
+namespace comm {
+
+CommConstants::CommConstants() {
+}
+
+std::vector<jsi::PropNameID> CommConstants::getPropertyNames(jsi::Runtime &rt) {
+ std::vector<jsi::PropNameID> result;
+ result.push_back(
+ jsi::PropNameID::forUtf8(rt, std::string("NATIVE_MESSAGE_TYPES")));
+ return result;
+}
+
+jsi::Value
+CommConstants::get(jsi::Runtime &rt, const jsi::PropNameID &propName) {
+ auto cppPropName = propName.utf8(rt);
+ if (constantsCache.find(cppPropName) != constantsCache.end()) {
+ return jsi::Value(rt, *constantsCache.at(cppPropName));
+ }
+
+ if (cppPropName == "NATIVE_MESSAGE_TYPES") {
+ constantsCache[cppPropName] =
+ std::make_unique<jsi::Array>(prepareNativeMessageTypesArray(rt));
+ return jsi::Value(rt, *constantsCache.at(cppPropName));
+ }
+
+ return jsi::Value::undefined();
+}
+
+jsi::Array CommConstants::prepareNativeMessageTypesArray(jsi::Runtime &rt) {
+ jsi::Array messageTypesArray = jsi::Array(rt, messageSpecsHolder.size());
+
+ size_t writeIndex = 0;
+ for (const auto &typeSpecPair : messageSpecsHolder) {
+ auto nativeMessageType = static_cast<int>(typeSpecPair.first);
+ messageTypesArray.setValueAtIndex(
+ rt, writeIndex++, jsi::Value(nativeMessageType));
+ }
+ return messageTypesArray;
+}
+
+} // namespace comm
diff --git a/native/ios/Comm.xcodeproj/project.pbxproj b/native/ios/Comm.xcodeproj/project.pbxproj
--- a/native/ios/Comm.xcodeproj/project.pbxproj
+++ b/native/ios/Comm.xcodeproj/project.pbxproj
@@ -51,6 +51,7 @@
B71AFF1F265EDD8600B22352 /* IBMPlexSans-Medium.ttf in Resources */ = {isa = PBXBuildFile; fileRef = B71AFF1E265EDD8600B22352 /* IBMPlexSans-Medium.ttf */; };
CB1648AF27CFBE6A00394D9D /* CryptoModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 71BF5B7B26BBDA6100EDE27D /* CryptoModule.cpp */; };
CB24361829A39A2500FEC4E1 /* NotificationsCryptoModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB24361729A39A2500FEC4E1 /* NotificationsCryptoModule.cpp */; };
+ CB2689002A2DF58000EC7300 /* CommConstants.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CB2688FF2A2DF56000EC7300 /* CommConstants.cpp */; };
CB38B48228771C7A00171182 /* NonBlockingLock.mm in Sources */ = {isa = PBXBuildFile; fileRef = CB38B47B287718A200171182 /* NonBlockingLock.mm */; };
CB38B48328771C8300171182 /* NonBlockingLock.mm in Sources */ = {isa = PBXBuildFile; fileRef = CB38B47B287718A200171182 /* NonBlockingLock.mm */; };
CB38B48428771CAF00171182 /* EncryptedFileUtils.mm in Sources */ = {isa = PBXBuildFile; fileRef = CB38B47D2877194100171182 /* EncryptedFileUtils.mm */; };
@@ -206,6 +207,8 @@
C562A7004903539402D988CE /* Pods-Comm.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Comm.release.xcconfig"; path = "Target Support Files/Pods-Comm/Pods-Comm.release.xcconfig"; sourceTree = "<group>"; };
CB24361629A397AB00FEC4E1 /* NotificationsCryptoModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NotificationsCryptoModule.h; path = Notifications/BackgroundDataStorage/NotificationsCryptoModule.h; sourceTree = "<group>"; };
CB24361729A39A2500FEC4E1 /* NotificationsCryptoModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NotificationsCryptoModule.cpp; path = Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp; sourceTree = "<group>"; };
+ CB2688FE2A2DF55F00EC7300 /* CommConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CommConstants.h; sourceTree = "<group>"; };
+ CB2688FF2A2DF56000EC7300 /* CommConstants.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CommConstants.cpp; sourceTree = "<group>"; };
CB30C12327D0ACF700FBE8DE /* NotificationService.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NotificationService.entitlements; sourceTree = "<group>"; };
CB38B4792877179A00171182 /* NonBlockingLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NonBlockingLock.h; path = Comm/TemporaryMessageStorage/NonBlockingLock.h; sourceTree = "<group>"; };
CB38B47B287718A200171182 /* NonBlockingLock.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = NonBlockingLock.mm; path = Comm/TemporaryMessageStorage/NonBlockingLock.mm; sourceTree = "<group>"; };
@@ -382,6 +385,8 @@
children = (
8EE6E4A02A39CCAB00AE6BCD /* DraftStoreOperations.h */,
8EE6E49F2A39CCAB00AE6BCD /* ReportStoreOperations.h */,
+ CB2688FF2A2DF56000EC7300 /* CommConstants.cpp */,
+ CB2688FE2A2DF55F00EC7300 /* CommConstants.h */,
CBED0E2C284E086100CD3863 /* PersistentStorageUtilities */,
726E5D722731A4240032361D /* InternalModules */,
71BE843C2636A944002849D2 /* CommCoreModule.cpp */,
@@ -984,6 +989,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ CB2689002A2DF58000EC7300 /* CommConstants.cpp in Sources */,
CB7EF17E295C674300B17035 /* CommIOSNotifications.mm in Sources */,
CB7EF180295C674300B17035 /* CommIOSNotificationsBridgeQueue.mm in Sources */,
7F0C6E31291C4468002AA2D9 /* ExpoModulesProvider.swift in Sources */,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 9, 12:15 PM (9 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2834841
Default Alt Text
D8070.diff (6 KB)
Attached To
Mode
D8070: Implement CommConstants HostObject with `NATIVE_MESSAGE_TYPES` property in C++
Attached
Detach File
Event Timeline
Log In to Comment