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
|
@@ -2,10 +2,14 @@ import { NitroModules } from 'react-native-nitro-modules'
|
|
|
2
2
|
|
|
3
3
|
import type { Scope } from '../../components/ScopedThemeContext'
|
|
4
4
|
import type { VerifyReport } from '../../diagnostics/types'
|
|
5
|
+
import type { Host } from '../../unifiber/src'
|
|
5
6
|
import type { UnistylesShadowRegistry as UnistylesShadowRegistrySpec } from './ShadowRegistry.nitro'
|
|
6
7
|
import type { ShadowNode, Unistyle, ViewHandle } from './types'
|
|
7
8
|
|
|
9
|
+
import { Fiber, Reanimated } from '../../unifiber/src'
|
|
8
10
|
import { StyleSheet } from '../StyleSheet'
|
|
11
|
+
import { createUnistylesStyleSource } from './styleSource'
|
|
12
|
+
import { traceSection } from './tracing'
|
|
9
13
|
|
|
10
14
|
interface ShadowRegistry extends UnistylesShadowRegistrySpec {
|
|
11
15
|
// Babel API
|
|
@@ -25,126 +29,71 @@ interface ShadowRegistry extends UnistylesShadowRegistrySpec {
|
|
|
25
29
|
|
|
26
30
|
const HybridShadowRegistry = NitroModules.createHybridObject<ShadowRegistry>('UnistylesShadowRegistry')
|
|
27
31
|
|
|
28
|
-
const
|
|
29
|
-
const SUSPENSE_TAG = 13
|
|
30
|
-
const OFFSCREEN_TAG = 22
|
|
32
|
+
const { collectVisibleAncestors, getHostFor, getHostForInstanceHandle, getShadowNode, getShadowNodes, isHidden } = Fiber
|
|
31
33
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
+
const { source: styleSource, bumpEpoch } = createUnistylesStyleSource({
|
|
35
|
+
get: () => HybridShadowRegistry.getScopedTheme(),
|
|
36
|
+
set: (name) => HybridShadowRegistry.setScopedTheme(name),
|
|
37
|
+
})
|
|
38
|
+
const owners = Fiber.createOwnerRegistry(styleSource, [Reanimated.cssAdapter], (reason) => {
|
|
39
|
+
console.warn(`Unistyles: ${reason}. CSS transitions won't follow theme changes.`)
|
|
40
|
+
})
|
|
34
41
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
current = current.return
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return false
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const findFiberForHandle = (handle: ViewHandle) => {
|
|
47
|
-
return (
|
|
48
|
-
handle?.__internalInstanceHandle ??
|
|
49
|
-
handle?.getScrollResponder?.()?.getNativeScrollRef?.()?.__internalInstanceHandle ??
|
|
50
|
-
handle?.getNativeScrollRef?.()?.__internalInstanceHandle ??
|
|
51
|
-
handle?._viewRef?.__internalInstanceHandle ??
|
|
52
|
-
handle?.viewRef?.current?.__internalInstanceHandle ??
|
|
53
|
-
handle?._nativeRef?.__internalInstanceHandle
|
|
54
|
-
)
|
|
55
|
-
}
|
|
42
|
+
// A component can point at another native view by the time its ref is cleaned up, eg. FlatList on Android remounts
|
|
43
|
+
// its native ScrollView when `horizontal` changes, so remove unlinks the view it was linked with
|
|
44
|
+
// The host points at its current node, while a stored node would keep its first revision (and children) alive
|
|
45
|
+
// Native views always resolve to their own host, so they skip it
|
|
46
|
+
const linkedHosts = new WeakMap<object, Host>()
|
|
56
47
|
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
handle?.__internalInstanceHandle?.stateNode?.node ??
|
|
60
|
-
handle?.getScrollResponder?.()?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node ??
|
|
61
|
-
handle?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node ??
|
|
62
|
-
handle?._viewRef?.__internalInstanceHandle?.stateNode?.node ??
|
|
63
|
-
handle?.viewRef?.current?.__internalInstanceHandle?.stateNode?.node ??
|
|
64
|
-
handle?._nativeRef?.__internalInstanceHandle?.stateNode?.node
|
|
65
|
-
|
|
66
|
-
// @ts-ignore we don't know the type of handle
|
|
67
|
-
if (!node && handle?.props?.horizontal && handle?.constructor?.name === 'FlatList') {
|
|
68
|
-
throw new Error(
|
|
69
|
-
'Unistyles: detected an unsupported FlatList with the horizontal prop. This will cause crashes on Android due to a bug in React Native core. Read more: https://github.com/facebook/react-native/issues/51601',
|
|
70
|
-
)
|
|
71
|
-
}
|
|
48
|
+
const committedHosts: Array<Host | undefined> = []
|
|
49
|
+
let refreshNodes: Array<ShadowNode> = []
|
|
72
50
|
|
|
73
|
-
|
|
51
|
+
const collectShadowNodes = (host: Host) => {
|
|
52
|
+
getShadowNodes(host, refreshNodes)
|
|
74
53
|
}
|
|
75
54
|
|
|
76
55
|
// React re-attaches an untouched subtree through its root's node and only follows clones made on the JS thread.
|
|
77
56
|
// Once a node was cloned elsewhere (state updates, Reanimated), React would commit a subtree from before a Unistyles
|
|
78
57
|
// update, so after a Unistyles commit the committed nodes and their host ancestors must point at the committed tree
|
|
79
58
|
const refreshReactNodes = () => {
|
|
80
|
-
|
|
59
|
+
bumpEpoch()
|
|
60
|
+
|
|
61
|
+
const handles = HybridShadowRegistry.takeCommittedInstanceHandles()
|
|
81
62
|
|
|
82
|
-
if (
|
|
63
|
+
if (handles.length === 0) {
|
|
83
64
|
return
|
|
84
65
|
}
|
|
85
66
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
for (const fiber of fibers) {
|
|
91
|
-
// collected, unmounted since
|
|
92
|
-
if (!fiber) {
|
|
93
|
-
continue
|
|
67
|
+
try {
|
|
68
|
+
for (let i = 0; i < handles.length; i++) {
|
|
69
|
+
committedHosts[i] = getHostForInstanceHandle(handles[i])
|
|
94
70
|
}
|
|
95
71
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
hostFibers.length = 0
|
|
99
|
-
|
|
100
|
-
for (let current: any = fiber; current; current = current.return) {
|
|
101
|
-
// hidden by Suspense or a frozen screen
|
|
102
|
-
if ((current.tag === SUSPENSE_TAG || current.tag === OFFSCREEN_TAG) && current.memoizedState !== null) {
|
|
103
|
-
isHidden = true
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (current.tag !== HOST_COMPONENT_TAG) {
|
|
107
|
-
continue
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// its ancestors are visible and already collected
|
|
111
|
-
if (refreshedTags.has(current.stateNode?.canonical?.nativeTag)) {
|
|
112
|
-
break
|
|
113
|
-
}
|
|
72
|
+
collectVisibleAncestors(committedHosts, collectShadowNodes)
|
|
114
73
|
|
|
115
|
-
|
|
74
|
+
if (refreshNodes.length > 0) {
|
|
75
|
+
HybridShadowRegistry.refreshReactNodes(refreshNodes)
|
|
116
76
|
}
|
|
117
77
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const alternateNode = hostFiber.alternate?.stateNode?.node
|
|
125
|
-
const hostTag = hostFiber.stateNode?.canonical?.nativeTag
|
|
126
|
-
|
|
127
|
-
if (hostTag !== undefined) {
|
|
128
|
-
refreshedTags.add(hostTag)
|
|
129
|
-
}
|
|
78
|
+
traceSection('refreshOwners', () => owners.refresh(committedHosts))
|
|
79
|
+
} finally {
|
|
80
|
+
committedHosts.length = 0
|
|
81
|
+
refreshNodes = []
|
|
82
|
+
}
|
|
83
|
+
}
|
|
130
84
|
|
|
131
|
-
|
|
132
|
-
nodes.push(node)
|
|
133
|
-
}
|
|
85
|
+
StyleSheet.addChangeListener(refreshReactNodes)
|
|
134
86
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
87
|
+
// a unistyle key holds its secrets object. A unistyle spread into another StyleSheet.create keeps its key,
|
|
88
|
+
// but the parser resolves the (hidden) secrets to undefined, so the key no longer points at a unistyle
|
|
89
|
+
const isUnistyleKey = (style: any, key: string) => {
|
|
90
|
+
if (!key.startsWith('unistyles_')) {
|
|
91
|
+
return false
|
|
139
92
|
}
|
|
140
93
|
|
|
141
|
-
|
|
142
|
-
HybridShadowRegistry.refreshReactNodes(nodes)
|
|
143
|
-
}
|
|
94
|
+
return typeof style[key] === 'object' && style[key] !== null
|
|
144
95
|
}
|
|
145
96
|
|
|
146
|
-
StyleSheet.addChangeListener(refreshReactNodes)
|
|
147
|
-
|
|
148
97
|
// skips empty styles and splits a style merged from many unistyles (eg. flattened by Animated) into one per unistyle
|
|
149
98
|
// runs for every style on every link, so it reads the keys once and allocates only for the rare merged style
|
|
150
99
|
const collectStyle = (style: any, collected: Array<any>) => {
|
|
@@ -156,7 +105,7 @@ const collectStyle = (style: any, collected: Array<any>) => {
|
|
|
156
105
|
let unistylesCount = 0
|
|
157
106
|
|
|
158
107
|
for (const key of keys) {
|
|
159
|
-
if (key
|
|
108
|
+
if (isUnistyleKey(style, key)) {
|
|
160
109
|
unistylesCount++
|
|
161
110
|
}
|
|
162
111
|
}
|
|
@@ -170,7 +119,7 @@ const collectStyle = (style: any, collected: Array<any>) => {
|
|
|
170
119
|
}
|
|
171
120
|
|
|
172
121
|
for (const key of keys) {
|
|
173
|
-
if (key
|
|
122
|
+
if (isUnistyleKey(style, key)) {
|
|
174
123
|
collected.push({ [key]: style[key] })
|
|
175
124
|
}
|
|
176
125
|
}
|
|
@@ -191,9 +140,10 @@ HybridShadowRegistry.add = (handle, styles, scope) => {
|
|
|
191
140
|
}
|
|
192
141
|
|
|
193
142
|
if (filteredStyles.length > 0) {
|
|
194
|
-
const
|
|
143
|
+
const host = getHostFor(handle)
|
|
144
|
+
const node = host && getShadowNode(host)
|
|
195
145
|
|
|
196
|
-
if (!node) {
|
|
146
|
+
if (!host || !node) {
|
|
197
147
|
throw new Error(
|
|
198
148
|
`Unistyles: Could not find shadow node for one of your components of type ${handle?.constructor?.name ?? 'unknown'}`,
|
|
199
149
|
)
|
|
@@ -207,6 +157,11 @@ HybridShadowRegistry.add = (handle, styles, scope) => {
|
|
|
207
157
|
}
|
|
208
158
|
|
|
209
159
|
HybridShadowRegistry.link(node, filteredStyles)
|
|
160
|
+
owners.link(host)
|
|
161
|
+
|
|
162
|
+
if (!handle.__internalInstanceHandle) {
|
|
163
|
+
linkedHosts.set(handle, host)
|
|
164
|
+
}
|
|
210
165
|
|
|
211
166
|
if (scope) {
|
|
212
167
|
HybridShadowRegistry.setScopedTheme(previousScopedTheme)
|
|
@@ -219,12 +174,16 @@ HybridShadowRegistry.remove = (handle) => {
|
|
|
219
174
|
return
|
|
220
175
|
}
|
|
221
176
|
|
|
222
|
-
const
|
|
177
|
+
const linkedHost = handle.__internalInstanceHandle ? undefined : linkedHosts.get(handle)
|
|
178
|
+
const host = linkedHost ?? getHostFor(handle)
|
|
179
|
+
const maybeNode = host && getShadowNode(host)
|
|
223
180
|
|
|
224
|
-
if (
|
|
225
|
-
|
|
181
|
+
if (linkedHost) {
|
|
182
|
+
linkedHosts.delete(handle)
|
|
183
|
+
}
|
|
226
184
|
|
|
227
|
-
|
|
185
|
+
if (host && maybeNode) {
|
|
186
|
+
if (isHidden(host)) {
|
|
228
187
|
HybridShadowRegistry.suspend(maybeNode)
|
|
229
188
|
} else {
|
|
230
189
|
HybridShadowRegistry.unlink(maybeNode)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Scope } from '../../components/ScopedThemeContext'
|
|
2
|
+
import type { StyleSource } from '../../unifiber/src'
|
|
3
|
+
|
|
4
|
+
import { ScopedThemeContext } from '../../components/ScopedThemeContext'
|
|
5
|
+
|
|
6
|
+
type ScopedThemeAccess = {
|
|
7
|
+
get(): string | undefined
|
|
8
|
+
set(name: string | undefined): void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const createUnistylesStyleSource = (scopedTheme: ScopedThemeAccess) => {
|
|
12
|
+
let epoch = 0
|
|
13
|
+
let warned = false
|
|
14
|
+
|
|
15
|
+
const source: StyleSource = {
|
|
16
|
+
name: 'unistyles',
|
|
17
|
+
epoch: () => epoch,
|
|
18
|
+
contexts: [ScopedThemeContext],
|
|
19
|
+
contextKey: (_context, scope) => (scope as Scope | null)?.name,
|
|
20
|
+
resolve: (props, read) => {
|
|
21
|
+
try {
|
|
22
|
+
return resolveFresh(props, read(ScopedThemeContext))
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (!warned) {
|
|
25
|
+
warned = true
|
|
26
|
+
console.warn(`Unistyles: Could not refresh styles for a CSS transition. ${String(error)}`)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return undefined
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const resolveFresh = (props: Record<string, any>, scope: Scope | null | undefined) => {
|
|
35
|
+
const styles = [props.style].flat(Infinity)
|
|
36
|
+
const fresh: Record<string, unknown> = {}
|
|
37
|
+
let hasUnistyles = false
|
|
38
|
+
|
|
39
|
+
for (const style of styles) {
|
|
40
|
+
if (!style || typeof style !== 'object') {
|
|
41
|
+
continue
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Object.assign(fresh, style)
|
|
45
|
+
|
|
46
|
+
for (const key in style) {
|
|
47
|
+
if (!key.startsWith('unistyles_') || !Object.prototype.hasOwnProperty.call(style, key)) {
|
|
48
|
+
continue
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
hasUnistyles = true
|
|
52
|
+
|
|
53
|
+
const previousScopedTheme = scope ? scopedTheme.get() : undefined
|
|
54
|
+
|
|
55
|
+
if (scope) {
|
|
56
|
+
scopedTheme.set(scope.name)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
Object.assign(fresh, style[key]?.uni__getStyles?.())
|
|
61
|
+
} finally {
|
|
62
|
+
if (scope) {
|
|
63
|
+
scopedTheme.set(previousScopedTheme)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return hasUnistyles ? fresh : undefined
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
source,
|
|
74
|
+
bumpEpoch: () => {
|
|
75
|
+
epoch++
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// console.timeStamp(label, start, end, trackName), React Native 0.86+ reports it only while DevTools records and keeps
|
|
2
|
+
// nothing, unlike performance.measure, which adds every entry to an unbounded buffer
|
|
3
|
+
type TracingConsole = {
|
|
4
|
+
timeStamp?: (label: string, start: number, end: number, trackName: string) => void
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const tracingConsole = console as unknown as TracingConsole
|
|
8
|
+
const canTrace = __DEV__ && typeof tracingConsole.timeStamp === 'function'
|
|
9
|
+
|
|
10
|
+
// Slice on the "Unistyles" track of the React Native DevTools Performance panel, next to the native ones
|
|
11
|
+
export const traceSection = <T>(name: string, fn: () => T): T => {
|
|
12
|
+
if (!canTrace) {
|
|
13
|
+
return fn()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const start = performance.now()
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
return fn()
|
|
20
|
+
} finally {
|
|
21
|
+
tracingConsole.timeStamp?.(name, start, performance.now(), 'Unistyles')
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,48 +1,8 @@
|
|
|
1
|
-
export type
|
|
2
|
-
node?: ShadowNode
|
|
3
|
-
canonical?: {
|
|
4
|
-
nativeTag?: number
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type ShadowNode = {
|
|
9
|
-
__hostObjectShadowNodeWrapper: any
|
|
10
|
-
}
|
|
1
|
+
export type { ShadowNode } from '../../unifiber/src'
|
|
11
2
|
|
|
12
3
|
export type ViewHandle = {
|
|
13
|
-
__internalInstanceHandle?:
|
|
14
|
-
|
|
15
|
-
elementType?: string
|
|
16
|
-
}
|
|
17
|
-
getScrollResponder?: () => {
|
|
18
|
-
getNativeScrollRef?: () => {
|
|
19
|
-
__internalInstanceHandle?: {
|
|
20
|
-
stateNode?: StateNode
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
getNativeScrollRef?: () => {
|
|
25
|
-
__internalInstanceHandle?: {
|
|
26
|
-
stateNode?: StateNode
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
_viewRef?: {
|
|
30
|
-
__internalInstanceHandle?: {
|
|
31
|
-
stateNode?: StateNode
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
viewRef?: {
|
|
35
|
-
current?: {
|
|
36
|
-
__internalInstanceHandle?: {
|
|
37
|
-
stateNode?: StateNode
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
_nativeRef?: {
|
|
42
|
-
__internalInstanceHandle?: {
|
|
43
|
-
stateNode?: StateNode
|
|
44
|
-
}
|
|
45
|
-
}
|
|
4
|
+
__internalInstanceHandle?: unknown
|
|
5
|
+
constructor?: { name?: string }
|
|
46
6
|
}
|
|
47
7
|
|
|
48
8
|
export type Unistyle = {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jacek Pudysz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# unifiber
|
|
4
|
+
|
|
5
|
+
**One small, tested place for everything React Native styling libraries read from React's private fiber tree.**
|
|
6
|
+
|
|
7
|
+
Built for [Unistyles](https://github.com/jpudysz/react-native-unistyles) and Uniwind Pro.
|
|
8
|
+
|
|
9
|
+
`React 19` · `React Native 0.86 – 0.87` · `iOS + Android` · `Hermes-first` · `MIT`
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Why this exists
|
|
16
|
+
|
|
17
|
+
Unistyles and Uniwind both do something React Native doesn't officially support: they update the native shadow tree **without a React render**. Theme switches, breakpoints and insets reach native views in a single commit. To do that, both read React's private fiber fields: `__internalInstanceHandle`, `stateNode.node`, `memoizedState`, `return`, `alternate` and more.
|
|
18
|
+
|
|
19
|
+
Until now, each library kept its own copy of those reads. They drifted apart, and both had bugs that only show up on real apps.
|
|
20
|
+
|
|
21
|
+
unifiber is the one module that knows what a fiber looks like. It answers questions such as "which native view is this ref?", "is it hidden, and why?" and "what must refresh?". It's tested against **React Native's own components** and **Unistyles' real code**. A daily CI run against React Native nightly catches changes to React's internals before they ship.
|
|
22
|
+
|
|
23
|
+
## API
|
|
24
|
+
|
|
25
|
+
`Fiber` and `Reanimated` are plain objects. A **`Host`** is a native view's creation fiber behind an opaque type: free to keep, and stable, so the same view is always the same `Host` (`===` and `WeakMap` keys work).
|
|
26
|
+
|
|
27
|
+
### ref → Host
|
|
28
|
+
| | |
|
|
29
|
+
|---|---|
|
|
30
|
+
| `getHostFor(ref)` | Native-view refs, RN composites (ScrollView, FlatList / SectionList / VirtualizedList, ImageBackground, KeyboardAvoidingView, RefreshControl), and class components that render their view directly (Button on Android). Any other class component gives the first native view it renders, which may not be the one you styled. Call once per link and keep the result. |
|
|
31
|
+
| `getShadowNodeFor(ref)` | Hot path when you don't keep a Host. |
|
|
32
|
+
| `getHostForInstanceHandle(handle)` | For fibers handed back from C++ (`ShadowNodeFamily::getInstanceHandle`). |
|
|
33
|
+
| `getContentContainerFor(ref)` | ScrollView / list content container, through RN's public `getInnerViewRef()`. |
|
|
34
|
+
|
|
35
|
+
### Host → native
|
|
36
|
+
| | |
|
|
37
|
+
|---|---|
|
|
38
|
+
| `getShadowNode(host)` | The node in React's `stateNode.node` wrapper. |
|
|
39
|
+
| `getShadowNodes(host, out?)` | Every node React may diff against or re-attach: one after a commit, two while a render is in flight. |
|
|
40
|
+
| `getNativeTag(host)` | `undefined` once the view has unmounted. |
|
|
41
|
+
| `getParentHost(host)` | The nearest native view above (ActivityIndicator's wrapper, on both platforms). |
|
|
42
|
+
| `patchRenderedProps(host, patch)` | Replaces React's diff baseline on both halves. **The only write**, used by Uniwind's baseline. |
|
|
43
|
+
|
|
44
|
+
### Hidden state
|
|
45
|
+
| | |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `isHidden(host)` | Inside a Suspense fallback, a frozen screen or a hidden `<Activity>`: suspend instead of unlinking. Also right inside a ref cleanup, where React has not switched the committed tree yet. |
|
|
48
|
+
| `isSuspended` · `isFrozen` · `isInHiddenActivity` | Why. Frozen means react-freeze (react-native-screens `freezeOnBlur`, react-navigation). |
|
|
49
|
+
| `collectVisibleAncestors(hosts, visit)` | Batch refresh. Each visible native view from `hosts` up to the root, visited once, in one shared pass. |
|
|
50
|
+
| `collectAncestors(hosts, visit)` | The same walk, with hidden views included. These are the semantics of Uniwind's `collectHostNodes` today. |
|
|
51
|
+
|
|
52
|
+
### Diagnostics
|
|
53
|
+
| | |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `verify(host, expected)` | Style keys React would re-send, i.e. undo, on this view's next render. |
|
|
56
|
+
| `getOwners(host)` | *Development builds only:* the components that created the view, e.g. `['ProfileCard', 'ProfileScreen']`. |
|
|
57
|
+
| `getCreationStack(host)` | *Development builds only:* where the JSX was written, for Metro to symbolicate. |
|
|
58
|
+
|
|
59
|
+
### Adapters: when a 3rd-party component owns the view
|
|
60
|
+
Reanimated's `AnimatedComponent` keeps its own copy of a view's style for CSS transitions, so a native-only theme change gets overridden. The adapter keeps that copy in sync, so the theme change **animates** instead.
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
const owners = Fiber.createOwnerRegistry({
|
|
64
|
+
name: 'unistyles',
|
|
65
|
+
epoch: () => themeVersion, // bump on every runtime change
|
|
66
|
+
contexts: [ScopedThemeContext],
|
|
67
|
+
contextKey: (_ctx, scope) => scope?.name, // stable scopes are renamed in place
|
|
68
|
+
resolve: (props, read) => freshStyles(props, read(ScopedThemeContext)),
|
|
69
|
+
}, [Reanimated.cssAdapter], warnOnce)
|
|
70
|
+
|
|
71
|
+
owners.link(host) // in the link path: ~86 ns for a plain view
|
|
72
|
+
owners.refresh(hosts) // after a native-only update
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Hidden views (a frozen screen, Suspense, a hidden `<Activity>`) are refreshed too, so a transition-only view shows the new value when it's revealed. **Trade-off:** a view that also has a keyframe animation (`animation*` keys) or pseudo-style values isn't refreshed while hidden. After it's revealed, it transitions from the pre-hide value to the new one, then settles correctly. Reanimated registers animations and pseudo-styles again on update, and React runs no `componentWillUnmount` for a subtree deleted while hidden, so refreshing them would leak.
|
|
76
|
+
|
|
77
|
+
An adapter that throws is switched off for the session and reported once. Private Reanimated fields are pinned by a contract test against the 4.5.1 and 4.7.0 sources.
|
|
78
|
+
|
|
79
|
+
## Compatibility
|
|
80
|
+
|
|
81
|
+
| | |
|
|
82
|
+
|---|---|
|
|
83
|
+
| React | 19.2, and 19.3.1 with RN nightly (fiber tags pinned for 19.x) |
|
|
84
|
+
| React Native | 0.87.1, 0.86.3 · iOS, Android · development and production. CI also runs React Native **nightly** (main) every day; 0.89.0-nightly-20261016 passes |
|
|
85
|
+
| Reanimated | 4.5.1, 4.7.0 |
|
|
86
|
+
| Unistyles | 3.5.3 and `main` (its real code runs in the suite) |
|
|
87
|
+
| Uniwind | its lookups copied verbatim into the suite |
|
|
88
|
+
| Engine | Hermes (legacy Hermes benchmarked) |
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT
|