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
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// A Host is the view's creation fiber behind an opaque type: no allocation, and stable identity (=== / WeakMap keys).
|
|
2
|
+
import type { FiberNode, RawFiber, ShadowNode } from './fiber'
|
|
3
|
+
import * as fiber from './fiber'
|
|
4
|
+
|
|
5
|
+
// Bound once: Metro's inline requires would turn each imported name used in a function into a require per call
|
|
6
|
+
const {
|
|
7
|
+
committedOf,
|
|
8
|
+
fiberOfInstance,
|
|
9
|
+
firstHostBelow,
|
|
10
|
+
hostAncestor,
|
|
11
|
+
patchRenderedProps: patchFiberProps,
|
|
12
|
+
raw,
|
|
13
|
+
resolveHostFiber,
|
|
14
|
+
shadowNodesOf,
|
|
15
|
+
} = fiber
|
|
16
|
+
const { HostComponent: HOST_COMPONENT, Offscreen: OFFSCREEN, Suspense: SUSPENSE, Activity: ACTIVITY } = fiber.Tag
|
|
17
|
+
|
|
18
|
+
declare const brand: unique symbol
|
|
19
|
+
export type Host = { readonly [brand]: 'Host' }
|
|
20
|
+
|
|
21
|
+
export const fiberOf = (host: Host): RawFiber => host as unknown as RawFiber
|
|
22
|
+
|
|
23
|
+
export const toHost = (fiber: RawFiber | FiberNode | null | undefined): Host | undefined =>
|
|
24
|
+
((fiber as RawFiber | null | undefined)?.stateNode?.canonical?.internalInstanceHandle ?? undefined) as Host | undefined
|
|
25
|
+
|
|
26
|
+
const resolveRefSlowly = (ref: unknown): RawFiber | undefined =>
|
|
27
|
+
raw(resolveHostFiber(ref)) ?? (toHost(firstHostBelow(fiberOfInstance(ref))) as unknown as RawFiber | undefined)
|
|
28
|
+
|
|
29
|
+
// The fast path is inlined: legacy Hermes doesn't inline calls
|
|
30
|
+
export const getHostFor = (ref: unknown): Host | undefined => {
|
|
31
|
+
const fiber = (ref as { __internalInstanceHandle?: RawFiber } | null | undefined)?.__internalInstanceHandle
|
|
32
|
+
|
|
33
|
+
if (fiber !== undefined) {
|
|
34
|
+
return fiber as unknown as Host
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return resolveRefSlowly(ref) as unknown as Host | undefined
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const getShadowNodeFor = (ref: unknown): ShadowNode | undefined => {
|
|
41
|
+
const fiber = (ref as { __internalInstanceHandle?: RawFiber } | null | undefined)?.__internalInstanceHandle
|
|
42
|
+
|
|
43
|
+
if (fiber !== undefined) {
|
|
44
|
+
return fiber.stateNode?.node
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return resolveRefSlowly(ref)?.stateNode?.node
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const getHostForInstanceHandle = (handle: unknown): Host | undefined => toHost(handle as RawFiber | null | undefined)
|
|
51
|
+
|
|
52
|
+
// Not the first host below the scroll view: on iOS a refreshControl comes first
|
|
53
|
+
export const getContentContainerFor = (ref: any): Host | undefined => {
|
|
54
|
+
const scroll = ref?.getInnerViewRef ? ref : (ref?.getNativeScrollRef?.() ?? ref?.getScrollResponder?.())
|
|
55
|
+
|
|
56
|
+
return getHostFor(scroll?.getInnerViewRef?.())
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const getShadowNode = (host: Host): ShadowNode | undefined => fiberOf(host).stateNode?.node
|
|
60
|
+
|
|
61
|
+
// Two nodes only while a render is in flight; after a commit both halves share one
|
|
62
|
+
export const getShadowNodes = (host: Host, out: Array<ShadowNode> = []): Array<ShadowNode> => {
|
|
63
|
+
shadowNodesOf(host as unknown as FiberNode, out)
|
|
64
|
+
|
|
65
|
+
return out
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const getNativeTag = (host: Host): number | undefined => fiberOf(host).stateNode?.canonical?.nativeTag
|
|
69
|
+
|
|
70
|
+
export const getParentHost = (host: Host): Host | undefined => toHost(hostAncestor(host as unknown as FiberNode))
|
|
71
|
+
|
|
72
|
+
export const patchRenderedProps = (host: Host, patch: (props: Record<string, any>) => Record<string, any> | undefined): boolean =>
|
|
73
|
+
patchFiberProps(host as unknown as FiberNode, patch)
|
|
74
|
+
|
|
75
|
+
export const HiddenBy = {
|
|
76
|
+
None: 0,
|
|
77
|
+
Suspense: 1,
|
|
78
|
+
Freeze: 2,
|
|
79
|
+
Activity: 4,
|
|
80
|
+
} as const
|
|
81
|
+
|
|
82
|
+
// `return` can point into either half of a pair; ask which half is committed only when they disagree
|
|
83
|
+
export const committedHalf = (fiber: RawFiber, differs: (a: RawFiber, b: RawFiber) => boolean): RawFiber | null => {
|
|
84
|
+
const alternate = fiber.alternate
|
|
85
|
+
|
|
86
|
+
if (!alternate || !differs(fiber, alternate)) {
|
|
87
|
+
return fiber
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return raw(committedOf(fiber as unknown as FiberNode)) ?? null
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const hiddenStateDiffers = (a: RawFiber, b: RawFiber) => (a.memoizedState === null) !== (b.memoizedState === null)
|
|
94
|
+
|
|
95
|
+
// React's own visibility bit on the Offscreen instance: shared by both halves and flipped in the commit before refs
|
|
96
|
+
// detach, so it also holds inside a ref cleanup, where the committed half is still the old tree
|
|
97
|
+
const OFFSCREEN_VISIBLE = 1
|
|
98
|
+
const isOffscreenHidden = (offscreen: RawFiber): boolean => {
|
|
99
|
+
const visibility = offscreen.stateNode?._visibility
|
|
100
|
+
|
|
101
|
+
if (typeof visibility === 'number') {
|
|
102
|
+
return (visibility & OFFSCREEN_VISIBLE) === 0
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return committedHalf(offscreen, hiddenStateDiffers)?.memoizedState != null
|
|
106
|
+
}
|
|
107
|
+
const freezeDiffers = (a: RawFiber, b: RawFiber) => a.memoizedProps?.freeze !== b.memoizedProps?.freeze
|
|
108
|
+
|
|
109
|
+
// react-freeze: Freeze > Suspense > Suspender. The Suspender keeps stale props because it throws, so read Freeze's.
|
|
110
|
+
const isFrozenBoundary = (suspense: RawFiber) =>
|
|
111
|
+
committedHalf(suspense.return as RawFiber, freezeDiffers)?.memoizedProps?.freeze === true
|
|
112
|
+
|
|
113
|
+
// Every hidden subtree sits under an Offscreen fiber with memoizedState set
|
|
114
|
+
export const getHiddenReasons = (host: Host): number => {
|
|
115
|
+
let reasons = 0
|
|
116
|
+
|
|
117
|
+
for (let current = fiberOf(host).return; current; current = current.return) {
|
|
118
|
+
if (current.tag !== OFFSCREEN || !isOffscreenHidden(current)) {
|
|
119
|
+
continue
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const boundary = current.return
|
|
123
|
+
|
|
124
|
+
if (boundary?.tag === ACTIVITY) {
|
|
125
|
+
reasons |= HiddenBy.Activity
|
|
126
|
+
} else if (boundary?.tag === SUSPENSE) {
|
|
127
|
+
reasons |= isFrozenBoundary(boundary) ? HiddenBy.Freeze : HiddenBy.Suspense
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return reasons
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Any hidden Offscreen, as in collectVisibleAncestors. Stops at the first: the reason isn't needed
|
|
135
|
+
export const isHidden = (host: Host): boolean => {
|
|
136
|
+
for (let current = fiberOf(host).return; current; current = current.return) {
|
|
137
|
+
if (current.tag === OFFSCREEN && isOffscreenHidden(current)) {
|
|
138
|
+
return true
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return false
|
|
143
|
+
}
|
|
144
|
+
export const isSuspended = (host: Host) => (getHiddenReasons(host) & HiddenBy.Suspense) !== 0
|
|
145
|
+
export const isFrozen = (host: Host) => (getHiddenReasons(host) & HiddenBy.Freeze) !== 0
|
|
146
|
+
export const isInHiddenActivity = (host: Host) => (getHiddenReasons(host) & HiddenBy.Activity) !== 0
|
|
147
|
+
|
|
148
|
+
const isHiddenOffscreen = (offscreen: RawFiber, boundaries: Map<RawFiber, boolean>): boolean => {
|
|
149
|
+
let hidden = boundaries.get(offscreen)
|
|
150
|
+
|
|
151
|
+
if (hidden === undefined) {
|
|
152
|
+
hidden = isOffscreenHidden(offscreen)
|
|
153
|
+
boundaries.set(offscreen, hidden)
|
|
154
|
+
|
|
155
|
+
if (offscreen.alternate) {
|
|
156
|
+
boundaries.set(offscreen.alternate, hidden)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return hidden
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Hot loops below: indexed loops and writes, explicit null checks, no helper calls (legacy Hermes)
|
|
164
|
+
export const collectVisibleAncestors = (hosts: ReadonlyArray<Host | null | undefined>, visit: (host: Host) => void) => {
|
|
165
|
+
const visibleByTag = new Map<number, boolean>()
|
|
166
|
+
const boundaries = new Map<RawFiber, boolean>()
|
|
167
|
+
const pending: Array<RawFiber> = []
|
|
168
|
+
|
|
169
|
+
for (let h = 0; h < hosts.length; h++) {
|
|
170
|
+
let visible = true
|
|
171
|
+
let count = 0
|
|
172
|
+
|
|
173
|
+
for (let current = hosts[h] as unknown as RawFiber | null | undefined; current != null; current = current.return) {
|
|
174
|
+
if (current.tag === HOST_COMPONENT) {
|
|
175
|
+
const stateNode = current.stateNode
|
|
176
|
+
|
|
177
|
+
if (stateNode == null || stateNode.canonical == null) {
|
|
178
|
+
break
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const answer = visibleByTag.get(stateNode.canonical.nativeTag)
|
|
182
|
+
|
|
183
|
+
if (answer !== undefined) {
|
|
184
|
+
visible = answer
|
|
185
|
+
break
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
pending[count++] = current
|
|
189
|
+
} else if (current.tag === OFFSCREEN && isHiddenOffscreen(current, boundaries)) {
|
|
190
|
+
visible = false
|
|
191
|
+
break
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
for (let i = 0; i < count; i++) {
|
|
196
|
+
const canonical = pending[i]!.stateNode.canonical
|
|
197
|
+
|
|
198
|
+
visibleByTag.set(canonical.nativeTag, visible)
|
|
199
|
+
|
|
200
|
+
if (visible && canonical.internalInstanceHandle != null) {
|
|
201
|
+
visit(canonical.internalInstanceHandle as Host)
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Hidden hosts included
|
|
208
|
+
export const collectAncestors = (hosts: ReadonlyArray<Host | null | undefined>, visit: (host: Host) => void) => {
|
|
209
|
+
const visitedByTag = new Set<number>()
|
|
210
|
+
|
|
211
|
+
for (let h = 0; h < hosts.length; h++) {
|
|
212
|
+
for (let current = hosts[h] as unknown as RawFiber | null | undefined; current != null; current = current.return) {
|
|
213
|
+
if (current.tag !== HOST_COMPONENT) {
|
|
214
|
+
continue
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const stateNode = current.stateNode
|
|
218
|
+
|
|
219
|
+
if (stateNode == null || stateNode.canonical == null) {
|
|
220
|
+
break
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const canonical = stateNode.canonical
|
|
224
|
+
|
|
225
|
+
if (visitedByTag.has(canonical.nativeTag)) {
|
|
226
|
+
break
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
visitedByTag.add(canonical.nativeTag)
|
|
230
|
+
|
|
231
|
+
if (canonical.internalInstanceHandle != null) {
|
|
232
|
+
visit(canonical.internalInstanceHandle as Host)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createOwnerRegistry } from './adapters/registry'
|
|
2
|
+
import { animatedComponentOf, reanimatedCSSAdapter } from './adapters/reanimated'
|
|
3
|
+
import { getCreationStack, getOwners, verify } from './diagnostics'
|
|
4
|
+
import * as HostApi from './host'
|
|
5
|
+
|
|
6
|
+
export type { Host } from './host'
|
|
7
|
+
export type { Drift } from './diagnostics'
|
|
8
|
+
export type { ShadowNode } from './fiber'
|
|
9
|
+
export type { OwnerAdapter, OwnerRegistry, StyleSource } from './adapters/registry'
|
|
10
|
+
|
|
11
|
+
// Object literals, not classes: static methods on a Babel-transpiled class are slower on Hermes
|
|
12
|
+
export const Fiber = {
|
|
13
|
+
getHostFor: HostApi.getHostFor,
|
|
14
|
+
getShadowNodeFor: HostApi.getShadowNodeFor,
|
|
15
|
+
getHostForInstanceHandle: HostApi.getHostForInstanceHandle,
|
|
16
|
+
getContentContainerFor: HostApi.getContentContainerFor,
|
|
17
|
+
|
|
18
|
+
getShadowNode: HostApi.getShadowNode,
|
|
19
|
+
getShadowNodes: HostApi.getShadowNodes,
|
|
20
|
+
getNativeTag: HostApi.getNativeTag,
|
|
21
|
+
getParentHost: HostApi.getParentHost,
|
|
22
|
+
|
|
23
|
+
isHidden: HostApi.isHidden,
|
|
24
|
+
isSuspended: HostApi.isSuspended,
|
|
25
|
+
isFrozen: HostApi.isFrozen,
|
|
26
|
+
isInHiddenActivity: HostApi.isInHiddenActivity,
|
|
27
|
+
|
|
28
|
+
collectVisibleAncestors: HostApi.collectVisibleAncestors,
|
|
29
|
+
collectAncestors: HostApi.collectAncestors,
|
|
30
|
+
|
|
31
|
+
patchRenderedProps: HostApi.patchRenderedProps,
|
|
32
|
+
|
|
33
|
+
verify,
|
|
34
|
+
getOwners,
|
|
35
|
+
getCreationStack,
|
|
36
|
+
|
|
37
|
+
createOwnerRegistry,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const Reanimated = {
|
|
41
|
+
animatedComponentOf,
|
|
42
|
+
cssAdapter: reanimatedCSSAdapter,
|
|
43
|
+
}
|
package/src/utils.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export const isDefined = <T>(value: T): value is NonNullable<T> => value !== undefined && value !== null
|
|
2
2
|
|
|
3
|
+
// Reanimated useAnimatedStyle handle, it's a plain object, not an Animated.Node
|
|
4
|
+
// styleUpdaterContainer was added in Reanimated 4.1, so check only the keys every version has
|
|
5
|
+
export const isAnimatedStyleHandle = (value: unknown): boolean =>
|
|
6
|
+
typeof value === 'object' && value !== null && 'viewDescriptors' in value && 'initial' in value
|
|
7
|
+
|
|
3
8
|
export const deepMergeObjects = <T extends Record<PropertyKey, any>>(...sources: Array<T>) => {
|
|
4
9
|
const target = {} as T
|
|
5
10
|
|
|
@@ -23,7 +28,53 @@ export const deepMergeObjects = <T extends Record<PropertyKey, any>>(...sources:
|
|
|
23
28
|
return target
|
|
24
29
|
}
|
|
25
30
|
|
|
31
|
+
// React tells a class component from a function component by these keys
|
|
32
|
+
const CLASS_PROTOTYPE_KEYS = ['isReactComponent', 'render']
|
|
33
|
+
const CLASS_STATIC_KEYS = ['contextType', 'contextTypes', 'childContextTypes', 'getDerivedStateFromProps']
|
|
34
|
+
|
|
35
|
+
// owner doesn't have the key, objects that inherit from owner read it from source
|
|
36
|
+
const hideFromOwner = (owner: object, source: object, key: string) => {
|
|
37
|
+
Object.defineProperty(owner, key, {
|
|
38
|
+
configurable: true,
|
|
39
|
+
get() {
|
|
40
|
+
return this === owner ? undefined : Reflect.get(source, key, this)
|
|
41
|
+
},
|
|
42
|
+
set(value) {
|
|
43
|
+
Object.defineProperty(this, key, { value, writable: true, enumerable: true, configurable: true })
|
|
44
|
+
},
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const inheritNativeClass = (Component: any, UnistylesComponent: (props: unknown) => unknown) => {
|
|
49
|
+
function UnistylesClassComponent(this: unknown, ...args: Array<unknown>) {
|
|
50
|
+
if (this instanceof UnistylesClassComponent) {
|
|
51
|
+
return Reflect.construct(Component, args, new.target ?? this.constructor)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return UnistylesComponent(args[0])
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
Object.setPrototypeOf(UnistylesClassComponent, Component)
|
|
58
|
+
UnistylesClassComponent.prototype = Object.create(Component.prototype, {
|
|
59
|
+
constructor: { value: UnistylesClassComponent, writable: true, configurable: true },
|
|
60
|
+
})
|
|
61
|
+
// only the keys of the class, eg. React warns about a subclass with a `contextType` key that isn't a context
|
|
62
|
+
CLASS_PROTOTYPE_KEYS.filter((key) => key in Component.prototype).forEach((key) =>
|
|
63
|
+
hideFromOwner(UnistylesClassComponent.prototype, Component.prototype, key),
|
|
64
|
+
)
|
|
65
|
+
CLASS_STATIC_KEYS.filter((key) => key in Component).forEach((key) =>
|
|
66
|
+
hideFromOwner(UnistylesClassComponent, Component, key),
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
return UnistylesClassComponent
|
|
70
|
+
}
|
|
71
|
+
|
|
26
72
|
export const copyComponentProperties = (Component: any, UnistylesComponent: any) => {
|
|
73
|
+
// static properties (eg. displayName) are inherited from the class
|
|
74
|
+
if (Component?.prototype?.isReactComponent && typeof UnistylesComponent === 'function') {
|
|
75
|
+
return inheritNativeClass(Component, UnistylesComponent)
|
|
76
|
+
}
|
|
77
|
+
|
|
27
78
|
Object.entries(Component).forEach(([key, value]) => {
|
|
28
79
|
// Filter out the keys we don't want to copy
|
|
29
80
|
if (['$$typeof', 'render', 'contextType'].includes(key)) {
|
package/src/web/convert/index.ts
CHANGED
|
@@ -2,11 +2,38 @@ import type { UnistylesValues } from '../../types'
|
|
|
2
2
|
import type { UnistylesRuntime } from '../runtime'
|
|
3
3
|
|
|
4
4
|
import { deepMergeObjects } from '../../utils'
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getBackgroundLayers,
|
|
7
|
+
getBoxShadow,
|
|
8
|
+
getFilterStyle,
|
|
9
|
+
getFontVariationSettings,
|
|
10
|
+
getTransformStyle,
|
|
11
|
+
} from './object'
|
|
6
12
|
import { isPseudo } from './pseudo'
|
|
7
13
|
import { getBoxShadowStyle, getTextShadowStyle } from './shadow'
|
|
8
14
|
import { getStyle } from './style'
|
|
9
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
isBackgroundLayer,
|
|
17
|
+
isBoxShadow,
|
|
18
|
+
isFilter,
|
|
19
|
+
isFontVariationSettings,
|
|
20
|
+
isShadow,
|
|
21
|
+
isTextShadow,
|
|
22
|
+
isTransform,
|
|
23
|
+
} from './utils'
|
|
24
|
+
|
|
25
|
+
// a breakpoint can hold React Native's array or object syntax too
|
|
26
|
+
const getBreakpointStyle = (key: string, value: any) => {
|
|
27
|
+
if (isBackgroundLayer(key, value)) {
|
|
28
|
+
return getBackgroundLayers(key, value)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (isFontVariationSettings(key, value)) {
|
|
32
|
+
return getFontVariationSettings(value)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return getStyle(key, value)
|
|
36
|
+
}
|
|
10
37
|
|
|
11
38
|
export const convertUnistyles = (value: UnistylesValues, runtime: UnistylesRuntime) => {
|
|
12
39
|
// Flag to mark if textShadow is already created
|
|
@@ -65,10 +92,19 @@ export const convertUnistyles = (value: UnistylesValues, runtime: UnistylesRunti
|
|
|
65
92
|
return getTransformStyle(unistylesValue)
|
|
66
93
|
}
|
|
67
94
|
|
|
95
|
+
// React Native's array and object syntaxes, not breakpoints
|
|
96
|
+
if (isBackgroundLayer(unistylesKey, unistylesValue)) {
|
|
97
|
+
return getBackgroundLayers(unistylesKey, unistylesValue)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (isFontVariationSettings(unistylesKey, unistylesValue)) {
|
|
101
|
+
return getFontVariationSettings(unistylesValue)
|
|
102
|
+
}
|
|
103
|
+
|
|
68
104
|
// Breakpoints
|
|
69
105
|
if (typeof unistylesValue === 'object' && unistylesValue !== null) {
|
|
70
106
|
return Object.entries(unistylesValue).map(([breakpointKey, breakpointValue]) => {
|
|
71
|
-
return { [breakpointKey]:
|
|
107
|
+
return { [breakpointKey]: getBreakpointStyle(unistylesKey, breakpointValue) }
|
|
72
108
|
})
|
|
73
109
|
}
|
|
74
110
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { normalizeNumericValue } from '../utils'
|
|
2
|
+
|
|
3
|
+
type BackgroundLayerKey = 'backgroundSize' | 'backgroundPosition' | 'backgroundRepeat'
|
|
4
|
+
type BackgroundSize = string | { x: string | number; y: string | number }
|
|
5
|
+
type BackgroundPosition = Partial<Record<'top' | 'left' | 'right' | 'bottom', string | number>>
|
|
6
|
+
type BackgroundRepeat = { x: string; y: string }
|
|
7
|
+
|
|
8
|
+
const createBackgroundSizeValue = (size: BackgroundSize) => {
|
|
9
|
+
if (typeof size === 'string') {
|
|
10
|
+
return size
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return `${normalizeNumericValue(size.x)} ${normalizeNumericValue(size.y)}`
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const createBackgroundPositionValue = (position: BackgroundPosition) => {
|
|
17
|
+
const edges = (['left', 'right', 'top', 'bottom'] as const).filter((edge) => position[edge] !== undefined)
|
|
18
|
+
|
|
19
|
+
return edges.map((edge) => `${edge} ${normalizeNumericValue(position[edge]!)}`).join(' ')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const createBackgroundRepeatValue = (repeat: BackgroundRepeat) => `${repeat.x} ${repeat.y}`
|
|
23
|
+
|
|
24
|
+
const createBackgroundLayerValue = {
|
|
25
|
+
backgroundSize: createBackgroundSizeValue,
|
|
26
|
+
backgroundPosition: createBackgroundPositionValue,
|
|
27
|
+
backgroundRepeat: createBackgroundRepeatValue,
|
|
28
|
+
} as Record<BackgroundLayerKey, (layer: any) => string>
|
|
29
|
+
|
|
30
|
+
// React Native's processed syntax, one object per background layer
|
|
31
|
+
export const getBackgroundLayers = (key: string, layers: Array<unknown>) => ({
|
|
32
|
+
[key]: layers.map(createBackgroundLayerValue[key as BackgroundLayerKey]).join(', '),
|
|
33
|
+
})
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Same output as React Native's processFontVariationSettings, eg. { wght: 700 } -> 'wght' 700
|
|
2
|
+
export const getFontVariationSettings = (fontVariationSettings: Record<string, number>) => ({
|
|
3
|
+
fontVariationSettings: Object.keys(fontVariationSettings)
|
|
4
|
+
.sort()
|
|
5
|
+
.map((axis) => `${axis.includes("'") ? `"${axis}"` : `'${axis}'`} ${fontVariationSettings[axis]}`)
|
|
6
|
+
.join(', '),
|
|
7
|
+
})
|
package/src/web/convert/utils.ts
CHANGED
|
@@ -21,6 +21,17 @@ export const isFilter = (key: string, value: any): value is Array<Filters> => ke
|
|
|
21
21
|
export const isBoxShadow = (key: string, value: any): value is Array<BoxShadowValue> =>
|
|
22
22
|
key === 'boxShadow' && Array.isArray(value)
|
|
23
23
|
|
|
24
|
+
export const isBackgroundLayer = (key: string, value: any): value is Array<unknown> =>
|
|
25
|
+
['backgroundSize', 'backgroundPosition', 'backgroundRepeat'].includes(key) && Array.isArray(value)
|
|
26
|
+
|
|
27
|
+
// { wght: 700 } is the object syntax, a breakpoints object holds strings or objects
|
|
28
|
+
export const isFontVariationSettings = (key: string, value: any): value is Record<string, number> =>
|
|
29
|
+
key === 'fontVariationSettings' &&
|
|
30
|
+
typeof value === 'object' &&
|
|
31
|
+
value !== null &&
|
|
32
|
+
!Array.isArray(value) &&
|
|
33
|
+
Object.values(value).every((axisValue) => typeof axisValue === 'number')
|
|
34
|
+
|
|
24
35
|
export const normalizeNumericValue = (value: number | string) =>
|
|
25
36
|
value && typeof value === 'number' ? `${value}px` : value
|
|
26
37
|
|
package/src/web/registry.ts
CHANGED
|
@@ -32,7 +32,7 @@ export class UnistylesRegistry {
|
|
|
32
32
|
)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
return stylesheet(scopedTheme, this.services.runtime.
|
|
35
|
+
return stylesheet(scopedTheme, this.services.runtime.getMiniRuntime(scopedThemeName))
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const computedStylesheet = this.stylesheets.get(stylesheet)
|
|
@@ -41,11 +41,9 @@ export class UnistylesRegistry {
|
|
|
41
41
|
return computedStylesheet
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
)
|
|
48
|
-
const createdStylesheet = stylesheet(currentTheme, this.services.runtime.miniRuntime)
|
|
44
|
+
const themeName = this.services.runtime.themeName
|
|
45
|
+
const currentTheme = this.services.runtime.getTheme(themeName, this.services.state.CSSVars)
|
|
46
|
+
const createdStylesheet = stylesheet(currentTheme, this.services.runtime.getMiniRuntime(themeName))
|
|
49
47
|
const dependencies = Object.values(createdStylesheet).flatMap((value) => extractUnistyleDependencies(value))
|
|
50
48
|
|
|
51
49
|
this.addDependenciesToStylesheet(stylesheet, dependencies)
|
|
@@ -65,9 +63,10 @@ export class UnistylesRegistry {
|
|
|
65
63
|
dependencies.forEach((dependency) => dependenciesMap.add(dependency))
|
|
66
64
|
|
|
67
65
|
const dispose = this.services.listener.addStylesheetListeners(Array.from(dependenciesMap), () => {
|
|
66
|
+
const themeName = this.services.runtime.themeName
|
|
68
67
|
const newComputedStylesheet = stylesheet(
|
|
69
|
-
this.services.runtime.getTheme(
|
|
70
|
-
this.services.runtime.
|
|
68
|
+
this.services.runtime.getTheme(themeName, this.services.state.CSSVars),
|
|
69
|
+
this.services.runtime.getMiniRuntime(themeName),
|
|
71
70
|
)
|
|
72
71
|
|
|
73
72
|
this.stylesheets.set(stylesheet, newComputedStylesheet)
|
package/src/web/runtime.ts
CHANGED
|
@@ -49,13 +49,8 @@ export class UnistylesRuntime {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
// App theme, like on native. ScopedTheme is read from React Context (useUnistyles) (#1295)
|
|
52
53
|
get themeName() {
|
|
53
|
-
const scopedTheme = this.services.shadowRegistry.getScopedTheme()
|
|
54
|
-
|
|
55
|
-
if (scopedTheme) {
|
|
56
|
-
return scopedTheme
|
|
57
|
-
}
|
|
58
|
-
|
|
59
54
|
if (this.services.state.hasAdaptiveThemes) {
|
|
60
55
|
return schemeToTheme(this.colorScheme) as AppThemeName
|
|
61
56
|
}
|
|
@@ -150,9 +145,14 @@ export class UnistylesRuntime {
|
|
|
150
145
|
}
|
|
151
146
|
|
|
152
147
|
get miniRuntime(): UnistylesMiniRuntime {
|
|
148
|
+
return this.getMiniRuntime(this.themeName)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// StyleSheets get the name of the theme they are called with
|
|
152
|
+
getMiniRuntime = (themeName?: AppThemeName): UnistylesMiniRuntime => {
|
|
153
153
|
return {
|
|
154
154
|
colorScheme: this.colorScheme,
|
|
155
|
-
themeName
|
|
155
|
+
themeName,
|
|
156
156
|
contentSizeCategory: this.contentSizeCategory,
|
|
157
157
|
breakpoint: this.breakpoint,
|
|
158
158
|
isLandscape: this.orientation === Orientation.Landscape,
|
|
@@ -6,7 +6,7 @@ import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../
|
|
|
6
6
|
import type { UnistylesRuntime } from '../runtime'
|
|
7
7
|
|
|
8
8
|
import { ColorScheme, Orientation } from '../../specs/types'
|
|
9
|
-
import { isDefined, isUnistylesMq, parseMq } from '../../utils'
|
|
9
|
+
import { isAnimatedStyleHandle, isDefined, isUnistylesMq, parseMq } from '../../utils'
|
|
10
10
|
import * as unistyles from '../services'
|
|
11
11
|
import { UNI_GENERATED_KEYS, type UniGeneratedKey, type UniGeneratedStyle } from '../types'
|
|
12
12
|
import { hyphenate, keyInObject, reduceObject } from './common'
|
|
@@ -98,9 +98,13 @@ export const getMediaQuery = (query: string, allBreakpoints: Array<string>) => {
|
|
|
98
98
|
.map((b) => unistyles.services.runtime.breakpoints[b] as number)
|
|
99
99
|
.sort((a, b) => a - b)
|
|
100
100
|
.find((b) => b > breakpointValue)
|
|
101
|
+
// Viewport widths are fractional CSS px under browser zoom / OS scaling, so an integer
|
|
102
|
+
// `max-width: next - 1` leaves a dead band (e.g. 767 < width < 768) that matches neither
|
|
103
|
+
// this breakpoint nor the next one. 0.02px below the next breakpoint (the Bootstrap
|
|
104
|
+
// convention) closes it without overlapping `(min-width: next)`.
|
|
101
105
|
const queries = [
|
|
102
106
|
`(min-width: ${breakpointValue}px)`,
|
|
103
|
-
nextBreakpoint ? `(max-width: ${nextBreakpoint -
|
|
107
|
+
nextBreakpoint ? `(max-width: ${nextBreakpoint - 0.02}px)` : undefined,
|
|
104
108
|
]
|
|
105
109
|
.filter(Boolean)
|
|
106
110
|
.join(' and ')
|
|
@@ -138,12 +142,15 @@ export const checkForAnimated = (value: any): boolean => {
|
|
|
138
142
|
}
|
|
139
143
|
|
|
140
144
|
if (typeof value === 'object' && value !== null) {
|
|
145
|
+
if (isAnimatedStyleHandle(value)) {
|
|
146
|
+
return true
|
|
147
|
+
}
|
|
148
|
+
|
|
141
149
|
const objectValues = Object.values(value)
|
|
142
150
|
const secrets = extractSecrets(value)
|
|
143
151
|
|
|
144
|
-
// @ts-expect-error React Native Web exports Animated.AnimatedNode as Animated.Node
|
|
145
152
|
// prettier-ignore
|
|
146
|
-
return value instanceof Animated.Node || objectValues.length > 0 && objectValues.some(checkForAnimated) || secrets && Object.keys(secrets).length === 0
|
|
153
|
+
return value instanceof Animated.Node || objectValues.length > 0 && objectValues.some(checkForAnimated) || !!secrets && Object.keys(secrets).length === 0
|
|
147
154
|
}
|
|
148
155
|
|
|
149
156
|
return false
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["web/convert/module.d.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["web/convert/module.d.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/mocks.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"passForwardRef.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/passForwardRef.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scoped-theme.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/scoped-theme.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shadow-registry.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/shadow-registry.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-child-selector.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/web-child-selector.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-listener.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/web-listener.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-pointer-events.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/web-pointer-events.spec.ts"],"names":[],"mappings":""}
|