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
@@ -2,7 +2,7 @@
|
|
2
2
|
/// UnistyleDependency.hpp
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
4
4
|
/// https://github.com/mrousavy/nitro
|
5
|
-
/// Copyright ©
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
6
6
|
///
|
7
7
|
|
8
8
|
#pragma once
|
@@ -59,7 +59,7 @@ namespace margelo::nitro {
|
|
59
59
|
int enumValue = static_cast<int>(arg);
|
60
60
|
return JSIConverter<int>::toJSI(runtime, enumValue);
|
61
61
|
}
|
62
|
-
static inline bool canConvert(jsi::Runtime
|
62
|
+
static inline bool canConvert(jsi::Runtime&, const jsi::Value& value) {
|
63
63
|
if (!value.isNumber()) {
|
64
64
|
return false;
|
65
65
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "3.0.0-beta.
|
3
|
+
"version": "3.0.0-beta.6",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
@@ -11,15 +11,15 @@
|
|
11
11
|
"precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn test'",
|
12
12
|
"release": "release-it"
|
13
13
|
},
|
14
|
-
"main": "lib/commonjs/index",
|
15
|
-
"module": "lib/module/index",
|
14
|
+
"main": "lib/commonjs/index.js",
|
15
|
+
"module": "lib/module/index.js",
|
16
16
|
"types": "lib/typescript/src/index.d.ts",
|
17
17
|
"source": "src/index",
|
18
18
|
"exports": {
|
19
19
|
".": {
|
20
20
|
"types": "./lib/typescript/src/index.d.ts",
|
21
|
-
"module": "./lib/module/index",
|
22
|
-
"default": "./lib/commonjs/index",
|
21
|
+
"module": "./lib/module/index.js",
|
22
|
+
"default": "./lib/commonjs/index.js",
|
23
23
|
"react-native": "./src/index"
|
24
24
|
},
|
25
25
|
"./components/native/*": {
|
@@ -31,7 +31,13 @@
|
|
31
31
|
"module": "./plugin/index.js",
|
32
32
|
"default": "./plugin/index.js"
|
33
33
|
},
|
34
|
-
"./package.json": "./package.json"
|
34
|
+
"./package.json": "./package.json",
|
35
|
+
"./server": {
|
36
|
+
"types": "./lib/typescript/src/server/index.d.ts",
|
37
|
+
"module": "./lib/module/server/index.js",
|
38
|
+
"default": "./lib/commonjs/server/index.js",
|
39
|
+
"react-native": "./src/server"
|
40
|
+
}
|
35
41
|
},
|
36
42
|
"files": [
|
37
43
|
"src",
|
@@ -76,27 +82,29 @@
|
|
76
82
|
},
|
77
83
|
"devDependencies": {
|
78
84
|
"@babel/plugin-syntax-jsx": "7.25.9",
|
85
|
+
"@babel/preset-flow": "7.25.9",
|
86
|
+
"@babel/preset-typescript": "7.26.0",
|
79
87
|
"@biomejs/biome": "1.9.4",
|
80
88
|
"@commitlint/config-conventional": "19.6.0",
|
81
|
-
"@react-native/normalize-colors": "0.
|
89
|
+
"@react-native/normalize-colors": "0.77.0",
|
82
90
|
"@release-it/conventional-changelog": "8.0.2",
|
83
91
|
"@types/jest": "29.5.14",
|
84
92
|
"@types/react": "18.3.12",
|
85
93
|
"babel-plugin-tester": "11.0.4",
|
86
|
-
"commitlint": "19.6.
|
87
|
-
"concurrently": "9.1.
|
94
|
+
"commitlint": "19.6.1",
|
95
|
+
"concurrently": "9.1.2",
|
88
96
|
"husky": "9.1.7",
|
89
97
|
"jest": "29.7.0",
|
90
98
|
"metro-react-native-babel-preset": "0.77.0",
|
91
|
-
"nitro-codegen": "0.
|
99
|
+
"nitro-codegen": "0.21.0",
|
92
100
|
"react": "18.3.1",
|
93
|
-
"react-native": "0.
|
101
|
+
"react-native": "0.77.0",
|
94
102
|
"react-native-builder-bob": "0.33.1",
|
95
|
-
"react-native-nitro-modules": "0.
|
103
|
+
"react-native-nitro-modules": "0.21.0",
|
96
104
|
"react-native-web": "0.19.13",
|
97
105
|
"react-test-renderer": "18.3.1",
|
98
106
|
"release-it": "17.6.0",
|
99
|
-
"typescript": "5.7.
|
107
|
+
"typescript": "5.7.3"
|
100
108
|
},
|
101
109
|
"peerDependencies": {
|
102
110
|
"@react-native/normalize-colors": "*",
|
@@ -107,7 +115,8 @@
|
|
107
115
|
},
|
108
116
|
"workspaces": [
|
109
117
|
"example",
|
110
|
-
"docs"
|
118
|
+
"docs",
|
119
|
+
"expo-example"
|
111
120
|
],
|
112
121
|
"packageManager": "yarn@3.6.1",
|
113
122
|
"engines": {
|
package/plugin/consts.js
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
const REACT_NATIVE_COMPONENT_NAMES = [
|
2
|
+
'ActivityIndicator',
|
3
|
+
'View',
|
4
|
+
'Text',
|
5
|
+
'Image',
|
6
|
+
'ImageBackground',
|
7
|
+
'KeyboardAvoidingView',
|
8
|
+
'Pressable',
|
9
|
+
'ScrollView',
|
10
|
+
'FlatList',
|
11
|
+
'SectionList',
|
12
|
+
'Switch',
|
13
|
+
'TextInput',
|
14
|
+
'RefreshControl',
|
15
|
+
'TouchableHighlight',
|
16
|
+
'TouchableOpacity',
|
17
|
+
'VirtualizedList',
|
18
|
+
'Animated'
|
19
|
+
// Modal - there is no exposed native handle
|
20
|
+
// TouchableWithoutFeedback - can't accept a ref
|
21
|
+
]
|
22
|
+
|
23
|
+
// auto replace RN imports to Unistyles imports under these paths
|
24
|
+
// our implementation simply borrows 'ref' to register it in ShadowRegistry
|
25
|
+
// so we won't affect anyone's implementation
|
26
|
+
const REPLACE_WITH_UNISTYLES_PATHS = [
|
27
|
+
'react-native-reanimated/src/component',
|
28
|
+
'react-native-gesture-handler/src/components'
|
29
|
+
]
|
30
|
+
|
31
|
+
// this is more powerful API as it allows to convert unmatched imports to Unistyles
|
32
|
+
// { path: string, imports: Array<{ name: string, isDefault: boolean, path: string, mapTo: string }> }
|
33
|
+
// path => node_modules path
|
34
|
+
// imports:
|
35
|
+
// name? <- target import name if isDefault is false
|
36
|
+
// isDefault <- is the import default?
|
37
|
+
// path <- path to the target import
|
38
|
+
// mapTo <- name of the Unistyles component
|
39
|
+
const REPLACE_WITH_UNISTYLES_EXOTIC_PATHS = []
|
40
|
+
|
41
|
+
// this list will additionally detect React Native direct imports
|
42
|
+
const NATIVE_COMPONENTS_PATHS = {
|
43
|
+
imports: [
|
44
|
+
{
|
45
|
+
name: 'NativeText',
|
46
|
+
isDefault: false,
|
47
|
+
path: 'react-native/Libraries/Text/TextNativeComponent',
|
48
|
+
mapTo: 'NativeText'
|
49
|
+
},
|
50
|
+
{
|
51
|
+
isDefault: true,
|
52
|
+
path: 'react-native/Libraries/Components/View/ViewNativeComponent',
|
53
|
+
mapTo: 'NativeView'
|
54
|
+
}
|
55
|
+
]
|
56
|
+
}
|
57
|
+
|
58
|
+
module.exports = {
|
59
|
+
NATIVE_COMPONENTS_PATHS,
|
60
|
+
REACT_NATIVE_COMPONENT_NAMES,
|
61
|
+
REPLACE_WITH_UNISTYLES_PATHS,
|
62
|
+
REPLACE_WITH_UNISTYLES_EXOTIC_PATHS
|
63
|
+
}
|
package/plugin/exotic.js
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
function handleExoticImport(t, path, state, exoticImport) {
|
2
|
+
const specifiers = path.node.specifiers
|
3
|
+
const source = path.node.source
|
4
|
+
|
5
|
+
if (path.node.importKind !== 'value') {
|
6
|
+
return
|
7
|
+
}
|
8
|
+
|
9
|
+
specifiers.forEach(specifier => {
|
10
|
+
for (const rule of exoticImport.imports) {
|
11
|
+
const hasMatchingImportType = (!rule.isDefault && t.isImportSpecifier(specifier)) || (rule.isDefault && t.isImportDefaultSpecifier(specifier))
|
12
|
+
const hasMatchingImportName = rule.isDefault || (!rule.isDefault && rule.name === specifier.local.name)
|
13
|
+
const hasMatchingPath = rule.path === source.value
|
14
|
+
|
15
|
+
if (!hasMatchingImportType || !hasMatchingImportName || !hasMatchingPath) {
|
16
|
+
continue
|
17
|
+
}
|
18
|
+
|
19
|
+
if (t.isImportDefaultSpecifier(specifier)) {
|
20
|
+
const newImport = t.importDeclaration(
|
21
|
+
[t.importDefaultSpecifier(t.identifier(specifier.local.name))],
|
22
|
+
t.stringLiteral(state.opts.isLocal
|
23
|
+
? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/components/native/${rule.mapTo}`)
|
24
|
+
: `react-native-unistyles/components/native/${rule.mapTo}`
|
25
|
+
)
|
26
|
+
)
|
27
|
+
|
28
|
+
path.replaceWith(newImport)
|
29
|
+
} else {
|
30
|
+
const newImport = t.importDeclaration(
|
31
|
+
[t.importSpecifier(t.identifier(rule.mapTo), t.identifier(rule.mapTo))],
|
32
|
+
t.stringLiteral(state.opts.isLocal
|
33
|
+
? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/components/native/${rule.mapTo}`)
|
34
|
+
: `react-native-unistyles/components/native/${rule.mapTo}`
|
35
|
+
)
|
36
|
+
)
|
37
|
+
|
38
|
+
path.node.specifiers = specifiers.filter(s => s !== specifier)
|
39
|
+
|
40
|
+
if (path.node.specifiers.length === 0) {
|
41
|
+
path.replaceWith(newImport)
|
42
|
+
} else {
|
43
|
+
path.insertBefore(newImport)
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
return
|
48
|
+
}
|
49
|
+
})
|
50
|
+
}
|
51
|
+
|
52
|
+
module.exports = {
|
53
|
+
handleExoticImport
|
54
|
+
}
|
package/plugin/import.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
/** @param {import('./index').UnistylesPluginPass} state */
|
1
2
|
function addUnistylesImport(t, path, state) {
|
2
3
|
const localNames = Object.keys(state.reactNativeImports)
|
3
4
|
const names = Object.values(state.reactNativeImports)
|
@@ -38,27 +39,6 @@ function addUnistylesImport(t, path, state) {
|
|
38
39
|
path.node.body.unshift(newImport)
|
39
40
|
})
|
40
41
|
|
41
|
-
// import variants
|
42
|
-
if (state.file.hasVariants) {
|
43
|
-
const unistylesImport = path.node.body
|
44
|
-
.find(node => t.isImportDeclaration(node) && node.source.value === 'react-native-unistyles')
|
45
|
-
|
46
|
-
if (unistylesImport) {
|
47
|
-
// prevent duplications
|
48
|
-
if (!unistylesImport.specifiers.some(specifier => specifier.local.name === 'Variants')) {
|
49
|
-
unistylesImport.specifiers.push(t.importSpecifier(t.identifier('Variants'), t.identifier('Variants')))
|
50
|
-
}
|
51
|
-
} else {
|
52
|
-
// Add a new import declaration for "Variants" from "react-native-unistyles"
|
53
|
-
const newImport = t.importDeclaration(
|
54
|
-
[t.importSpecifier(t.identifier('Variants'), t.identifier('Variants'))],
|
55
|
-
t.stringLiteral('react-native-unistyles')
|
56
|
-
)
|
57
|
-
|
58
|
-
path.node.body.unshift(newImport)
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
42
|
// cleanup
|
63
43
|
nodesToRemove.forEach(node => path.node.body.splice(path.node.body.indexOf(node), 1))
|
64
44
|
}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
type RemapImport = {
|
2
|
+
name?: string,
|
3
|
+
isDefault: boolean,
|
4
|
+
path: string,
|
5
|
+
mapTo: string
|
6
|
+
}
|
7
|
+
|
8
|
+
type RemapConfig = {
|
9
|
+
path: string,
|
10
|
+
imports: Array<RemapImport>
|
11
|
+
}
|
12
|
+
|
13
|
+
export interface UnistylesPluginOptions {
|
14
|
+
/**
|
15
|
+
* Example: "src" or "apps/mobile"
|
16
|
+
* Add this option if some of your components don't have `react-native-unistyles` import.
|
17
|
+
* Babel plugin will automatically process all files under this root.
|
18
|
+
*/
|
19
|
+
autoProcessRoot?: string,
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Example: ['@codemask/styles']
|
23
|
+
* Enable this option if you want to process only files containing specific imports.
|
24
|
+
*/
|
25
|
+
autoProcessImports?: Array<string>,
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Example: [{
|
29
|
+
* path: "node_modules/custom-library/components",
|
30
|
+
* imports: [
|
31
|
+
* {
|
32
|
+
* name: "NativeText",
|
33
|
+
* isDefault: false,
|
34
|
+
* path: "react-native/Libraries/Text/TextNativeComponent",
|
35
|
+
* mapTo: "NativeText"
|
36
|
+
* },
|
37
|
+
* {
|
38
|
+
* isDefault: true,
|
39
|
+
* path: "react-native/Libraries/Components/View/ViewNativeComponent",
|
40
|
+
* mapTo: "NativeView"
|
41
|
+
* }
|
42
|
+
* ]
|
43
|
+
* }]
|
44
|
+
*
|
45
|
+
* Will map:
|
46
|
+
* import { NativeText } from "react-native/Libraries/Text/TextNativeComponent"
|
47
|
+
* to Unistyles "NativeText"
|
48
|
+
*
|
49
|
+
* import View from "react-native/Libraries/Components/View/ViewNativeComponent"
|
50
|
+
* to Unistyles "NativeView"
|
51
|
+
*
|
52
|
+
* This is the most powerful way of remapping imports. If 3rd party library uses imports different from `react-native` we can remap them to `react-native-unistyles` factories.
|
53
|
+
* Internally we do that for raw RCTView and RCTText components.
|
54
|
+
*
|
55
|
+
* path -> must be within node_modules folder
|
56
|
+
* imports.name is Optional if library used export default
|
57
|
+
* imports.mapTo - name of the component from react-native-unistyles/src/components/native
|
58
|
+
*/
|
59
|
+
autoRemapImports?: Array<RemapConfig>,
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Example: ['external-library/components']
|
63
|
+
* Enable this option to process some 3rd party components under `node_modules`.
|
64
|
+
* Under these paths we will replace `react-native` imports with `react-native-unistyles` factories that will borrow components refs [read more](https://www.unistyl.es/v3/other/babel-plugin#3-component-factory-borrowing-ref).
|
65
|
+
*
|
66
|
+
* Defaults to:
|
67
|
+
*
|
68
|
+
* ```ts
|
69
|
+
* ['react-native-reanimated/src/component', 'react-native-gesture-handler/src/components']
|
70
|
+
* ```
|
71
|
+
*/
|
72
|
+
autoProcessPaths?: Array<string>,
|
73
|
+
|
74
|
+
/**
|
75
|
+
* In order to list detected dependencies by the Babel plugin you can enable the `debug` flag.
|
76
|
+
* It will `console.log` name of the file and component with Unistyles dependencies.
|
77
|
+
*/
|
78
|
+
debug?: boolean,
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Only applicable for Unistyles monorepo for
|
82
|
+
* path resolution, don't use it!
|
83
|
+
*/
|
84
|
+
isLocal?: boolean
|
85
|
+
}
|
86
|
+
|
87
|
+
export interface UnistylesPluginPass {
|
88
|
+
opts: UnistylesPluginOptions
|
89
|
+
}
|
package/plugin/index.js
CHANGED
@@ -1,57 +1,45 @@
|
|
1
1
|
const { addUnistylesImport, isInsideNodeModules } = require('./import')
|
2
|
-
const { getStyleMetadata, getStyleAttribute, styleAttributeToArray, handlePressable } = require('./style')
|
3
2
|
const { hasStringRef } = require('./ref')
|
4
|
-
const { isUnistylesStyleSheet, analyzeDependencies, addStyleSheetTag, getUnistyles } = require('./stylesheet')
|
5
|
-
const {
|
6
|
-
|
7
|
-
const
|
8
|
-
'ActivityIndicator',
|
9
|
-
'View',
|
10
|
-
'Text',
|
11
|
-
'Image',
|
12
|
-
'ImageBackground',
|
13
|
-
'KeyboardAvoidingView',
|
14
|
-
'Pressable',
|
15
|
-
'ScrollView',
|
16
|
-
'FlatList',
|
17
|
-
'SectionList',
|
18
|
-
'Switch',
|
19
|
-
'TextInput',
|
20
|
-
'RefreshControl',
|
21
|
-
'TouchableHighlight',
|
22
|
-
'TouchableOpacity',
|
23
|
-
'VirtualizedList'
|
24
|
-
]
|
25
|
-
|
26
|
-
// Modal - there is no exposed native handle
|
27
|
-
// TouchableWithoutFeedback - can't accept a ref
|
3
|
+
const { isUnistylesStyleSheet, analyzeDependencies, addStyleSheetTag, getUnistyles, isKindOfStyleSheet, addThemeDependencyToMemberExpression } = require('./stylesheet')
|
4
|
+
const { extractVariants } = require('./variants')
|
5
|
+
const { REACT_NATIVE_COMPONENT_NAMES, REPLACE_WITH_UNISTYLES_PATHS, REPLACE_WITH_UNISTYLES_EXOTIC_PATHS, NATIVE_COMPONENTS_PATHS } = require('./consts')
|
6
|
+
const { handleExoticImport } = require('./exotic')
|
28
7
|
|
29
8
|
module.exports = function ({ types: t }) {
|
30
9
|
return {
|
31
10
|
name: 'babel-react-native-unistyles',
|
32
11
|
visitor: {
|
33
12
|
Program: {
|
13
|
+
/** @param {import('./index').UnistylesPluginPass} state */
|
34
14
|
enter(path, state) {
|
35
|
-
|
36
|
-
|
37
|
-
|
15
|
+
state.file.replaceWithUnistyles = REPLACE_WITH_UNISTYLES_PATHS
|
16
|
+
.concat(state.opts.autoProcessPaths ?? [])
|
17
|
+
.some(path => state.filename.includes(path))
|
38
18
|
|
39
19
|
state.file.hasAnyUnistyle = false
|
40
|
-
state.file.hasUnistylesImport = false
|
41
|
-
state.file.shouldIncludePressable = false
|
42
20
|
state.file.hasVariants = false
|
43
21
|
state.file.styleSheetLocalName = ''
|
44
22
|
state.file.tagNumber = 0
|
45
|
-
state.file.isClassComponent = false
|
46
23
|
state.reactNativeImports = {}
|
24
|
+
state.file.forceProcessing = state.opts.autoProcessRoot
|
25
|
+
? state.filename.includes(`${state.file.opts.root}/${state.opts.autoProcessRoot}/`)
|
26
|
+
: false
|
47
27
|
},
|
48
28
|
exit(path, state) {
|
49
|
-
if (state
|
29
|
+
if (isInsideNodeModules(state) && !state.file.replaceWithUnistyles) {
|
30
|
+
return
|
31
|
+
}
|
32
|
+
|
33
|
+
if (state.file.hasAnyUnistyle || state.file.hasVariants || state.file.replaceWithUnistyles || state.file.forceProcessing) {
|
50
34
|
addUnistylesImport(t, path, state)
|
51
35
|
}
|
52
36
|
}
|
53
37
|
},
|
54
38
|
FunctionDeclaration(path, state) {
|
39
|
+
if (isInsideNodeModules(state)) {
|
40
|
+
return
|
41
|
+
}
|
42
|
+
|
55
43
|
const componentName = path.node.id
|
56
44
|
? path.node.id.name
|
57
45
|
: null
|
@@ -61,13 +49,16 @@ module.exports = function ({ types: t }) {
|
|
61
49
|
}
|
62
50
|
},
|
63
51
|
ClassDeclaration(path, state) {
|
52
|
+
if (isInsideNodeModules(state)) {
|
53
|
+
return
|
54
|
+
}
|
55
|
+
|
64
56
|
const componentName = path.node.id
|
65
57
|
? path.node.id.name
|
66
58
|
: null
|
67
59
|
|
68
60
|
if (componentName) {
|
69
61
|
state.file.hasVariants = false
|
70
|
-
state.file.isClassComponent = true
|
71
62
|
}
|
72
63
|
},
|
73
64
|
VariableDeclaration(path, state) {
|
@@ -87,16 +78,23 @@ module.exports = function ({ types: t }) {
|
|
87
78
|
}
|
88
79
|
})
|
89
80
|
},
|
81
|
+
/** @param {import('./index').UnistylesPluginPass} state */
|
90
82
|
ImportDeclaration(path, state) {
|
91
|
-
|
83
|
+
const exoticImport = REPLACE_WITH_UNISTYLES_EXOTIC_PATHS
|
84
|
+
.concat(state.opts.autoRemapImports ?? [])
|
85
|
+
.find(exotic => state.filename.includes(exotic.path))
|
86
|
+
|
87
|
+
if (exoticImport) {
|
88
|
+
return handleExoticImport(t, path, state, exoticImport)
|
89
|
+
}
|
90
|
+
|
91
|
+
if (isInsideNodeModules(state) && !state.file.replaceWithUnistyles) {
|
92
92
|
return
|
93
93
|
}
|
94
94
|
|
95
95
|
const importSource = path.node.source.value
|
96
96
|
|
97
97
|
if (importSource.includes('react-native-unistyles')) {
|
98
|
-
state.file.hasUnistylesImport = true
|
99
|
-
|
100
98
|
path.node.specifiers.forEach(specifier => {
|
101
99
|
if (specifier.imported && specifier.imported.name === 'StyleSheet') {
|
102
100
|
state.file.styleSheetLocalName = specifier.local.name
|
@@ -104,20 +102,20 @@ module.exports = function ({ types: t }) {
|
|
104
102
|
})
|
105
103
|
}
|
106
104
|
|
107
|
-
if (importSource
|
105
|
+
if (importSource === 'react-native') {
|
108
106
|
path.node.specifiers.forEach(specifier => {
|
109
|
-
if (specifier.imported && specifier.imported.name
|
110
|
-
state.file.shouldIncludePressable = true
|
111
|
-
}
|
112
|
-
|
113
|
-
if (specifier.imported && reactNativeComponentNames.includes(specifier.imported.name)) {
|
107
|
+
if (specifier.imported && REACT_NATIVE_COMPONENT_NAMES.includes(specifier.imported.name)) {
|
114
108
|
state.reactNativeImports[specifier.local.name] = specifier.imported.name
|
115
109
|
}
|
116
110
|
})
|
117
111
|
}
|
118
112
|
|
119
|
-
if (importSource.includes('react-native
|
120
|
-
state
|
113
|
+
if (importSource.includes('react-native/Libraries')) {
|
114
|
+
handleExoticImport(t, path, state, NATIVE_COMPONENTS_PATHS)
|
115
|
+
}
|
116
|
+
|
117
|
+
if (!state.file.forceProcessing && Array.isArray(state.opts.autoProcessImports)) {
|
118
|
+
state.file.forceProcessing = state.opts.autoProcessImports.includes(importSource)
|
121
119
|
}
|
122
120
|
},
|
123
121
|
JSXElement(path, state) {
|
@@ -125,63 +123,28 @@ module.exports = function ({ types: t }) {
|
|
125
123
|
return
|
126
124
|
}
|
127
125
|
|
128
|
-
if (state.file.isClassComponent) {
|
129
|
-
return
|
130
|
-
}
|
131
|
-
|
132
|
-
const openingElement = path.node.openingElement
|
133
|
-
const openingElementName = openingElement.name.name
|
134
|
-
const isReactNativeComponent = Boolean(state.reactNativeImports[openingElementName])
|
135
|
-
const isAnimatedComponent = (
|
136
|
-
!isReactNativeComponent &&
|
137
|
-
openingElement.name.object &&
|
138
|
-
openingElement.name.object.name === 'Animated'
|
139
|
-
)
|
140
|
-
|
141
|
-
if (!isReactNativeComponent && !isAnimatedComponent) {
|
142
|
-
return
|
143
|
-
}
|
144
|
-
|
145
|
-
const styleAttr = getStyleAttribute(t, path)
|
146
|
-
|
147
|
-
// component has no style prop
|
148
|
-
if (!styleAttr) {
|
149
|
-
return
|
150
|
-
}
|
151
|
-
|
152
|
-
const metadata = getStyleMetadata(t, styleAttr.value.expression, null, state)
|
153
|
-
|
154
|
-
if (openingElementName === 'Pressable') {
|
155
|
-
return handlePressable(t, path, styleAttr, metadata, state)
|
156
|
-
}
|
157
|
-
|
158
|
-
// style prop is using unexpected expression
|
159
|
-
if (metadata.length === 0) {
|
160
|
-
return
|
161
|
-
}
|
162
|
-
|
163
|
-
styleAttributeToArray(t, path)
|
164
|
-
|
165
|
-
// to add import
|
166
|
-
state.file.hasAnyUnistyle = true
|
167
|
-
|
168
126
|
if (hasStringRef(t, path)) {
|
169
127
|
throw new Error("Detected string based ref which is not supported by Unistyles.")
|
170
128
|
}
|
171
129
|
},
|
172
|
-
|
130
|
+
BlockStatement(path, state) {
|
173
131
|
if (isInsideNodeModules(state)) {
|
174
132
|
return
|
175
133
|
}
|
176
134
|
|
177
|
-
|
178
|
-
|
135
|
+
extractVariants(t, path, state)
|
136
|
+
},
|
137
|
+
CallExpression(path, state) {
|
138
|
+
if (isInsideNodeModules(state)) {
|
139
|
+
return
|
179
140
|
}
|
180
141
|
|
181
|
-
if (!isUnistylesStyleSheet(t, path, state)) {
|
142
|
+
if (!isUnistylesStyleSheet(t, path, state) && !isKindOfStyleSheet(t, path, state)) {
|
182
143
|
return
|
183
144
|
}
|
184
145
|
|
146
|
+
state.file.hasAnyUnistyle = true
|
147
|
+
|
185
148
|
addStyleSheetTag(t, path, state)
|
186
149
|
|
187
150
|
const arg = path.node.arguments[0]
|
@@ -220,6 +183,13 @@ module.exports = function ({ types: t }) {
|
|
220
183
|
if (t.isObjectProperty(property)) {
|
221
184
|
const propertyValues = getUnistyles(t, property)
|
222
185
|
|
186
|
+
// maybe user used inlined theme? ({ container: theme.components.container })
|
187
|
+
if (propertyValues.length === 0 && t.isMemberExpression(property.value)) {
|
188
|
+
if (property.value.object.object.name === themeLocalName) {
|
189
|
+
addThemeDependencyToMemberExpression(t, property)
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
223
193
|
propertyValues.forEach(propertyValue => {
|
224
194
|
analyzeDependencies(t, state, property.key.name, propertyValue, themeLocalName, miniRuntimeLocalName)
|
225
195
|
})
|
@@ -227,14 +197,6 @@ module.exports = function ({ types: t }) {
|
|
227
197
|
})
|
228
198
|
}
|
229
199
|
}
|
230
|
-
},
|
231
|
-
ReturnStatement(path, state) {
|
232
|
-
// ignore nested returns in JSX elements
|
233
|
-
const hasJSXParent = path.findParent(p => p.isJSXElement())
|
234
|
-
|
235
|
-
if (!hasJSXParent && state.file.hasVariants) {
|
236
|
-
addJSXVariants(t, path, state)
|
237
|
-
}
|
238
200
|
}
|
239
201
|
}
|
240
202
|
}
|