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
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// A Host is the view's creation fiber behind an opaque type: no allocation, and stable identity (=== / WeakMap keys).
|
|
2
|
+
import type { FiberNode, RawFiber, ShadowNode } from './fiber'
|
|
3
|
+
import * as fiber from './fiber'
|
|
4
|
+
|
|
5
|
+
// Bound once: Metro's inline requires would turn each imported name used in a function into a require per call
|
|
6
|
+
const {
|
|
7
|
+
committedOf,
|
|
8
|
+
fiberOfInstance,
|
|
9
|
+
firstHostBelow,
|
|
10
|
+
hostAncestor,
|
|
11
|
+
patchRenderedProps: patchFiberProps,
|
|
12
|
+
raw,
|
|
13
|
+
resolveHostFiber,
|
|
14
|
+
shadowNodesOf,
|
|
15
|
+
} = fiber
|
|
16
|
+
const { HostComponent: HOST_COMPONENT, Offscreen: OFFSCREEN, Suspense: SUSPENSE, Activity: ACTIVITY } = fiber.Tag
|
|
17
|
+
|
|
18
|
+
declare const brand: unique symbol
|
|
19
|
+
export type Host = { readonly [brand]: 'Host' }
|
|
20
|
+
|
|
21
|
+
export const fiberOf = (host: Host): RawFiber => host as unknown as RawFiber
|
|
22
|
+
|
|
23
|
+
export const toHost = (fiber: RawFiber | FiberNode | null | undefined): Host | undefined =>
|
|
24
|
+
((fiber as RawFiber | null | undefined)?.stateNode?.canonical?.internalInstanceHandle ?? undefined) as Host | undefined
|
|
25
|
+
|
|
26
|
+
const resolveRefSlowly = (ref: unknown): RawFiber | undefined =>
|
|
27
|
+
raw(resolveHostFiber(ref)) ?? (toHost(firstHostBelow(fiberOfInstance(ref))) as unknown as RawFiber | undefined)
|
|
28
|
+
|
|
29
|
+
// The fast path is inlined: legacy Hermes doesn't inline calls
|
|
30
|
+
export const getHostFor = (ref: unknown): Host | undefined => {
|
|
31
|
+
const fiber = (ref as { __internalInstanceHandle?: RawFiber } | null | undefined)?.__internalInstanceHandle
|
|
32
|
+
|
|
33
|
+
if (fiber !== undefined) {
|
|
34
|
+
return fiber as unknown as Host
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return resolveRefSlowly(ref) as unknown as Host | undefined
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const getShadowNodeFor = (ref: unknown): ShadowNode | undefined => {
|
|
41
|
+
const fiber = (ref as { __internalInstanceHandle?: RawFiber } | null | undefined)?.__internalInstanceHandle
|
|
42
|
+
|
|
43
|
+
if (fiber !== undefined) {
|
|
44
|
+
return fiber.stateNode?.node
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return resolveRefSlowly(ref)?.stateNode?.node
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const getHostForInstanceHandle = (handle: unknown): Host | undefined => toHost(handle as RawFiber | null | undefined)
|
|
51
|
+
|
|
52
|
+
// Not the first host below the scroll view: on iOS a refreshControl comes first
|
|
53
|
+
export const getContentContainerFor = (ref: any): Host | undefined => {
|
|
54
|
+
const scroll = ref?.getInnerViewRef ? ref : (ref?.getNativeScrollRef?.() ?? ref?.getScrollResponder?.())
|
|
55
|
+
|
|
56
|
+
return getHostFor(scroll?.getInnerViewRef?.())
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const getShadowNode = (host: Host): ShadowNode | undefined => fiberOf(host).stateNode?.node
|
|
60
|
+
|
|
61
|
+
// Two nodes only while a render is in flight; after a commit both halves share one
|
|
62
|
+
export const getShadowNodes = (host: Host, out: Array<ShadowNode> = []): Array<ShadowNode> => {
|
|
63
|
+
shadowNodesOf(host as unknown as FiberNode, out)
|
|
64
|
+
|
|
65
|
+
return out
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const getNativeTag = (host: Host): number | undefined => fiberOf(host).stateNode?.canonical?.nativeTag
|
|
69
|
+
|
|
70
|
+
export const getParentHost = (host: Host): Host | undefined => toHost(hostAncestor(host as unknown as FiberNode))
|
|
71
|
+
|
|
72
|
+
export const patchRenderedProps = (host: Host, patch: (props: Record<string, any>) => Record<string, any> | undefined): boolean =>
|
|
73
|
+
patchFiberProps(host as unknown as FiberNode, patch)
|
|
74
|
+
|
|
75
|
+
export const HiddenBy = {
|
|
76
|
+
None: 0,
|
|
77
|
+
Suspense: 1,
|
|
78
|
+
Freeze: 2,
|
|
79
|
+
Activity: 4,
|
|
80
|
+
} as const
|
|
81
|
+
|
|
82
|
+
// `return` can point into either half of a pair; ask which half is committed only when they disagree
|
|
83
|
+
export const committedHalf = (fiber: RawFiber, differs: (a: RawFiber, b: RawFiber) => boolean): RawFiber | null => {
|
|
84
|
+
const alternate = fiber.alternate
|
|
85
|
+
|
|
86
|
+
if (!alternate || !differs(fiber, alternate)) {
|
|
87
|
+
return fiber
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return raw(committedOf(fiber as unknown as FiberNode)) ?? null
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const hiddenStateDiffers = (a: RawFiber, b: RawFiber) => (a.memoizedState === null) !== (b.memoizedState === null)
|
|
94
|
+
|
|
95
|
+
// React's own visibility bit on the Offscreen instance: shared by both halves and flipped in the commit before refs
|
|
96
|
+
// detach, so it also holds inside a ref cleanup, where the committed half is still the old tree
|
|
97
|
+
const OFFSCREEN_VISIBLE = 1
|
|
98
|
+
const isOffscreenHidden = (offscreen: RawFiber): boolean => {
|
|
99
|
+
const visibility = offscreen.stateNode?._visibility
|
|
100
|
+
|
|
101
|
+
if (typeof visibility === 'number') {
|
|
102
|
+
return (visibility & OFFSCREEN_VISIBLE) === 0
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return committedHalf(offscreen, hiddenStateDiffers)?.memoizedState != null
|
|
106
|
+
}
|
|
107
|
+
const freezeDiffers = (a: RawFiber, b: RawFiber) => a.memoizedProps?.freeze !== b.memoizedProps?.freeze
|
|
108
|
+
|
|
109
|
+
// react-freeze: Freeze > Suspense > Suspender. The Suspender keeps stale props because it throws, so read Freeze's.
|
|
110
|
+
const isFrozenBoundary = (suspense: RawFiber) =>
|
|
111
|
+
committedHalf(suspense.return as RawFiber, freezeDiffers)?.memoizedProps?.freeze === true
|
|
112
|
+
|
|
113
|
+
// Every hidden subtree sits under an Offscreen fiber with memoizedState set
|
|
114
|
+
export const getHiddenReasons = (host: Host): number => {
|
|
115
|
+
let reasons = 0
|
|
116
|
+
|
|
117
|
+
for (let current = fiberOf(host).return; current; current = current.return) {
|
|
118
|
+
if (current.tag !== OFFSCREEN || !isOffscreenHidden(current)) {
|
|
119
|
+
continue
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const boundary = current.return
|
|
123
|
+
|
|
124
|
+
if (boundary?.tag === ACTIVITY) {
|
|
125
|
+
reasons |= HiddenBy.Activity
|
|
126
|
+
} else if (boundary?.tag === SUSPENSE) {
|
|
127
|
+
reasons |= isFrozenBoundary(boundary) ? HiddenBy.Freeze : HiddenBy.Suspense
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return reasons
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Any hidden Offscreen, as in collectVisibleAncestors. Stops at the first: the reason isn't needed
|
|
135
|
+
export const isHidden = (host: Host): boolean => {
|
|
136
|
+
for (let current = fiberOf(host).return; current; current = current.return) {
|
|
137
|
+
if (current.tag === OFFSCREEN && isOffscreenHidden(current)) {
|
|
138
|
+
return true
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return false
|
|
143
|
+
}
|
|
144
|
+
export const isSuspended = (host: Host) => (getHiddenReasons(host) & HiddenBy.Suspense) !== 0
|
|
145
|
+
export const isFrozen = (host: Host) => (getHiddenReasons(host) & HiddenBy.Freeze) !== 0
|
|
146
|
+
export const isInHiddenActivity = (host: Host) => (getHiddenReasons(host) & HiddenBy.Activity) !== 0
|
|
147
|
+
|
|
148
|
+
const isHiddenOffscreen = (offscreen: RawFiber, boundaries: Map<RawFiber, boolean>): boolean => {
|
|
149
|
+
let hidden = boundaries.get(offscreen)
|
|
150
|
+
|
|
151
|
+
if (hidden === undefined) {
|
|
152
|
+
hidden = isOffscreenHidden(offscreen)
|
|
153
|
+
boundaries.set(offscreen, hidden)
|
|
154
|
+
|
|
155
|
+
if (offscreen.alternate) {
|
|
156
|
+
boundaries.set(offscreen.alternate, hidden)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return hidden
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Hot loops below: indexed loops and writes, explicit null checks, no helper calls (legacy Hermes)
|
|
164
|
+
export const collectVisibleAncestors = (hosts: ReadonlyArray<Host | null | undefined>, visit: (host: Host) => void) => {
|
|
165
|
+
const visibleByTag = new Map<number, boolean>()
|
|
166
|
+
const boundaries = new Map<RawFiber, boolean>()
|
|
167
|
+
const pending: Array<RawFiber> = []
|
|
168
|
+
|
|
169
|
+
for (let h = 0; h < hosts.length; h++) {
|
|
170
|
+
let visible = true
|
|
171
|
+
let count = 0
|
|
172
|
+
|
|
173
|
+
for (let current = hosts[h] as unknown as RawFiber | null | undefined; current != null; current = current.return) {
|
|
174
|
+
if (current.tag === HOST_COMPONENT) {
|
|
175
|
+
const stateNode = current.stateNode
|
|
176
|
+
|
|
177
|
+
if (stateNode == null || stateNode.canonical == null) {
|
|
178
|
+
break
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const answer = visibleByTag.get(stateNode.canonical.nativeTag)
|
|
182
|
+
|
|
183
|
+
if (answer !== undefined) {
|
|
184
|
+
visible = answer
|
|
185
|
+
break
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
pending[count++] = current
|
|
189
|
+
} else if (current.tag === OFFSCREEN && isHiddenOffscreen(current, boundaries)) {
|
|
190
|
+
visible = false
|
|
191
|
+
break
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
for (let i = 0; i < count; i++) {
|
|
196
|
+
const canonical = pending[i]!.stateNode.canonical
|
|
197
|
+
|
|
198
|
+
visibleByTag.set(canonical.nativeTag, visible)
|
|
199
|
+
|
|
200
|
+
if (visible && canonical.internalInstanceHandle != null) {
|
|
201
|
+
visit(canonical.internalInstanceHandle as Host)
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Hidden hosts included
|
|
208
|
+
export const collectAncestors = (hosts: ReadonlyArray<Host | null | undefined>, visit: (host: Host) => void) => {
|
|
209
|
+
const visitedByTag = new Set<number>()
|
|
210
|
+
|
|
211
|
+
for (let h = 0; h < hosts.length; h++) {
|
|
212
|
+
for (let current = hosts[h] as unknown as RawFiber | null | undefined; current != null; current = current.return) {
|
|
213
|
+
if (current.tag !== HOST_COMPONENT) {
|
|
214
|
+
continue
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const stateNode = current.stateNode
|
|
218
|
+
|
|
219
|
+
if (stateNode == null || stateNode.canonical == null) {
|
|
220
|
+
break
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const canonical = stateNode.canonical
|
|
224
|
+
|
|
225
|
+
if (visitedByTag.has(canonical.nativeTag)) {
|
|
226
|
+
break
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
visitedByTag.add(canonical.nativeTag)
|
|
230
|
+
|
|
231
|
+
if (canonical.internalInstanceHandle != null) {
|
|
232
|
+
visit(canonical.internalInstanceHandle as Host)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createOwnerRegistry } from './adapters/registry'
|
|
2
|
+
import { animatedComponentOf, reanimatedCSSAdapter } from './adapters/reanimated'
|
|
3
|
+
import { getCreationStack, getOwners, verify } from './diagnostics'
|
|
4
|
+
import * as HostApi from './host'
|
|
5
|
+
|
|
6
|
+
export type { Host } from './host'
|
|
7
|
+
export type { Drift } from './diagnostics'
|
|
8
|
+
export type { ShadowNode } from './fiber'
|
|
9
|
+
export type { OwnerAdapter, OwnerRegistry, StyleSource } from './adapters/registry'
|
|
10
|
+
|
|
11
|
+
// Object literals, not classes: static methods on a Babel-transpiled class are slower on Hermes
|
|
12
|
+
export const Fiber = {
|
|
13
|
+
getHostFor: HostApi.getHostFor,
|
|
14
|
+
getShadowNodeFor: HostApi.getShadowNodeFor,
|
|
15
|
+
getHostForInstanceHandle: HostApi.getHostForInstanceHandle,
|
|
16
|
+
getContentContainerFor: HostApi.getContentContainerFor,
|
|
17
|
+
|
|
18
|
+
getShadowNode: HostApi.getShadowNode,
|
|
19
|
+
getShadowNodes: HostApi.getShadowNodes,
|
|
20
|
+
getNativeTag: HostApi.getNativeTag,
|
|
21
|
+
getParentHost: HostApi.getParentHost,
|
|
22
|
+
|
|
23
|
+
isHidden: HostApi.isHidden,
|
|
24
|
+
isSuspended: HostApi.isSuspended,
|
|
25
|
+
isFrozen: HostApi.isFrozen,
|
|
26
|
+
isInHiddenActivity: HostApi.isInHiddenActivity,
|
|
27
|
+
|
|
28
|
+
collectVisibleAncestors: HostApi.collectVisibleAncestors,
|
|
29
|
+
collectAncestors: HostApi.collectAncestors,
|
|
30
|
+
|
|
31
|
+
patchRenderedProps: HostApi.patchRenderedProps,
|
|
32
|
+
|
|
33
|
+
verify,
|
|
34
|
+
getOwners,
|
|
35
|
+
getCreationStack,
|
|
36
|
+
|
|
37
|
+
createOwnerRegistry,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const Reanimated = {
|
|
41
|
+
animatedComponentOf,
|
|
42
|
+
cssAdapter: reanimatedCSSAdapter,
|
|
43
|
+
}
|
|
@@ -98,9 +98,13 @@ export const getMediaQuery = (query: string, allBreakpoints: Array<string>) => {
|
|
|
98
98
|
.map((b) => unistyles.services.runtime.breakpoints[b] as number)
|
|
99
99
|
.sort((a, b) => a - b)
|
|
100
100
|
.find((b) => b > breakpointValue)
|
|
101
|
+
// Viewport widths are fractional CSS px under browser zoom / OS scaling, so an integer
|
|
102
|
+
// `max-width: next - 1` leaves a dead band (e.g. 767 < width < 768) that matches neither
|
|
103
|
+
// this breakpoint nor the next one. 0.02px below the next breakpoint (the Bootstrap
|
|
104
|
+
// convention) closes it without overlapping `(min-width: next)`.
|
|
101
105
|
const queries = [
|
|
102
106
|
`(min-width: ${breakpointValue}px)`,
|
|
103
|
-
nextBreakpoint ? `(max-width: ${nextBreakpoint -
|
|
107
|
+
nextBreakpoint ? `(max-width: ${nextBreakpoint - 0.02}px)` : undefined,
|
|
104
108
|
]
|
|
105
109
|
.filter(Boolean)
|
|
106
110
|
.join(' and ')
|
|
@@ -138,12 +142,17 @@ export const checkForAnimated = (value: any): boolean => {
|
|
|
138
142
|
}
|
|
139
143
|
|
|
140
144
|
if (typeof value === 'object' && value !== null) {
|
|
145
|
+
// Reanimated useAnimatedStyle handle, it's a plain object, not an Animated.Node
|
|
146
|
+
// styleUpdaterContainer was added in Reanimated 4.1, so check only the keys every version has
|
|
147
|
+
if ('viewDescriptors' in value && 'initial' in value) {
|
|
148
|
+
return true
|
|
149
|
+
}
|
|
150
|
+
|
|
141
151
|
const objectValues = Object.values(value)
|
|
142
152
|
const secrets = extractSecrets(value)
|
|
143
153
|
|
|
144
|
-
// @ts-expect-error React Native Web exports Animated.AnimatedNode as Animated.Node
|
|
145
154
|
// prettier-ignore
|
|
146
|
-
return value instanceof Animated.Node || objectValues.length > 0 && objectValues.some(checkForAnimated) || secrets && Object.keys(secrets).length === 0
|
|
155
|
+
return value instanceof Animated.Node || objectValues.length > 0 && objectValues.some(checkForAnimated) || !!secrets && Object.keys(secrets).length === 0
|
|
147
156
|
}
|
|
148
157
|
|
|
149
158
|
return false
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/mocks.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"passForwardRef.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/passForwardRef.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scoped-theme.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/scoped-theme.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shadow-registry.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/shadow-registry.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-child-selector.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/web-child-selector.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-listener.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/web-listener.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-pointer-events.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/web-pointer-events.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"web-runtime.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/web-runtime.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withUnistyles.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/withUnistyles.spec.ts"],"names":[],"mappings":""}
|