react-native-unistyles 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -26
- package/android/CMakeLists.txt +18 -2
- package/android/build.gradle +5 -1
- package/android/src/main/cxx/cpp-adapter.cpp +16 -80
- package/android/src/main/cxx/helpers.cpp +61 -0
- package/android/src/main/cxx/helpers.h +7 -0
- package/android/src/main/cxx/platform.cpp +170 -0
- package/android/src/main/cxx/platform.h +20 -0
- package/android/src/main/java/com/unistyles/Models.kt +12 -70
- package/android/src/main/java/com/unistyles/Platform.kt +311 -10
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +145 -153
- package/cxx/Macros.h +11 -0
- package/cxx/UnistylesImpl.cpp +310 -0
- package/cxx/UnistylesModel.cpp +234 -0
- package/cxx/UnistylesModel.h +141 -0
- package/cxx/UnistylesRuntime.cpp +17 -356
- package/cxx/UnistylesRuntime.h +71 -87
- package/ios/UnistylesModule.h +13 -0
- package/ios/UnistylesModule.mm +20 -90
- package/ios/platform/Platform_Shared.h +8 -0
- package/ios/platform/Platform_Shared.mm +160 -0
- package/ios/platform/Platform_iOS.h +6 -10
- package/ios/platform/Platform_iOS.mm +143 -93
- package/ios/platform/Platform_macOS.h +3 -7
- package/ios/platform/Platform_macOS.mm +52 -34
- package/ios/platform/Platform_tvOS.h +17 -0
- package/ios/platform/Platform_tvOS.mm +96 -0
- package/ios/platform/Platform_visionOS.h +20 -0
- package/ios/platform/Platform_visionOS.mm +120 -0
- package/lib/commonjs/UnistylesProvider.js +32 -0
- package/lib/commonjs/UnistylesProvider.js.map +1 -0
- package/lib/commonjs/common.js +3 -2
- package/lib/commonjs/common.js.map +1 -1
- package/lib/commonjs/core/UnistyleRegistry.js +14 -4
- package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
- package/lib/commonjs/core/Unistyles.js +7 -0
- package/lib/commonjs/core/Unistyles.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.js +52 -8
- package/lib/commonjs/core/UnistylesModule.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.native.js.map +1 -1
- package/lib/commonjs/core/UnistylesModule.windows.js.map +1 -1
- package/lib/commonjs/core/UnistylesRuntime.js +114 -4
- package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/core/mocks/UnistylesMockedBridge.js +36 -0
- package/lib/commonjs/core/mocks/UnistylesMockedBridge.js.map +1 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRegistry.js +46 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRegistry.js.map +1 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRuntime.js +122 -0
- package/lib/commonjs/core/mocks/UnistylesMockedRuntime.js.map +1 -0
- package/lib/commonjs/core/mocks/index.js +27 -0
- package/lib/commonjs/core/mocks/index.js.map +1 -0
- package/lib/commonjs/createStyleSheet.js.map +1 -1
- package/lib/commonjs/global.js.map +1 -1
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useCSS.js.map +1 -1
- package/lib/commonjs/hooks/useCSS.native.js.map +1 -1
- package/lib/commonjs/hooks/useInitialTheme.js.map +1 -1
- package/lib/commonjs/hooks/useSharedContext.js +77 -0
- package/lib/commonjs/hooks/useSharedContext.js.map +1 -0
- package/lib/commonjs/hooks/useUnistyles.js +18 -65
- package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
- package/lib/commonjs/hooks/useVariants.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/normalizer/index.js.map +1 -1
- package/lib/commonjs/normalizer/module.d.js.map +1 -1
- package/lib/commonjs/normalizer/normalizeStyle.js.map +1 -1
- package/lib/commonjs/normalizer/normalizer.js +1 -1
- package/lib/commonjs/normalizer/normalizer.js.map +1 -1
- package/lib/commonjs/normalizer/normalizer.macos.js.map +1 -1
- package/lib/commonjs/plugins/cssMediaQueriesPlugin.js.map +1 -1
- package/lib/commonjs/plugins/index.js.map +1 -1
- package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -1
- package/lib/commonjs/types/breakpoints.js.map +1 -1
- package/lib/commonjs/types/color.js +2 -0
- package/lib/commonjs/types/color.js.map +1 -0
- package/lib/commonjs/types/common.js.map +1 -1
- package/lib/commonjs/types/core.js.map +1 -1
- package/lib/commonjs/types/index.js +11 -0
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/normalizer.js.map +1 -1
- package/lib/commonjs/types/plugin.js.map +1 -1
- package/lib/commonjs/types/stylesheet.js.map +1 -1
- package/lib/commonjs/types/unistyles.js.map +1 -1
- package/lib/commonjs/types/variants.js.map +1 -1
- package/lib/commonjs/useStyles.js +1 -1
- package/lib/commonjs/useStyles.js.map +1 -1
- package/lib/commonjs/utils/breakpoints.js.map +1 -1
- package/lib/commonjs/utils/cssMediaQuery.js.map +1 -1
- package/lib/commonjs/utils/generateId.js.map +1 -1
- package/lib/commonjs/utils/hash32.js.map +1 -1
- package/lib/commonjs/utils/index.js +7 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/mq.js.map +1 -1
- package/lib/commonjs/utils/mqParser.js.map +1 -1
- package/lib/commonjs/utils/parseColor.js +35 -0
- package/lib/commonjs/utils/parseColor.js.map +1 -0
- package/lib/commonjs/utils/styles.js +15 -1
- package/lib/commonjs/utils/styles.js.map +1 -1
- package/lib/commonjs/utils/withPlugins.js.map +1 -1
- package/lib/module/UnistylesProvider.js +24 -0
- package/lib/module/UnistylesProvider.js.map +1 -0
- package/lib/module/common.js +2 -1
- package/lib/module/common.js.map +1 -1
- package/lib/module/core/UnistyleRegistry.js +15 -5
- package/lib/module/core/UnistyleRegistry.js.map +1 -1
- package/lib/module/core/Unistyles.js +8 -1
- package/lib/module/core/Unistyles.js.map +1 -1
- package/lib/module/core/UnistylesModule.js +52 -8
- package/lib/module/core/UnistylesModule.js.map +1 -1
- package/lib/module/core/UnistylesModule.native.js.map +1 -1
- package/lib/module/core/UnistylesModule.windows.js.map +1 -1
- package/lib/module/core/UnistylesRuntime.js +115 -4
- package/lib/module/core/UnistylesRuntime.js.map +1 -1
- package/lib/module/core/index.js +2 -1
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/mocks/UnistylesMockedBridge.js +29 -0
- package/lib/module/core/mocks/UnistylesMockedBridge.js.map +1 -0
- package/lib/module/core/mocks/UnistylesMockedRegistry.js +39 -0
- package/lib/module/core/mocks/UnistylesMockedRegistry.js.map +1 -0
- package/lib/module/core/mocks/UnistylesMockedRuntime.js +114 -0
- package/lib/module/core/mocks/UnistylesMockedRuntime.js.map +1 -0
- package/lib/module/core/mocks/index.js +4 -0
- package/lib/module/core/mocks/index.js.map +1 -0
- package/lib/module/createStyleSheet.js.map +1 -1
- package/lib/module/global.js.map +1 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useCSS.js.map +1 -1
- package/lib/module/hooks/useCSS.native.js.map +1 -1
- package/lib/module/hooks/useInitialTheme.js.map +1 -1
- package/lib/module/hooks/useSharedContext.js +70 -0
- package/lib/module/hooks/useSharedContext.js.map +1 -0
- package/lib/module/hooks/useUnistyles.js +19 -66
- package/lib/module/hooks/useUnistyles.js.map +1 -1
- package/lib/module/hooks/useVariants.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/normalizer/index.js.map +1 -1
- package/lib/module/normalizer/module.d.js.map +1 -1
- package/lib/module/normalizer/normalizeStyle.js.map +1 -1
- package/lib/module/normalizer/normalizer.js.map +1 -1
- package/lib/module/normalizer/normalizer.macos.js.map +1 -1
- package/lib/module/plugins/cssMediaQueriesPlugin.js.map +1 -1
- package/lib/module/plugins/index.js.map +1 -1
- package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -1
- package/lib/module/types/breakpoints.js.map +1 -1
- package/lib/module/types/color.js +2 -0
- package/lib/module/types/color.js.map +1 -0
- package/lib/module/types/common.js.map +1 -1
- package/lib/module/types/core.js.map +1 -1
- package/lib/module/types/index.js +1 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/normalizer.js.map +1 -1
- package/lib/module/types/plugin.js.map +1 -1
- package/lib/module/types/stylesheet.js.map +1 -1
- package/lib/module/types/unistyles.js.map +1 -1
- package/lib/module/types/variants.js.map +1 -1
- package/lib/module/useStyles.js +1 -1
- package/lib/module/useStyles.js.map +1 -1
- package/lib/module/utils/breakpoints.js.map +1 -1
- package/lib/module/utils/cssMediaQuery.js.map +1 -1
- package/lib/module/utils/generateId.js.map +1 -1
- package/lib/module/utils/hash32.js.map +1 -1
- package/lib/module/utils/index.js +1 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/mq.js.map +1 -1
- package/lib/module/utils/mqParser.js.map +1 -1
- package/lib/module/utils/parseColor.js +28 -0
- package/lib/module/utils/parseColor.js.map +1 -0
- package/lib/module/utils/styles.js +15 -1
- package/lib/module/utils/styles.js.map +1 -1
- package/lib/module/utils/withPlugins.js.map +1 -1
- package/lib/typescript/src/UnistylesProvider.d.ts +20 -0
- package/lib/typescript/src/UnistylesProvider.d.ts.map +1 -0
- package/lib/typescript/src/common.d.ts +3 -2
- package/lib/typescript/src/common.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
- package/lib/typescript/src/core/Unistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.d.ts +1 -0
- package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesModule.windows.d.ts.map +1 -1
- package/lib/typescript/src/core/UnistylesRuntime.d.ts +84 -8
- package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
- package/lib/typescript/src/core/index.d.ts +3 -1
- package/lib/typescript/src/core/index.d.ts.map +1 -1
- package/lib/typescript/src/core/mocks/UnistylesMockedBridge.d.ts +28 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedBridge.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRegistry.d.ts +21 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRegistry.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRuntime.d.ts +79 -0
- package/lib/typescript/src/core/mocks/UnistylesMockedRuntime.d.ts.map +1 -0
- package/lib/typescript/src/core/mocks/index.d.ts +4 -0
- package/lib/typescript/src/core/mocks/index.d.ts.map +1 -0
- package/lib/typescript/src/createStyleSheet.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCSS.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCSS.native.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useSharedContext.d.ts +33 -0
- package/lib/typescript/src/hooks/useSharedContext.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useUnistyles.d.ts +4 -19
- package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useVariants.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +7 -15
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/normalizer/normalizeStyle.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +9 -8
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/color.d.ts +4 -0
- package/lib/typescript/src/types/color.d.ts.map +1 -0
- package/lib/typescript/src/types/core.d.ts +2 -2
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +2 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/normalizer.d.ts +1 -1
- package/lib/typescript/src/types/normalizer.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +9 -6
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/types/unistyles.d.ts +20 -9
- package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
- package/lib/typescript/src/useStyles.d.ts +1 -1
- package/lib/typescript/src/useStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/utils/index.d.ts +1 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/mqParser.d.ts.map +1 -1
- package/lib/typescript/src/utils/parseColor.d.ts +3 -0
- package/lib/typescript/src/utils/parseColor.d.ts.map +1 -0
- package/lib/typescript/src/utils/styles.d.ts.map +1 -1
- package/package.json +38 -25
- package/react-native-unistyles.podspec +4 -1
- package/src/UnistylesProvider.tsx +33 -0
- package/src/common.ts +3 -2
- package/src/core/UnistyleRegistry.ts +19 -5
- package/src/core/Unistyles.ts +10 -1
- package/src/core/UnistylesModule.ts +61 -14
- package/src/core/UnistylesRuntime.ts +120 -5
- package/src/core/index.ts +7 -1
- package/src/core/mocks/UnistylesMockedBridge.ts +30 -0
- package/src/core/mocks/UnistylesMockedRegistry.ts +47 -0
- package/src/core/mocks/UnistylesMockedRuntime.ts +144 -0
- package/src/core/mocks/index.ts +3 -0
- package/src/hooks/useSharedContext.ts +83 -0
- package/src/hooks/useUnistyles.ts +15 -71
- package/src/index.ts +10 -4
- package/src/types/breakpoints.ts +19 -9
- package/src/types/color.ts +26 -0
- package/src/types/core.ts +2 -2
- package/src/types/index.ts +5 -1
- package/src/types/normalizer.ts +1 -1
- package/src/types/stylesheet.ts +10 -7
- package/src/types/unistyles.ts +28 -12
- package/src/useStyles.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/parseColor.ts +33 -0
- package/src/utils/styles.ts +24 -1
- package/windows/ExperimentalFeatures.props +4 -4
- package/windows/NuGet.Config +0 -1
- package/windows/ReactNativeUnistyles/ReactNativeUnistyles.h +42 -118
- package/windows/ReactNativeUnistyles/ReactNativeUnistyles.vcxproj +7 -2
- package/windows/ReactNativeUnistyles/ReactNativeUnistyles.vcxproj.filters +6 -1
- package/windows/ReactNativeUnistyles/packages.lock.json +31 -31
- package/android/src/main/java/com/unistyles/Config.kt +0 -116
- package/android/src/main/java/com/unistyles/Insets.kt +0 -138
- package/ios/UnistylesHelpers.h +0 -3
- package/ios/UnistylesHelpers.mm +0 -5
package/cxx/UnistylesRuntime.cpp
CHANGED
@@ -1,375 +1,36 @@
|
|
1
1
|
#include "UnistylesRuntime.h"
|
2
|
-
|
2
|
+
#include "Macros.h"
|
3
3
|
#include <string>
|
4
|
-
#include <vector>
|
5
|
-
#include <algorithm>
|
6
4
|
|
7
|
-
|
5
|
+
using namespace facebook;
|
8
6
|
|
9
|
-
std::vector<jsi::PropNameID> UnistylesRuntime::getPropertyNames(jsi::Runtime&
|
7
|
+
std::vector<jsi::PropNameID> UnistylesRuntime::getPropertyNames(jsi::Runtime& rt) {
|
10
8
|
std::vector<jsi::PropNameID> properties;
|
9
|
+
std::for_each(this->getters.begin(), this->getters.end(), [&](const auto& it){
|
10
|
+
properties.push_back(jsi::PropNameID::forUtf8(rt, std::string(it.first)));
|
11
|
+
});
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("contentSizeCategory")));
|
16
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("hasAdaptiveThemes")));
|
17
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("themeName")));
|
18
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("breakpoint")));
|
19
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("colorScheme")));
|
20
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("sortedBreakpointPairs")));
|
21
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("useBreakpoints")));
|
22
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("useTheme")));
|
23
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("updateTheme")));
|
24
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("useAdaptiveThemes")));
|
25
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("addPlugin")));
|
26
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("removePlugin")));
|
27
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("enabledPlugins")));
|
28
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("insets")));
|
29
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("statusBar")));
|
30
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("navigationBar")));
|
31
|
-
|
32
|
-
// setters
|
33
|
-
properties.push_back(jsi::PropNameID::forUtf8(runtime, std::string("themes")));
|
13
|
+
std::for_each(this->setters.begin(), this->setters.end(), [&](const auto& it){
|
14
|
+
properties.push_back(jsi::PropNameID::forUtf8(rt, std::string(it.first)));
|
15
|
+
});
|
34
16
|
|
35
17
|
return properties;
|
36
18
|
}
|
37
19
|
|
38
|
-
jsi::Value UnistylesRuntime::get(jsi::Runtime&
|
39
|
-
|
40
|
-
|
41
|
-
if (propName == "screenWidth") {
|
42
|
-
return jsi::Value(this->screen.width);
|
43
|
-
}
|
44
|
-
|
45
|
-
if (propName == "screenHeight") {
|
46
|
-
return jsi::Value(this->screen.height);
|
47
|
-
}
|
48
|
-
|
49
|
-
if (propName == "hasAdaptiveThemes") {
|
50
|
-
return jsi::Value(this->hasAdaptiveThemes);
|
51
|
-
}
|
52
|
-
|
53
|
-
if (propName == "contentSizeCategory") {
|
54
|
-
return jsi::Value(jsi::String::createFromUtf8(runtime, this->contentSizeCategory));
|
55
|
-
}
|
56
|
-
|
57
|
-
if (propName == "themeName") {
|
58
|
-
return !this->themeName.empty()
|
59
|
-
? jsi::Value(jsi::String::createFromUtf8(runtime, this->themeName))
|
60
|
-
: this->getThemeOrFail(runtime);
|
61
|
-
}
|
62
|
-
|
63
|
-
if (propName == "breakpoint") {
|
64
|
-
return !this->breakpoint.empty()
|
65
|
-
? jsi::Value(jsi::String::createFromUtf8(runtime, this->breakpoint))
|
66
|
-
: jsi::Value::undefined();
|
67
|
-
}
|
20
|
+
jsi::Value UnistylesRuntime::get(jsi::Runtime& rt, const jsi::PropNameID& propNameId) {
|
21
|
+
auto method = this->getters.find(propNameId.utf8(rt));
|
68
22
|
|
69
|
-
if (
|
70
|
-
return
|
71
|
-
}
|
72
|
-
|
73
|
-
if (propName == "enabledPlugins") {
|
74
|
-
auto jsiArray = facebook::jsi::Array(runtime, this->pluginNames.size());
|
75
|
-
|
76
|
-
for (size_t i = 0; i < this->pluginNames.size(); i++) {
|
77
|
-
jsiArray.setValueAtIndex(runtime, i, facebook::jsi::String::createFromUtf8(runtime, this->pluginNames[i]));
|
78
|
-
}
|
79
|
-
|
80
|
-
return jsiArray;
|
81
|
-
}
|
82
|
-
|
83
|
-
if (propName == "sortedBreakpointPairs") {
|
84
|
-
std::unique_ptr<jsi::Array> sortedBreakpointEntriesArray = std::make_unique<jsi::Array>(runtime, this->sortedBreakpointPairs.size());
|
85
|
-
|
86
|
-
for (size_t i = 0; i < this->sortedBreakpointPairs.size(); ++i) {
|
87
|
-
std::unique_ptr<jsi::Array> pairArray = std::make_unique<jsi::Array>(runtime, 2);
|
88
|
-
jsi::String nameValue = jsi::String::createFromUtf8(runtime, this->sortedBreakpointPairs[i].first);
|
89
|
-
|
90
|
-
pairArray->setValueAtIndex(runtime, 0, nameValue);
|
91
|
-
pairArray->setValueAtIndex(runtime, 1, jsi::Value(this->sortedBreakpointPairs[i].second));
|
92
|
-
sortedBreakpointEntriesArray->setValueAtIndex(runtime, i, *pairArray);
|
93
|
-
}
|
94
|
-
|
95
|
-
return jsi::Value(runtime, *sortedBreakpointEntriesArray);
|
96
|
-
}
|
97
|
-
|
98
|
-
if (propName == "addPlugin") {
|
99
|
-
return jsi::Function::createFromHostFunction(
|
100
|
-
runtime,
|
101
|
-
jsi::PropNameID::forAscii(runtime, "addPlugin"),
|
102
|
-
1,
|
103
|
-
[this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
|
104
|
-
std::string pluginName = arguments[0].asString(runtime).utf8(runtime);
|
105
|
-
bool notify = arguments[1].asBool();
|
106
|
-
|
107
|
-
this->pluginNames.push_back(pluginName);
|
108
|
-
|
109
|
-
// registry enabled plugins won't notify listeners
|
110
|
-
if (notify) {
|
111
|
-
this->onPluginChangeCallback();
|
112
|
-
}
|
113
|
-
|
114
|
-
return jsi::Value::undefined();
|
115
|
-
}
|
116
|
-
);
|
117
|
-
}
|
118
|
-
|
119
|
-
if (propName == "removePlugin") {
|
120
|
-
return jsi::Function::createFromHostFunction(
|
121
|
-
runtime,
|
122
|
-
jsi::PropNameID::forAscii(runtime, "removePlugin"),
|
123
|
-
1,
|
124
|
-
[this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
|
125
|
-
std::string pluginName = arguments[0].asString(runtime).utf8(runtime);
|
126
|
-
|
127
|
-
auto it = std::find(this->pluginNames.begin(), this->pluginNames.end(), pluginName);
|
128
|
-
|
129
|
-
if (it != this->pluginNames.end()) {
|
130
|
-
this->pluginNames.erase(it);
|
131
|
-
this->onPluginChangeCallback();
|
132
|
-
}
|
133
|
-
|
134
|
-
return jsi::Value::undefined();
|
135
|
-
}
|
136
|
-
);
|
137
|
-
}
|
138
|
-
|
139
|
-
if (propName == "useBreakpoints") {
|
140
|
-
return jsi::Function::createFromHostFunction(
|
141
|
-
runtime,
|
142
|
-
jsi::PropNameID::forAscii(runtime, "useBreakpoints"),
|
143
|
-
1,
|
144
|
-
[this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
|
145
|
-
jsi::Object breakpointsObj = arguments[0].asObject(runtime);
|
146
|
-
jsi::Array propertyNames = breakpointsObj.getPropertyNames(runtime);
|
147
|
-
std::vector<std::pair<std::string, double>> sortedBreakpointEntriesVec;
|
148
|
-
|
149
|
-
for (size_t i = 0; i < propertyNames.size(runtime); ++i) {
|
150
|
-
jsi::Value propNameValue = propertyNames.getValueAtIndex(runtime, i);
|
151
|
-
std::string name = propNameValue.asString(runtime).utf8(runtime);
|
152
|
-
jsi::PropNameID propNameID = jsi::PropNameID::forUtf8(runtime, name);
|
153
|
-
jsi::Value value = breakpointsObj.getProperty(runtime, propNameID);
|
154
|
-
|
155
|
-
if (value.isNumber()) {
|
156
|
-
double breakpointValue = value.asNumber();
|
157
|
-
sortedBreakpointEntriesVec.push_back(std::make_pair(name, breakpointValue));
|
158
|
-
}
|
159
|
-
}
|
160
|
-
|
161
|
-
std::sort(sortedBreakpointEntriesVec.begin(), sortedBreakpointEntriesVec.end(), [](const std::pair<std::string, double>& a, const std::pair<std::string, double>& b) {
|
162
|
-
return a.second < b.second;
|
163
|
-
});
|
164
|
-
|
165
|
-
if (sortedBreakpointEntriesVec.size() == 0) {
|
166
|
-
throw jsi::JSError(runtime, UnistylesErrorBreakpointsCannotBeEmpty);
|
167
|
-
}
|
168
|
-
|
169
|
-
if (sortedBreakpointEntriesVec.at(0).second != 0) {
|
170
|
-
throw jsi::JSError(runtime, UnistylesErrorBreakpointsMustStartFromZero);
|
171
|
-
}
|
172
|
-
|
173
|
-
this->sortedBreakpointPairs = sortedBreakpointEntriesVec;
|
174
|
-
|
175
|
-
std::string breakpoint = this->getBreakpointFromScreenWidth(this->screen.width, sortedBreakpointEntriesVec);
|
176
|
-
|
177
|
-
this->breakpoint = breakpoint;
|
178
|
-
|
179
|
-
return jsi::Value::undefined();
|
180
|
-
}
|
181
|
-
);
|
182
|
-
}
|
183
|
-
|
184
|
-
if (propName == "useTheme") {
|
185
|
-
return jsi::Function::createFromHostFunction(runtime,
|
186
|
-
jsi::PropNameID::forAscii(runtime, "useTheme"),
|
187
|
-
1,
|
188
|
-
[this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
|
189
|
-
std::string themeName = arguments[0].asString(runtime).utf8(runtime);
|
190
|
-
|
191
|
-
if (this->themeName != themeName) {
|
192
|
-
this->themeName = themeName;
|
193
|
-
this->onThemeChangeCallback(themeName);
|
194
|
-
}
|
195
|
-
|
196
|
-
return jsi::Value::undefined();
|
197
|
-
}
|
198
|
-
);
|
199
|
-
}
|
200
|
-
|
201
|
-
if (propName == "updateTheme") {
|
202
|
-
return jsi::Function::createFromHostFunction(runtime,
|
203
|
-
jsi::PropNameID::forAscii(runtime, "updateTheme"),
|
204
|
-
1,
|
205
|
-
[this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
|
206
|
-
std::string themeName = arguments[0].asString(runtime).utf8(runtime);
|
207
|
-
|
208
|
-
if (this->themeName == themeName) {
|
209
|
-
this->onThemeChangeCallback(themeName);
|
210
|
-
}
|
211
|
-
|
212
|
-
return jsi::Value::undefined();
|
213
|
-
}
|
214
|
-
);
|
215
|
-
}
|
216
|
-
|
217
|
-
if (propName == "useAdaptiveThemes") {
|
218
|
-
return jsi::Function::createFromHostFunction(runtime,
|
219
|
-
jsi::PropNameID::forAscii(runtime, "useAdaptiveThemes"),
|
220
|
-
1,
|
221
|
-
[this](jsi::Runtime &runtime, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) -> jsi::Value {
|
222
|
-
bool enableAdaptiveThemes = arguments[0].asBool();
|
223
|
-
|
224
|
-
this->hasAdaptiveThemes = enableAdaptiveThemes;
|
225
|
-
|
226
|
-
if (!enableAdaptiveThemes || !this->supportsAutomaticColorScheme) {
|
227
|
-
return jsi::Value::undefined();
|
228
|
-
}
|
229
|
-
|
230
|
-
if (this->themeName != this->colorScheme) {
|
231
|
-
this->themeName = this->colorScheme;
|
232
|
-
this->onThemeChangeCallback(this->themeName);
|
233
|
-
}
|
234
|
-
|
235
|
-
return jsi::Value::undefined();
|
236
|
-
}
|
237
|
-
);
|
238
|
-
}
|
239
|
-
|
240
|
-
if (propName == "insets") {
|
241
|
-
auto insets = jsi::Object(runtime);
|
242
|
-
|
243
|
-
insets.setProperty(runtime, "top", this->insets.top);
|
244
|
-
insets.setProperty(runtime, "bottom", this->insets.bottom);
|
245
|
-
insets.setProperty(runtime, "left", this->insets.left);
|
246
|
-
insets.setProperty(runtime, "right", this->insets.right);
|
247
|
-
|
248
|
-
return insets;
|
249
|
-
}
|
250
|
-
|
251
|
-
if (propName == "statusBar") {
|
252
|
-
auto statusBar = jsi::Object(runtime);
|
253
|
-
|
254
|
-
statusBar.setProperty(runtime, "width", this->statusBar.width);
|
255
|
-
statusBar.setProperty(runtime, "height", this->statusBar.height);
|
256
|
-
|
257
|
-
return statusBar;
|
258
|
-
}
|
259
|
-
|
260
|
-
if (propName == "navigationBar") {
|
261
|
-
auto navigationBarValue = jsi::Object(runtime);
|
262
|
-
|
263
|
-
navigationBarValue.setProperty(runtime, "width", this->navigationBar.width);
|
264
|
-
navigationBarValue.setProperty(runtime, "height", this->navigationBar.height);
|
265
|
-
|
266
|
-
return navigationBarValue;
|
23
|
+
if (method != this->getters.cend()) {
|
24
|
+
return method->second(rt, method->first);
|
267
25
|
}
|
268
26
|
|
269
27
|
return jsi::Value::undefined();
|
270
28
|
}
|
271
29
|
|
272
|
-
void UnistylesRuntime::set(jsi::Runtime&
|
273
|
-
|
274
|
-
|
275
|
-
if (propName == "themes" && value.isObject()) {
|
276
|
-
jsi::Array themes = value.asObject(runtime).asArray(runtime);
|
277
|
-
std::vector<std::string> themesVector;
|
278
|
-
size_t length = themes.size(runtime);
|
279
|
-
|
280
|
-
for (size_t i = 0; i < length; ++i) {
|
281
|
-
jsi::Value element = themes.getValueAtIndex(runtime, i);
|
282
|
-
|
283
|
-
if (element.isString()) {
|
284
|
-
std::string theme = element.asString(runtime).utf8(runtime);
|
285
|
-
themesVector.push_back(theme);
|
286
|
-
}
|
287
|
-
}
|
288
|
-
|
289
|
-
if (themesVector.size() == 0) {
|
290
|
-
throw jsi::JSError(runtime, UnistylesErrorThemesCannotBeEmpty);
|
291
|
-
}
|
292
|
-
|
293
|
-
this->themes = themesVector;
|
294
|
-
this->themeName = "";
|
295
|
-
|
296
|
-
bool hasLightTheme = std::find(themesVector.begin(), themesVector.end(), "light") != themesVector.end();
|
297
|
-
bool hasDarkTheme = std::find(themesVector.begin(), themesVector.end(), "dark") != themesVector.end();
|
298
|
-
|
299
|
-
this->supportsAutomaticColorScheme = hasLightTheme && hasDarkTheme;
|
300
|
-
|
301
|
-
return;
|
302
|
-
}
|
303
|
-
}
|
304
|
-
|
305
|
-
#pragma endregion
|
306
|
-
#pragma region Helpers
|
307
|
-
|
308
|
-
std::string UnistylesRuntime::getBreakpointFromScreenWidth(int width, const std::vector<std::pair<std::string, double>>& sortedBreakpointPairs) {
|
309
|
-
for (size_t i = 0; i < sortedBreakpointPairs.size(); ++i) {
|
310
|
-
const auto& [key, value] = sortedBreakpointPairs[i];
|
311
|
-
const double maxVal = (i + 1 < sortedBreakpointPairs.size()) ? sortedBreakpointPairs[i + 1].second : std::numeric_limits<double>::infinity();
|
312
|
-
|
313
|
-
if (width >= value && width < maxVal) {
|
314
|
-
return key;
|
315
|
-
}
|
316
|
-
}
|
317
|
-
|
318
|
-
return sortedBreakpointPairs.empty() ? "" : sortedBreakpointPairs.back().first;
|
319
|
-
}
|
320
|
-
|
321
|
-
void UnistylesRuntime::handleScreenSizeChange(Dimensions& screen, Insets& insets, Dimensions& statusBar, Dimensions& navigationBar) {
|
322
|
-
std::string breakpoint = this->getBreakpointFromScreenWidth(screen.width, this->sortedBreakpointPairs);
|
323
|
-
bool hasDifferentBreakpoint = this->breakpoint != breakpoint;
|
324
|
-
bool hasDifferentScreenDimensions = this->screen.width != screen.width || this->screen.height != screen.height;
|
325
|
-
bool hasDifferentInsets = this->insets.top != insets.top || this->insets.bottom != insets.bottom || this->insets.left != insets.left || this->insets.right != insets.right;
|
326
|
-
|
327
|
-
// we don't need to check statusBar/navigationBar as they will only change on orientation change witch is equal to hasDifferentScreenDimensions
|
328
|
-
bool shouldNotify = hasDifferentBreakpoint || hasDifferentScreenDimensions || hasDifferentInsets;
|
329
|
-
|
330
|
-
this->breakpoint = breakpoint;
|
331
|
-
this->screen = {screen.width, screen.height};
|
332
|
-
this->insets = {insets.top, insets.bottom, insets.left, insets.right};
|
333
|
-
this->statusBar = {statusBar.width, statusBar.height};
|
334
|
-
this->navigationBar = {navigationBar.width, navigationBar.height};
|
335
|
-
|
336
|
-
std::string orientation = screen.width > screen.height
|
337
|
-
? UnistylesOrientationLandscape
|
338
|
-
: UnistylesOrientationPortrait;
|
339
|
-
|
340
|
-
if (shouldNotify) {
|
341
|
-
this->onLayoutChangeCallback(breakpoint, orientation, screen, statusBar, insets, navigationBar);
|
342
|
-
}
|
343
|
-
}
|
344
|
-
|
345
|
-
void UnistylesRuntime::handleAppearanceChange(std::string colorScheme) {
|
346
|
-
this->colorScheme = colorScheme;
|
347
|
-
|
348
|
-
if (!this->supportsAutomaticColorScheme || !this->hasAdaptiveThemes) {
|
349
|
-
return;
|
350
|
-
}
|
30
|
+
void UnistylesRuntime::set(jsi::Runtime& rt, const jsi::PropNameID& propNameId, const jsi::Value& value) {
|
31
|
+
auto method = this->setters.find(propNameId.utf8(rt));
|
351
32
|
|
352
|
-
if (
|
353
|
-
|
354
|
-
this->themeName = this->colorScheme;
|
33
|
+
if (method != this->setters.cend()) {
|
34
|
+
method->second(rt, value);
|
355
35
|
}
|
356
36
|
}
|
357
|
-
|
358
|
-
void UnistylesRuntime::handleContentSizeCategoryChange(std::string contentSizeCategory) {
|
359
|
-
this->contentSizeCategory = contentSizeCategory;
|
360
|
-
this->onContentSizeCategoryChangeCallback(contentSizeCategory);
|
361
|
-
}
|
362
|
-
|
363
|
-
jsi::Value UnistylesRuntime::getThemeOrFail(jsi::Runtime& runtime) {
|
364
|
-
if (this->themes.size() == 1) {
|
365
|
-
std::string themeName = this->themes.at(0);
|
366
|
-
|
367
|
-
this->themeName = themeName;
|
368
|
-
|
369
|
-
return jsi::String::createFromUtf8(runtime, themeName);
|
370
|
-
}
|
371
|
-
|
372
|
-
return jsi::Value().undefined();
|
373
|
-
}
|
374
|
-
|
375
|
-
#pragma endregion
|
package/cxx/UnistylesRuntime.h
CHANGED
@@ -1,96 +1,80 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
|
+
#include "UnistylesModel.h"
|
4
|
+
#include "Macros.h"
|
3
5
|
#include <jsi/jsi.h>
|
4
|
-
#include <vector>
|
5
|
-
#include <map>
|
6
6
|
|
7
7
|
using namespace facebook;
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
using Getter = std::function<jsi::Value(jsi::Runtime& rt, std::string)>;
|
10
|
+
using Setter = std::function<std::optional<jsi::Value>(jsi::Runtime& rt, const jsi::Value&)>;
|
11
|
+
|
12
|
+
struct JSI_EXPORT UnistylesRuntime : public jsi::HostObject, UnistylesModel {
|
13
|
+
UnistylesRuntime(std::function<void(std::function<void(jsi::Runtime&)>&&)> runOnJSThread) : UnistylesModel(runOnJSThread) {
|
14
|
+
this->getters = {
|
15
|
+
{"screenWidth", BIND_FN(getScreenWidth)},
|
16
|
+
{"screenHeight", BIND_FN(getScreenHeight)},
|
17
|
+
{"contentSizeCategory", BIND_FN(getContentSizeCategory)},
|
18
|
+
{"hasAdaptiveThemes", BIND_FN(hasEnabledAdaptiveThemes)},
|
19
|
+
{"themeName", BIND_FN(getThemeName)},
|
20
|
+
{"breakpoint", BIND_FN(getCurrentBreakpoint)},
|
21
|
+
{"colorScheme", BIND_FN(getColorScheme)},
|
22
|
+
{"sortedBreakpointPairs", BIND_FN(getSortedBreakpointPairs)},
|
23
|
+
{"useBreakpoints", BIND_FN(setBreakpoints)},
|
24
|
+
{"useTheme", BIND_FN(setActiveTheme)},
|
25
|
+
{"updateTheme", BIND_FN(updateTheme)},
|
26
|
+
{"useAdaptiveThemes", BIND_FN(useAdaptiveThemes)},
|
27
|
+
{"addPlugin", BIND_FN(addPlugin)},
|
28
|
+
{"removePlugin", BIND_FN(removePlugin)},
|
29
|
+
{"enabledPlugins", BIND_FN(getEnabledPlugins)},
|
30
|
+
{"insets", BIND_FN(getInsets)},
|
31
|
+
{"statusBar", BIND_FN(getStatusBar)},
|
32
|
+
{"navigationBar", BIND_FN(getNavigationBar)},
|
33
|
+
{"pixelRatio", BIND_FN(getPixelRatio)},
|
34
|
+
{"fontScale", BIND_FN(getFontScale)},
|
35
|
+
{"setRootViewBackgroundColor", BIND_FN(setRootBackgroundColor)},
|
36
|
+
{"setImmersiveMode", BIND_FN(setImmersiveModeEnabled)},
|
37
|
+
{"rtl", BIND_FN(getIsRtl)},
|
38
|
+
{"disableAnimatedInsets", BIND_FN(disableAnimatedInsets)}
|
39
|
+
};
|
40
|
+
|
41
|
+
this->setters = {
|
42
|
+
{"themes", BIND_FN(setThemes)}
|
43
|
+
};
|
44
|
+
};
|
45
|
+
|
46
|
+
jsi::Value getScreenWidth(jsi::Runtime&, std::string);
|
47
|
+
jsi::Value getScreenHeight(jsi::Runtime&, std::string);
|
48
|
+
jsi::Value getContentSizeCategory(jsi::Runtime&, std::string);
|
49
|
+
jsi::Value hasEnabledAdaptiveThemes(jsi::Runtime&, std::string);
|
50
|
+
jsi::Value getThemeName(jsi::Runtime&, std::string);
|
51
|
+
jsi::Value getCurrentBreakpoint(jsi::Runtime&, std::string);
|
52
|
+
jsi::Value getColorScheme(jsi::Runtime&, std::string);
|
53
|
+
jsi::Value getSortedBreakpointPairs(jsi::Runtime&, std::string);
|
54
|
+
jsi::Value setBreakpoints(jsi::Runtime&, std::string);
|
55
|
+
jsi::Value setActiveTheme(jsi::Runtime&, std::string);
|
56
|
+
jsi::Value updateTheme(jsi::Runtime&, std::string);
|
57
|
+
jsi::Value useAdaptiveThemes(jsi::Runtime&, std::string);
|
58
|
+
jsi::Value addPlugin(jsi::Runtime&, std::string);
|
59
|
+
jsi::Value removePlugin(jsi::Runtime&, std::string);
|
60
|
+
jsi::Value getEnabledPlugins(jsi::Runtime&, std::string);
|
61
|
+
jsi::Value getInsets(jsi::Runtime&, std::string);
|
62
|
+
jsi::Value getStatusBar(jsi::Runtime&, std::string);
|
63
|
+
jsi::Value getNavigationBar(jsi::Runtime&, std::string);
|
64
|
+
jsi::Value getPixelRatio(jsi::Runtime&, std::string);
|
65
|
+
jsi::Value getFontScale(jsi::Runtime&, std::string);
|
66
|
+
jsi::Value setRootBackgroundColor(jsi::Runtime&, std::string);
|
67
|
+
jsi::Value setImmersiveModeEnabled(jsi::Runtime&, std::string);
|
68
|
+
jsi::Value getIsRtl(jsi::Runtime&, std::string);
|
69
|
+
jsi::Value disableAnimatedInsets(jsi::Runtime&, std::string);
|
70
|
+
|
71
|
+
std::optional<jsi::Value> setThemes(jsi::Runtime&, const jsi::Value&);
|
72
|
+
|
73
|
+
jsi::Value get(jsi::Runtime&, const jsi::PropNameID&) override;
|
74
|
+
void set(jsi::Runtime&, const jsi::PropNameID&, const jsi::Value&) override;
|
75
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime&) override;
|
11
76
|
|
12
|
-
const std::string UnistylesDarkScheme = "dark";
|
13
|
-
const std::string UnistylesLightScheme = "light";
|
14
|
-
const std::string UnistylesUnspecifiedScheme = "unspecified";
|
15
|
-
|
16
|
-
const std::string UnistylesErrorBreakpointsCannotBeEmpty = "You are trying to register empty breakpoints object";
|
17
|
-
const std::string UnistylesErrorBreakpointsMustStartFromZero = "You are trying to register breakpoints that don't start from 0";
|
18
|
-
const std::string UnistylesErrorThemesCannotBeEmpty = "You are trying to register empty themes object";
|
19
|
-
|
20
|
-
struct Dimensions {
|
21
|
-
int width;
|
22
|
-
int height;
|
23
|
-
};
|
24
|
-
|
25
|
-
struct Insets {
|
26
|
-
int top;
|
27
|
-
int bottom;
|
28
|
-
int left;
|
29
|
-
int right;
|
30
|
-
};
|
31
|
-
|
32
|
-
class JSI_EXPORT UnistylesRuntime : public jsi::HostObject {
|
33
77
|
private:
|
34
|
-
std::
|
35
|
-
std::
|
36
|
-
std::function<void(std::string)> onContentSizeCategoryChangeCallback;
|
37
|
-
std::function<void()> onPluginChangeCallback;
|
38
|
-
|
39
|
-
Dimensions screen;
|
40
|
-
Dimensions statusBar;
|
41
|
-
Dimensions navigationBar;
|
42
|
-
Insets insets;
|
43
|
-
std::string colorScheme;
|
44
|
-
std::string contentSizeCategory;
|
45
|
-
|
46
|
-
public:
|
47
|
-
UnistylesRuntime(
|
48
|
-
Dimensions screen,
|
49
|
-
std::string colorScheme,
|
50
|
-
std::string contentSizeCategory,
|
51
|
-
Insets insets,
|
52
|
-
Dimensions statusBar,
|
53
|
-
Dimensions navigationBar
|
54
|
-
): screen(screen),
|
55
|
-
colorScheme(colorScheme),
|
56
|
-
contentSizeCategory(contentSizeCategory),
|
57
|
-
insets(insets),
|
58
|
-
statusBar(statusBar),
|
59
|
-
navigationBar(navigationBar) {}
|
60
|
-
|
61
|
-
bool hasAdaptiveThemes;
|
62
|
-
bool supportsAutomaticColorScheme;
|
63
|
-
|
64
|
-
std::string themeName;
|
65
|
-
std::string breakpoint;
|
66
|
-
std::vector<std::string> pluginNames;
|
67
|
-
std::vector<std::string> themes;
|
68
|
-
std::vector<std::pair<std::string, double>> sortedBreakpointPairs;
|
69
|
-
|
70
|
-
void onThemeChange(std::function<void(std::string)> callback) {
|
71
|
-
this->onThemeChangeCallback = callback;
|
72
|
-
}
|
73
|
-
|
74
|
-
void onLayoutChange(std::function<void(std::string breakpoint, std::string orientation, Dimensions& screen, Dimensions& statusBar, Insets& insets, Dimensions& navigationBar)> callback) {
|
75
|
-
this->onLayoutChangeCallback = callback;
|
76
|
-
}
|
77
|
-
|
78
|
-
void onPluginChange(std::function<void()> callback) {
|
79
|
-
this->onPluginChangeCallback = callback;
|
80
|
-
}
|
81
|
-
|
82
|
-
void onContentSizeCategoryChange(std::function<void(std::string)> callback) {
|
83
|
-
this->onContentSizeCategoryChangeCallback = callback;
|
84
|
-
}
|
85
|
-
|
86
|
-
jsi::Value get(jsi::Runtime&, const jsi::PropNameID& name) override;
|
87
|
-
void set(jsi::Runtime& runtime, const jsi::PropNameID& propNameId, const jsi::Value& value) override;
|
88
|
-
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override;
|
89
|
-
|
90
|
-
void handleScreenSizeChange(Dimensions& screen, Insets& insets, Dimensions& statusBar, Dimensions& navigationBar);
|
91
|
-
void handleAppearanceChange(std::string colorScheme);
|
92
|
-
void handleContentSizeCategoryChange(std::string contentSizeCategory);
|
93
|
-
|
94
|
-
jsi::Value getThemeOrFail(jsi::Runtime&);
|
95
|
-
std::string getBreakpointFromScreenWidth(int width, const std::vector<std::pair<std::string, double>>& sortedBreakpointEntries);
|
78
|
+
std::map<std::string, Getter> getters;
|
79
|
+
std::map<std::string, Setter> setters;
|
96
80
|
};
|
package/ios/UnistylesModule.h
CHANGED
@@ -1,13 +1,26 @@
|
|
1
1
|
#import <React/RCTBridgeModule.h>
|
2
2
|
#import <React/RCTEventEmitter.h>
|
3
|
+
#include <ReactCommon/CallInvoker.h>
|
4
|
+
|
3
5
|
#import <string>
|
4
6
|
|
5
7
|
#if TARGET_OS_OSX
|
6
8
|
#import "Platform_macOS.h"
|
7
9
|
#elif TARGET_OS_IOS
|
8
10
|
#import "Platform_iOS.h"
|
11
|
+
#elif TARGET_OS_TV
|
12
|
+
#import "Platform_tvOS.h"
|
13
|
+
#elif TARGET_OS_VISION
|
14
|
+
#import "Platform_visionOS.h"
|
9
15
|
#endif
|
10
16
|
|
17
|
+
@interface RCTBridge (BridgeWithRuntime)
|
18
|
+
|
19
|
+
- (void *)runtime;
|
20
|
+
- (std::shared_ptr<facebook::react::CallInvoker>)jsCallInvoker;
|
21
|
+
|
22
|
+
@end
|
23
|
+
|
11
24
|
@interface UnistylesModule : RCTEventEmitter<RCTBridgeModule>
|
12
25
|
|
13
26
|
@property (nonatomic, assign) BOOL hasListeners;
|