react-native-unistyles 3.0.0-beta.8 → 3.0.0-experimental-2025051402
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 +32 -26
- package/Unistyles.podspec +1 -0
- 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 +2 -3
- 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 +4 -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 +67 -64
- package/cxx/core/UnistylesRegistry.h +1 -1
- package/cxx/hybridObjects/HybridStyleSheet.cpp +10 -19
- package/cxx/hybridObjects/HybridStyleSheet.h +3 -8
- package/cxx/parser/Parser.cpp +161 -115
- package/cxx/parser/Parser.h +1 -1
- package/cxx/shadowTree/ShadowTrafficController.h +7 -9
- package/cxx/shadowTree/ShadowTreeManager.cpp +36 -33
- 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 +17 -28
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js +7 -4
- 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 +6 -4
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js +7 -5
- 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 +14 -1
- 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 +1 -1
- 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 +18 -29
- package/lib/module/components/native/ImageBackground.js.map +1 -1
- package/lib/module/components/native/Pressable.native.js +7 -4
- 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 +6 -4
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js +7 -5
- 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 +14 -1
- 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 +1 -1
- 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/ShadowRegistry/index.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.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++/JUnistyleDependency.hpp +3 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistyleDependency.kt +2 -1
- package/nitrogen/generated/ios/swift/UnistyleDependency.swift +4 -0
- package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +2 -1
- package/package.json +66 -32
- package/plugin/index.js +155 -67
- 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 +18 -33
- package/src/components/native/Pressable.native.tsx +12 -4
- package/src/core/createUnistylesElement.native.tsx +12 -6
- package/src/core/createUnistylesElement.tsx +26 -27
- package/src/core/createUnistylesImageBackground.tsx +16 -10
- 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 +17 -0
- package/src/core/withUnistyles/withUnistyles.native.tsx +3 -4
- 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 +1 -2
- package/src/types/common.ts +0 -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 -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/common/{Constants.h → UnistylesConstants.h} +0 -0
@@ -73,17 +73,19 @@ void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
|
|
73
73
|
const ShadowNodeFamily* shadowNodeFamily,
|
74
74
|
std::vector<std::shared_ptr<UnistyleData>>& unistylesData
|
75
75
|
) {
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
std::for_each(unistylesData.begin(), unistylesData.end(), [this, &rt, shadowNodeFamily](std::shared_ptr<UnistyleData> unistyleData){
|
80
|
-
this->_shadowRegistry[&rt][shadowNodeFamily].emplace_back(unistyleData);
|
81
|
-
});
|
76
|
+
this->trafficController.withLock([this, &rt, &unistylesData, shadowNodeFamily](){
|
77
|
+
shadow::ShadowLeafUpdates updates;
|
78
|
+
auto parser = parser::Parser(nullptr);
|
82
79
|
|
83
|
-
|
80
|
+
std::for_each(unistylesData.begin(), unistylesData.end(), [this, &rt, shadowNodeFamily](std::shared_ptr<UnistyleData> unistyleData){
|
81
|
+
this->_shadowRegistry[&rt][shadowNodeFamily].emplace_back(unistyleData);
|
82
|
+
});
|
84
83
|
|
85
|
-
|
86
|
-
|
84
|
+
updates[shadowNodeFamily] = parser.parseStylesToShadowTreeStyles(rt, unistylesData);
|
85
|
+
|
86
|
+
this->trafficController.setUpdates(updates);
|
87
|
+
this->trafficController.resumeUnistylesTraffic();
|
88
|
+
});
|
87
89
|
}
|
88
90
|
|
89
91
|
void core::UnistylesRegistry::removeDuplicatedUnistyles(jsi::Runtime& rt, const ShadowNodeFamily *shadowNodeFamily, std::vector<core::Unistyle::Shared>& unistyles) {
|
@@ -111,7 +113,7 @@ void core::UnistylesRegistry::unlinkShadowNodeWithUnistyles(jsi::Runtime& rt, co
|
|
111
113
|
this->trafficController.withLock([this, &rt, shadowNodeFamily](){
|
112
114
|
this->_shadowRegistry[&rt].erase(shadowNodeFamily);
|
113
115
|
this->trafficController.removeShadowNode(shadowNodeFamily);
|
114
|
-
|
116
|
+
|
115
117
|
if (this->_shadowRegistry[&rt].empty()) {
|
116
118
|
this->_shadowRegistry.erase(&rt);
|
117
119
|
}
|
@@ -125,31 +127,36 @@ std::shared_ptr<core::StyleSheet> core::UnistylesRegistry::addStyleSheet(jsi::Ru
|
|
125
127
|
}
|
126
128
|
|
127
129
|
core::DependencyMap core::UnistylesRegistry::buildDependencyMap(jsi::Runtime& rt, std::vector<UnistyleDependency>& deps) {
|
128
|
-
DependencyMap dependencyMap;
|
129
|
-
|
130
|
+
core::DependencyMap dependencyMap;
|
131
|
+
|
132
|
+
std::unordered_set<UnistyleDependency> uniqueDependencies(deps.begin(), deps.end());
|
130
133
|
|
131
134
|
for (const auto& [family, unistyles] : this->_shadowRegistry[&rt]) {
|
135
|
+
bool hasAnyOfDependencies = false;
|
136
|
+
|
137
|
+
// Check if any dependency matches
|
132
138
|
for (const auto& unistyleData : unistyles) {
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
return std::find(uniqueDependencies.begin(), uniqueDependencies.end(), dep) != uniqueDependencies.end();
|
139
|
+
for (const auto& dep : unistyleData->unistyle->dependencies) {
|
140
|
+
if (uniqueDependencies.count(dep)) {
|
141
|
+
hasAnyOfDependencies = true;
|
142
|
+
break;
|
138
143
|
}
|
139
|
-
);
|
140
|
-
|
141
|
-
if (!hasAnyOfDependencies) {
|
142
|
-
continue;
|
143
|
-
}
|
144
|
-
|
145
|
-
// we need to take in count all unistyles from the shadowNode
|
146
|
-
// as user might be using spreads and not all of them may have dependencies
|
147
|
-
for (const auto& unistyleData : unistyles) {
|
148
|
-
dependencyMap[family].emplace_back(unistyleData);
|
149
144
|
}
|
145
|
+
|
146
|
+
if (hasAnyOfDependencies) {
|
147
|
+
break;
|
148
|
+
};
|
149
|
+
}
|
150
150
|
|
151
|
-
|
151
|
+
if (!hasAnyOfDependencies) {
|
152
|
+
continue;
|
152
153
|
}
|
154
|
+
|
155
|
+
dependencyMap[family].insert(
|
156
|
+
dependencyMap[family].end(),
|
157
|
+
unistyles.begin(),
|
158
|
+
unistyles.end()
|
159
|
+
);
|
153
160
|
}
|
154
161
|
|
155
162
|
return dependencyMap;
|
@@ -159,56 +166,49 @@ core::DependencyMap core::UnistylesRegistry::buildDependencyMap(jsi::Runtime& rt
|
|
159
166
|
// so we need to rebuild all instances as they may have different variants
|
160
167
|
void core::UnistylesRegistry::shadowLeafUpdateFromUnistyle(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Value& maybePressableId) {
|
161
168
|
shadow::ShadowLeafUpdates updates;
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
169
|
+
this->trafficController.withLock([this, &rt, &maybePressableId, unistyle, &updates](){
|
170
|
+
auto parser = parser::Parser(nullptr);
|
171
|
+
std::optional<std::string> pressableId = maybePressableId.isString()
|
172
|
+
? std::make_optional(maybePressableId.asString(rt).utf8(rt))
|
173
|
+
: std::nullopt;
|
166
174
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
175
|
+
for (const auto& [family, unistyles] : this->_shadowRegistry[&rt]) {
|
176
|
+
for (const auto& unistyleData : unistyles) {
|
177
|
+
if (unistyleData->unistyle == unistyle) {
|
178
|
+
updates[family] = parser.parseStylesToShadowTreeStyles(rt, { unistyleData });
|
179
|
+
}
|
171
180
|
}
|
172
181
|
}
|
173
|
-
}
|
174
182
|
|
175
|
-
|
183
|
+
this->trafficController.setUpdates(updates);
|
184
|
+
});
|
176
185
|
}
|
177
186
|
|
178
|
-
std::vector<std::shared_ptr<core::StyleSheet>>
|
179
|
-
std::vector<std::shared_ptr<core::StyleSheet>> stylesheetsToRefresh
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
187
|
+
std::vector<std::shared_ptr<core::StyleSheet>>core::UnistylesRegistry::getStyleSheetsToRefresh(jsi::Runtime& rt, std::vector<UnistyleDependency>& unistylesDependencies) {
|
188
|
+
std::vector<std::shared_ptr<core::StyleSheet>> stylesheetsToRefresh;
|
189
|
+
std::unordered_set<UnistyleDependency> depSet(
|
190
|
+
unistylesDependencies.begin(),
|
191
|
+
unistylesDependencies.end()
|
192
|
+
);
|
193
|
+
|
194
|
+
bool themeDidChange = depSet.count(UnistyleDependency::THEME) > 0;
|
195
|
+
bool runtimeDidChange = (themeDidChange && depSet.size() > 1) || !depSet.empty();
|
185
196
|
|
186
|
-
// if nothing changed, skip further lookup
|
187
197
|
if (!themeDidChange && !runtimeDidChange) {
|
188
198
|
return stylesheetsToRefresh;
|
189
199
|
}
|
190
200
|
|
191
201
|
auto& styleSheets = this->_styleSheetRegistry[&rt];
|
192
202
|
|
193
|
-
|
194
|
-
auto& [_, styleSheet] = pair;
|
195
|
-
|
203
|
+
for (const auto& [_, styleSheet] : styleSheets) {
|
196
204
|
if (styleSheet->type == StyleSheetType::ThemableWithMiniRuntime) {
|
197
|
-
for (const auto&
|
198
|
-
auto&
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
[&unistylesDependencies](UnistyleDependency dep) {
|
204
|
-
return std::find(unistylesDependencies.begin(), unistylesDependencies.end(), dep) != unistylesDependencies.end();
|
205
|
+
for (const auto& [__, unistyle] : styleSheet->unistyles) {
|
206
|
+
for (const auto& dep : unistyle->dependencies) {
|
207
|
+
if (depSet.count(dep)) {
|
208
|
+
stylesheetsToRefresh.emplace_back(styleSheet);
|
209
|
+
|
210
|
+
goto nextStyleSheet;
|
205
211
|
}
|
206
|
-
);
|
207
|
-
|
208
|
-
if (hasAnyOfDependencies) {
|
209
|
-
stylesheetsToRefresh.emplace_back(styleSheet);
|
210
|
-
|
211
|
-
return;
|
212
212
|
}
|
213
213
|
}
|
214
214
|
}
|
@@ -216,11 +216,14 @@ std::vector<std::shared_ptr<core::StyleSheet>> core::UnistylesRegistry::getStyle
|
|
216
216
|
if (styleSheet->type == StyleSheetType::Themable && themeDidChange) {
|
217
217
|
stylesheetsToRefresh.emplace_back(styleSheet);
|
218
218
|
}
|
219
|
-
|
219
|
+
|
220
|
+
nextStyleSheet:;
|
221
|
+
}
|
220
222
|
|
221
223
|
return stylesheetsToRefresh;
|
222
224
|
}
|
223
225
|
|
226
|
+
|
224
227
|
core::Unistyle::Shared core::UnistylesRegistry::getUnistyleById(jsi::Runtime& rt, std::string unistyleID) {
|
225
228
|
for (auto& pair: this->_styleSheetRegistry[&rt]) {
|
226
229
|
auto [_, stylesheet] = pair;
|
@@ -56,7 +56,7 @@ private:
|
|
56
56
|
std::optional<std::string> _scopedTheme{};
|
57
57
|
std::unordered_map<jsi::Runtime*, UnistylesState> _states{};
|
58
58
|
std::unordered_map<jsi::Runtime*, std::unordered_map<int, std::shared_ptr<core::StyleSheet>>> _styleSheetRegistry{};
|
59
|
-
std::unordered_map<jsi::Runtime*, std::unordered_map<const ShadowNodeFamily*, std::vector<
|
59
|
+
std::unordered_map<jsi::Runtime*, std::unordered_map<const ShadowNodeFamily*, std::vector<std::shared_ptr<UnistyleData>>>> _shadowRegistry{};
|
60
60
|
};
|
61
61
|
|
62
62
|
inline UnistylesRegistry& UnistylesRegistry::get() {
|
@@ -80,15 +80,14 @@ jsi::Value HybridStyleSheet::init(jsi::Runtime &rt, const jsi::Value &thisVal, c
|
|
80
80
|
if (this->isInitialized) {
|
81
81
|
return jsi::Value::undefined();
|
82
82
|
}
|
83
|
-
|
83
|
+
|
84
84
|
// create new state
|
85
85
|
auto& registry = core::UnistylesRegistry::get();
|
86
86
|
|
87
87
|
registry.createState(rt);
|
88
88
|
|
89
89
|
loadExternalMethods(thisVal, rt);
|
90
|
-
|
91
|
-
|
90
|
+
|
92
91
|
this->isInitialized = true;
|
93
92
|
|
94
93
|
return jsi::Value::undefined();
|
@@ -127,18 +126,18 @@ void HybridStyleSheet::parseSettings(jsi::Runtime &rt, jsi::Object settings) {
|
|
127
126
|
if (propertyName == "CSSVars") {
|
128
127
|
return;
|
129
128
|
}
|
130
|
-
|
129
|
+
|
131
130
|
if (propertyName == "nativeBreakpointsMode") {
|
132
131
|
helpers::assertThat(rt, propertyValue.isString(), "StyleSheet.configure's nativeBreakpointsMode must be a string");
|
133
|
-
|
132
|
+
|
134
133
|
auto mode = propertyValue.asString(rt).utf8(rt);
|
135
|
-
|
134
|
+
|
136
135
|
helpers::assertThat(rt, mode == "pixels" || mode == "points", "StyleSheet.configure's nativeBreakpointsMode must be one of: pixels or points");
|
137
|
-
|
136
|
+
|
138
137
|
if (mode == "points") {
|
139
138
|
registry.shouldUsePointsForBreakpoints = true;
|
140
139
|
}
|
141
|
-
|
140
|
+
|
142
141
|
return;
|
143
142
|
}
|
144
143
|
|
@@ -156,12 +155,12 @@ void HybridStyleSheet::parseBreakpoints(jsi::Runtime &rt, jsi::Object breakpoint
|
|
156
155
|
auto& state = registry.getState(rt);
|
157
156
|
|
158
157
|
registry.registerBreakpoints(rt, sortedBreakpoints);
|
159
|
-
|
158
|
+
|
160
159
|
auto rawWidth = this->_unistylesRuntime->getScreen().width;
|
161
160
|
auto width = registry.shouldUsePointsForBreakpoints
|
162
161
|
? rawWidth / this->_unistylesRuntime->getPixelRatio()
|
163
162
|
: rawWidth;
|
164
|
-
|
163
|
+
|
165
164
|
state.computeCurrentBreakpoint(width);
|
166
165
|
}
|
167
166
|
|
@@ -256,14 +255,6 @@ void HybridStyleSheet::loadExternalMethods(const jsi::Value& thisValue, jsi::Run
|
|
256
255
|
state.registerProcessColorFunction(std::move(processColorFn));
|
257
256
|
}
|
258
257
|
|
259
|
-
void HybridStyleSheet::registerHooks(jsi::Runtime& rt) {
|
260
|
-
// cleanup Shadow updates
|
261
|
-
core::UnistylesRegistry::get().trafficController.restore();
|
262
|
-
|
263
|
-
this->_unistylesCommitHook = std::make_shared<core::UnistylesCommitHook>(this->_uiManager);
|
264
|
-
this->_unistylesMountHook = std::make_shared<core::UnistylesMountHook>(this->_uiManager);
|
265
|
-
}
|
266
|
-
|
267
258
|
void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependency> dependencies) {
|
268
259
|
// this event listener is triggered from C++ module, and it's only about theme / adaptive theme changes
|
269
260
|
if (dependencies.size() == 0) {
|
@@ -317,7 +308,7 @@ void HybridStyleSheet::onPlatformNativeDependenciesChange(std::vector<UnistyleDe
|
|
317
308
|
auto width = registry.shouldUsePointsForBreakpoints
|
318
309
|
? rawWidth / this->_unistylesRuntime->getPixelRatio()
|
319
310
|
: rawWidth;
|
320
|
-
|
311
|
+
|
321
312
|
registry.getState(rt).computeCurrentBreakpoint(width);
|
322
313
|
}
|
323
314
|
|
@@ -6,18 +6,16 @@
|
|
6
6
|
#include "HybridUnistylesStyleSheetSpec.hpp"
|
7
7
|
#include "RNStyle.h"
|
8
8
|
#include "Helpers.h"
|
9
|
-
#include "
|
9
|
+
#include "UnistylesConstants.h"
|
10
10
|
#include "Breakpoints.h"
|
11
11
|
#include "Parser.h"
|
12
|
-
#include "
|
13
|
-
#include "UnistylesMountHook.h"
|
12
|
+
#include "ShadowTreeManager.h"
|
14
13
|
|
15
14
|
using namespace margelo::nitro::unistyles;
|
16
15
|
using namespace facebook::react;
|
17
16
|
|
18
17
|
struct HybridStyleSheet: public HybridUnistylesStyleSheetSpec {
|
19
|
-
HybridStyleSheet(std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime,
|
20
|
-
: HybridObject(TAG), _unistylesRuntime{unistylesRuntime}, _uiManager{uiManager} {
|
18
|
+
HybridStyleSheet(std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime): HybridObject(TAG), _unistylesRuntime{unistylesRuntime} {
|
21
19
|
this->_unistylesRuntime->registerPlatformListener(
|
22
20
|
std::bind(&HybridStyleSheet::onPlatformDependenciesChange, this, std::placeholders::_1)
|
23
21
|
);
|
@@ -67,7 +65,6 @@ private:
|
|
67
65
|
void verifyAndSelectTheme(jsi::Runtime &rt);
|
68
66
|
void setThemeFromColorScheme(jsi::Runtime& rt);
|
69
67
|
void loadExternalMethods(const jsi::Value& thisValue, jsi::Runtime& rt);
|
70
|
-
void registerHooks(jsi::Runtime& rt);
|
71
68
|
void onPlatformDependenciesChange(std::vector<UnistyleDependency> dependencies);
|
72
69
|
void onPlatformNativeDependenciesChange(std::vector<UnistyleDependency> dependencies, UnistylesNativeMiniRuntime miniRuntime);
|
73
70
|
void onImeChange(UnistylesNativeMiniRuntime miniRuntime);
|
@@ -77,8 +74,6 @@ private:
|
|
77
74
|
double __unid = -1;
|
78
75
|
std::vector<std::unique_ptr<const std::function<void(std::vector<UnistyleDependency>&)>>> _changeListeners{};
|
79
76
|
std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
|
80
|
-
std::shared_ptr<core::UnistylesCommitHook> _unistylesCommitHook;
|
81
|
-
std::shared_ptr<core::UnistylesMountHook> _unistylesMountHook;
|
82
77
|
std::shared_ptr<UIManager> _uiManager;
|
83
78
|
};
|
84
79
|
|