react-native-unistyles 3.0.0-beta.4 → 3.0.0-beta.6
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 +18 -3
- package/android/src/main/cxx/NativeUnistylesModule.cpp +2 -2
- package/android/src/main/cxx/NativeUnistylesModule.h +1 -1
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +1 -2
- package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +4 -0
- package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +2 -1
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +0 -4
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +6 -6
- package/components/native/ActivityIndicator/package.json +2 -1
- package/components/native/Animated/package.json +5 -0
- package/components/native/FlatList/package.json +2 -1
- package/components/native/Image/package.json +2 -1
- package/components/native/ImageBackground/package.json +2 -1
- package/components/native/KeyboardAvoidingView/package.json +2 -1
- package/components/native/NativeText/package.json +5 -0
- package/components/native/NativeView/package.json +5 -0
- package/components/native/Pressable/package.json +1 -1
- package/components/native/RefreshControl/package.json +2 -1
- package/components/native/ScrollView/package.json +2 -1
- package/components/native/SectionList/package.json +2 -1
- package/components/native/Switch/package.json +2 -1
- package/components/native/Text/package.json +2 -1
- package/components/native/TextInput/package.json +2 -1
- package/components/native/TouchableHighlight/package.json +2 -1
- package/components/native/TouchableOpacity/package.json +2 -1
- package/components/native/View/package.json +2 -1
- package/components/native/VirtualizedList/package.json +2 -1
- package/cxx/common/Constants.h +4 -4
- package/cxx/common/Helpers.h +1 -1
- package/cxx/core/HashGenerator.cpp +23 -0
- package/cxx/core/HashGenerator.h +13 -0
- package/cxx/core/HostUnistyle.cpp +83 -0
- package/cxx/core/HostUnistyle.h +27 -0
- package/cxx/core/RNStyle.h +18 -0
- package/cxx/core/Unistyle.h +13 -4
- package/cxx/core/UnistyleWrapper.h +92 -47
- package/cxx/core/UnistylesRegistry.cpp +40 -11
- package/cxx/core/UnistylesRegistry.h +5 -4
- package/cxx/hybridObjects/HybridNavigationBar.cpp +3 -3
- package/cxx/hybridObjects/HybridNavigationBar.h +2 -2
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +39 -45
- package/cxx/hybridObjects/HybridShadowRegistry.h +0 -10
- package/cxx/hybridObjects/HybridStatusBar.cpp +3 -3
- package/cxx/hybridObjects/HybridStatusBar.h +2 -2
- package/cxx/hybridObjects/HybridStyleSheet.cpp +52 -10
- package/cxx/hybridObjects/HybridStyleSheet.h +2 -1
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +15 -15
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -2
- package/cxx/parser/Parser.cpp +26 -27
- package/cxx/parser/Parser.h +2 -1
- package/ios/NativePlatform+ios.swift +21 -11
- package/ios/NativePlatform.swift +2 -2
- package/ios/UnistylesModuleOnLoad.h +4 -4
- package/ios/UnistylesModuleOnLoad.mm +5 -8
- package/lib/commonjs/components/ScopedTheme.js.map +1 -1
- package/lib/commonjs/components/index.js +0 -7
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/native/Animated.js +23 -0
- package/lib/commonjs/components/native/Animated.js.map +1 -0
- package/lib/commonjs/components/native/ImageBackground.js +47 -1
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/ImageBackground.native.js +10 -0
- package/lib/commonjs/components/native/ImageBackground.native.js.map +1 -0
- package/lib/commonjs/components/native/NativeText.js +13 -0
- package/lib/commonjs/components/native/NativeText.js.map +1 -0
- package/lib/commonjs/components/native/NativeText.native.js +18 -0
- package/lib/commonjs/components/native/NativeText.native.js.map +1 -0
- package/lib/commonjs/components/native/NativeView.js +9 -0
- package/lib/commonjs/components/native/NativeView.js.map +1 -0
- package/lib/commonjs/components/native/NativeView.native.js +20 -0
- package/lib/commonjs/components/native/NativeView.native.js.map +1 -0
- package/lib/commonjs/components/native/Pressable.js +26 -51
- package/lib/commonjs/components/native/Pressable.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js +25 -9
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js +33 -5
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js +54 -0
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -0
- package/lib/commonjs/core/createUnistylesImageBackground.js +41 -15
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/getClassname.js +23 -0
- package/lib/commonjs/core/getClassname.js.map +1 -0
- package/lib/commonjs/core/getClassname.native.js +9 -0
- package/lib/commonjs/core/getClassname.native.js.map +1 -0
- package/lib/commonjs/core/index.js +14 -7
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/core/passForwardRef.js +2 -2
- package/lib/commonjs/core/passForwardRef.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/index.js +13 -0
- package/lib/commonjs/core/useProxifiedUnistyles/index.js.map +1 -0
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js +22 -0
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js.map +1 -0
- package/lib/commonjs/core/useProxifiedUnistyles/listener.native.js +26 -0
- package/lib/commonjs/core/useProxifiedUnistyles/listener.native.js.map +1 -0
- package/lib/commonjs/core/useProxifiedUnistyles/types.js +6 -0
- package/lib/commonjs/core/useProxifiedUnistyles/types.js.map +1 -0
- package/lib/commonjs/core/{withUnistyles/useDependencies.js → useProxifiedUnistyles/useProxifiedUnistyles.js} +22 -22
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -0
- package/lib/commonjs/core/useUnistyles.js +19 -0
- package/lib/commonjs/core/useUnistyles.js.map +1 -0
- package/lib/commonjs/core/warn.js +16 -0
- package/lib/commonjs/core/warn.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +19 -55
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +32 -65
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/index.js +23 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/server/getServerUnistyles.js +40 -0
- package/lib/commonjs/server/getServerUnistyles.js.map +1 -0
- package/lib/commonjs/server/hydrateServerUnistyles.js +17 -0
- package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -0
- package/lib/commonjs/server/index.js +34 -0
- package/lib/commonjs/server/index.js.map +1 -0
- package/lib/commonjs/server/resetServerUnistyles.js +16 -0
- package/lib/commonjs/server/resetServerUnistyles.js.map +1 -0
- package/lib/commonjs/server/types.js +8 -0
- package/lib/commonjs/server/types.js.map +1 -0
- package/lib/commonjs/server/useServerUnistyles.js +27 -0
- package/lib/commonjs/server/useServerUnistyles.js.map +1 -0
- package/lib/commonjs/specs/ShadowRegistry/index.js +6 -3
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/utils.js +19 -2
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/convert/object/filter.js +2 -2
- package/lib/commonjs/web/convert/object/filter.js.map +1 -1
- package/lib/commonjs/web/convert/style.js +4 -4
- package/lib/commonjs/web/convert/style.js.map +1 -1
- package/lib/commonjs/web/create.js +20 -15
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/css/core.js +55 -0
- package/lib/commonjs/web/css/core.js.map +1 -0
- package/lib/commonjs/web/css/index.js +17 -0
- package/lib/commonjs/web/css/index.js.map +1 -0
- package/lib/commonjs/web/css/state.js +155 -0
- package/lib/commonjs/web/css/state.js.map +1 -0
- package/lib/commonjs/web/css/utils.js +47 -0
- package/lib/commonjs/web/css/utils.js.map +1 -0
- package/lib/commonjs/web/index.js +14 -18
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/listener.js +9 -7
- package/lib/commonjs/web/listener.js.map +1 -1
- package/lib/commonjs/web/registry.js +44 -123
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js +28 -21
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/services.js +28 -0
- package/lib/commonjs/web/services.js.map +1 -0
- package/lib/commonjs/web/shadowRegistry.js +46 -93
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/state.js +39 -9
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/types.js +6 -0
- package/lib/commonjs/web/types.js.map +1 -0
- package/lib/commonjs/web/utils/common.js +29 -9
- package/lib/commonjs/web/utils/common.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +32 -19
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/commonjs/web/variants.js +25 -27
- package/lib/commonjs/web/variants.js.map +1 -1
- package/lib/module/components/ScopedTheme.js.map +1 -1
- package/lib/module/components/index.js +0 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/native/Animated.js +19 -0
- package/lib/module/components/native/Animated.js.map +1 -0
- package/lib/module/components/native/ImageBackground.js +47 -2
- package/lib/module/components/native/ImageBackground.js.map +1 -1
- package/lib/module/components/native/ImageBackground.native.js +6 -0
- package/lib/module/components/native/ImageBackground.native.js.map +1 -0
- package/lib/module/components/native/NativeText.js +4 -0
- package/lib/module/components/native/NativeText.js.map +1 -0
- package/lib/module/components/native/NativeText.native.js +15 -0
- package/lib/module/components/native/NativeText.native.js.map +1 -0
- package/lib/module/components/native/NativeView.js +5 -0
- package/lib/module/components/native/NativeView.js.map +1 -0
- package/lib/module/components/native/NativeView.native.js +17 -0
- package/lib/module/components/native/NativeView.native.js.map +1 -0
- package/lib/module/components/native/Pressable.js +27 -52
- package/lib/module/components/native/Pressable.js.map +1 -1
- package/lib/module/components/native/Pressable.native.js +26 -10
- package/lib/module/components/native/Pressable.native.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js +33 -5
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +47 -0
- package/lib/module/core/createUnistylesElement.native.js.map +1 -0
- package/lib/module/core/createUnistylesImageBackground.js +39 -14
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/getClassname.js +18 -0
- package/lib/module/core/getClassname.js.map +1 -0
- package/lib/module/core/getClassname.native.js +4 -0
- package/lib/module/core/getClassname.native.js.map +1 -0
- package/lib/module/core/index.js +2 -1
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/passForwardRef.js +2 -2
- package/lib/module/core/passForwardRef.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/index.js +4 -0
- package/lib/module/core/useProxifiedUnistyles/index.js.map +1 -0
- package/lib/module/core/useProxifiedUnistyles/listener.js +17 -0
- package/lib/module/core/useProxifiedUnistyles/listener.js.map +1 -0
- package/lib/module/core/useProxifiedUnistyles/listener.native.js +21 -0
- package/lib/module/core/useProxifiedUnistyles/listener.native.js.map +1 -0
- package/lib/module/core/useProxifiedUnistyles/types.js +4 -0
- package/lib/module/core/useProxifiedUnistyles/types.js.map +1 -0
- package/lib/module/core/{withUnistyles/useDependencies.js → useProxifiedUnistyles/useProxifiedUnistyles.js} +19 -19
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -0
- package/lib/module/core/useUnistyles.js +14 -0
- package/lib/module/core/useUnistyles.js.map +1 -0
- package/lib/module/core/warn.js +11 -0
- package/lib/module/core/warn.js.map +1 -0
- package/lib/module/core/withUnistyles/withUnistyles.js +19 -55
- package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.native.js +33 -66
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/server/getServerUnistyles.js +34 -0
- package/lib/module/server/getServerUnistyles.js.map +1 -0
- package/lib/module/server/hydrateServerUnistyles.js +12 -0
- package/lib/module/server/hydrateServerUnistyles.js.map +1 -0
- package/lib/module/server/index.js +7 -0
- package/lib/module/server/index.js.map +1 -0
- package/lib/module/server/resetServerUnistyles.js +11 -0
- package/lib/module/server/resetServerUnistyles.js.map +1 -0
- package/lib/module/server/types.js +4 -0
- package/lib/module/server/types.js.map +1 -0
- package/lib/module/server/useServerUnistyles.js +22 -0
- package/lib/module/server/useServerUnistyles.js.map +1 -0
- package/lib/module/specs/ShadowRegistry/index.js +6 -3
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/utils.js +16 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/convert/object/filter.js +2 -2
- package/lib/module/web/convert/object/filter.js.map +1 -1
- package/lib/module/web/convert/style.js +4 -4
- package/lib/module/web/convert/style.js.map +1 -1
- package/lib/module/web/create.js +20 -15
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/css/core.js +50 -0
- package/lib/module/web/css/core.js.map +1 -0
- package/lib/module/web/css/index.js +4 -0
- package/lib/module/web/css/index.js.map +1 -0
- package/lib/module/web/css/state.js +150 -0
- package/lib/module/web/css/state.js.map +1 -0
- package/lib/module/web/css/utils.js +41 -0
- package/lib/module/web/css/utils.js.map +1 -0
- package/lib/module/web/index.js +10 -5
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/listener.js +8 -7
- package/lib/module/web/listener.js.map +1 -1
- package/lib/module/web/registry.js +44 -124
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js +27 -21
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/services.js +23 -0
- package/lib/module/web/services.js.map +1 -0
- package/lib/module/web/shadowRegistry.js +46 -94
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/state.js +39 -10
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/types.js +4 -0
- package/lib/module/web/types.js.map +1 -0
- package/lib/module/web/utils/common.js +26 -7
- package/lib/module/web/utils/common.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +31 -17
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/module/web/variants.js +25 -27
- package/lib/module/web/variants.js.map +1 -1
- package/lib/typescript/src/components/index.d.ts +0 -1
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts +1 -1
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Animated.d.ts +39 -0
- package/lib/typescript/src/components/native/Animated.d.ts.map +1 -0
- package/lib/typescript/src/components/native/FlatList.d.ts +1 -1
- package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Image.d.ts +1 -1
- package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.d.ts +1 -2
- package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.native.d.ts +2 -0
- package/lib/typescript/src/components/native/ImageBackground.native.d.ts.map +1 -0
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts +1 -1
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/NativeText.d.ts +2 -0
- package/lib/typescript/src/components/native/NativeText.d.ts.map +1 -0
- package/lib/typescript/src/components/native/NativeText.native.d.ts +2 -0
- package/lib/typescript/src/components/native/NativeText.native.d.ts.map +1 -0
- package/lib/typescript/src/components/native/NativeView.d.ts +3 -0
- package/lib/typescript/src/components/native/NativeView.d.ts.map +1 -0
- package/lib/typescript/src/components/native/NativeView.native.d.ts +3 -0
- package/lib/typescript/src/components/native/NativeView.native.d.ts.map +1 -0
- package/lib/typescript/src/components/native/Pressable.d.ts +3 -2
- package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/RefreshControl.d.ts +1 -1
- package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ScrollView.d.ts +1 -1
- package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/SectionList.d.ts +1 -1
- package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Switch.d.ts +1 -1
- package/lib/typescript/src/components/native/Switch.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Text.d.ts +1 -1
- package/lib/typescript/src/components/native/Text.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TextInput.d.ts +1 -1
- package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts +1 -1
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts +1 -1
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -1
- package/lib/typescript/src/components/native/View.d.ts +1 -1
- package/lib/typescript/src/components/native/View.d.ts.map +1 -1
- package/lib/typescript/src/components/native/VirtualizedList.d.ts +1 -1
- package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.d.ts +1 -2
- package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts +2 -0
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts +2 -3
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/core/getClassname.d.ts +7 -0
- package/lib/typescript/src/core/getClassname.d.ts.map +1 -0
- package/lib/typescript/src/core/getClassname.native.d.ts +2 -0
- package/lib/typescript/src/core/getClassname.native.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +2 -1
- package/lib/typescript/src/core/index.d.ts.map +1 -1
- package/lib/typescript/src/core/passForwardRef.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/index.d.ts +2 -0
- package/lib/typescript/src/core/useProxifiedUnistyles/index.d.ts.map +1 -0
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.d.ts +3 -0
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.d.ts.map +1 -0
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts +3 -0
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts.map +1 -0
- package/lib/typescript/src/core/useProxifiedUnistyles/types.d.ts +7 -0
- package/lib/typescript/src/core/useProxifiedUnistyles/types.d.ts.map +1 -0
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts +8 -0
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/core/useUnistyles.d.ts +6 -0
- package/lib/typescript/src/core/useUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/core/warn.d.ts +3 -0
- package/lib/typescript/src/core/warn.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts +0 -3
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/server/getServerUnistyles.d.ts +4 -0
- package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/server/hydrateServerUnistyles.d.ts +8 -0
- package/lib/typescript/src/server/hydrateServerUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/server/index.d.ts +5 -0
- package/lib/typescript/src/server/index.d.ts.map +1 -0
- package/lib/typescript/src/server/resetServerUnistyles.d.ts +2 -0
- package/lib/typescript/src/server/resetServerUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/server/types.d.ts +5 -0
- package/lib/typescript/src/server/types.d.ts.map +1 -0
- package/lib/typescript/src/server/useServerUnistyles.d.ts +4 -0
- package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +0 -3
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +5 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +2 -0
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/style.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 +3 -0
- package/lib/typescript/src/web/css/core.d.ts.map +1 -0
- package/lib/typescript/src/web/css/index.d.ts +2 -0
- package/lib/typescript/src/web/css/index.d.ts.map +1 -0
- package/lib/typescript/src/web/css/state.d.ts +30 -0
- package/lib/typescript/src/web/css/state.d.ts.map +1 -0
- package/lib/typescript/src/web/css/utils.d.ts +4 -0
- package/lib/typescript/src/web/css/utils.d.ts.map +1 -0
- package/lib/typescript/src/web/index.d.ts +7 -1
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/listener.d.ts +4 -3
- package/lib/typescript/src/web/listener.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +11 -8
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +6 -4
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/services.d.ts +15 -0
- package/lib/typescript/src/web/services.d.ts.map +1 -0
- package/lib/typescript/src/web/shadowRegistry.d.ts +10 -13
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/state.d.ts +7 -3
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/types.d.ts +13 -0
- package/lib/typescript/src/web/types.d.ts.map +1 -0
- package/lib/typescript/src/web/utils/common.d.ts +2 -1
- package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts +5 -4
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/lib/typescript/src/web/variants.d.ts +2 -2
- package/lib/typescript/src/web/variants.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JColorScheme.hpp +2 -1
- package/nitrogen/generated/android/c++/JDimensions.hpp +2 -1
- package/nitrogen/generated/android/c++/JFunc_void_UnistylesNativeMiniRuntime.hpp +36 -10
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.hpp +53 -19
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +5 -5
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/JInsets.hpp +2 -1
- package/nitrogen/generated/android/c++/JOrientation.hpp +2 -1
- package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +2 -1
- package/nitrogen/generated/android/c++/JUnistylesNativeMiniRuntime.hpp +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/ColorScheme.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Dimensions.kt +10 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_UnistylesNativeMiniRuntime.kt +43 -14
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.kt +43 -14
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +10 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Insets.kt +13 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Orientation.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistyleDependency.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +19 -14
- package/nitrogen/generated/android/unistyles+autolinking.cmake +4 -1
- package/nitrogen/generated/android/unistyles+autolinking.gradle +1 -1
- package/nitrogen/generated/android/unistylesOnLoad.cpp +7 -3
- package/nitrogen/generated/android/unistylesOnLoad.hpp +1 -1
- package/nitrogen/generated/ios/Unistyles+autolinking.rb +1 -1
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +21 -6
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +105 -27
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +5 -3
- package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.cpp +1 -1
- package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +92 -33
- package/nitrogen/generated/ios/swift/ColorScheme.swift +1 -1
- package/nitrogen/generated/ios/swift/Dimensions.swift +1 -1
- package/nitrogen/generated/ios/swift/Func_void_UnistylesNativeMiniRuntime.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +36 -23
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec_cxx.swift +327 -0
- package/nitrogen/generated/ios/swift/Insets.swift +1 -1
- package/nitrogen/generated/ios/swift/Orientation.swift +1 -1
- package/nitrogen/generated/ios/swift/UnistyleDependency.swift +1 -1
- package/nitrogen/generated/ios/swift/UnistylesNativeMiniRuntime.swift +1 -1
- package/nitrogen/generated/shared/c++/ColorScheme.hpp +1 -1
- package/nitrogen/generated/shared/c++/Dimensions.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/Insets.hpp +1 -1
- package/nitrogen/generated/shared/c++/Orientation.hpp +1 -1
- package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +2 -2
- package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +1 -1
- package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +1 -1
- package/package.json +23 -14
- package/plugin/consts.js +63 -0
- package/plugin/exotic.js +54 -0
- package/plugin/import.js +1 -21
- package/plugin/index.d.ts +89 -0
- package/plugin/index.js +58 -96
- package/plugin/stylesheet.js +28 -1
- package/plugin/variants.js +49 -75
- package/src/components/ScopedTheme.tsx +1 -1
- package/src/components/index.ts +0 -1
- package/src/components/native/Animated.tsx +17 -0
- package/src/components/native/ImageBackground.native.tsx +4 -0
- package/src/components/native/ImageBackground.tsx +57 -2
- package/src/components/native/NativeText.native.tsx +12 -0
- package/src/components/native/NativeText.tsx +1 -0
- package/src/components/native/NativeView.native.tsx +13 -0
- package/src/components/native/NativeView.tsx +3 -0
- package/src/components/native/Pressable.native.tsx +32 -15
- package/src/components/native/Pressable.tsx +35 -69
- package/src/core/createUnistylesElement.native.tsx +51 -0
- package/src/core/createUnistylesElement.tsx +47 -8
- package/src/core/createUnistylesImageBackground.tsx +44 -18
- package/src/core/getClassname.native.ts +1 -0
- package/src/core/getClassname.ts +14 -0
- package/src/core/index.ts +2 -1
- package/src/core/passForwardRef.ts +1 -2
- package/src/core/useProxifiedUnistyles/index.ts +1 -0
- package/src/core/useProxifiedUnistyles/listener.native.ts +18 -0
- package/src/core/useProxifiedUnistyles/listener.ts +13 -0
- package/src/core/useProxifiedUnistyles/types.ts +7 -0
- package/src/core/{withUnistyles/useDependencies.ts → useProxifiedUnistyles/useProxifiedUnistyles.ts} +19 -26
- package/src/core/useUnistyles.ts +11 -0
- package/src/core/warn.ts +13 -0
- package/src/core/withUnistyles/withUnistyles.native.tsx +39 -68
- package/src/core/withUnistyles/withUnistyles.tsx +19 -56
- package/src/index.ts +3 -2
- package/src/server/getServerUnistyles.tsx +21 -0
- package/src/server/hydrateServerUnistyles.ts +17 -0
- package/src/server/index.ts +5 -0
- package/src/server/resetServerUnistyles.ts +9 -0
- package/src/server/types.ts +4 -0
- package/src/server/useServerUnistyles.tsx +22 -0
- package/src/specs/ShadowRegistry/index.ts +12 -9
- package/src/specs/StyleSheet/index.ts +6 -1
- package/src/utils.ts +32 -11
- package/src/web/convert/object/filter.ts +2 -2
- package/src/web/convert/style.ts +8 -7
- package/src/web/create.ts +23 -18
- package/src/web/css/core.ts +58 -0
- package/src/web/css/index.ts +1 -0
- package/src/web/css/state.ts +191 -0
- package/src/web/css/utils.ts +54 -0
- package/src/web/index.ts +18 -5
- package/src/web/listener.ts +8 -8
- package/src/web/registry.ts +47 -152
- package/src/web/runtime.ts +32 -22
- package/src/web/services.ts +28 -0
- package/src/web/shadowRegistry.ts +46 -104
- package/src/web/state.ts +46 -11
- package/src/web/types.ts +13 -0
- package/src/web/utils/common.ts +32 -8
- package/src/web/utils/unistyle.ts +46 -25
- package/src/web/variants.ts +27 -27
- package/cxx/core/HostStyle.cpp +0 -73
- package/cxx/core/HostStyle.h +0 -34
- package/lib/commonjs/components/Variants.js +0 -36
- package/lib/commonjs/components/Variants.js.map +0 -1
- package/lib/commonjs/core/createUnistylesComponent.js +0 -16
- package/lib/commonjs/core/createUnistylesComponent.js.map +0 -1
- package/lib/commonjs/core/withUnistyles/useDependencies.js.map +0 -1
- package/lib/module/components/Variants.js +0 -29
- package/lib/module/components/Variants.js.map +0 -1
- package/lib/module/core/createUnistylesComponent.js +0 -11
- package/lib/module/core/createUnistylesComponent.js.map +0 -1
- package/lib/module/core/withUnistyles/useDependencies.js.map +0 -1
- package/lib/typescript/src/components/Variants.d.ts +0 -7
- package/lib/typescript/src/components/Variants.d.ts.map +0 -1
- package/lib/typescript/src/core/createUnistylesComponent.d.ts +0 -14
- package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +0 -1
- package/lib/typescript/src/core/withUnistyles/useDependencies.d.ts +0 -13
- package/lib/typescript/src/core/withUnistyles/useDependencies.d.ts.map +0 -1
- package/nitrogen/generated/android/unistylesOnLoad.kt +0 -1
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +0 -314
- package/plugin/style.js +0 -168
- package/src/components/Variants.tsx +0 -30
- package/src/core/createUnistylesComponent.tsx +0 -14
@@ -1,24 +1,50 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import type { ImageBackground, ImageBackgroundProps } from 'react-native'
|
1
|
+
import React, { useLayoutEffect, useRef } from 'react'
|
2
|
+
import type { Image, ImageBackground, ImageBackgroundProps } from 'react-native'
|
3
3
|
import { UnistylesShadowRegistry } from '../specs'
|
4
4
|
import { passForwardedRef } from './passForwardRef'
|
5
|
+
import { maybeWarnAboutMultipleUnistyles } from './warn'
|
6
|
+
import { copyComponentProperties } from '../utils'
|
5
7
|
|
6
|
-
export const createUnistylesImageBackground = (Component: typeof ImageBackground) =>
|
7
|
-
<
|
8
|
-
|
9
|
-
ref={ref => passForwardedRef(props, ref, forwardedRef)}
|
10
|
-
imageRef={ref => {
|
11
|
-
const style = Array.isArray(props.imageStyle)
|
12
|
-
? props.imageStyle
|
13
|
-
: [props.imageStyle]
|
14
|
-
|
15
|
-
// @ts-expect-error - This is hidden from TS
|
16
|
-
UnistylesShadowRegistry.add(ref, style)
|
8
|
+
export const createUnistylesImageBackground = (Component: typeof ImageBackground) => {
|
9
|
+
const UnistylesImageBackground = React.forwardRef<ImageBackground, ImageBackgroundProps>((props, forwardedRef) => {
|
10
|
+
const storedImageRef = useRef<Image | null>(null)
|
17
11
|
|
12
|
+
useLayoutEffect(() => {
|
18
13
|
return () => {
|
19
|
-
|
20
|
-
|
14
|
+
if (storedImageRef.current) {
|
15
|
+
// @ts-ignore
|
16
|
+
UnistylesShadowRegistry.remove(storedImageRef.current)
|
17
|
+
}
|
21
18
|
}
|
22
|
-
}
|
23
|
-
|
24
|
-
|
19
|
+
}, [])
|
20
|
+
|
21
|
+
// @ts-expect-error we don't know the type of the component
|
22
|
+
maybeWarnAboutMultipleUnistyles(props.style, 'ImageBackground')
|
23
|
+
// @ts-ignore we don't know the type of the component
|
24
|
+
maybeWarnAboutMultipleUnistyles(props.imageStyle, 'ImageBackground')
|
25
|
+
|
26
|
+
return (
|
27
|
+
<Component
|
28
|
+
{...props}
|
29
|
+
ref={ref => {
|
30
|
+
passForwardedRef(props, ref, forwardedRef)
|
31
|
+
|
32
|
+
return () => {
|
33
|
+
// @ts-ignore
|
34
|
+
UnistylesShadowRegistry.remove(ref)
|
35
|
+
}
|
36
|
+
}}
|
37
|
+
imageRef={ref => {
|
38
|
+
if (ref) {
|
39
|
+
storedImageRef.current = ref
|
40
|
+
}
|
41
|
+
|
42
|
+
// @ts-expect-error web types are not compatible with RN styles
|
43
|
+
UnistylesShadowRegistry.add(ref, props.imageStyle)
|
44
|
+
}}
|
45
|
+
/>
|
46
|
+
)
|
47
|
+
})
|
48
|
+
|
49
|
+
return copyComponentProperties(Component, UnistylesImageBackground)
|
50
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export const getClassName = () => undefined
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { UnistylesValues } from '../types'
|
2
|
+
import { UnistylesWeb } from '../web'
|
3
|
+
|
4
|
+
export const getClassName = (unistyle: UnistylesValues | undefined | Array<UnistylesValues>) => {
|
5
|
+
if (!unistyle) {
|
6
|
+
return undefined
|
7
|
+
}
|
8
|
+
|
9
|
+
const { hash, injectedClassName } = UnistylesWeb.shadowRegistry.addStyles(
|
10
|
+
Array.isArray(unistyle) ? unistyle.flat(Number.POSITIVE_INFINITY) : [unistyle]
|
11
|
+
)
|
12
|
+
|
13
|
+
return hash ? { $$css: true, hash, injectedClassName } : undefined
|
14
|
+
}
|
package/src/core/index.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
export { createUnistylesComponent } from './createUnistylesComponent'
|
2
1
|
export { createUnistylesElement } from './createUnistylesElement'
|
3
2
|
export { createUnistylesImageBackground } from './createUnistylesImageBackground'
|
4
3
|
export { withUnistyles } from './withUnistyles'
|
5
4
|
export { passForwardedRef } from './passForwardRef'
|
5
|
+
export { getClassName } from './getClassname'
|
6
|
+
export { useUnistyles } from './useUnistyles'
|
@@ -19,11 +19,10 @@ export const passForwardedRef = <T>(
|
|
19
19
|
}
|
20
20
|
const forwardedRefReturnFn = passForwardedRef()
|
21
21
|
|
22
|
+
// @ts-expect-error hidden from TS
|
22
23
|
UnistylesShadowRegistry.add(ref, props.style)
|
23
24
|
|
24
25
|
return () => {
|
25
|
-
// @ts-expect-error - This is hidden from TS
|
26
|
-
UnistylesShadowRegistry.remove(ref)
|
27
26
|
forwardedRefReturnFn?.()
|
28
27
|
}
|
29
28
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { useProxifiedUnistyles } from './useProxifiedUnistyles'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { StyleSheet, UnistyleDependency } from '../../specs'
|
2
|
+
import type { ListenerProps } from './types'
|
3
|
+
|
4
|
+
export const listener = ({ dependencies, updateTheme, updateRuntime }: ListenerProps) => {
|
5
|
+
const listensToTheme = dependencies.includes(UnistyleDependency.Theme)
|
6
|
+
// @ts-expect-error - this is hidden from TS
|
7
|
+
const dispose = StyleSheet.addChangeListener(changedDependencies => {
|
8
|
+
if (listensToTheme && changedDependencies.includes(UnistyleDependency.Theme)) {
|
9
|
+
updateTheme()
|
10
|
+
}
|
11
|
+
|
12
|
+
if (changedDependencies.some((dependency: UnistyleDependency) => dependencies.includes(dependency))) {
|
13
|
+
updateRuntime()
|
14
|
+
}
|
15
|
+
})
|
16
|
+
|
17
|
+
return () => dispose()
|
18
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { UnistyleDependency } from '../../specs'
|
2
|
+
import { UnistylesWeb } from '../../web'
|
3
|
+
import type { ListenerProps } from './types'
|
4
|
+
|
5
|
+
export const listener = ({ dependencies, updateTheme, updateRuntime }: ListenerProps) => {
|
6
|
+
const disposeTheme = UnistylesWeb.listener.addListeners(dependencies.filter(dependency => dependency === UnistyleDependency.Theme), updateTheme)
|
7
|
+
const disposeRuntime = UnistylesWeb.listener.addListeners(dependencies.filter(dependency => dependency !== UnistyleDependency.Theme), updateRuntime)
|
8
|
+
|
9
|
+
return () => {
|
10
|
+
disposeTheme()
|
11
|
+
disposeRuntime()
|
12
|
+
}
|
13
|
+
}
|
package/src/core/{withUnistyles/useDependencies.ts → useProxifiedUnistyles/useProxifiedUnistyles.ts}
RENAMED
@@ -3,7 +3,7 @@ import { UnistylesRuntime, UnistylesShadowRegistry, type UnistylesMiniRuntime }
|
|
3
3
|
// It's imported that way because of circular dependency
|
4
4
|
import { UnistyleDependency } from '../../specs/NativePlatform'
|
5
5
|
import type { UnistylesTheme } from '../../types'
|
6
|
-
import
|
6
|
+
import { listener } from './listener'
|
7
7
|
|
8
8
|
const getMiniRuntime = (): UnistylesMiniRuntime => {
|
9
9
|
// @ts-expect-error This is hidden from TS
|
@@ -26,13 +26,7 @@ const RTDependencyMap = {
|
|
26
26
|
themeName: UnistyleDependency.ThemeName,
|
27
27
|
} satisfies Partial<Record<keyof UnistylesMiniRuntime, UnistyleDependency>>
|
28
28
|
|
29
|
-
|
30
|
-
updateTheme: VoidFunction,
|
31
|
-
updateRuntime: VoidFunction,
|
32
|
-
dependencies: Array<UnistyleDependency>
|
33
|
-
}
|
34
|
-
|
35
|
-
export const useDependencies = (listener: (props: ListenerProps) => VoidFunction) => {
|
29
|
+
export const useProxifiedUnistyles = () => {
|
36
30
|
const scopedTheme = UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme
|
37
31
|
const [dependencies] = useState(() => new Set<number>())
|
38
32
|
const [theme, setTheme] = useState(UnistylesRuntime.getTheme(scopedTheme))
|
@@ -60,27 +54,26 @@ export const useDependencies = (listener: (props: ListenerProps) => VoidFunction
|
|
60
54
|
return () => disposeRef.current?.()
|
61
55
|
}, [dependencies.size])
|
62
56
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
get: (target, prop) => {
|
67
|
-
dependencies.add(UnistyleDependency.Theme)
|
57
|
+
const proxifiedTheme = new Proxy(theme, {
|
58
|
+
get: (target, prop) => {
|
59
|
+
dependencies.add(UnistyleDependency.Theme)
|
68
60
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
61
|
+
return target[prop]
|
62
|
+
}
|
63
|
+
})
|
64
|
+
const proxifiedRuntime = new Proxy(getMiniRuntime(), {
|
65
|
+
get: (target, prop) => {
|
66
|
+
if (prop in RTDependencyMap) {
|
67
|
+
dependencies.add(RTDependencyMap[prop as keyof typeof RTDependencyMap])
|
68
|
+
}
|
77
69
|
|
78
|
-
|
79
|
-
|
80
|
-
|
70
|
+
return target[prop as keyof typeof target]
|
71
|
+
}
|
72
|
+
})
|
81
73
|
|
82
|
-
|
83
|
-
|
74
|
+
return {
|
75
|
+
proxifiedTheme,
|
76
|
+
proxifiedRuntime,
|
84
77
|
addDependencies: (newDependencies: Array<UnistyleDependency>) => {
|
85
78
|
const dependenciesSize = dependencies.size
|
86
79
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { UnistylesTheme } from '../types'
|
2
|
+
import { useProxifiedUnistyles } from './useProxifiedUnistyles'
|
3
|
+
|
4
|
+
export const useUnistyles = () => {
|
5
|
+
const { proxifiedRuntime, proxifiedTheme } = useProxifiedUnistyles()
|
6
|
+
|
7
|
+
return {
|
8
|
+
theme: proxifiedTheme as UnistylesTheme,
|
9
|
+
rt: proxifiedRuntime
|
10
|
+
}
|
11
|
+
}
|
package/src/core/warn.ts
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
import type { ViewStyle } from 'react-native'
|
2
|
+
|
3
|
+
export const maybeWarnAboutMultipleUnistyles = (style: ViewStyle, displayName = 'Unknown') => {
|
4
|
+
if (__DEV__ && style && !Array.isArray(style)) {
|
5
|
+
const unistylesKeys = Object
|
6
|
+
.keys(style)
|
7
|
+
.filter(key => key.startsWith('unistyles-'))
|
8
|
+
|
9
|
+
if (unistylesKeys.length > 1) {
|
10
|
+
console.warn(`Unistyles: we detected style object with ${unistylesKeys.length} unistyles styles. This might cause no updates or unpredictable behavior. Please check style prop for "${displayName}" and use array syntax instead of object syntax.`)
|
11
|
+
}
|
12
|
+
}
|
13
|
+
}
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import React, { forwardRef, useEffect,
|
2
|
-
import {
|
1
|
+
import React, { forwardRef, useEffect, type ComponentType } from 'react'
|
2
|
+
import type { UnistyleDependency } from '../../specs'
|
3
3
|
import type { PartialBy } from '../../types/common'
|
4
4
|
import { deepMergeObjects } from '../../utils'
|
5
|
-
import { SUPPORTED_STYLE_PROPS } from './types'
|
6
5
|
import type { Mappings, SupportedStyleProps } from './types'
|
7
|
-
import {
|
6
|
+
import { maybeWarnAboutMultipleUnistyles } from '../warn'
|
7
|
+
import { useProxifiedUnistyles } from '../useProxifiedUnistyles'
|
8
8
|
|
9
9
|
// @ts-expect-error
|
10
10
|
type GenericComponentProps<P> = ComponentProps<P>
|
@@ -16,81 +16,52 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
|
|
16
16
|
type PropsWithUnistyles = PartialBy<TProps, keyof TMappings | SupportedStyleProps> & {
|
17
17
|
uniProps?: Mappings<TProps>
|
18
18
|
}
|
19
|
+
const getSecrets = (styleProps: Record<string, any> = {}): { uni__getStyles(): any, uni__dependencies: Array<UnistyleDependency> } => {
|
20
|
+
const unistyleKey = Object
|
21
|
+
.keys(styleProps)
|
22
|
+
.find(key => key.startsWith('unistyles-'))
|
23
|
+
|
24
|
+
return unistyleKey
|
25
|
+
? styleProps[unistyleKey]
|
26
|
+
: {
|
27
|
+
uni__getStyles: () => styleProps,
|
28
|
+
uni__dependencies: [],
|
29
|
+
}
|
30
|
+
}
|
19
31
|
|
20
32
|
return forwardRef<GenericComponentRef<TComponent>, PropsWithUnistyles>((props, ref) => {
|
21
33
|
const narrowedProps = props as PropsWithUnistyles
|
22
|
-
const stylesRef = useRef<Record<string, any>>({})
|
23
|
-
const isForcedRef = useRef(false)
|
24
34
|
const NativeComponent = Component as ComponentType
|
25
35
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
console.error(`🦄 Unistyles: withUnistyles requires ${propName} to be an object. Please check props for component: ${NativeComponent.displayName}`)
|
31
|
-
}
|
32
|
-
|
33
|
-
// @ts-expect-error - this is hidden from TS
|
34
|
-
if (props[propName].__unistyles_name && !props[propName].__proto__?.getStyle) {
|
35
|
-
console.error(`🦄 Unistyles: withUnistyles received style that is not bound. You likely used the spread operator on a Unistyle style. Please check props for component: ${NativeComponent.displayName}`)
|
36
|
-
}
|
37
|
-
|
38
|
-
stylesRef.current = {
|
39
|
-
...stylesRef.current,
|
40
|
-
// @ts-expect-error - this is hidden from TS
|
41
|
-
[propName]: props[propName].__proto__?.getStyle?.() || props[propName]
|
42
|
-
}
|
43
|
-
}
|
44
|
-
})
|
45
|
-
}
|
46
|
-
|
47
|
-
const { mappingsCallback, addDependencies } = useDependencies(({ dependencies, updateTheme, updateRuntime }) => {
|
48
|
-
const listensToTheme = dependencies.includes(UnistyleDependency.Theme)
|
49
|
-
// @ts-expect-error - this is hidden from TS
|
50
|
-
const dispose = StyleSheet.addChangeListener(changedDependencies => {
|
51
|
-
if (listensToTheme && changedDependencies.includes(UnistyleDependency.Theme)) {
|
52
|
-
updateTheme()
|
53
|
-
}
|
54
|
-
|
55
|
-
if (changedDependencies.some((dependency: UnistyleDependency) => dependencies.includes(dependency))) {
|
56
|
-
SUPPORTED_STYLE_PROPS.forEach(propName => {
|
57
|
-
if (narrowedProps?.[propName]) {
|
58
|
-
stylesRef.current = {
|
59
|
-
...stylesRef.current,
|
60
|
-
// @ts-expect-error - this is hidden from TS
|
61
|
-
[propName]: props[propName].__proto__?.getStyle?.() || props[propName]
|
62
|
-
}
|
36
|
+
// @ts-ignore we don't know the type of the component
|
37
|
+
maybeWarnAboutMultipleUnistyles(narrowedProps.style, `withUnistyles(${Component.displayName ?? Component.name ?? 'Unknown'})`)
|
38
|
+
// @ts-ignore we don't know the type of the component
|
39
|
+
maybeWarnAboutMultipleUnistyles(narrowedProps.contentContainerStyle, `withUnistyles(${Component.displayName ?? Component.name ?? 'Unknown'})`)
|
63
40
|
|
64
|
-
|
65
|
-
}
|
66
|
-
})
|
67
|
-
|
68
|
-
updateRuntime()
|
69
|
-
}
|
70
|
-
})
|
71
|
-
|
72
|
-
return () => dispose()
|
73
|
-
})
|
41
|
+
const { proxifiedRuntime, proxifiedTheme, addDependencies } = useProxifiedUnistyles()
|
74
42
|
|
75
43
|
useEffect(() => {
|
76
|
-
const
|
77
|
-
const
|
44
|
+
const styleSecrets = getSecrets(narrowedProps.style)
|
45
|
+
const contentContainerStyleSecrets = getSecrets(narrowedProps.contentContainerStyle)
|
78
46
|
|
79
|
-
addDependencies([...
|
47
|
+
addDependencies(Array.from(new Set([...styleSecrets.uni__dependencies, ...contentContainerStyleSecrets.uni__dependencies])))
|
80
48
|
}, [narrowedProps.style, narrowedProps.contentContainerStyle])
|
81
49
|
|
82
|
-
const
|
83
|
-
const unistyleProps = narrowedProps.uniProps ?
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
50
|
+
const mappingsProps = mappings ? mappings(proxifiedTheme, proxifiedRuntime) : {}
|
51
|
+
const unistyleProps = narrowedProps.uniProps ? narrowedProps.uniProps(proxifiedTheme, proxifiedRuntime) : {}
|
52
|
+
|
53
|
+
const styleSecrets = getSecrets(narrowedProps.style)
|
54
|
+
const contentContainerStyleSecrets = getSecrets(narrowedProps.contentContainerStyle)
|
55
|
+
|
56
|
+
const finalProps = {
|
57
|
+
...deepMergeObjects(mappingsProps, unistyleProps, props),
|
58
|
+
...narrowedProps.style ? {
|
59
|
+
style: styleSecrets.uni__getStyles(),
|
60
|
+
} : {},
|
61
|
+
...narrowedProps.contentContainerStyle ? {
|
62
|
+
contentContainerStyle: contentContainerStyleSecrets.uni__getStyles(),
|
63
|
+
} : {},
|
64
|
+
} as any
|
94
65
|
|
95
66
|
return <NativeComponent {...finalProps as TProps} ref={ref} />
|
96
67
|
})
|
@@ -1,42 +1,11 @@
|
|
1
|
-
import React, {
|
1
|
+
import React, { type ComponentType, forwardRef, type ComponentProps, type ComponentRef } from 'react'
|
2
2
|
import type { PartialBy } from '../../types/common'
|
3
|
-
import { UnistylesListener } from '../../web/listener'
|
4
|
-
import { UnistylesShadowRegistry } from '../../web'
|
5
|
-
import { equal } from '../../web/utils'
|
6
3
|
import { deepMergeObjects } from '../../utils'
|
7
4
|
import type { Mappings, SupportedStyleProps } from './types'
|
8
|
-
import { useDependencies } from './useDependencies'
|
9
|
-
import { UnistyleDependency } from '../../specs/NativePlatform'
|
10
5
|
import type { UnistylesValues } from '../../types'
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
const oldClassNames = useRef<Array<string>>([])
|
15
|
-
const classNames = useMemo(() => {
|
16
|
-
if (!style) {
|
17
|
-
return []
|
18
|
-
}
|
19
|
-
|
20
|
-
const newClassNames = UnistylesShadowRegistry.add(ref, [style]) ?? []
|
21
|
-
|
22
|
-
if (equal(oldClassNames.current, newClassNames)) {
|
23
|
-
return oldClassNames.current
|
24
|
-
}
|
25
|
-
|
26
|
-
oldClassNames.current = newClassNames
|
27
|
-
|
28
|
-
return newClassNames
|
29
|
-
}, [style])
|
30
|
-
|
31
|
-
useEffect(() => () => {
|
32
|
-
// Remove styles on unmount
|
33
|
-
if (style) {
|
34
|
-
UnistylesShadowRegistry.add(null, [style])
|
35
|
-
}
|
36
|
-
})
|
37
|
-
|
38
|
-
return classNames
|
39
|
-
}
|
6
|
+
import { getClassName } from '../getClassname'
|
7
|
+
import { maybeWarnAboutMultipleUnistyles } from '../warn'
|
8
|
+
import { useProxifiedUnistyles } from '../useProxifiedUnistyles'
|
40
9
|
|
41
10
|
// @ts-expect-error
|
42
11
|
type GenericComponentProps<T> = ComponentProps<T>
|
@@ -47,42 +16,36 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
|
|
47
16
|
type TProps = GenericComponentProps<TComponent>
|
48
17
|
type PropsWithUnistyles = PartialBy<TProps, keyof TMappings | SupportedStyleProps> & {
|
49
18
|
uniProps?: Mappings<TProps>
|
19
|
+
}
|
20
|
+
type UnistyleStyles = {
|
50
21
|
style?: UnistylesValues,
|
51
22
|
contentContainerStyle?: UnistylesValues
|
52
23
|
}
|
53
24
|
|
54
25
|
return forwardRef<GenericComponentRef<TComponent>, PropsWithUnistyles>((props, ref) => {
|
55
|
-
const narrowedProps = props as PropsWithUnistyles
|
56
|
-
const styleClassNames =
|
57
|
-
const contentContainerStyleClassNames =
|
58
|
-
const {
|
59
|
-
const disposeTheme = UnistylesListener.addListeners(dependencies.filter(dependency => dependency === UnistyleDependency.Theme), updateTheme)
|
60
|
-
const disposeRuntime = UnistylesListener.addListeners(dependencies.filter(dependency => dependency !== UnistyleDependency.Theme), updateRuntime)
|
26
|
+
const narrowedProps = props as PropsWithUnistyles & UnistyleStyles
|
27
|
+
const styleClassNames = getClassName(narrowedProps.style)
|
28
|
+
const contentContainerStyleClassNames = getClassName(narrowedProps.contentContainerStyle)
|
29
|
+
const { proxifiedRuntime, proxifiedTheme } = useProxifiedUnistyles()
|
61
30
|
|
62
|
-
|
63
|
-
|
64
|
-
disposeRuntime()
|
65
|
-
}
|
66
|
-
})
|
67
|
-
const mappingsProps = mappings ? mappingsCallback(mappings) : {}
|
68
|
-
const unistyleProps = narrowedProps.uniProps ? mappingsCallback(narrowedProps.uniProps) : {}
|
31
|
+
const mappingsProps = mappings ? mappings(proxifiedTheme, proxifiedRuntime) : {}
|
32
|
+
const unistyleProps = narrowedProps.uniProps ? narrowedProps.uniProps(proxifiedTheme, proxifiedRuntime) : {}
|
69
33
|
|
70
34
|
const combinedProps = {
|
71
35
|
...deepMergeObjects(mappingsProps, unistyleProps, props),
|
72
36
|
...narrowedProps.style ? {
|
73
|
-
style:
|
74
|
-
$$css: true,
|
75
|
-
'unistyles': styleClassNames.join(' ')
|
76
|
-
},
|
37
|
+
style: styleClassNames,
|
77
38
|
} : {},
|
78
39
|
...narrowedProps.contentContainerStyle ? {
|
79
|
-
style:
|
80
|
-
$$css: true,
|
81
|
-
'unistyles': contentContainerStyleClassNames.join(' ')
|
82
|
-
},
|
40
|
+
style: contentContainerStyleClassNames,
|
83
41
|
} : {},
|
84
42
|
} as any
|
85
43
|
|
44
|
+
// @ts-ignore
|
45
|
+
maybeWarnAboutMultipleUnistyles(narrowedProps.style, `withUnistyles(${Component.displayName ?? Component.name ?? 'Unknown'})`)
|
46
|
+
// @ts-ignore
|
47
|
+
maybeWarnAboutMultipleUnistyles(narrowedProps.contentContainerStyle, `withUnistyles(${Component.displayName ?? Component.name ?? 'Unknown'})`)
|
48
|
+
|
86
49
|
const NativeComponent = Component as ComponentType
|
87
50
|
|
88
51
|
return <NativeComponent {...combinedProps} ref={ref} />
|
package/src/index.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
export { StyleSheet, UnistylesRuntime, StatusBar, NavigationBar } from './specs'
|
2
2
|
export { mq } from './mq'
|
3
3
|
export type { UnistylesThemes, UnistylesBreakpoints } from './global'
|
4
|
-
export {
|
4
|
+
export { withUnistyles, useUnistyles } from './core'
|
5
5
|
export type { UnistylesVariants } from './types'
|
6
|
-
export { Display, Hide,
|
6
|
+
export { Display, Hide, ScopedTheme } from './components'
|
7
|
+
export { useServerUnistyles, hydrateServerUnistyles, getServerUnistyles, resetServerUnistyles } from './server'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { StyleSheet } from 'react-native'
|
3
|
+
import { error, isServer } from '../web/utils'
|
4
|
+
import { UnistylesWeb } from '../web'
|
5
|
+
import { DefaultServerUnistylesSettings, type ServerUnistylesSettings } from './types'
|
6
|
+
|
7
|
+
export const getServerUnistyles = ({ includeRNWStyles = true }: ServerUnistylesSettings = DefaultServerUnistylesSettings) => {
|
8
|
+
if (!isServer()) {
|
9
|
+
throw error('Server styles should only be read on the server')
|
10
|
+
}
|
11
|
+
// @ts-ignore
|
12
|
+
const rnwStyle: string | null = includeRNWStyles ? (StyleSheet?.getSheet().textContent ?? '') : null
|
13
|
+
const css = UnistylesWeb.registry.css.getStyles()
|
14
|
+
const state = UnistylesWeb.registry.css.getState()
|
15
|
+
return <>
|
16
|
+
{rnwStyle && <style id='rnw-style'>{rnwStyle}</style>}
|
17
|
+
<style id='unistyles-web'>{css}</style>
|
18
|
+
{/* biome-ignore lint/security/noDangerouslySetInnerHtml: Needs the json quotes to be unescaped */}
|
19
|
+
<script id='unistyles-script' dangerouslySetInnerHTML={{ __html: `window.__UNISTYLES_STATE__ = ${JSON.stringify(state)}`}} />
|
20
|
+
</>
|
21
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { error, isServer } from '../web/utils'
|
2
|
+
import { UnistylesWeb } from '../web'
|
3
|
+
|
4
|
+
declare global {
|
5
|
+
interface Window {
|
6
|
+
// @ts-ignore
|
7
|
+
__UNISTYLES_STATE__: ReturnType<typeof UnistylesWeb.registry.css.getState>
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
export const hydrateServerUnistyles = () => {
|
12
|
+
if (isServer()) {
|
13
|
+
throw error('Server styles should only be hydrated on the client')
|
14
|
+
}
|
15
|
+
UnistylesWeb.registry.css.hydrate(window.__UNISTYLES_STATE__)
|
16
|
+
document.querySelector('#unistyles-script')?.remove()
|
17
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import React, { useRef } from 'react'
|
2
|
+
import { isServer } from '../web/utils'
|
3
|
+
import { DefaultServerUnistylesSettings, type ServerUnistylesSettings } from './types'
|
4
|
+
import { getServerUnistyles } from './getServerUnistyles'
|
5
|
+
import { resetServerUnistyles } from './resetServerUnistyles'
|
6
|
+
import { hydrateServerUnistyles } from './hydrateServerUnistyles'
|
7
|
+
|
8
|
+
export const useServerUnistyles = (settings: ServerUnistylesSettings = DefaultServerUnistylesSettings): React.ReactNode | null => {
|
9
|
+
const isServerInserted = useRef(false)
|
10
|
+
|
11
|
+
if (isServer() && !isServerInserted.current) {
|
12
|
+
isServerInserted.current = true
|
13
|
+
const components = getServerUnistyles(settings)
|
14
|
+
resetServerUnistyles()
|
15
|
+
return components
|
16
|
+
}
|
17
|
+
|
18
|
+
if (!isServer()) {
|
19
|
+
hydrateServerUnistyles()
|
20
|
+
}
|
21
|
+
return null
|
22
|
+
}
|
@@ -2,8 +2,6 @@ import { NitroModules } from 'react-native-nitro-modules'
|
|
2
2
|
import type { UnistylesShadowRegistry as UnistylesShadowRegistrySpec } from './ShadowRegistry.nitro'
|
3
3
|
import type { ShadowNode, Unistyle, ViewHandle } from './types'
|
4
4
|
|
5
|
-
type Variants = Record<string, string | boolean | undefined>
|
6
|
-
|
7
5
|
interface ShadowRegistry extends UnistylesShadowRegistrySpec {
|
8
6
|
// Babel API
|
9
7
|
add(handle?: ViewHandle, styles?: Array<Unistyle>): void,
|
@@ -11,10 +9,8 @@ interface ShadowRegistry extends UnistylesShadowRegistrySpec {
|
|
11
9
|
// JSI
|
12
10
|
link(node: ShadowNode, styles?: Array<Unistyle>): void,
|
13
11
|
unlink(node: ShadowNode): void,
|
14
|
-
selectVariants(variants?: Variants): void,
|
15
12
|
setScopedTheme(themeName?: string): void,
|
16
|
-
getScopedTheme(): string | undefined
|
17
|
-
getVariants(): Record<string, string | boolean | undefined> | undefined,
|
13
|
+
getScopedTheme(): string | undefined
|
18
14
|
}
|
19
15
|
|
20
16
|
const HybridShadowRegistry = NitroModules.createHybridObject<ShadowRegistry>('UnistylesShadowRegistry')
|
@@ -36,16 +32,23 @@ const findShadowNodeForHandle = (handle: ViewHandle) => {
|
|
36
32
|
|
37
33
|
HybridShadowRegistry.add = (handle, styles) => {
|
38
34
|
// virtualized nodes can be null
|
39
|
-
if (!handle || !styles
|
35
|
+
if (!handle || !styles) {
|
40
36
|
return
|
41
37
|
}
|
42
38
|
|
39
|
+
const stylesArray = Array.isArray(styles)
|
40
|
+
? styles.flat()
|
41
|
+
: [styles]
|
42
|
+
|
43
43
|
// filter Reanimated styles and styles that are undefined
|
44
|
-
const filteredStyles =
|
44
|
+
const filteredStyles = stylesArray
|
45
45
|
.filter(style => !style?.initial?.updater)
|
46
|
-
.filter(
|
46
|
+
.filter(style => style && Object.keys(style).length > 0)
|
47
|
+
.flat()
|
47
48
|
|
48
|
-
|
49
|
+
if (filteredStyles.length > 0) {
|
50
|
+
HybridShadowRegistry.link(findShadowNodeForHandle(handle), filteredStyles)
|
51
|
+
}
|
49
52
|
}
|
50
53
|
|
51
54
|
HybridShadowRegistry.remove = handle => {
|