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
@@ -17,6 +17,11 @@ interface NamedThemeProps extends PropsWithChildren {
17
17
  export const NamedTheme: React.FunctionComponent<NamedThemeProps> = ({ name, children, previousScopedTheme }) => {
18
18
  const scope = useMemo(() => ({ name }), [name])
19
19
 
20
+ useLayoutEffect(() => {
21
+ // this will affect only scoped styles as other styles are not yet mounted
22
+ UnistylesShadowRegistry.flush()
23
+ })
24
+
20
25
  const mappedChildren = [
21
26
  <ApplyScopedTheme key="apply" name={name} />,
22
27
  <ScopedThemeContext.Provider key="scope" value={scope}>
@@ -25,10 +30,5 @@ export const NamedTheme: React.FunctionComponent<NamedThemeProps> = ({ name, chi
25
30
  <ApplyScopedTheme key="dispose" name={previousScopedTheme as keyof UnistylesThemes | undefined} />,
26
31
  ]
27
32
 
28
- useLayoutEffect(() => {
29
- // this will affect only scoped styles as other styles are not yet mounted
30
- UnistylesShadowRegistry.flush()
31
- })
32
-
33
33
  return <React.Fragment>{mappedChildren}</React.Fragment>
34
34
  }
@@ -1,4 +1,4 @@
1
- import { createContext } from 'react'
1
+ import { type Context, createContext } from 'react'
2
2
 
3
3
  import type { UnistylesThemes } from '../global'
4
4
 
@@ -6,4 +6,8 @@ export type Scope = {
6
6
  name: keyof UnistylesThemes | undefined
7
7
  }
8
8
 
9
- export const ScopedThemeContext = createContext<Scope | null>(null)
9
+ // React Server Components load a React build without createContext (or useContext). The Next.js App Router
10
+ // setup imports Unistyles from the root layout, a server component, and nothing can read this context there.
11
+ export const ScopedThemeContext = (
12
+ typeof createContext === 'function' ? createContext<Scope | null>(null) : null
13
+ ) as Context<Scope | null>
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the ActivityIndicator module of react-native or react-native-web here
2
+ export { ActivityIndicator, ActivityIndicator as default } from '../ActivityIndicator'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the Animated module of react-native or react-native-web here
2
+ export { Animated, Animated as default } from '../Animated'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the FlatList module of react-native or react-native-web here
2
+ export { FlatList, FlatList as default } from '../FlatList'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the Image module of react-native or react-native-web here
2
+ export { Image, Image as default } from '../Image'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the ImageBackground module of react-native or react-native-web here
2
+ export { ImageBackground, ImageBackground as default } from '../ImageBackground'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the KeyboardAvoidingView module of react-native or react-native-web here
2
+ export { KeyboardAvoidingView, KeyboardAvoidingView as default } from '../KeyboardAvoidingView'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the Pressable module of react-native or react-native-web here
2
+ export { Pressable, Pressable as default } from '../Pressable'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the RefreshControl module of react-native or react-native-web here
2
+ export { RefreshControl, RefreshControl as default } from '../RefreshControl'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the SafeAreaView module of react-native or react-native-web here
2
+ export { SafeAreaView, SafeAreaView as default } from '../SafeAreaView'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the ScrollView module of react-native or react-native-web here
2
+ export { ScrollView, ScrollView as default } from '../ScrollView'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the SectionList module of react-native or react-native-web here
2
+ export { SectionList, SectionList as default } from '../SectionList'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the Switch module of react-native or react-native-web here
2
+ export { Switch, Switch as default } from '../Switch'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the Text module of react-native or react-native-web here
2
+ export { Text, Text as default } from '../Text'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the TextInput module of react-native or react-native-web here
2
+ export { TextInput, TextInput as default } from '../TextInput'
@@ -0,0 +1,5 @@
1
+ // react-native-unistyles/metro resolves direct imports of react-native/Libraries/Text/TextNativeComponent here,
2
+ // its other exports (eg. NativeVirtualText) stay untouched
3
+ // @ts-ignore deep imports are typed only by some React Native versions
4
+ export * from 'react-native/Libraries/Text/TextNativeComponent'
5
+ export { NativeText } from '../NativeText'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the TouchableHighlight module of react-native or react-native-web here
2
+ export { TouchableHighlight, TouchableHighlight as default } from '../TouchableHighlight'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the TouchableOpacity module of react-native or react-native-web here
2
+ export { TouchableOpacity, TouchableOpacity as default } from '../TouchableOpacity'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the View module of react-native or react-native-web here
2
+ export { View, View as default } from '../View'
@@ -0,0 +1,5 @@
1
+ // react-native-unistyles/metro resolves direct imports of react-native/Libraries/Components/View/ViewNativeComponent here,
2
+ // its other exports stay untouched
3
+ // @ts-ignore deep imports are typed only by some React Native versions
4
+ export * from 'react-native/Libraries/Components/View/ViewNativeComponent'
5
+ export { NativeView as default } from '../NativeView'
@@ -0,0 +1,2 @@
1
+ // react-native-unistyles/metro resolves direct imports of the VirtualizedList module of react-native or react-native-web here
2
+ export { VirtualizedList, VirtualizedList as default } from '../VirtualizedList'
@@ -0,0 +1,41 @@
1
+ // react-native-unistyles/metro resolves every `react-native` import (react-native-web on web) to this module,
2
+ // so it exposes every export of react-native and swaps the components Unistyles can update.
3
+ // Imports from this folder are Unistyles' own, they reach the real react-native
4
+ const ReactNative: Record<string, unknown> = require('react-native')
5
+
6
+ // lazy, like react-native's own exports
7
+ const UNISTYLES_COMPONENTS: Record<string, () => unknown> = {
8
+ ActivityIndicator: () => require('./ActivityIndicator').ActivityIndicator,
9
+ Animated: () => require('./Animated').Animated,
10
+ FlatList: () => require('./FlatList').FlatList,
11
+ Image: () => require('./Image').Image,
12
+ ImageBackground: () => require('./ImageBackground').ImageBackground,
13
+ KeyboardAvoidingView: () => require('./KeyboardAvoidingView').KeyboardAvoidingView,
14
+ Pressable: () => require('./Pressable').Pressable,
15
+ RefreshControl: () => require('./RefreshControl').RefreshControl,
16
+ SafeAreaView: () => require('./SafeAreaView').SafeAreaView,
17
+ ScrollView: () => require('./ScrollView').ScrollView,
18
+ SectionList: () => require('./SectionList').SectionList,
19
+ Switch: () => require('./Switch').Switch,
20
+ Text: () => require('./Text').Text,
21
+ TextInput: () => require('./TextInput').TextInput,
22
+ TouchableHighlight: () => require('./TouchableHighlight').TouchableHighlight,
23
+ TouchableOpacity: () => require('./TouchableOpacity').TouchableOpacity,
24
+ View: () => require('./View').View,
25
+ VirtualizedList: () => require('./VirtualizedList').VirtualizedList,
26
+ unstable_NativeText: () => require('./NativeText').NativeText,
27
+ unstable_NativeView: () => require('./NativeView').NativeView,
28
+ }
29
+
30
+ // Object.keys doesn't call react-native's getters. Unistyles components are added even if missing,
31
+ // react-native-web and React Native before 0.83 don't export unstable_NativeView / unstable_NativeText
32
+ const exportNames = new Set(Object.keys(ReactNative).concat(Object.keys(UNISTYLES_COMPONENTS)))
33
+
34
+ exportNames.forEach((name) => {
35
+ // CommonJS without the __esModule flag, like react-native, so a default import still gets every export
36
+ // @ts-ignore module is provided by Metro
37
+ Object.defineProperty(module.exports, name, {
38
+ enumerable: true,
39
+ get: UNISTYLES_COMPONENTS[name] ?? (() => ReactNative[name]),
40
+ })
41
+ })
@@ -2,18 +2,21 @@ import type { ActivityIndicator } from 'react-native'
2
2
 
3
3
  import React, { useContext } from 'react'
4
4
 
5
- import { isAndroid } from '../common'
6
5
  import { ScopedThemeContext } from '../components/ScopedThemeContext'
7
6
  import { UnistylesShadowRegistry } from '../specs'
7
+ import { Fiber } from '../unifiber/src'
8
8
  import { copyComponentProperties } from '../utils'
9
+ import { hasUnistyles } from './hasUnistyles'
9
10
  import { passForwardedRef } from './passForwardRef'
10
11
  import { maybeWarnAboutMultipleUnistyles } from './warn'
11
12
 
12
- const getWrapperHandle = (ref: any) => {
13
- const spinner = ref?.__internalInstanceHandle
13
+ const { getHostFor, getParentHost } = Fiber
14
+
15
+ const getWrapperHandle = (ref: unknown) => {
16
+ const spinner = getHostFor(ref)
14
17
 
15
18
  return {
16
- __internalInstanceHandle: isAndroid ? spinner?.return?.return : spinner?.return,
19
+ __internalInstanceHandle: spinner && getParentHost(spinner),
17
20
  }
18
21
  }
19
22
 
@@ -21,6 +24,10 @@ export const createUnistylesActivityIndicator = (Component: typeof ActivityIndic
21
24
  const UnistylesActivityIndicator = (props: any) => {
22
25
  const scope = useContext(ScopedThemeContext)
23
26
 
27
+ if (!hasUnistyles(props.style)) {
28
+ return <Component {...props} />
29
+ }
30
+
24
31
  return (
25
32
  <Component
26
33
  {...props}
@@ -5,6 +5,7 @@ import React, { useContext, useRef } from 'react'
5
5
  import { ScopedThemeContext } from '../components/ScopedThemeContext'
6
6
  import { UnistylesShadowRegistry } from '../specs'
7
7
  import { copyComponentProperties } from '../utils'
8
+ import { hasUnistyles } from './hasUnistyles'
8
9
  import { passForwardedRef } from './passForwardRef'
9
10
  import { maybeWarnAboutMultipleUnistyles } from './warn'
10
11
 
@@ -13,6 +14,10 @@ export const createUnistylesElement = (Component: any) => {
13
14
  const scrollViewRef = useRef<ScrollView>(null)
14
15
  const scope = useContext(ScopedThemeContext)
15
16
 
17
+ if (!hasUnistyles(props.style)) {
18
+ return <Component {...props} />
19
+ }
20
+
16
21
  return (
17
22
  <Component
18
23
  {...props}
@@ -5,11 +5,16 @@ import React, { useContext } from 'react'
5
5
  import { ScopedThemeContext } from '../components/ScopedThemeContext'
6
6
  import { UnistylesShadowRegistry } from '../specs'
7
7
  import { copyComponentProperties } from '../utils'
8
+ import { hasUnistyles } from './hasUnistyles'
8
9
  import { passForwardedRef } from './passForwardRef'
9
10
  import { maybeWarnAboutMultipleUnistyles } from './warn'
10
11
 
11
12
  export const createUnistylesImageBackground = (Component: typeof ImageBackground) => {
12
- const UnistylesImageBackground = React.forwardRef<ImageBackground, ImageBackgroundProps>((props, forwardedRef) => {
13
+ const UnistylesImageBackground = ({
14
+ ref,
15
+ ...props
16
+ }: ImageBackgroundProps & { ref?: React.ForwardedRef<ImageBackground> }) => {
17
+ const forwardedRef: React.ForwardedRef<ImageBackground> = ref ?? null
13
18
  const scope = useContext(ScopedThemeContext)
14
19
 
15
20
  // @ts-expect-error we don't know the type of the component
@@ -17,35 +22,38 @@ export const createUnistylesImageBackground = (Component: typeof ImageBackground
17
22
  // @ts-ignore we don't know the type of the component
18
23
  maybeWarnAboutMultipleUnistyles(props.imageStyle, 'ImageBackground')
19
24
 
25
+ const linkRef = (ref: ImageBackground | null) => {
26
+ return passForwardedRef(
27
+ ref,
28
+ forwardedRef,
29
+ () => {
30
+ // @ts-expect-error - this is hidden from TS
31
+ UnistylesShadowRegistry.add(ref, props.style, scope)
32
+ },
33
+ () => {
34
+ // @ts-expect-error - this is hidden from TS
35
+ UnistylesShadowRegistry.remove(ref)
36
+ },
37
+ )
38
+ }
39
+ const linkImageRef = (ref: unknown) => {
40
+ // @ts-expect-error web types are not compatible with RN styles
41
+ UnistylesShadowRegistry.add(ref, props.imageStyle, scope)
42
+
43
+ return () => {
44
+ // @ts-ignore this is hidden from TS
45
+ UnistylesShadowRegistry.remove(ref)
46
+ }
47
+ }
48
+
20
49
  return (
21
50
  <Component
22
51
  {...props}
23
- ref={(ref) => {
24
- return passForwardedRef(
25
- ref,
26
- forwardedRef,
27
- () => {
28
- // @ts-expect-error - this is hidden from TS
29
- UnistylesShadowRegistry.add(ref, props.style, scope)
30
- },
31
- () => {
32
- // @ts-expect-error - this is hidden from TS
33
- UnistylesShadowRegistry.remove(ref)
34
- },
35
- )
36
- }}
37
- imageRef={(ref) => {
38
- // @ts-expect-error web types are not compatible with RN styles
39
- UnistylesShadowRegistry.add(ref, props.imageStyle, scope)
40
-
41
- return () => {
42
- // @ts-ignore this is hidden from TS
43
- UnistylesShadowRegistry.remove(ref)
44
- }
45
- }}
52
+ ref={hasUnistyles(props.style) ? linkRef : forwardedRef}
53
+ imageRef={hasUnistyles(props.imageStyle) ? linkImageRef : props.imageRef}
46
54
  />
47
55
  )
48
- })
56
+ }
49
57
 
50
58
  return copyComponentProperties(Component, UnistylesImageBackground)
51
59
  }
@@ -5,6 +5,7 @@ import React, { useCallback, useContext, useLayoutEffect, useRef, useState } fro
5
5
  import { ScopedThemeContext } from '../components/ScopedThemeContext'
6
6
  import { UnistylesShadowRegistry } from '../specs'
7
7
  import { copyComponentProperties } from '../utils'
8
+ import { hasUnistyles } from './hasUnistyles'
8
9
  import { passForwardedRef } from './passForwardRef'
9
10
  import { maybeWarnAboutMultipleUnistyles } from './warn'
10
11
 
@@ -49,6 +50,10 @@ export const createUnistylesTouchableHighlight = (Component: typeof TouchableHig
49
50
  [props, scope],
50
51
  )
51
52
 
53
+ if (!hasUnistyles(props.style)) {
54
+ return <Component {...props} />
55
+ }
56
+
52
57
  return (
53
58
  <Component
54
59
  {...props}
@@ -1,7 +1,7 @@
1
1
  import type { UnistylesValues } from '../types'
2
2
 
3
3
  import * as unistyles from '../web/services'
4
- import { checkForAnimated } from '../web/utils'
4
+ import { checkForAnimated, isGeneratedUnistyle } from '../web/utils'
5
5
 
6
6
  export const getClassName = (unistyle: UnistylesValues | undefined | Array<UnistylesValues>, forChild?: boolean) => {
7
7
  if (!unistyle) {
@@ -11,6 +11,15 @@ export const getClassName = (unistyle: UnistylesValues | undefined | Array<Unist
11
11
  const flattenedStyles = Array.isArray(unistyle) ? unistyle.flat(Number.POSITIVE_INFINITY) : [unistyle]
12
12
  const animatedStyles = flattenedStyles.filter(checkForAnimated)
13
13
  const regularStyles = flattenedStyles.filter((style) => !checkForAnimated(style))
14
+ const [firstStyle, ...otherStyles] = regularStyles
15
+
16
+ // Already processed by an outer Unistyles component, e.g. createUnistylesElement(Animated.View),
17
+ // styles added after it (like Reanimated's initial animated values) stay inline
18
+ if (firstStyle && isGeneratedUnistyle(firstStyle) && firstStyle.hash) {
19
+ const { hash, injectedClassName } = firstStyle
20
+
21
+ return [{ $$css: true, hash, injectedClassName }, otherStyles.concat(animatedStyles)] as const
22
+ }
14
23
 
15
24
  const { hash, injectedClassName } = unistyles.services.shadowRegistry.addStyles(regularStyles, forChild)
16
25
 
@@ -0,0 +1,20 @@
1
+ // whether a style prop (also nested arrays) holds a unistyle, the only styles Unistyles updates
2
+ // a view without one renders like a React Native view, it never links
3
+ export const hasUnistyles = (style: unknown): boolean => {
4
+ if (Array.isArray(style)) {
5
+ return style.some(hasUnistyles)
6
+ }
7
+
8
+ if (!style || typeof style !== 'object') {
9
+ return false
10
+ }
11
+
12
+ // own keys only, like the registry. A unistyle starts with its `unistyles_` key, so it exits early
13
+ for (const key in style) {
14
+ if (key.startsWith('unistyles_') && Object.prototype.hasOwnProperty.call(style, key)) {
15
+ return true
16
+ }
17
+ }
18
+
19
+ return false
20
+ }
@@ -1,10 +1,10 @@
1
1
  import React, {
2
- forwardRef,
3
2
  useContext,
4
3
  useEffect,
5
4
  type ComponentProps,
6
5
  type ComponentRef,
7
6
  type ComponentType,
7
+ type Ref,
8
8
  } from 'react'
9
9
 
10
10
  import type { UnistylesValues } from '../../types'
@@ -12,7 +12,7 @@ import type { Mappings } from './types'
12
12
 
13
13
  import { ScopedThemeContext } from '../../components/ScopedThemeContext'
14
14
  import { type UnistyleDependency, UnistylesShadowRegistry } from '../../specs'
15
- import { deepMergeObjects } from '../../utils'
15
+ import { deepMergeObjects, isAnimatedStyleHandle } from '../../utils'
16
16
  import { useProxifiedUnistyles } from '../useProxifiedUnistyles'
17
17
  import { maybeWarnAboutMultipleUnistyles } from '../warn'
18
18
 
@@ -27,10 +27,30 @@ type UnistylesSecrets = {
27
27
  }
28
28
 
29
29
  type MappedSecrets = {
30
- styles: Record<string, any>
30
+ styles: Record<string, any> | Array<Record<string, any>>
31
31
  dependencies: Array<UnistyleDependency>
32
32
  }
33
33
 
34
+ // Reanimated finds animated styles by their keys, merged with other styles they would hide them
35
+ // so keep every animated style as a separate entry and merge only the styles between them, in order
36
+ const mergeAroundAnimatedStyles = (secrets: Array<UnistylesSecrets>) =>
37
+ secrets.reduce<Array<Record<string, any>>>((acc, secret) => {
38
+ const style = secret.uni__getStyles()
39
+ const lastStyle = acc.at(-1)
40
+
41
+ if (isAnimatedStyleHandle(style)) {
42
+ return acc.concat([style])
43
+ }
44
+
45
+ if (lastStyle && !isAnimatedStyleHandle(lastStyle)) {
46
+ Object.assign(lastStyle, style)
47
+
48
+ return acc
49
+ }
50
+
51
+ return acc.concat([{ ...style }])
52
+ }, [])
53
+
34
54
  export const getSecrets = (styleProps: Record<string, any> = {}): MappedSecrets => {
35
55
  const styles = Array.isArray(styleProps) ? styleProps.flat(Infinity) : [styleProps]
36
56
 
@@ -48,7 +68,9 @@ export const getSecrets = (styleProps: Record<string, any> = {}): MappedSecrets
48
68
  }, [])
49
69
 
50
70
  return {
51
- styles: secrets.reduce((acc, secret) => Object.assign(acc, secret.uni__getStyles()), {} as Record<string, any>),
71
+ styles: styles.some(isAnimatedStyleHandle)
72
+ ? mergeAroundAnimatedStyles(secrets)
73
+ : secrets.reduce((acc, secret) => Object.assign(acc, secret.uni__getStyles()), {} as Record<string, any>),
52
74
  dependencies: secrets.flatMap((secret) => secret.uni__dependencies),
53
75
  }
54
76
  }
@@ -66,7 +88,7 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
66
88
  contentContainerStyle?: UnistylesValues
67
89
  }
68
90
 
69
- return forwardRef<GenericComponentRef<TComponent>, PropsWithUnistyles>((props, ref) => {
91
+ return ({ ref, ...props }: PropsWithUnistyles & { ref?: Ref<GenericComponentRef<TComponent>> }) => {
70
92
  const narrowedProps = props as PropsWithUnistyles & UnistyleStyles
71
93
  const NativeComponent = Component as ComponentType
72
94
 
@@ -127,5 +149,5 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
127
149
  } as any
128
150
 
129
151
  return <NativeComponent key={uniPropsKey || mappingsKey} {...finalProps} ref={ref} />
130
- })
152
+ }
131
153
  }
@@ -1,4 +1,4 @@
1
- import React, { type ComponentType, forwardRef, type ComponentProps, type ComponentRef } from 'react'
1
+ import React, { type ComponentType, type ComponentProps, type ComponentRef, type Ref } from 'react'
2
2
 
3
3
  import type { UnistylesValues } from '../../types'
4
4
  import type { Mappings } from './types'
@@ -26,9 +26,9 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
26
26
  contentContainerStyle?: UnistylesValues
27
27
  }
28
28
 
29
- return forwardRef<GenericComponentRef<TComponent>, PropsWithUnistyles>((props, ref) => {
29
+ return ({ ref, ...props }: PropsWithUnistyles & { ref?: Ref<GenericComponentRef<TComponent>> }) => {
30
30
  const narrowedProps = props as PropsWithUnistyles & UnistyleStyles
31
- const styleClassNames = getClassName(narrowedProps.style, true)
31
+ const [classNames, animatedStyles] = getClassName(narrowedProps.style, true) ?? []
32
32
  const contentContainerStyleClassNames = getClassName(narrowedProps.contentContainerStyle)
33
33
  const { proxifiedRuntime, proxifiedTheme } = useProxifiedUnistyles()
34
34
 
@@ -50,7 +50,8 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
50
50
  ...(narrowedProps.style
51
51
  ? {
52
52
  // Override default component styles with undefined values to reset them
53
- style: emptyStyles,
53
+ // animated styles can't be a class, so they stay inline
54
+ style: animatedStyles?.length ? [emptyStyles, ...animatedStyles] : emptyStyles,
54
55
  }
55
56
  : {}),
56
57
  ...(narrowedProps.contentContainerStyle
@@ -68,12 +69,11 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
68
69
  maybeWarnAboutMultipleUnistyles(narrowedProps.contentContainerStyle, `withUnistyles(${Component.displayName ?? Component.name ?? 'Unknown'})`)
69
70
 
70
71
  const NativeComponent = Component as ComponentType
71
- const [classNames] = styleClassNames ?? []
72
72
 
73
73
  return (
74
74
  <div className={classNames?.hash} style={{ display: 'contents' }}>
75
75
  <NativeComponent key={uniPropsKey || mappingsKey} {...combinedProps} ref={ref} />
76
76
  </div>
77
77
  )
78
- })
78
+ }
79
79
  }
package/src/mocks.ts CHANGED
@@ -20,6 +20,7 @@ jest.mock('react-native-nitro-modules', () => ({
20
20
  createHybridObject: () => ({
21
21
  add: () => {},
22
22
  init: () => {},
23
+ addChangeListener: () => () => {},
23
24
  createHybridStatusBar: () => ({
24
25
  setStyle: () => {},
25
26
  }),
@@ -199,11 +200,19 @@ jest.mock('react-native-unistyles', () => {
199
200
  Component: TComponent,
200
201
  mapper?: (theme: UnistylesTheme, runtime: typeof miniRuntime) => TComponent,
201
202
  ) =>
202
- (props: any) =>
203
- React.createElement(Component, {
204
- ...mapper?.((Object.values(_REGISTRY.themes).at(0) ?? {}) as UnistylesTheme, miniRuntime),
205
- ...props,
206
- }),
203
+ ({ uniProps, ...props }: any) => {
204
+ const { deepMergeObjects } = require('./utils')
205
+ const theme = (Object.values(_REGISTRY.themes).at(0) ?? {}) as UnistylesTheme
206
+ const { key: mappingsKey, ...mappingsProps } = mapper?.(theme, miniRuntime) ?? ({} as any)
207
+ const { key: uniPropsKey, ...unistyleProps } = uniProps?.(theme, miniRuntime) ?? {}
208
+
209
+ return React.createElement(Component, {
210
+ ...deepMergeObjects(mappingsProps, unistyleProps, props),
211
+ ...(props.style ? { style: props.style } : {}),
212
+ ...(props.contentContainerStyle ? { contentContainerStyle: props.contentContainerStyle } : {}),
213
+ key: uniPropsKey || mappingsKey,
214
+ })
215
+ },
207
216
  mq: {
208
217
  only: {
209
218
  width: () => ({