react-native-unistyles 3.0.24 → 3.1.1
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 +7 -6
- package/android/src/main/cxx/NativeUnistylesModule.cpp +7 -4
- package/android/src/main/cxx/NativeUnistylesModule.h +9 -3
- package/android/src/main/cxx/cpp-adapter.cpp +1 -1
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +22 -4
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +1 -0
- package/cxx/core/StyleSheetRegistry.cpp +11 -11
- package/cxx/core/StyleSheetRegistry.h +4 -4
- package/cxx/core/UnistylesRegistry.cpp +27 -14
- package/cxx/core/UnistylesRegistry.h +4 -1
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +5 -0
- package/cxx/hybridObjects/HybridStyleSheet.cpp +2 -14
- package/cxx/hybridObjects/HybridStyleSheet.h +0 -2
- package/ios/UnistylesModuleOnLoad.mm +10 -2
- package/lib/commonjs/components/AdaptiveTheme.js +1 -1
- package/lib/commonjs/components/AdaptiveTheme.js.map +1 -1
- package/lib/commonjs/components/ApplyScopedTheme.js.map +1 -1
- package/lib/commonjs/components/Display.js.map +1 -1
- package/lib/commonjs/components/Hide.js.map +1 -1
- package/lib/commonjs/components/NamedTheme.js +2 -2
- package/lib/commonjs/components/NamedTheme.js.map +1 -1
- package/lib/commonjs/components/ScopedTheme.js.map +1 -1
- package/lib/commonjs/components/native/ActivityIndicator.js.map +1 -1
- package/lib/commonjs/components/native/Animated.js.map +1 -1
- package/lib/commonjs/components/native/FlatList.js.map +1 -1
- package/lib/commonjs/components/native/Image.js.map +1 -1
- package/lib/commonjs/components/native/Image.native.js.map +1 -1
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/ImageBackground.native.js.map +1 -1
- package/lib/commonjs/components/native/KeyboardAvoidingView.js.map +1 -1
- package/lib/commonjs/components/native/NativeText.native.js.map +1 -1
- package/lib/commonjs/components/native/NativeView.native.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/components/native/RefreshControl.js.map +1 -1
- package/lib/commonjs/components/native/SafeAreaView.js.map +1 -1
- package/lib/commonjs/components/native/ScrollView.js.map +1 -1
- package/lib/commonjs/components/native/SectionList.js.map +1 -1
- package/lib/commonjs/components/native/Switch.js.map +1 -1
- package/lib/commonjs/components/native/Text.js.map +1 -1
- package/lib/commonjs/components/native/TextInput.js.map +1 -1
- package/lib/commonjs/components/native/TouchableHighlight.js.map +1 -1
- package/lib/commonjs/components/native/TouchableOpacity.js.map +1 -1
- package/lib/commonjs/components/native/View.js.map +1 -1
- package/lib/commonjs/components/native/VirtualizedList.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/getClassname.js.map +1 -1
- package/lib/commonjs/core/parseBoxShadow.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/listener.native.js +0 -1
- package/lib/commonjs/core/useProxifiedUnistyles/listener.native.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/commonjs/core/useUnistyles.js.map +1 -1
- package/lib/commonjs/core/warn.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +3 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +6 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.native.js +0 -1
- package/lib/commonjs/hooks/useMedia.native.js.map +1 -1
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mocks.js +28 -8
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/mq.js.map +1 -1
- package/lib/commonjs/reanimated/useAnimatedTheme.js.map +1 -1
- package/lib/commonjs/reanimated/useAnimatedTheme.native.js +0 -1
- package/lib/commonjs/reanimated/useAnimatedTheme.native.js.map +1 -1
- package/lib/commonjs/reanimated/variant/useAnimatedVariantColor.js.map +1 -1
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js.map +1 -1
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js +0 -1
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js.map +1 -1
- package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/useServerUnistyles.js.map +1 -1
- package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +9 -5
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/commonjs/specs/index.native.js +1 -1
- package/lib/commonjs/specs/index.native.js.map +1 -1
- package/lib/commonjs/specs/types.js.map +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/stylesheet.js.map +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/convert/index.js.map +1 -1
- package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -1
- package/lib/commonjs/web/convert/object/filter.js.map +1 -1
- package/lib/commonjs/web/convert/object/objectStyle.js.map +1 -1
- package/lib/commonjs/web/convert/object/transform.js.map +1 -1
- package/lib/commonjs/web/convert/pseudo.js.map +1 -1
- package/lib/commonjs/web/convert/shadow/boxShadow.js.map +1 -1
- package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js.map +1 -1
- package/lib/commonjs/web/convert/shadow/textShadow.js.map +1 -1
- package/lib/commonjs/web/convert/types.js.map +1 -1
- package/lib/commonjs/web/convert/utils.js.map +1 -1
- package/lib/commonjs/web/create.js +1 -5
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/css/core.js.map +1 -1
- package/lib/commonjs/web/css/state.js.map +1 -1
- package/lib/commonjs/web/css/utils.js.map +1 -1
- package/lib/commonjs/web/index.js +1 -0
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/listener.js +29 -8
- package/lib/commonjs/web/listener.js.map +1 -1
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js +1 -2
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/state.js +3 -3
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/utils/common.js.map +1 -1
- package/lib/commonjs/web/utils/createUnistylesRef.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +2 -0
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/commonjs/web/variants.js.map +1 -1
- package/lib/commonjs/web-only/getWebProps.js.map +1 -1
- package/lib/commonjs/web-only/index.js.map +1 -1
- package/lib/module/components/AdaptiveTheme.js +1 -1
- package/lib/module/components/AdaptiveTheme.js.map +1 -1
- package/lib/module/components/ApplyScopedTheme.js.map +1 -1
- package/lib/module/components/Display.js.map +1 -1
- package/lib/module/components/Hide.js.map +1 -1
- package/lib/module/components/NamedTheme.js +2 -2
- package/lib/module/components/NamedTheme.js.map +1 -1
- package/lib/module/components/ScopedTheme.js.map +1 -1
- package/lib/module/components/native/ActivityIndicator.js.map +1 -1
- package/lib/module/components/native/Animated.js.map +1 -1
- package/lib/module/components/native/FlatList.js.map +1 -1
- package/lib/module/components/native/Image.js.map +1 -1
- package/lib/module/components/native/Image.native.js.map +1 -1
- package/lib/module/components/native/ImageBackground.js.map +1 -1
- package/lib/module/components/native/ImageBackground.native.js.map +1 -1
- package/lib/module/components/native/KeyboardAvoidingView.js.map +1 -1
- package/lib/module/components/native/NativeText.native.js.map +1 -1
- package/lib/module/components/native/NativeView.native.js.map +1 -1
- package/lib/module/components/native/Pressable.js.map +1 -1
- package/lib/module/components/native/Pressable.native.js.map +1 -1
- package/lib/module/components/native/RefreshControl.js.map +1 -1
- package/lib/module/components/native/SafeAreaView.js.map +1 -1
- package/lib/module/components/native/ScrollView.js.map +1 -1
- package/lib/module/components/native/SectionList.js.map +1 -1
- package/lib/module/components/native/Switch.js.map +1 -1
- package/lib/module/components/native/Text.js.map +1 -1
- package/lib/module/components/native/TextInput.js.map +1 -1
- package/lib/module/components/native/TouchableHighlight.js.map +1 -1
- package/lib/module/components/native/TouchableOpacity.js.map +1 -1
- package/lib/module/components/native/View.js.map +1 -1
- package/lib/module/components/native/VirtualizedList.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/getClassname.js.map +1 -1
- package/lib/module/core/parseBoxShadow.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/listener.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/listener.native.js +0 -1
- package/lib/module/core/useProxifiedUnistyles/listener.native.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/module/core/useUnistyles.js.map +1 -1
- package/lib/module/core/warn.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.js +3 -1
- package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.native.js +6 -0
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/hooks/useMedia.js.map +1 -1
- package/lib/module/hooks/useMedia.native.js +0 -1
- package/lib/module/hooks/useMedia.native.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/mocks.js +28 -8
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/mq.js.map +1 -1
- package/lib/module/reanimated/useAnimatedTheme.js.map +1 -1
- package/lib/module/reanimated/useAnimatedTheme.native.js +0 -1
- package/lib/module/reanimated/useAnimatedTheme.native.js.map +1 -1
- package/lib/module/reanimated/variant/useAnimatedVariantColor.js.map +1 -1
- package/lib/module/reanimated/variant/useUpdateVariantColor.js.map +1 -1
- package/lib/module/reanimated/variant/useUpdateVariantColor.native.js +0 -1
- package/lib/module/reanimated/variant/useUpdateVariantColor.native.js.map +1 -1
- package/lib/module/server/getServerUnistyles.js.map +1 -1
- package/lib/module/server/useServerUnistyles.js.map +1 -1
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +9 -5
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/StatusBar/index.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/module/specs/index.native.js +1 -1
- package/lib/module/specs/index.native.js.map +1 -1
- package/lib/module/specs/types.js.map +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/stylesheet.js.map +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/convert/index.js.map +1 -1
- package/lib/module/web/convert/object/boxShadow.js.map +1 -1
- package/lib/module/web/convert/object/filter.js.map +1 -1
- package/lib/module/web/convert/object/objectStyle.js.map +1 -1
- package/lib/module/web/convert/object/transform.js.map +1 -1
- package/lib/module/web/convert/pseudo.js.map +1 -1
- package/lib/module/web/convert/shadow/boxShadow.js.map +1 -1
- package/lib/module/web/convert/shadow/getShadowBreakpoints.js.map +1 -1
- package/lib/module/web/convert/shadow/textShadow.js.map +1 -1
- package/lib/module/web/convert/types.js.map +1 -1
- package/lib/module/web/convert/utils.js.map +1 -1
- package/lib/module/web/create.js +2 -6
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/css/core.js.map +1 -1
- package/lib/module/web/css/state.js.map +1 -1
- package/lib/module/web/css/utils.js.map +1 -1
- package/lib/module/web/index.js +1 -0
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/listener.js +29 -8
- package/lib/module/web/listener.js.map +1 -1
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js +1 -2
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/state.js +3 -3
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/utils/common.js.map +1 -1
- package/lib/module/web/utils/createUnistylesRef.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +2 -0
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/module/web/variants.js.map +1 -1
- package/lib/module/web-only/getWebProps.js.map +1 -1
- package/lib/module/web-only/index.js.map +1 -1
- package/lib/typescript/src/__tests__/mocks.spec.d.ts +2 -0
- package/lib/typescript/src/__tests__/mocks.spec.d.ts.map +1 -0
- package/lib/typescript/src/__tests__/web-listener.spec.d.ts +2 -0
- package/lib/typescript/src/__tests__/web-listener.spec.d.ts.map +1 -0
- package/lib/typescript/src/components/AdaptiveTheme.d.ts +1 -1
- package/lib/typescript/src/components/AdaptiveTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/ApplyScopedTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/Display.d.ts.map +1 -1
- package/lib/typescript/src/components/Hide.d.ts.map +1 -1
- package/lib/typescript/src/components/NamedTheme.d.ts +1 -1
- package/lib/typescript/src/components/NamedTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/ScopedTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Animated.d.ts.map +1 -1
- package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Image.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/NativeText.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/NativeView.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.d.ts +1 -1
- package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.native.d.ts +1 -1
- package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -1
- package/lib/typescript/src/components/native/SafeAreaView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Switch.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Text.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -1
- package/lib/typescript/src/components/native/View.d.ts.map +1 -1
- package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
- package/lib/typescript/src/core/parseBoxShadow.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/types.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/useUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/types.d.ts +1 -1
- package/lib/typescript/src/core/withUnistyles/types.d.ts.map +1 -1
- 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/global.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.native.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mq.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/variant/types.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/variant/useAnimatedVariantColor.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts +1 -1
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts +1 -1
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts.map +1 -1
- package/lib/typescript/src/server/getServerUnistyles.d.ts +1 -1
- package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/server/types.d.ts.map +1 -1
- package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +4 -5
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/UnistylesStatusBar.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +0 -1
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +3 -3
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.native.d.ts +4 -4
- package/lib/typescript/src/specs/index.native.d.ts.map +1 -1
- package/lib/typescript/src/specs/types.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +2 -2
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +1 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/types/variants.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/types.d.ts +2 -2
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts +1 -1
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/css/core.d.ts.map +1 -1
- package/lib/typescript/src/web/css/state.d.ts.map +1 -1
- package/lib/typescript/src/web/css/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/listener.d.ts +5 -1
- package/lib/typescript/src/web/listener.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +1 -1
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +1 -1
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/types.d.ts +1 -1
- package/lib/typescript/src/web/types.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/createUnistylesRef.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/lib/typescript/src/web/variants.d.ts.map +1 -1
- package/lib/typescript/src/web-only/getWebProps.d.ts.map +1 -1
- package/lib/typescript/src/web-only/index.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +36 -42
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +19 -22
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +15 -18
- package/nitrogen/generated/android/unistylesOnLoad.cpp +14 -9
- package/nitrogen/generated/android/unistylesOnLoad.hpp +13 -4
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +0 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +0 -1
- package/package.json +43 -44
- package/plugin/index.d.ts +34 -28
- package/plugin/index.js +113 -103
- package/repack-plugin/index.d.ts +2 -2
- package/src/components/AdaptiveTheme.tsx +8 -12
- package/src/components/ApplyScopedTheme.tsx +2 -0
- package/src/components/Display.tsx +2 -3
- package/src/components/Hide.tsx +2 -3
- package/src/components/NamedTheme.tsx +9 -14
- package/src/components/ScopedTheme.tsx +22 -27
- package/src/components/native/ActivityIndicator.tsx +1 -0
- package/src/components/native/Animated.tsx +2 -1
- package/src/components/native/FlatList.tsx +1 -0
- package/src/components/native/Image.native.tsx +1 -0
- package/src/components/native/Image.tsx +11 -7
- package/src/components/native/ImageBackground.native.tsx +1 -0
- package/src/components/native/ImageBackground.tsx +11 -7
- package/src/components/native/KeyboardAvoidingView.tsx +1 -0
- package/src/components/native/NativeText.native.tsx +3 -1
- package/src/components/native/NativeView.native.tsx +3 -1
- package/src/components/native/Pressable.native.tsx +8 -8
- package/src/components/native/Pressable.tsx +25 -20
- package/src/components/native/RefreshControl.tsx +1 -0
- package/src/components/native/SafeAreaView.tsx +1 -0
- package/src/components/native/ScrollView.tsx +1 -0
- package/src/components/native/SectionList.tsx +1 -0
- package/src/components/native/Switch.tsx +1 -0
- package/src/components/native/Text.tsx +1 -0
- package/src/components/native/TextInput.tsx +1 -0
- package/src/components/native/TouchableHighlight.tsx +1 -0
- package/src/components/native/TouchableOpacity.tsx +1 -0
- package/src/components/native/View.tsx +1 -0
- package/src/components/native/VirtualizedList.tsx +1 -0
- package/src/core/createUnistylesElement.native.tsx +4 -2
- package/src/core/createUnistylesElement.tsx +14 -17
- package/src/core/createUnistylesImageBackground.tsx +6 -4
- package/src/core/getClassname.ts +4 -11
- package/src/core/parseBoxShadow.ts +11 -24
- package/src/core/passForwardRef.ts +1 -1
- package/src/core/useProxifiedUnistyles/listener.native.ts +3 -3
- package/src/core/useProxifiedUnistyles/listener.ts +10 -3
- package/src/core/useProxifiedUnistyles/types.ts +2 -2
- package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +13 -9
- package/src/core/useUnistyles.ts +2 -1
- package/src/core/warn.ts +4 -4
- package/src/core/withUnistyles/types.ts +7 -4
- package/src/core/withUnistyles/withUnistyles.native.tsx +53 -44
- package/src/core/withUnistyles/withUnistyles.tsx +30 -24
- package/src/global.ts +2 -2
- package/src/hooks/useMedia.native.ts +2 -2
- package/src/hooks/useMedia.ts +6 -3
- package/src/index.ts +1 -0
- package/src/mocks.ts +74 -49
- package/src/mq.ts +23 -15
- package/src/reanimated/useAnimatedTheme.native.ts +4 -3
- package/src/reanimated/useAnimatedTheme.ts +6 -2
- package/src/reanimated/variant/types.ts +11 -10
- package/src/reanimated/variant/useAnimatedVariantColor.ts +7 -7
- package/src/reanimated/variant/useUpdateVariantColor.native.ts +10 -6
- package/src/reanimated/variant/useUpdateVariantColor.ts +21 -21
- package/src/server/getServerUnistyles.tsx +11 -4
- package/src/server/index.ts +0 -1
- package/src/server/types.ts +1 -1
- package/src/server/useServerUnistyles.tsx +4 -1
- package/src/specs/NativePlatform/NativePlatform.nitro.ts +30 -27
- package/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.ts +3 -3
- package/src/specs/ShadowRegistry/ShadowRegistry.nitro.ts +1 -1
- package/src/specs/ShadowRegistry/index.ts +35 -29
- package/src/specs/ShadowRegistry/types.ts +9 -10
- package/src/specs/StatusBar/UnistylesStatusBar.nitro.ts +4 -4
- package/src/specs/StatusBar/index.ts +5 -5
- package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +2 -2
- package/src/specs/StyleSheet/index.ts +32 -27
- package/src/specs/TurboUnistyles/NativeTurboUnistyles.ts +1 -0
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +26 -25
- package/src/specs/UnistylesRuntime/index.ts +20 -20
- package/src/specs/index.native.ts +6 -18
- package/src/specs/types.ts +9 -8
- package/src/types/accessibility.ts +2 -2
- package/src/types/breakpoints.ts +61 -59
- package/src/types/core.ts +17 -17
- package/src/types/index.ts +2 -9
- package/src/types/stylesheet.ts +27 -19
- package/src/types/variants.ts +3 -11
- package/src/utils.ts +16 -16
- package/src/web/convert/index.ts +6 -2
- package/src/web/convert/object/boxShadow.ts +23 -18
- package/src/web/convert/object/filter.ts +30 -13
- package/src/web/convert/object/objectStyle.ts +33 -23
- package/src/web/convert/object/transform.ts +10 -8
- package/src/web/convert/pseudo.ts +2 -2
- package/src/web/convert/shadow/boxShadow.ts +6 -6
- package/src/web/convert/shadow/getShadowBreakpoints.ts +4 -4
- package/src/web/convert/shadow/textShadow.ts +6 -6
- package/src/web/convert/style.ts +25 -25
- package/src/web/convert/types.ts +4 -3
- package/src/web/convert/utils.ts +20 -10
- package/src/web/create.ts +29 -20
- package/src/web/css/core.ts +2 -1
- package/src/web/css/state.ts +11 -8
- package/src/web/css/utils.ts +2 -1
- package/src/web/index.ts +7 -4
- package/src/web/listener.ts +61 -18
- package/src/web/mock.ts +2 -2
- package/src/web/registry.ts +17 -10
- package/src/web/runtime.ts +23 -17
- package/src/web/shadowRegistry.ts +26 -24
- package/src/web/state.ts +23 -16
- package/src/web/types.ts +5 -5
- package/src/web/utils/common.ts +7 -9
- package/src/web/utils/createUnistylesRef.ts +18 -14
- package/src/web/utils/unistyle.ts +53 -34
- package/src/web/variants.ts +19 -11
- package/src/web-only/getWebProps.ts +5 -6
- package/src/web-only/index.ts +0 -1
- package/LICENSE +0 -20
- package/lib/typescript/plugin/src/consts.d.ts +0 -17
- package/lib/typescript/plugin/src/consts.d.ts.map +0 -1
- package/lib/typescript/repack-plugin/src/index.d.ts +0 -18
- package/lib/typescript/repack-plugin/src/index.d.ts.map +0 -1
- package/lib/typescript/repack-plugin/src/loader.d.ts +0 -9
- package/lib/typescript/repack-plugin/src/loader.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-unistyles",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"test": "NODE_ENV=babel-test jest ./plugin",
|
|
6
|
+
"test": "NODE_ENV=babel-test jest ./plugin ./src/__tests__",
|
|
7
7
|
"test:coverage": "NODE_ENV=babel-test jest --passWithNoTests --coverage",
|
|
8
8
|
"tsc": "node_modules/typescript/bin/tsc --noEmit",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"check
|
|
12
|
-
"
|
|
13
|
-
"
|
|
9
|
+
"format": "oxfmt src plugin repack-plugin",
|
|
10
|
+
"lint": "oxlint src plugin repack-plugin",
|
|
11
|
+
"check": "oxfmt src plugin repack-plugin && oxlint --fix src plugin repack-plugin",
|
|
12
|
+
"check:ci": "oxfmt --check src plugin repack-plugin && oxlint src plugin repack-plugin",
|
|
13
|
+
"prepare": "bob build && bun run plugin:build && bun run repack:plugin:build",
|
|
14
|
+
"precommit": "concurrently 'bun run tsc' 'bun run lint' 'bun run check' 'bun run test' 'bun run circular:check'",
|
|
14
15
|
"plugin:build": "node plugin/esbuild.js",
|
|
15
16
|
"repack:plugin:build": "node repack-plugin/esbuild.js",
|
|
16
17
|
"circular:check": "dpdm --no-warning --no-tree -T --exit-code circular:1 src/**/*.ts",
|
|
@@ -125,36 +126,35 @@
|
|
|
125
126
|
"publishConfig": {
|
|
126
127
|
"registry": "https://registry.npmjs.org/"
|
|
127
128
|
},
|
|
129
|
+
"dependencies": {
|
|
130
|
+
"@babel/types": "7.29.0"
|
|
131
|
+
},
|
|
128
132
|
"devDependencies": {
|
|
129
|
-
"@
|
|
130
|
-
"@
|
|
131
|
-
"@
|
|
132
|
-
"@
|
|
133
|
-
"@
|
|
134
|
-
"@
|
|
135
|
-
"
|
|
136
|
-
"
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
"
|
|
141
|
-
"babel
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
"
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
"react": "
|
|
151
|
-
"react-native": "
|
|
152
|
-
"react-native-
|
|
153
|
-
"
|
|
154
|
-
"react-native-reanimated": "3.17.5",
|
|
155
|
-
"react-native-web": "0.20.0",
|
|
156
|
-
"react-test-renderer": "19.1.0",
|
|
157
|
-
"typescript": "5.8.3"
|
|
133
|
+
"@callstack/repack": "5.2.4",
|
|
134
|
+
"@commitlint/config-conventional": "20.4.2",
|
|
135
|
+
"@react-native/normalize-colors": "0.83.2",
|
|
136
|
+
"@rspack/core": "1.7.6",
|
|
137
|
+
"@types/jest": "30.0.0",
|
|
138
|
+
"@types/react": "19.2.14",
|
|
139
|
+
"babel-plugin-tester": "12.0.0",
|
|
140
|
+
"commitlint": "20.4.2",
|
|
141
|
+
"concurrently": "9.2.1",
|
|
142
|
+
"dpdm": "4.0.1",
|
|
143
|
+
"esbuild": "0.27.3",
|
|
144
|
+
"jest": "30.2.0",
|
|
145
|
+
"@babel/plugin-syntax-jsx": "7.28.6",
|
|
146
|
+
"@babel/runtime": "7.28.6",
|
|
147
|
+
"@react-native/babel-preset": "0.83.2",
|
|
148
|
+
"nitrogen": "0.35.0",
|
|
149
|
+
"oxfmt": "0.35.0",
|
|
150
|
+
"oxlint": "1.50.0",
|
|
151
|
+
"react": "19.2.0",
|
|
152
|
+
"react-native": "0.83.2",
|
|
153
|
+
"react-native-builder-bob": "0.40.18",
|
|
154
|
+
"react-native-nitro-modules": "0.35.0",
|
|
155
|
+
"react-native-reanimated": "4.2.2",
|
|
156
|
+
"react-native-web": "0.21.2",
|
|
157
|
+
"typescript": "5.9.3"
|
|
158
158
|
},
|
|
159
159
|
"peerDependencies": {
|
|
160
160
|
"@react-native/normalize-colors": "*",
|
|
@@ -167,27 +167,26 @@
|
|
|
167
167
|
"peerDependenciesMeta": {
|
|
168
168
|
"react-native-reanimated": {
|
|
169
169
|
"optional": true
|
|
170
|
+
},
|
|
171
|
+
"react-native-edge-to-edge": {
|
|
172
|
+
"optional": true
|
|
170
173
|
}
|
|
171
174
|
},
|
|
172
|
-
"workspaces": [
|
|
173
|
-
"example",
|
|
174
|
-
"docs",
|
|
175
|
-
"expo-example"
|
|
176
|
-
],
|
|
177
|
-
"packageManager": "yarn@3.6.1",
|
|
178
175
|
"engines": {
|
|
179
|
-
"node": ">= 18.0
|
|
176
|
+
"node": ">= 20.18.0"
|
|
180
177
|
},
|
|
181
178
|
"jest": {
|
|
182
179
|
"preset": "react-native",
|
|
183
180
|
"modulePathIgnorePatterns": [
|
|
184
|
-
"<rootDir>/docs/node_modules",
|
|
185
181
|
"<rootDir>/lib/",
|
|
186
182
|
"<rootDir>/cxx/tests"
|
|
187
183
|
],
|
|
188
184
|
"testMatch": [
|
|
189
185
|
"**/*.spec.(ts|tsx|js)"
|
|
190
186
|
],
|
|
187
|
+
"transformIgnorePatterns": [
|
|
188
|
+
"node_modules/(?!(.bun/.*?/node_modules/)?(react-native|@react-native|react-native-nitro-modules|react-native-reanimated)/)"
|
|
189
|
+
],
|
|
191
190
|
"coverageReporters": [
|
|
192
191
|
"html"
|
|
193
192
|
]
|
package/plugin/index.d.ts
CHANGED
|
@@ -2,17 +2,17 @@ interface RemapImport {
|
|
|
2
2
|
/**
|
|
3
3
|
* The target import name if `isDefault` is false.
|
|
4
4
|
*/
|
|
5
|
-
name?: string
|
|
5
|
+
name?: string
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Whether the import is default.
|
|
9
9
|
*/
|
|
10
|
-
isDefault: boolean
|
|
10
|
+
isDefault: boolean
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* The path to the target import.
|
|
14
14
|
*/
|
|
15
|
-
path: string
|
|
15
|
+
path: string
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The name of the Unistyles component, check `react-native-unistyles/src/components/native`
|
|
@@ -27,7 +27,7 @@ export interface RemapConfig {
|
|
|
27
27
|
/**
|
|
28
28
|
* The node_modules path.
|
|
29
29
|
*/
|
|
30
|
-
path: string
|
|
30
|
+
path: string
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* An array of import objects with the following properties:
|
|
@@ -42,13 +42,13 @@ export interface UnistylesPluginOptions {
|
|
|
42
42
|
* Add root folder of your project. All files under this folder will be processed by the Babel plugin.
|
|
43
43
|
* If you need to process extra folders, use with `autoProcessPaths` option.
|
|
44
44
|
*/
|
|
45
|
-
root: string
|
|
45
|
+
root: string
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
autoProcessImports?: Array<string
|
|
48
|
+
* Example: ['@codemask/styles']
|
|
49
|
+
* Enable this option if you want to process only files containing specific imports.
|
|
50
|
+
*/
|
|
51
|
+
autoProcessImports?: Array<string>
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Example:
|
|
@@ -94,30 +94,36 @@ export interface UnistylesPluginOptions {
|
|
|
94
94
|
* imports.name is Optional if library used export default
|
|
95
95
|
* imports.mapTo - name of the component from react-native-unistyles/src/components/native
|
|
96
96
|
*/
|
|
97
|
-
autoRemapImports?: Array<RemapConfig
|
|
97
|
+
autoRemapImports?: Array<RemapConfig>
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
autoProcessPaths?: Array<string
|
|
100
|
+
* Example: ['external-library/components']
|
|
101
|
+
* Enable this option to process some 3rd party components under `node_modules`.
|
|
102
|
+
* 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).
|
|
103
|
+
*
|
|
104
|
+
* Defaults to:
|
|
105
|
+
*
|
|
106
|
+
* ```ts
|
|
107
|
+
* ['react-native-reanimated/src/component']
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
autoProcessPaths?: Array<string>
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
debug?: boolean
|
|
113
|
+
* In order to list detected dependencies by the Babel plugin you can enable the `debug` flag.
|
|
114
|
+
* It will `console.log` name of the file and component with Unistyles dependencies.
|
|
115
|
+
*/
|
|
116
|
+
debug?: boolean
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
* Only applicable for Unistyles monorepo for
|
|
120
|
+
* path resolution, don't use it!
|
|
121
|
+
*/
|
|
122
122
|
isLocal?: boolean
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Absolute path to the local package root.
|
|
126
|
+
* Used with `isLocal` for monorepo development to resolve component imports.
|
|
127
|
+
*/
|
|
128
|
+
localPath?: string
|
|
123
129
|
}
|
package/plugin/index.js
CHANGED
|
@@ -33,8 +33,8 @@ __export(index_exports, {
|
|
|
33
33
|
default: () => index_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
|
-
var import_node_path2 = __toESM(require("node:path"));
|
|
37
36
|
var t6 = __toESM(require("@babel/types"));
|
|
37
|
+
var import_node_path2 = __toESM(require("node:path"));
|
|
38
38
|
|
|
39
39
|
// plugin/src/consts.ts
|
|
40
40
|
var REACT_NATIVE_COMPONENT_NAMES = [
|
|
@@ -81,75 +81,46 @@ var NATIVE_COMPONENTS_PATHS = {
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
// plugin/src/exotic.ts
|
|
84
|
+
var t2 = __toESM(require("@babel/types"));
|
|
85
|
+
|
|
86
|
+
// plugin/src/import.ts
|
|
84
87
|
var t = __toESM(require("@babel/types"));
|
|
85
|
-
function
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (path2.node.importKind !== "value") {
|
|
89
|
-
return;
|
|
88
|
+
function getComponentPath(state, name) {
|
|
89
|
+
if (!state.opts.isLocal) {
|
|
90
|
+
return `react-native-unistyles/components/native/${name}`;
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const hasMatchingPath = rule.path === source.value;
|
|
96
|
-
if (!hasMatchingImportType || !hasMatchingImportName || !hasMatchingPath) {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
if (t.isImportDefaultSpecifier(specifier)) {
|
|
100
|
-
const newImport = t.importDeclaration(
|
|
101
|
-
[t.importDefaultSpecifier(t.identifier(specifier.local.name))],
|
|
102
|
-
t.stringLiteral(
|
|
103
|
-
state.opts.isLocal ? state.file.opts.filename?.split("react-native-unistyles").at(0)?.concat(`react-native-unistyles/components/native/${rule.mapTo}`) ?? "" : `react-native-unistyles/components/native/${rule.mapTo}`
|
|
104
|
-
)
|
|
105
|
-
);
|
|
106
|
-
path2.replaceWith(newImport);
|
|
107
|
-
} else {
|
|
108
|
-
const newImport = t.importDeclaration(
|
|
109
|
-
[t.importSpecifier(t.identifier(rule.mapTo), t.identifier(rule.mapTo))],
|
|
110
|
-
t.stringLiteral(
|
|
111
|
-
state.opts.isLocal ? state.file.opts.filename?.split("react-native-unistyles").at(0)?.concat(`react-native-unistyles/components/native/${rule.mapTo}`) ?? "" : `react-native-unistyles/components/native/${rule.mapTo}`
|
|
112
|
-
)
|
|
113
|
-
);
|
|
114
|
-
path2.node.specifiers = specifiers.filter((s) => s !== specifier);
|
|
115
|
-
if (path2.node.specifiers.length === 0) {
|
|
116
|
-
path2.replaceWith(newImport);
|
|
117
|
-
} else {
|
|
118
|
-
path2.insertBefore(newImport);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
});
|
|
92
|
+
if (state.opts.localPath) {
|
|
93
|
+
return `${state.opts.localPath}/src/components/native/${name}`;
|
|
94
|
+
}
|
|
95
|
+
return state.file.opts.filename?.split("react-native-unistyles").at(0)?.concat(`react-native-unistyles/src/components/native/${name}`) ?? "";
|
|
124
96
|
}
|
|
125
|
-
|
|
126
|
-
// plugin/src/import.ts
|
|
127
|
-
var t2 = __toESM(require("@babel/types"));
|
|
128
97
|
function addUnistylesImport(path2, state) {
|
|
129
98
|
const localNames = Object.keys(state.reactNativeImports);
|
|
130
99
|
const names = Object.values(state.reactNativeImports);
|
|
131
100
|
const pairs = Object.entries(state.reactNativeImports);
|
|
132
101
|
const nodesToRemove = [];
|
|
133
102
|
path2.node.body.forEach((node) => {
|
|
134
|
-
if (
|
|
135
|
-
node.specifiers = node.specifiers.filter(
|
|
103
|
+
if (t.isImportDeclaration(node) && node.source.value === "react-native") {
|
|
104
|
+
node.specifiers = node.specifiers.filter(
|
|
105
|
+
(specifier) => !localNames.some((name) => name === specifier.local.name)
|
|
106
|
+
);
|
|
136
107
|
if (node.specifiers.length === 0) {
|
|
137
108
|
nodesToRemove.push(node);
|
|
138
109
|
}
|
|
139
110
|
}
|
|
140
111
|
});
|
|
141
112
|
names.forEach((name) => {
|
|
142
|
-
const rnWebImport = path2.node.body.find(
|
|
113
|
+
const rnWebImport = path2.node.body.find(
|
|
114
|
+
(node) => t.isImportDeclaration(node) && node.source.value === `react-native-web/dist/exports/${name}`
|
|
115
|
+
);
|
|
143
116
|
if (rnWebImport) {
|
|
144
117
|
rnWebImport.specifiers = [];
|
|
145
118
|
}
|
|
146
119
|
});
|
|
147
120
|
pairs.forEach(([localName, name]) => {
|
|
148
|
-
const newImport =
|
|
149
|
-
[
|
|
150
|
-
|
|
151
|
-
state.opts.isLocal ? state.file.opts.filename?.split("react-native-unistyles").at(0)?.concat(`react-native-unistyles/src/components/native/${name}`) ?? "" : `react-native-unistyles/components/native/${name}`
|
|
152
|
-
)
|
|
121
|
+
const newImport = t.importDeclaration(
|
|
122
|
+
[t.importSpecifier(t.identifier(localName), t.identifier(name))],
|
|
123
|
+
t.stringLiteral(getComponentPath(state, name))
|
|
153
124
|
);
|
|
154
125
|
path2.node.body.unshift(newImport);
|
|
155
126
|
});
|
|
@@ -160,11 +131,11 @@ function isInsideNodeModules(state) {
|
|
|
160
131
|
}
|
|
161
132
|
function addUnistylesRequire(path2, state) {
|
|
162
133
|
Object.entries(state.reactNativeImports).forEach(([componentName, uniqueName]) => {
|
|
163
|
-
const newRequire =
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
134
|
+
const newRequire = t.variableDeclaration("const", [
|
|
135
|
+
t.variableDeclarator(
|
|
136
|
+
t.identifier(uniqueName),
|
|
137
|
+
t.callExpression(t.identifier("require"), [
|
|
138
|
+
t.stringLiteral(`react-native-unistyles/components/native/${componentName}`)
|
|
168
139
|
])
|
|
169
140
|
)
|
|
170
141
|
]);
|
|
@@ -172,6 +143,44 @@ function addUnistylesRequire(path2, state) {
|
|
|
172
143
|
});
|
|
173
144
|
}
|
|
174
145
|
|
|
146
|
+
// plugin/src/exotic.ts
|
|
147
|
+
function handleExoticImport(path2, state, exoticImport) {
|
|
148
|
+
const specifiers = path2.node.specifiers;
|
|
149
|
+
const source = path2.node.source;
|
|
150
|
+
if (path2.node.importKind !== "value") {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
specifiers.forEach((specifier) => {
|
|
154
|
+
for (const rule of exoticImport.imports) {
|
|
155
|
+
const hasMatchingImportType = !rule.isDefault && t2.isImportSpecifier(specifier) || rule.isDefault && t2.isImportDefaultSpecifier(specifier);
|
|
156
|
+
const hasMatchingImportName = rule.isDefault || !rule.isDefault && rule.name === specifier.local.name;
|
|
157
|
+
const hasMatchingPath = rule.path === source.value;
|
|
158
|
+
if (!hasMatchingImportType || !hasMatchingImportName || !hasMatchingPath) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
if (t2.isImportDefaultSpecifier(specifier)) {
|
|
162
|
+
const newImport = t2.importDeclaration(
|
|
163
|
+
[t2.importDefaultSpecifier(t2.identifier(specifier.local.name))],
|
|
164
|
+
t2.stringLiteral(getComponentPath(state, rule.mapTo))
|
|
165
|
+
);
|
|
166
|
+
path2.replaceWith(newImport);
|
|
167
|
+
} else {
|
|
168
|
+
const newImport = t2.importDeclaration(
|
|
169
|
+
[t2.importSpecifier(t2.identifier(rule.mapTo), t2.identifier(rule.mapTo))],
|
|
170
|
+
t2.stringLiteral(getComponentPath(state, rule.mapTo))
|
|
171
|
+
);
|
|
172
|
+
path2.node.specifiers = specifiers.filter((s) => s !== specifier);
|
|
173
|
+
if (path2.node.specifiers.length === 0) {
|
|
174
|
+
path2.replaceWith(newImport);
|
|
175
|
+
} else {
|
|
176
|
+
path2.insertBefore(newImport);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
175
184
|
// plugin/src/paths.ts
|
|
176
185
|
var import_node_path = __toESM(require("node:path"));
|
|
177
186
|
var isWindows = process.platform === "win32";
|
|
@@ -314,15 +323,6 @@ function getReturnStatementsFromBody(node, results = []) {
|
|
|
314
323
|
}
|
|
315
324
|
return results;
|
|
316
325
|
}
|
|
317
|
-
function stringToUniqueId(str) {
|
|
318
|
-
let hash = 0;
|
|
319
|
-
for (let i = 0; i < str.length; i++) {
|
|
320
|
-
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
321
|
-
hash |= 0;
|
|
322
|
-
}
|
|
323
|
-
const absHash = Math.abs(hash);
|
|
324
|
-
return absHash % 1e9;
|
|
325
|
-
}
|
|
326
326
|
function isUnistylesStyleSheet(path2, state) {
|
|
327
327
|
const { callee } = path2.node;
|
|
328
328
|
if (!t4.isMemberExpression(callee) || !t4.isIdentifier(callee.property)) {
|
|
@@ -384,11 +384,6 @@ function isKindOfStyleSheet(path2, state) {
|
|
|
384
384
|
}
|
|
385
385
|
return false;
|
|
386
386
|
}
|
|
387
|
-
function addStyleSheetTag(path2, state) {
|
|
388
|
-
const str = state.filename?.replace(state.cwd, "") ?? "";
|
|
389
|
-
const uniqueId = stringToUniqueId(str) + ++state.file.tagNumber;
|
|
390
|
-
path2.node.arguments.push(t4.numericLiteral(uniqueId));
|
|
391
|
-
}
|
|
392
387
|
function getStylesDependenciesFromObject(path2) {
|
|
393
388
|
const detectedStylesWithVariants = /* @__PURE__ */ new Set();
|
|
394
389
|
const stylesheet = path2.node.arguments[0];
|
|
@@ -426,10 +421,7 @@ function getStylesDependenciesFromObject(path2) {
|
|
|
426
421
|
const variants = Array.from(detectedStylesWithVariants);
|
|
427
422
|
return variants.reduce((acc, { key, label }) => {
|
|
428
423
|
if (acc[key]) {
|
|
429
|
-
acc[key] = [
|
|
430
|
-
...acc[key],
|
|
431
|
-
label
|
|
432
|
-
];
|
|
424
|
+
acc[key] = [...acc[key], label];
|
|
433
425
|
return acc;
|
|
434
426
|
}
|
|
435
427
|
acc[key] = [label];
|
|
@@ -546,7 +538,9 @@ function getStylesDependenciesFromFunction(funcPath) {
|
|
|
546
538
|
return;
|
|
547
539
|
}
|
|
548
540
|
binding.referencePaths.forEach((refPath) => {
|
|
549
|
-
const containerProp = refPath.findParent(
|
|
541
|
+
const containerProp = refPath.findParent(
|
|
542
|
+
(parent) => parent.isObjectProperty() && parent.parentPath === returnedObjectPath
|
|
543
|
+
);
|
|
550
544
|
if (!containerProp) {
|
|
551
545
|
return;
|
|
552
546
|
}
|
|
@@ -607,7 +601,9 @@ function getStylesDependenciesFromFunction(funcPath) {
|
|
|
607
601
|
}
|
|
608
602
|
}
|
|
609
603
|
}
|
|
610
|
-
const containerProp = refPath.findParent(
|
|
604
|
+
const containerProp = refPath.findParent(
|
|
605
|
+
(parent2) => parent2.isObjectProperty() && parent2.parentPath === returnedObjectPath
|
|
606
|
+
);
|
|
611
607
|
if (!containerProp) {
|
|
612
608
|
return;
|
|
613
609
|
}
|
|
@@ -631,10 +627,7 @@ function getStylesDependenciesFromFunction(funcPath) {
|
|
|
631
627
|
const rt = Array.from(detectedStylesWithRt);
|
|
632
628
|
return theme.concat(rt).concat(variants).reduce((acc, { key, label }) => {
|
|
633
629
|
if (acc[key]) {
|
|
634
|
-
acc[key] = [
|
|
635
|
-
...acc[key],
|
|
636
|
-
label
|
|
637
|
-
];
|
|
630
|
+
acc[key] = [...acc[key], label];
|
|
638
631
|
return acc;
|
|
639
632
|
}
|
|
640
633
|
acc[key] = [label];
|
|
@@ -644,8 +637,14 @@ function getStylesDependenciesFromFunction(funcPath) {
|
|
|
644
637
|
function addDependencies(state, styleName, unistyle, detectedDependencies) {
|
|
645
638
|
const debugMessage = (deps) => {
|
|
646
639
|
if (state.opts.debug) {
|
|
647
|
-
const mappedDeps = deps.map(
|
|
648
|
-
|
|
640
|
+
const mappedDeps = deps.map(
|
|
641
|
+
(dep) => Object.keys(UnistyleDependency).find(
|
|
642
|
+
(key) => UnistyleDependency[key] === dep
|
|
643
|
+
)
|
|
644
|
+
).join(", ");
|
|
645
|
+
console.log(
|
|
646
|
+
`${state.filename?.replace(`${state.file.opts.root}/`, "")}: styles.${styleName}: [${mappedDeps}]`
|
|
647
|
+
);
|
|
649
648
|
}
|
|
650
649
|
};
|
|
651
650
|
const styleDependencies = detectedDependencies.map(toUnistylesDependency);
|
|
@@ -660,9 +659,7 @@ function addDependencies(state, styleName, unistyle, detectedDependencies) {
|
|
|
660
659
|
if (t4.isBlockStatement(unistyle.value.body)) {
|
|
661
660
|
targets = getReturnStatementsFromBody(unistyle.value.body).map((node) => {
|
|
662
661
|
if (t4.isIdentifier(node.argument)) {
|
|
663
|
-
node.argument = t4.objectExpression([
|
|
664
|
-
t4.spreadElement(node.argument)
|
|
665
|
-
]);
|
|
662
|
+
node.argument = t4.objectExpression([t4.spreadElement(node.argument)]);
|
|
666
663
|
}
|
|
667
664
|
return node.argument;
|
|
668
665
|
}).filter((node) => t4.isObjectExpression(node));
|
|
@@ -680,7 +677,9 @@ function addDependencies(state, styleName, unistyle, detectedDependencies) {
|
|
|
680
677
|
target.properties.push(
|
|
681
678
|
t4.objectProperty(
|
|
682
679
|
t4.identifier("uni__dependencies"),
|
|
683
|
-
t4.arrayExpression(
|
|
680
|
+
t4.arrayExpression(
|
|
681
|
+
uniqueDependencies.filter((dep) => dep !== void 0 && dep !== null).map((dep) => t4.numericLiteral(dep))
|
|
682
|
+
)
|
|
684
683
|
)
|
|
685
684
|
);
|
|
686
685
|
});
|
|
@@ -691,7 +690,9 @@ function addDependencies(state, styleName, unistyle, detectedDependencies) {
|
|
|
691
690
|
// plugin/src/variants.ts
|
|
692
691
|
var t5 = __toESM(require("@babel/types"));
|
|
693
692
|
function extractVariants(path2, state) {
|
|
694
|
-
const maybeVariants = path2.node.body.filter(
|
|
693
|
+
const maybeVariants = path2.node.body.filter(
|
|
694
|
+
(node2) => t5.isExpressionStatement(node2) && t5.isCallExpression(node2.expression) && t5.isMemberExpression(node2.expression.callee)
|
|
695
|
+
);
|
|
695
696
|
if (maybeVariants.length === 0) {
|
|
696
697
|
return;
|
|
697
698
|
}
|
|
@@ -727,15 +728,8 @@ function extractVariants(path2, state) {
|
|
|
727
728
|
]);
|
|
728
729
|
const pathIndex = path2.node.body.findIndex((bodyPath) => bodyPath === targetVariant);
|
|
729
730
|
const rest = path2.node.body.slice(pathIndex + 1);
|
|
730
|
-
const statement = t5.blockStatement([
|
|
731
|
-
|
|
732
|
-
...rest
|
|
733
|
-
]);
|
|
734
|
-
path2.node.body = [
|
|
735
|
-
...path2.node.body.slice(0, pathIndex),
|
|
736
|
-
shadowDeclaration,
|
|
737
|
-
statement
|
|
738
|
-
];
|
|
731
|
+
const statement = t5.blockStatement([finalDeclaration, ...rest]);
|
|
732
|
+
path2.node.body = [...path2.node.body.slice(0, pathIndex), shadowDeclaration, statement];
|
|
739
733
|
state.file.hasVariants = true;
|
|
740
734
|
}
|
|
741
735
|
|
|
@@ -753,20 +747,25 @@ function index_default() {
|
|
|
753
747
|
Program: {
|
|
754
748
|
enter(path2, state) {
|
|
755
749
|
if (!state.opts.root) {
|
|
756
|
-
throw new Error(
|
|
750
|
+
throw new Error(
|
|
751
|
+
"Unistyles \u{1F984}: Babel plugin requires `root` option to be set. Please check https://www.unistyl.es/v3/other/babel-plugin#extra-configuration"
|
|
752
|
+
);
|
|
757
753
|
}
|
|
758
754
|
const appRoot = toPlatformPath(import_node_path2.default.join(state.file.opts.root, state.opts.root));
|
|
759
755
|
if (state.file.opts.root === appRoot) {
|
|
760
|
-
throw new Error(
|
|
756
|
+
throw new Error(
|
|
757
|
+
"Unistyles \u{1F984}: Root option can't resolve to project root as it will include node_modules folder. Please check https://www.unistyl.es/v3/other/babel-plugin#extra-configuration"
|
|
758
|
+
);
|
|
761
759
|
}
|
|
762
|
-
state.file.replaceWithUnistyles = REPLACE_WITH_UNISTYLES_PATHS.concat(
|
|
760
|
+
state.file.replaceWithUnistyles = REPLACE_WITH_UNISTYLES_PATHS.concat(
|
|
761
|
+
state.opts.autoProcessPaths ?? []
|
|
762
|
+
).map(toPlatformPath).some((path3) => state.filename?.includes(path3));
|
|
763
763
|
state.file.hasAnyUnistyle = false;
|
|
764
764
|
state.file.hasUnistylesImport = false;
|
|
765
765
|
state.file.addUnistylesRequire = false;
|
|
766
766
|
state.file.hasVariants = false;
|
|
767
767
|
state.file.styleSheetLocalName = "";
|
|
768
768
|
state.file.reactNativeCommonJSName = "";
|
|
769
|
-
state.file.tagNumber = 0;
|
|
770
769
|
state.reactNativeImports = {};
|
|
771
770
|
state.file.forceProcessing = state.filename?.includes(appRoot) ?? false;
|
|
772
771
|
path2.traverse({
|
|
@@ -822,7 +821,9 @@ function index_default() {
|
|
|
822
821
|
});
|
|
823
822
|
},
|
|
824
823
|
ImportDeclaration(path2, state) {
|
|
825
|
-
const exoticImport = REPLACE_WITH_UNISTYLES_EXOTIC_PATHS.concat(state.opts.autoRemapImports ?? []).find(
|
|
824
|
+
const exoticImport = REPLACE_WITH_UNISTYLES_EXOTIC_PATHS.concat(state.opts.autoRemapImports ?? []).find(
|
|
825
|
+
(exotic) => state.filename?.includes(exotic.path)
|
|
826
|
+
);
|
|
826
827
|
if (exoticImport) {
|
|
827
828
|
return handleExoticImport(path2, state, exoticImport);
|
|
828
829
|
}
|
|
@@ -894,7 +895,6 @@ function index_default() {
|
|
|
894
895
|
return;
|
|
895
896
|
}
|
|
896
897
|
state.file.hasAnyUnistyle = true;
|
|
897
|
-
addStyleSheetTag(path2, state);
|
|
898
898
|
const arg = t6.isAssignmentExpression(path2.node.arguments[0]) ? path2.node.arguments[0].right : path2.node.arguments[0];
|
|
899
899
|
if (t6.isObjectExpression(arg)) {
|
|
900
900
|
const detectedDependencies = getStylesDependenciesFromObject(path2);
|
|
@@ -902,7 +902,12 @@ function index_default() {
|
|
|
902
902
|
if (t6.isObjectExpression(arg)) {
|
|
903
903
|
arg.properties.forEach((property) => {
|
|
904
904
|
if (t6.isObjectProperty(property) && t6.isIdentifier(property.key) && Object.prototype.hasOwnProperty.call(detectedDependencies, property.key.name)) {
|
|
905
|
-
addDependencies(
|
|
905
|
+
addDependencies(
|
|
906
|
+
state,
|
|
907
|
+
property.key.name,
|
|
908
|
+
property,
|
|
909
|
+
detectedDependencies[property.key.name] ?? []
|
|
910
|
+
);
|
|
906
911
|
}
|
|
907
912
|
});
|
|
908
913
|
}
|
|
@@ -916,7 +921,12 @@ function index_default() {
|
|
|
916
921
|
if (t6.isObjectExpression(body)) {
|
|
917
922
|
body.properties.forEach((property) => {
|
|
918
923
|
if (t6.isObjectProperty(property) && t6.isIdentifier(property.key) && Object.prototype.hasOwnProperty.call(detectedDependencies, property.key.name)) {
|
|
919
|
-
addDependencies(
|
|
924
|
+
addDependencies(
|
|
925
|
+
state,
|
|
926
|
+
property.key.name,
|
|
927
|
+
property,
|
|
928
|
+
detectedDependencies[property.key.name] ?? []
|
|
929
|
+
);
|
|
920
930
|
}
|
|
921
931
|
});
|
|
922
932
|
}
|
package/repack-plugin/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {Compiler,LoaderContext,RspackPluginInstance } from '@rspack/core'
|
|
1
|
+
import type { Compiler, LoaderContext, RspackPluginInstance } from '@rspack/core'
|
|
2
2
|
import type { UnistylesPluginOptions } from 'react-native-unistyles/plugin'
|
|
3
3
|
|
|
4
4
|
export declare const BASE_REPACK_EXCLUDE_PATHS: Array<RegExp>
|
|
@@ -14,6 +14,6 @@ export declare class RepackUnistylePlugin implements RspackPluginInstance {
|
|
|
14
14
|
apply(compiler: Compiler): void
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
declare function unistylesLoader(this: LoaderContext<UnistylesLoaderOptions>, source: string): void
|
|
17
|
+
declare function unistylesLoader(this: LoaderContext<UnistylesLoaderOptions>, source: string): void
|
|
18
18
|
|
|
19
19
|
export default unistylesLoader
|