react-native-unistyles 3.5.3 → 3.7.0
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 +6 -8
- package/android/build.gradle +42 -0
- package/android/src/legacy/java/com/unistyles/NativePlatform+extraWindows.kt +16 -0
- package/android/src/main/cxx/NativeUnistylesModule.cpp +5 -11
- package/android/src/main/cxx/NativeUnistylesModule.h +0 -4
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +82 -39
- package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +73 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +2 -13
- package/android/src/rn86/java/com/unistyles/NativePlatform+extraWindows.kt +28 -0
- package/cxx/common/PerformanceTracing.h +85 -0
- package/cxx/converters/BackgroundImageConverter.cpp +198 -11
- package/cxx/converters/BackgroundImageConverter.h +1 -0
- package/cxx/converters/BackgroundLayerConverter.cpp +523 -0
- package/cxx/converters/BackgroundLayerConverter.h +14 -0
- package/cxx/converters/FontVariationSettingsConverter.cpp +104 -0
- package/cxx/converters/FontVariationSettingsConverter.h +17 -0
- package/cxx/core/HostUnistyle.cpp +6 -0
- package/cxx/core/UnistyleWrapper.h +16 -1
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +13 -0
- package/cxx/hybridObjects/HybridStyleSheet.cpp +11 -0
- package/cxx/hybridObjects/HybridStyleSheet.h +1 -0
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +10 -30
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -2
- package/cxx/parser/Parser.cpp +92 -5
- package/cxx/shadowTree/ShadowTreeDiagnostics.cpp +74 -0
- package/cxx/shadowTree/ShadowTreeManager.cpp +3 -0
- package/ios/NativePlatform+ios.swift +22 -11
- package/ios/NativePlatformListener+ios.swift +9 -0
- package/lib/commonjs/components/NamedTheme.js +4 -4
- package/lib/commonjs/components/NamedTheme.js.map +1 -1
- package/lib/commonjs/components/ScopedThemeContext.js +3 -1
- package/lib/commonjs/components/ScopedThemeContext.js.map +1 -1
- package/lib/commonjs/components/native/deep/ActivityIndicator.js +19 -0
- package/lib/commonjs/components/native/deep/ActivityIndicator.js.map +1 -0
- package/lib/commonjs/components/native/deep/Animated.js +19 -0
- package/lib/commonjs/components/native/deep/Animated.js.map +1 -0
- package/lib/commonjs/components/native/deep/FlatList.js +19 -0
- package/lib/commonjs/components/native/deep/FlatList.js.map +1 -0
- package/lib/commonjs/components/native/deep/Image.js +19 -0
- package/lib/commonjs/components/native/deep/Image.js.map +1 -0
- package/lib/commonjs/components/native/deep/ImageBackground.js +19 -0
- package/lib/commonjs/components/native/deep/ImageBackground.js.map +1 -0
- package/lib/commonjs/components/native/deep/KeyboardAvoidingView.js +19 -0
- package/lib/commonjs/components/native/deep/KeyboardAvoidingView.js.map +1 -0
- package/lib/commonjs/components/native/deep/Pressable.js +19 -0
- package/lib/commonjs/components/native/deep/Pressable.js.map +1 -0
- package/lib/commonjs/components/native/deep/RefreshControl.js +19 -0
- package/lib/commonjs/components/native/deep/RefreshControl.js.map +1 -0
- package/lib/commonjs/components/native/deep/SafeAreaView.js +19 -0
- package/lib/commonjs/components/native/deep/SafeAreaView.js.map +1 -0
- package/lib/commonjs/components/native/deep/ScrollView.js +19 -0
- package/lib/commonjs/components/native/deep/ScrollView.js.map +1 -0
- package/lib/commonjs/components/native/deep/SectionList.js +19 -0
- package/lib/commonjs/components/native/deep/SectionList.js.map +1 -0
- package/lib/commonjs/components/native/deep/Switch.js +19 -0
- package/lib/commonjs/components/native/deep/Switch.js.map +1 -0
- package/lib/commonjs/components/native/deep/Text.js +19 -0
- package/lib/commonjs/components/native/deep/Text.js.map +1 -0
- package/lib/commonjs/components/native/deep/TextInput.js +19 -0
- package/lib/commonjs/components/native/deep/TextInput.js.map +1 -0
- package/lib/commonjs/components/native/deep/TextNativeComponent.js +28 -0
- package/lib/commonjs/components/native/deep/TextNativeComponent.js.map +1 -0
- package/lib/commonjs/components/native/deep/TouchableHighlight.js +19 -0
- package/lib/commonjs/components/native/deep/TouchableHighlight.js.map +1 -0
- package/lib/commonjs/components/native/deep/TouchableOpacity.js +19 -0
- package/lib/commonjs/components/native/deep/TouchableOpacity.js.map +1 -0
- package/lib/commonjs/components/native/deep/View.js +19 -0
- package/lib/commonjs/components/native/deep/View.js.map +1 -0
- package/lib/commonjs/components/native/deep/ViewNativeComponent.js +26 -0
- package/lib/commonjs/components/native/deep/ViewNativeComponent.js.map +1 -0
- package/lib/commonjs/components/native/deep/VirtualizedList.js +19 -0
- package/lib/commonjs/components/native/deep/VirtualizedList.js.map +1 -0
- package/lib/commonjs/components/native/index.js +43 -0
- package/lib/commonjs/components/native/index.js.map +1 -0
- package/lib/commonjs/core/createUnistylesActivityIndicator.js +13 -3
- package/lib/commonjs/core/createUnistylesActivityIndicator.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js +6 -0
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js +26 -19
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/createUnistylesTouchableHighlight.js +6 -0
- package/lib/commonjs/core/createUnistylesTouchableHighlight.js.map +1 -1
- package/lib/commonjs/core/getClassname.js +15 -0
- package/lib/commonjs/core/getClassname.js.map +1 -1
- package/lib/commonjs/core/hasUnistyles.js +26 -0
- package/lib/commonjs/core/hasUnistyles.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +10 -7
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +22 -3
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/mocks.js +27 -3
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +69 -76
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/styleSource.js +65 -0
- package/lib/commonjs/specs/ShadowRegistry/styleSource.js.map +1 -0
- package/lib/commonjs/specs/ShadowRegistry/tracing.js +26 -0
- package/lib/commonjs/specs/ShadowRegistry/tracing.js.map +1 -0
- package/lib/commonjs/unifiber/src/adapters/reanimated.js +157 -0
- package/lib/commonjs/unifiber/src/adapters/reanimated.js.map +1 -0
- package/lib/commonjs/unifiber/src/adapters/registry.js +67 -0
- package/lib/commonjs/unifiber/src/adapters/registry.js.map +1 -0
- package/lib/commonjs/unifiber/src/diagnostics.js +59 -0
- package/lib/commonjs/unifiber/src/diagnostics.js.map +1 -0
- package/lib/commonjs/unifiber/src/fiber.js +199 -0
- package/lib/commonjs/unifiber/src/fiber.js.map +1 -0
- package/lib/commonjs/unifiber/src/host.js +214 -0
- package/lib/commonjs/unifiber/src/host.js.map +1 -0
- package/lib/commonjs/unifiber/src/index.js +38 -0
- package/lib/commonjs/unifiber/src/index.js.map +1 -0
- package/lib/commonjs/utils.js +52 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/convert/index.js +19 -1
- package/lib/commonjs/web/convert/index.js.map +1 -1
- package/lib/commonjs/web/convert/module.d.ts +3 -0
- package/lib/commonjs/web/convert/object/backgroundLayers.js +30 -0
- package/lib/commonjs/web/convert/object/backgroundLayers.js.map +1 -0
- package/lib/commonjs/web/convert/object/fontVariationSettings.js +12 -0
- package/lib/commonjs/web/convert/object/fontVariationSettings.js.map +1 -0
- package/lib/commonjs/web/convert/object/index.js +22 -0
- package/lib/commonjs/web/convert/object/index.js.map +1 -1
- package/lib/commonjs/web/convert/utils.js +7 -1
- package/lib/commonjs/web/convert/utils.js.map +1 -1
- package/lib/commonjs/web/registry.js +6 -4
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js +9 -6
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +9 -3
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/components/NamedTheme.js +4 -4
- package/lib/module/components/NamedTheme.js.map +1 -1
- package/lib/module/components/ScopedThemeContext.js +3 -1
- package/lib/module/components/ScopedThemeContext.js.map +1 -1
- package/lib/module/components/native/deep/ActivityIndicator.js +5 -0
- package/lib/module/components/native/deep/ActivityIndicator.js.map +1 -0
- package/lib/module/components/native/deep/Animated.js +5 -0
- package/lib/module/components/native/deep/Animated.js.map +1 -0
- package/lib/module/components/native/deep/FlatList.js +5 -0
- package/lib/module/components/native/deep/FlatList.js.map +1 -0
- package/lib/module/components/native/deep/Image.js +5 -0
- package/lib/module/components/native/deep/Image.js.map +1 -0
- package/lib/module/components/native/deep/ImageBackground.js +5 -0
- package/lib/module/components/native/deep/ImageBackground.js.map +1 -0
- package/lib/module/components/native/deep/KeyboardAvoidingView.js +5 -0
- package/lib/module/components/native/deep/KeyboardAvoidingView.js.map +1 -0
- package/lib/module/components/native/deep/Pressable.js +5 -0
- package/lib/module/components/native/deep/Pressable.js.map +1 -0
- package/lib/module/components/native/deep/RefreshControl.js +5 -0
- package/lib/module/components/native/deep/RefreshControl.js.map +1 -0
- package/lib/module/components/native/deep/SafeAreaView.js +5 -0
- package/lib/module/components/native/deep/SafeAreaView.js.map +1 -0
- package/lib/module/components/native/deep/ScrollView.js +5 -0
- package/lib/module/components/native/deep/ScrollView.js.map +1 -0
- package/lib/module/components/native/deep/SectionList.js +5 -0
- package/lib/module/components/native/deep/SectionList.js.map +1 -0
- package/lib/module/components/native/deep/Switch.js +5 -0
- package/lib/module/components/native/deep/Switch.js.map +1 -0
- package/lib/module/components/native/deep/Text.js +5 -0
- package/lib/module/components/native/deep/Text.js.map +1 -0
- package/lib/module/components/native/deep/TextInput.js +5 -0
- package/lib/module/components/native/deep/TextInput.js.map +1 -0
- package/lib/module/components/native/deep/TextNativeComponent.js +8 -0
- package/lib/module/components/native/deep/TextNativeComponent.js.map +1 -0
- package/lib/module/components/native/deep/TouchableHighlight.js +5 -0
- package/lib/module/components/native/deep/TouchableHighlight.js.map +1 -0
- package/lib/module/components/native/deep/TouchableOpacity.js +5 -0
- package/lib/module/components/native/deep/TouchableOpacity.js.map +1 -0
- package/lib/module/components/native/deep/View.js +5 -0
- package/lib/module/components/native/deep/View.js.map +1 -0
- package/lib/module/components/native/deep/ViewNativeComponent.js +8 -0
- package/lib/module/components/native/deep/ViewNativeComponent.js.map +1 -0
- package/lib/module/components/native/deep/VirtualizedList.js +5 -0
- package/lib/module/components/native/deep/VirtualizedList.js.map +1 -0
- package/lib/module/components/native/index.js +43 -0
- package/lib/module/components/native/index.js.map +1 -0
- package/lib/module/core/createUnistylesActivityIndicator.js +13 -3
- package/lib/module/core/createUnistylesActivityIndicator.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +6 -0
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js +26 -19
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/createUnistylesTouchableHighlight.js +6 -0
- package/lib/module/core/createUnistylesTouchableHighlight.js.map +1 -1
- package/lib/module/core/getClassname.js +16 -1
- package/lib/module/core/getClassname.js.map +1 -1
- package/lib/module/core/hasUnistyles.js +21 -0
- package/lib/module/core/hasUnistyles.js.map +1 -0
- package/lib/module/core/withUnistyles/withUnistyles.js +9 -6
- package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.native.js +24 -5
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/mocks.js +27 -3
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +69 -76
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/styleSource.js +60 -0
- package/lib/module/specs/ShadowRegistry/styleSource.js.map +1 -0
- package/lib/module/specs/ShadowRegistry/tracing.js +21 -0
- package/lib/module/specs/ShadowRegistry/tracing.js.map +1 -0
- package/lib/module/unifiber/src/adapters/reanimated.js +152 -0
- package/lib/module/unifiber/src/adapters/reanimated.js.map +1 -0
- package/lib/module/unifiber/src/adapters/registry.js +62 -0
- package/lib/module/unifiber/src/adapters/registry.js.map +1 -0
- package/lib/module/unifiber/src/diagnostics.js +52 -0
- package/lib/module/unifiber/src/diagnostics.js.map +1 -0
- package/lib/module/unifiber/src/fiber.js +183 -0
- package/lib/module/unifiber/src/fiber.js.map +1 -0
- package/lib/module/unifiber/src/host.js +191 -0
- package/lib/module/unifiber/src/host.js.map +1 -0
- package/lib/module/unifiber/src/index.js +33 -0
- package/lib/module/unifiber/src/index.js.map +1 -0
- package/lib/module/utils.js +50 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/convert/index.js +22 -3
- package/lib/module/web/convert/index.js.map +1 -1
- package/lib/module/web/convert/module.d.ts +3 -0
- package/lib/module/web/convert/object/backgroundLayers.js +25 -0
- package/lib/module/web/convert/object/backgroundLayers.js.map +1 -0
- package/lib/module/web/convert/object/fontVariationSettings.js +7 -0
- package/lib/module/web/convert/object/fontVariationSettings.js.map +1 -0
- package/lib/module/web/convert/object/index.js +2 -0
- package/lib/module/web/convert/object/index.js.map +1 -1
- package/lib/module/web/convert/utils.js +4 -0
- package/lib/module/web/convert/utils.js.map +1 -1
- package/lib/module/web/registry.js +6 -4
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js +9 -6
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +10 -4
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/typescript/src/components/ScopedThemeContext.d.ts +2 -1
- package/lib/typescript/src/components/ScopedThemeContext.d.ts.map +1 -1
- package/lib/typescript/src/components/native/deep/ActivityIndicator.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/ActivityIndicator.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/Animated.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/Animated.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/FlatList.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/FlatList.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/Image.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/Image.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/ImageBackground.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/ImageBackground.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/KeyboardAvoidingView.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/KeyboardAvoidingView.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/Pressable.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/Pressable.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/RefreshControl.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/RefreshControl.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/SafeAreaView.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/SafeAreaView.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/ScrollView.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/ScrollView.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/SectionList.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/SectionList.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/Switch.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/Switch.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/Text.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/Text.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/TextInput.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/TextInput.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/TextNativeComponent.d.ts +3 -0
- package/lib/typescript/src/components/native/deep/TextNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/TouchableHighlight.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/TouchableHighlight.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/TouchableOpacity.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/TouchableOpacity.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/View.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/View.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/ViewNativeComponent.d.ts +3 -0
- package/lib/typescript/src/components/native/deep/ViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/components/native/deep/VirtualizedList.d.ts +2 -0
- package/lib/typescript/src/components/native/deep/VirtualizedList.d.ts.map +1 -0
- package/lib/typescript/src/components/native/index.d.ts +4 -0
- package/lib/typescript/src/components/native/index.d.ts.map +1 -0
- package/lib/typescript/src/components/scopeChildren.d.ts +1 -1
- package/lib/typescript/src/core/createUnistylesActivityIndicator.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/createUnistylesTouchableHighlight.d.ts.map +1 -1
- package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
- package/lib/typescript/src/core/hasUnistyles.d.ts +2 -0
- package/lib/typescript/src/core/hasUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts +6 -3
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts +7 -4
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/styleSource.d.ts +11 -0
- package/lib/typescript/src/specs/ShadowRegistry/styleSource.d.ts.map +1 -0
- package/lib/typescript/src/specs/ShadowRegistry/tracing.d.ts +2 -0
- package/lib/typescript/src/specs/ShadowRegistry/tracing.d.ts.map +1 -0
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +4 -41
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
- package/lib/typescript/src/unifiber/src/adapters/reanimated.d.ts +17 -0
- package/lib/typescript/src/unifiber/src/adapters/reanimated.d.ts.map +1 -0
- package/lib/typescript/src/unifiber/src/adapters/registry.d.ts +23 -0
- package/lib/typescript/src/unifiber/src/adapters/registry.d.ts.map +1 -0
- package/lib/typescript/src/unifiber/src/diagnostics.d.ts +10 -0
- package/lib/typescript/src/unifiber/src/diagnostics.d.ts.map +1 -0
- package/lib/typescript/src/unifiber/src/fiber.d.ts +48 -0
- package/lib/typescript/src/unifiber/src/fiber.d.ts.map +1 -0
- package/lib/typescript/src/unifiber/src/host.d.ts +32 -0
- package/lib/typescript/src/unifiber/src/host.d.ts.map +1 -0
- package/lib/typescript/src/unifiber/src/index.d.ts +49 -0
- package/lib/typescript/src/unifiber/src/index.d.ts.map +1 -0
- package/lib/typescript/src/utils.d.ts +1 -0
- 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/backgroundLayers.d.ts +4 -0
- package/lib/typescript/src/web/convert/object/backgroundLayers.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/fontVariationSettings.d.ts +4 -0
- package/lib/typescript/src/web/convert/object/fontVariationSettings.d.ts.map +1 -0
- package/lib/typescript/src/web/convert/object/index.d.ts +2 -0
- package/lib/typescript/src/web/convert/object/index.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/utils.d.ts +2 -0
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +1 -0
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/metro/babel-transformer.js +1102 -0
- package/metro/index.d.ts +31 -0
- package/metro/index.js +170 -0
- package/package.json +50 -32
- package/plugin/index.d.ts +7 -0
- package/plugin/index.js +115 -33
- package/src/components/NamedTheme.tsx +5 -5
- package/src/components/ScopedThemeContext.ts +6 -2
- package/src/components/native/deep/ActivityIndicator.ts +2 -0
- package/src/components/native/deep/Animated.ts +2 -0
- package/src/components/native/deep/FlatList.ts +2 -0
- package/src/components/native/deep/Image.ts +2 -0
- package/src/components/native/deep/ImageBackground.ts +2 -0
- package/src/components/native/deep/KeyboardAvoidingView.ts +2 -0
- package/src/components/native/deep/Pressable.ts +2 -0
- package/src/components/native/deep/RefreshControl.ts +2 -0
- package/src/components/native/deep/SafeAreaView.ts +2 -0
- package/src/components/native/deep/ScrollView.ts +2 -0
- package/src/components/native/deep/SectionList.ts +2 -0
- package/src/components/native/deep/Switch.ts +2 -0
- package/src/components/native/deep/Text.ts +2 -0
- package/src/components/native/deep/TextInput.ts +2 -0
- package/src/components/native/deep/TextNativeComponent.ts +5 -0
- package/src/components/native/deep/TouchableHighlight.ts +2 -0
- package/src/components/native/deep/TouchableOpacity.ts +2 -0
- package/src/components/native/deep/View.ts +2 -0
- package/src/components/native/deep/ViewNativeComponent.ts +5 -0
- package/src/components/native/deep/VirtualizedList.ts +2 -0
- package/src/components/native/index.ts +41 -0
- package/src/core/createUnistylesActivityIndicator.tsx +11 -4
- package/src/core/createUnistylesElement.native.tsx +5 -0
- package/src/core/createUnistylesImageBackground.tsx +33 -25
- package/src/core/createUnistylesTouchableHighlight.tsx +5 -0
- package/src/core/getClassname.ts +10 -1
- package/src/core/hasUnistyles.ts +20 -0
- package/src/core/withUnistyles/withUnistyles.native.tsx +28 -6
- package/src/core/withUnistyles/withUnistyles.tsx +6 -6
- package/src/mocks.ts +14 -5
- package/src/specs/ShadowRegistry/index.ts +62 -103
- package/src/specs/ShadowRegistry/styleSource.ts +78 -0
- package/src/specs/ShadowRegistry/tracing.ts +23 -0
- package/src/specs/ShadowRegistry/types.ts +3 -43
- package/src/unifiber/LICENSE +21 -0
- package/src/unifiber/README.md +92 -0
- package/src/unifiber/src/adapters/reanimated.ts +204 -0
- package/src/unifiber/src/adapters/registry.ts +102 -0
- package/src/unifiber/src/diagnostics.ts +55 -0
- package/src/unifiber/src/fiber.ts +262 -0
- package/src/unifiber/src/host.ts +236 -0
- package/src/unifiber/src/index.ts +43 -0
- package/src/utils.ts +51 -0
- package/src/web/convert/index.ts +39 -3
- package/src/web/convert/object/backgroundLayers.ts +33 -0
- package/src/web/convert/object/fontVariationSettings.ts +7 -0
- package/src/web/convert/object/index.ts +2 -0
- package/src/web/convert/utils.ts +11 -0
- package/src/web/registry.ts +7 -8
- package/src/web/runtime.ts +7 -7
- package/src/web/utils/unistyle.ts +11 -4
- package/lib/commonjs/web/convert/module.d.js +0 -2
- package/lib/commonjs/web/convert/module.d.js.map +0 -1
- package/lib/module/web/convert/module.d.js +0 -2
- package/lib/module/web/convert/module.d.js.map +0 -1
- package/lib/typescript/src/__tests__/mocks.spec.d.ts +0 -2
- package/lib/typescript/src/__tests__/mocks.spec.d.ts.map +0 -1
- package/lib/typescript/src/__tests__/passForwardRef.spec.d.ts +0 -2
- package/lib/typescript/src/__tests__/passForwardRef.spec.d.ts.map +0 -1
- package/lib/typescript/src/__tests__/scoped-theme.spec.d.ts +0 -2
- package/lib/typescript/src/__tests__/scoped-theme.spec.d.ts.map +0 -1
- package/lib/typescript/src/__tests__/shadow-registry.spec.d.ts +0 -2
- package/lib/typescript/src/__tests__/shadow-registry.spec.d.ts.map +0 -1
- package/lib/typescript/src/__tests__/web-child-selector.spec.d.ts +0 -2
- package/lib/typescript/src/__tests__/web-child-selector.spec.d.ts.map +0 -1
- package/lib/typescript/src/__tests__/web-listener.spec.d.ts +0 -2
- package/lib/typescript/src/__tests__/web-listener.spec.d.ts.map +0 -1
- package/lib/typescript/src/__tests__/web-pointer-events.spec.d.ts +0 -2
- package/lib/typescript/src/__tests__/web-pointer-events.spec.d.ts.map +0 -1
- package/lib/typescript/src/__tests__/web-runtime.spec.d.ts +0 -2
- package/lib/typescript/src/__tests__/web-runtime.spec.d.ts.map +0 -1
- package/lib/typescript/src/__tests__/withUnistyles.spec.d.ts +0 -2
- package/lib/typescript/src/__tests__/withUnistyles.spec.d.ts.map +0 -1
package/metro/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type MetroConfig = {
|
|
2
|
+
transformer?: {
|
|
3
|
+
babelTransformerPath?: string
|
|
4
|
+
}
|
|
5
|
+
resolver?: {
|
|
6
|
+
resolveRequest?: ((...args: Array<any>) => any) | null
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface UnistylesMetroOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Logs the dependencies detected in every StyleSheet, same as the `debug` option of the Babel plugin
|
|
13
|
+
*/
|
|
14
|
+
debug?: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Experimental, replaces `react-native-unistyles/plugin` in babel.config.js
|
|
19
|
+
*
|
|
20
|
+
* Every `react-native` import (also from node_modules) resolves to Unistyles components
|
|
21
|
+
* and StyleSheets are processed by the Unistyles Babel plugin, run by Metro.
|
|
22
|
+
* There is nothing to configure: no `root`, `autoProcessImports`, `autoProcessPaths` or `autoRemapImports`.
|
|
23
|
+
*
|
|
24
|
+
* ```js
|
|
25
|
+
* const { getDefaultConfig } = require('expo/metro-config')
|
|
26
|
+
* const { withUnistylesConfig } = require('react-native-unistyles/metro')
|
|
27
|
+
*
|
|
28
|
+
* module.exports = withUnistylesConfig(getDefaultConfig(__dirname))
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const withUnistylesConfig: <T extends MetroConfig>(config: T, options?: UnistylesMetroOptions) => T
|
package/metro/index.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// metro/src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
withUnistylesConfig: () => withUnistylesConfig
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
37
|
+
var import_node_path2 = __toESM(require("node:path"));
|
|
38
|
+
|
|
39
|
+
// plugin/src/consts.ts
|
|
40
|
+
var REACT_NATIVE_COMPONENT_NAMES = [
|
|
41
|
+
"ActivityIndicator",
|
|
42
|
+
"View",
|
|
43
|
+
"Text",
|
|
44
|
+
"Image",
|
|
45
|
+
"ImageBackground",
|
|
46
|
+
"KeyboardAvoidingView",
|
|
47
|
+
"Pressable",
|
|
48
|
+
"ScrollView",
|
|
49
|
+
"FlatList",
|
|
50
|
+
"SectionList",
|
|
51
|
+
"Switch",
|
|
52
|
+
"TextInput",
|
|
53
|
+
"RefreshControl",
|
|
54
|
+
"TouchableHighlight",
|
|
55
|
+
"TouchableOpacity",
|
|
56
|
+
"VirtualizedList",
|
|
57
|
+
"Animated",
|
|
58
|
+
"SafeAreaView"
|
|
59
|
+
// Modal - there is no exposed native handle
|
|
60
|
+
// TouchableWithoutFeedback - can't accept a ref
|
|
61
|
+
];
|
|
62
|
+
var METRO_UPSTREAM_TRANSFORMER_ENV = "UNISTYLES_METRO_UPSTREAM_TRANSFORMER";
|
|
63
|
+
var METRO_OPTIONS_ENV = "UNISTYLES_METRO_OPTIONS";
|
|
64
|
+
|
|
65
|
+
// metro/src/resolver.ts
|
|
66
|
+
var import_node_path = __toESM(require("node:path"));
|
|
67
|
+
var DEEP_IMPORTS = [...REACT_NATIVE_COMPONENT_NAMES, "ViewNativeComponent", "TextNativeComponent"];
|
|
68
|
+
var PASSTHROUGH_PACKAGES = ["react-native", "@react-native", "react-native-web"];
|
|
69
|
+
var createResolveRequest = ({ unistylesRoot, upstream, path: path2 = import_node_path.default }) => {
|
|
70
|
+
const { sep } = path2;
|
|
71
|
+
const sourceDir = path2.join(unistylesRoot, "src");
|
|
72
|
+
const componentsDir = path2.join(sourceDir, "components", "native");
|
|
73
|
+
const componentsIndex = path2.join(componentsDir, "index.ts");
|
|
74
|
+
const builds = [path2.join(unistylesRoot, "lib", "module"), path2.join(unistylesRoot, "lib", "commonjs")];
|
|
75
|
+
const getSourcePath = (filePath) => {
|
|
76
|
+
const build = builds.find((buildDir) => filePath.startsWith(`${buildDir}${sep}`));
|
|
77
|
+
if (!build) {
|
|
78
|
+
return void 0;
|
|
79
|
+
}
|
|
80
|
+
const modulePath = filePath.slice(build.length + 1).replace(/\.js$/, "").replace(/\.(native|ios|android|web)$/, "");
|
|
81
|
+
return path2.join(sourceDir, modulePath);
|
|
82
|
+
};
|
|
83
|
+
const getPackageName = (filePath) => {
|
|
84
|
+
const parts = filePath.split(`${sep}node_modules${sep}`);
|
|
85
|
+
if (parts.length === 1) {
|
|
86
|
+
return void 0;
|
|
87
|
+
}
|
|
88
|
+
const segments = parts.at(-1).split(sep);
|
|
89
|
+
return segments[0]?.startsWith("@") ? `${segments[0]}${sep}${segments[1]}` : segments[0];
|
|
90
|
+
};
|
|
91
|
+
const shouldSwapFrom = (originModulePath) => {
|
|
92
|
+
if (originModulePath.startsWith(`${unistylesRoot}${sep}`)) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
const packageName = getPackageName(originModulePath);
|
|
96
|
+
return !PASSTHROUGH_PACKAGES.some((name) => packageName === name || packageName?.startsWith(`${name}${sep}`));
|
|
97
|
+
};
|
|
98
|
+
const getDeepImport = (filePath) => {
|
|
99
|
+
const segments = filePath.split(sep);
|
|
100
|
+
if (segments.at(-5) === "react-native-web" && segments.at(-4) === "dist" && segments.at(-3) === "exports") {
|
|
101
|
+
return segments.at(-2);
|
|
102
|
+
}
|
|
103
|
+
if (filePath.includes(`${sep}react-native${sep}Libraries${sep}`)) {
|
|
104
|
+
return segments.at(-1)?.split(".").at(0);
|
|
105
|
+
}
|
|
106
|
+
return void 0;
|
|
107
|
+
};
|
|
108
|
+
const getSwapTarget = (moduleName, filePath) => {
|
|
109
|
+
if (moduleName === "react-native" || filePath.endsWith(`${sep}react-native-web${sep}dist${sep}index.js`)) {
|
|
110
|
+
return componentsIndex;
|
|
111
|
+
}
|
|
112
|
+
const deepImport = getDeepImport(filePath);
|
|
113
|
+
return deepImport && DEEP_IMPORTS.includes(deepImport) ? path2.join(componentsDir, "deep", `${deepImport}.ts`) : void 0;
|
|
114
|
+
};
|
|
115
|
+
return (context, moduleName, platform) => {
|
|
116
|
+
const resolve = upstream ?? context.resolveRequest;
|
|
117
|
+
const resolution = resolve(context, moduleName, platform);
|
|
118
|
+
if (resolution.type !== "sourceFile" || !("filePath" in resolution)) {
|
|
119
|
+
return resolution;
|
|
120
|
+
}
|
|
121
|
+
const sourcePath = getSourcePath(resolution.filePath);
|
|
122
|
+
if (sourcePath) {
|
|
123
|
+
return resolve(context, sourcePath, platform);
|
|
124
|
+
}
|
|
125
|
+
if (!shouldSwapFrom(context.originModulePath)) {
|
|
126
|
+
return resolution;
|
|
127
|
+
}
|
|
128
|
+
const swapTarget = getSwapTarget(moduleName, resolution.filePath);
|
|
129
|
+
return swapTarget ? { type: "sourceFile", filePath: swapTarget } : resolution;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// metro/src/index.ts
|
|
134
|
+
var withUnistylesConfig = (config, options = {}) => {
|
|
135
|
+
const babelTransformerPath = import_node_path2.default.join(__dirname, "babel-transformer.js");
|
|
136
|
+
const upstreamBabelTransformerPath = config.transformer?.babelTransformerPath;
|
|
137
|
+
if (upstreamBabelTransformerPath === babelTransformerPath) {
|
|
138
|
+
throw new Error("Unistyles \u{1F984}: withUnistylesConfig was applied twice to the same Metro config");
|
|
139
|
+
}
|
|
140
|
+
if (!upstreamBabelTransformerPath) {
|
|
141
|
+
throw new Error(
|
|
142
|
+
"Unistyles \u{1F984}: Metro config has no babelTransformerPath, pass the config returned by getDefaultConfig to withUnistylesConfig"
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
const unistylesOptions = {
|
|
146
|
+
debug: options.debug ?? false
|
|
147
|
+
};
|
|
148
|
+
process.env[METRO_UPSTREAM_TRANSFORMER_ENV] = upstreamBabelTransformerPath;
|
|
149
|
+
process.env[METRO_OPTIONS_ENV] = JSON.stringify(unistylesOptions);
|
|
150
|
+
return {
|
|
151
|
+
...config,
|
|
152
|
+
transformer: {
|
|
153
|
+
...config.transformer,
|
|
154
|
+
babelTransformerPath,
|
|
155
|
+
// part of Metro's transform cache key
|
|
156
|
+
unistyles: unistylesOptions
|
|
157
|
+
},
|
|
158
|
+
resolver: {
|
|
159
|
+
...config.resolver,
|
|
160
|
+
resolveRequest: createResolveRequest({
|
|
161
|
+
unistylesRoot: import_node_fs.default.realpathSync(import_node_path2.default.join(__dirname, "..")),
|
|
162
|
+
upstream: config.resolver?.resolveRequest
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
168
|
+
0 && (module.exports = {
|
|
169
|
+
withUnistylesConfig
|
|
170
|
+
});
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-unistyles",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"test": "NODE_ENV=babel-test jest ./plugin ./src/__tests__",
|
|
6
|
+
"test": "NODE_ENV=babel-test jest ./plugin ./metro ./src/__tests__",
|
|
7
7
|
"test:coverage": "NODE_ENV=babel-test jest --passWithNoTests --coverage",
|
|
8
8
|
"tsc": "node_modules/typescript/bin/tsc --noEmit",
|
|
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",
|
|
9
|
+
"format": "oxfmt src plugin repack-plugin metro",
|
|
10
|
+
"lint": "oxlint src plugin repack-plugin metro",
|
|
11
|
+
"check": "oxfmt src plugin repack-plugin metro && oxlint --fix src plugin repack-plugin metro",
|
|
12
|
+
"check:ci": "oxfmt --check src plugin repack-plugin metro && oxlint src plugin repack-plugin metro",
|
|
13
|
+
"prepare": "bob build && bun run plugin:build && bun run repack:plugin:build && bun run metro:build",
|
|
14
14
|
"precommit": "concurrently 'bun run tsc' 'bun run lint' 'bun run check' 'bun run test' 'bun run circular:check'",
|
|
15
15
|
"plugin:build": "node plugin/esbuild.js",
|
|
16
16
|
"repack:plugin:build": "node repack-plugin/esbuild.js",
|
|
17
|
+
"metro:build": "node metro/esbuild.js",
|
|
17
18
|
"circular:check": "dpdm --no-warning --no-tree -T --exit-code circular:1 src/**/*.ts",
|
|
18
19
|
"components:build": "node build-components.js"
|
|
19
20
|
},
|
|
@@ -25,22 +26,22 @@
|
|
|
25
26
|
"exports": {
|
|
26
27
|
".": {
|
|
27
28
|
"types": "./lib/typescript/src/index.d.ts",
|
|
28
|
-
"import": "./lib/module/index.js",
|
|
29
29
|
"browser": "./lib/module/index.js",
|
|
30
30
|
"react-native": "./src/index.ts",
|
|
31
|
+
"import": "./lib/module/index.js",
|
|
31
32
|
"default": "./lib/commonjs/index.js"
|
|
32
33
|
},
|
|
33
34
|
"./mocks": {
|
|
34
35
|
"types": "./lib/typescript/src/mocks.d.ts",
|
|
35
|
-
"import": "./lib/module/mocks.js",
|
|
36
36
|
"browser": "./lib/module/mocks.js",
|
|
37
37
|
"react-native": "./src/mocks.ts",
|
|
38
|
+
"import": "./lib/module/mocks.js",
|
|
38
39
|
"default": "./lib/commonjs/mocks.js"
|
|
39
40
|
},
|
|
40
41
|
"./components/native/*": {
|
|
41
|
-
"import": "./lib/module/components/native/*",
|
|
42
42
|
"browser": "./lib/module/components/native/*",
|
|
43
43
|
"react-native": "./src/components/native/*",
|
|
44
|
+
"import": "./lib/module/components/native/*",
|
|
44
45
|
"default": "./lib/commonjs/components/native/*"
|
|
45
46
|
},
|
|
46
47
|
"./plugin": {
|
|
@@ -53,33 +54,37 @@
|
|
|
53
54
|
"types": "./repack-plugin/index.d.ts",
|
|
54
55
|
"default": "./repack-plugin/index.js"
|
|
55
56
|
},
|
|
57
|
+
"./metro": {
|
|
58
|
+
"types": "./metro/index.d.ts",
|
|
59
|
+
"default": "./metro/index.js"
|
|
60
|
+
},
|
|
56
61
|
"./package.json": "./package.json",
|
|
57
62
|
"./server": {
|
|
58
63
|
"types": "./lib/typescript/src/server/index.d.ts",
|
|
59
|
-
"import": "./lib/module/server/index.js",
|
|
60
64
|
"browser": "./lib/module/server/index.js",
|
|
61
65
|
"react-native": "./src/server/index.ts",
|
|
66
|
+
"import": "./lib/module/server/index.js",
|
|
62
67
|
"default": "./lib/commonjs/server/index.js"
|
|
63
68
|
},
|
|
64
69
|
"./web": {
|
|
65
70
|
"types": "./lib/typescript/src/web-only/index.d.ts",
|
|
66
|
-
"import": "./lib/module/web-only/index.js",
|
|
67
71
|
"browser": "./lib/module/web-only/index.js",
|
|
68
72
|
"react-native": "./src/web-only/index.ts",
|
|
73
|
+
"import": "./lib/module/web-only/index.js",
|
|
69
74
|
"default": "./lib/commonjs/web-only/index.js"
|
|
70
75
|
},
|
|
71
76
|
"./reanimated": {
|
|
72
77
|
"types": "./lib/typescript/src/reanimated/index.d.ts",
|
|
73
|
-
"import": "./lib/module/reanimated/index.js",
|
|
74
78
|
"browser": "./lib/module/reanimated/index.js",
|
|
75
79
|
"react-native": "./src/reanimated/index.ts",
|
|
80
|
+
"import": "./lib/module/reanimated/index.js",
|
|
76
81
|
"default": "./lib/commonjs/reanimated/index.js"
|
|
77
82
|
},
|
|
78
83
|
"./diagnostics": {
|
|
79
84
|
"types": "./lib/typescript/src/diagnostics/index.d.ts",
|
|
80
|
-
"import": "./lib/module/diagnostics/index.js",
|
|
81
85
|
"browser": "./lib/module/diagnostics/index.js",
|
|
82
86
|
"react-native": "./src/diagnostics/index.ts",
|
|
87
|
+
"import": "./lib/module/diagnostics/index.js",
|
|
83
88
|
"default": "./lib/commonjs/diagnostics/index.js"
|
|
84
89
|
}
|
|
85
90
|
},
|
|
@@ -100,6 +105,7 @@
|
|
|
100
105
|
"react-native.config.js",
|
|
101
106
|
"Unistyles.podspec",
|
|
102
107
|
"repack-plugin",
|
|
108
|
+
"metro",
|
|
103
109
|
"unistyles_get_rn_version.rb",
|
|
104
110
|
"!repack-plugin/__tests__",
|
|
105
111
|
"!repack-plugin/src",
|
|
@@ -107,6 +113,9 @@
|
|
|
107
113
|
"!plugin/__tests__",
|
|
108
114
|
"!plugin/src",
|
|
109
115
|
"!plugin/esbuild.js",
|
|
116
|
+
"!metro/__tests__",
|
|
117
|
+
"!metro/src",
|
|
118
|
+
"!metro/esbuild.js",
|
|
110
119
|
"!ios/build",
|
|
111
120
|
"!android/build",
|
|
112
121
|
"!android/gradle",
|
|
@@ -115,7 +124,13 @@
|
|
|
115
124
|
"!android/local.properties",
|
|
116
125
|
"!**/*.spec.ts",
|
|
117
126
|
"!**/*.spec.tsx",
|
|
118
|
-
"
|
|
127
|
+
"!**/__tests__",
|
|
128
|
+
"!**/.*",
|
|
129
|
+
"!src/unifiber/test",
|
|
130
|
+
"!src/unifiber/bench",
|
|
131
|
+
"!src/unifiber/package.json",
|
|
132
|
+
"!src/unifiber/tsconfig.json",
|
|
133
|
+
"!src/unifiber/bun.lock"
|
|
119
134
|
],
|
|
120
135
|
"keywords": [
|
|
121
136
|
"react-native",
|
|
@@ -139,31 +154,33 @@
|
|
|
139
154
|
"@babel/types": "7.29.8"
|
|
140
155
|
},
|
|
141
156
|
"devDependencies": {
|
|
142
|
-
"@callstack/repack": "5.4.
|
|
143
|
-
"@commitlint/config-conventional": "21.2.
|
|
144
|
-
"@react-native/normalize-colors": "0.
|
|
145
|
-
"@rspack/core": "2.2.
|
|
157
|
+
"@callstack/repack": "5.4.2",
|
|
158
|
+
"@commitlint/config-conventional": "21.2.4",
|
|
159
|
+
"@react-native/normalize-colors": "0.88.0",
|
|
160
|
+
"@rspack/core": "2.2.9",
|
|
146
161
|
"@types/jest": "30.0.0",
|
|
147
|
-
"@types/react": "19.
|
|
162
|
+
"@types/react": "19.3.0",
|
|
148
163
|
"babel-plugin-tester": "12.0.0",
|
|
149
|
-
"commitlint": "21.2.
|
|
150
|
-
"concurrently": "10.0.
|
|
164
|
+
"commitlint": "21.2.4",
|
|
165
|
+
"concurrently": "10.0.6",
|
|
151
166
|
"dpdm": "4.3.0",
|
|
152
167
|
"esbuild": "0.28.2",
|
|
153
168
|
"jest": "30.5.2",
|
|
169
|
+
"@babel/core": "7.29.7",
|
|
154
170
|
"@babel/plugin-syntax-jsx": "7.29.7",
|
|
155
|
-
"@babel/runtime": "7.29.
|
|
156
|
-
"@react-native/babel-preset": "0.
|
|
157
|
-
"@react-native/jest-preset": "0.
|
|
171
|
+
"@babel/runtime": "7.29.10",
|
|
172
|
+
"@react-native/babel-preset": "0.88.0",
|
|
173
|
+
"@react-native/jest-preset": "0.88.0",
|
|
174
|
+
"@react-native/metro-babel-transformer": "0.88.0",
|
|
158
175
|
"nitrogen": "0.37.1",
|
|
159
|
-
"oxfmt": "0.
|
|
160
|
-
"oxlint": "1.
|
|
161
|
-
"react": "19.
|
|
162
|
-
"react-native": "0.
|
|
163
|
-
"react-native-builder-bob": "0.43.
|
|
176
|
+
"oxfmt": "0.74.0",
|
|
177
|
+
"oxlint": "1.89.0",
|
|
178
|
+
"react": "19.3.0",
|
|
179
|
+
"react-native": "0.88.0",
|
|
180
|
+
"react-native-builder-bob": "0.43.2",
|
|
164
181
|
"react-native-nitro-modules": "0.37.1",
|
|
165
|
-
"react-native-reanimated": "4.7.
|
|
166
|
-
"react-native-web": "0.21.
|
|
182
|
+
"react-native-reanimated": "4.7.1",
|
|
183
|
+
"react-native-web": "0.21.4",
|
|
167
184
|
"typescript": "6.0.3"
|
|
168
185
|
},
|
|
169
186
|
"peerDependencies": {
|
|
@@ -209,6 +226,7 @@
|
|
|
209
226
|
"react-native-builder-bob": {
|
|
210
227
|
"source": "src",
|
|
211
228
|
"output": "lib",
|
|
229
|
+
"exclude": "{**/{__tests__,__fixtures__,__mocks__}/**,**/unifiber/{test,bench}/**,**/unifiber/*}",
|
|
212
230
|
"targets": [
|
|
213
231
|
"commonjs",
|
|
214
232
|
"module",
|
package/plugin/index.d.ts
CHANGED
|
@@ -44,6 +44,13 @@ export interface UnistylesPluginOptions {
|
|
|
44
44
|
*/
|
|
45
45
|
root: string
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Set by react-native-unistyles/metro, don't use it!
|
|
49
|
+
* Metro picks the files to process and swaps imports in its resolver,
|
|
50
|
+
* so `root`, `autoProcessImports`, `autoProcessPaths` and `autoRemapImports` are ignored
|
|
51
|
+
*/
|
|
52
|
+
isMetro?: boolean
|
|
53
|
+
|
|
47
54
|
/**
|
|
48
55
|
* Example: ['@my-org/styles']
|
|
49
56
|
* Enable this option if you want to process only files containing specific imports.
|
package/plugin/index.js
CHANGED
|
@@ -91,6 +91,7 @@ var NATIVE_COMPONENTS_PATHS = {
|
|
|
91
91
|
}
|
|
92
92
|
]
|
|
93
93
|
};
|
|
94
|
+
var METRO_UPSTREAM_TRANSFORMER_ENV = "UNISTYLES_METRO_UPSTREAM_TRANSFORMER";
|
|
94
95
|
|
|
95
96
|
// plugin/src/exotic.ts
|
|
96
97
|
var t2 = __toESM(require("@babel/types"));
|
|
@@ -139,6 +140,9 @@ function addUnistylesImport(path2, state) {
|
|
|
139
140
|
nodesToRemove.forEach((node) => path2.node.body.splice(path2.node.body.indexOf(node), 1));
|
|
140
141
|
}
|
|
141
142
|
function isInsideNodeModules(state) {
|
|
143
|
+
if (state.opts.isMetro) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
142
146
|
return state.file.opts.filename?.includes("node_modules") && !state.file.replaceWithUnistyles;
|
|
143
147
|
}
|
|
144
148
|
function addUnistylesRequire(path2, state) {
|
|
@@ -351,6 +355,47 @@ function getReturnStatementsFromBody(node, results = []) {
|
|
|
351
355
|
}
|
|
352
356
|
return results;
|
|
353
357
|
}
|
|
358
|
+
function countReturnStatements(node) {
|
|
359
|
+
if (t4.isFunction(node) || t4.isClass(node)) {
|
|
360
|
+
return 0;
|
|
361
|
+
}
|
|
362
|
+
if (t4.isReturnStatement(node)) {
|
|
363
|
+
return 1;
|
|
364
|
+
}
|
|
365
|
+
return (t4.VISITOR_KEYS[node.type] ?? []).reduce((count, key) => {
|
|
366
|
+
const child = node[key];
|
|
367
|
+
const children = (Array.isArray(child) ? child : [child]).filter(
|
|
368
|
+
(childNode) => t4.isNode(childNode)
|
|
369
|
+
);
|
|
370
|
+
return count + children.reduce((childCount, childNode) => childCount + countReturnStatements(childNode), 0);
|
|
371
|
+
}, 0);
|
|
372
|
+
}
|
|
373
|
+
function collectReturnedObjects(node, targets, unsupported) {
|
|
374
|
+
if (t4.isObjectExpression(node)) {
|
|
375
|
+
targets.push(node);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (t4.isConditionalExpression(node)) {
|
|
379
|
+
collectReturnedObjects(node.consequent, targets, unsupported);
|
|
380
|
+
collectReturnedObjects(node.alternate, targets, unsupported);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (t4.isLogicalExpression(node)) {
|
|
384
|
+
if (node.operator !== "&&") {
|
|
385
|
+
collectReturnedObjects(node.left, targets, unsupported);
|
|
386
|
+
}
|
|
387
|
+
collectReturnedObjects(node.right, targets, unsupported);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
if (t4.isTSAsExpression(node) || t4.isTSSatisfiesExpression(node) || t4.isParenthesizedExpression(node)) {
|
|
391
|
+
collectReturnedObjects(node.expression, targets, unsupported);
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
if (t4.isNullLiteral(node) || t4.isBooleanLiteral(node) || t4.isIdentifier(node) && node.name === "undefined") {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
unsupported.push(node);
|
|
398
|
+
}
|
|
354
399
|
function isUnistylesStyleSheet(path2, state) {
|
|
355
400
|
const { callee } = path2.node;
|
|
356
401
|
if (!t4.isMemberExpression(callee) || !t4.isIdentifier(callee.property)) {
|
|
@@ -665,42 +710,63 @@ function getStylesDependenciesFromFunction(funcPath) {
|
|
|
665
710
|
}, {});
|
|
666
711
|
}
|
|
667
712
|
function addDependencies(state, styleName, unistyle, detectedDependencies) {
|
|
668
|
-
const debugMessage = (deps) => {
|
|
713
|
+
const debugMessage = (deps, unsupportedReason) => {
|
|
669
714
|
if (state.opts.debug) {
|
|
670
715
|
const mappedDeps = deps.map(
|
|
671
716
|
(dep) => Object.keys(UnistyleDependency).find(
|
|
672
717
|
(key) => UnistyleDependency[key] === dep
|
|
673
718
|
)
|
|
674
719
|
).join(", ");
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
720
|
+
const style = `${state.filename?.replace(`${state.file.opts.root}/`, "")}: styles.${styleName}`;
|
|
721
|
+
if (unsupportedReason) {
|
|
722
|
+
console.warn(
|
|
723
|
+
`Unistyles \u{1F984}: ${style}: detected [${mappedDeps}], but ${unsupportedReason}. Return an object literal, or a ternary/logical expression of object literals.`
|
|
724
|
+
);
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
console.log(`${style}: [${mappedDeps}]`);
|
|
678
728
|
}
|
|
679
729
|
};
|
|
680
730
|
const styleDependencies = detectedDependencies.map(toUnistylesDependency);
|
|
681
731
|
if (styleDependencies.length > 0) {
|
|
682
732
|
const uniqueDependencies = Array.from(new Set(styleDependencies));
|
|
683
|
-
|
|
684
|
-
|
|
733
|
+
const targets = [];
|
|
734
|
+
const unsupported = [];
|
|
735
|
+
let unsupportedReturns = 0;
|
|
685
736
|
if (t4.isArrowFunctionExpression(unistyle.value) || t4.isFunctionExpression(unistyle.value)) {
|
|
686
|
-
if (t4.isObjectExpression(unistyle.value.body)) {
|
|
687
|
-
targets.push(unistyle.value.body);
|
|
688
|
-
}
|
|
689
737
|
if (t4.isBlockStatement(unistyle.value.body)) {
|
|
690
|
-
|
|
738
|
+
const returnStatements = getReturnStatementsFromBody(unistyle.value.body);
|
|
739
|
+
unsupportedReturns = countReturnStatements(unistyle.value.body) - returnStatements.length;
|
|
740
|
+
returnStatements.forEach((node) => {
|
|
691
741
|
if (t4.isIdentifier(node.argument)) {
|
|
692
742
|
node.argument = t4.objectExpression([t4.spreadElement(node.argument)]);
|
|
693
743
|
}
|
|
694
|
-
|
|
695
|
-
|
|
744
|
+
if (node.argument) {
|
|
745
|
+
collectReturnedObjects(node.argument, targets, unsupported);
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
} else {
|
|
749
|
+
collectReturnedObjects(unistyle.value.body, targets, unsupported);
|
|
696
750
|
}
|
|
697
|
-
}
|
|
698
|
-
if (t4.isObjectExpression(unistyle.value)) {
|
|
699
|
-
targets.push(unistyle.value);
|
|
700
|
-
}
|
|
701
|
-
if (t4.isMemberExpression(unistyle.value)) {
|
|
751
|
+
} else if (t4.isMemberExpression(unistyle.value)) {
|
|
702
752
|
unistyle.value = t4.objectExpression([t4.spreadElement(unistyle.value)]);
|
|
703
753
|
targets.push(unistyle.value);
|
|
754
|
+
} else {
|
|
755
|
+
collectReturnedObjects(unistyle.value, targets, unsupported);
|
|
756
|
+
}
|
|
757
|
+
if (unsupported.length > 0 || unsupportedReturns > 0) {
|
|
758
|
+
const reasons = unsupported.map((node) => `${node.type}${node.loc ? ` (line ${node.loc.start.line})` : ""}`).concat(
|
|
759
|
+
unsupportedReturns > 0 ? `${unsupportedReturns} return statement(s) inside switch, loop or try blocks` : []
|
|
760
|
+
);
|
|
761
|
+
const consequence = targets.length > 0 ? "the style may not update when these dependencies change, eg. when one of these values is returned first" : "the style won't update when these dependencies change";
|
|
762
|
+
debugMessage(uniqueDependencies, `they can't be attached to: ${reasons.join(", ")}, so ${consequence}`);
|
|
763
|
+
} else if (targets.length === 0) {
|
|
764
|
+
debugMessage(
|
|
765
|
+
uniqueDependencies,
|
|
766
|
+
"no returned object was found to attach them to, so the style won't update when these dependencies change"
|
|
767
|
+
);
|
|
768
|
+
} else {
|
|
769
|
+
debugMessage(uniqueDependencies);
|
|
704
770
|
}
|
|
705
771
|
if (targets.length > 0) {
|
|
706
772
|
targets.forEach((target) => {
|
|
@@ -719,6 +785,7 @@ function addDependencies(state, styleName, unistyle, detectedDependencies) {
|
|
|
719
785
|
|
|
720
786
|
// plugin/src/variants.ts
|
|
721
787
|
var t5 = __toESM(require("@babel/types"));
|
|
788
|
+
var scopedVariants = /* @__PURE__ */ new WeakMap();
|
|
722
789
|
function extractVariants(path2, state) {
|
|
723
790
|
const maybeVariants = path2.node.body.filter(
|
|
724
791
|
(node2) => t5.isExpressionStatement(node2) && t5.isCallExpression(node2.expression) && t5.isMemberExpression(node2.expression.callee)
|
|
@@ -745,22 +812,29 @@ function extractVariants(path2, state) {
|
|
|
745
812
|
return;
|
|
746
813
|
}
|
|
747
814
|
const calleeName = callee.object.name;
|
|
748
|
-
const
|
|
749
|
-
const
|
|
750
|
-
|
|
751
|
-
]);
|
|
815
|
+
const binding = path2.scope.getBinding(calleeName);
|
|
816
|
+
const existingShadowName = binding && t5.isVariableDeclarator(binding.path.node) ? scopedVariants.get(binding.path.node) : void 0;
|
|
817
|
+
const shadowName = existingShadowName ?? path2.scope.generateUidIdentifier(calleeName).name;
|
|
752
818
|
const newCallExpression = t5.callExpression(
|
|
753
|
-
t5.memberExpression(t5.identifier(
|
|
819
|
+
t5.memberExpression(t5.identifier(shadowName), t5.identifier("useVariants")),
|
|
754
820
|
node.arguments
|
|
755
821
|
);
|
|
756
|
-
const
|
|
757
|
-
|
|
758
|
-
|
|
822
|
+
const finalDeclarator = t5.variableDeclarator(t5.identifier(calleeName), newCallExpression);
|
|
823
|
+
const finalDeclaration = t5.variableDeclaration("const", [finalDeclarator]);
|
|
824
|
+
scopedVariants.set(finalDeclarator, shadowName);
|
|
759
825
|
const pathIndex = path2.node.body.findIndex((bodyPath) => bodyPath === targetVariant);
|
|
760
826
|
const rest = path2.node.body.slice(pathIndex + 1);
|
|
761
827
|
const statement = t5.blockStatement([finalDeclaration, ...rest]);
|
|
762
|
-
path2.node.body = [...path2.node.body.slice(0, pathIndex), shadowDeclaration, statement];
|
|
763
828
|
state.file.hasVariants = true;
|
|
829
|
+
if (existingShadowName) {
|
|
830
|
+
path2.node.body = [...path2.node.body.slice(0, pathIndex), statement];
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
const shadowDeclaration = t5.variableDeclaration("const", [
|
|
834
|
+
t5.variableDeclarator(t5.identifier(shadowName), t5.identifier(calleeName))
|
|
835
|
+
]);
|
|
836
|
+
path2.node.body = [...path2.node.body.slice(0, pathIndex), shadowDeclaration, statement];
|
|
837
|
+
path2.scope.registerDeclaration(path2.get(`body.${pathIndex}`));
|
|
764
838
|
}
|
|
765
839
|
|
|
766
840
|
// plugin/src/index.ts
|
|
@@ -776,13 +850,18 @@ function index_default() {
|
|
|
776
850
|
visitor: {
|
|
777
851
|
Program: {
|
|
778
852
|
enter(path2, state) {
|
|
779
|
-
if (!state.opts.
|
|
853
|
+
if (!state.opts.isMetro && process.env[METRO_UPSTREAM_TRANSFORMER_ENV]) {
|
|
854
|
+
throw new Error(
|
|
855
|
+
"Unistyles \u{1F984}: react-native-unistyles/metro is enabled in metro.config.js, remove react-native-unistyles/plugin from babel.config.js"
|
|
856
|
+
);
|
|
857
|
+
}
|
|
858
|
+
if (!state.opts.root && !state.opts.isMetro) {
|
|
780
859
|
throw new Error(
|
|
781
860
|
"Unistyles \u{1F984}: Babel plugin requires `root` option to be set. Please check https://www.unistyl.es/v3/other/babel-plugin#extra-configuration"
|
|
782
861
|
);
|
|
783
862
|
}
|
|
784
|
-
const appRoot = toPlatformPath(import_node_path2.default.join(state.file.opts.root, state.opts.root));
|
|
785
|
-
if (state.file.opts.root === appRoot) {
|
|
863
|
+
const appRoot = toPlatformPath(import_node_path2.default.join(state.file.opts.root, state.opts.root ?? ""));
|
|
864
|
+
if (!state.opts.isMetro && state.file.opts.root === appRoot) {
|
|
786
865
|
throw new Error(
|
|
787
866
|
"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"
|
|
788
867
|
);
|
|
@@ -797,7 +876,7 @@ function index_default() {
|
|
|
797
876
|
state.file.styleSheetLocalName = "";
|
|
798
877
|
state.file.reactNativeCommonJSName = "";
|
|
799
878
|
state.reactNativeImports = {};
|
|
800
|
-
state.file.forceProcessing = state.filename?.includes(appRoot) ?? false;
|
|
879
|
+
state.file.forceProcessing = state.opts.isMetro || (state.filename?.includes(appRoot) ?? false);
|
|
801
880
|
path2.traverse({
|
|
802
881
|
BlockStatement(blockPath) {
|
|
803
882
|
if (isInsideNodeModules(state)) {
|
|
@@ -808,7 +887,7 @@ function index_default() {
|
|
|
808
887
|
});
|
|
809
888
|
},
|
|
810
889
|
exit(path2, state) {
|
|
811
|
-
if (isInsideNodeModules(state)) {
|
|
890
|
+
if (state.opts.isMetro || isInsideNodeModules(state)) {
|
|
812
891
|
return;
|
|
813
892
|
}
|
|
814
893
|
if (state.file.addUnistylesRequire) {
|
|
@@ -851,7 +930,7 @@ function index_default() {
|
|
|
851
930
|
});
|
|
852
931
|
},
|
|
853
932
|
ImportDeclaration(path2, state) {
|
|
854
|
-
const exoticImport = REPLACE_WITH_UNISTYLES_EXOTIC_PATHS.concat(state.opts.autoRemapImports ?? []).find(
|
|
933
|
+
const exoticImport = state.opts.isMetro ? void 0 : REPLACE_WITH_UNISTYLES_EXOTIC_PATHS.concat(state.opts.autoRemapImports ?? []).find(
|
|
855
934
|
(exotic) => state.filename?.includes(exotic.path)
|
|
856
935
|
);
|
|
857
936
|
if (exoticImport) {
|
|
@@ -869,6 +948,9 @@ function index_default() {
|
|
|
869
948
|
}
|
|
870
949
|
});
|
|
871
950
|
}
|
|
951
|
+
if (state.opts.isMetro) {
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
872
954
|
if (importSource === "react-native") {
|
|
873
955
|
path2.node.specifiers.forEach((specifier) => {
|
|
874
956
|
if (t6.isImportSpecifier(specifier) && t6.isIdentifier(specifier.imported) && REACT_NATIVE_COMPONENT_NAMES.includes(specifier.imported.name)) {
|
|
@@ -892,7 +974,7 @@ function index_default() {
|
|
|
892
974
|
}
|
|
893
975
|
},
|
|
894
976
|
MemberExpression(path2, state) {
|
|
895
|
-
if (isInsideNodeModules(state)) {
|
|
977
|
+
if (state.opts.isMetro || isInsideNodeModules(state)) {
|
|
896
978
|
return;
|
|
897
979
|
}
|
|
898
980
|
if (!state.file.reactNativeCommonJSName || !t6.isIdentifier(path2.node.object)) {
|