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
package/README.md
CHANGED
@@ -15,21 +15,21 @@
|
|
15
15
|
## Installation
|
16
16
|
|
17
17
|
```shell
|
18
|
-
yarn add react-native-unistyles@
|
18
|
+
yarn add react-native-unistyles@next
|
19
19
|
```
|
20
20
|
|
21
21
|
Install dependencies:
|
22
22
|
|
23
23
|
```shell
|
24
|
-
yarn add react-native-edge-to-edge react-native-nitro-modules@0.
|
24
|
+
yarn add react-native-edge-to-edge react-native-nitro-modules@0.25.2
|
25
25
|
```
|
26
26
|
|
27
|
-
>
|
27
|
+
> To avoid unexpected behavior, always use a fixed version of `react-native-nitro-modules`
|
28
28
|
|
29
29
|
| react-native-unistyles | react-native-nitro-modules |
|
30
30
|
|------------------------|----------------------------|
|
31
|
-
| 3.0.0
|
32
|
-
| 3.0.0.
|
31
|
+
| 3.0.0-nightly-20250513 | 0.25.2 |
|
32
|
+
| 3.0.0-rc.4 | 0.25.2 |
|
33
33
|
|
34
34
|
Then follow [installation guides](https://unistyl.es/v3/start/getting-started) for your platform.
|
35
35
|
|
@@ -78,47 +78,53 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
|
|
78
78
|
<a href="https://github.com/oscklm">
|
79
79
|
<img src="https://avatars.githubusercontent.com/u/22825865?v=4" height="70px" width="70px" alt="oscklm" />
|
80
80
|
</a>
|
81
|
-
<a href="https://github.com/
|
82
|
-
<img src="https://avatars.githubusercontent.com/u/
|
81
|
+
<a href="https://github.com/ryanlanciaux">
|
82
|
+
<img src="https://avatars.githubusercontent.com/u/85041?v=4" height="70px" width="70px" alt="ryanlanciaux" />
|
83
83
|
</a>
|
84
|
-
<a href="https://github.com/
|
85
|
-
<img src="https://avatars.githubusercontent.com/u/
|
86
|
-
</a>
|
87
|
-
<a href="https://github.com/4cc3ssX">
|
88
|
-
<img src="https://avatars.githubusercontent.com/u/57473799?v=4" height="70px" width="70px" alt="4cc3ssX" />
|
89
|
-
</a>
|
90
|
-
<a href="https://github.com/dacoto97">
|
91
|
-
<img src="https://avatars.githubusercontent.com/u/16915053?v=4" height="70px" width="70px" alt="dacoto97" />
|
92
|
-
</a>
|
93
|
-
<a href="https://github.com/chinamcafee">
|
94
|
-
<img src="https://avatars.githubusercontent.com/u/3439961?v=4" height="70px" width="70px" alt="chinamcafee" />
|
84
|
+
<a href="https://github.com/loopsware">
|
85
|
+
<img src="https://avatars.githubusercontent.com/u/161434039?s=200&v=4" height="70px" width="70px" alt="loopsware" />
|
95
86
|
</a>
|
96
87
|
|
97
88
|
## Past sponsors
|
98
89
|
|
99
90
|
<a href="https://github.com/kmartinezmedia">
|
100
|
-
<img src="https://avatars.githubusercontent.com/u/6308123?s=200&v=4" height="
|
91
|
+
<img src="https://avatars.githubusercontent.com/u/6308123?s=200&v=4" height="60px" width="60px" alt="kmartinezmedia" />
|
101
92
|
</a>
|
102
93
|
<a href="https://github.com/levibuzolic">
|
103
|
-
<img src="https://avatars.githubusercontent.com/u/721323?v=4" height="
|
94
|
+
<img src="https://avatars.githubusercontent.com/u/721323?v=4" height="60px" width="60px" alt="levibuzolic" />
|
104
95
|
</a>
|
105
96
|
<a href="https://github.com/claudesortwell">
|
106
|
-
<img src="https://avatars.githubusercontent.com/u/41422239?v=4" height="
|
97
|
+
<img src="https://avatars.githubusercontent.com/u/41422239?v=4" height="60px" width="60px" alt="claudesortwell" />
|
107
98
|
</a>
|
108
99
|
<a href="https://github.com/luoxuhai">
|
109
|
-
<img src="https://avatars.githubusercontent.com/u/37284154?v=4" height="
|
100
|
+
<img src="https://avatars.githubusercontent.com/u/37284154?v=4" height="60px" width="60px" alt="luoxuhai" />
|
110
101
|
</a>
|
111
102
|
<a href="https://github.com">
|
112
|
-
<img src="https://avatars.githubusercontent.com/u/113348625?v=4" height="
|
103
|
+
<img src="https://avatars.githubusercontent.com/u/113348625?v=4" height="60px" width="60px" alt="anonymous" />
|
113
104
|
</a>
|
114
105
|
<a href="https://github.com/abanobboles">
|
115
|
-
<img src="https://avatars.githubusercontent.com/u/9078953?v=4" height="
|
106
|
+
<img src="https://avatars.githubusercontent.com/u/9078953?v=4" height="60px" width="60px" alt="abanobboles" />
|
116
107
|
</a>
|
117
108
|
<a href="https://github.com/hyoban">
|
118
|
-
<img src="https://avatars.githubusercontent.com/u/38493346?v=4" height="
|
109
|
+
<img src="https://avatars.githubusercontent.com/u/38493346?v=4" height="60px" width="60px" alt="hyoban" />
|
119
110
|
</a>
|
120
111
|
<a href="https://github.com/giovannilondero">
|
121
|
-
<img src="https://avatars.githubusercontent.com/u/10998991?v=4" height="
|
112
|
+
<img src="https://avatars.githubusercontent.com/u/10998991?v=4" height="60px" width="60px" alt="giovannilondero" />
|
113
|
+
</a>
|
114
|
+
<a href="https://github.com/4cc3ssX">
|
115
|
+
<img src="https://avatars.githubusercontent.com/u/57473799?v=4" height="60px" width="60px" alt="4cc3ssX" />
|
116
|
+
</a>
|
117
|
+
<a href="https://github.com/FilipiRafael">
|
118
|
+
<img src="https://avatars.githubusercontent.com/u/61629642?v=4" height="60px" width="60px" alt="FilipiRafael" />
|
119
|
+
</a>
|
120
|
+
<a href="https://github.com/dacoto97">
|
121
|
+
<img src="https://avatars.githubusercontent.com/u/16915053?v=4" height="60px" width="60px" alt="dacoto97" />
|
122
|
+
</a>
|
123
|
+
<a href="https://github.com/chinamcafee">
|
124
|
+
<img src="https://avatars.githubusercontent.com/u/3439961?v=4" height="60px" width="60px" alt="chinamcafee" />
|
125
|
+
</a>
|
126
|
+
<a href="https://github.com/guillaumehcht">
|
127
|
+
<img src="https://avatars.githubusercontent.com/u/80776475?v=4" height="60px" width="60px" alt="guillaumehcht" />
|
122
128
|
</a>
|
123
129
|
|
124
130
|
## Sponsor my work
|
package/Unistyles.podspec
CHANGED
@@ -29,6 +29,7 @@ Pod::Spec.new do |s|
|
|
29
29
|
if ENV["USE_FRAMEWORKS"]
|
30
30
|
s.dependency "React-Core"
|
31
31
|
add_dependency(s, "React-jsinspector", :framework_name => "jsinspector_modern")
|
32
|
+
add_dependency(s, "React-jsinspectortracing", :framework_name => 'jsinspector_moderntracing')
|
32
33
|
add_dependency(s, "React-rendererconsistency", :framework_name => "React_rendererconsistency")
|
33
34
|
end
|
34
35
|
|
@@ -10,19 +10,16 @@ using namespace facebook::react;
|
|
10
10
|
UnistylesModule::UnistylesModule(
|
11
11
|
jni::alias_ref<UnistylesModule::jhybridobject> jThis,
|
12
12
|
jni::alias_ref<react::JRuntimeExecutor::javaobject> runtimeExecutorHolder,
|
13
|
-
jni::alias_ref<JFabricUIManager::javaobject> fabricUIManager,
|
14
13
|
jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
|
15
14
|
): _runtimeExecutor(runtimeExecutorHolder->cthis()->get()),
|
16
|
-
_uiManager(fabricUIManager->getBinding()->getScheduler()->getUIManager()),
|
17
15
|
_nativePlatform(nativePlatform->cthis()) {}
|
18
16
|
|
19
17
|
jni::local_ref<UnistylesModule::jhybriddata> UnistylesModule::initHybrid(
|
20
18
|
jni::alias_ref<UnistylesModule::jhybridobject> jThis,
|
21
19
|
jni::alias_ref<JRuntimeExecutor::javaobject> runtimeExecutorHolder,
|
22
|
-
jni::alias_ref<JFabricUIManager::javaobject> fabricUIManager,
|
23
20
|
jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
|
24
21
|
) {
|
25
|
-
return makeCxxInstance(jThis, runtimeExecutorHolder,
|
22
|
+
return makeCxxInstance(jThis, runtimeExecutorHolder, nativePlatform);
|
26
23
|
}
|
27
24
|
|
28
25
|
void UnistylesModule::registerNatives() {
|
@@ -34,10 +31,9 @@ void UnistylesModule::registerNatives() {
|
|
34
31
|
|
35
32
|
jni::local_ref<BindingsInstallerHolder::javaobject> UnistylesModule::getBindingsInstaller(jni::alias_ref<UnistylesModule::javaobject> jobj) {
|
36
33
|
auto& runtimeExecutor = jobj->cthis()->_runtimeExecutor;
|
37
|
-
auto& uiManager = jobj->cthis()->_uiManager;
|
38
34
|
auto& nativePlatform = jobj->cthis()->_nativePlatform;
|
39
35
|
|
40
|
-
return BindingsInstallerHolder::newObjectCxxArgs([&runtimeExecutor, &
|
36
|
+
return BindingsInstallerHolder::newObjectCxxArgs([&runtimeExecutor, &nativePlatform](jsi::Runtime& rt) {
|
41
37
|
// function is called on: first init and every live reload
|
42
38
|
// check if this is live reload, if so let's replace UnistylesRuntime with new runtime
|
43
39
|
auto hasUnistylesRuntime = HybridObjectRegistry::hasHybridObject("UnistylesRuntime");
|
@@ -56,7 +52,7 @@ jni::local_ref<BindingsInstallerHolder::javaobject> UnistylesModule::getBindings
|
|
56
52
|
|
57
53
|
// init hybrids
|
58
54
|
auto unistylesRuntime = std::make_shared<HybridUnistylesRuntime>(nativePlatform, rt, runOnJSThread);
|
59
|
-
auto styleSheet = std::make_shared<HybridStyleSheet>(unistylesRuntime
|
55
|
+
auto styleSheet = std::make_shared<HybridStyleSheet>(unistylesRuntime);
|
60
56
|
|
61
57
|
HybridObjectRegistry::registerHybridObjectConstructor("UnistylesRuntime", [unistylesRuntime]() -> std::shared_ptr<HybridObject>{
|
62
58
|
return unistylesRuntime;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
3
|
#include <ReactCommon/BindingsInstallerHolder.h>
|
4
|
-
#include <react/fabric/JFabricUIManager.h>
|
5
4
|
#include <react/jni/JRuntimeExecutor.h>
|
6
5
|
#include <react/renderer/scheduler/Scheduler.h>
|
7
6
|
#include <fbjni/fbjni.h>
|
@@ -19,7 +18,6 @@ struct UnistylesModule : public jni::HybridClass<UnistylesModule> {
|
|
19
18
|
explicit UnistylesModule(
|
20
19
|
jni::alias_ref<jhybridobject> jThis,
|
21
20
|
jni::alias_ref<react::JRuntimeExecutor::javaobject> runtimeExecutorHolder,
|
22
|
-
jni::alias_ref<JFabricUIManager::javaobject> fabricUIManager,
|
23
21
|
jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
|
24
22
|
);
|
25
23
|
|
@@ -27,14 +25,12 @@ struct UnistylesModule : public jni::HybridClass<UnistylesModule> {
|
|
27
25
|
static jni::local_ref<jhybriddata> initHybrid(
|
28
26
|
jni::alias_ref<jhybridobject> jThis,
|
29
27
|
jni::alias_ref<JRuntimeExecutor::javaobject> runtimeExecutorHolder,
|
30
|
-
jni::alias_ref<JFabricUIManager::javaobject>,
|
31
28
|
jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
|
32
29
|
);
|
33
30
|
|
34
31
|
static jni::local_ref<BindingsInstallerHolder::javaobject> getBindingsInstaller(jni::alias_ref<UnistylesModule::javaobject> jThis);
|
35
32
|
|
36
33
|
private:
|
37
|
-
std::shared_ptr<UIManager> _uiManager;
|
38
34
|
RuntimeExecutor _runtimeExecutor;
|
39
35
|
std::shared_ptr<HybridNativePlatformSpec> _nativePlatform;
|
40
36
|
};
|
@@ -27,7 +27,7 @@ import java.util.Locale
|
|
27
27
|
@Keep
|
28
28
|
@DoNotStrip
|
29
29
|
class NativePlatformAndroid(private val reactContext: ReactApplicationContext): HybridNativePlatformSpec(), LifecycleEventListener {
|
30
|
-
private val _insets = NativePlatformInsets(reactContext, this::getMiniRuntime) { this.
|
30
|
+
private val _insets = NativePlatformInsets(reactContext, this::getMiniRuntime) { this.onConfigChange() }
|
31
31
|
private var _miniRuntime: UnistylesNativeMiniRuntime = buildMiniRuntime()
|
32
32
|
private val _listener = NativePlatformListener(reactContext, this::getMiniRuntime) { this.diffMiniRuntime() }
|
33
33
|
|
@@ -263,6 +263,10 @@ class NativePlatformAndroid(private val reactContext: ReactApplicationContext):
|
|
263
263
|
return changedDependencies
|
264
264
|
}
|
265
265
|
|
266
|
+
private fun onConfigChange() {
|
267
|
+
this._listener.onConfigChange()
|
268
|
+
}
|
269
|
+
|
266
270
|
override fun registerPlatformListener(callback: (dependencies: Array<UnistyleDependency>, miniRuntime: UnistylesNativeMiniRuntime) -> Unit) {
|
267
271
|
this._listener.addPlatformListener(callback)
|
268
272
|
}
|
@@ -12,7 +12,6 @@ import androidx.core.view.WindowInsetsCompat
|
|
12
12
|
import com.facebook.proguard.annotations.DoNotStrip
|
13
13
|
import com.facebook.react.bridge.ReactApplicationContext
|
14
14
|
import com.margelo.nitro.unistyles.Insets
|
15
|
-
import com.margelo.nitro.unistyles.UnistyleDependency
|
16
15
|
import com.margelo.nitro.unistyles.UnistylesNativeMiniRuntime
|
17
16
|
|
18
17
|
typealias CxxImeListener = (miniRuntime: UnistylesNativeMiniRuntime) -> Unit
|
@@ -22,7 +21,7 @@ typealias CxxImeListener = (miniRuntime: UnistylesNativeMiniRuntime) -> Unit
|
|
22
21
|
class NativePlatformInsets(
|
23
22
|
private val reactContext: ReactApplicationContext,
|
24
23
|
private val getMiniRuntime: () -> UnistylesNativeMiniRuntime,
|
25
|
-
private val
|
24
|
+
private val onConfigChange: () -> Unit
|
26
25
|
) {
|
27
26
|
private var _shouldListenToImeEvents = false
|
28
27
|
private val _imeListeners: MutableList<CxxImeListener> = mutableListOf()
|
@@ -106,7 +105,7 @@ class NativePlatformInsets(
|
|
106
105
|
return
|
107
106
|
}
|
108
107
|
|
109
|
-
|
108
|
+
this@NativePlatformInsets.onConfigChange()
|
110
109
|
|
111
110
|
if (shouldEmitImeEvent) {
|
112
111
|
this@NativePlatformInsets.emitImeEvent(this.getMiniRuntime())
|
@@ -5,11 +5,8 @@ import com.facebook.jni.HybridData
|
|
5
5
|
import com.facebook.proguard.annotations.DoNotStrip
|
6
6
|
import com.facebook.react.bridge.ReactApplicationContext
|
7
7
|
import com.facebook.react.bridge.RuntimeExecutor
|
8
|
-
import com.facebook.react.fabric.FabricUIManager
|
9
8
|
import com.facebook.react.turbomodule.core.interfaces.BindingsInstallerHolder
|
10
9
|
import com.facebook.react.turbomodule.core.interfaces.TurboModuleWithJSIBindings
|
11
|
-
import com.facebook.react.uimanager.UIManagerHelper
|
12
|
-
import com.facebook.react.uimanager.common.UIManagerType
|
13
10
|
import com.margelo.nitro.unistyles.HybridNativePlatformSpec
|
14
11
|
import com.margelo.nitro.unistyles.unistylesOnLoad.Companion.initializeNative
|
15
12
|
|
@@ -34,10 +31,8 @@ class UnistylesModule(reactContext: ReactApplicationContext): NativeTurboUnistyl
|
|
34
31
|
private fun initializeHybridData(reactContext: ReactApplicationContext): HybridData {
|
35
32
|
val runtimeExecutor = reactContext.catalystInstance?.runtimeExecutor
|
36
33
|
?: throw IllegalStateException("Unistyles: React Native runtime executor is not available. Please follow installation guides.")
|
37
|
-
val fabricUIManager = UIManagerHelper.getUIManager(reactContext, UIManagerType.FABRIC) as? FabricUIManager
|
38
|
-
?: throw IllegalStateException("Unistyles: Fabric UI Manager is not available. Please follow installation guides.")
|
39
34
|
|
40
|
-
return initHybrid(runtimeExecutor,
|
35
|
+
return initHybrid(runtimeExecutor, _nativePlatform)
|
41
36
|
}
|
42
37
|
|
43
38
|
@DoNotStrip
|
@@ -46,7 +41,6 @@ class UnistylesModule(reactContext: ReactApplicationContext): NativeTurboUnistyl
|
|
46
41
|
@DoNotStrip
|
47
42
|
private external fun initHybrid(
|
48
43
|
runtimeExecutor: RuntimeExecutor,
|
49
|
-
fabricUIManager: FabricUIManager,
|
50
44
|
nativePlatform: HybridNativePlatformSpec
|
51
45
|
): HybridData
|
52
46
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"main": "../../../lib/commonjs/components/native/ActivityIndicator.js",
|
3
3
|
"module": "../../../lib/module/components/native/ActivityIndicator.js",
|
4
|
+
"browser": "../../../lib/module/components/native/ActivityIndicator.js",
|
4
5
|
"react-native": "../../../src/components/native/ActivityIndicator.tsx"
|
5
6
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"main": "../../../lib/commonjs/components/native/Image.js",
|
3
3
|
"module": "../../../lib/module/components/native/Image.js",
|
4
|
-
"
|
4
|
+
"browser": "../../../lib/module/components/native/Image.js",
|
5
|
+
"react-native": "../../../src/components/native/Image.native.tsx"
|
5
6
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"main": "../../../lib/commonjs/components/native/ImageBackground.js",
|
3
3
|
"module": "../../../lib/module/components/native/ImageBackground.js",
|
4
|
+
"browser": "../../../lib/module/components/native/ImageBackground.js",
|
4
5
|
"react-native": "../../../src/components/native/ImageBackground.native.tsx"
|
5
6
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"main": "../../../lib/commonjs/components/native/KeyboardAvoidingView.js",
|
3
3
|
"module": "../../../lib/module/components/native/KeyboardAvoidingView.js",
|
4
|
+
"browser": "../../../lib/module/components/native/KeyboardAvoidingView.js",
|
4
5
|
"react-native": "../../../src/components/native/KeyboardAvoidingView.tsx"
|
5
6
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"main": "../../../lib/commonjs/components/native/NativeText.js",
|
3
3
|
"module": "../../../lib/module/components/native/NativeText.js",
|
4
|
+
"browser": "../../../lib/module/components/native/NativeText.js",
|
4
5
|
"react-native": "../../../src/components/native/NativeText.native.tsx"
|
5
6
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"main": "../../../lib/commonjs/components/native/NativeView.js",
|
3
3
|
"module": "../../../lib/module/components/native/NativeView.js",
|
4
|
+
"browser": "../../../lib/module/components/native/NativeView.js",
|
4
5
|
"react-native": "../../../src/components/native/NativeView.native.tsx"
|
5
6
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"main": "../../../lib/commonjs/components/native/Pressable.js",
|
3
3
|
"module": "../../../lib/module/components/native/Pressable.js",
|
4
|
+
"browser": "../../../lib/module/components/native/Pressable.js",
|
4
5
|
"react-native": "../../../src/components/native/Pressable.native.tsx"
|
5
6
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"main": "../../../lib/commonjs/components/native/RefreshControl.js",
|
3
3
|
"module": "../../../lib/module/components/native/RefreshControl.js",
|
4
|
+
"browser": "../../../lib/module/components/native/RefreshControl.js",
|
4
5
|
"react-native": "../../../src/components/native/RefreshControl.tsx"
|
5
6
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"main": "../../../lib/commonjs/components/native/ScrollView.js",
|
3
3
|
"module": "../../../lib/module/components/native/ScrollView.js",
|
4
|
+
"browser": "../../../lib/module/components/native/ScrollView.js",
|
4
5
|
"react-native": "../../../src/components/native/ScrollView.tsx"
|
5
6
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"main": "../../../lib/commonjs/components/native/SectionList.js",
|
3
3
|
"module": "../../../lib/module/components/native/SectionList.js",
|
4
|
+
"browser": "../../../lib/module/components/native/SectionList.js",
|
4
5
|
"react-native": "../../../src/components/native/SectionList.tsx"
|
5
6
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"main": "../../../lib/commonjs/components/native/TouchableHighlight.js",
|
3
3
|
"module": "../../../lib/module/components/native/TouchableHighlight.js",
|
4
|
+
"browser": "../../../lib/module/components/native/TouchableHighlight.js",
|
4
5
|
"react-native": "../../../src/components/native/TouchableHighlight.tsx"
|
5
6
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"main": "../../../lib/commonjs/components/native/TouchableOpacity.js",
|
3
3
|
"module": "../../../lib/module/components/native/TouchableOpacity.js",
|
4
|
+
"browser": "../../../lib/module/components/native/TouchableOpacity.js",
|
4
5
|
"react-native": "../../../src/components/native/TouchableOpacity.tsx"
|
5
6
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"main": "../../../lib/commonjs/components/native/VirtualizedList.js",
|
3
3
|
"module": "../../../lib/module/components/native/VirtualizedList.js",
|
4
|
+
"browser": "../../../lib/module/components/native/VirtualizedList.js",
|
4
5
|
"react-native": "../../../src/components/native/VirtualizedList.tsx"
|
5
6
|
}
|
package/cxx/common/Helpers.h
CHANGED
@@ -122,6 +122,10 @@ inline Variants variantsToPairs(jsi::Runtime& rt, jsi::Object&& variants) {
|
|
122
122
|
if (variantValue.isString()) {
|
123
123
|
pairs.emplace_back(std::make_pair(variantName, variantValue.asString(rt).utf8(rt)));
|
124
124
|
}
|
125
|
+
|
126
|
+
if (variantValue.isNumber()) {
|
127
|
+
pairs.emplace_back(std::make_pair(variantName, std::to_string(static_cast<int>(variantValue.asNumber()))));
|
128
|
+
}
|
125
129
|
});
|
126
130
|
|
127
131
|
return pairs;
|
@@ -87,19 +87,28 @@ jsi::Function HostUnistyle::createAddVariantsProxyFunction(jsi::Runtime& rt) {
|
|
87
87
|
Variants variants = helpers::variantsToPairs(rt, arguments[0].asObject(rt));
|
88
88
|
parser::Parser parser = parser::Parser(this->_unistylesRuntime);
|
89
89
|
|
90
|
-
|
91
|
-
|
90
|
+
auto stylesheetCopy = std::make_shared<StyleSheet>(
|
91
|
+
this->_stylesheet->tag,
|
92
|
+
this->_stylesheet->type,
|
93
|
+
jsi::Value(rt, this->_stylesheet->rawValue).asObject(rt)
|
94
|
+
);
|
95
|
+
|
96
|
+
parser.buildUnistyles(rt, stylesheetCopy);
|
97
|
+
parser.parseUnistyles(rt, stylesheetCopy);
|
98
|
+
|
99
|
+
helpers::enumerateJSIObject(rt, thisVal.asObject(rt), [this, &parser, &rt, &variants, stylesheetCopy](const std::string& name, jsi::Value& value){
|
100
|
+
if (name == helpers::ADD_VARIANTS_FN || !stylesheetCopy->unistyles.contains(name)) {
|
92
101
|
return;
|
93
102
|
}
|
94
103
|
|
95
|
-
auto unistyle =
|
96
|
-
|
104
|
+
auto unistyle = stylesheetCopy->unistyles[name];
|
105
|
+
|
97
106
|
if (unistyle->dependsOn(UnistyleDependency::VARIANTS)) {
|
98
107
|
parser.rebuildUnistyle(rt, unistyle, variants, std::nullopt);
|
99
108
|
}
|
100
109
|
});
|
101
110
|
|
102
|
-
auto style = std::make_shared<core::HostUnistyle>(
|
111
|
+
auto style = std::make_shared<core::HostUnistyle>(stylesheetCopy, this->_unistylesRuntime, variants);
|
103
112
|
auto styleHostObject = jsi::Object::createFromHostObject(rt, style);
|
104
113
|
|
105
114
|
return styleHostObject;
|
package/cxx/core/StyleSheet.h
CHANGED
@@ -8,32 +8,11 @@ namespace margelo::nitro::unistyles::core {
|
|
8
8
|
// React Native uses 0-10
|
9
9
|
// Reanimated uses 27-28
|
10
10
|
constexpr shadow::ShadowNodeTraits::Trait UnistylesCommitTrait{1 << 30};
|
11
|
-
constexpr shadow::ShadowNodeTraits::Trait UnistylesMountTrait{1 << 31};
|
12
11
|
|
13
12
|
struct UnistylesCommitShadowNode: public shadow::ShadowNode {
|
14
13
|
inline void addUnistylesCommitTrait() {
|
15
14
|
traits_.set(UnistylesCommitTrait);
|
16
15
|
}
|
17
|
-
|
18
|
-
inline void removeUnistylesCommitTrait() {
|
19
|
-
traits_.unset(UnistylesCommitTrait);
|
20
|
-
}
|
21
|
-
|
22
|
-
inline bool hasUnistylesCommitTrait() {
|
23
|
-
return traits_.check(UnistylesCommitTrait);
|
24
|
-
}
|
25
|
-
|
26
|
-
inline void addUnistylesMountTrait() {
|
27
|
-
traits_.set(UnistylesMountTrait);
|
28
|
-
}
|
29
|
-
|
30
|
-
inline void removeUnistylesMountTrait() {
|
31
|
-
traits_.unset(UnistylesMountTrait);
|
32
|
-
}
|
33
|
-
|
34
|
-
inline bool hasUnistylesMountTrait() {
|
35
|
-
return traits_.check(UnistylesMountTrait);
|
36
|
-
}
|
37
16
|
};
|
38
17
|
|
39
18
|
}
|