react-native-unistyles 3.5.2 → 3.6.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 +3 -0
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +44 -7
- package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +1 -1
- package/cxx/converters/BackgroundImageConverter.cpp +198 -11
- package/cxx/converters/BackgroundImageConverter.h +1 -0
- package/cxx/core/HostUnistyle.cpp +6 -0
- package/cxx/core/UnistylesRegistry.cpp +5 -5
- package/cxx/core/UnistylesRegistry.h +3 -3
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +53 -14
- package/cxx/hybridObjects/HybridShadowRegistry.h +3 -2
- package/cxx/hybridObjects/HybridStyleSheet.cpp +3 -3
- package/cxx/parser/Parser.cpp +47 -9
- package/cxx/shadowTree/ShadowTreeManager.cpp +5 -5
- package/cxx/shadowTree/ShadowTreeManager.h +1 -1
- package/ios/NativePlatform+ios.swift +28 -15
- package/ios/NativePlatformListener+ios.swift +9 -0
- 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 +20 -17
- 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/useProxifiedUnistyles/useProxifiedUnistyles.js +10 -0
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +16 -15
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +86 -110
- 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/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/web/css/core.js +30 -5
- package/lib/commonjs/web/css/core.js.map +1 -1
- package/lib/commonjs/web/css/state.js +4 -1
- package/lib/commonjs/web/css/state.js.map +1 -1
- package/lib/commonjs/web/registry.js +1 -1
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +11 -3
- package/lib/commonjs/web/utils/unistyle.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 +20 -17
- 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/useProxifiedUnistyles/useProxifiedUnistyles.js +10 -0
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.native.js +14 -14
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +86 -110
- 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/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/web/css/core.js +28 -4
- package/lib/module/web/css/core.js.map +1 -1
- package/lib/module/web/css/state.js +5 -2
- package/lib/module/web/css/state.js.map +1 -1
- package/lib/module/web/registry.js +1 -1
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +11 -3
- package/lib/module/web/utils/unistyle.js.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/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts +6 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +2 -2
- 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/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/web/css/core.d.ts +1 -0
- package/lib/typescript/src/web/css/core.d.ts.map +1 -1
- package/lib/typescript/src/web/css/state.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/metro/babel-transformer.js +1040 -0
- package/metro/index.d.ts +31 -0
- package/metro/index.js +170 -0
- package/package.json +26 -8
- package/plugin/index.d.ts +7 -0
- package/plugin/index.js +36 -16
- 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 +27 -23
- package/src/core/createUnistylesTouchableHighlight.tsx +5 -0
- package/src/core/getClassname.ts +10 -1
- package/src/core/hasUnistyles.ts +20 -0
- package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +11 -0
- package/src/core/withUnistyles/withUnistyles.native.tsx +22 -25
- package/src/specs/ShadowRegistry/index.ts +87 -149
- package/src/specs/ShadowRegistry/styleSource.ts +78 -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/web/css/core.ts +29 -4
- package/src/web/css/state.ts +6 -2
- package/src/web/registry.ts +1 -1
- package/src/web/utils/unistyle.ts +12 -3
- 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-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-runtime.spec.d.ts +0 -2
- package/lib/typescript/src/__tests__/web-runtime.spec.d.ts.map +0 -1
|
@@ -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
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// Keeps Reanimated's CSS style copy (`_cssStyle`) in sync with native-only style updates.
|
|
2
|
+
// Private fields are pinned by test/reanimated-contract.test.ts for 4.5 and 4.7.
|
|
3
|
+
import type { Host } from '../host'
|
|
4
|
+
import type { OwnerAdapter, StyleSource } from './registry'
|
|
5
|
+
import * as fiber from '../fiber'
|
|
6
|
+
|
|
7
|
+
// Bound once: Metro's inline requires
|
|
8
|
+
const { contextReaderFor } = fiber
|
|
9
|
+
const CLASS_COMPONENT = fiber.Tag.ClassComponent
|
|
10
|
+
|
|
11
|
+
type CSSManagerLike = { update(style: Record<string, unknown>, props?: Record<string, unknown>): void }
|
|
12
|
+
|
|
13
|
+
type AnimatedComponentLike = {
|
|
14
|
+
props: Record<string, any>
|
|
15
|
+
_cssStyle: Record<string, unknown>
|
|
16
|
+
_CSSManager?: CSSManagerLike
|
|
17
|
+
// true between componentWillUnmount and componentDidMount: also while frozen, suspended or in a hidden Activity
|
|
18
|
+
_willUnmount?: boolean
|
|
19
|
+
_updateStyles(props: Record<string, any>): void
|
|
20
|
+
shouldComponentUpdate(nextProps: Record<string, any>, ...rest: Array<unknown>): boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type AttachedState = {
|
|
24
|
+
source: StyleSource
|
|
25
|
+
original: (props: Record<string, any>) => void
|
|
26
|
+
originalShouldUpdate: AnimatedComponentLike['shouldComponentUpdate']
|
|
27
|
+
rendering: boolean
|
|
28
|
+
styleProp: unknown
|
|
29
|
+
epoch: number
|
|
30
|
+
contextKeys: Array<unknown>
|
|
31
|
+
fresh: Record<string, unknown> | undefined
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Symbol.for: two copies of unifiber in one bundle never wrap a component twice
|
|
35
|
+
const STATE = Symbol.for('unifiber.reanimated.css')
|
|
36
|
+
|
|
37
|
+
// Kept out of AnimatedComponentLike: a unique symbol in a public type breaks consumers' declaration builds (TS4023)
|
|
38
|
+
type Attached = AnimatedComponentLike & { [STATE]?: AttachedState }
|
|
39
|
+
|
|
40
|
+
const hasCSSConfig = (cssStyle: Record<string, unknown>) => {
|
|
41
|
+
for (const key in cssStyle) {
|
|
42
|
+
if (key.startsWith('transition') || key.startsWith('animation')) {
|
|
43
|
+
return true
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Keyframe animations and pseudo-styles register again on update after componentWillUnmount cleaned them up.
|
|
51
|
+
// React runs no componentWillUnmount for a subtree deleted while hidden, so on a hidden owner they would leak.
|
|
52
|
+
const registersOnUpdate = (cssStyle: Record<string, unknown>) => {
|
|
53
|
+
for (const key in cssStyle) {
|
|
54
|
+
if (key.startsWith('animation')) {
|
|
55
|
+
return true
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const value = cssStyle[key]
|
|
59
|
+
|
|
60
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
61
|
+
for (const selector in value) {
|
|
62
|
+
if (selector === 'default' || selector.startsWith(':')) {
|
|
63
|
+
return true
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
break
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return false
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Deepest case: ScrollView with refreshControl on Android, 6-7 fibers
|
|
75
|
+
const MAX_OWNER_DEPTH = 12
|
|
76
|
+
|
|
77
|
+
// The class whose `_componentRef` is this host's public instance. Lists don't match: their ref isn't a host.
|
|
78
|
+
export const animatedComponentOf = (host: Host | null | undefined): AnimatedComponentLike | null => {
|
|
79
|
+
const fiber = host as any
|
|
80
|
+
|
|
81
|
+
if (fiber?.memoizedProps?.collapsable !== false) {
|
|
82
|
+
return null
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const publicInstance = fiber.stateNode?.canonical?.publicInstance
|
|
86
|
+
|
|
87
|
+
if (!publicInstance) {
|
|
88
|
+
return null
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let current = fiber.return
|
|
92
|
+
|
|
93
|
+
for (let depth = 0; current && depth < MAX_OWNER_DEPTH; depth++) {
|
|
94
|
+
if (current.tag === CLASS_COMPONENT && current.stateNode?._componentRef === publicInstance) {
|
|
95
|
+
return isAnimatedComponent(current.stateNode) ? current.stateNode : null
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
current = current.return
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return null
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const isAnimatedComponent = (owner: any): owner is AnimatedComponentLike =>
|
|
105
|
+
typeof owner?._updateStyles === 'function' &&
|
|
106
|
+
typeof owner.shouldComponentUpdate === 'function' &&
|
|
107
|
+
owner._cssStyle !== null &&
|
|
108
|
+
typeof owner._cssStyle === 'object'
|
|
109
|
+
|
|
110
|
+
function updateStylesThroughSource(this: Attached, props: Record<string, any>) {
|
|
111
|
+
const state = this[STATE]!
|
|
112
|
+
|
|
113
|
+
state.original.call(this, props)
|
|
114
|
+
|
|
115
|
+
if (!hasCSSConfig(this._cssStyle)) {
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const epoch = state.source.epoch()
|
|
120
|
+
const read = contextReaderFor(this, state.rendering)
|
|
121
|
+
const contexts = state.source.contexts ?? []
|
|
122
|
+
let contextChanged = false
|
|
123
|
+
|
|
124
|
+
for (let i = 0; i < contexts.length; i++) {
|
|
125
|
+
const context = contexts[i]!
|
|
126
|
+
const value = read(context)
|
|
127
|
+
const key = state.source.contextKey ? state.source.contextKey(context, value) : value
|
|
128
|
+
|
|
129
|
+
if (state.contextKeys[i] !== key) {
|
|
130
|
+
state.contextKeys[i] = key
|
|
131
|
+
contextChanged = true
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (contextChanged || state.styleProp !== props.style || state.epoch !== epoch) {
|
|
136
|
+
state.fresh = state.source.resolve(props, read)
|
|
137
|
+
state.styleProp = props.style
|
|
138
|
+
state.epoch = epoch
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const fresh = state.fresh
|
|
142
|
+
|
|
143
|
+
if (!fresh) {
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// only the keys Reanimated kept: animated styles were split out of _cssStyle
|
|
148
|
+
for (const key in this._cssStyle) {
|
|
149
|
+
if (key in fresh) {
|
|
150
|
+
this._cssStyle[key] = fresh[key]
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Marks the render phase, where context must be read from React's stack
|
|
156
|
+
function shouldUpdateMarkingRender(this: Attached, ...args: [Record<string, any>, ...Array<unknown>]) {
|
|
157
|
+
const state = this[STATE]!
|
|
158
|
+
|
|
159
|
+
state.rendering = true
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
return state.originalShouldUpdate.apply(this, args)
|
|
163
|
+
} finally {
|
|
164
|
+
state.rendering = false
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export const reanimatedCSSAdapter: OwnerAdapter<AnimatedComponentLike> = {
|
|
169
|
+
name: 'react-native-reanimated/css',
|
|
170
|
+
gate: (host: Host) => (host as unknown as fiber.RawFiber).memoizedProps?.collapsable === false,
|
|
171
|
+
claim: animatedComponentOf,
|
|
172
|
+
attach: (owner: Attached, source) => {
|
|
173
|
+
if (owner[STATE]) {
|
|
174
|
+
return
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
owner[STATE] = {
|
|
178
|
+
source,
|
|
179
|
+
original: owner._updateStyles,
|
|
180
|
+
originalShouldUpdate: owner.shouldComponentUpdate,
|
|
181
|
+
rendering: false,
|
|
182
|
+
styleProp: undefined,
|
|
183
|
+
epoch: -1,
|
|
184
|
+
contextKeys: [],
|
|
185
|
+
fresh: undefined,
|
|
186
|
+
}
|
|
187
|
+
owner._updateStyles = updateStylesThroughSource
|
|
188
|
+
owner.shouldComponentUpdate = shouldUpdateMarkingRender
|
|
189
|
+
},
|
|
190
|
+
refresh: (owner) => {
|
|
191
|
+
// not mounted yet
|
|
192
|
+
if (typeof owner._CSSManager?.update !== 'function') {
|
|
193
|
+
return
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Hidden transitions still run, so the reveal shows the new value instead of animating from the old one
|
|
197
|
+
if (owner._willUnmount === true && registersOnUpdate(owner._cssStyle)) {
|
|
198
|
+
return
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
owner._updateStyles(owner.props)
|
|
202
|
+
owner._CSSManager.update(owner._cssStyle, owner.props)
|
|
203
|
+
},
|
|
204
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { Context } from 'react'
|
|
2
|
+
import type { ContextReader } from '../fiber'
|
|
3
|
+
import type { Host } from '../host'
|
|
4
|
+
|
|
5
|
+
export interface StyleSource {
|
|
6
|
+
readonly name: string
|
|
7
|
+
// bumps on every runtime change (theme, breakpoint, ...)
|
|
8
|
+
epoch(): number
|
|
9
|
+
readonly contexts?: ReadonlyArray<Context<any>>
|
|
10
|
+
// cache key for a context value; default: the value itself. Stable scopes renamed in place need `scope?.name`
|
|
11
|
+
contextKey?(context: Context<any>, value: unknown): unknown
|
|
12
|
+
// undefined: none of these styles belong to this source
|
|
13
|
+
resolve(props: Record<string, any>, read: ContextReader): Record<string, unknown> | undefined
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface OwnerAdapter<Owner extends object = object> {
|
|
17
|
+
readonly name: string
|
|
18
|
+
// runs on every link: keep it to a property read or two
|
|
19
|
+
gate(host: Host): boolean
|
|
20
|
+
claim(host: Host): Owner | null
|
|
21
|
+
attach(owner: Owner, source: StyleSource): void
|
|
22
|
+
// runs for hidden owners too (frozen, suspended, hidden Activity): skip there what can't run while hidden
|
|
23
|
+
refresh(owner: Owner, source: StyleSource): void
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type OwnerRegistry = {
|
|
27
|
+
link(host: Host | null | undefined): void
|
|
28
|
+
refresh(hosts: ReadonlyArray<Host | null | undefined>): void
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// An adapter that throws is disabled for the session and reported once
|
|
32
|
+
export const createOwnerRegistry = (
|
|
33
|
+
source: StyleSource,
|
|
34
|
+
adapters: ReadonlyArray<OwnerAdapter<any>>,
|
|
35
|
+
onAdapterError?: (reason: string) => void,
|
|
36
|
+
): OwnerRegistry => {
|
|
37
|
+
const disabledAdapters = new Set<OwnerAdapter>()
|
|
38
|
+
const disable = (adapter: OwnerAdapter, error: unknown) => {
|
|
39
|
+
disabledAdapters.add(adapter)
|
|
40
|
+
onAdapterError?.(`adapter ${adapter.name} failed: ${String(error)}`)
|
|
41
|
+
}
|
|
42
|
+
// Not inline closures: a closure in link() makes Hermes allocate its environment on every call
|
|
43
|
+
const attachOwner = (adapter: OwnerAdapter, host: Host) => {
|
|
44
|
+
try {
|
|
45
|
+
const owner = adapter.claim(host)
|
|
46
|
+
|
|
47
|
+
if (owner) {
|
|
48
|
+
adapter.attach(owner, source)
|
|
49
|
+
}
|
|
50
|
+
} catch (error) {
|
|
51
|
+
disable(adapter, error)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const refreshOwner = (adapter: OwnerAdapter, host: Host, seen: Set<object>) => {
|
|
55
|
+
try {
|
|
56
|
+
const owner = adapter.claim(host)
|
|
57
|
+
|
|
58
|
+
if (owner && !seen.has(owner)) {
|
|
59
|
+
seen.add(owner)
|
|
60
|
+
adapter.attach(owner, source)
|
|
61
|
+
adapter.refresh(owner, source)
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {
|
|
64
|
+
disable(adapter, error)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
link(host) {
|
|
70
|
+
if (!host) {
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
for (let i = 0; i < adapters.length; i++) {
|
|
75
|
+
const adapter = adapters[i]!
|
|
76
|
+
|
|
77
|
+
if (adapter.gate(host) && !disabledAdapters.has(adapter)) {
|
|
78
|
+
attachOwner(adapter, host)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
refresh(hosts) {
|
|
83
|
+
const seen = new Set<object>()
|
|
84
|
+
|
|
85
|
+
for (let h = 0; h < hosts.length; h++) {
|
|
86
|
+
const host = hosts[h]
|
|
87
|
+
|
|
88
|
+
if (!host) {
|
|
89
|
+
continue
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
for (let i = 0; i < adapters.length; i++) {
|
|
93
|
+
const adapter = adapters[i]!
|
|
94
|
+
|
|
95
|
+
if (adapter.gate(host) && !disabledAdapters.has(adapter)) {
|
|
96
|
+
refreshOwner(adapter, host, seen)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { RawFiber } from './fiber'
|
|
2
|
+
import type { Host } from './host'
|
|
3
|
+
import * as host from './host'
|
|
4
|
+
|
|
5
|
+
// Bound once: Metro's inline requires
|
|
6
|
+
const { committedHalf, fiberOf } = host
|
|
7
|
+
|
|
8
|
+
const styleDiffers = (a: RawFiber, b: RawFiber) => a.memoizedProps?.style !== b.memoizedProps?.style
|
|
9
|
+
|
|
10
|
+
const flattenInto = (style: unknown, out: Record<string, unknown>) => {
|
|
11
|
+
if (Array.isArray(style)) {
|
|
12
|
+
for (let i = 0; i < style.length; i++) {
|
|
13
|
+
flattenInto(style[i], out)
|
|
14
|
+
}
|
|
15
|
+
} else if (style && typeof style === 'object') {
|
|
16
|
+
Object.assign(out, style)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return out
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type Drift = { key: string; react: unknown; expected: unknown }
|
|
23
|
+
|
|
24
|
+
// Keys that differ from React's committed props: React re-sends them on the view's next render
|
|
25
|
+
export const verify = (host: Host, expected: Record<string, unknown>): Array<Drift> => {
|
|
26
|
+
const baseline = committedHalf(fiberOf(host), styleDiffers) ?? fiberOf(host)
|
|
27
|
+
const react = flattenInto(baseline.memoizedProps?.style, {})
|
|
28
|
+
const drift: Array<Drift> = []
|
|
29
|
+
|
|
30
|
+
for (const key in expected) {
|
|
31
|
+
if (react[key] !== expected[key]) {
|
|
32
|
+
drift.push({ key, react: react[key], expected: expected[key] })
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return drift
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Development builds only
|
|
40
|
+
export const getOwners = (host: Host, max = 8): Array<string> => {
|
|
41
|
+
const owners: Array<string> = []
|
|
42
|
+
|
|
43
|
+
for (let owner = fiberOf(host)._debugOwner; owner && owners.length < max; owner = owner._debugOwner ?? owner.owner) {
|
|
44
|
+
const name = owner.name ?? owner.type?.displayName ?? owner.type?.name ?? owner.type?.render?.name
|
|
45
|
+
|
|
46
|
+
if (name) {
|
|
47
|
+
owners.push(name)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return owners
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Development builds only
|
|
55
|
+
export const getCreationStack = (host: Host): string | undefined => fiberOf(host)._debugStack?.stack
|