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
|
@@ -5,137 +5,107 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.UnistylesShadowRegistry = void 0;
|
|
7
7
|
var _reactNativeNitroModules = require("react-native-nitro-modules");
|
|
8
|
+
var _src = require("../../unifiber/src");
|
|
8
9
|
var _StyleSheet = require("../StyleSheet");
|
|
10
|
+
var _styleSource = require("./styleSource");
|
|
9
11
|
const HybridShadowRegistry = _reactNativeNitroModules.NitroModules.createHybridObject('UnistylesShadowRegistry');
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// @ts-ignore we don't know the type of handle
|
|
30
|
-
if (!node && handle?.props?.horizontal && handle?.constructor?.name === 'FlatList') {
|
|
31
|
-
throw new Error('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');
|
|
32
|
-
}
|
|
33
|
-
return node;
|
|
34
|
-
};
|
|
35
|
-
const getNativeTag = handle => findFiberForHandle(handle)?.stateNode?.canonical?.nativeTag;
|
|
36
|
-
|
|
37
|
-
// by native tag, weak: views unmounted while frozen never unlink, their dead refs are dropped when the map doubles
|
|
38
|
-
const linkedHandles = new Map();
|
|
39
|
-
const MIN_SWEEP_SIZE = 256;
|
|
40
|
-
let sweepSize = MIN_SWEEP_SIZE;
|
|
41
|
-
const sweepUnmountedHandles = () => {
|
|
42
|
-
linkedHandles.forEach((ref, tag) => {
|
|
43
|
-
if (!ref.deref()) {
|
|
44
|
-
linkedHandles.delete(tag);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
sweepSize = Math.max(MIN_SWEEP_SIZE, linkedHandles.size * 2);
|
|
48
|
-
};
|
|
49
|
-
const trackHandle = handle => {
|
|
50
|
-
const tag = getNativeTag(handle);
|
|
12
|
+
const {
|
|
13
|
+
collectVisibleAncestors,
|
|
14
|
+
getHostFor,
|
|
15
|
+
getHostForInstanceHandle,
|
|
16
|
+
getShadowNode,
|
|
17
|
+
getShadowNodes,
|
|
18
|
+
isHidden
|
|
19
|
+
} = _src.Fiber;
|
|
20
|
+
const {
|
|
21
|
+
source: styleSource,
|
|
22
|
+
bumpEpoch
|
|
23
|
+
} = (0, _styleSource.createUnistylesStyleSource)({
|
|
24
|
+
get: () => HybridShadowRegistry.getScopedTheme(),
|
|
25
|
+
set: name => HybridShadowRegistry.setScopedTheme(name)
|
|
26
|
+
});
|
|
27
|
+
const owners = _src.Fiber.createOwnerRegistry(styleSource, [_src.Reanimated.cssAdapter], reason => {
|
|
28
|
+
console.warn(`Unistyles: ${reason}. CSS transitions won't follow theme changes.`);
|
|
29
|
+
});
|
|
51
30
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const untrackHandle = handle => {
|
|
62
|
-
const tag = getNativeTag(handle);
|
|
63
|
-
if (tag !== undefined && linkedHandles.get(tag)?.deref() === handle) {
|
|
64
|
-
linkedHandles.delete(tag);
|
|
65
|
-
}
|
|
31
|
+
// A component can point at another native view by the time its ref is cleaned up, eg. FlatList on Android remounts
|
|
32
|
+
// its native ScrollView when `horizontal` changes, so remove unlinks the view it was linked with
|
|
33
|
+
// The host points at its current node, while a stored node would keep its first revision (and children) alive
|
|
34
|
+
// Native views always resolve to their own host, so they skip it
|
|
35
|
+
const linkedHosts = new WeakMap();
|
|
36
|
+
const committedHosts = [];
|
|
37
|
+
let refreshNodes = [];
|
|
38
|
+
const collectShadowNodes = host => {
|
|
39
|
+
getShadowNodes(host, refreshNodes);
|
|
66
40
|
};
|
|
67
41
|
|
|
68
42
|
// React re-attaches an untouched subtree through its root's node and only follows clones made on the JS thread.
|
|
69
43
|
// Once a node was cloned elsewhere (state updates, Reanimated), React would commit a subtree from before a Unistyles
|
|
70
44
|
// update, so after a Unistyles commit the committed nodes and their host ancestors must point at the committed tree
|
|
71
45
|
const refreshReactNodes = () => {
|
|
72
|
-
|
|
73
|
-
|
|
46
|
+
bumpEpoch();
|
|
47
|
+
const handles = HybridShadowRegistry.takeCommittedInstanceHandles();
|
|
48
|
+
if (handles.length === 0) {
|
|
74
49
|
return;
|
|
75
50
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const handle = linkedHandles.get(tag)?.deref();
|
|
80
|
-
if (!handle) {
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
const fiber = findFiberForHandle(handle);
|
|
84
|
-
|
|
85
|
-
// hidden by Suspense or a frozen screen
|
|
86
|
-
if (!fiber || isInsideSuspendedBoundary(fiber)) {
|
|
87
|
-
continue;
|
|
51
|
+
try {
|
|
52
|
+
for (let i = 0; i < handles.length; i++) {
|
|
53
|
+
committedHosts[i] = getHostForInstanceHandle(handles[i]);
|
|
88
54
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
visited.add(current.alternate);
|
|
93
|
-
}
|
|
94
|
-
if (current.tag !== HOST_COMPONENT_TAG) {
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
for (const target of [current, current.alternate]) {
|
|
98
|
-
const node = target?.stateNode?.node;
|
|
99
|
-
if (node) {
|
|
100
|
-
nodes.add(node);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
55
|
+
collectVisibleAncestors(committedHosts, collectShadowNodes);
|
|
56
|
+
if (refreshNodes.length > 0) {
|
|
57
|
+
HybridShadowRegistry.refreshReactNodes(refreshNodes);
|
|
103
58
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
59
|
+
owners.refresh(committedHosts);
|
|
60
|
+
} finally {
|
|
61
|
+
committedHosts.length = 0;
|
|
62
|
+
refreshNodes = [];
|
|
107
63
|
}
|
|
108
64
|
};
|
|
109
65
|
_StyleSheet.StyleSheet.addChangeListener(refreshReactNodes);
|
|
110
66
|
|
|
111
|
-
//
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
67
|
+
// skips empty styles and splits a style merged from many unistyles (eg. flattened by Animated) into one per unistyle
|
|
68
|
+
// runs for every style on every link, so it reads the keys once and allocates only for the rare merged style
|
|
69
|
+
const collectStyle = (style, collected) => {
|
|
70
|
+
if (!style) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const keys = Object.keys(style);
|
|
74
|
+
let unistylesCount = 0;
|
|
75
|
+
for (const key of keys) {
|
|
76
|
+
if (key.startsWith('unistyles_')) {
|
|
77
|
+
unistylesCount++;
|
|
117
78
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
79
|
+
}
|
|
80
|
+
if (unistylesCount < 2) {
|
|
81
|
+
if (keys.length > 0) {
|
|
82
|
+
collected.push(style);
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
for (const key of keys) {
|
|
87
|
+
if (key.startsWith('unistyles_')) {
|
|
88
|
+
collected.push({
|
|
89
|
+
[key]: style[key]
|
|
90
|
+
});
|
|
122
91
|
}
|
|
123
|
-
hasUnistyle = true;
|
|
124
92
|
}
|
|
125
|
-
return style;
|
|
126
93
|
};
|
|
127
94
|
HybridShadowRegistry.add = (handle, styles, scope) => {
|
|
128
95
|
// virtualized nodes can be null
|
|
129
96
|
if (!handle || !styles) {
|
|
130
97
|
return;
|
|
131
98
|
}
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
99
|
+
const filteredStyles = [];
|
|
100
|
+
if (Array.isArray(styles)) {
|
|
101
|
+
styles.flat(Infinity).forEach(style => collectStyle(style, filteredStyles));
|
|
102
|
+
} else {
|
|
103
|
+
collectStyle(styles, filteredStyles);
|
|
104
|
+
}
|
|
136
105
|
if (filteredStyles.length > 0) {
|
|
137
|
-
const
|
|
138
|
-
|
|
106
|
+
const host = getHostFor(handle);
|
|
107
|
+
const node = host && getShadowNode(host);
|
|
108
|
+
if (!host || !node) {
|
|
139
109
|
throw new Error(`Unistyles: Could not find shadow node for one of your components of type ${handle?.constructor?.name ?? 'unknown'}`);
|
|
140
110
|
}
|
|
141
111
|
|
|
@@ -145,24 +115,30 @@ HybridShadowRegistry.add = (handle, styles, scope) => {
|
|
|
145
115
|
HybridShadowRegistry.setScopedTheme(scope.name);
|
|
146
116
|
}
|
|
147
117
|
HybridShadowRegistry.link(node, filteredStyles);
|
|
118
|
+
owners.link(host);
|
|
119
|
+
if (!handle.__internalInstanceHandle) {
|
|
120
|
+
linkedHosts.set(handle, host);
|
|
121
|
+
}
|
|
148
122
|
if (scope) {
|
|
149
123
|
HybridShadowRegistry.setScopedTheme(previousScopedTheme);
|
|
150
124
|
}
|
|
151
|
-
trackHandle(handle);
|
|
152
125
|
}
|
|
153
126
|
};
|
|
154
127
|
HybridShadowRegistry.remove = handle => {
|
|
155
128
|
if (!handle) {
|
|
156
129
|
return;
|
|
157
130
|
}
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
131
|
+
const linkedHost = handle.__internalInstanceHandle ? undefined : linkedHosts.get(handle);
|
|
132
|
+
const host = linkedHost ?? getHostFor(handle);
|
|
133
|
+
const maybeNode = host && getShadowNode(host);
|
|
134
|
+
if (linkedHost) {
|
|
135
|
+
linkedHosts.delete(handle);
|
|
136
|
+
}
|
|
137
|
+
if (host && maybeNode) {
|
|
138
|
+
if (isHidden(host)) {
|
|
162
139
|
HybridShadowRegistry.suspend(maybeNode);
|
|
163
140
|
} else {
|
|
164
141
|
HybridShadowRegistry.unlink(maybeNode);
|
|
165
|
-
untrackHandle(handle);
|
|
166
142
|
}
|
|
167
143
|
}
|
|
168
144
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativeNitroModules","require","
|
|
1
|
+
{"version":3,"names":["_reactNativeNitroModules","require","_src","_StyleSheet","_styleSource","HybridShadowRegistry","NitroModules","createHybridObject","collectVisibleAncestors","getHostFor","getHostForInstanceHandle","getShadowNode","getShadowNodes","isHidden","Fiber","source","styleSource","bumpEpoch","createUnistylesStyleSource","get","getScopedTheme","set","name","setScopedTheme","owners","createOwnerRegistry","Reanimated","cssAdapter","reason","console","warn","linkedHosts","WeakMap","committedHosts","refreshNodes","collectShadowNodes","host","refreshReactNodes","handles","takeCommittedInstanceHandles","length","i","refresh","StyleSheet","addChangeListener","collectStyle","style","collected","keys","Object","unistylesCount","key","startsWith","push","add","handle","styles","scope","filteredStyles","Array","isArray","flat","Infinity","forEach","node","Error","constructor","previousScopedTheme","undefined","link","__internalInstanceHandle","remove","linkedHost","maybeNode","delete","suspend","unlink","UnistylesShadowRegistry","exports"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAQA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAkBA,MAAMI,oBAAoB,GAAGC,qCAAY,CAACC,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAM;EAAEC,uBAAuB;EAAEC,UAAU;EAAEC,wBAAwB;EAAEC,aAAa;EAAEC,cAAc;EAAEC;AAAS,CAAC,GAAGC,UAAK;AAExH,MAAM;EAAEC,MAAM,EAAEC,WAAW;EAAEC;AAAU,CAAC,GAAG,IAAAC,uCAA0B,EAAC;EAClEC,GAAG,EAAEA,CAAA,KAAMd,oBAAoB,CAACe,cAAc,CAAC,CAAC;EAChDC,GAAG,EAAGC,IAAI,IAAKjB,oBAAoB,CAACkB,cAAc,CAACD,IAAI;AAC3D,CAAC,CAAC;AACF,MAAME,MAAM,GAAGV,UAAK,CAACW,mBAAmB,CAACT,WAAW,EAAE,CAACU,eAAU,CAACC,UAAU,CAAC,EAAGC,MAAM,IAAK;EACvFC,OAAO,CAACC,IAAI,CAAC,cAAcF,MAAM,+CAA+C,CAAC;AACrF,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA,MAAMG,WAAW,GAAG,IAAIC,OAAO,CAAe,CAAC;AAE/C,MAAMC,cAAuC,GAAG,EAAE;AAClD,IAAIC,YAA+B,GAAG,EAAE;AAExC,MAAMC,kBAAkB,GAAIC,IAAU,IAAK;EACvCxB,cAAc,CAACwB,IAAI,EAAEF,YAAY,CAAC;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EAAEN,cAAc,CAAC;IAC/ClC,MAAM,CAAC6C,IAAI,CAACjC,IAAI,CAAC;IAEjB,IAAI,CAACmB,MAAM,CAACe,wBAAwB,EAAE;MAClCvC,WAAW,CAACV,GAAG,CAACkC,MAAM,EAAEnB,IAAI,CAAC;IACjC;IAEA,IAAIqB,KAAK,EAAE;MACPpD,oBAAoB,CAACkB,cAAc,CAAC4C,mBAAmB,CAAC;IAC5D;EACJ;AACJ,CAAC;AAED9D,oBAAoB,CAACkE,MAAM,GAAIhB,MAAM,IAAK;EACtC,IAAI,CAACA,MAAM,EAAE;IACT;EACJ;EAEA,MAAMiB,UAAU,GAAGjB,MAAM,CAACe,wBAAwB,GAAGF,SAAS,GAAGrC,WAAW,CAACZ,GAAG,CAACoC,MAAM,CAAC;EACxF,MAAMnB,IAAI,GAAGoC,UAAU,IAAI/D,UAAU,CAAC8C,MAAM,CAAC;EAC7C,MAAMkB,SAAS,GAAGrC,IAAI,IAAIzB,aAAa,CAACyB,IAAI,CAAC;EAE7C,IAAIoC,UAAU,EAAE;IACZzC,WAAW,CAAC2C,MAAM,CAACnB,MAAM,CAAC;EAC9B;EAEA,IAAInB,IAAI,IAAIqC,SAAS,EAAE;IACnB,IAAI5D,QAAQ,CAACuB,IAAI,CAAC,EAAE;MAChB/B,oBAAoB,CAACsE,OAAO,CAACF,SAAS,CAAC;IAC3C,CAAC,MAAM;MACHpE,oBAAoB,CAACuE,MAAM,CAACH,SAAS,CAAC;IAC1C;EACJ;AACJ,CAAC;AAWM,MAAMI,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAGxE,oBAA4D","ignoreList":[]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createUnistylesStyleSource = void 0;
|
|
7
|
+
var _ScopedThemeContext = require("../../components/ScopedThemeContext");
|
|
8
|
+
const createUnistylesStyleSource = scopedTheme => {
|
|
9
|
+
let epoch = 0;
|
|
10
|
+
let warned = false;
|
|
11
|
+
const source = {
|
|
12
|
+
name: 'unistyles',
|
|
13
|
+
epoch: () => epoch,
|
|
14
|
+
contexts: [_ScopedThemeContext.ScopedThemeContext],
|
|
15
|
+
contextKey: (_context, scope) => scope?.name,
|
|
16
|
+
resolve: (props, read) => {
|
|
17
|
+
try {
|
|
18
|
+
return resolveFresh(props, read(_ScopedThemeContext.ScopedThemeContext));
|
|
19
|
+
} catch (error) {
|
|
20
|
+
if (!warned) {
|
|
21
|
+
warned = true;
|
|
22
|
+
console.warn(`Unistyles: Could not refresh styles for a CSS transition. ${String(error)}`);
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const resolveFresh = (props, scope) => {
|
|
29
|
+
const styles = [props.style].flat(Infinity);
|
|
30
|
+
const fresh = {};
|
|
31
|
+
let hasUnistyles = false;
|
|
32
|
+
for (const style of styles) {
|
|
33
|
+
if (!style || typeof style !== 'object') {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
Object.assign(fresh, style);
|
|
37
|
+
for (const key in style) {
|
|
38
|
+
if (!key.startsWith('unistyles_') || !Object.prototype.hasOwnProperty.call(style, key)) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
hasUnistyles = true;
|
|
42
|
+
const previousScopedTheme = scope ? scopedTheme.get() : undefined;
|
|
43
|
+
if (scope) {
|
|
44
|
+
scopedTheme.set(scope.name);
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
Object.assign(fresh, style[key]?.uni__getStyles?.());
|
|
48
|
+
} finally {
|
|
49
|
+
if (scope) {
|
|
50
|
+
scopedTheme.set(previousScopedTheme);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return hasUnistyles ? fresh : undefined;
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
source,
|
|
59
|
+
bumpEpoch: () => {
|
|
60
|
+
epoch++;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
exports.createUnistylesStyleSource = createUnistylesStyleSource;
|
|
65
|
+
//# sourceMappingURL=styleSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_ScopedThemeContext","require","createUnistylesStyleSource","scopedTheme","epoch","warned","source","name","contexts","ScopedThemeContext","contextKey","_context","scope","resolve","props","read","resolveFresh","error","console","warn","String","undefined","styles","style","flat","Infinity","fresh","hasUnistyles","Object","assign","key","startsWith","prototype","hasOwnProperty","call","previousScopedTheme","get","set","uni__getStyles","bumpEpoch","exports"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/styleSource.ts"],"mappings":";;;;;;AAGA,IAAAA,mBAAA,GAAAC,OAAA;AAOO,MAAMC,0BAA0B,GAAIC,WAA8B,IAAK;EAC1E,IAAIC,KAAK,GAAG,CAAC;EACb,IAAIC,MAAM,GAAG,KAAK;EAElB,MAAMC,MAAmB,GAAG;IACxBC,IAAI,EAAE,WAAW;IACjBH,KAAK,EAAEA,CAAA,KAAMA,KAAK;IAClBI,QAAQ,EAAE,CAACC,sCAAkB,CAAC;IAC9BC,UAAU,EAAEA,CAACC,QAAQ,EAAEC,KAAK,KAAMA,KAAK,EAAmBL,IAAI;IAC9DM,OAAO,EAAEA,CAACC,KAAK,EAAEC,IAAI,KAAK;MACtB,IAAI;QACA,OAAOC,YAAY,CAACF,KAAK,EAAEC,IAAI,CAACN,sCAAkB,CAAC,CAAC;MACxD,CAAC,CAAC,OAAOQ,KAAK,EAAE;QACZ,IAAI,CAACZ,MAAM,EAAE;UACTA,MAAM,GAAG,IAAI;UACba,OAAO,CAACC,IAAI,CAAC,6DAA6DC,MAAM,CAACH,KAAK,CAAC,EAAE,CAAC;QAC9F;QAEA,OAAOI,SAAS;MACpB;IACJ;EACJ,CAAC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","ignoreList":[]}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.reanimatedCSSAdapter = exports.animatedComponentOf = void 0;
|
|
7
|
+
var fiber = _interopRequireWildcard(require("../fiber"));
|
|
8
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
9
|
+
// Keeps Reanimated's CSS style copy (`_cssStyle`) in sync with native-only style updates.
|
|
10
|
+
// Private fields are pinned by test/reanimated-contract.test.ts for 4.5 and 4.7.
|
|
11
|
+
|
|
12
|
+
// Bound once: Metro's inline requires
|
|
13
|
+
const {
|
|
14
|
+
contextReaderFor
|
|
15
|
+
} = fiber;
|
|
16
|
+
const CLASS_COMPONENT = fiber.Tag.ClassComponent;
|
|
17
|
+
// Symbol.for: two copies of unifiber in one bundle never wrap a component twice
|
|
18
|
+
const STATE = Symbol.for('unifiber.reanimated.css');
|
|
19
|
+
|
|
20
|
+
// Kept out of AnimatedComponentLike: a unique symbol in a public type breaks consumers' declaration builds (TS4023)
|
|
21
|
+
|
|
22
|
+
const hasCSSConfig = cssStyle => {
|
|
23
|
+
for (const key in cssStyle) {
|
|
24
|
+
if (key.startsWith('transition') || key.startsWith('animation')) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Keyframe animations and pseudo-styles register again on update after componentWillUnmount cleaned them up.
|
|
32
|
+
// React runs no componentWillUnmount for a subtree deleted while hidden, so on a hidden owner they would leak.
|
|
33
|
+
const registersOnUpdate = cssStyle => {
|
|
34
|
+
for (const key in cssStyle) {
|
|
35
|
+
if (key.startsWith('animation')) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
const value = cssStyle[key];
|
|
39
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
40
|
+
for (const selector in value) {
|
|
41
|
+
if (selector === 'default' || selector.startsWith(':')) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// Deepest case: ScrollView with refreshControl on Android, 6-7 fibers
|
|
52
|
+
const MAX_OWNER_DEPTH = 12;
|
|
53
|
+
|
|
54
|
+
// The class whose `_componentRef` is this host's public instance. Lists don't match: their ref isn't a host.
|
|
55
|
+
const animatedComponentOf = host => {
|
|
56
|
+
const fiber = host;
|
|
57
|
+
if (fiber?.memoizedProps?.collapsable !== false) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const publicInstance = fiber.stateNode?.canonical?.publicInstance;
|
|
61
|
+
if (!publicInstance) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
let current = fiber.return;
|
|
65
|
+
for (let depth = 0; current && depth < MAX_OWNER_DEPTH; depth++) {
|
|
66
|
+
if (current.tag === CLASS_COMPONENT && current.stateNode?._componentRef === publicInstance) {
|
|
67
|
+
return isAnimatedComponent(current.stateNode) ? current.stateNode : null;
|
|
68
|
+
}
|
|
69
|
+
current = current.return;
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
};
|
|
73
|
+
exports.animatedComponentOf = animatedComponentOf;
|
|
74
|
+
const isAnimatedComponent = owner => typeof owner?._updateStyles === 'function' && typeof owner.shouldComponentUpdate === 'function' && owner._cssStyle !== null && typeof owner._cssStyle === 'object';
|
|
75
|
+
function updateStylesThroughSource(props) {
|
|
76
|
+
const state = this[STATE];
|
|
77
|
+
state.original.call(this, props);
|
|
78
|
+
if (!hasCSSConfig(this._cssStyle)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const epoch = state.source.epoch();
|
|
82
|
+
const read = contextReaderFor(this, state.rendering);
|
|
83
|
+
const contexts = state.source.contexts ?? [];
|
|
84
|
+
let contextChanged = false;
|
|
85
|
+
for (let i = 0; i < contexts.length; i++) {
|
|
86
|
+
const context = contexts[i];
|
|
87
|
+
const value = read(context);
|
|
88
|
+
const key = state.source.contextKey ? state.source.contextKey(context, value) : value;
|
|
89
|
+
if (state.contextKeys[i] !== key) {
|
|
90
|
+
state.contextKeys[i] = key;
|
|
91
|
+
contextChanged = true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (contextChanged || state.styleProp !== props.style || state.epoch !== epoch) {
|
|
95
|
+
state.fresh = state.source.resolve(props, read);
|
|
96
|
+
state.styleProp = props.style;
|
|
97
|
+
state.epoch = epoch;
|
|
98
|
+
}
|
|
99
|
+
const fresh = state.fresh;
|
|
100
|
+
if (!fresh) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// only the keys Reanimated kept: animated styles were split out of _cssStyle
|
|
105
|
+
for (const key in this._cssStyle) {
|
|
106
|
+
if (key in fresh) {
|
|
107
|
+
this._cssStyle[key] = fresh[key];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Marks the render phase, where context must be read from React's stack
|
|
113
|
+
function shouldUpdateMarkingRender(...args) {
|
|
114
|
+
const state = this[STATE];
|
|
115
|
+
state.rendering = true;
|
|
116
|
+
try {
|
|
117
|
+
return state.originalShouldUpdate.apply(this, args);
|
|
118
|
+
} finally {
|
|
119
|
+
state.rendering = false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const reanimatedCSSAdapter = exports.reanimatedCSSAdapter = {
|
|
123
|
+
name: 'react-native-reanimated/css',
|
|
124
|
+
gate: host => host.memoizedProps?.collapsable === false,
|
|
125
|
+
claim: animatedComponentOf,
|
|
126
|
+
attach: (owner, source) => {
|
|
127
|
+
if (owner[STATE]) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
owner[STATE] = {
|
|
131
|
+
source,
|
|
132
|
+
original: owner._updateStyles,
|
|
133
|
+
originalShouldUpdate: owner.shouldComponentUpdate,
|
|
134
|
+
rendering: false,
|
|
135
|
+
styleProp: undefined,
|
|
136
|
+
epoch: -1,
|
|
137
|
+
contextKeys: [],
|
|
138
|
+
fresh: undefined
|
|
139
|
+
};
|
|
140
|
+
owner._updateStyles = updateStylesThroughSource;
|
|
141
|
+
owner.shouldComponentUpdate = shouldUpdateMarkingRender;
|
|
142
|
+
},
|
|
143
|
+
refresh: owner => {
|
|
144
|
+
// not mounted yet
|
|
145
|
+
if (typeof owner._CSSManager?.update !== 'function') {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Hidden transitions still run, so the reveal shows the new value instead of animating from the old one
|
|
150
|
+
if (owner._willUnmount === true && registersOnUpdate(owner._cssStyle)) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
owner._updateStyles(owner.props);
|
|
154
|
+
owner._CSSManager.update(owner._cssStyle, owner.props);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
//# sourceMappingURL=reanimated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fiber","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","contextReaderFor","CLASS_COMPONENT","Tag","ClassComponent","STATE","Symbol","for","hasCSSConfig","cssStyle","key","startsWith","registersOnUpdate","value","Array","isArray","selector","MAX_OWNER_DEPTH","animatedComponentOf","host","memoizedProps","collapsable","publicInstance","stateNode","canonical","current","return","depth","tag","_componentRef","isAnimatedComponent","exports","owner","_updateStyles","shouldComponentUpdate","_cssStyle","updateStylesThroughSource","props","state","original","epoch","source","read","rendering","contexts","contextChanged","length","context","contextKey","contextKeys","styleProp","style","fresh","resolve","shouldUpdateMarkingRender","args","originalShouldUpdate","apply","reanimatedCSSAdapter","name","gate","claim","attach","undefined","refresh","_CSSManager","update","_willUnmount"],"sourceRoot":"../../../../../src","sources":["unifiber/src/adapters/reanimated.ts"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAiC,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAA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D;IACJ;;IAEA;IACA,IAAIlC,KAAK,CAACmC,YAAY,KAAK,IAAI,IAAIvD,iBAAiB,CAACoB,KAAK,CAACG,SAAS,CAAC,EAAE;MACnE;IACJ;IAEAH,KAAK,CAACC,aAAa,CAACD,KAAK,CAACK,KAAK,CAAC;IAChCL,KAAK,CAACiC,WAAW,CAACC,MAAM,CAAClC,KAAK,CAACG,SAAS,EAAEH,KAAK,CAACK,KAAK,CAAC;EAC1D;AACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createOwnerRegistry = void 0;
|
|
7
|
+
// An adapter that throws is disabled for the session and reported once
|
|
8
|
+
const createOwnerRegistry = (source, adapters, onAdapterError) => {
|
|
9
|
+
const disabledAdapters = new Set();
|
|
10
|
+
const disable = (adapter, error) => {
|
|
11
|
+
disabledAdapters.add(adapter);
|
|
12
|
+
onAdapterError?.(`adapter ${adapter.name} failed: ${String(error)}`);
|
|
13
|
+
};
|
|
14
|
+
// Not inline closures: a closure in link() makes Hermes allocate its environment on every call
|
|
15
|
+
const attachOwner = (adapter, host) => {
|
|
16
|
+
try {
|
|
17
|
+
const owner = adapter.claim(host);
|
|
18
|
+
if (owner) {
|
|
19
|
+
adapter.attach(owner, source);
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {
|
|
22
|
+
disable(adapter, error);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const refreshOwner = (adapter, host, seen) => {
|
|
26
|
+
try {
|
|
27
|
+
const owner = adapter.claim(host);
|
|
28
|
+
if (owner && !seen.has(owner)) {
|
|
29
|
+
seen.add(owner);
|
|
30
|
+
adapter.attach(owner, source);
|
|
31
|
+
adapter.refresh(owner, source);
|
|
32
|
+
}
|
|
33
|
+
} catch (error) {
|
|
34
|
+
disable(adapter, error);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
link(host) {
|
|
39
|
+
if (!host) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
for (let i = 0; i < adapters.length; i++) {
|
|
43
|
+
const adapter = adapters[i];
|
|
44
|
+
if (adapter.gate(host) && !disabledAdapters.has(adapter)) {
|
|
45
|
+
attachOwner(adapter, host);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
refresh(hosts) {
|
|
50
|
+
const seen = new Set();
|
|
51
|
+
for (let h = 0; h < hosts.length; h++) {
|
|
52
|
+
const host = hosts[h];
|
|
53
|
+
if (!host) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
for (let i = 0; i < adapters.length; i++) {
|
|
57
|
+
const adapter = adapters[i];
|
|
58
|
+
if (adapter.gate(host) && !disabledAdapters.has(adapter)) {
|
|
59
|
+
refreshOwner(adapter, host, seen);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
exports.createOwnerRegistry = createOwnerRegistry;
|
|
67
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createOwnerRegistry","source","adapters","onAdapterError","disabledAdapters","Set","disable","adapter","error","add","name","String","attachOwner","host","owner","claim","attach","refreshOwner","seen","has","refresh","link","i","length","gate","hosts","h","exports"],"sourceRoot":"../../../../../src","sources":["unifiber/src/adapters/registry.ts"],"mappings":";;;;;;AA8BA;AACO,MAAMA,mBAAmB,GAAGA,CAC/BC,MAAmB,EACnBC,QAA0C,EAC1CC,cAAyC,KACzB;EAChB,MAAMC,gBAAgB,GAAG,IAAIC,GAAG,CAAe,CAAC;EAChD,MAAMC,OAAO,GAAGA,CAACC,OAAqB,EAAEC,KAAc,KAAK;IACvDJ,gBAAgB,CAACK,GAAG,CAACF,OAAO,CAAC;IAC7BJ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