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
|
@@ -17,6 +17,11 @@ interface NamedThemeProps extends PropsWithChildren {
|
|
|
17
17
|
export const NamedTheme: React.FunctionComponent<NamedThemeProps> = ({ name, children, previousScopedTheme }) => {
|
|
18
18
|
const scope = useMemo(() => ({ name }), [name])
|
|
19
19
|
|
|
20
|
+
useLayoutEffect(() => {
|
|
21
|
+
// this will affect only scoped styles as other styles are not yet mounted
|
|
22
|
+
UnistylesShadowRegistry.flush()
|
|
23
|
+
})
|
|
24
|
+
|
|
20
25
|
const mappedChildren = [
|
|
21
26
|
<ApplyScopedTheme key="apply" name={name} />,
|
|
22
27
|
<ScopedThemeContext.Provider key="scope" value={scope}>
|
|
@@ -25,10 +30,5 @@ export const NamedTheme: React.FunctionComponent<NamedThemeProps> = ({ name, chi
|
|
|
25
30
|
<ApplyScopedTheme key="dispose" name={previousScopedTheme as keyof UnistylesThemes | undefined} />,
|
|
26
31
|
]
|
|
27
32
|
|
|
28
|
-
useLayoutEffect(() => {
|
|
29
|
-
// this will affect only scoped styles as other styles are not yet mounted
|
|
30
|
-
UnistylesShadowRegistry.flush()
|
|
31
|
-
})
|
|
32
|
-
|
|
33
33
|
return <React.Fragment>{mappedChildren}</React.Fragment>
|
|
34
34
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext } from 'react'
|
|
1
|
+
import { type Context, createContext } from 'react'
|
|
2
2
|
|
|
3
3
|
import type { UnistylesThemes } from '../global'
|
|
4
4
|
|
|
@@ -6,4 +6,8 @@ export type Scope = {
|
|
|
6
6
|
name: keyof UnistylesThemes | undefined
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// React Server Components load a React build without createContext (or useContext). The Next.js App Router
|
|
10
|
+
// setup imports Unistyles from the root layout, a server component, and nothing can read this context there.
|
|
11
|
+
export const ScopedThemeContext = (
|
|
12
|
+
typeof createContext === 'function' ? createContext<Scope | null>(null) : null
|
|
13
|
+
) as Context<Scope | null>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// react-native-unistyles/metro resolves direct imports of react-native/Libraries/Text/TextNativeComponent here,
|
|
2
|
+
// its other exports (eg. NativeVirtualText) stay untouched
|
|
3
|
+
// @ts-ignore deep imports are typed only by some React Native versions
|
|
4
|
+
export * from 'react-native/Libraries/Text/TextNativeComponent'
|
|
5
|
+
export { NativeText } from '../NativeText'
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// react-native-unistyles/metro resolves direct imports of react-native/Libraries/Components/View/ViewNativeComponent here,
|
|
2
|
+
// its other exports stay untouched
|
|
3
|
+
// @ts-ignore deep imports are typed only by some React Native versions
|
|
4
|
+
export * from 'react-native/Libraries/Components/View/ViewNativeComponent'
|
|
5
|
+
export { NativeView as default } from '../NativeView'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// react-native-unistyles/metro resolves every `react-native` import (react-native-web on web) to this module,
|
|
2
|
+
// so it exposes every export of react-native and swaps the components Unistyles can update.
|
|
3
|
+
// Imports from this folder are Unistyles' own, they reach the real react-native
|
|
4
|
+
const ReactNative: Record<string, unknown> = require('react-native')
|
|
5
|
+
|
|
6
|
+
// lazy, like react-native's own exports
|
|
7
|
+
const UNISTYLES_COMPONENTS: Record<string, () => unknown> = {
|
|
8
|
+
ActivityIndicator: () => require('./ActivityIndicator').ActivityIndicator,
|
|
9
|
+
Animated: () => require('./Animated').Animated,
|
|
10
|
+
FlatList: () => require('./FlatList').FlatList,
|
|
11
|
+
Image: () => require('./Image').Image,
|
|
12
|
+
ImageBackground: () => require('./ImageBackground').ImageBackground,
|
|
13
|
+
KeyboardAvoidingView: () => require('./KeyboardAvoidingView').KeyboardAvoidingView,
|
|
14
|
+
Pressable: () => require('./Pressable').Pressable,
|
|
15
|
+
RefreshControl: () => require('./RefreshControl').RefreshControl,
|
|
16
|
+
SafeAreaView: () => require('./SafeAreaView').SafeAreaView,
|
|
17
|
+
ScrollView: () => require('./ScrollView').ScrollView,
|
|
18
|
+
SectionList: () => require('./SectionList').SectionList,
|
|
19
|
+
Switch: () => require('./Switch').Switch,
|
|
20
|
+
Text: () => require('./Text').Text,
|
|
21
|
+
TextInput: () => require('./TextInput').TextInput,
|
|
22
|
+
TouchableHighlight: () => require('./TouchableHighlight').TouchableHighlight,
|
|
23
|
+
TouchableOpacity: () => require('./TouchableOpacity').TouchableOpacity,
|
|
24
|
+
View: () => require('./View').View,
|
|
25
|
+
VirtualizedList: () => require('./VirtualizedList').VirtualizedList,
|
|
26
|
+
unstable_NativeText: () => require('./NativeText').NativeText,
|
|
27
|
+
unstable_NativeView: () => require('./NativeView').NativeView,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Object.keys doesn't call react-native's getters. Unistyles components are added even if missing,
|
|
31
|
+
// react-native-web and React Native before 0.83 don't export unstable_NativeView / unstable_NativeText
|
|
32
|
+
const exportNames = new Set(Object.keys(ReactNative).concat(Object.keys(UNISTYLES_COMPONENTS)))
|
|
33
|
+
|
|
34
|
+
exportNames.forEach((name) => {
|
|
35
|
+
// CommonJS without the __esModule flag, like react-native, so a default import still gets every export
|
|
36
|
+
// @ts-ignore module is provided by Metro
|
|
37
|
+
Object.defineProperty(module.exports, name, {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: UNISTYLES_COMPONENTS[name] ?? (() => ReactNative[name]),
|
|
40
|
+
})
|
|
41
|
+
})
|
|
@@ -2,18 +2,21 @@ import type { ActivityIndicator } from 'react-native'
|
|
|
2
2
|
|
|
3
3
|
import React, { useContext } from 'react'
|
|
4
4
|
|
|
5
|
-
import { isAndroid } from '../common'
|
|
6
5
|
import { ScopedThemeContext } from '../components/ScopedThemeContext'
|
|
7
6
|
import { UnistylesShadowRegistry } from '../specs'
|
|
7
|
+
import { Fiber } from '../unifiber/src'
|
|
8
8
|
import { copyComponentProperties } from '../utils'
|
|
9
|
+
import { hasUnistyles } from './hasUnistyles'
|
|
9
10
|
import { passForwardedRef } from './passForwardRef'
|
|
10
11
|
import { maybeWarnAboutMultipleUnistyles } from './warn'
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
-
|
|
13
|
+
const { getHostFor, getParentHost } = Fiber
|
|
14
|
+
|
|
15
|
+
const getWrapperHandle = (ref: unknown) => {
|
|
16
|
+
const spinner = getHostFor(ref)
|
|
14
17
|
|
|
15
18
|
return {
|
|
16
|
-
__internalInstanceHandle:
|
|
19
|
+
__internalInstanceHandle: spinner && getParentHost(spinner),
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
|
|
@@ -21,6 +24,10 @@ export const createUnistylesActivityIndicator = (Component: typeof ActivityIndic
|
|
|
21
24
|
const UnistylesActivityIndicator = (props: any) => {
|
|
22
25
|
const scope = useContext(ScopedThemeContext)
|
|
23
26
|
|
|
27
|
+
if (!hasUnistyles(props.style)) {
|
|
28
|
+
return <Component {...props} />
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
return (
|
|
25
32
|
<Component
|
|
26
33
|
{...props}
|
|
@@ -5,6 +5,7 @@ import React, { useContext, useRef } from 'react'
|
|
|
5
5
|
import { ScopedThemeContext } from '../components/ScopedThemeContext'
|
|
6
6
|
import { UnistylesShadowRegistry } from '../specs'
|
|
7
7
|
import { copyComponentProperties } from '../utils'
|
|
8
|
+
import { hasUnistyles } from './hasUnistyles'
|
|
8
9
|
import { passForwardedRef } from './passForwardRef'
|
|
9
10
|
import { maybeWarnAboutMultipleUnistyles } from './warn'
|
|
10
11
|
|
|
@@ -13,6 +14,10 @@ export const createUnistylesElement = (Component: any) => {
|
|
|
13
14
|
const scrollViewRef = useRef<ScrollView>(null)
|
|
14
15
|
const scope = useContext(ScopedThemeContext)
|
|
15
16
|
|
|
17
|
+
if (!hasUnistyles(props.style)) {
|
|
18
|
+
return <Component {...props} />
|
|
19
|
+
}
|
|
20
|
+
|
|
16
21
|
return (
|
|
17
22
|
<Component
|
|
18
23
|
{...props}
|
|
@@ -5,11 +5,16 @@ import React, { useContext } from 'react'
|
|
|
5
5
|
import { ScopedThemeContext } from '../components/ScopedThemeContext'
|
|
6
6
|
import { UnistylesShadowRegistry } from '../specs'
|
|
7
7
|
import { copyComponentProperties } from '../utils'
|
|
8
|
+
import { hasUnistyles } from './hasUnistyles'
|
|
8
9
|
import { passForwardedRef } from './passForwardRef'
|
|
9
10
|
import { maybeWarnAboutMultipleUnistyles } from './warn'
|
|
10
11
|
|
|
11
12
|
export const createUnistylesImageBackground = (Component: typeof ImageBackground) => {
|
|
12
|
-
const UnistylesImageBackground =
|
|
13
|
+
const UnistylesImageBackground = ({
|
|
14
|
+
ref,
|
|
15
|
+
...props
|
|
16
|
+
}: ImageBackgroundProps & { ref?: React.ForwardedRef<ImageBackground> }) => {
|
|
17
|
+
const forwardedRef: React.ForwardedRef<ImageBackground> = ref ?? null
|
|
13
18
|
const scope = useContext(ScopedThemeContext)
|
|
14
19
|
|
|
15
20
|
// @ts-expect-error we don't know the type of the component
|
|
@@ -17,35 +22,38 @@ export const createUnistylesImageBackground = (Component: typeof ImageBackground
|
|
|
17
22
|
// @ts-ignore we don't know the type of the component
|
|
18
23
|
maybeWarnAboutMultipleUnistyles(props.imageStyle, 'ImageBackground')
|
|
19
24
|
|
|
25
|
+
const linkRef = (ref: ImageBackground | null) => {
|
|
26
|
+
return passForwardedRef(
|
|
27
|
+
ref,
|
|
28
|
+
forwardedRef,
|
|
29
|
+
() => {
|
|
30
|
+
// @ts-expect-error - this is hidden from TS
|
|
31
|
+
UnistylesShadowRegistry.add(ref, props.style, scope)
|
|
32
|
+
},
|
|
33
|
+
() => {
|
|
34
|
+
// @ts-expect-error - this is hidden from TS
|
|
35
|
+
UnistylesShadowRegistry.remove(ref)
|
|
36
|
+
},
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
const linkImageRef = (ref: unknown) => {
|
|
40
|
+
// @ts-expect-error web types are not compatible with RN styles
|
|
41
|
+
UnistylesShadowRegistry.add(ref, props.imageStyle, scope)
|
|
42
|
+
|
|
43
|
+
return () => {
|
|
44
|
+
// @ts-ignore this is hidden from TS
|
|
45
|
+
UnistylesShadowRegistry.remove(ref)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
20
49
|
return (
|
|
21
50
|
<Component
|
|
22
51
|
{...props}
|
|
23
|
-
ref={(
|
|
24
|
-
|
|
25
|
-
ref,
|
|
26
|
-
forwardedRef,
|
|
27
|
-
() => {
|
|
28
|
-
// @ts-expect-error - this is hidden from TS
|
|
29
|
-
UnistylesShadowRegistry.add(ref, props.style, scope)
|
|
30
|
-
},
|
|
31
|
-
() => {
|
|
32
|
-
// @ts-expect-error - this is hidden from TS
|
|
33
|
-
UnistylesShadowRegistry.remove(ref)
|
|
34
|
-
},
|
|
35
|
-
)
|
|
36
|
-
}}
|
|
37
|
-
imageRef={(ref) => {
|
|
38
|
-
// @ts-expect-error web types are not compatible with RN styles
|
|
39
|
-
UnistylesShadowRegistry.add(ref, props.imageStyle, scope)
|
|
40
|
-
|
|
41
|
-
return () => {
|
|
42
|
-
// @ts-ignore this is hidden from TS
|
|
43
|
-
UnistylesShadowRegistry.remove(ref)
|
|
44
|
-
}
|
|
45
|
-
}}
|
|
52
|
+
ref={hasUnistyles(props.style) ? linkRef : forwardedRef}
|
|
53
|
+
imageRef={hasUnistyles(props.imageStyle) ? linkImageRef : props.imageRef}
|
|
46
54
|
/>
|
|
47
55
|
)
|
|
48
|
-
}
|
|
56
|
+
}
|
|
49
57
|
|
|
50
58
|
return copyComponentProperties(Component, UnistylesImageBackground)
|
|
51
59
|
}
|
|
@@ -5,6 +5,7 @@ import React, { useCallback, useContext, useLayoutEffect, useRef, useState } fro
|
|
|
5
5
|
import { ScopedThemeContext } from '../components/ScopedThemeContext'
|
|
6
6
|
import { UnistylesShadowRegistry } from '../specs'
|
|
7
7
|
import { copyComponentProperties } from '../utils'
|
|
8
|
+
import { hasUnistyles } from './hasUnistyles'
|
|
8
9
|
import { passForwardedRef } from './passForwardRef'
|
|
9
10
|
import { maybeWarnAboutMultipleUnistyles } from './warn'
|
|
10
11
|
|
|
@@ -49,6 +50,10 @@ export const createUnistylesTouchableHighlight = (Component: typeof TouchableHig
|
|
|
49
50
|
[props, scope],
|
|
50
51
|
)
|
|
51
52
|
|
|
53
|
+
if (!hasUnistyles(props.style)) {
|
|
54
|
+
return <Component {...props} />
|
|
55
|
+
}
|
|
56
|
+
|
|
52
57
|
return (
|
|
53
58
|
<Component
|
|
54
59
|
{...props}
|
package/src/core/getClassname.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { UnistylesValues } from '../types'
|
|
2
2
|
|
|
3
3
|
import * as unistyles from '../web/services'
|
|
4
|
-
import { checkForAnimated } from '../web/utils'
|
|
4
|
+
import { checkForAnimated, isGeneratedUnistyle } from '../web/utils'
|
|
5
5
|
|
|
6
6
|
export const getClassName = (unistyle: UnistylesValues | undefined | Array<UnistylesValues>, forChild?: boolean) => {
|
|
7
7
|
if (!unistyle) {
|
|
@@ -11,6 +11,15 @@ export const getClassName = (unistyle: UnistylesValues | undefined | Array<Unist
|
|
|
11
11
|
const flattenedStyles = Array.isArray(unistyle) ? unistyle.flat(Number.POSITIVE_INFINITY) : [unistyle]
|
|
12
12
|
const animatedStyles = flattenedStyles.filter(checkForAnimated)
|
|
13
13
|
const regularStyles = flattenedStyles.filter((style) => !checkForAnimated(style))
|
|
14
|
+
const [firstStyle, ...otherStyles] = regularStyles
|
|
15
|
+
|
|
16
|
+
// Already processed by an outer Unistyles component, e.g. createUnistylesElement(Animated.View),
|
|
17
|
+
// styles added after it (like Reanimated's initial animated values) stay inline
|
|
18
|
+
if (firstStyle && isGeneratedUnistyle(firstStyle) && firstStyle.hash) {
|
|
19
|
+
const { hash, injectedClassName } = firstStyle
|
|
20
|
+
|
|
21
|
+
return [{ $$css: true, hash, injectedClassName }, otherStyles.concat(animatedStyles)] as const
|
|
22
|
+
}
|
|
14
23
|
|
|
15
24
|
const { hash, injectedClassName } = unistyles.services.shadowRegistry.addStyles(regularStyles, forChild)
|
|
16
25
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// whether a style prop (also nested arrays) holds a unistyle, the only styles Unistyles updates
|
|
2
|
+
// a view without one renders like a React Native view, it never links
|
|
3
|
+
export const hasUnistyles = (style: unknown): boolean => {
|
|
4
|
+
if (Array.isArray(style)) {
|
|
5
|
+
return style.some(hasUnistyles)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (!style || typeof style !== 'object') {
|
|
9
|
+
return false
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// own keys only, like the registry. A unistyle starts with its `unistyles_` key, so it exits early
|
|
13
|
+
for (const key in style) {
|
|
14
|
+
if (key.startsWith('unistyles_') && Object.prototype.hasOwnProperty.call(style, key)) {
|
|
15
|
+
return true
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return false
|
|
20
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, {
|
|
2
|
-
forwardRef,
|
|
3
2
|
useContext,
|
|
4
3
|
useEffect,
|
|
5
4
|
type ComponentProps,
|
|
6
5
|
type ComponentRef,
|
|
7
6
|
type ComponentType,
|
|
7
|
+
type Ref,
|
|
8
8
|
} from 'react'
|
|
9
9
|
|
|
10
10
|
import type { UnistylesValues } from '../../types'
|
|
@@ -12,7 +12,7 @@ import type { Mappings } from './types'
|
|
|
12
12
|
|
|
13
13
|
import { ScopedThemeContext } from '../../components/ScopedThemeContext'
|
|
14
14
|
import { type UnistyleDependency, UnistylesShadowRegistry } from '../../specs'
|
|
15
|
-
import { deepMergeObjects } from '../../utils'
|
|
15
|
+
import { deepMergeObjects, isAnimatedStyleHandle } from '../../utils'
|
|
16
16
|
import { useProxifiedUnistyles } from '../useProxifiedUnistyles'
|
|
17
17
|
import { maybeWarnAboutMultipleUnistyles } from '../warn'
|
|
18
18
|
|
|
@@ -27,10 +27,30 @@ type UnistylesSecrets = {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
type MappedSecrets = {
|
|
30
|
-
styles: Record<string, any>
|
|
30
|
+
styles: Record<string, any> | Array<Record<string, any>>
|
|
31
31
|
dependencies: Array<UnistyleDependency>
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
// Reanimated finds animated styles by their keys, merged with other styles they would hide them
|
|
35
|
+
// so keep every animated style as a separate entry and merge only the styles between them, in order
|
|
36
|
+
const mergeAroundAnimatedStyles = (secrets: Array<UnistylesSecrets>) =>
|
|
37
|
+
secrets.reduce<Array<Record<string, any>>>((acc, secret) => {
|
|
38
|
+
const style = secret.uni__getStyles()
|
|
39
|
+
const lastStyle = acc.at(-1)
|
|
40
|
+
|
|
41
|
+
if (isAnimatedStyleHandle(style)) {
|
|
42
|
+
return acc.concat([style])
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (lastStyle && !isAnimatedStyleHandle(lastStyle)) {
|
|
46
|
+
Object.assign(lastStyle, style)
|
|
47
|
+
|
|
48
|
+
return acc
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return acc.concat([{ ...style }])
|
|
52
|
+
}, [])
|
|
53
|
+
|
|
34
54
|
export const getSecrets = (styleProps: Record<string, any> = {}): MappedSecrets => {
|
|
35
55
|
const styles = Array.isArray(styleProps) ? styleProps.flat(Infinity) : [styleProps]
|
|
36
56
|
|
|
@@ -48,7 +68,9 @@ export const getSecrets = (styleProps: Record<string, any> = {}): MappedSecrets
|
|
|
48
68
|
}, [])
|
|
49
69
|
|
|
50
70
|
return {
|
|
51
|
-
styles:
|
|
71
|
+
styles: styles.some(isAnimatedStyleHandle)
|
|
72
|
+
? mergeAroundAnimatedStyles(secrets)
|
|
73
|
+
: secrets.reduce((acc, secret) => Object.assign(acc, secret.uni__getStyles()), {} as Record<string, any>),
|
|
52
74
|
dependencies: secrets.flatMap((secret) => secret.uni__dependencies),
|
|
53
75
|
}
|
|
54
76
|
}
|
|
@@ -66,7 +88,7 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
|
|
|
66
88
|
contentContainerStyle?: UnistylesValues
|
|
67
89
|
}
|
|
68
90
|
|
|
69
|
-
return
|
|
91
|
+
return ({ ref, ...props }: PropsWithUnistyles & { ref?: Ref<GenericComponentRef<TComponent>> }) => {
|
|
70
92
|
const narrowedProps = props as PropsWithUnistyles & UnistyleStyles
|
|
71
93
|
const NativeComponent = Component as ComponentType
|
|
72
94
|
|
|
@@ -127,5 +149,5 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
|
|
|
127
149
|
} as any
|
|
128
150
|
|
|
129
151
|
return <NativeComponent key={uniPropsKey || mappingsKey} {...finalProps} ref={ref} />
|
|
130
|
-
}
|
|
152
|
+
}
|
|
131
153
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { type ComponentType,
|
|
1
|
+
import React, { type ComponentType, type ComponentProps, type ComponentRef, type Ref } from 'react'
|
|
2
2
|
|
|
3
3
|
import type { UnistylesValues } from '../../types'
|
|
4
4
|
import type { Mappings } from './types'
|
|
@@ -26,9 +26,9 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
|
|
|
26
26
|
contentContainerStyle?: UnistylesValues
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
return
|
|
29
|
+
return ({ ref, ...props }: PropsWithUnistyles & { ref?: Ref<GenericComponentRef<TComponent>> }) => {
|
|
30
30
|
const narrowedProps = props as PropsWithUnistyles & UnistyleStyles
|
|
31
|
-
const
|
|
31
|
+
const [classNames, animatedStyles] = getClassName(narrowedProps.style, true) ?? []
|
|
32
32
|
const contentContainerStyleClassNames = getClassName(narrowedProps.contentContainerStyle)
|
|
33
33
|
const { proxifiedRuntime, proxifiedTheme } = useProxifiedUnistyles()
|
|
34
34
|
|
|
@@ -50,7 +50,8 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
|
|
|
50
50
|
...(narrowedProps.style
|
|
51
51
|
? {
|
|
52
52
|
// Override default component styles with undefined values to reset them
|
|
53
|
-
|
|
53
|
+
// animated styles can't be a class, so they stay inline
|
|
54
|
+
style: animatedStyles?.length ? [emptyStyles, ...animatedStyles] : emptyStyles,
|
|
54
55
|
}
|
|
55
56
|
: {}),
|
|
56
57
|
...(narrowedProps.contentContainerStyle
|
|
@@ -68,12 +69,11 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
|
|
|
68
69
|
maybeWarnAboutMultipleUnistyles(narrowedProps.contentContainerStyle, `withUnistyles(${Component.displayName ?? Component.name ?? 'Unknown'})`)
|
|
69
70
|
|
|
70
71
|
const NativeComponent = Component as ComponentType
|
|
71
|
-
const [classNames] = styleClassNames ?? []
|
|
72
72
|
|
|
73
73
|
return (
|
|
74
74
|
<div className={classNames?.hash} style={{ display: 'contents' }}>
|
|
75
75
|
<NativeComponent key={uniPropsKey || mappingsKey} {...combinedProps} ref={ref} />
|
|
76
76
|
</div>
|
|
77
77
|
)
|
|
78
|
-
}
|
|
78
|
+
}
|
|
79
79
|
}
|
package/src/mocks.ts
CHANGED
|
@@ -20,6 +20,7 @@ jest.mock('react-native-nitro-modules', () => ({
|
|
|
20
20
|
createHybridObject: () => ({
|
|
21
21
|
add: () => {},
|
|
22
22
|
init: () => {},
|
|
23
|
+
addChangeListener: () => () => {},
|
|
23
24
|
createHybridStatusBar: () => ({
|
|
24
25
|
setStyle: () => {},
|
|
25
26
|
}),
|
|
@@ -199,11 +200,19 @@ jest.mock('react-native-unistyles', () => {
|
|
|
199
200
|
Component: TComponent,
|
|
200
201
|
mapper?: (theme: UnistylesTheme, runtime: typeof miniRuntime) => TComponent,
|
|
201
202
|
) =>
|
|
202
|
-
(props: any) =>
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
})
|
|
203
|
+
({ uniProps, ...props }: any) => {
|
|
204
|
+
const { deepMergeObjects } = require('./utils')
|
|
205
|
+
const theme = (Object.values(_REGISTRY.themes).at(0) ?? {}) as UnistylesTheme
|
|
206
|
+
const { key: mappingsKey, ...mappingsProps } = mapper?.(theme, miniRuntime) ?? ({} as any)
|
|
207
|
+
const { key: uniPropsKey, ...unistyleProps } = uniProps?.(theme, miniRuntime) ?? {}
|
|
208
|
+
|
|
209
|
+
return React.createElement(Component, {
|
|
210
|
+
...deepMergeObjects(mappingsProps, unistyleProps, props),
|
|
211
|
+
...(props.style ? { style: props.style } : {}),
|
|
212
|
+
...(props.contentContainerStyle ? { contentContainerStyle: props.contentContainerStyle } : {}),
|
|
213
|
+
key: uniPropsKey || mappingsKey,
|
|
214
|
+
})
|
|
215
|
+
},
|
|
207
216
|
mq: {
|
|
208
217
|
only: {
|
|
209
218
|
width: () => ({
|