react-native-unistyles 3.5.3 → 3.7.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 (401) hide show
  1. package/README.md +6 -8
  2. package/android/build.gradle +42 -0
  3. package/android/src/legacy/java/com/unistyles/NativePlatform+extraWindows.kt +16 -0
  4. package/android/src/main/cxx/NativeUnistylesModule.cpp +5 -11
  5. package/android/src/main/cxx/NativeUnistylesModule.h +0 -4
  6. package/android/src/main/java/com/unistyles/NativePlatform+android.kt +82 -39
  7. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +73 -0
  8. package/android/src/main/java/com/unistyles/UnistylesModule.kt +2 -13
  9. package/android/src/rn86/java/com/unistyles/NativePlatform+extraWindows.kt +28 -0
  10. package/cxx/common/PerformanceTracing.h +85 -0
  11. package/cxx/converters/BackgroundImageConverter.cpp +198 -11
  12. package/cxx/converters/BackgroundImageConverter.h +1 -0
  13. package/cxx/converters/BackgroundLayerConverter.cpp +523 -0
  14. package/cxx/converters/BackgroundLayerConverter.h +14 -0
  15. package/cxx/converters/FontVariationSettingsConverter.cpp +104 -0
  16. package/cxx/converters/FontVariationSettingsConverter.h +17 -0
  17. package/cxx/core/HostUnistyle.cpp +6 -0
  18. package/cxx/core/UnistyleWrapper.h +16 -1
  19. package/cxx/hybridObjects/HybridShadowRegistry.cpp +13 -0
  20. package/cxx/hybridObjects/HybridStyleSheet.cpp +11 -0
  21. package/cxx/hybridObjects/HybridStyleSheet.h +1 -0
  22. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +10 -30
  23. package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -2
  24. package/cxx/parser/Parser.cpp +92 -5
  25. package/cxx/shadowTree/ShadowTreeDiagnostics.cpp +74 -0
  26. package/cxx/shadowTree/ShadowTreeManager.cpp +3 -0
  27. package/ios/NativePlatform+ios.swift +22 -11
  28. package/ios/NativePlatformListener+ios.swift +9 -0
  29. package/lib/commonjs/components/NamedTheme.js +4 -4
  30. package/lib/commonjs/components/NamedTheme.js.map +1 -1
  31. package/lib/commonjs/components/ScopedThemeContext.js +3 -1
  32. package/lib/commonjs/components/ScopedThemeContext.js.map +1 -1
  33. package/lib/commonjs/components/native/deep/ActivityIndicator.js +19 -0
  34. package/lib/commonjs/components/native/deep/ActivityIndicator.js.map +1 -0
  35. package/lib/commonjs/components/native/deep/Animated.js +19 -0
  36. package/lib/commonjs/components/native/deep/Animated.js.map +1 -0
  37. package/lib/commonjs/components/native/deep/FlatList.js +19 -0
  38. package/lib/commonjs/components/native/deep/FlatList.js.map +1 -0
  39. package/lib/commonjs/components/native/deep/Image.js +19 -0
  40. package/lib/commonjs/components/native/deep/Image.js.map +1 -0
  41. package/lib/commonjs/components/native/deep/ImageBackground.js +19 -0
  42. package/lib/commonjs/components/native/deep/ImageBackground.js.map +1 -0
  43. package/lib/commonjs/components/native/deep/KeyboardAvoidingView.js +19 -0
  44. package/lib/commonjs/components/native/deep/KeyboardAvoidingView.js.map +1 -0
  45. package/lib/commonjs/components/native/deep/Pressable.js +19 -0
  46. package/lib/commonjs/components/native/deep/Pressable.js.map +1 -0
  47. package/lib/commonjs/components/native/deep/RefreshControl.js +19 -0
  48. package/lib/commonjs/components/native/deep/RefreshControl.js.map +1 -0
  49. package/lib/commonjs/components/native/deep/SafeAreaView.js +19 -0
  50. package/lib/commonjs/components/native/deep/SafeAreaView.js.map +1 -0
  51. package/lib/commonjs/components/native/deep/ScrollView.js +19 -0
  52. package/lib/commonjs/components/native/deep/ScrollView.js.map +1 -0
  53. package/lib/commonjs/components/native/deep/SectionList.js +19 -0
  54. package/lib/commonjs/components/native/deep/SectionList.js.map +1 -0
  55. package/lib/commonjs/components/native/deep/Switch.js +19 -0
  56. package/lib/commonjs/components/native/deep/Switch.js.map +1 -0
  57. package/lib/commonjs/components/native/deep/Text.js +19 -0
  58. package/lib/commonjs/components/native/deep/Text.js.map +1 -0
  59. package/lib/commonjs/components/native/deep/TextInput.js +19 -0
  60. package/lib/commonjs/components/native/deep/TextInput.js.map +1 -0
  61. package/lib/commonjs/components/native/deep/TextNativeComponent.js +28 -0
  62. package/lib/commonjs/components/native/deep/TextNativeComponent.js.map +1 -0
  63. package/lib/commonjs/components/native/deep/TouchableHighlight.js +19 -0
  64. package/lib/commonjs/components/native/deep/TouchableHighlight.js.map +1 -0
  65. package/lib/commonjs/components/native/deep/TouchableOpacity.js +19 -0
  66. package/lib/commonjs/components/native/deep/TouchableOpacity.js.map +1 -0
  67. package/lib/commonjs/components/native/deep/View.js +19 -0
  68. package/lib/commonjs/components/native/deep/View.js.map +1 -0
  69. package/lib/commonjs/components/native/deep/ViewNativeComponent.js +26 -0
  70. package/lib/commonjs/components/native/deep/ViewNativeComponent.js.map +1 -0
  71. package/lib/commonjs/components/native/deep/VirtualizedList.js +19 -0
  72. package/lib/commonjs/components/native/deep/VirtualizedList.js.map +1 -0
  73. package/lib/commonjs/components/native/index.js +43 -0
  74. package/lib/commonjs/components/native/index.js.map +1 -0
  75. package/lib/commonjs/core/createUnistylesActivityIndicator.js +13 -3
  76. package/lib/commonjs/core/createUnistylesActivityIndicator.js.map +1 -1
  77. package/lib/commonjs/core/createUnistylesElement.native.js +6 -0
  78. package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
  79. package/lib/commonjs/core/createUnistylesImageBackground.js +26 -19
  80. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
  81. package/lib/commonjs/core/createUnistylesTouchableHighlight.js +6 -0
  82. package/lib/commonjs/core/createUnistylesTouchableHighlight.js.map +1 -1
  83. package/lib/commonjs/core/getClassname.js +15 -0
  84. package/lib/commonjs/core/getClassname.js.map +1 -1
  85. package/lib/commonjs/core/hasUnistyles.js +26 -0
  86. package/lib/commonjs/core/hasUnistyles.js.map +1 -0
  87. package/lib/commonjs/core/withUnistyles/withUnistyles.js +10 -7
  88. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
  89. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +22 -3
  90. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
  91. package/lib/commonjs/mocks.js +27 -3
  92. package/lib/commonjs/mocks.js.map +1 -1
  93. package/lib/commonjs/specs/ShadowRegistry/index.js +69 -76
  94. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  95. package/lib/commonjs/specs/ShadowRegistry/styleSource.js +65 -0
  96. package/lib/commonjs/specs/ShadowRegistry/styleSource.js.map +1 -0
  97. package/lib/commonjs/specs/ShadowRegistry/tracing.js +26 -0
  98. package/lib/commonjs/specs/ShadowRegistry/tracing.js.map +1 -0
  99. package/lib/commonjs/unifiber/src/adapters/reanimated.js +157 -0
  100. package/lib/commonjs/unifiber/src/adapters/reanimated.js.map +1 -0
  101. package/lib/commonjs/unifiber/src/adapters/registry.js +67 -0
  102. package/lib/commonjs/unifiber/src/adapters/registry.js.map +1 -0
  103. package/lib/commonjs/unifiber/src/diagnostics.js +59 -0
  104. package/lib/commonjs/unifiber/src/diagnostics.js.map +1 -0
  105. package/lib/commonjs/unifiber/src/fiber.js +199 -0
  106. package/lib/commonjs/unifiber/src/fiber.js.map +1 -0
  107. package/lib/commonjs/unifiber/src/host.js +214 -0
  108. package/lib/commonjs/unifiber/src/host.js.map +1 -0
  109. package/lib/commonjs/unifiber/src/index.js +38 -0
  110. package/lib/commonjs/unifiber/src/index.js.map +1 -0
  111. package/lib/commonjs/utils.js +52 -1
  112. package/lib/commonjs/utils.js.map +1 -1
  113. package/lib/commonjs/web/convert/index.js +19 -1
  114. package/lib/commonjs/web/convert/index.js.map +1 -1
  115. package/lib/commonjs/web/convert/module.d.ts +3 -0
  116. package/lib/commonjs/web/convert/object/backgroundLayers.js +30 -0
  117. package/lib/commonjs/web/convert/object/backgroundLayers.js.map +1 -0
  118. package/lib/commonjs/web/convert/object/fontVariationSettings.js +12 -0
  119. package/lib/commonjs/web/convert/object/fontVariationSettings.js.map +1 -0
  120. package/lib/commonjs/web/convert/object/index.js +22 -0
  121. package/lib/commonjs/web/convert/object/index.js.map +1 -1
  122. package/lib/commonjs/web/convert/utils.js +7 -1
  123. package/lib/commonjs/web/convert/utils.js.map +1 -1
  124. package/lib/commonjs/web/registry.js +6 -4
  125. package/lib/commonjs/web/registry.js.map +1 -1
  126. package/lib/commonjs/web/runtime.js +9 -6
  127. package/lib/commonjs/web/runtime.js.map +1 -1
  128. package/lib/commonjs/web/utils/unistyle.js +9 -3
  129. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  130. package/lib/module/components/NamedTheme.js +4 -4
  131. package/lib/module/components/NamedTheme.js.map +1 -1
  132. package/lib/module/components/ScopedThemeContext.js +3 -1
  133. package/lib/module/components/ScopedThemeContext.js.map +1 -1
  134. package/lib/module/components/native/deep/ActivityIndicator.js +5 -0
  135. package/lib/module/components/native/deep/ActivityIndicator.js.map +1 -0
  136. package/lib/module/components/native/deep/Animated.js +5 -0
  137. package/lib/module/components/native/deep/Animated.js.map +1 -0
  138. package/lib/module/components/native/deep/FlatList.js +5 -0
  139. package/lib/module/components/native/deep/FlatList.js.map +1 -0
  140. package/lib/module/components/native/deep/Image.js +5 -0
  141. package/lib/module/components/native/deep/Image.js.map +1 -0
  142. package/lib/module/components/native/deep/ImageBackground.js +5 -0
  143. package/lib/module/components/native/deep/ImageBackground.js.map +1 -0
  144. package/lib/module/components/native/deep/KeyboardAvoidingView.js +5 -0
  145. package/lib/module/components/native/deep/KeyboardAvoidingView.js.map +1 -0
  146. package/lib/module/components/native/deep/Pressable.js +5 -0
  147. package/lib/module/components/native/deep/Pressable.js.map +1 -0
  148. package/lib/module/components/native/deep/RefreshControl.js +5 -0
  149. package/lib/module/components/native/deep/RefreshControl.js.map +1 -0
  150. package/lib/module/components/native/deep/SafeAreaView.js +5 -0
  151. package/lib/module/components/native/deep/SafeAreaView.js.map +1 -0
  152. package/lib/module/components/native/deep/ScrollView.js +5 -0
  153. package/lib/module/components/native/deep/ScrollView.js.map +1 -0
  154. package/lib/module/components/native/deep/SectionList.js +5 -0
  155. package/lib/module/components/native/deep/SectionList.js.map +1 -0
  156. package/lib/module/components/native/deep/Switch.js +5 -0
  157. package/lib/module/components/native/deep/Switch.js.map +1 -0
  158. package/lib/module/components/native/deep/Text.js +5 -0
  159. package/lib/module/components/native/deep/Text.js.map +1 -0
  160. package/lib/module/components/native/deep/TextInput.js +5 -0
  161. package/lib/module/components/native/deep/TextInput.js.map +1 -0
  162. package/lib/module/components/native/deep/TextNativeComponent.js +8 -0
  163. package/lib/module/components/native/deep/TextNativeComponent.js.map +1 -0
  164. package/lib/module/components/native/deep/TouchableHighlight.js +5 -0
  165. package/lib/module/components/native/deep/TouchableHighlight.js.map +1 -0
  166. package/lib/module/components/native/deep/TouchableOpacity.js +5 -0
  167. package/lib/module/components/native/deep/TouchableOpacity.js.map +1 -0
  168. package/lib/module/components/native/deep/View.js +5 -0
  169. package/lib/module/components/native/deep/View.js.map +1 -0
  170. package/lib/module/components/native/deep/ViewNativeComponent.js +8 -0
  171. package/lib/module/components/native/deep/ViewNativeComponent.js.map +1 -0
  172. package/lib/module/components/native/deep/VirtualizedList.js +5 -0
  173. package/lib/module/components/native/deep/VirtualizedList.js.map +1 -0
  174. package/lib/module/components/native/index.js +43 -0
  175. package/lib/module/components/native/index.js.map +1 -0
  176. package/lib/module/core/createUnistylesActivityIndicator.js +13 -3
  177. package/lib/module/core/createUnistylesActivityIndicator.js.map +1 -1
  178. package/lib/module/core/createUnistylesElement.native.js +6 -0
  179. package/lib/module/core/createUnistylesElement.native.js.map +1 -1
  180. package/lib/module/core/createUnistylesImageBackground.js +26 -19
  181. package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
  182. package/lib/module/core/createUnistylesTouchableHighlight.js +6 -0
  183. package/lib/module/core/createUnistylesTouchableHighlight.js.map +1 -1
  184. package/lib/module/core/getClassname.js +16 -1
  185. package/lib/module/core/getClassname.js.map +1 -1
  186. package/lib/module/core/hasUnistyles.js +21 -0
  187. package/lib/module/core/hasUnistyles.js.map +1 -0
  188. package/lib/module/core/withUnistyles/withUnistyles.js +9 -6
  189. package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
  190. package/lib/module/core/withUnistyles/withUnistyles.native.js +24 -5
  191. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
  192. package/lib/module/mocks.js +27 -3
  193. package/lib/module/mocks.js.map +1 -1
  194. package/lib/module/specs/ShadowRegistry/index.js +69 -76
  195. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  196. package/lib/module/specs/ShadowRegistry/styleSource.js +60 -0
  197. package/lib/module/specs/ShadowRegistry/styleSource.js.map +1 -0
  198. package/lib/module/specs/ShadowRegistry/tracing.js +21 -0
  199. package/lib/module/specs/ShadowRegistry/tracing.js.map +1 -0
  200. package/lib/module/unifiber/src/adapters/reanimated.js +152 -0
  201. package/lib/module/unifiber/src/adapters/reanimated.js.map +1 -0
  202. package/lib/module/unifiber/src/adapters/registry.js +62 -0
  203. package/lib/module/unifiber/src/adapters/registry.js.map +1 -0
  204. package/lib/module/unifiber/src/diagnostics.js +52 -0
  205. package/lib/module/unifiber/src/diagnostics.js.map +1 -0
  206. package/lib/module/unifiber/src/fiber.js +183 -0
  207. package/lib/module/unifiber/src/fiber.js.map +1 -0
  208. package/lib/module/unifiber/src/host.js +191 -0
  209. package/lib/module/unifiber/src/host.js.map +1 -0
  210. package/lib/module/unifiber/src/index.js +33 -0
  211. package/lib/module/unifiber/src/index.js.map +1 -0
  212. package/lib/module/utils.js +50 -0
  213. package/lib/module/utils.js.map +1 -1
  214. package/lib/module/web/convert/index.js +22 -3
  215. package/lib/module/web/convert/index.js.map +1 -1
  216. package/lib/module/web/convert/module.d.ts +3 -0
  217. package/lib/module/web/convert/object/backgroundLayers.js +25 -0
  218. package/lib/module/web/convert/object/backgroundLayers.js.map +1 -0
  219. package/lib/module/web/convert/object/fontVariationSettings.js +7 -0
  220. package/lib/module/web/convert/object/fontVariationSettings.js.map +1 -0
  221. package/lib/module/web/convert/object/index.js +2 -0
  222. package/lib/module/web/convert/object/index.js.map +1 -1
  223. package/lib/module/web/convert/utils.js +4 -0
  224. package/lib/module/web/convert/utils.js.map +1 -1
  225. package/lib/module/web/registry.js +6 -4
  226. package/lib/module/web/registry.js.map +1 -1
  227. package/lib/module/web/runtime.js +9 -6
  228. package/lib/module/web/runtime.js.map +1 -1
  229. package/lib/module/web/utils/unistyle.js +10 -4
  230. package/lib/module/web/utils/unistyle.js.map +1 -1
  231. package/lib/typescript/src/components/ScopedThemeContext.d.ts +2 -1
  232. package/lib/typescript/src/components/ScopedThemeContext.d.ts.map +1 -1
  233. package/lib/typescript/src/components/native/deep/ActivityIndicator.d.ts +2 -0
  234. package/lib/typescript/src/components/native/deep/ActivityIndicator.d.ts.map +1 -0
  235. package/lib/typescript/src/components/native/deep/Animated.d.ts +2 -0
  236. package/lib/typescript/src/components/native/deep/Animated.d.ts.map +1 -0
  237. package/lib/typescript/src/components/native/deep/FlatList.d.ts +2 -0
  238. package/lib/typescript/src/components/native/deep/FlatList.d.ts.map +1 -0
  239. package/lib/typescript/src/components/native/deep/Image.d.ts +2 -0
  240. package/lib/typescript/src/components/native/deep/Image.d.ts.map +1 -0
  241. package/lib/typescript/src/components/native/deep/ImageBackground.d.ts +2 -0
  242. package/lib/typescript/src/components/native/deep/ImageBackground.d.ts.map +1 -0
  243. package/lib/typescript/src/components/native/deep/KeyboardAvoidingView.d.ts +2 -0
  244. package/lib/typescript/src/components/native/deep/KeyboardAvoidingView.d.ts.map +1 -0
  245. package/lib/typescript/src/components/native/deep/Pressable.d.ts +2 -0
  246. package/lib/typescript/src/components/native/deep/Pressable.d.ts.map +1 -0
  247. package/lib/typescript/src/components/native/deep/RefreshControl.d.ts +2 -0
  248. package/lib/typescript/src/components/native/deep/RefreshControl.d.ts.map +1 -0
  249. package/lib/typescript/src/components/native/deep/SafeAreaView.d.ts +2 -0
  250. package/lib/typescript/src/components/native/deep/SafeAreaView.d.ts.map +1 -0
  251. package/lib/typescript/src/components/native/deep/ScrollView.d.ts +2 -0
  252. package/lib/typescript/src/components/native/deep/ScrollView.d.ts.map +1 -0
  253. package/lib/typescript/src/components/native/deep/SectionList.d.ts +2 -0
  254. package/lib/typescript/src/components/native/deep/SectionList.d.ts.map +1 -0
  255. package/lib/typescript/src/components/native/deep/Switch.d.ts +2 -0
  256. package/lib/typescript/src/components/native/deep/Switch.d.ts.map +1 -0
  257. package/lib/typescript/src/components/native/deep/Text.d.ts +2 -0
  258. package/lib/typescript/src/components/native/deep/Text.d.ts.map +1 -0
  259. package/lib/typescript/src/components/native/deep/TextInput.d.ts +2 -0
  260. package/lib/typescript/src/components/native/deep/TextInput.d.ts.map +1 -0
  261. package/lib/typescript/src/components/native/deep/TextNativeComponent.d.ts +3 -0
  262. package/lib/typescript/src/components/native/deep/TextNativeComponent.d.ts.map +1 -0
  263. package/lib/typescript/src/components/native/deep/TouchableHighlight.d.ts +2 -0
  264. package/lib/typescript/src/components/native/deep/TouchableHighlight.d.ts.map +1 -0
  265. package/lib/typescript/src/components/native/deep/TouchableOpacity.d.ts +2 -0
  266. package/lib/typescript/src/components/native/deep/TouchableOpacity.d.ts.map +1 -0
  267. package/lib/typescript/src/components/native/deep/View.d.ts +2 -0
  268. package/lib/typescript/src/components/native/deep/View.d.ts.map +1 -0
  269. package/lib/typescript/src/components/native/deep/ViewNativeComponent.d.ts +3 -0
  270. package/lib/typescript/src/components/native/deep/ViewNativeComponent.d.ts.map +1 -0
  271. package/lib/typescript/src/components/native/deep/VirtualizedList.d.ts +2 -0
  272. package/lib/typescript/src/components/native/deep/VirtualizedList.d.ts.map +1 -0
  273. package/lib/typescript/src/components/native/index.d.ts +4 -0
  274. package/lib/typescript/src/components/native/index.d.ts.map +1 -0
  275. package/lib/typescript/src/components/scopeChildren.d.ts +1 -1
  276. package/lib/typescript/src/core/createUnistylesActivityIndicator.d.ts.map +1 -1
  277. package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
  278. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
  279. package/lib/typescript/src/core/createUnistylesTouchableHighlight.d.ts.map +1 -1
  280. package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
  281. package/lib/typescript/src/core/hasUnistyles.d.ts +2 -0
  282. package/lib/typescript/src/core/hasUnistyles.d.ts.map +1 -0
  283. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts +6 -3
  284. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
  285. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts +7 -4
  286. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
  287. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  288. package/lib/typescript/src/specs/ShadowRegistry/styleSource.d.ts +11 -0
  289. package/lib/typescript/src/specs/ShadowRegistry/styleSource.d.ts.map +1 -0
  290. package/lib/typescript/src/specs/ShadowRegistry/tracing.d.ts +2 -0
  291. package/lib/typescript/src/specs/ShadowRegistry/tracing.d.ts.map +1 -0
  292. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +4 -41
  293. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
  294. package/lib/typescript/src/unifiber/src/adapters/reanimated.d.ts +17 -0
  295. package/lib/typescript/src/unifiber/src/adapters/reanimated.d.ts.map +1 -0
  296. package/lib/typescript/src/unifiber/src/adapters/registry.d.ts +23 -0
  297. package/lib/typescript/src/unifiber/src/adapters/registry.d.ts.map +1 -0
  298. package/lib/typescript/src/unifiber/src/diagnostics.d.ts +10 -0
  299. package/lib/typescript/src/unifiber/src/diagnostics.d.ts.map +1 -0
  300. package/lib/typescript/src/unifiber/src/fiber.d.ts +48 -0
  301. package/lib/typescript/src/unifiber/src/fiber.d.ts.map +1 -0
  302. package/lib/typescript/src/unifiber/src/host.d.ts +32 -0
  303. package/lib/typescript/src/unifiber/src/host.d.ts.map +1 -0
  304. package/lib/typescript/src/unifiber/src/index.d.ts +49 -0
  305. package/lib/typescript/src/unifiber/src/index.d.ts.map +1 -0
  306. package/lib/typescript/src/utils.d.ts +1 -0
  307. package/lib/typescript/src/utils.d.ts.map +1 -1
  308. package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
  309. package/lib/typescript/src/web/convert/object/backgroundLayers.d.ts +4 -0
  310. package/lib/typescript/src/web/convert/object/backgroundLayers.d.ts.map +1 -0
  311. package/lib/typescript/src/web/convert/object/fontVariationSettings.d.ts +4 -0
  312. package/lib/typescript/src/web/convert/object/fontVariationSettings.d.ts.map +1 -0
  313. package/lib/typescript/src/web/convert/object/index.d.ts +2 -0
  314. package/lib/typescript/src/web/convert/object/index.d.ts.map +1 -1
  315. package/lib/typescript/src/web/convert/utils.d.ts +2 -0
  316. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  317. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  318. package/lib/typescript/src/web/runtime.d.ts +1 -0
  319. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  320. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  321. package/metro/babel-transformer.js +1102 -0
  322. package/metro/index.d.ts +31 -0
  323. package/metro/index.js +170 -0
  324. package/package.json +50 -32
  325. package/plugin/index.d.ts +7 -0
  326. package/plugin/index.js +115 -33
  327. package/src/components/NamedTheme.tsx +5 -5
  328. package/src/components/ScopedThemeContext.ts +6 -2
  329. package/src/components/native/deep/ActivityIndicator.ts +2 -0
  330. package/src/components/native/deep/Animated.ts +2 -0
  331. package/src/components/native/deep/FlatList.ts +2 -0
  332. package/src/components/native/deep/Image.ts +2 -0
  333. package/src/components/native/deep/ImageBackground.ts +2 -0
  334. package/src/components/native/deep/KeyboardAvoidingView.ts +2 -0
  335. package/src/components/native/deep/Pressable.ts +2 -0
  336. package/src/components/native/deep/RefreshControl.ts +2 -0
  337. package/src/components/native/deep/SafeAreaView.ts +2 -0
  338. package/src/components/native/deep/ScrollView.ts +2 -0
  339. package/src/components/native/deep/SectionList.ts +2 -0
  340. package/src/components/native/deep/Switch.ts +2 -0
  341. package/src/components/native/deep/Text.ts +2 -0
  342. package/src/components/native/deep/TextInput.ts +2 -0
  343. package/src/components/native/deep/TextNativeComponent.ts +5 -0
  344. package/src/components/native/deep/TouchableHighlight.ts +2 -0
  345. package/src/components/native/deep/TouchableOpacity.ts +2 -0
  346. package/src/components/native/deep/View.ts +2 -0
  347. package/src/components/native/deep/ViewNativeComponent.ts +5 -0
  348. package/src/components/native/deep/VirtualizedList.ts +2 -0
  349. package/src/components/native/index.ts +41 -0
  350. package/src/core/createUnistylesActivityIndicator.tsx +11 -4
  351. package/src/core/createUnistylesElement.native.tsx +5 -0
  352. package/src/core/createUnistylesImageBackground.tsx +33 -25
  353. package/src/core/createUnistylesTouchableHighlight.tsx +5 -0
  354. package/src/core/getClassname.ts +10 -1
  355. package/src/core/hasUnistyles.ts +20 -0
  356. package/src/core/withUnistyles/withUnistyles.native.tsx +28 -6
  357. package/src/core/withUnistyles/withUnistyles.tsx +6 -6
  358. package/src/mocks.ts +14 -5
  359. package/src/specs/ShadowRegistry/index.ts +62 -103
  360. package/src/specs/ShadowRegistry/styleSource.ts +78 -0
  361. package/src/specs/ShadowRegistry/tracing.ts +23 -0
  362. package/src/specs/ShadowRegistry/types.ts +3 -43
  363. package/src/unifiber/LICENSE +21 -0
  364. package/src/unifiber/README.md +92 -0
  365. package/src/unifiber/src/adapters/reanimated.ts +204 -0
  366. package/src/unifiber/src/adapters/registry.ts +102 -0
  367. package/src/unifiber/src/diagnostics.ts +55 -0
  368. package/src/unifiber/src/fiber.ts +262 -0
  369. package/src/unifiber/src/host.ts +236 -0
  370. package/src/unifiber/src/index.ts +43 -0
  371. package/src/utils.ts +51 -0
  372. package/src/web/convert/index.ts +39 -3
  373. package/src/web/convert/object/backgroundLayers.ts +33 -0
  374. package/src/web/convert/object/fontVariationSettings.ts +7 -0
  375. package/src/web/convert/object/index.ts +2 -0
  376. package/src/web/convert/utils.ts +11 -0
  377. package/src/web/registry.ts +7 -8
  378. package/src/web/runtime.ts +7 -7
  379. package/src/web/utils/unistyle.ts +11 -4
  380. package/lib/commonjs/web/convert/module.d.js +0 -2
  381. package/lib/commonjs/web/convert/module.d.js.map +0 -1
  382. package/lib/module/web/convert/module.d.js +0 -2
  383. package/lib/module/web/convert/module.d.js.map +0 -1
  384. package/lib/typescript/src/__tests__/mocks.spec.d.ts +0 -2
  385. package/lib/typescript/src/__tests__/mocks.spec.d.ts.map +0 -1
  386. package/lib/typescript/src/__tests__/passForwardRef.spec.d.ts +0 -2
  387. package/lib/typescript/src/__tests__/passForwardRef.spec.d.ts.map +0 -1
  388. package/lib/typescript/src/__tests__/scoped-theme.spec.d.ts +0 -2
  389. package/lib/typescript/src/__tests__/scoped-theme.spec.d.ts.map +0 -1
  390. package/lib/typescript/src/__tests__/shadow-registry.spec.d.ts +0 -2
  391. package/lib/typescript/src/__tests__/shadow-registry.spec.d.ts.map +0 -1
  392. package/lib/typescript/src/__tests__/web-child-selector.spec.d.ts +0 -2
  393. package/lib/typescript/src/__tests__/web-child-selector.spec.d.ts.map +0 -1
  394. package/lib/typescript/src/__tests__/web-listener.spec.d.ts +0 -2
  395. package/lib/typescript/src/__tests__/web-listener.spec.d.ts.map +0 -1
  396. package/lib/typescript/src/__tests__/web-pointer-events.spec.d.ts +0 -2
  397. package/lib/typescript/src/__tests__/web-pointer-events.spec.d.ts.map +0 -1
  398. package/lib/typescript/src/__tests__/web-runtime.spec.d.ts +0 -2
  399. package/lib/typescript/src/__tests__/web-runtime.spec.d.ts.map +0 -1
  400. package/lib/typescript/src/__tests__/withUnistyles.spec.d.ts +0 -2
  401. package/lib/typescript/src/__tests__/withUnistyles.spec.d.ts.map +0 -1
@@ -0,0 +1,204 @@
1
+ // Keeps Reanimated's CSS style copy (`_cssStyle`) in sync with native-only style updates.
2
+ // Private fields are pinned by test/reanimated-contract.test.ts for 4.5 and 4.7.
3
+ import type { Host } from '../host'
4
+ import type { OwnerAdapter, StyleSource } from './registry'
5
+ import * as fiber from '../fiber'
6
+
7
+ // Bound once: Metro's inline requires
8
+ const { contextReaderFor } = fiber
9
+ const CLASS_COMPONENT = fiber.Tag.ClassComponent
10
+
11
+ type CSSManagerLike = { update(style: Record<string, unknown>, props?: Record<string, unknown>): void }
12
+
13
+ type AnimatedComponentLike = {
14
+ props: Record<string, any>
15
+ _cssStyle: Record<string, unknown>
16
+ _CSSManager?: CSSManagerLike
17
+ // true between componentWillUnmount and componentDidMount: also while frozen, suspended or in a hidden Activity
18
+ _willUnmount?: boolean
19
+ _updateStyles(props: Record<string, any>): void
20
+ shouldComponentUpdate(nextProps: Record<string, any>, ...rest: Array<unknown>): boolean
21
+ }
22
+
23
+ type AttachedState = {
24
+ source: StyleSource
25
+ original: (props: Record<string, any>) => void
26
+ originalShouldUpdate: AnimatedComponentLike['shouldComponentUpdate']
27
+ rendering: boolean
28
+ styleProp: unknown
29
+ epoch: number
30
+ contextKeys: Array<unknown>
31
+ fresh: Record<string, unknown> | undefined
32
+ }
33
+
34
+ // Symbol.for: two copies of unifiber in one bundle never wrap a component twice
35
+ const STATE = Symbol.for('unifiber.reanimated.css')
36
+
37
+ // Kept out of AnimatedComponentLike: a unique symbol in a public type breaks consumers' declaration builds (TS4023)
38
+ type Attached = AnimatedComponentLike & { [STATE]?: AttachedState }
39
+
40
+ const hasCSSConfig = (cssStyle: Record<string, unknown>) => {
41
+ for (const key in cssStyle) {
42
+ if (key.startsWith('transition') || key.startsWith('animation')) {
43
+ return true
44
+ }
45
+ }
46
+
47
+ return false
48
+ }
49
+
50
+ // Keyframe animations and pseudo-styles register again on update after componentWillUnmount cleaned them up.
51
+ // React runs no componentWillUnmount for a subtree deleted while hidden, so on a hidden owner they would leak.
52
+ const registersOnUpdate = (cssStyle: Record<string, unknown>) => {
53
+ for (const key in cssStyle) {
54
+ if (key.startsWith('animation')) {
55
+ return true
56
+ }
57
+
58
+ const value = cssStyle[key]
59
+
60
+ if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
61
+ for (const selector in value) {
62
+ if (selector === 'default' || selector.startsWith(':')) {
63
+ return true
64
+ }
65
+
66
+ break
67
+ }
68
+ }
69
+ }
70
+
71
+ return false
72
+ }
73
+
74
+ // Deepest case: ScrollView with refreshControl on Android, 6-7 fibers
75
+ const MAX_OWNER_DEPTH = 12
76
+
77
+ // The class whose `_componentRef` is this host's public instance. Lists don't match: their ref isn't a host.
78
+ export const animatedComponentOf = (host: Host | null | undefined): AnimatedComponentLike | null => {
79
+ const fiber = host as any
80
+
81
+ if (fiber?.memoizedProps?.collapsable !== false) {
82
+ return null
83
+ }
84
+
85
+ const publicInstance = fiber.stateNode?.canonical?.publicInstance
86
+
87
+ if (!publicInstance) {
88
+ return null
89
+ }
90
+
91
+ let current = fiber.return
92
+
93
+ for (let depth = 0; current && depth < MAX_OWNER_DEPTH; depth++) {
94
+ if (current.tag === CLASS_COMPONENT && current.stateNode?._componentRef === publicInstance) {
95
+ return isAnimatedComponent(current.stateNode) ? current.stateNode : null
96
+ }
97
+
98
+ current = current.return
99
+ }
100
+
101
+ return null
102
+ }
103
+
104
+ const isAnimatedComponent = (owner: any): owner is AnimatedComponentLike =>
105
+ typeof owner?._updateStyles === 'function' &&
106
+ typeof owner.shouldComponentUpdate === 'function' &&
107
+ owner._cssStyle !== null &&
108
+ typeof owner._cssStyle === 'object'
109
+
110
+ function updateStylesThroughSource(this: Attached, props: Record<string, any>) {
111
+ const state = this[STATE]!
112
+
113
+ state.original.call(this, props)
114
+
115
+ if (!hasCSSConfig(this._cssStyle)) {
116
+ return
117
+ }
118
+
119
+ const epoch = state.source.epoch()
120
+ const read = contextReaderFor(this, state.rendering)
121
+ const contexts = state.source.contexts ?? []
122
+ let contextChanged = false
123
+
124
+ for (let i = 0; i < contexts.length; i++) {
125
+ const context = contexts[i]!
126
+ const value = read(context)
127
+ const key = state.source.contextKey ? state.source.contextKey(context, value) : value
128
+
129
+ if (state.contextKeys[i] !== key) {
130
+ state.contextKeys[i] = key
131
+ contextChanged = true
132
+ }
133
+ }
134
+
135
+ if (contextChanged || state.styleProp !== props.style || state.epoch !== epoch) {
136
+ state.fresh = state.source.resolve(props, read)
137
+ state.styleProp = props.style
138
+ state.epoch = epoch
139
+ }
140
+
141
+ const fresh = state.fresh
142
+
143
+ if (!fresh) {
144
+ return
145
+ }
146
+
147
+ // only the keys Reanimated kept: animated styles were split out of _cssStyle
148
+ for (const key in this._cssStyle) {
149
+ if (key in fresh) {
150
+ this._cssStyle[key] = fresh[key]
151
+ }
152
+ }
153
+ }
154
+
155
+ // Marks the render phase, where context must be read from React's stack
156
+ function shouldUpdateMarkingRender(this: Attached, ...args: [Record<string, any>, ...Array<unknown>]) {
157
+ const state = this[STATE]!
158
+
159
+ state.rendering = true
160
+
161
+ try {
162
+ return state.originalShouldUpdate.apply(this, args)
163
+ } finally {
164
+ state.rendering = false
165
+ }
166
+ }
167
+
168
+ export const reanimatedCSSAdapter: OwnerAdapter<AnimatedComponentLike> = {
169
+ name: 'react-native-reanimated/css',
170
+ gate: (host: Host) => (host as unknown as fiber.RawFiber).memoizedProps?.collapsable === false,
171
+ claim: animatedComponentOf,
172
+ attach: (owner: Attached, source) => {
173
+ if (owner[STATE]) {
174
+ return
175
+ }
176
+
177
+ owner[STATE] = {
178
+ source,
179
+ original: owner._updateStyles,
180
+ originalShouldUpdate: owner.shouldComponentUpdate,
181
+ rendering: false,
182
+ styleProp: undefined,
183
+ epoch: -1,
184
+ contextKeys: [],
185
+ fresh: undefined,
186
+ }
187
+ owner._updateStyles = updateStylesThroughSource
188
+ owner.shouldComponentUpdate = shouldUpdateMarkingRender
189
+ },
190
+ refresh: (owner) => {
191
+ // not mounted yet
192
+ if (typeof owner._CSSManager?.update !== 'function') {
193
+ return
194
+ }
195
+
196
+ // Hidden transitions still run, so the reveal shows the new value instead of animating from the old one
197
+ if (owner._willUnmount === true && registersOnUpdate(owner._cssStyle)) {
198
+ return
199
+ }
200
+
201
+ owner._updateStyles(owner.props)
202
+ owner._CSSManager.update(owner._cssStyle, owner.props)
203
+ },
204
+ }
@@ -0,0 +1,102 @@
1
+ import type { Context } from 'react'
2
+ import type { ContextReader } from '../fiber'
3
+ import type { Host } from '../host'
4
+
5
+ export interface StyleSource {
6
+ readonly name: string
7
+ // bumps on every runtime change (theme, breakpoint, ...)
8
+ epoch(): number
9
+ readonly contexts?: ReadonlyArray<Context<any>>
10
+ // cache key for a context value; default: the value itself. Stable scopes renamed in place need `scope?.name`
11
+ contextKey?(context: Context<any>, value: unknown): unknown
12
+ // undefined: none of these styles belong to this source
13
+ resolve(props: Record<string, any>, read: ContextReader): Record<string, unknown> | undefined
14
+ }
15
+
16
+ export interface OwnerAdapter<Owner extends object = object> {
17
+ readonly name: string
18
+ // runs on every link: keep it to a property read or two
19
+ gate(host: Host): boolean
20
+ claim(host: Host): Owner | null
21
+ attach(owner: Owner, source: StyleSource): void
22
+ // runs for hidden owners too (frozen, suspended, hidden Activity): skip there what can't run while hidden
23
+ refresh(owner: Owner, source: StyleSource): void
24
+ }
25
+
26
+ export type OwnerRegistry = {
27
+ link(host: Host | null | undefined): void
28
+ refresh(hosts: ReadonlyArray<Host | null | undefined>): void
29
+ }
30
+
31
+ // An adapter that throws is disabled for the session and reported once
32
+ export const createOwnerRegistry = (
33
+ source: StyleSource,
34
+ adapters: ReadonlyArray<OwnerAdapter<any>>,
35
+ onAdapterError?: (reason: string) => void,
36
+ ): OwnerRegistry => {
37
+ const disabledAdapters = new Set<OwnerAdapter>()
38
+ const disable = (adapter: OwnerAdapter, error: unknown) => {
39
+ disabledAdapters.add(adapter)
40
+ onAdapterError?.(`adapter ${adapter.name} failed: ${String(error)}`)
41
+ }
42
+ // Not inline closures: a closure in link() makes Hermes allocate its environment on every call
43
+ const attachOwner = (adapter: OwnerAdapter, host: Host) => {
44
+ try {
45
+ const owner = adapter.claim(host)
46
+
47
+ if (owner) {
48
+ adapter.attach(owner, source)
49
+ }
50
+ } catch (error) {
51
+ disable(adapter, error)
52
+ }
53
+ }
54
+ const refreshOwner = (adapter: OwnerAdapter, host: Host, seen: Set<object>) => {
55
+ try {
56
+ const owner = adapter.claim(host)
57
+
58
+ if (owner && !seen.has(owner)) {
59
+ seen.add(owner)
60
+ adapter.attach(owner, source)
61
+ adapter.refresh(owner, source)
62
+ }
63
+ } catch (error) {
64
+ disable(adapter, error)
65
+ }
66
+ }
67
+
68
+ return {
69
+ link(host) {
70
+ if (!host) {
71
+ return
72
+ }
73
+
74
+ for (let i = 0; i < adapters.length; i++) {
75
+ const adapter = adapters[i]!
76
+
77
+ if (adapter.gate(host) && !disabledAdapters.has(adapter)) {
78
+ attachOwner(adapter, host)
79
+ }
80
+ }
81
+ },
82
+ refresh(hosts) {
83
+ const seen = new Set<object>()
84
+
85
+ for (let h = 0; h < hosts.length; h++) {
86
+ const host = hosts[h]
87
+
88
+ if (!host) {
89
+ continue
90
+ }
91
+
92
+ for (let i = 0; i < adapters.length; i++) {
93
+ const adapter = adapters[i]!
94
+
95
+ if (adapter.gate(host) && !disabledAdapters.has(adapter)) {
96
+ refreshOwner(adapter, host, seen)
97
+ }
98
+ }
99
+ }
100
+ },
101
+ }
102
+ }
@@ -0,0 +1,55 @@
1
+ import type { RawFiber } from './fiber'
2
+ import type { Host } from './host'
3
+ import * as host from './host'
4
+
5
+ // Bound once: Metro's inline requires
6
+ const { committedHalf, fiberOf } = host
7
+
8
+ const styleDiffers = (a: RawFiber, b: RawFiber) => a.memoizedProps?.style !== b.memoizedProps?.style
9
+
10
+ const flattenInto = (style: unknown, out: Record<string, unknown>) => {
11
+ if (Array.isArray(style)) {
12
+ for (let i = 0; i < style.length; i++) {
13
+ flattenInto(style[i], out)
14
+ }
15
+ } else if (style && typeof style === 'object') {
16
+ Object.assign(out, style)
17
+ }
18
+
19
+ return out
20
+ }
21
+
22
+ export type Drift = { key: string; react: unknown; expected: unknown }
23
+
24
+ // Keys that differ from React's committed props: React re-sends them on the view's next render
25
+ export const verify = (host: Host, expected: Record<string, unknown>): Array<Drift> => {
26
+ const baseline = committedHalf(fiberOf(host), styleDiffers) ?? fiberOf(host)
27
+ const react = flattenInto(baseline.memoizedProps?.style, {})
28
+ const drift: Array<Drift> = []
29
+
30
+ for (const key in expected) {
31
+ if (react[key] !== expected[key]) {
32
+ drift.push({ key, react: react[key], expected: expected[key] })
33
+ }
34
+ }
35
+
36
+ return drift
37
+ }
38
+
39
+ // Development builds only
40
+ export const getOwners = (host: Host, max = 8): Array<string> => {
41
+ const owners: Array<string> = []
42
+
43
+ for (let owner = fiberOf(host)._debugOwner; owner && owners.length < max; owner = owner._debugOwner ?? owner.owner) {
44
+ const name = owner.name ?? owner.type?.displayName ?? owner.type?.name ?? owner.type?.render?.name
45
+
46
+ if (name) {
47
+ owners.push(name)
48
+ }
49
+ }
50
+
51
+ return owners
52
+ }
53
+
54
+ // Development builds only
55
+ export const getCreationStack = (host: Host): string | undefined => fiberOf(host)._debugStack?.stack
@@ -0,0 +1,262 @@
1
+ // The only module that reads React's fiber fields. A missing field gives undefined / null for that call, never a throw.
2
+ import type { Context } from 'react'
3
+
4
+ // ReactWorkTags, React 19
5
+ export const Tag = {
6
+ ClassComponent: 1,
7
+ HostRoot: 3,
8
+ HostComponent: 5,
9
+ ContextProvider: 10,
10
+ Suspense: 13,
11
+ Offscreen: 22,
12
+ Activity: 31,
13
+ } as const
14
+
15
+ declare const brand: unique symbol
16
+ export type FiberNode = { readonly [brand]: 'FiberNode' }
17
+ export type ShadowNode = { readonly __hostObjectShadowNodeWrapper?: unknown }
18
+
19
+ export type RawFiber = {
20
+ tag: number
21
+ type: any
22
+ return: RawFiber | null
23
+ child: RawFiber | null
24
+ sibling: RawFiber | null
25
+ alternate: RawFiber | null
26
+ stateNode: any
27
+ memoizedProps: any
28
+ pendingProps: any
29
+ memoizedState: any
30
+ _debugOwner?: any
31
+ _debugStack?: { stack?: string } | null
32
+ }
33
+
34
+ export const raw = (fiber: FiberNode | null | undefined) => fiber as unknown as RawFiber | null | undefined
35
+
36
+ export const hostFiberOf = (instance: unknown): FiberNode | null =>
37
+ ((instance as any)?.__internalInstanceHandle ?? null) as FiberNode | null
38
+
39
+ // RN composites that keep their host behind a ref of their own, most common first
40
+ const compositeHostRefs: Array<(handle: any) => unknown> = [
41
+ (handle) => handle?.getScrollResponder?.()?.getNativeScrollRef?.(), // FlatList, SectionList, VirtualizedList
42
+ (handle) => handle?.getNativeScrollRef?.(), // ScrollView
43
+ (handle) => handle?._viewRef, // ImageBackground
44
+ (handle) => handle?.viewRef?.current, // KeyboardAvoidingView
45
+ (handle) => handle?._nativeRef, // RefreshControl
46
+ ]
47
+
48
+ export const resolveHostFiber = (handle: unknown): FiberNode | null => {
49
+ const direct = hostFiberOf(handle)
50
+
51
+ if (direct || !handle) {
52
+ return direct
53
+ }
54
+
55
+ for (let i = 0; i < compositeHostRefs.length; i++) {
56
+ const fiber = hostFiberOf(compositeHostRefs[i]!(handle))
57
+
58
+ if (fiber) {
59
+ return fiber
60
+ }
61
+ }
62
+
63
+ return null
64
+ }
65
+
66
+ export const fiberOfInstance = (instance: unknown): FiberNode | null =>
67
+ ((instance as any)?._reactInternals ?? null) as FiberNode | null
68
+
69
+ export const firstHostBelow = (fiber: FiberNode | null): FiberNode | null => {
70
+ let current = raw(fiber)
71
+
72
+ while (current && current.tag !== Tag.HostComponent) {
73
+ current = current.child
74
+ }
75
+
76
+ return (current ?? null) as FiberNode | null
77
+ }
78
+
79
+ export const hostAncestor = (fiber: FiberNode | null, levels = 1): FiberNode | null => {
80
+ let current = raw(fiber)?.return
81
+
82
+ while (current) {
83
+ if (current.tag === Tag.HostComponent && --levels === 0) {
84
+ return current as unknown as FiberNode
85
+ }
86
+
87
+ current = current.return
88
+ }
89
+
90
+ return null
91
+ }
92
+
93
+ export const shadowNodesOf = (fiber: FiberNode | null, out: Array<ShadowNode>) => {
94
+ const current = raw(fiber)
95
+ const node = current?.stateNode?.node
96
+ const alternateNode = current?.alternate?.stateNode?.node
97
+
98
+ if (node) {
99
+ out.push(node)
100
+ }
101
+
102
+ if (alternateNode && alternateNode !== node) {
103
+ out.push(alternateNode)
104
+ }
105
+ }
106
+
107
+ const childOfParent = (parent: RawFiber, a: RawFiber, b: RawFiber): RawFiber | null => {
108
+ for (let child = parent.child; child; child = child.sibling) {
109
+ if (child === a || child === b) {
110
+ return child
111
+ }
112
+ }
113
+
114
+ return null
115
+ }
116
+
117
+ // React 19.2 findCurrentFiberUsingSlowPath, returning null where React throws
118
+ export const committedOf = (fiber: FiberNode | null): FiberNode | null => {
119
+ const self = raw(fiber)
120
+
121
+ if (!self) {
122
+ return null
123
+ }
124
+
125
+ const alternate = self.alternate
126
+
127
+ if (!alternate) {
128
+ let root = self
129
+
130
+ while (root.return) {
131
+ root = root.return
132
+ }
133
+
134
+ return root.tag === Tag.HostRoot ? fiber : null
135
+ }
136
+
137
+ let a: RawFiber = self
138
+ let b: RawFiber = alternate
139
+
140
+ while (true) {
141
+ const parentA = a.return
142
+
143
+ if (!parentA) {
144
+ break
145
+ }
146
+
147
+ const parentB = parentA.alternate
148
+
149
+ if (!parentB) {
150
+ const next = parentA.return
151
+
152
+ if (next) {
153
+ a = next
154
+ continue
155
+ }
156
+
157
+ break
158
+ }
159
+
160
+ if (parentA.child === parentB.child) {
161
+ const found = childOfParent(parentA, a, b)
162
+
163
+ return found === a ? fiber : found === b ? (alternate as unknown as FiberNode) : null
164
+ }
165
+
166
+ if (a.return !== b.return) {
167
+ a = parentA
168
+ b = parentB
169
+ } else {
170
+ const inA = childOfParent(parentA, a, b)
171
+ const inB = inA ? null : childOfParent(parentB, a, b)
172
+
173
+ if (!inA && !inB) {
174
+ return null
175
+ }
176
+
177
+ const aUnderA = inA ? inA === a : inB !== a
178
+
179
+ a = aUnderA ? parentA : parentB
180
+ b = aUnderA ? parentB : parentA
181
+ }
182
+
183
+ if (a.alternate !== b) {
184
+ return null
185
+ }
186
+ }
187
+
188
+ if (a.tag !== Tag.HostRoot) {
189
+ return null
190
+ }
191
+
192
+ return a.stateNode?.current === a ? fiber : (alternate as unknown as FiberNode)
193
+ }
194
+
195
+ // a provider's other half can hold its previous value
196
+ const committedProviderValue = (provider: RawFiber): unknown => {
197
+ const alternate = provider.alternate
198
+
199
+ if (!alternate || alternate.memoizedProps?.value === provider.memoizedProps?.value) {
200
+ return provider.memoizedProps?.value
201
+ }
202
+
203
+ return (raw(committedOf(provider as unknown as FiberNode)) ?? provider).memoizedProps?.value
204
+ }
205
+
206
+ export const readContext = <T>(fiber: FiberNode | null, context: Context<T>, fallback?: T): T | undefined => {
207
+ for (let current = raw(fiber)?.return; current; current = current.return) {
208
+ if (current.tag === Tag.ContextProvider && (current.type === context || current.type?._context === context)) {
209
+ return committedProviderValue(current) as T
210
+ }
211
+ }
212
+
213
+ return fallback
214
+ }
215
+
216
+ // Fabric is a secondary renderer: its context stack is `_currentValue2`. Only valid during render.
217
+ export const readContextDuringRender = <T>(context: Context<T>): T | undefined =>
218
+ (context as any)?._currentValue2
219
+
220
+ export type ContextReader = <T>(context: Context<T>) => T | undefined
221
+
222
+ export const contextReaderFor = (instance: unknown, rendering: boolean): ContextReader =>
223
+ rendering ? readContextDuringRender : (context) => readCommittedContext(instance, context)
224
+
225
+ const NO_PROVIDER = Symbol('no provider')
226
+
227
+ const readCommittedContext = <T>(instance: unknown, context: Context<T>): T | undefined => {
228
+ const value = readContext(committedOf(fiberOfInstance(instance)), context, NO_PROVIDER as T)
229
+
230
+ return value === NO_PROVIDER ? readContextDuringRender(context) : value
231
+ }
232
+
233
+ // pendingProps too, so React still bails out. Replaced, not mutated: props are frozen in dev.
234
+ export const patchRenderedProps = (
235
+ fiber: FiberNode | null,
236
+ patch: (props: Record<string, any>) => Record<string, any> | undefined,
237
+ ): boolean => {
238
+ const self = raw(fiber)
239
+
240
+ if (!self) {
241
+ return false
242
+ }
243
+
244
+ const patchedSelf = replaceProps(self, patch)
245
+ const patchedAlternate = self.alternate ? replaceProps(self.alternate, patch) : false
246
+
247
+ return patchedSelf || patchedAlternate
248
+ }
249
+
250
+ const replaceProps = (target: RawFiber, patch: (props: Record<string, any>) => Record<string, any> | undefined) => {
251
+ const props = target.memoizedProps
252
+ const next = props ? patch(props) : undefined
253
+
254
+ if (!next) {
255
+ return false
256
+ }
257
+
258
+ target.memoizedProps = next
259
+ target.pendingProps = next
260
+
261
+ return true
262
+ }