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.
Files changed (283) hide show
  1. package/README.md +3 -0
  2. package/cxx/converters/BackgroundImageConverter.cpp +198 -11
  3. package/cxx/converters/BackgroundImageConverter.h +1 -0
  4. package/cxx/core/HostUnistyle.cpp +6 -0
  5. package/cxx/hybridObjects/HybridShadowRegistry.cpp +5 -0
  6. package/cxx/parser/Parser.cpp +29 -7
  7. package/ios/NativePlatform+ios.swift +22 -11
  8. package/ios/NativePlatformListener+ios.swift +9 -0
  9. package/lib/commonjs/components/native/deep/ActivityIndicator.js +19 -0
  10. package/lib/commonjs/components/native/deep/ActivityIndicator.js.map +1 -0
  11. package/lib/commonjs/components/native/deep/Animated.js +19 -0
  12. package/lib/commonjs/components/native/deep/Animated.js.map +1 -0
  13. package/lib/commonjs/components/native/deep/FlatList.js +19 -0
  14. package/lib/commonjs/components/native/deep/FlatList.js.map +1 -0
  15. package/lib/commonjs/components/native/deep/Image.js +19 -0
  16. package/lib/commonjs/components/native/deep/Image.js.map +1 -0
  17. package/lib/commonjs/components/native/deep/ImageBackground.js +19 -0
  18. package/lib/commonjs/components/native/deep/ImageBackground.js.map +1 -0
  19. package/lib/commonjs/components/native/deep/KeyboardAvoidingView.js +19 -0
  20. package/lib/commonjs/components/native/deep/KeyboardAvoidingView.js.map +1 -0
  21. package/lib/commonjs/components/native/deep/Pressable.js +19 -0
  22. package/lib/commonjs/components/native/deep/Pressable.js.map +1 -0
  23. package/lib/commonjs/components/native/deep/RefreshControl.js +19 -0
  24. package/lib/commonjs/components/native/deep/RefreshControl.js.map +1 -0
  25. package/lib/commonjs/components/native/deep/SafeAreaView.js +19 -0
  26. package/lib/commonjs/components/native/deep/SafeAreaView.js.map +1 -0
  27. package/lib/commonjs/components/native/deep/ScrollView.js +19 -0
  28. package/lib/commonjs/components/native/deep/ScrollView.js.map +1 -0
  29. package/lib/commonjs/components/native/deep/SectionList.js +19 -0
  30. package/lib/commonjs/components/native/deep/SectionList.js.map +1 -0
  31. package/lib/commonjs/components/native/deep/Switch.js +19 -0
  32. package/lib/commonjs/components/native/deep/Switch.js.map +1 -0
  33. package/lib/commonjs/components/native/deep/Text.js +19 -0
  34. package/lib/commonjs/components/native/deep/Text.js.map +1 -0
  35. package/lib/commonjs/components/native/deep/TextInput.js +19 -0
  36. package/lib/commonjs/components/native/deep/TextInput.js.map +1 -0
  37. package/lib/commonjs/components/native/deep/TextNativeComponent.js +28 -0
  38. package/lib/commonjs/components/native/deep/TextNativeComponent.js.map +1 -0
  39. package/lib/commonjs/components/native/deep/TouchableHighlight.js +19 -0
  40. package/lib/commonjs/components/native/deep/TouchableHighlight.js.map +1 -0
  41. package/lib/commonjs/components/native/deep/TouchableOpacity.js +19 -0
  42. package/lib/commonjs/components/native/deep/TouchableOpacity.js.map +1 -0
  43. package/lib/commonjs/components/native/deep/View.js +19 -0
  44. package/lib/commonjs/components/native/deep/View.js.map +1 -0
  45. package/lib/commonjs/components/native/deep/ViewNativeComponent.js +26 -0
  46. package/lib/commonjs/components/native/deep/ViewNativeComponent.js.map +1 -0
  47. package/lib/commonjs/components/native/deep/VirtualizedList.js +19 -0
  48. package/lib/commonjs/components/native/deep/VirtualizedList.js.map +1 -0
  49. package/lib/commonjs/components/native/index.js +43 -0
  50. package/lib/commonjs/components/native/index.js.map +1 -0
  51. package/lib/commonjs/core/createUnistylesActivityIndicator.js +13 -3
  52. package/lib/commonjs/core/createUnistylesActivityIndicator.js.map +1 -1
  53. package/lib/commonjs/core/createUnistylesElement.native.js +6 -0
  54. package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
  55. package/lib/commonjs/core/createUnistylesImageBackground.js +20 -17
  56. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
  57. package/lib/commonjs/core/createUnistylesTouchableHighlight.js +6 -0
  58. package/lib/commonjs/core/createUnistylesTouchableHighlight.js.map +1 -1
  59. package/lib/commonjs/core/getClassname.js +15 -0
  60. package/lib/commonjs/core/getClassname.js.map +1 -1
  61. package/lib/commonjs/core/hasUnistyles.js +26 -0
  62. package/lib/commonjs/core/hasUnistyles.js.map +1 -0
  63. package/lib/commonjs/specs/ShadowRegistry/index.js +57 -74
  64. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  65. package/lib/commonjs/specs/ShadowRegistry/styleSource.js +65 -0
  66. package/lib/commonjs/specs/ShadowRegistry/styleSource.js.map +1 -0
  67. package/lib/commonjs/unifiber/src/adapters/reanimated.js +157 -0
  68. package/lib/commonjs/unifiber/src/adapters/reanimated.js.map +1 -0
  69. package/lib/commonjs/unifiber/src/adapters/registry.js +67 -0
  70. package/lib/commonjs/unifiber/src/adapters/registry.js.map +1 -0
  71. package/lib/commonjs/unifiber/src/diagnostics.js +59 -0
  72. package/lib/commonjs/unifiber/src/diagnostics.js.map +1 -0
  73. package/lib/commonjs/unifiber/src/fiber.js +199 -0
  74. package/lib/commonjs/unifiber/src/fiber.js.map +1 -0
  75. package/lib/commonjs/unifiber/src/host.js +214 -0
  76. package/lib/commonjs/unifiber/src/host.js.map +1 -0
  77. package/lib/commonjs/unifiber/src/index.js +38 -0
  78. package/lib/commonjs/unifiber/src/index.js.map +1 -0
  79. package/lib/commonjs/web/utils/unistyle.js +11 -3
  80. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  81. package/lib/module/components/native/deep/ActivityIndicator.js +5 -0
  82. package/lib/module/components/native/deep/ActivityIndicator.js.map +1 -0
  83. package/lib/module/components/native/deep/Animated.js +5 -0
  84. package/lib/module/components/native/deep/Animated.js.map +1 -0
  85. package/lib/module/components/native/deep/FlatList.js +5 -0
  86. package/lib/module/components/native/deep/FlatList.js.map +1 -0
  87. package/lib/module/components/native/deep/Image.js +5 -0
  88. package/lib/module/components/native/deep/Image.js.map +1 -0
  89. package/lib/module/components/native/deep/ImageBackground.js +5 -0
  90. package/lib/module/components/native/deep/ImageBackground.js.map +1 -0
  91. package/lib/module/components/native/deep/KeyboardAvoidingView.js +5 -0
  92. package/lib/module/components/native/deep/KeyboardAvoidingView.js.map +1 -0
  93. package/lib/module/components/native/deep/Pressable.js +5 -0
  94. package/lib/module/components/native/deep/Pressable.js.map +1 -0
  95. package/lib/module/components/native/deep/RefreshControl.js +5 -0
  96. package/lib/module/components/native/deep/RefreshControl.js.map +1 -0
  97. package/lib/module/components/native/deep/SafeAreaView.js +5 -0
  98. package/lib/module/components/native/deep/SafeAreaView.js.map +1 -0
  99. package/lib/module/components/native/deep/ScrollView.js +5 -0
  100. package/lib/module/components/native/deep/ScrollView.js.map +1 -0
  101. package/lib/module/components/native/deep/SectionList.js +5 -0
  102. package/lib/module/components/native/deep/SectionList.js.map +1 -0
  103. package/lib/module/components/native/deep/Switch.js +5 -0
  104. package/lib/module/components/native/deep/Switch.js.map +1 -0
  105. package/lib/module/components/native/deep/Text.js +5 -0
  106. package/lib/module/components/native/deep/Text.js.map +1 -0
  107. package/lib/module/components/native/deep/TextInput.js +5 -0
  108. package/lib/module/components/native/deep/TextInput.js.map +1 -0
  109. package/lib/module/components/native/deep/TextNativeComponent.js +8 -0
  110. package/lib/module/components/native/deep/TextNativeComponent.js.map +1 -0
  111. package/lib/module/components/native/deep/TouchableHighlight.js +5 -0
  112. package/lib/module/components/native/deep/TouchableHighlight.js.map +1 -0
  113. package/lib/module/components/native/deep/TouchableOpacity.js +5 -0
  114. package/lib/module/components/native/deep/TouchableOpacity.js.map +1 -0
  115. package/lib/module/components/native/deep/View.js +5 -0
  116. package/lib/module/components/native/deep/View.js.map +1 -0
  117. package/lib/module/components/native/deep/ViewNativeComponent.js +8 -0
  118. package/lib/module/components/native/deep/ViewNativeComponent.js.map +1 -0
  119. package/lib/module/components/native/deep/VirtualizedList.js +5 -0
  120. package/lib/module/components/native/deep/VirtualizedList.js.map +1 -0
  121. package/lib/module/components/native/index.js +43 -0
  122. package/lib/module/components/native/index.js.map +1 -0
  123. package/lib/module/core/createUnistylesActivityIndicator.js +13 -3
  124. package/lib/module/core/createUnistylesActivityIndicator.js.map +1 -1
  125. package/lib/module/core/createUnistylesElement.native.js +6 -0
  126. package/lib/module/core/createUnistylesElement.native.js.map +1 -1
  127. package/lib/module/core/createUnistylesImageBackground.js +20 -17
  128. package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
  129. package/lib/module/core/createUnistylesTouchableHighlight.js +6 -0
  130. package/lib/module/core/createUnistylesTouchableHighlight.js.map +1 -1
  131. package/lib/module/core/getClassname.js +16 -1
  132. package/lib/module/core/getClassname.js.map +1 -1
  133. package/lib/module/core/hasUnistyles.js +21 -0
  134. package/lib/module/core/hasUnistyles.js.map +1 -0
  135. package/lib/module/specs/ShadowRegistry/index.js +57 -74
  136. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  137. package/lib/module/specs/ShadowRegistry/styleSource.js +60 -0
  138. package/lib/module/specs/ShadowRegistry/styleSource.js.map +1 -0
  139. package/lib/module/unifiber/src/adapters/reanimated.js +152 -0
  140. package/lib/module/unifiber/src/adapters/reanimated.js.map +1 -0
  141. package/lib/module/unifiber/src/adapters/registry.js +62 -0
  142. package/lib/module/unifiber/src/adapters/registry.js.map +1 -0
  143. package/lib/module/unifiber/src/diagnostics.js +52 -0
  144. package/lib/module/unifiber/src/diagnostics.js.map +1 -0
  145. package/lib/module/unifiber/src/fiber.js +183 -0
  146. package/lib/module/unifiber/src/fiber.js.map +1 -0
  147. package/lib/module/unifiber/src/host.js +191 -0
  148. package/lib/module/unifiber/src/host.js.map +1 -0
  149. package/lib/module/unifiber/src/index.js +33 -0
  150. package/lib/module/unifiber/src/index.js.map +1 -0
  151. package/lib/module/web/utils/unistyle.js +11 -3
  152. package/lib/module/web/utils/unistyle.js.map +1 -1
  153. package/lib/typescript/src/components/native/deep/ActivityIndicator.d.ts +2 -0
  154. package/lib/typescript/src/components/native/deep/ActivityIndicator.d.ts.map +1 -0
  155. package/lib/typescript/src/components/native/deep/Animated.d.ts +2 -0
  156. package/lib/typescript/src/components/native/deep/Animated.d.ts.map +1 -0
  157. package/lib/typescript/src/components/native/deep/FlatList.d.ts +2 -0
  158. package/lib/typescript/src/components/native/deep/FlatList.d.ts.map +1 -0
  159. package/lib/typescript/src/components/native/deep/Image.d.ts +2 -0
  160. package/lib/typescript/src/components/native/deep/Image.d.ts.map +1 -0
  161. package/lib/typescript/src/components/native/deep/ImageBackground.d.ts +2 -0
  162. package/lib/typescript/src/components/native/deep/ImageBackground.d.ts.map +1 -0
  163. package/lib/typescript/src/components/native/deep/KeyboardAvoidingView.d.ts +2 -0
  164. package/lib/typescript/src/components/native/deep/KeyboardAvoidingView.d.ts.map +1 -0
  165. package/lib/typescript/src/components/native/deep/Pressable.d.ts +2 -0
  166. package/lib/typescript/src/components/native/deep/Pressable.d.ts.map +1 -0
  167. package/lib/typescript/src/components/native/deep/RefreshControl.d.ts +2 -0
  168. package/lib/typescript/src/components/native/deep/RefreshControl.d.ts.map +1 -0
  169. package/lib/typescript/src/components/native/deep/SafeAreaView.d.ts +2 -0
  170. package/lib/typescript/src/components/native/deep/SafeAreaView.d.ts.map +1 -0
  171. package/lib/typescript/src/components/native/deep/ScrollView.d.ts +2 -0
  172. package/lib/typescript/src/components/native/deep/ScrollView.d.ts.map +1 -0
  173. package/lib/typescript/src/components/native/deep/SectionList.d.ts +2 -0
  174. package/lib/typescript/src/components/native/deep/SectionList.d.ts.map +1 -0
  175. package/lib/typescript/src/components/native/deep/Switch.d.ts +2 -0
  176. package/lib/typescript/src/components/native/deep/Switch.d.ts.map +1 -0
  177. package/lib/typescript/src/components/native/deep/Text.d.ts +2 -0
  178. package/lib/typescript/src/components/native/deep/Text.d.ts.map +1 -0
  179. package/lib/typescript/src/components/native/deep/TextInput.d.ts +2 -0
  180. package/lib/typescript/src/components/native/deep/TextInput.d.ts.map +1 -0
  181. package/lib/typescript/src/components/native/deep/TextNativeComponent.d.ts +3 -0
  182. package/lib/typescript/src/components/native/deep/TextNativeComponent.d.ts.map +1 -0
  183. package/lib/typescript/src/components/native/deep/TouchableHighlight.d.ts +2 -0
  184. package/lib/typescript/src/components/native/deep/TouchableHighlight.d.ts.map +1 -0
  185. package/lib/typescript/src/components/native/deep/TouchableOpacity.d.ts +2 -0
  186. package/lib/typescript/src/components/native/deep/TouchableOpacity.d.ts.map +1 -0
  187. package/lib/typescript/src/components/native/deep/View.d.ts +2 -0
  188. package/lib/typescript/src/components/native/deep/View.d.ts.map +1 -0
  189. package/lib/typescript/src/components/native/deep/ViewNativeComponent.d.ts +3 -0
  190. package/lib/typescript/src/components/native/deep/ViewNativeComponent.d.ts.map +1 -0
  191. package/lib/typescript/src/components/native/deep/VirtualizedList.d.ts +2 -0
  192. package/lib/typescript/src/components/native/deep/VirtualizedList.d.ts.map +1 -0
  193. package/lib/typescript/src/components/native/index.d.ts +4 -0
  194. package/lib/typescript/src/components/native/index.d.ts.map +1 -0
  195. package/lib/typescript/src/components/scopeChildren.d.ts +1 -1
  196. package/lib/typescript/src/core/createUnistylesActivityIndicator.d.ts.map +1 -1
  197. package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
  198. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
  199. package/lib/typescript/src/core/createUnistylesTouchableHighlight.d.ts.map +1 -1
  200. package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
  201. package/lib/typescript/src/core/hasUnistyles.d.ts +2 -0
  202. package/lib/typescript/src/core/hasUnistyles.d.ts.map +1 -0
  203. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  204. package/lib/typescript/src/specs/ShadowRegistry/styleSource.d.ts +11 -0
  205. package/lib/typescript/src/specs/ShadowRegistry/styleSource.d.ts.map +1 -0
  206. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +4 -41
  207. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
  208. package/lib/typescript/src/unifiber/src/adapters/reanimated.d.ts +17 -0
  209. package/lib/typescript/src/unifiber/src/adapters/reanimated.d.ts.map +1 -0
  210. package/lib/typescript/src/unifiber/src/adapters/registry.d.ts +23 -0
  211. package/lib/typescript/src/unifiber/src/adapters/registry.d.ts.map +1 -0
  212. package/lib/typescript/src/unifiber/src/diagnostics.d.ts +10 -0
  213. package/lib/typescript/src/unifiber/src/diagnostics.d.ts.map +1 -0
  214. package/lib/typescript/src/unifiber/src/fiber.d.ts +48 -0
  215. package/lib/typescript/src/unifiber/src/fiber.d.ts.map +1 -0
  216. package/lib/typescript/src/unifiber/src/host.d.ts +32 -0
  217. package/lib/typescript/src/unifiber/src/host.d.ts.map +1 -0
  218. package/lib/typescript/src/unifiber/src/index.d.ts +49 -0
  219. package/lib/typescript/src/unifiber/src/index.d.ts.map +1 -0
  220. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  221. package/metro/babel-transformer.js +1040 -0
  222. package/metro/index.d.ts +31 -0
  223. package/metro/index.js +170 -0
  224. package/package.json +26 -8
  225. package/plugin/index.d.ts +7 -0
  226. package/plugin/index.js +36 -16
  227. package/src/components/native/deep/ActivityIndicator.ts +2 -0
  228. package/src/components/native/deep/Animated.ts +2 -0
  229. package/src/components/native/deep/FlatList.ts +2 -0
  230. package/src/components/native/deep/Image.ts +2 -0
  231. package/src/components/native/deep/ImageBackground.ts +2 -0
  232. package/src/components/native/deep/KeyboardAvoidingView.ts +2 -0
  233. package/src/components/native/deep/Pressable.ts +2 -0
  234. package/src/components/native/deep/RefreshControl.ts +2 -0
  235. package/src/components/native/deep/SafeAreaView.ts +2 -0
  236. package/src/components/native/deep/ScrollView.ts +2 -0
  237. package/src/components/native/deep/SectionList.ts +2 -0
  238. package/src/components/native/deep/Switch.ts +2 -0
  239. package/src/components/native/deep/Text.ts +2 -0
  240. package/src/components/native/deep/TextInput.ts +2 -0
  241. package/src/components/native/deep/TextNativeComponent.ts +5 -0
  242. package/src/components/native/deep/TouchableHighlight.ts +2 -0
  243. package/src/components/native/deep/TouchableOpacity.ts +2 -0
  244. package/src/components/native/deep/View.ts +2 -0
  245. package/src/components/native/deep/ViewNativeComponent.ts +5 -0
  246. package/src/components/native/deep/VirtualizedList.ts +2 -0
  247. package/src/components/native/index.ts +41 -0
  248. package/src/core/createUnistylesActivityIndicator.tsx +11 -4
  249. package/src/core/createUnistylesElement.native.tsx +5 -0
  250. package/src/core/createUnistylesImageBackground.tsx +27 -23
  251. package/src/core/createUnistylesTouchableHighlight.tsx +5 -0
  252. package/src/core/getClassname.ts +10 -1
  253. package/src/core/hasUnistyles.ts +20 -0
  254. package/src/specs/ShadowRegistry/index.ts +50 -102
  255. package/src/specs/ShadowRegistry/styleSource.ts +78 -0
  256. package/src/specs/ShadowRegistry/types.ts +3 -43
  257. package/src/unifiber/LICENSE +21 -0
  258. package/src/unifiber/README.md +92 -0
  259. package/src/unifiber/src/adapters/reanimated.ts +204 -0
  260. package/src/unifiber/src/adapters/registry.ts +102 -0
  261. package/src/unifiber/src/diagnostics.ts +55 -0
  262. package/src/unifiber/src/fiber.ts +262 -0
  263. package/src/unifiber/src/host.ts +236 -0
  264. package/src/unifiber/src/index.ts +43 -0
  265. package/src/web/utils/unistyle.ts +12 -3
  266. package/lib/typescript/src/__tests__/mocks.spec.d.ts +0 -2
  267. package/lib/typescript/src/__tests__/mocks.spec.d.ts.map +0 -1
  268. package/lib/typescript/src/__tests__/passForwardRef.spec.d.ts +0 -2
  269. package/lib/typescript/src/__tests__/passForwardRef.spec.d.ts.map +0 -1
  270. package/lib/typescript/src/__tests__/scoped-theme.spec.d.ts +0 -2
  271. package/lib/typescript/src/__tests__/scoped-theme.spec.d.ts.map +0 -1
  272. package/lib/typescript/src/__tests__/shadow-registry.spec.d.ts +0 -2
  273. package/lib/typescript/src/__tests__/shadow-registry.spec.d.ts.map +0 -1
  274. package/lib/typescript/src/__tests__/web-child-selector.spec.d.ts +0 -2
  275. package/lib/typescript/src/__tests__/web-child-selector.spec.d.ts.map +0 -1
  276. package/lib/typescript/src/__tests__/web-listener.spec.d.ts +0 -2
  277. package/lib/typescript/src/__tests__/web-listener.spec.d.ts.map +0 -1
  278. package/lib/typescript/src/__tests__/web-pointer-events.spec.d.ts +0 -2
  279. package/lib/typescript/src/__tests__/web-pointer-events.spec.d.ts.map +0 -1
  280. package/lib/typescript/src/__tests__/web-runtime.spec.d.ts +0 -2
  281. package/lib/typescript/src/__tests__/web-runtime.spec.d.ts.map +0 -1
  282. package/lib/typescript/src/__tests__/withUnistyles.spec.d.ts +0 -2
  283. 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 - 1}px)` : undefined,
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,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=mocks.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mocks.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/mocks.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=passForwardRef.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"passForwardRef.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/passForwardRef.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=scoped-theme.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scoped-theme.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/scoped-theme.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=shadow-registry.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shadow-registry.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/shadow-registry.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=web-child-selector.spec.d.ts.map
@@ -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,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=web-listener.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-listener.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/web-listener.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=web-pointer-events.spec.d.ts.map
@@ -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,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=web-runtime.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-runtime.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/web-runtime.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=withUnistyles.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"withUnistyles.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/withUnistyles.spec.ts"],"names":[],"mappings":""}