react-native-unistyles 3.0.0-rc.3 → 3.0.0-rc.5
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 +10 -8
- package/android/src/main/cxx/NativeUnistylesModule.cpp +3 -7
- package/android/src/main/cxx/NativeUnistylesModule.h +0 -4
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +1 -7
- package/cxx/core/UnistyleWrapper.h +4 -1
- package/cxx/core/UnistylesCommitShadowNode.h +0 -21
- package/cxx/core/UnistylesRegistry.cpp +45 -49
- package/cxx/core/UnistylesState.cpp +10 -0
- package/cxx/core/UnistylesState.h +3 -0
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +6 -1
- package/cxx/hybridObjects/HybridShadowRegistry.h +6 -0
- package/cxx/hybridObjects/HybridStyleSheet.cpp +13 -16
- package/cxx/hybridObjects/HybridStyleSheet.h +2 -7
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +8 -0
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -0
- package/cxx/parser/Parser.cpp +175 -110
- package/cxx/parser/Parser.h +1 -0
- package/cxx/shadowTree/ShadowTreeManager.cpp +36 -33
- package/cxx/shadowTree/ShadowTreeManager.h +0 -1
- package/ios/UnistylesModuleOnLoad.h +1 -5
- package/ios/UnistylesModuleOnLoad.mm +5 -13
- package/lib/commonjs/components/AdaptiveTheme.js +35 -0
- package/lib/commonjs/components/AdaptiveTheme.js.map +1 -0
- package/lib/commonjs/components/ApplyScopedTheme.js +19 -0
- package/lib/commonjs/components/ApplyScopedTheme.js.map +1 -0
- package/lib/commonjs/components/NamedTheme.js +31 -0
- package/lib/commonjs/components/NamedTheme.js.map +1 -0
- package/lib/commonjs/components/ScopedTheme.js +24 -20
- package/lib/commonjs/components/ScopedTheme.js.map +1 -1
- package/lib/commonjs/components/native/Image.js +1 -2
- package/lib/commonjs/components/native/Image.js.map +1 -1
- package/lib/commonjs/components/native/ImageBackground.js +1 -2
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.js +1 -2
- package/lib/commonjs/components/native/Pressable.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js +1 -2
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js +3 -3
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js +18 -31
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js +6 -21
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/getClassname.js +1 -2
- package/lib/commonjs/core/getClassname.js.map +1 -1
- package/lib/commonjs/core/parseBoxShadow.js +57 -0
- package/lib/commonjs/core/parseBoxShadow.js.map +1 -0
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js +1 -2
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +1 -2
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +1 -2
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mocks.js +5 -2
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/reanimated/index.js +20 -0
- package/lib/commonjs/reanimated/index.js.map +1 -0
- package/lib/commonjs/reanimated/useAnimatedTheme.js +22 -0
- package/lib/commonjs/reanimated/useAnimatedTheme.js.map +1 -0
- package/lib/commonjs/reanimated/useAnimatedTheme.native.js +24 -0
- package/lib/commonjs/reanimated/useAnimatedTheme.native.js.map +1 -0
- package/lib/commonjs/reanimated/variant/index.js +17 -0
- package/lib/commonjs/reanimated/variant/index.js.map +1 -0
- package/lib/commonjs/reanimated/variant/types.js +2 -0
- package/lib/commonjs/reanimated/variant/types.js.map +1 -0
- package/lib/commonjs/reanimated/variant/useAnimatedVariantColor.js +38 -0
- package/lib/commonjs/reanimated/variant/useAnimatedVariantColor.js.map +1 -0
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js +66 -0
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js.map +1 -0
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js +39 -0
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js.map +1 -0
- package/lib/commonjs/server/getServerUnistyles.js +1 -2
- package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/hydrateServerUnistyles.js +1 -2
- package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/resetServerUnistyles.js +1 -2
- package/lib/commonjs/server/resetServerUnistyles.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +6 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js +3 -1
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/utils.js +0 -3
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/create.js +2 -3
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/css/core.js +6 -1
- package/lib/commonjs/web/css/core.js.map +1 -1
- package/lib/commonjs/web/css/state.js +10 -7
- package/lib/commonjs/web/css/state.js.map +1 -1
- package/lib/commonjs/web/index.js +1 -2
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/listener.js +2 -0
- package/lib/commonjs/web/listener.js.map +1 -1
- package/lib/commonjs/web/runtime.js +15 -1
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +12 -4
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/state.js +1 -10
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/types.js +2 -0
- package/lib/commonjs/web/types.js.map +1 -1
- package/lib/commonjs/web/utils/createUnistylesRef.js +1 -2
- package/lib/commonjs/web/utils/createUnistylesRef.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +30 -3
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/commonjs/web-only/getWebProps.js +19 -0
- package/lib/commonjs/web-only/getWebProps.js.map +1 -0
- package/lib/commonjs/web-only/index.js +13 -0
- package/lib/commonjs/web-only/index.js.map +1 -0
- package/lib/module/components/AdaptiveTheme.js +29 -0
- package/lib/module/components/AdaptiveTheme.js.map +1 -0
- package/lib/module/components/ApplyScopedTheme.js +14 -0
- package/lib/module/components/ApplyScopedTheme.js.map +1 -0
- package/lib/module/components/NamedTheme.js +25 -0
- package/lib/module/components/NamedTheme.js.map +1 -0
- package/lib/module/components/ScopedTheme.js +24 -19
- package/lib/module/components/ScopedTheme.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js +3 -3
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +18 -30
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js +5 -19
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/parseBoxShadow.js +52 -0
- package/lib/module/core/parseBoxShadow.js.map +1 -0
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/mocks.js +5 -2
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/reanimated/index.js +5 -0
- package/lib/module/reanimated/index.js.map +1 -0
- package/lib/module/reanimated/useAnimatedTheme.js +17 -0
- package/lib/module/reanimated/useAnimatedTheme.js.map +1 -0
- package/lib/module/reanimated/useAnimatedTheme.native.js +19 -0
- package/lib/module/reanimated/useAnimatedTheme.native.js.map +1 -0
- package/lib/module/reanimated/variant/index.js +4 -0
- package/lib/module/reanimated/variant/index.js.map +1 -0
- package/lib/module/reanimated/variant/types.js +2 -0
- package/lib/module/reanimated/variant/types.js.map +1 -0
- package/lib/module/reanimated/variant/useAnimatedVariantColor.js +33 -0
- package/lib/module/reanimated/variant/useAnimatedVariantColor.js.map +1 -0
- package/lib/module/reanimated/variant/useUpdateVariantColor.js +61 -0
- package/lib/module/reanimated/variant/useUpdateVariantColor.js.map +1 -0
- package/lib/module/reanimated/variant/useUpdateVariantColor.native.js +34 -0
- package/lib/module/reanimated/variant/useUpdateVariantColor.native.js.map +1 -0
- package/lib/module/specs/ShadowRegistry/index.js +6 -1
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js +3 -1
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/utils.js +0 -3
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/create.js +1 -1
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/css/core.js +6 -1
- package/lib/module/web/css/core.js.map +1 -1
- package/lib/module/web/css/state.js +10 -7
- package/lib/module/web/css/state.js.map +1 -1
- package/lib/module/web/listener.js +2 -0
- package/lib/module/web/listener.js.map +1 -1
- package/lib/module/web/runtime.js +16 -2
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +13 -5
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/state.js +1 -10
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/types.js +1 -1
- package/lib/module/web/types.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +27 -2
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/module/web-only/getWebProps.js +14 -0
- package/lib/module/web-only/getWebProps.js.map +1 -0
- package/lib/module/web-only/index.js +4 -0
- package/lib/module/web-only/index.js.map +1 -0
- package/lib/typescript/plugin/src/consts.d.ts +17 -0
- package/lib/typescript/plugin/src/consts.d.ts.map +1 -0
- package/lib/typescript/repack-plugin/src/index.d.ts +18 -0
- package/lib/typescript/repack-plugin/src/index.d.ts.map +1 -0
- package/lib/typescript/repack-plugin/src/loader.d.ts +9 -0
- package/lib/typescript/repack-plugin/src/loader.d.ts.map +1 -0
- package/lib/typescript/src/components/AdaptiveTheme.d.ts +8 -0
- package/lib/typescript/src/components/AdaptiveTheme.d.ts.map +1 -0
- package/lib/typescript/src/components/ApplyScopedTheme.d.ts +7 -0
- package/lib/typescript/src/components/ApplyScopedTheme.d.ts.map +1 -0
- package/lib/typescript/src/components/NamedTheme.d.ts +10 -0
- package/lib/typescript/src/components/NamedTheme.d.ts.map +1 -0
- package/lib/typescript/src/components/ScopedTheme.d.ts +4 -0
- package/lib/typescript/src/components/ScopedTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Animated.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
- package/lib/typescript/src/core/parseBoxShadow.d.ts +11 -0
- package/lib/typescript/src/core/parseBoxShadow.d.ts.map +1 -0
- package/lib/typescript/src/core/passForwardRef.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/warn.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.native.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/index.d.ts +3 -0
- package/lib/typescript/src/reanimated/index.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts +4 -0
- package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts +4 -0
- package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/variant/index.d.ts +2 -0
- package/lib/typescript/src/reanimated/variant/index.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/variant/types.d.ts +10 -0
- package/lib/typescript/src/reanimated/variant/types.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/variant/useAnimatedVariantColor.d.ts +3 -0
- package/lib/typescript/src/reanimated/variant/useAnimatedVariantColor.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts +6 -0
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts.map +1 -0
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts +6 -0
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts.map +1 -0
- package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/server/serialize.d.ts.map +1 -1
- package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +1 -0
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +2 -0
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +2 -0
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/shadow/textShadow.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/style.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/css/core.d.ts.map +1 -1
- package/lib/typescript/src/web/css/state.d.ts +2 -1
- package/lib/typescript/src/web/css/state.d.ts.map +1 -1
- package/lib/typescript/src/web/css/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/listener.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +2 -0
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts +4 -2
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/types.d.ts +6 -0
- package/lib/typescript/src/web/types.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/createUnistylesRef.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts +7 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/lib/typescript/src/web/variants.d.ts.map +1 -1
- package/lib/typescript/src/web-only/getWebProps.d.ts +7 -0
- package/lib/typescript/src/web-only/getWebProps.d.ts.map +1 -0
- package/lib/typescript/src/web-only/index.d.ts +2 -0
- package/lib/typescript/src/web-only/index.d.ts.map +1 -0
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +1 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +2 -0
- package/package.json +57 -25
- package/plugin/index.d.ts +6 -5
- package/plugin/index.js +103 -99
- package/reanimated/package.json +6 -0
- package/repack-plugin/index.d.ts +19 -0
- package/repack-plugin/index.js +149 -0
- package/src/components/AdaptiveTheme.tsx +34 -0
- package/src/components/ApplyScopedTheme.tsx +17 -0
- package/src/components/NamedTheme.tsx +33 -0
- package/src/components/ScopedTheme.tsx +42 -22
- package/src/core/createUnistylesElement.native.tsx +21 -31
- package/src/core/createUnistylesElement.tsx +3 -3
- package/src/core/createUnistylesImageBackground.tsx +7 -22
- package/src/core/parseBoxShadow.ts +87 -0
- package/src/core/withUnistyles/withUnistyles.native.tsx +1 -0
- package/src/index.ts +8 -0
- package/src/mocks.ts +5 -2
- package/src/reanimated/index.ts +2 -0
- package/src/reanimated/useAnimatedTheme.native.ts +21 -0
- package/src/reanimated/useAnimatedTheme.ts +19 -0
- package/src/reanimated/variant/index.ts +1 -0
- package/src/reanimated/variant/types.ts +14 -0
- package/src/reanimated/variant/useAnimatedVariantColor.ts +38 -0
- package/src/reanimated/variant/useUpdateVariantColor.native.ts +38 -0
- package/src/reanimated/variant/useUpdateVariantColor.ts +81 -0
- package/src/specs/ShadowRegistry/index.ts +7 -1
- package/src/specs/StyleSheet/index.ts +5 -2
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +2 -0
- package/src/utils.ts +1 -3
- package/src/web/create.ts +1 -1
- package/src/web/css/core.ts +9 -1
- package/src/web/css/state.ts +10 -8
- package/src/web/listener.ts +2 -0
- package/src/web/runtime.ts +23 -2
- package/src/web/shadowRegistry.ts +15 -6
- package/src/web/state.ts +7 -17
- package/src/web/types.ts +12 -4
- package/src/web/utils/unistyle.ts +38 -3
- package/src/web-only/getWebProps.ts +18 -0
- package/src/web-only/index.ts +2 -0
- package/web/package.json +6 -0
- package/cxx/core/UnistylesCommitHook.cpp +0 -52
- package/cxx/core/UnistylesCommitHook.h +0 -27
- package/cxx/core/UnistylesMountHook.cpp +0 -28
- package/cxx/core/UnistylesMountHook.h +0 -24
- package/lib/module/package.json +0 -1
package/cxx/parser/Parser.cpp
CHANGED
@@ -213,113 +213,115 @@ void parser::Parser::rebuildUnistyleWithVariants(jsi::Runtime& rt, std::shared_p
|
|
213
213
|
}
|
214
214
|
|
215
215
|
// rebuild all unistyles that are affected by platform event
|
216
|
-
void parser::Parser::rebuildUnistylesInDependencyMap(
|
217
|
-
|
218
|
-
|
219
|
-
std::
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
216
|
+
void parser::Parser::rebuildUnistylesInDependencyMap(
|
217
|
+
jsi::Runtime& rt,
|
218
|
+
DependencyMap& dependencyMap,
|
219
|
+
std::vector<std::shared_ptr<core::StyleSheet>>& styleSheets,
|
220
|
+
std::optional<UnistylesNativeMiniRuntime> maybeMiniRuntime
|
221
|
+
) {
|
222
|
+
std::unordered_map<std::shared_ptr<StyleSheet>, jsi::Value> parsedStyleSheetsWithDefaultTheme;
|
223
|
+
std::unordered_map<std::string, std::unordered_map<std::shared_ptr<StyleSheet>, jsi::Value>> parsedStyleSheetsWithScopedTheme;
|
224
|
+
std::unordered_set<std::shared_ptr<core::Unistyle>> parsedUnistyles;
|
225
|
+
|
226
|
+
// Parse all stylesheets that depend on changes
|
227
|
+
for (const auto& styleSheet : styleSheets) {
|
228
|
+
parsedStyleSheetsWithDefaultTheme.emplace(
|
229
|
+
styleSheet,
|
230
|
+
this->unwrapStyleSheet(rt, styleSheet, maybeMiniRuntime)
|
231
|
+
);
|
224
232
|
}
|
225
233
|
|
226
|
-
//
|
234
|
+
// Parse all visible Unistyles managed by Unistyle
|
227
235
|
for (auto& [shadowNode, unistyles] : dependencyMap) {
|
228
|
-
auto styleSheet = unistyles.
|
236
|
+
auto styleSheet = unistyles.front()->unistyle->parent;
|
229
237
|
|
230
|
-
//
|
231
|
-
if (styleSheet
|
232
|
-
parsedStyleSheetsWithDefaultTheme.emplace(
|
238
|
+
// Stylesheet may be optional for exotic unistyles
|
239
|
+
if (styleSheet && parsedStyleSheetsWithDefaultTheme.find(styleSheet) == parsedStyleSheetsWithDefaultTheme.end()) {
|
240
|
+
parsedStyleSheetsWithDefaultTheme.emplace(
|
241
|
+
styleSheet,
|
242
|
+
this->unwrapStyleSheet(rt, styleSheet, maybeMiniRuntime)
|
243
|
+
);
|
233
244
|
}
|
234
245
|
|
235
246
|
for (auto& unistyleData : unistyles) {
|
236
247
|
auto& unistyle = unistyleData->unistyle;
|
237
248
|
|
238
|
-
//
|
249
|
+
// For RN styles or inline styles, compute styles only once
|
239
250
|
if (unistyle->styleKey == helpers::EXOTIC_STYLE_KEY) {
|
240
251
|
if (!unistyleData->parsedStyle.has_value()) {
|
241
252
|
unistyleData->parsedStyle = jsi::Value(rt, unistyle->rawValue).asObject(rt);
|
242
|
-
|
243
|
-
if (!parsedUnistyles.contains(unistyle)) {
|
244
|
-
parsedUnistyles.emplace(unistyle, true);
|
245
|
-
}
|
253
|
+
parsedUnistyles.insert(unistyle);
|
246
254
|
}
|
247
255
|
|
248
256
|
continue;
|
249
257
|
}
|
250
258
|
|
251
|
-
//
|
259
|
+
// Reference Unistyles StyleSheet as we may mix them for one style
|
252
260
|
auto unistyleStyleSheet = unistyle->parent;
|
253
261
|
|
254
|
-
//
|
255
|
-
if (unistyleStyleSheet
|
256
|
-
parsedStyleSheetsWithDefaultTheme.emplace(
|
262
|
+
// We may hit now other StyleSheets that are referenced from affected nodes
|
263
|
+
if (unistyleStyleSheet && parsedStyleSheetsWithDefaultTheme.find(unistyleStyleSheet) == parsedStyleSheetsWithDefaultTheme.end()) {
|
264
|
+
parsedStyleSheetsWithDefaultTheme.emplace(
|
265
|
+
unistyleStyleSheet,
|
266
|
+
this->unwrapStyleSheet(rt, unistyleStyleSheet, maybeMiniRuntime)
|
267
|
+
);
|
257
268
|
}
|
258
269
|
|
259
270
|
// StyleSheet might have styles that are not affected
|
260
|
-
|
271
|
+
auto& parsedSheetValue = parsedStyleSheetsWithDefaultTheme[unistyleStyleSheet];
|
272
|
+
auto parsedSheetObj = parsedSheetValue.asObject(rt);
|
273
|
+
|
274
|
+
if (!parsedSheetObj.hasProperty(rt, unistyle->styleKey.c_str())) {
|
261
275
|
continue;
|
262
276
|
}
|
263
277
|
|
264
|
-
//
|
278
|
+
// For scoped themes we need to parse unistyle exclusively
|
265
279
|
if (unistyleData->scopedTheme.has_value()) {
|
266
|
-
|
267
|
-
|
268
|
-
if (unistyleData->dynamicFunctionMetadata.has_value()) {
|
269
|
-
arguments = unistyleData->dynamicFunctionMetadata.value();
|
270
|
-
}
|
280
|
+
auto& scopedThemeName = unistyleData->scopedTheme.value();
|
281
|
+
auto& scopedThemeMap = parsedStyleSheetsWithScopedTheme[scopedThemeName];
|
271
282
|
|
272
|
-
|
273
|
-
auto
|
283
|
+
jsi::Value parsedStyleSheet = jsi::Value::undefined();
|
284
|
+
auto it = scopedThemeMap.find(unistyle->parent);
|
274
285
|
|
275
|
-
|
276
|
-
|
277
|
-
if (parsedStyleSheetsWithScopedTheme[scopedThemeName].contains(unistyle->parent)) {
|
278
|
-
parsedStyleSheet = jsi::Value(rt, parsedStyleSheetsWithScopedTheme[scopedThemeName][unistyle->parent]);
|
279
|
-
}
|
286
|
+
if (it != scopedThemeMap.end()) {
|
287
|
+
parsedStyleSheet = jsi::Value(rt, it->second);
|
280
288
|
}
|
281
289
|
|
282
|
-
// if not, let's build it
|
283
290
|
if (parsedStyleSheet.isUndefined()) {
|
284
|
-
parsedStyleSheet = this->getParsedStyleSheetForScopedTheme(rt, unistyle,
|
285
|
-
|
286
|
-
if (!parsedStyleSheetsWithScopedTheme.contains(scopedThemeName)) {
|
287
|
-
parsedStyleSheetsWithScopedTheme.emplace(
|
288
|
-
scopedThemeName,
|
289
|
-
std::unordered_map<std::shared_ptr<StyleSheet>, jsi::Value>{}
|
290
|
-
);
|
291
|
-
}
|
292
|
-
|
293
|
-
parsedStyleSheetsWithScopedTheme[scopedThemeName].emplace(
|
291
|
+
parsedStyleSheet = this->getParsedStyleSheetForScopedTheme(rt, unistyle, scopedThemeName);
|
292
|
+
scopedThemeMap.emplace(
|
294
293
|
unistyle->parent,
|
295
294
|
jsi::Value(rt, parsedStyleSheet)
|
296
295
|
);
|
297
296
|
}
|
298
297
|
|
299
|
-
this->rebuildUnistyleWithScopedTheme(
|
300
|
-
rt,
|
301
|
-
parsedStyleSheet,
|
302
|
-
unistyleData
|
303
|
-
);
|
298
|
+
this->rebuildUnistyleWithScopedTheme(rt, parsedStyleSheet, unistyleData);
|
304
299
|
} else {
|
305
|
-
unistyle->rawValue =
|
306
|
-
|
300
|
+
unistyle->rawValue = parsedSheetObj
|
301
|
+
.getProperty(rt, unistyle->styleKey.c_str())
|
302
|
+
.asObject(rt);
|
303
|
+
this->rebuildUnistyle(
|
304
|
+
rt, unistyle, unistyleData->variants,
|
305
|
+
unistyleData->dynamicFunctionMetadata
|
306
|
+
);
|
307
307
|
unistyleData->parsedStyle = jsi::Value(rt, unistyle->parsedStyle.value()).asObject(rt);
|
308
308
|
unistyle->isDirty = true;
|
309
309
|
}
|
310
310
|
|
311
|
-
|
312
|
-
parsedUnistyles.emplace(unistyle, true);
|
313
|
-
}
|
311
|
+
parsedUnistyles.insert(unistyle);
|
314
312
|
}
|
315
313
|
}
|
316
314
|
|
317
|
-
//
|
318
|
-
|
319
|
-
|
315
|
+
// Parse whatever left in StyleSheets to be later accessible
|
316
|
+
for (const auto& styleSheet : styleSheets) {
|
317
|
+
auto& parsedSheetValue = parsedStyleSheetsWithDefaultTheme[styleSheet];
|
318
|
+
auto parsedSheetObj = parsedSheetValue.asObject(rt);
|
319
|
+
|
320
320
|
for (auto& [_, unistyle] : styleSheet->unistyles) {
|
321
321
|
if (!parsedUnistyles.contains(unistyle)) {
|
322
|
-
unistyle->rawValue =
|
322
|
+
unistyle->rawValue = parsedSheetObj
|
323
|
+
.getProperty(rt, unistyle->styleKey.c_str())
|
324
|
+
.asObject(rt);
|
323
325
|
unistyle->isDirty = true;
|
324
326
|
}
|
325
327
|
}
|
@@ -372,11 +374,12 @@ void parser::Parser::rebuildUnistyle(jsi::Runtime& rt, Unistyle::Shared unistyle
|
|
372
374
|
void parser::Parser::rebuildShadowLeafUpdates(jsi::Runtime& rt, core::DependencyMap& dependencyMap) {
|
373
375
|
auto& registry = core::UnistylesRegistry::get();
|
374
376
|
|
375
|
-
registry.trafficController.withLock([this, &rt, &dependencyMap, ®istry](){
|
377
|
+
registry.trafficController.withLock([this, &rt, &dependencyMap, ®istry]() {
|
376
378
|
shadow::ShadowLeafUpdates updates;
|
377
|
-
|
379
|
+
updates.reserve(dependencyMap.size());
|
380
|
+
|
378
381
|
for (const auto& [shadowNode, unistyles] : dependencyMap) {
|
379
|
-
//
|
382
|
+
// Parse string colors (e.g., "#000000") to int representation
|
380
383
|
auto rawProps = this->parseStylesToShadowTreeStyles(rt, unistyles);
|
381
384
|
|
382
385
|
updates.emplace(shadowNode, std::move(rawProps));
|
@@ -387,6 +390,7 @@ void parser::Parser::rebuildShadowLeafUpdates(jsi::Runtime& rt, core::Dependency
|
|
387
390
|
});
|
388
391
|
}
|
389
392
|
|
393
|
+
|
390
394
|
// first level of StyleSheet, we can expect here different properties than on second level
|
391
395
|
// eg. variants, compoundVariants, mq, breakpoints etc.
|
392
396
|
jsi::Object parser::Parser::parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared unistyle, std::optional<Variants> variants) {
|
@@ -420,6 +424,13 @@ jsi::Object parser::Parser::parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared u
|
|
420
424
|
return;
|
421
425
|
}
|
422
426
|
|
427
|
+
// special case as we need to convert it to jsi::Array<jsi::Object>
|
428
|
+
if (propertyName == "boxShadow" && propertyValue.isString()) {
|
429
|
+
parsedStyle.setProperty(rt, jsi::PropNameID::forUtf8(rt, propertyName), parseBoxShadowString(rt, propertyValue.asString(rt).utf8(rt)));
|
430
|
+
|
431
|
+
return;
|
432
|
+
}
|
433
|
+
|
423
434
|
// primitives
|
424
435
|
if (propertyValue.isNumber() || propertyValue.isString() || propertyValue.isUndefined() || propertyValue.isNull()) {
|
425
436
|
parsedStyle.setProperty(rt, jsi::PropNameID::forUtf8(rt, propertyName), propertyValue);
|
@@ -592,7 +603,7 @@ jsi::Value parser::Parser::parseTransforms(jsi::Runtime& rt, Unistyle::Shared un
|
|
592
603
|
jsi::Value parser::Parser::parseBoxShadow(jsi::Runtime &rt, Unistyle::Shared unistyle, jsi::Object &obj) {
|
593
604
|
std::vector<jsi::Value> parsedBoxShadows{};
|
594
605
|
|
595
|
-
parsedBoxShadows.reserve(
|
606
|
+
parsedBoxShadows.reserve(1);
|
596
607
|
|
597
608
|
helpers::iterateJSIArray(rt, obj.asArray(rt), [&](size_t i, jsi::Value& value){
|
598
609
|
if (!value.isObject()) {
|
@@ -614,6 +625,13 @@ jsi::Value parser::Parser::parseBoxShadow(jsi::Runtime &rt, Unistyle::Shared uni
|
|
614
625
|
return result;
|
615
626
|
}
|
616
627
|
|
628
|
+
jsi::Array parser::Parser::parseBoxShadowString(jsi::Runtime& rt, std::string&& boxShadowString) {
|
629
|
+
auto& registry = core::UnistylesRegistry::get();
|
630
|
+
auto& state = registry.getState(rt);
|
631
|
+
|
632
|
+
return state.parseBoxShadowString(std::move(boxShadowString));
|
633
|
+
}
|
634
|
+
|
617
635
|
// eg. [{ brightness: 0.5 }, { opacity: 0.25 }]
|
618
636
|
jsi::Value parser::Parser::parseFilters(jsi::Runtime &rt, Unistyle::Shared unistyle, jsi::Object &obj) {
|
619
637
|
std::vector<jsi::Value> parsedFilters{};
|
@@ -863,8 +881,16 @@ jsi::Value parser::Parser::parseSecondLevel(jsi::Runtime &rt, Unistyle::Shared u
|
|
863
881
|
jsi::Object parsedStyle = jsi::Object(rt);
|
864
882
|
|
865
883
|
helpers::enumerateJSIObject(rt, nestedObjectStyle, [&](const std::string& propertyName, jsi::Value& propertyValue){
|
866
|
-
//
|
867
|
-
|
884
|
+
// special case as we need to convert it to jsi::Array<jsi::Object>
|
885
|
+
// possible with variants and compoundVariants
|
886
|
+
if (propertyName == "boxShadow" && propertyValue.isString()) {
|
887
|
+
parsedStyle.setProperty(rt, jsi::PropNameID::forUtf8(rt, propertyName), parseBoxShadowString(rt, propertyValue.asString(rt).utf8(rt)));
|
888
|
+
|
889
|
+
return;
|
890
|
+
}
|
891
|
+
|
892
|
+
// primitives, bool is possible for boxShadow inset
|
893
|
+
if (propertyValue.isString() || propertyValue.isNumber() || propertyValue.isUndefined() || propertyValue.isNull() || propertyValue.isBool()) {
|
868
894
|
parsedStyle.setProperty(rt, propertyName.c_str(), propertyValue);
|
869
895
|
|
870
896
|
return;
|
@@ -884,13 +910,13 @@ jsi::Value parser::Parser::parseSecondLevel(jsi::Runtime &rt, Unistyle::Shared u
|
|
884
910
|
|
885
911
|
return;
|
886
912
|
}
|
887
|
-
|
913
|
+
|
888
914
|
auto isArray = nestedObjectStyle.isArray(rt);
|
889
|
-
|
915
|
+
|
890
916
|
if (!isArray) {
|
891
917
|
parsedStyle.setProperty(rt, propertyName.c_str(), this->getValueFromBreakpoints(rt, unistyle, nestedObjectStyle));
|
892
918
|
}
|
893
|
-
|
919
|
+
|
894
920
|
// possible with variants and compoundVariants
|
895
921
|
if (propertyName == "transform") {
|
896
922
|
parsedStyle.setProperty(rt, propertyName.c_str(), parseTransforms(rt, unistyle, nestedObjectStyle));
|
@@ -928,69 +954,108 @@ jsi::Value parser::Parser::parseSecondLevel(jsi::Runtime &rt, Unistyle::Shared u
|
|
928
954
|
|
929
955
|
// convert unistyles to folly with int colors
|
930
956
|
folly::dynamic parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, const std::vector<std::shared_ptr<UnistyleData>>& unistyles) {
|
931
|
-
jsi::Object convertedStyles
|
957
|
+
jsi::Object convertedStyles(rt);
|
932
958
|
auto& state = core::UnistylesRegistry::get().getState(rt);
|
933
959
|
|
934
960
|
for (const auto& unistyleData : unistyles) {
|
935
|
-
// this can happen for exotic stylesheets
|
936
961
|
if (!unistyleData->parsedStyle.has_value()) {
|
937
962
|
continue;
|
938
963
|
}
|
939
964
|
|
940
|
-
helpers::enumerateJSIObject(
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
if (!objValue.isArray(rt)) {
|
952
|
-
return convertedStyles.setProperty(rt, propertyName.c_str(), propertyValue);
|
953
|
-
}
|
954
|
-
|
955
|
-
// parse nested arrays like boxShadow
|
956
|
-
auto arrValue = objValue.asArray(rt);
|
957
|
-
auto parsedArray = jsi::Array(rt, arrValue.length(rt));
|
965
|
+
helpers::enumerateJSIObject(
|
966
|
+
rt,
|
967
|
+
unistyleData->parsedStyle.value(),
|
968
|
+
[this, &rt, &state, &convertedStyles](const std::string& propertyName, jsi::Value& propertyValue) {
|
969
|
+
if (this->isColor(propertyName)) {
|
970
|
+
convertedStyles.setProperty(
|
971
|
+
rt,
|
972
|
+
propertyName.c_str(),
|
973
|
+
jsi::Value(state.parseColor(propertyValue))
|
974
|
+
);
|
958
975
|
|
959
|
-
|
960
|
-
|
961
|
-
jsi::Object obj = jsi::Object(rt);
|
976
|
+
return;
|
977
|
+
}
|
962
978
|
|
963
|
-
|
964
|
-
|
965
|
-
|
979
|
+
if (!propertyValue.isObject()) {
|
980
|
+
convertedStyles.setProperty(
|
981
|
+
rt,
|
982
|
+
propertyName.c_str(),
|
983
|
+
propertyValue
|
984
|
+
);
|
966
985
|
|
967
|
-
|
968
|
-
|
986
|
+
return;
|
987
|
+
}
|
969
988
|
|
970
|
-
|
971
|
-
});
|
989
|
+
jsi::Object objValue = propertyValue.asObject(rt);
|
972
990
|
|
973
|
-
|
991
|
+
if (!objValue.isArray(rt)) {
|
992
|
+
convertedStyles.setProperty(
|
993
|
+
rt,
|
994
|
+
propertyName.c_str(),
|
995
|
+
propertyValue
|
996
|
+
);
|
974
997
|
|
975
998
|
return;
|
976
999
|
}
|
977
1000
|
|
978
|
-
|
979
|
-
|
1001
|
+
// parse nested arrays like boxShadow
|
1002
|
+
jsi::Array arrValue = objValue.asArray(rt);
|
1003
|
+
size_t arrLen = arrValue.length(rt);
|
1004
|
+
jsi::Array parsedArray(rt, arrLen);
|
980
1005
|
|
981
|
-
|
982
|
-
|
1006
|
+
helpers::iterateJSIArray(
|
1007
|
+
rt,
|
1008
|
+
arrValue,
|
1009
|
+
[this, &rt, &state, &propertyName, &parsedArray](size_t i, jsi::Value& nestedValue) {
|
1010
|
+
if (nestedValue.isObject()) {
|
1011
|
+
jsi::Object obj(rt);
|
1012
|
+
|
1013
|
+
helpers::enumerateJSIObject(
|
1014
|
+
rt,
|
1015
|
+
nestedValue.asObject(rt),
|
1016
|
+
[this, &rt, &state, &obj](const std::string& nestedPropName, jsi::Value& nestedPropValue) {
|
1017
|
+
if (this->isColor(nestedPropName)) {
|
1018
|
+
obj.setProperty(
|
1019
|
+
rt,
|
1020
|
+
nestedPropName.c_str(),
|
1021
|
+
state.parseColor(nestedPropValue)
|
1022
|
+
);
|
1023
|
+
} else {
|
1024
|
+
obj.setProperty(
|
1025
|
+
rt,
|
1026
|
+
nestedPropName.c_str(),
|
1027
|
+
nestedPropValue
|
1028
|
+
);
|
1029
|
+
}
|
1030
|
+
}
|
1031
|
+
);
|
1032
|
+
|
1033
|
+
parsedArray.setValueAtIndex(rt, i, obj);
|
1034
|
+
|
1035
|
+
return;
|
1036
|
+
}
|
983
1037
|
|
984
|
-
|
985
|
-
|
1038
|
+
if (this->isColor(propertyName)) {
|
1039
|
+
parsedArray.setValueAtIndex(
|
1040
|
+
rt,
|
1041
|
+
i,
|
1042
|
+
jsi::Value(state.parseColor(nestedValue))
|
1043
|
+
);
|
1044
|
+
} else {
|
1045
|
+
parsedArray.setValueAtIndex(rt, i, nestedValue);
|
1046
|
+
}
|
1047
|
+
}
|
1048
|
+
);
|
986
1049
|
|
987
|
-
|
988
|
-
|
1050
|
+
convertedStyles.setProperty(rt, propertyName.c_str(), parsedArray);
|
1051
|
+
}
|
1052
|
+
);
|
989
1053
|
}
|
990
1054
|
|
991
|
-
return jsi::dynamicFromValue(rt,
|
1055
|
+
return jsi::dynamicFromValue(rt, jsi::Value(rt, convertedStyles));
|
992
1056
|
}
|
993
1057
|
|
1058
|
+
|
994
1059
|
// check is styleKey contains color
|
995
1060
|
bool parser::Parser::isColor(const std::string& propertyName) {
|
996
1061
|
std::string str = propertyName;
|
package/cxx/parser/Parser.h
CHANGED
@@ -40,6 +40,7 @@ private:
|
|
40
40
|
std::vector<UnistyleDependency> parseDependencies(jsi::Runtime &rt, jsi::Object&& dependencies);
|
41
41
|
jsi::Value parseTransforms(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj);
|
42
42
|
jsi::Value parseBoxShadow(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj);
|
43
|
+
jsi::Array parseBoxShadowString(jsi::Runtime& rt, std::string&& boxShadowString);
|
43
44
|
jsi::Value parseFilters(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj);
|
44
45
|
jsi::Value getValueFromBreakpoints(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj);
|
45
46
|
jsi::Object parseVariants(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj, Variants& variants);
|
@@ -8,7 +8,7 @@ using AffectedNodes = std::unordered_map<const ShadowNodeFamily*, std::unordered
|
|
8
8
|
|
9
9
|
void shadow::ShadowTreeManager::updateShadowTree(const ShadowTreeRegistry& shadowTreeRegistry) {
|
10
10
|
auto& registry = core::UnistylesRegistry::get();
|
11
|
-
|
11
|
+
|
12
12
|
registry.trafficController.withLock([&](){
|
13
13
|
auto updates = registry.trafficController.getUpdates();
|
14
14
|
|
@@ -20,20 +20,14 @@ void shadow::ShadowTreeManager::updateShadowTree(const ShadowTreeRegistry& shado
|
|
20
20
|
// we could iterate via updates and create multiple commits
|
21
21
|
// but it can cause performance issues for hundreds of nodes
|
22
22
|
// so let's mutate Shadow Tree in single transaction
|
23
|
-
auto transaction = [&](const RootShadowNode& oldRootShadowNode) {
|
23
|
+
auto transaction = [&updates](const RootShadowNode& oldRootShadowNode) {
|
24
24
|
auto affectedNodes = shadow::ShadowTreeManager::findAffectedNodes(oldRootShadowNode, updates);
|
25
|
-
|
25
|
+
|
26
|
+
return std::static_pointer_cast<RootShadowNode>(shadow::ShadowTreeManager::cloneShadowTree(
|
26
27
|
oldRootShadowNode,
|
27
28
|
updates,
|
28
29
|
affectedNodes
|
29
30
|
));
|
30
|
-
|
31
|
-
// set unistyles trait
|
32
|
-
auto unistylesRootNode = std::reinterpret_pointer_cast<core::UnistylesCommitShadowNode>(newRootNode);
|
33
|
-
|
34
|
-
unistylesRootNode->addUnistylesCommitTrait();
|
35
|
-
|
36
|
-
return newRootNode;
|
37
31
|
};
|
38
32
|
|
39
33
|
// commit once!
|
@@ -71,18 +65,17 @@ void shadow::ShadowTreeManager::updateShadowTree(const ShadowTreeRegistry& shado
|
|
71
65
|
AffectedNodes shadow::ShadowTreeManager::findAffectedNodes(const RootShadowNode& rootNode, ShadowLeafUpdates& updates) {
|
72
66
|
AffectedNodes affectedNodes;
|
73
67
|
|
74
|
-
|
75
|
-
|
76
|
-
const auto& [family, _] = pair;
|
77
|
-
const auto familyAncestors = family->getAncestors(rootNode);
|
68
|
+
for (const auto& [family, _] : updates) {
|
69
|
+
auto familyAncestors = family->getAncestors(rootNode);
|
78
70
|
|
79
|
-
for (
|
71
|
+
for (auto it = familyAncestors.rbegin(); it != familyAncestors.rend(); ++it) {
|
72
|
+
const auto& [parentNode, index] = *it;
|
80
73
|
const auto parentFamily = &parentNode.get().getFamily();
|
81
|
-
|
74
|
+
auto [setIt, inserted] = affectedNodes.try_emplace(parentFamily, std::unordered_set<int>{});
|
82
75
|
|
83
|
-
|
76
|
+
setIt->second.insert(index);
|
84
77
|
}
|
85
|
-
}
|
78
|
+
}
|
86
79
|
|
87
80
|
return affectedNodes;
|
88
81
|
}
|
@@ -93,44 +86,54 @@ ShadowNode::Unshared shadow::ShadowTreeManager::cloneShadowTree(const ShadowNode
|
|
93
86
|
const auto family = &shadowNode.getFamily();
|
94
87
|
const auto rawPropsIt = updates.find(family);
|
95
88
|
const auto childrenIt = affectedNodes.find(family);
|
96
|
-
auto children = shadowNode.getChildren();
|
97
89
|
|
98
|
-
//
|
90
|
+
// Only copy children if we need to update them
|
91
|
+
std::shared_ptr<ShadowNode::ListOfShared> childrenPtr;
|
92
|
+
const auto& originalChildren = shadowNode.getChildren();
|
93
|
+
|
99
94
|
if (childrenIt != affectedNodes.end()) {
|
100
|
-
|
95
|
+
auto children = originalChildren;
|
96
|
+
|
101
97
|
for (const auto index : childrenIt->second) {
|
102
98
|
children[index] = cloneShadowTree(*children[index], updates, affectedNodes);
|
103
99
|
}
|
100
|
+
|
101
|
+
childrenPtr = std::make_shared<ShadowNode::ListOfShared>(std::move(children));
|
102
|
+
} else {
|
103
|
+
childrenPtr = std::make_shared<ShadowNode::ListOfShared>(originalChildren);
|
104
104
|
}
|
105
105
|
|
106
106
|
Props::Shared updatedProps = nullptr;
|
107
107
|
|
108
|
-
// clone props for our target shadow node and place fresh RawProps
|
109
108
|
if (rawPropsIt != updates.end()) {
|
109
|
+
const auto& componentDescriptor = shadowNode.getComponentDescriptor();
|
110
|
+
const auto& props = shadowNode.getProps();
|
111
|
+
|
110
112
|
PropsParserContext propsParserContext{
|
111
113
|
shadowNode.getSurfaceId(),
|
112
114
|
*shadowNode.getContextContainer()
|
113
115
|
};
|
114
116
|
|
115
|
-
|
116
|
-
// first of all Android doesn't like nullish props (they work perfectly fine on iOS)
|
117
|
-
// second of all Android props MUST be constructed from previous props, otherwise RawProps::~RawProps error occurs
|
118
|
-
// Meta wants to remove shadowNode.getProps()->rawProps, but for now it's the only viable solution
|
117
|
+
folly::dynamic newProps;
|
119
118
|
#ifdef ANDROID
|
120
|
-
auto safeProps = rawPropsIt->second == nullptr
|
121
|
-
|
119
|
+
auto safeProps = rawPropsIt->second == nullptr
|
120
|
+
? folly::dynamic::object()
|
121
|
+
: rawPropsIt->second;
|
122
|
+
newProps = folly::dynamic::merge(props->rawProps, safeProps);
|
122
123
|
#else
|
123
|
-
|
124
|
+
newProps = rawPropsIt->second;
|
124
125
|
#endif
|
125
126
|
|
126
|
-
updatedProps =
|
127
|
-
|
128
|
-
|
127
|
+
updatedProps = componentDescriptor.cloneProps(
|
128
|
+
propsParserContext,
|
129
|
+
props,
|
130
|
+
RawProps(newProps)
|
131
|
+
);
|
129
132
|
}
|
130
133
|
|
131
134
|
return shadowNode.clone({
|
132
135
|
updatedProps ? updatedProps : ShadowNodeFragment::propsPlaceholder(),
|
133
|
-
|
136
|
+
childrenPtr,
|
134
137
|
shadowNode.getState()
|
135
138
|
});
|
136
139
|
}
|
@@ -6,13 +6,9 @@
|
|
6
6
|
|
7
7
|
#import <React/RCTEventEmitter.h>
|
8
8
|
#import "TurboUnistyles/TurboUnistyles.h"
|
9
|
-
#import <React/RCTSurfacePresenter.h>
|
10
|
-
#import <React/RCTScheduler.h>
|
11
|
-
#import <React/RCTCallInvoker.h>
|
12
|
-
#import <React/RCTCallInvokerModule.h>
|
13
9
|
#import <ReactCommon/RCTTurboModuleWithJSIBindings.h>
|
14
10
|
|
15
|
-
@interface UnistylesModule: RCTEventEmitter<NativeTurboUnistylesSpec
|
11
|
+
@interface UnistylesModule: RCTEventEmitter<NativeTurboUnistylesSpec>
|
16
12
|
@end
|
17
13
|
|
18
14
|
@interface UnistylesModule()<RCTTurboModuleWithJSIBindings>
|
@@ -10,18 +10,11 @@ using namespace margelo::nitro;
|
|
10
10
|
|
11
11
|
RCT_EXPORT_MODULE(Unistyles)
|
12
12
|
|
13
|
-
__weak RCTSurfacePresenter* _surfacePresenter;
|
14
|
-
@synthesize callInvoker = _callInvoker;
|
15
|
-
|
16
13
|
+ (BOOL)requiresMainQueueSetup {
|
17
14
|
return YES;
|
18
15
|
}
|
19
16
|
|
20
|
-
- (void)
|
21
|
-
_surfacePresenter = surfacePresenter;
|
22
|
-
}
|
23
|
-
|
24
|
-
- (void)installJSIBindingsWithRuntime:(jsi::Runtime&)rt {
|
17
|
+
- (void)installJSIBindingsWithRuntime:(jsi::Runtime&)rt callInvoker:(const std::shared_ptr<facebook::react::CallInvoker> &)callInvoker {
|
25
18
|
// function is called on: first init and every live reload
|
26
19
|
// check if this is live reload, if so let's replace UnistylesRuntime with new runtime
|
27
20
|
auto hasUnistylesRuntime = HybridObjectRegistry::hasHybridObject("UnistylesRuntime");
|
@@ -32,18 +25,17 @@ __weak RCTSurfacePresenter* _surfacePresenter;
|
|
32
25
|
HybridObjectRegistry::unregisterHybridObjectConstructor("UnistylesShadowRegistry");
|
33
26
|
}
|
34
27
|
|
35
|
-
[self createHybrids:rt];
|
28
|
+
[self createHybrids:rt callInvoker:callInvoker];
|
36
29
|
}
|
37
30
|
|
38
|
-
- (void)createHybrids:(jsi::Runtime&)rt {
|
39
|
-
auto runOnJSThread = [callInvoker
|
31
|
+
- (void)createHybrids:(jsi::Runtime&)rt callInvoker:(const std::shared_ptr<facebook::react::CallInvoker> &)callInvoker {
|
32
|
+
auto runOnJSThread = [callInvoker](std::function<void(jsi::Runtime& rt)> &&callback){
|
40
33
|
callInvoker->invokeAsync(std::move(callback));
|
41
34
|
};
|
42
35
|
|
43
36
|
auto nativePlatform = Unistyles::NativePlatform::create().getCxxPart();
|
44
37
|
auto unistylesRuntime = std::make_shared<HybridUnistylesRuntime>(nativePlatform, rt, runOnJSThread);
|
45
|
-
auto
|
46
|
-
auto styleSheet = std::make_shared<HybridStyleSheet>(unistylesRuntime, uiManager);
|
38
|
+
auto styleSheet = std::make_shared<HybridStyleSheet>(unistylesRuntime);
|
47
39
|
|
48
40
|
HybridObjectRegistry::registerHybridObjectConstructor("UnistylesRuntime", [unistylesRuntime]() -> std::shared_ptr<HybridObject>{
|
49
41
|
return unistylesRuntime;
|