react-native-unistyles 3.0.0-beta.7 → 3.0.0-experimental-2025051401
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 +41 -19
- package/Unistyles.podspec +1 -0
- package/android/CMakeLists.txt +2 -1
- 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/NativePlatform+android.kt +5 -1
- package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +11 -4
- package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +1 -1
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +1 -7
- package/components/native/ActivityIndicator/package.json +1 -0
- package/components/native/Animated/package.json +1 -0
- package/components/native/FlatList/package.json +1 -0
- package/components/native/Image/package.json +2 -1
- package/components/native/ImageBackground/package.json +1 -0
- package/components/native/KeyboardAvoidingView/package.json +1 -0
- package/components/native/NativeText/package.json +1 -0
- package/components/native/NativeView/package.json +1 -0
- package/components/native/Pressable/package.json +1 -0
- package/components/native/RefreshControl/package.json +1 -0
- package/components/native/ScrollView/package.json +1 -0
- package/components/native/SectionList/package.json +1 -0
- package/components/native/Switch/package.json +1 -0
- package/components/native/Text/package.json +1 -0
- package/components/native/TextInput/package.json +1 -0
- package/components/native/TouchableHighlight/package.json +1 -0
- package/components/native/TouchableOpacity/package.json +1 -0
- package/components/native/View/package.json +1 -0
- package/components/native/VirtualizedList/package.json +1 -0
- package/cxx/common/Helpers.h +89 -0
- package/cxx/core/HostUnistyle.cpp +14 -5
- package/cxx/core/StyleSheet.h +1 -1
- package/cxx/core/UnistyleWrapper.h +1 -1
- package/cxx/core/UnistylesCommitShadowNode.h +0 -21
- package/cxx/core/UnistylesRegistry.cpp +74 -69
- package/cxx/core/UnistylesRegistry.h +1 -1
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +2 -5
- package/cxx/hybridObjects/HybridStyleSheet.cpp +10 -19
- package/cxx/hybridObjects/HybridStyleSheet.h +3 -8
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +5 -1
- package/cxx/parser/Parser.cpp +200 -89
- package/cxx/parser/Parser.h +1 -1
- package/cxx/shadowTree/ShadowTrafficController.h +13 -9
- package/cxx/shadowTree/ShadowTreeManager.cpp +64 -59
- package/cxx/shadowTree/ShadowTreeManager.h +0 -1
- package/ios/NativePlatform+ios.swift +1 -1
- package/ios/NativePlatformListener+ios.swift +12 -7
- package/ios/UnistylesModuleOnLoad.h +1 -5
- package/ios/UnistylesModuleOnLoad.mm +5 -13
- package/lib/commonjs/components/native/Image.js +27 -1
- package/lib/commonjs/components/native/Image.js.map +1 -1
- package/lib/commonjs/components/native/Image.native.js +10 -0
- package/lib/commonjs/components/native/Image.native.js.map +1 -0
- package/lib/commonjs/components/native/ImageBackground.js +21 -36
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js +16 -2
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js +17 -21
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js +7 -1
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js +10 -4
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/getClassname.js +11 -5
- package/lib/commonjs/core/getClassname.js.map +1 -1
- package/lib/commonjs/core/passForwardRef.js +3 -5
- package/lib/commonjs/core/passForwardRef.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js +5 -3
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js +15 -2
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +14 -5
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +14 -7
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.js +4 -4
- package/lib/commonjs/hooks/useMedia.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.native.js +4 -4
- package/lib/commonjs/hooks/useMedia.native.js.map +1 -1
- package/lib/commonjs/mocks.js +203 -0
- package/lib/commonjs/mocks.js.map +1 -0
- package/lib/commonjs/mq.js +1 -23
- package/lib/commonjs/mq.js.map +1 -1
- package/lib/commonjs/reanimated/index.js +13 -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/server/getServerUnistyles.js +9 -4
- package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/hydrateServerUnistyles.js +4 -2
- package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/resetServerUnistyles.js +4 -2
- package/lib/commonjs/server/resetServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/serialize.js +24 -0
- package/lib/commonjs/server/serialize.js.map +1 -0
- package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js +1 -0
- package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +2 -2
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/utils.js +23 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/convert/index.js +4 -7
- package/lib/commonjs/web/convert/index.js.map +1 -1
- package/lib/commonjs/web/convert/object/filter.js +7 -8
- package/lib/commonjs/web/convert/object/filter.js.map +1 -1
- package/lib/commonjs/web/create.js +10 -2
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/css/core.js +2 -2
- package/lib/commonjs/web/css/core.js.map +1 -1
- package/lib/commonjs/web/css/state.js +6 -3
- package/lib/commonjs/web/css/state.js.map +1 -1
- package/lib/commonjs/web/index.js +7 -12
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/registry.js +11 -9
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js +5 -1
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/services.js +7 -2
- package/lib/commonjs/web/services.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +27 -10
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/state.js +11 -2
- 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 +31 -0
- package/lib/commonjs/web/utils/createUnistylesRef.js.map +1 -0
- package/lib/commonjs/web/utils/unistyle.js +40 -14
- 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/native/Image.js +26 -2
- package/lib/module/components/native/Image.js.map +1 -1
- package/lib/module/components/native/Image.native.js +6 -0
- package/lib/module/components/native/Image.native.js.map +1 -0
- package/lib/module/components/native/ImageBackground.js +22 -37
- package/lib/module/components/native/ImageBackground.js.map +1 -1
- package/lib/module/components/native/Pressable.native.js +16 -2
- package/lib/module/components/native/Pressable.native.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js +17 -21
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +7 -1
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js +10 -4
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/getClassname.js +9 -5
- package/lib/module/core/getClassname.js.map +1 -1
- package/lib/module/core/passForwardRef.js +3 -5
- package/lib/module/core/passForwardRef.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/listener.js +3 -3
- package/lib/module/core/useProxifiedUnistyles/listener.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js +15 -2
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.js +14 -5
- package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.native.js +14 -7
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/hooks/useMedia.js +1 -1
- package/lib/module/hooks/useMedia.js.map +1 -1
- package/lib/module/hooks/useMedia.native.js +1 -1
- package/lib/module/hooks/useMedia.native.js.map +1 -1
- package/lib/module/mocks.js +201 -0
- package/lib/module/mocks.js.map +1 -0
- package/lib/module/mq.js +0 -19
- package/lib/module/mq.js.map +1 -1
- package/lib/module/reanimated/index.js +4 -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/server/getServerUnistyles.js +7 -4
- package/lib/module/server/getServerUnistyles.js.map +1 -1
- package/lib/module/server/hydrateServerUnistyles.js +2 -2
- package/lib/module/server/hydrateServerUnistyles.js.map +1 -1
- package/lib/module/server/resetServerUnistyles.js +2 -2
- package/lib/module/server/resetServerUnistyles.js.map +1 -1
- package/lib/module/server/serialize.js +19 -0
- package/lib/module/server/serialize.js.map +1 -0
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js +1 -0
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +2 -2
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/utils.js +19 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/convert/index.js +4 -7
- package/lib/module/web/convert/index.js.map +1 -1
- package/lib/module/web/convert/object/filter.js +3 -4
- package/lib/module/web/convert/object/filter.js.map +1 -1
- package/lib/module/web/create.js +9 -3
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/css/core.js +2 -2
- package/lib/module/web/css/core.js.map +1 -1
- package/lib/module/web/css/state.js +6 -3
- package/lib/module/web/css/state.js.map +1 -1
- package/lib/module/web/index.js +4 -10
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/registry.js +11 -9
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js +5 -1
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/services.js +7 -1
- package/lib/module/web/services.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +27 -10
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/state.js +11 -2
- 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/createUnistylesRef.js +24 -0
- package/lib/module/web/utils/createUnistylesRef.js.map +1 -0
- package/lib/module/web/utils/unistyle.js +32 -10
- 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/src/components/native/Animated.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Image.native.d.ts +2 -0
- package/lib/typescript/src/components/native/Image.native.d.ts.map +1 -0
- package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.native.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 +5 -5
- package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
- package/lib/typescript/src/core/passForwardRef.d.ts +1 -1
- 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 +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts +1 -3
- 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/mocks.d.ts +2 -0
- package/lib/typescript/src/mocks.d.ts.map +1 -0
- package/lib/typescript/src/mq.d.ts +0 -8
- package/lib/typescript/src/mq.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/index.d.ts +2 -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/server/getServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/server/hydrateServerUnistyles.d.ts +0 -1
- package/lib/typescript/src/server/hydrateServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/server/resetServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/server/serialize.d.ts +2 -0
- package/lib/typescript/src/server/serialize.d.ts.map +1 -0
- package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts +2 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
- package/lib/typescript/src/types/common.d.ts +0 -1
- package/lib/typescript/src/types/common.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +8 -0
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/index.d.ts +2 -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 +2 -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 +4 -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/index.d.ts +0 -5
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/listener.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +2 -2
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/services.d.ts +6 -1
- package/lib/typescript/src/web/services.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts +2 -2
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/state.d.ts +2 -0
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/types.d.ts +3 -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 +11 -0
- package/lib/typescript/src/web/utils/createUnistylesRef.d.ts.map +1 -0
- package/lib/typescript/src/web/utils/unistyle.d.ts +5 -2
- 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/android/c++/JFunc_void_UnistylesNativeMiniRuntime.hpp +2 -2
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.hpp +2 -2
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +19 -19
- package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +3 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_UnistylesNativeMiniRuntime.kt +7 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.kt +7 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +22 -22
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistyleDependency.kt +2 -1
- package/nitrogen/generated/android/unistyles+autolinking.cmake +16 -0
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +0 -1
- package/nitrogen/generated/ios/swift/UnistyleDependency.swift +4 -0
- package/nitrogen/generated/shared/c++/Dimensions.hpp +1 -0
- package/nitrogen/generated/shared/c++/Insets.hpp +1 -0
- package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +2 -1
- package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +1 -0
- package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +1 -0
- package/package.json +77 -33
- package/plugin/index.d.ts +51 -18
- package/plugin/index.js +878 -177
- package/reanimated/package.json +6 -0
- package/server/package.json +6 -0
- package/src/components/native/Image.native.tsx +4 -0
- package/src/components/native/Image.tsx +36 -3
- package/src/components/native/ImageBackground.tsx +20 -36
- package/src/components/native/Pressable.native.tsx +25 -2
- package/src/core/createUnistylesElement.native.tsx +13 -2
- package/src/core/createUnistylesElement.tsx +26 -27
- package/src/core/createUnistylesImageBackground.tsx +16 -5
- package/src/core/getClassname.ts +16 -5
- package/src/core/passForwardRef.ts +5 -5
- package/src/core/useProxifiedUnistyles/listener.ts +3 -3
- package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +18 -1
- package/src/core/withUnistyles/withUnistyles.native.tsx +42 -17
- package/src/core/withUnistyles/withUnistyles.tsx +23 -6
- package/src/hooks/useMedia.native.ts +1 -1
- package/src/hooks/useMedia.ts +1 -1
- package/src/mocks.ts +217 -0
- package/src/mq.ts +0 -24
- package/src/reanimated/index.ts +1 -0
- package/src/reanimated/useAnimatedTheme.native.ts +21 -0
- package/src/reanimated/useAnimatedTheme.ts +19 -0
- package/src/server/getServerUnistyles.tsx +15 -10
- package/src/server/hydrateServerUnistyles.ts +3 -2
- package/src/server/resetServerUnistyles.ts +4 -3
- package/src/server/serialize.ts +20 -0
- package/src/specs/NativePlatform/NativePlatform.nitro.ts +2 -1
- package/src/specs/ShadowRegistry/index.ts +2 -2
- package/src/types/common.ts +0 -1
- package/src/types/stylesheet.ts +1 -1
- package/src/utils.ts +25 -0
- package/src/web/convert/index.ts +5 -7
- package/src/web/convert/object/filter.ts +4 -4
- package/src/web/create.ts +10 -3
- package/src/web/css/core.ts +2 -2
- package/src/web/css/state.ts +5 -3
- package/src/web/index.ts +4 -16
- package/src/web/registry.ts +20 -11
- package/src/web/runtime.ts +6 -2
- package/src/web/services.ts +14 -1
- package/src/web/shadowRegistry.ts +35 -13
- package/src/web/state.ts +14 -2
- package/src/web/types.ts +9 -4
- package/src/web/utils/createUnistylesRef.ts +33 -0
- package/src/web/utils/unistyle.ts +55 -23
- 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 -49
- package/cxx/core/UnistylesCommitHook.h +0 -27
- package/cxx/core/UnistylesMountHook.cpp +0 -28
- package/cxx/core/UnistylesMountHook.h +0 -27
- package/lib/module/package.json +0 -1
- package/plugin/consts.js +0 -63
- package/plugin/exotic.js +0 -54
- package/plugin/import.js +0 -51
- package/plugin/ref.js +0 -11
- package/plugin/stylesheet.js +0 -565
- package/plugin/variants.js +0 -66
- /package/cxx/common/{Constants.h → UnistylesConstants.h} +0 -0
package/cxx/parser/Parser.cpp
CHANGED
@@ -62,10 +62,10 @@ jsi::Value parser::Parser::getParsedStyleSheetForScopedTheme(jsi::Runtime& rt, c
|
|
62
62
|
.asObject(rt);
|
63
63
|
}
|
64
64
|
|
65
|
-
void parser::Parser::rebuildUnistyleWithScopedTheme(jsi::Runtime& rt, jsi::Value&
|
66
|
-
auto parsedStyleSheet =
|
65
|
+
void parser::Parser::rebuildUnistyleWithScopedTheme(jsi::Runtime& rt, jsi::Value& scopedStyleSheet, std::shared_ptr<core::UnistyleData> unistyleData) {
|
66
|
+
auto parsedStyleSheet = scopedStyleSheet.isUndefined()
|
67
67
|
? this->getParsedStyleSheetForScopedTheme(rt, unistyleData->unistyle, unistyleData->scopedTheme.value())
|
68
|
-
:
|
68
|
+
: scopedStyleSheet.asObject(rt);
|
69
69
|
|
70
70
|
if (parsedStyleSheet.isUndefined()) {
|
71
71
|
return;
|
@@ -213,112 +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.contains(styleSheet)) {
|
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.contains(unistyleStyleSheet)) {
|
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
|
-
|
269
|
-
|
280
|
+
auto& scopedThemeName = unistyleData->scopedTheme.value();
|
281
|
+
auto& scopedThemeMap = parsedStyleSheetsWithScopedTheme[scopedThemeName];
|
282
|
+
|
283
|
+
jsi::Value parsedStyleSheet = jsi::Value::undefined();
|
284
|
+
auto it = scopedThemeMap.find(unistyle->parent);
|
285
|
+
|
286
|
+
if (it != scopedThemeMap.end()) {
|
287
|
+
parsedStyleSheet = jsi::Value(rt, it->second);
|
270
288
|
}
|
271
289
|
|
272
|
-
auto parsedStyleSheet = jsi::Value::undefined();
|
273
|
-
auto scopedThemeName = unistyleData->scopedTheme.value();
|
274
|
-
|
275
|
-
// check if we have theme in cache
|
276
|
-
if (parsedStyleSheetsWithScopedTheme.contains(scopedThemeName)) {
|
277
|
-
if (parsedStyleSheetsWithScopedTheme[scopedThemeName].contains(unistyle->parent)) {
|
278
|
-
parsedStyleSheet = jsi::Value(rt, parsedStyleSheetsWithScopedTheme[scopedThemeName][unistyle->parent]);
|
279
|
-
}
|
280
|
-
}
|
281
|
-
|
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
|
+
unistyle->isDirty = true;
|
308
309
|
}
|
309
310
|
|
310
|
-
|
311
|
-
parsedUnistyles.emplace(unistyle, true);
|
312
|
-
}
|
311
|
+
parsedUnistyles.insert(unistyle);
|
313
312
|
}
|
314
313
|
}
|
315
314
|
|
316
|
-
//
|
317
|
-
|
318
|
-
|
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
|
+
|
319
320
|
for (auto& [_, unistyle] : styleSheet->unistyles) {
|
320
321
|
if (!parsedUnistyles.contains(unistyle)) {
|
321
|
-
unistyle->rawValue =
|
322
|
+
unistyle->rawValue = parsedSheetObj
|
323
|
+
.getProperty(rt, unistyle->styleKey.c_str())
|
324
|
+
.asObject(rt);
|
322
325
|
unistyle->isDirty = true;
|
323
326
|
}
|
324
327
|
}
|
@@ -369,20 +372,25 @@ void parser::Parser::rebuildUnistyle(jsi::Runtime& rt, Unistyle::Shared unistyle
|
|
369
372
|
|
370
373
|
// convert dependency map to shadow tree updates
|
371
374
|
void parser::Parser::rebuildShadowLeafUpdates(jsi::Runtime& rt, core::DependencyMap& dependencyMap) {
|
372
|
-
shadow::ShadowLeafUpdates updates;
|
373
375
|
auto& registry = core::UnistylesRegistry::get();
|
374
376
|
|
375
|
-
|
376
|
-
|
377
|
-
|
377
|
+
registry.trafficController.withLock([this, &rt, &dependencyMap, ®istry]() {
|
378
|
+
shadow::ShadowLeafUpdates updates;
|
379
|
+
updates.reserve(dependencyMap.size());
|
378
380
|
|
379
|
-
|
380
|
-
|
381
|
+
for (const auto& [shadowNode, unistyles] : dependencyMap) {
|
382
|
+
// Parse string colors (e.g., "#000000") to int representation
|
383
|
+
auto rawProps = this->parseStylesToShadowTreeStyles(rt, unistyles);
|
381
384
|
|
382
|
-
|
383
|
-
|
385
|
+
updates.emplace(shadowNode, std::move(rawProps));
|
386
|
+
}
|
387
|
+
|
388
|
+
registry.trafficController.setUpdates(updates);
|
389
|
+
registry.trafficController.resumeUnistylesTraffic();
|
390
|
+
});
|
384
391
|
}
|
385
392
|
|
393
|
+
|
386
394
|
// first level of StyleSheet, we can expect here different properties than on second level
|
387
395
|
// eg. variants, compoundVariants, mq, breakpoints etc.
|
388
396
|
jsi::Object parser::Parser::parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared unistyle, std::optional<Variants> variants) {
|
@@ -880,21 +888,43 @@ jsi::Value parser::Parser::parseSecondLevel(jsi::Runtime &rt, Unistyle::Shared u
|
|
880
888
|
|
881
889
|
return;
|
882
890
|
}
|
883
|
-
|
891
|
+
|
892
|
+
auto isArray = nestedObjectStyle.isArray(rt);
|
893
|
+
|
894
|
+
if (!isArray) {
|
895
|
+
parsedStyle.setProperty(rt, propertyName.c_str(), this->getValueFromBreakpoints(rt, unistyle, nestedObjectStyle));
|
896
|
+
}
|
897
|
+
|
884
898
|
// possible with variants and compoundVariants
|
885
|
-
if (
|
899
|
+
if (propertyName == "transform") {
|
886
900
|
parsedStyle.setProperty(rt, propertyName.c_str(), parseTransforms(rt, unistyle, nestedObjectStyle));
|
887
901
|
|
888
902
|
return;
|
889
903
|
}
|
890
904
|
|
891
|
-
if (
|
905
|
+
if (propertyName == "boxShadow") {
|
906
|
+
parsedStyle.setProperty(rt, propertyName.c_str(), parseBoxShadow(rt, unistyle, nestedObjectStyle));
|
907
|
+
|
908
|
+
return;
|
909
|
+
}
|
910
|
+
|
911
|
+
if (propertyName == "filter") {
|
912
|
+
parsedStyle.setProperty(rt, propertyName.c_str(), parseFilters(rt, unistyle, nestedObjectStyle));
|
913
|
+
|
914
|
+
return;
|
915
|
+
}
|
916
|
+
|
917
|
+
if (propertyName == "fontVariant") {
|
892
918
|
parsedStyle.setProperty(rt, propertyName.c_str(), propertyValue);
|
893
919
|
|
894
920
|
return;
|
895
921
|
}
|
896
922
|
|
897
|
-
|
923
|
+
if (propertyName == "shadowOffset" || propertyName == "textShadowOffset") {
|
924
|
+
parsedStyle.setProperty(rt, propertyName.c_str(), this->parseSecondLevel(rt, unistyle, propertyValue));
|
925
|
+
|
926
|
+
return;
|
927
|
+
}
|
898
928
|
});
|
899
929
|
|
900
930
|
return parsedStyle;
|
@@ -902,27 +932,108 @@ jsi::Value parser::Parser::parseSecondLevel(jsi::Runtime &rt, Unistyle::Shared u
|
|
902
932
|
|
903
933
|
// convert unistyles to folly with int colors
|
904
934
|
folly::dynamic parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, const std::vector<std::shared_ptr<UnistyleData>>& unistyles) {
|
905
|
-
jsi::Object convertedStyles
|
935
|
+
jsi::Object convertedStyles(rt);
|
906
936
|
auto& state = core::UnistylesRegistry::get().getState(rt);
|
907
937
|
|
908
938
|
for (const auto& unistyleData : unistyles) {
|
909
|
-
// this can happen for exotic stylesheets
|
910
939
|
if (!unistyleData->parsedStyle.has_value()) {
|
911
|
-
|
940
|
+
continue;
|
912
941
|
}
|
913
942
|
|
914
|
-
helpers::enumerateJSIObject(
|
915
|
-
|
916
|
-
|
917
|
-
|
943
|
+
helpers::enumerateJSIObject(
|
944
|
+
rt,
|
945
|
+
unistyleData->parsedStyle.value(),
|
946
|
+
[this, &rt, &state, &convertedStyles](const std::string& propertyName, jsi::Value& propertyValue) {
|
947
|
+
if (this->isColor(propertyName)) {
|
948
|
+
convertedStyles.setProperty(
|
949
|
+
rt,
|
950
|
+
propertyName.c_str(),
|
951
|
+
jsi::Value(state.parseColor(propertyValue))
|
952
|
+
);
|
953
|
+
|
954
|
+
return;
|
955
|
+
}
|
918
956
|
|
919
|
-
|
920
|
-
|
957
|
+
if (!propertyValue.isObject()) {
|
958
|
+
convertedStyles.setProperty(
|
959
|
+
rt,
|
960
|
+
propertyName.c_str(),
|
961
|
+
propertyValue
|
962
|
+
);
|
963
|
+
|
964
|
+
return;
|
965
|
+
}
|
966
|
+
|
967
|
+
jsi::Object objValue = propertyValue.asObject(rt);
|
968
|
+
|
969
|
+
if (!objValue.isArray(rt)) {
|
970
|
+
convertedStyles.setProperty(
|
971
|
+
rt,
|
972
|
+
propertyName.c_str(),
|
973
|
+
propertyValue
|
974
|
+
);
|
975
|
+
|
976
|
+
return;
|
977
|
+
}
|
978
|
+
|
979
|
+
// parse nested arrays like boxShadow
|
980
|
+
jsi::Array arrValue = objValue.asArray(rt);
|
981
|
+
size_t arrLen = arrValue.length(rt);
|
982
|
+
jsi::Array parsedArray(rt, arrLen);
|
983
|
+
|
984
|
+
helpers::iterateJSIArray(
|
985
|
+
rt,
|
986
|
+
arrValue,
|
987
|
+
[this, &rt, &state, &propertyName, &parsedArray](size_t i, jsi::Value& nestedValue) {
|
988
|
+
if (nestedValue.isObject()) {
|
989
|
+
jsi::Object obj(rt);
|
990
|
+
|
991
|
+
helpers::enumerateJSIObject(
|
992
|
+
rt,
|
993
|
+
nestedValue.asObject(rt),
|
994
|
+
[this, &rt, &state, &obj](const std::string& nestedPropName, jsi::Value& nestedPropValue) {
|
995
|
+
if (this->isColor(nestedPropName)) {
|
996
|
+
obj.setProperty(
|
997
|
+
rt,
|
998
|
+
nestedPropName.c_str(),
|
999
|
+
state.parseColor(nestedPropValue)
|
1000
|
+
);
|
1001
|
+
} else {
|
1002
|
+
obj.setProperty(
|
1003
|
+
rt,
|
1004
|
+
nestedPropName.c_str(),
|
1005
|
+
nestedPropValue
|
1006
|
+
);
|
1007
|
+
}
|
1008
|
+
}
|
1009
|
+
);
|
1010
|
+
|
1011
|
+
parsedArray.setValueAtIndex(rt, i, obj);
|
1012
|
+
|
1013
|
+
return;
|
1014
|
+
}
|
1015
|
+
|
1016
|
+
if (this->isColor(propertyName)) {
|
1017
|
+
parsedArray.setValueAtIndex(
|
1018
|
+
rt,
|
1019
|
+
i,
|
1020
|
+
jsi::Value(state.parseColor(nestedValue))
|
1021
|
+
);
|
1022
|
+
} else {
|
1023
|
+
parsedArray.setValueAtIndex(rt, i, nestedValue);
|
1024
|
+
}
|
1025
|
+
}
|
1026
|
+
);
|
1027
|
+
|
1028
|
+
convertedStyles.setProperty(rt, propertyName.c_str(), parsedArray);
|
1029
|
+
}
|
1030
|
+
);
|
921
1031
|
}
|
922
1032
|
|
923
|
-
return jsi::dynamicFromValue(rt,
|
1033
|
+
return jsi::dynamicFromValue(rt, jsi::Value(rt, convertedStyles));
|
924
1034
|
}
|
925
1035
|
|
1036
|
+
|
926
1037
|
// check is styleKey contains color
|
927
1038
|
bool parser::Parser::isColor(const std::string& propertyName) {
|
928
1039
|
std::string str = propertyName;
|
package/cxx/parser/Parser.h
CHANGED
@@ -21,14 +21,12 @@ struct ShadowTrafficController {
|
|
21
21
|
}
|
22
22
|
|
23
23
|
inline shadow::ShadowLeafUpdates& getUpdates() {
|
24
|
-
|
25
|
-
|
24
|
+
// call it only within withLock!
|
26
25
|
return _unistylesUpdates;
|
27
26
|
}
|
28
27
|
|
29
28
|
inline void setUpdates(shadow::ShadowLeafUpdates& newUpdates) {
|
30
|
-
|
31
|
-
|
29
|
+
// call it only within withLock!
|
32
30
|
auto& targetUpdates = _unistylesUpdates;
|
33
31
|
|
34
32
|
// this is important as overriding updates may skip some interim changes
|
@@ -43,22 +41,28 @@ struct ShadowTrafficController {
|
|
43
41
|
targetUpdates.emplace(pair.first, std::move(pair.second));
|
44
42
|
});
|
45
43
|
}
|
46
|
-
|
44
|
+
|
47
45
|
inline void removeShadowNode(const ShadowNodeFamily* shadowNodeFamily) {
|
48
|
-
|
49
|
-
|
46
|
+
// call it only within withLock!
|
50
47
|
if (_unistylesUpdates.contains(shadowNodeFamily)) {
|
51
48
|
_unistylesUpdates.erase(shadowNodeFamily);
|
52
49
|
}
|
53
50
|
}
|
54
51
|
|
55
52
|
inline void restore() {
|
56
|
-
|
57
|
-
|
53
|
+
// call it only within withLock!
|
54
|
+
|
58
55
|
_unistylesUpdates = {};
|
59
56
|
_canCommit = false;
|
60
57
|
}
|
61
58
|
|
59
|
+
template <typename F>
|
60
|
+
inline auto withLock(F&& func) {
|
61
|
+
std::lock_guard<std::mutex> lock(_mutex);
|
62
|
+
|
63
|
+
return std::forward<F>(func)();
|
64
|
+
}
|
65
|
+
|
62
66
|
private:
|
63
67
|
std::atomic<bool> _canCommit = false;
|
64
68
|
shadow::ShadowLeafUpdates _unistylesUpdates{};
|
@@ -8,43 +8,40 @@ 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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return;
|
15
|
-
}
|
16
|
-
|
17
|
-
shadowTreeRegistry.enumerate([&updates](const ShadowTree& shadowTree, bool& stop){
|
18
|
-
// we could iterate via updates and create multiple commits
|
19
|
-
// but it can cause performance issues for hundreds of nodes
|
20
|
-
// so let's mutate Shadow Tree in single transaction
|
21
|
-
auto transaction = [&](const RootShadowNode& oldRootShadowNode) {
|
22
|
-
auto affectedNodes = shadow::ShadowTreeManager::findAffectedNodes(oldRootShadowNode, updates);
|
23
|
-
auto newRootNode = std::static_pointer_cast<RootShadowNode>(shadow::ShadowTreeManager::cloneShadowTree(
|
24
|
-
oldRootShadowNode,
|
25
|
-
updates,
|
26
|
-
affectedNodes
|
27
|
-
));
|
28
|
-
|
29
|
-
// set unistyles trait
|
30
|
-
auto unistylesRootNode = std::reinterpret_pointer_cast<core::UnistylesCommitShadowNode>(newRootNode);
|
31
|
-
|
32
|
-
unistylesRootNode->addUnistylesCommitTrait();
|
33
|
-
|
34
|
-
return newRootNode;
|
35
|
-
};
|
36
|
-
|
37
|
-
// commit once!
|
38
|
-
// CommitOptions:
|
39
|
-
// enableStateReconciliation: https://reactnative.dev/architecture/render-pipeline#react-native-renderer-state-updates
|
40
|
-
// mountSynchronously: must be true as this is update from C++ not React
|
41
|
-
shadowTree.commit(transaction, {false, true});
|
11
|
+
|
12
|
+
registry.trafficController.withLock([&](){
|
13
|
+
auto updates = registry.trafficController.getUpdates();
|
42
14
|
|
15
|
+
if (updates.empty()) {
|
16
|
+
return;
|
17
|
+
}
|
43
18
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
19
|
+
shadowTreeRegistry.enumerate([&updates](const ShadowTree& shadowTree, bool& stop){
|
20
|
+
// we could iterate via updates and create multiple commits
|
21
|
+
// but it can cause performance issues for hundreds of nodes
|
22
|
+
// so let's mutate Shadow Tree in single transaction
|
23
|
+
auto transaction = [&updates](const RootShadowNode& oldRootShadowNode) {
|
24
|
+
auto affectedNodes = shadow::ShadowTreeManager::findAffectedNodes(oldRootShadowNode, updates);
|
25
|
+
|
26
|
+
return std::static_pointer_cast<RootShadowNode>(shadow::ShadowTreeManager::cloneShadowTree(
|
27
|
+
oldRootShadowNode,
|
28
|
+
updates,
|
29
|
+
affectedNodes
|
30
|
+
));
|
31
|
+
};
|
32
|
+
|
33
|
+
// commit once!
|
34
|
+
// CommitOptions:
|
35
|
+
// enableStateReconciliation: https://reactnative.dev/architecture/render-pipeline#react-native-renderer-state-updates
|
36
|
+
// mountSynchronously: must be true as this is update from C++ not React
|
37
|
+
shadowTree.commit(transaction, {false, true});
|
38
|
+
|
39
|
+
|
40
|
+
// for now we're assuming single surface, can be improved in the future
|
41
|
+
// stop = true means stop enumerating next shadow tree
|
42
|
+
// so in other words first shadow tree is our desired tree
|
43
|
+
stop = true;
|
44
|
+
});
|
48
45
|
});
|
49
46
|
}
|
50
47
|
|
@@ -68,18 +65,17 @@ void shadow::ShadowTreeManager::updateShadowTree(const ShadowTreeRegistry& shado
|
|
68
65
|
AffectedNodes shadow::ShadowTreeManager::findAffectedNodes(const RootShadowNode& rootNode, ShadowLeafUpdates& updates) {
|
69
66
|
AffectedNodes affectedNodes;
|
70
67
|
|
71
|
-
|
72
|
-
|
73
|
-
const auto& [family, _] = pair;
|
74
|
-
const auto familyAncestors = family->getAncestors(rootNode);
|
68
|
+
for (const auto& [family, _] : updates) {
|
69
|
+
auto familyAncestors = family->getAncestors(rootNode);
|
75
70
|
|
76
|
-
for (
|
71
|
+
for (auto it = familyAncestors.rbegin(); it != familyAncestors.rend(); ++it) {
|
72
|
+
const auto& [parentNode, index] = *it;
|
77
73
|
const auto parentFamily = &parentNode.get().getFamily();
|
78
|
-
|
79
|
-
|
80
|
-
|
74
|
+
auto [setIt, inserted] = affectedNodes.try_emplace(parentFamily, std::unordered_set<int>{});
|
75
|
+
|
76
|
+
setIt->second.insert(index);
|
81
77
|
}
|
82
|
-
}
|
78
|
+
}
|
83
79
|
|
84
80
|
return affectedNodes;
|
85
81
|
}
|
@@ -90,44 +86,53 @@ ShadowNode::Unshared shadow::ShadowTreeManager::cloneShadowTree(const ShadowNode
|
|
90
86
|
const auto family = &shadowNode.getFamily();
|
91
87
|
const auto rawPropsIt = updates.find(family);
|
92
88
|
const auto childrenIt = affectedNodes.find(family);
|
93
|
-
auto children = shadowNode.getChildren();
|
94
89
|
|
95
|
-
//
|
90
|
+
// Only copy children if we need to update them
|
91
|
+
std::shared_ptr<ShadowNode::ListOfShared> childrenPtr;
|
92
|
+
const auto& originalChildren = shadowNode.getChildren();
|
93
|
+
|
96
94
|
if (childrenIt != affectedNodes.end()) {
|
97
|
-
|
95
|
+
auto children = originalChildren;
|
96
|
+
|
98
97
|
for (const auto index : childrenIt->second) {
|
99
98
|
children[index] = cloneShadowTree(*children[index], updates, affectedNodes);
|
100
99
|
}
|
100
|
+
|
101
|
+
childrenPtr = std::make_shared<ShadowNode::ListOfShared>(std::move(children));
|
102
|
+
} else {
|
103
|
+
childrenPtr = std::make_shared<ShadowNode::ListOfShared>(originalChildren);
|
101
104
|
}
|
102
105
|
|
103
106
|
Props::Shared updatedProps = nullptr;
|
104
107
|
|
105
|
-
// clone props for our target shadow node and place fresh RawProps
|
106
108
|
if (rawPropsIt != updates.end()) {
|
109
|
+
const auto& componentDescriptor = shadowNode.getComponentDescriptor();
|
110
|
+
|
107
111
|
PropsParserContext propsParserContext{
|
108
112
|
shadowNode.getSurfaceId(),
|
109
113
|
*shadowNode.getContextContainer()
|
110
114
|
};
|
111
115
|
|
112
|
-
|
113
|
-
// first of all Android doesn't like nullish props (they work perfectly fine on iOS)
|
114
|
-
// second of all Android props MUST be constructed from previous props, otherwise RawProps::~RawProps error occurs
|
115
|
-
// Meta wants to remove shadowNode.getProps()->rawProps, but for now it's the only viable solution
|
116
|
+
folly::dynamic newProps;
|
116
117
|
#ifdef ANDROID
|
117
|
-
auto safeProps = rawPropsIt->second == nullptr
|
118
|
-
|
118
|
+
auto safeProps = rawPropsIt->second == nullptr
|
119
|
+
? folly::dynamic::object()
|
120
|
+
: rawPropsIt->second;
|
121
|
+
newProps = folly::dynamic::merge(props->rawProps, safeProps);
|
119
122
|
#else
|
120
|
-
|
123
|
+
newProps = rawPropsIt->second;
|
121
124
|
#endif
|
122
125
|
|
123
|
-
updatedProps =
|
124
|
-
|
125
|
-
|
126
|
+
updatedProps = componentDescriptor.cloneProps(
|
127
|
+
propsParserContext,
|
128
|
+
shadowNode.getProps(),
|
129
|
+
RawProps(newProps)
|
130
|
+
);
|
126
131
|
}
|
127
132
|
|
128
133
|
return shadowNode.clone({
|
129
134
|
updatedProps ? updatedProps : ShadowNodeFragment::propsPlaceholder(),
|
130
|
-
|
135
|
+
childrenPtr,
|
131
136
|
shadowNode.getState()
|
132
137
|
});
|
133
138
|
}
|
@@ -313,7 +313,7 @@ class NativeIOSPlatform: HybridNativePlatformSpec {
|
|
313
313
|
}
|
314
314
|
|
315
315
|
func setStatusBarHidden(isHidden: Bool) throws {
|
316
|
-
self.
|
316
|
+
self.onNativePlatformChange()
|
317
317
|
}
|
318
318
|
|
319
319
|
// not implemented for iOS as there are no such APIs
|