react-native-unistyles 3.5.3 → 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/cxx/converters/BackgroundImageConverter.cpp +198 -11
- package/cxx/converters/BackgroundImageConverter.h +1 -0
- package/cxx/core/HostUnistyle.cpp +6 -0
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +5 -0
- package/cxx/parser/Parser.cpp +29 -7
- package/ios/NativePlatform+ios.swift +22 -11
- 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/specs/ShadowRegistry/index.js +57 -74
- 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/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/specs/ShadowRegistry/index.js +57 -74
- 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/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/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/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/specs/ShadowRegistry/index.ts +50 -102
- 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/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-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
|
@@ -1,87 +1,61 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { NitroModules } from 'react-native-nitro-modules';
|
|
4
|
+
import { Fiber, Reanimated } from '../../unifiber/src';
|
|
4
5
|
import { StyleSheet } from '../StyleSheet';
|
|
6
|
+
import { createUnistylesStyleSource } from './styleSource';
|
|
5
7
|
const HybridShadowRegistry = NitroModules.createHybridObject('UnistylesShadowRegistry');
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
const {
|
|
9
|
+
collectVisibleAncestors,
|
|
10
|
+
getHostFor,
|
|
11
|
+
getHostForInstanceHandle,
|
|
12
|
+
getShadowNode,
|
|
13
|
+
getShadowNodes,
|
|
14
|
+
isHidden
|
|
15
|
+
} = Fiber;
|
|
16
|
+
const {
|
|
17
|
+
source: styleSource,
|
|
18
|
+
bumpEpoch
|
|
19
|
+
} = createUnistylesStyleSource({
|
|
20
|
+
get: () => HybridShadowRegistry.getScopedTheme(),
|
|
21
|
+
set: name => HybridShadowRegistry.setScopedTheme(name)
|
|
22
|
+
});
|
|
23
|
+
const owners = Fiber.createOwnerRegistry(styleSource, [Reanimated.cssAdapter], reason => {
|
|
24
|
+
console.warn(`Unistyles: ${reason}. CSS transitions won't follow theme changes.`);
|
|
25
|
+
});
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
// A component can point at another native view by the time its ref is cleaned up, eg. FlatList on Android remounts
|
|
28
|
+
// its native ScrollView when `horizontal` changes, so remove unlinks the view it was linked with
|
|
29
|
+
// The host points at its current node, while a stored node would keep its first revision (and children) alive
|
|
30
|
+
// Native views always resolve to their own host, so they skip it
|
|
31
|
+
const linkedHosts = new WeakMap();
|
|
32
|
+
const committedHosts = [];
|
|
33
|
+
let refreshNodes = [];
|
|
34
|
+
const collectShadowNodes = host => {
|
|
35
|
+
getShadowNodes(host, refreshNodes);
|
|
30
36
|
};
|
|
31
37
|
|
|
32
38
|
// React re-attaches an untouched subtree through its root's node and only follows clones made on the JS thread.
|
|
33
39
|
// Once a node was cloned elsewhere (state updates, Reanimated), React would commit a subtree from before a Unistyles
|
|
34
40
|
// update, so after a Unistyles commit the committed nodes and their host ancestors must point at the committed tree
|
|
35
41
|
const refreshReactNodes = () => {
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
bumpEpoch();
|
|
43
|
+
const handles = HybridShadowRegistry.takeCommittedInstanceHandles();
|
|
44
|
+
if (handles.length === 0) {
|
|
38
45
|
return;
|
|
39
46
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
for (const fiber of fibers) {
|
|
44
|
-
// collected, unmounted since
|
|
45
|
-
if (!fiber) {
|
|
46
|
-
continue;
|
|
47
|
+
try {
|
|
48
|
+
for (let i = 0; i < handles.length; i++) {
|
|
49
|
+
committedHosts[i] = getHostForInstanceHandle(handles[i]);
|
|
47
50
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// hidden by Suspense or a frozen screen
|
|
52
|
-
if ((current.tag === SUSPENSE_TAG || current.tag === OFFSCREEN_TAG) && current.memoizedState !== null) {
|
|
53
|
-
isHidden = true;
|
|
54
|
-
}
|
|
55
|
-
if (current.tag !== HOST_COMPONENT_TAG) {
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// its ancestors are visible and already collected
|
|
60
|
-
if (refreshedTags.has(current.stateNode?.canonical?.nativeTag)) {
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
hostFibers.push(current);
|
|
51
|
+
collectVisibleAncestors(committedHosts, collectShadowNodes);
|
|
52
|
+
if (refreshNodes.length > 0) {
|
|
53
|
+
HybridShadowRegistry.refreshReactNodes(refreshNodes);
|
|
64
54
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const node = hostFiber.stateNode?.node;
|
|
70
|
-
const alternateNode = hostFiber.alternate?.stateNode?.node;
|
|
71
|
-
const hostTag = hostFiber.stateNode?.canonical?.nativeTag;
|
|
72
|
-
if (hostTag !== undefined) {
|
|
73
|
-
refreshedTags.add(hostTag);
|
|
74
|
-
}
|
|
75
|
-
if (node) {
|
|
76
|
-
nodes.push(node);
|
|
77
|
-
}
|
|
78
|
-
if (alternateNode && alternateNode !== node) {
|
|
79
|
-
nodes.push(alternateNode);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (nodes.length > 0) {
|
|
84
|
-
HybridShadowRegistry.refreshReactNodes(nodes);
|
|
55
|
+
owners.refresh(committedHosts);
|
|
56
|
+
} finally {
|
|
57
|
+
committedHosts.length = 0;
|
|
58
|
+
refreshNodes = [];
|
|
85
59
|
}
|
|
86
60
|
};
|
|
87
61
|
StyleSheet.addChangeListener(refreshReactNodes);
|
|
@@ -125,8 +99,9 @@ HybridShadowRegistry.add = (handle, styles, scope) => {
|
|
|
125
99
|
collectStyle(styles, filteredStyles);
|
|
126
100
|
}
|
|
127
101
|
if (filteredStyles.length > 0) {
|
|
128
|
-
const
|
|
129
|
-
|
|
102
|
+
const host = getHostFor(handle);
|
|
103
|
+
const node = host && getShadowNode(host);
|
|
104
|
+
if (!host || !node) {
|
|
130
105
|
throw new Error(`Unistyles: Could not find shadow node for one of your components of type ${handle?.constructor?.name ?? 'unknown'}`);
|
|
131
106
|
}
|
|
132
107
|
|
|
@@ -136,6 +111,10 @@ HybridShadowRegistry.add = (handle, styles, scope) => {
|
|
|
136
111
|
HybridShadowRegistry.setScopedTheme(scope.name);
|
|
137
112
|
}
|
|
138
113
|
HybridShadowRegistry.link(node, filteredStyles);
|
|
114
|
+
owners.link(host);
|
|
115
|
+
if (!handle.__internalInstanceHandle) {
|
|
116
|
+
linkedHosts.set(handle, host);
|
|
117
|
+
}
|
|
139
118
|
if (scope) {
|
|
140
119
|
HybridShadowRegistry.setScopedTheme(previousScopedTheme);
|
|
141
120
|
}
|
|
@@ -145,10 +124,14 @@ HybridShadowRegistry.remove = handle => {
|
|
|
145
124
|
if (!handle) {
|
|
146
125
|
return;
|
|
147
126
|
}
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
127
|
+
const linkedHost = handle.__internalInstanceHandle ? undefined : linkedHosts.get(handle);
|
|
128
|
+
const host = linkedHost ?? getHostFor(handle);
|
|
129
|
+
const maybeNode = host && getShadowNode(host);
|
|
130
|
+
if (linkedHost) {
|
|
131
|
+
linkedHosts.delete(handle);
|
|
132
|
+
}
|
|
133
|
+
if (host && maybeNode) {
|
|
134
|
+
if (isHidden(host)) {
|
|
152
135
|
HybridShadowRegistry.suspend(maybeNode);
|
|
153
136
|
} else {
|
|
154
137
|
HybridShadowRegistry.unlink(maybeNode);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NitroModules","
|
|
1
|
+
{"version":3,"names":["NitroModules","Fiber","Reanimated","StyleSheet","createUnistylesStyleSource","HybridShadowRegistry","createHybridObject","collectVisibleAncestors","getHostFor","getHostForInstanceHandle","getShadowNode","getShadowNodes","isHidden","source","styleSource","bumpEpoch","get","getScopedTheme","set","name","setScopedTheme","owners","createOwnerRegistry","cssAdapter","reason","console","warn","linkedHosts","WeakMap","committedHosts","refreshNodes","collectShadowNodes","host","refreshReactNodes","handles","takeCommittedInstanceHandles","length","i","refresh","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"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAQzD,SAASC,KAAK,EAAEC,UAAU,QAAQ,oBAAoB;AACtD,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,0BAA0B,QAAQ,eAAe;AAkB1D,MAAMC,oBAAoB,GAAGL,YAAY,CAACM,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAM;EAAEC,uBAAuB;EAAEC,UAAU;EAAEC,wBAAwB;EAAEC,aAAa;EAAEC,cAAc;EAAEC;AAAS,CAAC,GAA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S,GAAGpC,IAAI,IAAItB,aAAa,CAACsB,IAAI,CAAC;EAE7C,IAAImC,UAAU,EAAE;IACZxC,WAAW,CAAC0C,MAAM,CAACnB,MAAM,CAAC;EAC9B;EAEA,IAAIlB,IAAI,IAAIoC,SAAS,EAAE;IACnB,IAAIxD,QAAQ,CAACoB,IAAI,CAAC,EAAE;MAChB3B,oBAAoB,CAACiE,OAAO,CAACF,SAAS,CAAC;IAC3C,CAAC,MAAM;MACH/D,oBAAoB,CAACkE,MAAM,CAACH,SAAS,CAAC;IAC1C;EACJ;AACJ,CAAC;AAWD,OAAO,MAAMI,uBAAuB,GAAGnE,oBAA4D","ignoreList":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { ScopedThemeContext } from '../../components/ScopedThemeContext';
|
|
4
|
+
export const createUnistylesStyleSource = scopedTheme => {
|
|
5
|
+
let epoch = 0;
|
|
6
|
+
let warned = false;
|
|
7
|
+
const source = {
|
|
8
|
+
name: 'unistyles',
|
|
9
|
+
epoch: () => epoch,
|
|
10
|
+
contexts: [ScopedThemeContext],
|
|
11
|
+
contextKey: (_context, scope) => scope?.name,
|
|
12
|
+
resolve: (props, read) => {
|
|
13
|
+
try {
|
|
14
|
+
return resolveFresh(props, read(ScopedThemeContext));
|
|
15
|
+
} catch (error) {
|
|
16
|
+
if (!warned) {
|
|
17
|
+
warned = true;
|
|
18
|
+
console.warn(`Unistyles: Could not refresh styles for a CSS transition. ${String(error)}`);
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const resolveFresh = (props, scope) => {
|
|
25
|
+
const styles = [props.style].flat(Infinity);
|
|
26
|
+
const fresh = {};
|
|
27
|
+
let hasUnistyles = false;
|
|
28
|
+
for (const style of styles) {
|
|
29
|
+
if (!style || typeof style !== 'object') {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
Object.assign(fresh, style);
|
|
33
|
+
for (const key in style) {
|
|
34
|
+
if (!key.startsWith('unistyles_') || !Object.prototype.hasOwnProperty.call(style, key)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
hasUnistyles = true;
|
|
38
|
+
const previousScopedTheme = scope ? scopedTheme.get() : undefined;
|
|
39
|
+
if (scope) {
|
|
40
|
+
scopedTheme.set(scope.name);
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
Object.assign(fresh, style[key]?.uni__getStyles?.());
|
|
44
|
+
} finally {
|
|
45
|
+
if (scope) {
|
|
46
|
+
scopedTheme.set(previousScopedTheme);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return hasUnistyles ? fresh : undefined;
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
source,
|
|
55
|
+
bumpEpoch: () => {
|
|
56
|
+
epoch++;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=styleSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ScopedThemeContext","createUnistylesStyleSource","scopedTheme","epoch","warned","source","name","contexts","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"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/styleSource.ts"],"mappings":";;AAGA,SAASA,kBAAkB,QAAQ,qCAAqC;AAOxE,OAAO,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,CA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AAI,CAAC;QAC/B;QAEA,IAAI;UACAoB,MAAM,CAACC,MAAM,CAACH,KAAK,EAAEH,KAAK,CAACO,GAAG,CAAC,EAAEQ,cAAc,GAAG,CAAC,CAAC;QACxD,CAAC,SAAS;UACN,IAAI1B,KAAK,EAAE;YACPR,WAAW,CAACiC,GAAG,CAACF,mBAAmB,CAAC;UACxC;QACJ;MACJ;IACJ;IAEA,OAAOR,YAAY,GAAGD,KAAK,GAAGL,SAAS;EAC3C,CAAC;EAED,OAAO;IACHd,MAAM;IACNgC,SAAS,EAAEA,CAAA,KAAM;MACblC,KAAK,EAAE;IACX;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Keeps Reanimated's CSS style copy (`_cssStyle`) in sync with native-only style updates.
|
|
4
|
+
// Private fields are pinned by test/reanimated-contract.test.ts for 4.5 and 4.7.
|
|
5
|
+
|
|
6
|
+
import * as fiber from '../fiber';
|
|
7
|
+
|
|
8
|
+
// Bound once: Metro's inline requires
|
|
9
|
+
const {
|
|
10
|
+
contextReaderFor
|
|
11
|
+
} = fiber;
|
|
12
|
+
const CLASS_COMPONENT = fiber.Tag.ClassComponent;
|
|
13
|
+
// Symbol.for: two copies of unifiber in one bundle never wrap a component twice
|
|
14
|
+
const STATE = Symbol.for('unifiber.reanimated.css');
|
|
15
|
+
|
|
16
|
+
// Kept out of AnimatedComponentLike: a unique symbol in a public type breaks consumers' declaration builds (TS4023)
|
|
17
|
+
|
|
18
|
+
const hasCSSConfig = cssStyle => {
|
|
19
|
+
for (const key in cssStyle) {
|
|
20
|
+
if (key.startsWith('transition') || key.startsWith('animation')) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// Keyframe animations and pseudo-styles register again on update after componentWillUnmount cleaned them up.
|
|
28
|
+
// React runs no componentWillUnmount for a subtree deleted while hidden, so on a hidden owner they would leak.
|
|
29
|
+
const registersOnUpdate = cssStyle => {
|
|
30
|
+
for (const key in cssStyle) {
|
|
31
|
+
if (key.startsWith('animation')) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
const value = cssStyle[key];
|
|
35
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
36
|
+
for (const selector in value) {
|
|
37
|
+
if (selector === 'default' || selector.startsWith(':')) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Deepest case: ScrollView with refreshControl on Android, 6-7 fibers
|
|
48
|
+
const MAX_OWNER_DEPTH = 12;
|
|
49
|
+
|
|
50
|
+
// The class whose `_componentRef` is this host's public instance. Lists don't match: their ref isn't a host.
|
|
51
|
+
export const animatedComponentOf = host => {
|
|
52
|
+
const fiber = host;
|
|
53
|
+
if (fiber?.memoizedProps?.collapsable !== false) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const publicInstance = fiber.stateNode?.canonical?.publicInstance;
|
|
57
|
+
if (!publicInstance) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
let current = fiber.return;
|
|
61
|
+
for (let depth = 0; current && depth < MAX_OWNER_DEPTH; depth++) {
|
|
62
|
+
if (current.tag === CLASS_COMPONENT && current.stateNode?._componentRef === publicInstance) {
|
|
63
|
+
return isAnimatedComponent(current.stateNode) ? current.stateNode : null;
|
|
64
|
+
}
|
|
65
|
+
current = current.return;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
};
|
|
69
|
+
const isAnimatedComponent = owner => typeof owner?._updateStyles === 'function' && typeof owner.shouldComponentUpdate === 'function' && owner._cssStyle !== null && typeof owner._cssStyle === 'object';
|
|
70
|
+
function updateStylesThroughSource(props) {
|
|
71
|
+
const state = this[STATE];
|
|
72
|
+
state.original.call(this, props);
|
|
73
|
+
if (!hasCSSConfig(this._cssStyle)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const epoch = state.source.epoch();
|
|
77
|
+
const read = contextReaderFor(this, state.rendering);
|
|
78
|
+
const contexts = state.source.contexts ?? [];
|
|
79
|
+
let contextChanged = false;
|
|
80
|
+
for (let i = 0; i < contexts.length; i++) {
|
|
81
|
+
const context = contexts[i];
|
|
82
|
+
const value = read(context);
|
|
83
|
+
const key = state.source.contextKey ? state.source.contextKey(context, value) : value;
|
|
84
|
+
if (state.contextKeys[i] !== key) {
|
|
85
|
+
state.contextKeys[i] = key;
|
|
86
|
+
contextChanged = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (contextChanged || state.styleProp !== props.style || state.epoch !== epoch) {
|
|
90
|
+
state.fresh = state.source.resolve(props, read);
|
|
91
|
+
state.styleProp = props.style;
|
|
92
|
+
state.epoch = epoch;
|
|
93
|
+
}
|
|
94
|
+
const fresh = state.fresh;
|
|
95
|
+
if (!fresh) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// only the keys Reanimated kept: animated styles were split out of _cssStyle
|
|
100
|
+
for (const key in this._cssStyle) {
|
|
101
|
+
if (key in fresh) {
|
|
102
|
+
this._cssStyle[key] = fresh[key];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Marks the render phase, where context must be read from React's stack
|
|
108
|
+
function shouldUpdateMarkingRender(...args) {
|
|
109
|
+
const state = this[STATE];
|
|
110
|
+
state.rendering = true;
|
|
111
|
+
try {
|
|
112
|
+
return state.originalShouldUpdate.apply(this, args);
|
|
113
|
+
} finally {
|
|
114
|
+
state.rendering = false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export const reanimatedCSSAdapter = {
|
|
118
|
+
name: 'react-native-reanimated/css',
|
|
119
|
+
gate: host => host.memoizedProps?.collapsable === false,
|
|
120
|
+
claim: animatedComponentOf,
|
|
121
|
+
attach: (owner, source) => {
|
|
122
|
+
if (owner[STATE]) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
owner[STATE] = {
|
|
126
|
+
source,
|
|
127
|
+
original: owner._updateStyles,
|
|
128
|
+
originalShouldUpdate: owner.shouldComponentUpdate,
|
|
129
|
+
rendering: false,
|
|
130
|
+
styleProp: undefined,
|
|
131
|
+
epoch: -1,
|
|
132
|
+
contextKeys: [],
|
|
133
|
+
fresh: undefined
|
|
134
|
+
};
|
|
135
|
+
owner._updateStyles = updateStylesThroughSource;
|
|
136
|
+
owner.shouldComponentUpdate = shouldUpdateMarkingRender;
|
|
137
|
+
},
|
|
138
|
+
refresh: owner => {
|
|
139
|
+
// not mounted yet
|
|
140
|
+
if (typeof owner._CSSManager?.update !== 'function') {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Hidden transitions still run, so the reveal shows the new value instead of animating from the old one
|
|
145
|
+
if (owner._willUnmount === true && registersOnUpdate(owner._cssStyle)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
owner._updateStyles(owner.props);
|
|
149
|
+
owner._CSSManager.update(owner._cssStyle, owner.props);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=reanimated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fiber","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","owner","_updateStyles","shouldComponentUpdate","_cssStyle","updateStylesThroughSource","props","state","original","call","epoch","source","read","rendering","contexts","contextChanged","i","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":";;AAAA;AACA;;AAGA,OAAO,KAAKA,KAAK,MAAM,UAAU;;AAEjC;AACA,MAAM;EAAEC;AAAiB,CAAC,GAAGD,KAAK;AAClC,MAAME,eAAe,GAAGF,KAAK,CAACG,GAAG,CAACC,cAAc;AAyBhD;AACA,MAAMC,KAAK,GAAGC,MAAM,CAACC,GAAG,CAAC,yBAAyB,CAAC;;AAEnD;;AAGA,MAAMC,YAAY,GAAIC,QAAiC,IAAK;EACxD,KAAK,MAAMC,GAAG,IAAID,QAAQ,EAAE;IACxB,IAAIC,GAAG,CAACC,UAAU,CAAC,YAAY,CAAC,IAAID,GAAG,CAACC,UAAU,CAAC,WAAW,CAAC,EAAE;MAC7D,OAAO,IAAI;IACf;EACJ;EAEA,OAAO,KAAK;AAChB,CAAC;;AAED;AACA;AACA,MAAMC,iBAAiB,GAAIH,QAAiC,IAAK;EAC7D,KAAK,MAAMC,GAAG,IAAID,QAAQ,EAAE;IACxB,IAAIC,GAAG,CAACC,UAAU,CAAC,WAAW,CAAC,EAAE;MAC7B,OAAO,IAAI;IACf;IAEA,MAAME,KAAK,GAAGJ,QAAQ,CAACC,GAAG,CAAC;IAE3B,IAAIG,KAAK,KAAK,IAAI,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;MACtE,KAAK,MAAMG,QAAQ,IAAIH,KAAK,EAAE;QAC1B,IAAIG,QAAQ,KAAK,SAAS,IAAIA,QAAQ,CAACL,UAAU,CAAC,GAAG,CAAC,EAAE;UACpD,OAAO,IAAI;QACf;QAEA;MACJ;IACJ;EACJ;EAEA,OAAO,KAAK;AAChB,CAAC;;AAED;AACA,MAAMM,eAAe,GAAG,EAAE;;A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CAACqC,YAAY,KAAK,IAAI,IAAIxD,iBAAiB,CAACmB,KAAK,CAACG,SAAS,CAAC,EAAE;MACnE;IACJ;IAEAH,KAAK,CAACC,aAAa,CAACD,KAAK,CAACK,KAAK,CAAC;IAChCL,KAAK,CAACmC,WAAW,CAACC,MAAM,CAACpC,KAAK,CAACG,SAAS,EAAEH,KAAK,CAACK,KAAK,CAAC;EAC1D;AACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// An adapter that throws is disabled for the session and reported once
|
|
4
|
+
export const createOwnerRegistry = (source, adapters, onAdapterError) => {
|
|
5
|
+
const disabledAdapters = new Set();
|
|
6
|
+
const disable = (adapter, error) => {
|
|
7
|
+
disabledAdapters.add(adapter);
|
|
8
|
+
onAdapterError?.(`adapter ${adapter.name} failed: ${String(error)}`);
|
|
9
|
+
};
|
|
10
|
+
// Not inline closures: a closure in link() makes Hermes allocate its environment on every call
|
|
11
|
+
const attachOwner = (adapter, host) => {
|
|
12
|
+
try {
|
|
13
|
+
const owner = adapter.claim(host);
|
|
14
|
+
if (owner) {
|
|
15
|
+
adapter.attach(owner, source);
|
|
16
|
+
}
|
|
17
|
+
} catch (error) {
|
|
18
|
+
disable(adapter, error);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const refreshOwner = (adapter, host, seen) => {
|
|
22
|
+
try {
|
|
23
|
+
const owner = adapter.claim(host);
|
|
24
|
+
if (owner && !seen.has(owner)) {
|
|
25
|
+
seen.add(owner);
|
|
26
|
+
adapter.attach(owner, source);
|
|
27
|
+
adapter.refresh(owner, source);
|
|
28
|
+
}
|
|
29
|
+
} catch (error) {
|
|
30
|
+
disable(adapter, error);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
link(host) {
|
|
35
|
+
if (!host) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
for (let i = 0; i < adapters.length; i++) {
|
|
39
|
+
const adapter = adapters[i];
|
|
40
|
+
if (adapter.gate(host) && !disabledAdapters.has(adapter)) {
|
|
41
|
+
attachOwner(adapter, host);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
refresh(hosts) {
|
|
46
|
+
const seen = new Set();
|
|
47
|
+
for (let h = 0; h < hosts.length; h++) {
|
|
48
|
+
const host = hosts[h];
|
|
49
|
+
if (!host) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
for (let i = 0; i < adapters.length; i++) {
|
|
53
|
+
const adapter = adapters[i];
|
|
54
|
+
if (adapter.gate(host) && !disabledAdapters.has(adapter)) {
|
|
55
|
+
refreshOwner(adapter, host, seen);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
//# 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"],"sourceRoot":"../../../../../src","sources":["unifiber/src/adapters/registry.ts"],"mappings":";;AA8BA;AACA,OAAO,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,cAAc,GAAG,WAAWI,OAAO,CAACG,IAAI,YAAYC,MAAM,CAACH,KAAK,CAAC,EAAE,CAAC;EACxE,CAAC;EACD;EACA,MAAMI,WAAW,GAAGA,CAACL,OAAqB,EAAEM,IAAU,KAAK;IACvD,IAAI;MACA,MAA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B,KAAK,IAAIqB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,KAAK,CAACF,MAAM,EAAEG,CAAC,EAAE,EAAE;QACnC,MAAMb,IAAI,GAAGY,KAAK,CAACC,CAAC,CAAC;QAErB,IAAI,CAACb,IAAI,EAAE;UACP;QACJ;QAEA,KAAK,IAAIS,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGpB,QAAQ,CAACqB,MAAM,EAAED,CAAC,EAAE,EAAE;UACtC,MAAMf,OAAO,GAAGL,QAAQ,CAACoB,CAAC,CAAE;UAE5B,IAAIf,OAAO,CAACiB,IAAI,CAACX,IAAI,CAAC,IAAI,CAACT,gBAAgB,CAACe,GAAG,CAACZ,OAAO,CAAC,EAAE;YACtDU,YAAY,CAACV,OAAO,EAAEM,IAAI,EAAEK,IAAI,CAAC;UACrC;QACJ;MACJ;IACJ;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import * as host from './host';
|
|
4
|
+
|
|
5
|
+
// Bound once: Metro's inline requires
|
|
6
|
+
const {
|
|
7
|
+
committedHalf,
|
|
8
|
+
fiberOf
|
|
9
|
+
} = host;
|
|
10
|
+
const styleDiffers = (a, b) => a.memoizedProps?.style !== b.memoizedProps?.style;
|
|
11
|
+
const flattenInto = (style, out) => {
|
|
12
|
+
if (Array.isArray(style)) {
|
|
13
|
+
for (let i = 0; i < style.length; i++) {
|
|
14
|
+
flattenInto(style[i], out);
|
|
15
|
+
}
|
|
16
|
+
} else if (style && typeof style === 'object') {
|
|
17
|
+
Object.assign(out, style);
|
|
18
|
+
}
|
|
19
|
+
return out;
|
|
20
|
+
};
|
|
21
|
+
// Keys that differ from React's committed props: React re-sends them on the view's next render
|
|
22
|
+
export const verify = (host, expected) => {
|
|
23
|
+
const baseline = committedHalf(fiberOf(host), styleDiffers) ?? fiberOf(host);
|
|
24
|
+
const react = flattenInto(baseline.memoizedProps?.style, {});
|
|
25
|
+
const drift = [];
|
|
26
|
+
for (const key in expected) {
|
|
27
|
+
if (react[key] !== expected[key]) {
|
|
28
|
+
drift.push({
|
|
29
|
+
key,
|
|
30
|
+
react: react[key],
|
|
31
|
+
expected: expected[key]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return drift;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Development builds only
|
|
39
|
+
export const getOwners = (host, max = 8) => {
|
|
40
|
+
const owners = [];
|
|
41
|
+
for (let owner = fiberOf(host)._debugOwner; owner && owners.length < max; owner = owner._debugOwner ?? owner.owner) {
|
|
42
|
+
const name = owner.name ?? owner.type?.displayName ?? owner.type?.name ?? owner.type?.render?.name;
|
|
43
|
+
if (name) {
|
|
44
|
+
owners.push(name);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return owners;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Development builds only
|
|
51
|
+
export const getCreationStack = host => fiberOf(host)._debugStack?.stack;
|
|
52
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["host","committedHalf","fiberOf","styleDiffers","a","b","memoizedProps","style","flattenInto","out","Array","isArray","i","length","Object","assign","verify","expected","baseline","react","drift","key","push","getOwners","max","owners","owner","_debugOwner","name","type","displayName","render","getCreationStack","_debugStack","stack"],"sourceRoot":"../../../../src","sources":["unifiber/src/diagnostics.ts"],"mappings":";;AAEA,OAAO,KAAKA,IAAI,MAAM,QAAQ;;AAE9B;AACA,MAAM;EAAEC,aAAa;EAAEC;AAAQ,CAAC,GAAGF,IAAI;AAEvC,MAAMG,YAAY,GAAGA,CAACC,CAAW,EAAEC,CAAW,KAAKD,CAAC,CAACE,aAAa,EAAEC,KAAK,KAAKF,CAAC,CAACC,aAAa,EAAEC,KAAK;AAEpG,MAAMC,WAAW,GAAGA,CAACD,KAAc,EAAEE,GAA4B,KAAK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