react-native-unistyles 3.0.0-beta.8 → 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 +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 +35 -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
@@ -1,9 +1,11 @@
|
|
1
|
+
import { Animated } from 'react-native'
|
1
2
|
import type { UnistylesBreakpoints } from '../../global'
|
2
|
-
import {
|
3
|
-
import type { UnistyleDependency } from '../../specs/NativePlatform'
|
3
|
+
import type { UnistyleDependency } from '../../specs/NativePlatform/NativePlatform.nitro'
|
4
4
|
import { ColorScheme, Orientation } from '../../specs/types'
|
5
5
|
import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../../types/stylesheet'
|
6
|
-
import {
|
6
|
+
import { isUnistylesMq, parseMq } from '../../utils'
|
7
|
+
import * as unistyles from '../services'
|
8
|
+
import { UNI_GENERATED_KEYS, type UniGeneratedKey, type UniGeneratedStyle } from '../types'
|
7
9
|
import { keyInObject, reduceObject } from './common'
|
8
10
|
|
9
11
|
export const schemeToTheme = (scheme: ColorScheme) => {
|
@@ -49,13 +51,7 @@ export const extractSecrets = (object: any) => {
|
|
49
51
|
return undefined
|
50
52
|
}
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
-
if (Object.keys(hiddenSecrets).length === 0) {
|
55
|
-
return undefined
|
56
|
-
}
|
57
|
-
|
58
|
-
return reduceObject(hiddenSecrets, secret => secret.value)
|
54
|
+
return reduceObject(Object.getOwnPropertyDescriptors(secrets), secret => secret.value)
|
59
55
|
}
|
60
56
|
|
61
57
|
export const removeInlineStyles = (values: UnistylesValues) => {
|
@@ -70,8 +66,6 @@ export const removeInlineStyles = (values: UnistylesValues) => {
|
|
70
66
|
return returnValue
|
71
67
|
}
|
72
68
|
|
73
|
-
export const isInDocument = (element: HTMLElement) => document.body.contains(element)
|
74
|
-
|
75
69
|
export const getMediaQuery = (query: string, allBreakpoints: Array<string>) => {
|
76
70
|
if (Object.values(Orientation).includes(query as Orientation)) {
|
77
71
|
return `@media (orientation: ${query})`
|
@@ -89,18 +83,18 @@ export const getMediaQuery = (query: string, allBreakpoints: Array<string>) => {
|
|
89
83
|
return `@media ${queries}`
|
90
84
|
}
|
91
85
|
|
92
|
-
const breakpointValue =
|
86
|
+
const breakpointValue = unistyles.services.runtime.breakpoints[query as keyof UnistylesBreakpoints] ?? 0
|
93
87
|
const nextBreakpoint = allBreakpoints
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
88
|
+
.filter((b): b is keyof UnistylesBreakpoints => b in unistyles.services.runtime.breakpoints)
|
89
|
+
.map(b => unistyles.services.runtime.breakpoints[b] as number)
|
90
|
+
.sort((a, b) => a - b)
|
91
|
+
.find(b => b > breakpointValue)
|
92
|
+
const queries = [
|
93
|
+
`(min-width: ${breakpointValue}px)`,
|
94
|
+
nextBreakpoint ? `(max-width: ${nextBreakpoint - 1}px)` : undefined,
|
95
|
+
].filter(Boolean).join(' and ')
|
96
|
+
|
97
|
+
return `@media ${queries}`
|
104
98
|
}
|
105
99
|
|
106
100
|
export const extractUnistyleDependencies = (value: any) => {
|
@@ -112,3 +106,41 @@ export const extractUnistyleDependencies = (value: any) => {
|
|
112
106
|
|
113
107
|
return Array.isArray(dependencies) ? dependencies : []
|
114
108
|
}
|
109
|
+
|
110
|
+
export const checkForProp = (value: any, prop: string): boolean => {
|
111
|
+
if (Array.isArray(value)) {
|
112
|
+
return value.some(nestedValue => checkForProp(nestedValue, prop))
|
113
|
+
}
|
114
|
+
|
115
|
+
if (typeof value === 'object' && value !== null) {
|
116
|
+
return keyInObject(value, prop)
|
117
|
+
? true
|
118
|
+
: keyInObject(value, '_web')
|
119
|
+
? checkForProp(value._web, prop)
|
120
|
+
: false
|
121
|
+
}
|
122
|
+
|
123
|
+
return false
|
124
|
+
}
|
125
|
+
|
126
|
+
export const checkForAnimated = (value: any): boolean => {
|
127
|
+
if (Array.isArray(value)) {
|
128
|
+
return value.some(checkForAnimated)
|
129
|
+
}
|
130
|
+
|
131
|
+
if (typeof value === 'object' && value !== null) {
|
132
|
+
const objectValues = Object.values(value)
|
133
|
+
const secrets = extractSecrets(value)
|
134
|
+
|
135
|
+
// @ts-expect-error React Native Web exports Animated.AnimatedNode as Animated.Node
|
136
|
+
return value instanceof Animated.Node ||
|
137
|
+
objectValues.length > 0 && objectValues.some(checkForAnimated) ||
|
138
|
+
secrets && Object.keys(secrets).length === 0
|
139
|
+
}
|
140
|
+
|
141
|
+
return false
|
142
|
+
}
|
143
|
+
|
144
|
+
export const isGeneratedUnistyle = (value: Record<string, any>): value is UniGeneratedStyle => {
|
145
|
+
return Object.keys(value).every(key => UNI_GENERATED_KEYS.includes(key as UniGeneratedKey))
|
146
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import type { StyleProp } from 'react-native'
|
2
|
+
import { getClassName } from '../core'
|
3
|
+
import type { RNStyle, UnistylesValues } from '../types'
|
4
|
+
import { createUnistylesRef } from '../web/utils/createUnistylesRef'
|
5
|
+
|
6
|
+
export const getWebProps = <T>(style: StyleProp<RNStyle>) => {
|
7
|
+
const styles = getClassName(style as UnistylesValues)
|
8
|
+
const ref = createUnistylesRef<T>(styles)
|
9
|
+
const [generatedStyles] = styles ?? []
|
10
|
+
|
11
|
+
return {
|
12
|
+
className: [
|
13
|
+
generatedStyles?.hash,
|
14
|
+
generatedStyles?.injectedClassName,
|
15
|
+
].filter(Boolean).join(' '),
|
16
|
+
ref
|
17
|
+
}
|
18
|
+
}
|
package/web/package.json
ADDED
@@ -1,52 +0,0 @@
|
|
1
|
-
#include "UnistylesCommitHook.h"
|
2
|
-
|
3
|
-
using namespace margelo::nitro::unistyles;
|
4
|
-
using namespace facebook::react;
|
5
|
-
|
6
|
-
core::UnistylesCommitHook::~UnistylesCommitHook() noexcept {
|
7
|
-
_uiManager->unregisterCommitHook(*this);
|
8
|
-
}
|
9
|
-
|
10
|
-
void core::UnistylesCommitHook::commitHookWasRegistered(const UIManager &uiManager) noexcept {}
|
11
|
-
void core::UnistylesCommitHook::commitHookWasUnregistered(const UIManager &uiManager) noexcept {}
|
12
|
-
|
13
|
-
RootShadowNode::Unshared core::UnistylesCommitHook::shadowTreeWillCommit(
|
14
|
-
const ShadowTree &shadowTree,
|
15
|
-
const RootShadowNode::Shared &oldRootShadowNode,
|
16
|
-
const RootShadowNode::Unshared &newRootShadowNode
|
17
|
-
) noexcept {
|
18
|
-
RootShadowNode::Unshared rootNode = newRootShadowNode;
|
19
|
-
auto unistylesRootNode = std::reinterpret_pointer_cast<core::UnistylesCommitShadowNode>(newRootShadowNode);
|
20
|
-
|
21
|
-
// this is Unistyles commit, we don't need to override it
|
22
|
-
if (unistylesRootNode->hasUnistylesCommitTrait()) {
|
23
|
-
unistylesRootNode->removeUnistylesCommitTrait();
|
24
|
-
unistylesRootNode->addUnistylesMountTrait();
|
25
|
-
|
26
|
-
return newRootShadowNode;
|
27
|
-
}
|
28
|
-
|
29
|
-
// this is React Native / Reanimated commit
|
30
|
-
// merge Unistyles updates before it completes
|
31
|
-
auto& registry = core::UnistylesRegistry::get();
|
32
|
-
|
33
|
-
return registry.trafficController.withLock([&](){
|
34
|
-
auto& shadowLeafUpdates = registry.trafficController.getUpdates();
|
35
|
-
|
36
|
-
// oops, no updates from Unistyles yet, skip it!
|
37
|
-
if (shadowLeafUpdates.size() == 0) {
|
38
|
-
return newRootShadowNode;
|
39
|
-
}
|
40
|
-
|
41
|
-
auto affectedNodes = shadow::ShadowTreeManager::findAffectedNodes(*rootNode, shadowLeafUpdates);
|
42
|
-
|
43
|
-
registry.trafficController.stopUnistylesTraffic();
|
44
|
-
|
45
|
-
// we have few updates, so merge it
|
46
|
-
return std::static_pointer_cast<RootShadowNode>(shadow::ShadowTreeManager::cloneShadowTree(
|
47
|
-
*rootNode,
|
48
|
-
shadowLeafUpdates,
|
49
|
-
affectedNodes
|
50
|
-
));
|
51
|
-
});
|
52
|
-
}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#include <react/renderer/uimanager/UIManager.h>
|
4
|
-
#include <react/renderer/uimanager/UIManagerCommitHook.h>
|
5
|
-
#include "ShadowTreeManager.h"
|
6
|
-
#include "ShadowTrafficController.h"
|
7
|
-
|
8
|
-
namespace margelo::nitro::unistyles::core {
|
9
|
-
|
10
|
-
using namespace facebook::react;
|
11
|
-
|
12
|
-
struct UnistylesCommitHook : public UIManagerCommitHook {
|
13
|
-
UnistylesCommitHook(std::shared_ptr<UIManager> uiManager) : _uiManager{uiManager} {
|
14
|
-
_uiManager->registerCommitHook(*this);
|
15
|
-
}
|
16
|
-
|
17
|
-
~UnistylesCommitHook() noexcept override;
|
18
|
-
|
19
|
-
void commitHookWasRegistered(const UIManager &uiManager) noexcept override;
|
20
|
-
void commitHookWasUnregistered(const UIManager &uiManager) noexcept override;
|
21
|
-
RootShadowNode::Unshared shadowTreeWillCommit(const ShadowTree &shadowTree, const RootShadowNode::Shared &oldRootShadowNode, const RootShadowNode::Unshared &newRootShadowNode) noexcept override;
|
22
|
-
|
23
|
-
private:
|
24
|
-
std::shared_ptr<UIManager> _uiManager;
|
25
|
-
};
|
26
|
-
|
27
|
-
}
|
@@ -1,28 +0,0 @@
|
|
1
|
-
#include "UnistylesMountHook.h"
|
2
|
-
|
3
|
-
using namespace margelo::nitro::unistyles;
|
4
|
-
using namespace facebook::react;
|
5
|
-
|
6
|
-
core::UnistylesMountHook::~UnistylesMountHook() noexcept {
|
7
|
-
_uiManager->unregisterMountHook(*this);
|
8
|
-
}
|
9
|
-
|
10
|
-
void core::UnistylesMountHook::shadowTreeDidMount(RootShadowNode::Shared const &rootShadowNode, double mountTime) noexcept {
|
11
|
-
auto rootNode = std::const_pointer_cast<RootShadowNode>(rootShadowNode);
|
12
|
-
auto unistylesRootNode = std::reinterpret_pointer_cast<core::UnistylesCommitShadowNode>(rootNode);
|
13
|
-
|
14
|
-
// if this is Unistyles commit, do nothing
|
15
|
-
if (unistylesRootNode->hasUnistylesMountTrait()) {
|
16
|
-
unistylesRootNode->removeUnistylesMountTrait();
|
17
|
-
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
|
21
|
-
// this is React Native or Reanimated commit
|
22
|
-
// one more time merge Unistyles changes
|
23
|
-
auto& registry = core::UnistylesRegistry::get();
|
24
|
-
|
25
|
-
if (registry.trafficController.shouldStop()) {
|
26
|
-
registry.trafficController.resumeUnistylesTraffic();
|
27
|
-
}
|
28
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#include <react/renderer/uimanager/UIManager.h>
|
4
|
-
#include <react/renderer/uimanager/UIManagerMountHook.h>
|
5
|
-
#include "ShadowTreeManager.h"
|
6
|
-
|
7
|
-
namespace margelo::nitro::unistyles::core {
|
8
|
-
|
9
|
-
using namespace facebook::react;
|
10
|
-
|
11
|
-
struct UnistylesMountHook : public UIManagerMountHook {
|
12
|
-
UnistylesMountHook(std::shared_ptr<UIManager> uiManager): _uiManager{uiManager} {
|
13
|
-
_uiManager->registerMountHook(*this);
|
14
|
-
}
|
15
|
-
|
16
|
-
~UnistylesMountHook() noexcept override;
|
17
|
-
|
18
|
-
void shadowTreeDidMount(RootShadowNode::Shared const &rootShadowNode, double mountTime) noexcept override;
|
19
|
-
|
20
|
-
private:
|
21
|
-
std::shared_ptr<UIManager> _uiManager;
|
22
|
-
};
|
23
|
-
|
24
|
-
}
|
package/lib/module/package.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"type":"module"}
|
File without changes
|