react-native-unistyles 3.0.0-beta.8 → 3.0.0-experimental-2025051401

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 (367) hide show
  1. package/README.md +32 -26
  2. package/Unistyles.podspec +1 -0
  3. package/android/src/main/cxx/NativeUnistylesModule.cpp +3 -7
  4. package/android/src/main/cxx/NativeUnistylesModule.h +0 -4
  5. package/android/src/main/java/com/unistyles/NativePlatform+android.kt +5 -1
  6. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +2 -3
  7. package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +1 -1
  8. package/android/src/main/java/com/unistyles/UnistylesModule.kt +1 -7
  9. package/components/native/ActivityIndicator/package.json +1 -0
  10. package/components/native/Animated/package.json +1 -0
  11. package/components/native/FlatList/package.json +1 -0
  12. package/components/native/Image/package.json +2 -1
  13. package/components/native/ImageBackground/package.json +1 -0
  14. package/components/native/KeyboardAvoidingView/package.json +1 -0
  15. package/components/native/NativeText/package.json +1 -0
  16. package/components/native/NativeView/package.json +1 -0
  17. package/components/native/Pressable/package.json +1 -0
  18. package/components/native/RefreshControl/package.json +1 -0
  19. package/components/native/ScrollView/package.json +1 -0
  20. package/components/native/SectionList/package.json +1 -0
  21. package/components/native/Switch/package.json +1 -0
  22. package/components/native/Text/package.json +1 -0
  23. package/components/native/TextInput/package.json +1 -0
  24. package/components/native/TouchableHighlight/package.json +1 -0
  25. package/components/native/TouchableOpacity/package.json +1 -0
  26. package/components/native/View/package.json +1 -0
  27. package/components/native/VirtualizedList/package.json +1 -0
  28. package/cxx/common/Helpers.h +4 -0
  29. package/cxx/core/HostUnistyle.cpp +14 -5
  30. package/cxx/core/StyleSheet.h +1 -1
  31. package/cxx/core/UnistyleWrapper.h +1 -1
  32. package/cxx/core/UnistylesCommitShadowNode.h +0 -21
  33. package/cxx/core/UnistylesRegistry.cpp +67 -64
  34. package/cxx/core/UnistylesRegistry.h +1 -1
  35. package/cxx/hybridObjects/HybridStyleSheet.cpp +10 -19
  36. package/cxx/hybridObjects/HybridStyleSheet.h +3 -8
  37. package/cxx/parser/Parser.cpp +161 -115
  38. package/cxx/parser/Parser.h +1 -1
  39. package/cxx/shadowTree/ShadowTrafficController.h +7 -9
  40. package/cxx/shadowTree/ShadowTreeManager.cpp +35 -33
  41. package/cxx/shadowTree/ShadowTreeManager.h +0 -1
  42. package/ios/NativePlatform+ios.swift +1 -1
  43. package/ios/NativePlatformListener+ios.swift +12 -7
  44. package/ios/UnistylesModuleOnLoad.h +1 -5
  45. package/ios/UnistylesModuleOnLoad.mm +5 -13
  46. package/lib/commonjs/components/native/Image.js +27 -1
  47. package/lib/commonjs/components/native/Image.js.map +1 -1
  48. package/lib/commonjs/components/native/Image.native.js +10 -0
  49. package/lib/commonjs/components/native/Image.native.js.map +1 -0
  50. package/lib/commonjs/components/native/ImageBackground.js +17 -28
  51. package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
  52. package/lib/commonjs/components/native/Pressable.native.js +7 -4
  53. package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
  54. package/lib/commonjs/core/createUnistylesElement.js +17 -21
  55. package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
  56. package/lib/commonjs/core/createUnistylesElement.native.js +6 -4
  57. package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
  58. package/lib/commonjs/core/createUnistylesImageBackground.js +7 -5
  59. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
  60. package/lib/commonjs/core/getClassname.js +11 -5
  61. package/lib/commonjs/core/getClassname.js.map +1 -1
  62. package/lib/commonjs/core/passForwardRef.js +3 -5
  63. package/lib/commonjs/core/passForwardRef.js.map +1 -1
  64. package/lib/commonjs/core/useProxifiedUnistyles/listener.js +5 -3
  65. package/lib/commonjs/core/useProxifiedUnistyles/listener.js.map +1 -1
  66. package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js +14 -1
  67. package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
  68. package/lib/commonjs/core/withUnistyles/withUnistyles.js +14 -5
  69. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
  70. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +1 -1
  71. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
  72. package/lib/commonjs/hooks/useMedia.js +4 -4
  73. package/lib/commonjs/hooks/useMedia.js.map +1 -1
  74. package/lib/commonjs/hooks/useMedia.native.js +4 -4
  75. package/lib/commonjs/hooks/useMedia.native.js.map +1 -1
  76. package/lib/commonjs/mocks.js +203 -0
  77. package/lib/commonjs/mocks.js.map +1 -0
  78. package/lib/commonjs/mq.js +1 -23
  79. package/lib/commonjs/mq.js.map +1 -1
  80. package/lib/commonjs/reanimated/index.js +13 -0
  81. package/lib/commonjs/reanimated/index.js.map +1 -0
  82. package/lib/commonjs/reanimated/useAnimatedTheme.js +22 -0
  83. package/lib/commonjs/reanimated/useAnimatedTheme.js.map +1 -0
  84. package/lib/commonjs/reanimated/useAnimatedTheme.native.js +24 -0
  85. package/lib/commonjs/reanimated/useAnimatedTheme.native.js.map +1 -0
  86. package/lib/commonjs/server/getServerUnistyles.js +9 -4
  87. package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
  88. package/lib/commonjs/server/hydrateServerUnistyles.js +4 -2
  89. package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -1
  90. package/lib/commonjs/server/resetServerUnistyles.js +4 -2
  91. package/lib/commonjs/server/resetServerUnistyles.js.map +1 -1
  92. package/lib/commonjs/server/serialize.js +24 -0
  93. package/lib/commonjs/server/serialize.js.map +1 -0
  94. package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js +1 -0
  95. package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
  96. package/lib/commonjs/specs/ShadowRegistry/index.js +2 -2
  97. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  98. package/lib/commonjs/utils.js +23 -1
  99. package/lib/commonjs/utils.js.map +1 -1
  100. package/lib/commonjs/web/convert/index.js +4 -7
  101. package/lib/commonjs/web/convert/index.js.map +1 -1
  102. package/lib/commonjs/web/convert/object/filter.js +7 -8
  103. package/lib/commonjs/web/convert/object/filter.js.map +1 -1
  104. package/lib/commonjs/web/create.js +10 -2
  105. package/lib/commonjs/web/create.js.map +1 -1
  106. package/lib/commonjs/web/css/core.js +2 -2
  107. package/lib/commonjs/web/css/core.js.map +1 -1
  108. package/lib/commonjs/web/css/state.js +6 -3
  109. package/lib/commonjs/web/css/state.js.map +1 -1
  110. package/lib/commonjs/web/index.js +7 -12
  111. package/lib/commonjs/web/index.js.map +1 -1
  112. package/lib/commonjs/web/registry.js +11 -9
  113. package/lib/commonjs/web/registry.js.map +1 -1
  114. package/lib/commonjs/web/runtime.js +5 -1
  115. package/lib/commonjs/web/runtime.js.map +1 -1
  116. package/lib/commonjs/web/services.js +7 -2
  117. package/lib/commonjs/web/services.js.map +1 -1
  118. package/lib/commonjs/web/shadowRegistry.js +27 -10
  119. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  120. package/lib/commonjs/web/state.js +11 -2
  121. package/lib/commonjs/web/state.js.map +1 -1
  122. package/lib/commonjs/web/types.js +2 -0
  123. package/lib/commonjs/web/types.js.map +1 -1
  124. package/lib/commonjs/web/utils/createUnistylesRef.js +31 -0
  125. package/lib/commonjs/web/utils/createUnistylesRef.js.map +1 -0
  126. package/lib/commonjs/web/utils/unistyle.js +40 -14
  127. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  128. package/lib/commonjs/web-only/getWebProps.js +19 -0
  129. package/lib/commonjs/web-only/getWebProps.js.map +1 -0
  130. package/lib/commonjs/web-only/index.js +13 -0
  131. package/lib/commonjs/web-only/index.js.map +1 -0
  132. package/lib/module/components/native/Image.js +26 -2
  133. package/lib/module/components/native/Image.js.map +1 -1
  134. package/lib/module/components/native/Image.native.js +6 -0
  135. package/lib/module/components/native/Image.native.js.map +1 -0
  136. package/lib/module/components/native/ImageBackground.js +18 -29
  137. package/lib/module/components/native/ImageBackground.js.map +1 -1
  138. package/lib/module/components/native/Pressable.native.js +7 -4
  139. package/lib/module/components/native/Pressable.native.js.map +1 -1
  140. package/lib/module/core/createUnistylesElement.js +17 -21
  141. package/lib/module/core/createUnistylesElement.js.map +1 -1
  142. package/lib/module/core/createUnistylesElement.native.js +6 -4
  143. package/lib/module/core/createUnistylesElement.native.js.map +1 -1
  144. package/lib/module/core/createUnistylesImageBackground.js +7 -5
  145. package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
  146. package/lib/module/core/getClassname.js +9 -5
  147. package/lib/module/core/getClassname.js.map +1 -1
  148. package/lib/module/core/passForwardRef.js +3 -5
  149. package/lib/module/core/passForwardRef.js.map +1 -1
  150. package/lib/module/core/useProxifiedUnistyles/listener.js +3 -3
  151. package/lib/module/core/useProxifiedUnistyles/listener.js.map +1 -1
  152. package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js +14 -1
  153. package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
  154. package/lib/module/core/withUnistyles/withUnistyles.js +14 -5
  155. package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
  156. package/lib/module/core/withUnistyles/withUnistyles.native.js +1 -1
  157. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
  158. package/lib/module/hooks/useMedia.js +1 -1
  159. package/lib/module/hooks/useMedia.js.map +1 -1
  160. package/lib/module/hooks/useMedia.native.js +1 -1
  161. package/lib/module/hooks/useMedia.native.js.map +1 -1
  162. package/lib/module/mocks.js +201 -0
  163. package/lib/module/mocks.js.map +1 -0
  164. package/lib/module/mq.js +0 -19
  165. package/lib/module/mq.js.map +1 -1
  166. package/lib/module/reanimated/index.js +4 -0
  167. package/lib/module/reanimated/index.js.map +1 -0
  168. package/lib/module/reanimated/useAnimatedTheme.js +17 -0
  169. package/lib/module/reanimated/useAnimatedTheme.js.map +1 -0
  170. package/lib/module/reanimated/useAnimatedTheme.native.js +19 -0
  171. package/lib/module/reanimated/useAnimatedTheme.native.js.map +1 -0
  172. package/lib/module/server/getServerUnistyles.js +7 -4
  173. package/lib/module/server/getServerUnistyles.js.map +1 -1
  174. package/lib/module/server/hydrateServerUnistyles.js +2 -2
  175. package/lib/module/server/hydrateServerUnistyles.js.map +1 -1
  176. package/lib/module/server/resetServerUnistyles.js +2 -2
  177. package/lib/module/server/resetServerUnistyles.js.map +1 -1
  178. package/lib/module/server/serialize.js +19 -0
  179. package/lib/module/server/serialize.js.map +1 -0
  180. package/lib/module/specs/NativePlatform/NativePlatform.nitro.js +1 -0
  181. package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
  182. package/lib/module/specs/ShadowRegistry/index.js +2 -2
  183. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  184. package/lib/module/utils.js +19 -0
  185. package/lib/module/utils.js.map +1 -1
  186. package/lib/module/web/convert/index.js +4 -7
  187. package/lib/module/web/convert/index.js.map +1 -1
  188. package/lib/module/web/convert/object/filter.js +3 -4
  189. package/lib/module/web/convert/object/filter.js.map +1 -1
  190. package/lib/module/web/create.js +9 -3
  191. package/lib/module/web/create.js.map +1 -1
  192. package/lib/module/web/css/core.js +2 -2
  193. package/lib/module/web/css/core.js.map +1 -1
  194. package/lib/module/web/css/state.js +6 -3
  195. package/lib/module/web/css/state.js.map +1 -1
  196. package/lib/module/web/index.js +4 -10
  197. package/lib/module/web/index.js.map +1 -1
  198. package/lib/module/web/registry.js +11 -9
  199. package/lib/module/web/registry.js.map +1 -1
  200. package/lib/module/web/runtime.js +5 -1
  201. package/lib/module/web/runtime.js.map +1 -1
  202. package/lib/module/web/services.js +7 -1
  203. package/lib/module/web/services.js.map +1 -1
  204. package/lib/module/web/shadowRegistry.js +27 -10
  205. package/lib/module/web/shadowRegistry.js.map +1 -1
  206. package/lib/module/web/state.js +11 -2
  207. package/lib/module/web/state.js.map +1 -1
  208. package/lib/module/web/types.js +1 -1
  209. package/lib/module/web/types.js.map +1 -1
  210. package/lib/module/web/utils/createUnistylesRef.js +24 -0
  211. package/lib/module/web/utils/createUnistylesRef.js.map +1 -0
  212. package/lib/module/web/utils/unistyle.js +32 -10
  213. package/lib/module/web/utils/unistyle.js.map +1 -1
  214. package/lib/module/web-only/getWebProps.js +14 -0
  215. package/lib/module/web-only/getWebProps.js.map +1 -0
  216. package/lib/module/web-only/index.js +4 -0
  217. package/lib/module/web-only/index.js.map +1 -0
  218. package/lib/typescript/src/components/native/Animated.d.ts.map +1 -1
  219. package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
  220. package/lib/typescript/src/components/native/Image.native.d.ts +2 -0
  221. package/lib/typescript/src/components/native/Image.native.d.ts.map +1 -0
  222. package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
  223. package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
  224. package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
  225. package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
  226. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
  227. package/lib/typescript/src/core/getClassname.d.ts +5 -5
  228. package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
  229. package/lib/typescript/src/core/passForwardRef.d.ts +1 -1
  230. package/lib/typescript/src/core/passForwardRef.d.ts.map +1 -1
  231. package/lib/typescript/src/core/useProxifiedUnistyles/listener.d.ts.map +1 -1
  232. package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts.map +1 -1
  233. package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
  234. package/lib/typescript/src/core/warn.d.ts.map +1 -1
  235. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts +1 -1
  236. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
  237. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts +1 -3
  238. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
  239. package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -1
  240. package/lib/typescript/src/hooks/useMedia.native.d.ts.map +1 -1
  241. package/lib/typescript/src/mocks.d.ts +2 -0
  242. package/lib/typescript/src/mocks.d.ts.map +1 -0
  243. package/lib/typescript/src/mq.d.ts +0 -8
  244. package/lib/typescript/src/mq.d.ts.map +1 -1
  245. package/lib/typescript/src/reanimated/index.d.ts +2 -0
  246. package/lib/typescript/src/reanimated/index.d.ts.map +1 -0
  247. package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts +4 -0
  248. package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts.map +1 -0
  249. package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts +4 -0
  250. package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts.map +1 -0
  251. package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -1
  252. package/lib/typescript/src/server/hydrateServerUnistyles.d.ts +0 -1
  253. package/lib/typescript/src/server/hydrateServerUnistyles.d.ts.map +1 -1
  254. package/lib/typescript/src/server/resetServerUnistyles.d.ts.map +1 -1
  255. package/lib/typescript/src/server/serialize.d.ts +2 -0
  256. package/lib/typescript/src/server/serialize.d.ts.map +1 -0
  257. package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -1
  258. package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts +2 -1
  259. package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
  260. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  261. package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
  262. package/lib/typescript/src/types/common.d.ts +0 -1
  263. package/lib/typescript/src/types/common.d.ts.map +1 -1
  264. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  265. package/lib/typescript/src/utils.d.ts +8 -0
  266. package/lib/typescript/src/utils.d.ts.map +1 -1
  267. package/lib/typescript/src/web/convert/index.d.ts +2 -1
  268. package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
  269. package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -1
  270. package/lib/typescript/src/web/convert/object/filter.d.ts +2 -1
  271. package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -1
  272. package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -1
  273. package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -1
  274. package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -1
  275. package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts.map +1 -1
  276. package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts.map +1 -1
  277. package/lib/typescript/src/web/convert/shadow/textShadow.d.ts.map +1 -1
  278. package/lib/typescript/src/web/convert/style.d.ts.map +1 -1
  279. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  280. package/lib/typescript/src/web/create.d.ts.map +1 -1
  281. package/lib/typescript/src/web/css/core.d.ts.map +1 -1
  282. package/lib/typescript/src/web/css/state.d.ts +4 -1
  283. package/lib/typescript/src/web/css/state.d.ts.map +1 -1
  284. package/lib/typescript/src/web/css/utils.d.ts.map +1 -1
  285. package/lib/typescript/src/web/index.d.ts +0 -5
  286. package/lib/typescript/src/web/index.d.ts.map +1 -1
  287. package/lib/typescript/src/web/listener.d.ts.map +1 -1
  288. package/lib/typescript/src/web/registry.d.ts +2 -2
  289. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  290. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  291. package/lib/typescript/src/web/services.d.ts +6 -1
  292. package/lib/typescript/src/web/services.d.ts.map +1 -1
  293. package/lib/typescript/src/web/shadowRegistry.d.ts +2 -2
  294. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  295. package/lib/typescript/src/web/state.d.ts +2 -0
  296. package/lib/typescript/src/web/state.d.ts.map +1 -1
  297. package/lib/typescript/src/web/types.d.ts +3 -0
  298. package/lib/typescript/src/web/types.d.ts.map +1 -1
  299. package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
  300. package/lib/typescript/src/web/utils/createUnistylesRef.d.ts +11 -0
  301. package/lib/typescript/src/web/utils/createUnistylesRef.d.ts.map +1 -0
  302. package/lib/typescript/src/web/utils/unistyle.d.ts +5 -2
  303. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  304. package/lib/typescript/src/web/variants.d.ts.map +1 -1
  305. package/lib/typescript/src/web-only/getWebProps.d.ts +7 -0
  306. package/lib/typescript/src/web-only/getWebProps.d.ts.map +1 -0
  307. package/lib/typescript/src/web-only/index.d.ts +2 -0
  308. package/lib/typescript/src/web-only/index.d.ts.map +1 -0
  309. package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +3 -0
  310. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistyleDependency.kt +2 -1
  311. package/nitrogen/generated/ios/swift/UnistyleDependency.swift +4 -0
  312. package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +2 -1
  313. package/package.json +66 -32
  314. package/plugin/index.js +155 -67
  315. package/reanimated/package.json +6 -0
  316. package/server/package.json +6 -0
  317. package/src/components/native/Image.native.tsx +4 -0
  318. package/src/components/native/Image.tsx +36 -3
  319. package/src/components/native/ImageBackground.tsx +18 -33
  320. package/src/components/native/Pressable.native.tsx +12 -4
  321. package/src/core/createUnistylesElement.native.tsx +12 -6
  322. package/src/core/createUnistylesElement.tsx +26 -27
  323. package/src/core/createUnistylesImageBackground.tsx +16 -10
  324. package/src/core/getClassname.ts +16 -5
  325. package/src/core/passForwardRef.ts +5 -5
  326. package/src/core/useProxifiedUnistyles/listener.ts +3 -3
  327. package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +17 -0
  328. package/src/core/withUnistyles/withUnistyles.native.tsx +3 -4
  329. package/src/core/withUnistyles/withUnistyles.tsx +23 -6
  330. package/src/hooks/useMedia.native.ts +1 -1
  331. package/src/hooks/useMedia.ts +1 -1
  332. package/src/mocks.ts +217 -0
  333. package/src/mq.ts +0 -24
  334. package/src/reanimated/index.ts +1 -0
  335. package/src/reanimated/useAnimatedTheme.native.ts +21 -0
  336. package/src/reanimated/useAnimatedTheme.ts +19 -0
  337. package/src/server/getServerUnistyles.tsx +15 -10
  338. package/src/server/hydrateServerUnistyles.ts +3 -2
  339. package/src/server/resetServerUnistyles.ts +4 -3
  340. package/src/server/serialize.ts +20 -0
  341. package/src/specs/NativePlatform/NativePlatform.nitro.ts +2 -1
  342. package/src/specs/ShadowRegistry/index.ts +1 -2
  343. package/src/types/common.ts +0 -1
  344. package/src/utils.ts +25 -0
  345. package/src/web/convert/index.ts +5 -7
  346. package/src/web/convert/object/filter.ts +4 -4
  347. package/src/web/create.ts +10 -3
  348. package/src/web/css/core.ts +2 -2
  349. package/src/web/css/state.ts +5 -3
  350. package/src/web/index.ts +4 -16
  351. package/src/web/registry.ts +20 -11
  352. package/src/web/runtime.ts +6 -2
  353. package/src/web/services.ts +14 -1
  354. package/src/web/shadowRegistry.ts +35 -13
  355. package/src/web/state.ts +14 -2
  356. package/src/web/types.ts +9 -4
  357. package/src/web/utils/createUnistylesRef.ts +33 -0
  358. package/src/web/utils/unistyle.ts +55 -23
  359. package/src/web-only/getWebProps.ts +18 -0
  360. package/src/web-only/index.ts +2 -0
  361. package/web/package.json +6 -0
  362. package/cxx/core/UnistylesCommitHook.cpp +0 -52
  363. package/cxx/core/UnistylesCommitHook.h +0 -27
  364. package/cxx/core/UnistylesMountHook.cpp +0 -28
  365. package/cxx/core/UnistylesMountHook.h +0 -24
  366. package/lib/module/package.json +0 -1
  367. /package/cxx/common/{Constants.h → UnistylesConstants.h} +0 -0
package/plugin/index.js CHANGED
@@ -59,6 +59,9 @@ var REACT_NATIVE_COMPONENT_NAMES = [
59
59
  ];
60
60
  var REPLACE_WITH_UNISTYLES_PATHS = [
61
61
  "react-native-reanimated/src/component",
62
+ "react-native-reanimated/lib/module/component",
63
+ "react-native-gesture-handler/lib/module/components",
64
+ "react-native-gesture-handler/lib/commonjs/components",
62
65
  "react-native-gesture-handler/src/components"
63
66
  ];
64
67
  var REPLACE_WITH_UNISTYLES_EXOTIC_PATHS = [];
@@ -80,10 +83,10 @@ var NATIVE_COMPONENTS_PATHS = {
80
83
 
81
84
  // plugin/src/exotic.ts
82
85
  var t = __toESM(require("@babel/types"));
83
- function handleExoticImport(path, state, exoticImport) {
84
- const specifiers = path.node.specifiers;
85
- const source = path.node.source;
86
- if (path.node.importKind !== "value") {
86
+ function handleExoticImport(path2, state, exoticImport) {
87
+ const specifiers = path2.node.specifiers;
88
+ const source = path2.node.source;
89
+ if (path2.node.importKind !== "value") {
87
90
  return;
88
91
  }
89
92
  specifiers.forEach((specifier) => {
@@ -101,7 +104,7 @@ function handleExoticImport(path, state, exoticImport) {
101
104
  state.opts.isLocal ? state.file.opts.filename?.split("react-native-unistyles").at(0)?.concat(`react-native-unistyles/components/native/${rule.mapTo}`) ?? "" : `react-native-unistyles/components/native/${rule.mapTo}`
102
105
  )
103
106
  );
104
- path.replaceWith(newImport);
107
+ path2.replaceWith(newImport);
105
108
  } else {
106
109
  const newImport = t.importDeclaration(
107
110
  [t.importSpecifier(t.identifier(rule.mapTo), t.identifier(rule.mapTo))],
@@ -109,11 +112,11 @@ function handleExoticImport(path, state, exoticImport) {
109
112
  state.opts.isLocal ? state.file.opts.filename?.split("react-native-unistyles").at(0)?.concat(`react-native-unistyles/components/native/${rule.mapTo}`) ?? "" : `react-native-unistyles/components/native/${rule.mapTo}`
110
113
  )
111
114
  );
112
- path.node.specifiers = specifiers.filter((s) => s !== specifier);
113
- if (path.node.specifiers.length === 0) {
114
- path.replaceWith(newImport);
115
+ path2.node.specifiers = specifiers.filter((s) => s !== specifier);
116
+ if (path2.node.specifiers.length === 0) {
117
+ path2.replaceWith(newImport);
115
118
  } else {
116
- path.insertBefore(newImport);
119
+ path2.insertBefore(newImport);
117
120
  }
118
121
  }
119
122
  return;
@@ -123,12 +126,12 @@ function handleExoticImport(path, state, exoticImport) {
123
126
 
124
127
  // plugin/src/import.ts
125
128
  var t2 = __toESM(require("@babel/types"));
126
- function addUnistylesImport(path, state) {
129
+ function addUnistylesImport(path2, state) {
127
130
  const localNames = Object.keys(state.reactNativeImports);
128
131
  const names = Object.values(state.reactNativeImports);
129
132
  const pairs = Object.entries(state.reactNativeImports);
130
133
  const nodesToRemove = [];
131
- path.node.body.forEach((node) => {
134
+ path2.node.body.forEach((node) => {
132
135
  if (t2.isImportDeclaration(node) && node.source.value === "react-native") {
133
136
  node.specifiers = node.specifiers.filter((specifier) => !localNames.some((name) => name === specifier.local.name));
134
137
  if (node.specifiers.length === 0) {
@@ -137,7 +140,7 @@ function addUnistylesImport(path, state) {
137
140
  }
138
141
  });
139
142
  names.forEach((name) => {
140
- const rnWebImport = path.node.body.find((node) => t2.isImportDeclaration(node) && node.source.value === `react-native-web/dist/exports/${name}`);
143
+ const rnWebImport = path2.node.body.find((node) => t2.isImportDeclaration(node) && node.source.value === `react-native-web/dist/exports/${name}`);
141
144
  if (rnWebImport) {
142
145
  rnWebImport.specifiers = [];
143
146
  }
@@ -149,18 +152,41 @@ function addUnistylesImport(path, state) {
149
152
  state.opts.isLocal ? state.file.opts.filename?.split("react-native-unistyles").at(0)?.concat(`react-native-unistyles/src/components/native/${name}`) ?? "" : `react-native-unistyles/components/native/${name}`
150
153
  )
151
154
  );
152
- path.node.body.unshift(newImport);
155
+ path2.node.body.unshift(newImport);
153
156
  });
154
- nodesToRemove.forEach((node) => path.node.body.splice(path.node.body.indexOf(node), 1));
157
+ nodesToRemove.forEach((node) => path2.node.body.splice(path2.node.body.indexOf(node), 1));
155
158
  }
156
159
  function isInsideNodeModules(state) {
157
- return state.file.opts.filename?.includes("node_modules");
160
+ return state.file.opts.filename?.includes("node_modules") && !state.file.replaceWithUnistyles;
158
161
  }
162
+ function addUnistylesRequire(path2, state) {
163
+ Object.entries(state.reactNativeImports).forEach(([componentName, uniqueName]) => {
164
+ const newRequire = t2.variableDeclaration("const", [
165
+ t2.variableDeclarator(
166
+ t2.identifier(uniqueName),
167
+ t2.callExpression(t2.identifier("require"), [
168
+ t2.stringLiteral(`react-native-unistyles/src/components/native/${componentName}`)
169
+ ])
170
+ )
171
+ ]);
172
+ path2.node.body.unshift(newRequire);
173
+ });
174
+ }
175
+
176
+ // plugin/src/paths.ts
177
+ var import_node_path = __toESM(require("node:path"));
178
+ var isWindows = process.platform === "win32";
179
+ var toWinPath = (pathString) => {
180
+ return import_node_path.default.normalize(pathString).replace(/\//g, "\\");
181
+ };
182
+ var toPlatformPath = (pathString) => {
183
+ return isWindows ? toWinPath(pathString) : pathString;
184
+ };
159
185
 
160
186
  // plugin/src/ref.ts
161
187
  var t3 = __toESM(require("@babel/types"));
162
- function hasStringRef(path) {
163
- return path.node.openingElement.attributes.find(
188
+ function hasStringRef(path2) {
189
+ return path2.node.openingElement.attributes.find(
164
190
  (attr) => t3.isJSXAttribute(attr) && t3.isJSXIdentifier(attr.name, { name: "ref" }) && t3.isStringLiteral(attr.value)
165
191
  );
166
192
  }
@@ -182,7 +208,8 @@ var UnistyleDependency = {
182
208
  FontScale: 11,
183
209
  StatusBar: 12,
184
210
  NavigationBar: 13,
185
- Ime: 14
211
+ Ime: 14,
212
+ Rtl: 15
186
213
  };
187
214
  function getProperty(property) {
188
215
  if (!property) {
@@ -265,6 +292,9 @@ function toUnistylesDependency(dependency) {
265
292
  case "variants": {
266
293
  return UnistyleDependency.Variants;
267
294
  }
295
+ case "rtl": {
296
+ return UnistyleDependency.Rtl;
297
+ }
268
298
  default:
269
299
  return null;
270
300
  }
@@ -293,28 +323,47 @@ function stringToUniqueId(str) {
293
323
  const absHash = Math.abs(hash);
294
324
  return absHash % 1e9;
295
325
  }
296
- function isUnistylesStyleSheet(path, state) {
297
- const { callee } = path.node;
298
- if (t4.isMemberExpression(callee) && t4.isIdentifier(callee.property)) {
299
- return callee.property.name === "create" && t4.isIdentifier(callee.object) && callee.object.name === state.file.styleSheetLocalName;
326
+ function isUnistylesStyleSheet(path2, state) {
327
+ const { callee } = path2.node;
328
+ if (!t4.isMemberExpression(callee) || !t4.isIdentifier(callee.property)) {
329
+ return false;
330
+ }
331
+ const isImport = callee.property.name === "create" && t4.isIdentifier(callee.object) && callee.object.name === state.file.styleSheetLocalName;
332
+ const isRequire = state.file.hasUnistylesImport && callee.property.name === "create" && t4.isMemberExpression(callee.object) && t4.isIdentifier(callee.object.property) && t4.isIdentifier(callee.object.object) && callee.object.object.name === state.file.styleSheetLocalName && callee.object.property.name === "StyleSheet";
333
+ return isImport || isRequire;
334
+ }
335
+ function isUnistylesCommonJSRequire(path2, state) {
336
+ const isRequire = t4.isIdentifier(path2.node.callee) && path2.node.arguments.length > 0 && t4.isStringLiteral(path2.node.arguments[0]) && path2.node.arguments[0].value === "react-native-unistyles";
337
+ if (isRequire && t4.isVariableDeclarator(path2.parent) && t4.isIdentifier(path2.parent.id)) {
338
+ state.file.hasUnistylesImport = true;
339
+ state.file.styleSheetLocalName = path2.parent.id.name;
340
+ }
341
+ return isRequire;
342
+ }
343
+ function isReactNativeCommonJSRequire(path2, state) {
344
+ const isRequire = t4.isIdentifier(path2.node.callee) && path2.node.arguments.length > 0 && path2.node.callee.name === "require";
345
+ const requireImportName = path2.node.arguments.find((node) => t4.isStringLiteral(node));
346
+ const isReactNativeRequire = isRequire && requireImportName && (requireImportName.value === "react-native" || requireImportName.value === "react-native-web/dist/index");
347
+ if (isReactNativeRequire && t4.isVariableDeclarator(path2.parent) && t4.isIdentifier(path2.parent.id)) {
348
+ state.file.reactNativeCommonJSName = path2.parent.id.name;
300
349
  }
301
- return false;
350
+ return isRequire;
302
351
  }
303
- function isKindOfStyleSheet(path, state) {
352
+ function isKindOfStyleSheet(path2, state) {
304
353
  if (!state.file.forceProcessing && !state.file.hasUnistylesImport) {
305
354
  return false;
306
355
  }
307
- const { callee } = path.node;
356
+ const { callee } = path2.node;
308
357
  return t4.isMemberExpression(callee) && t4.isIdentifier(callee.property) && callee.property.name === "create" && t4.isIdentifier(callee.object);
309
358
  }
310
- function addStyleSheetTag(path, state) {
359
+ function addStyleSheetTag(path2, state) {
311
360
  const str = state.filename?.replace(state.cwd, "") ?? "";
312
361
  const uniqueId = stringToUniqueId(str) + ++state.file.tagNumber;
313
- path.node.arguments.push(t4.numericLiteral(uniqueId));
362
+ path2.node.arguments.push(t4.numericLiteral(uniqueId));
314
363
  }
315
- function getStylesDependenciesFromObject(path) {
364
+ function getStylesDependenciesFromObject(path2) {
316
365
  const detectedStylesWithVariants = /* @__PURE__ */ new Set();
317
- const stylesheet = path.node.arguments[0];
366
+ const stylesheet = path2.node.arguments[0];
318
367
  if (t4.isObjectExpression(stylesheet)) {
319
368
  stylesheet?.properties.forEach((property) => {
320
369
  if (!t4.isObjectProperty(property) || !t4.isIdentifier(property.key)) {
@@ -359,8 +408,7 @@ function getStylesDependenciesFromObject(path) {
359
408
  return acc;
360
409
  }, {});
361
410
  }
362
- function getStylesDependenciesFromFunction(path) {
363
- const funcPath = path.get("arguments.0");
411
+ function getStylesDependenciesFromFunction(funcPath) {
364
412
  if (!funcPath) {
365
413
  return;
366
414
  }
@@ -614,8 +662,8 @@ function addDependencies(state, styleName, unistyle, detectedDependencies) {
614
662
 
615
663
  // plugin/src/variants.ts
616
664
  var t5 = __toESM(require("@babel/types"));
617
- function extractVariants(path, state) {
618
- const maybeVariants = path.node.body.filter((node2) => t5.isExpressionStatement(node2) && t5.isCallExpression(node2.expression) && t5.isMemberExpression(node2.expression.callee));
665
+ function extractVariants(path2, state) {
666
+ const maybeVariants = path2.node.body.filter((node2) => t5.isExpressionStatement(node2) && t5.isCallExpression(node2.expression) && t5.isMemberExpression(node2.expression.callee));
619
667
  if (maybeVariants.length === 0) {
620
668
  return;
621
669
  }
@@ -638,7 +686,7 @@ function extractVariants(path, state) {
638
686
  return;
639
687
  }
640
688
  const calleeName = callee.object.name;
641
- const newUniqueName = path.scope.generateUidIdentifier(calleeName);
689
+ const newUniqueName = path2.scope.generateUidIdentifier(calleeName);
642
690
  const shadowDeclaration = t5.variableDeclaration("const", [
643
691
  t5.variableDeclarator(newUniqueName, t5.identifier(calleeName))
644
692
  ]);
@@ -649,14 +697,14 @@ function extractVariants(path, state) {
649
697
  const finalDeclaration = t5.variableDeclaration("const", [
650
698
  t5.variableDeclarator(t5.identifier(calleeName), newCallExpression)
651
699
  ]);
652
- const pathIndex = path.node.body.findIndex((bodyPath) => bodyPath === targetVariant);
653
- const rest = path.node.body.slice(pathIndex + 1);
700
+ const pathIndex = path2.node.body.findIndex((bodyPath) => bodyPath === targetVariant);
701
+ const rest = path2.node.body.slice(pathIndex + 1);
654
702
  const statement = t5.blockStatement([
655
703
  finalDeclaration,
656
704
  ...rest
657
705
  ]);
658
- path.node.body = [
659
- ...path.node.body.slice(0, pathIndex),
706
+ path2.node.body = [
707
+ ...path2.node.body.slice(0, pathIndex),
660
708
  shadowDeclaration,
661
709
  statement
662
710
  ];
@@ -665,52 +713,71 @@ function extractVariants(path, state) {
665
713
 
666
714
  // plugin/src/index.ts
667
715
  function index_default() {
716
+ if (process.env.NODE_ENV === "test") {
717
+ return {
718
+ name: "babel-react-native-unistyles",
719
+ visitor: {}
720
+ };
721
+ }
668
722
  return {
669
723
  name: "babel-react-native-unistyles",
670
724
  visitor: {
671
725
  Program: {
672
- enter(_, state) {
673
- state.file.replaceWithUnistyles = REPLACE_WITH_UNISTYLES_PATHS.concat(state.opts.autoProcessPaths ?? []).some((path) => state.filename?.includes(path));
726
+ enter(path2, state) {
727
+ state.file.replaceWithUnistyles = REPLACE_WITH_UNISTYLES_PATHS.map(toPlatformPath).concat(state.opts.autoProcessPaths ?? []).some((path3) => state.filename?.includes(path3));
674
728
  state.file.hasAnyUnistyle = false;
675
729
  state.file.hasUnistylesImport = false;
730
+ state.file.addUnistylesRequire = false;
676
731
  state.file.hasVariants = false;
677
732
  state.file.styleSheetLocalName = "";
733
+ state.file.reactNativeCommonJSName = "";
678
734
  state.file.tagNumber = 0;
679
735
  state.reactNativeImports = {};
680
- state.file.forceProcessing = state.opts.autoProcessRoot && state.filename ? state.filename.includes(`${state.file.opts.root}/${state.opts.autoProcessRoot}/`) : false;
736
+ state.file.forceProcessing = state.opts.autoProcessRoot && state.filename ? state.filename.includes(toPlatformPath(`${state.file.opts.root}/${state.opts.autoProcessRoot}/`)) : false;
737
+ path2.traverse({
738
+ BlockStatement(blockPath) {
739
+ if (isInsideNodeModules(state)) {
740
+ return;
741
+ }
742
+ extractVariants(blockPath, state);
743
+ }
744
+ });
681
745
  },
682
- exit(path, state) {
683
- if (isInsideNodeModules(state) && !state.file.replaceWithUnistyles) {
746
+ exit(path2, state) {
747
+ if (isInsideNodeModules(state)) {
684
748
  return;
685
749
  }
750
+ if (state.file.addUnistylesRequire) {
751
+ return addUnistylesRequire(path2, state);
752
+ }
686
753
  if (state.file.hasAnyUnistyle || state.file.hasVariants || state.file.replaceWithUnistyles || state.file.forceProcessing) {
687
- addUnistylesImport(path, state);
754
+ addUnistylesImport(path2, state);
688
755
  }
689
756
  }
690
757
  },
691
- FunctionDeclaration(path, state) {
758
+ FunctionDeclaration(path2, state) {
692
759
  if (isInsideNodeModules(state)) {
693
760
  return;
694
761
  }
695
- const componentName = path.node.id ? path.node.id.name : null;
762
+ const componentName = path2.node.id ? path2.node.id.name : null;
696
763
  if (componentName) {
697
764
  state.file.hasVariants = false;
698
765
  }
699
766
  },
700
- ClassDeclaration(path, state) {
767
+ ClassDeclaration(path2, state) {
701
768
  if (isInsideNodeModules(state)) {
702
769
  return;
703
770
  }
704
- const componentName = path.node.id ? path.node.id.name : null;
771
+ const componentName = path2.node.id ? path2.node.id.name : null;
705
772
  if (componentName) {
706
773
  state.file.hasVariants = false;
707
774
  }
708
775
  },
709
- VariableDeclaration(path, state) {
776
+ VariableDeclaration(path2, state) {
710
777
  if (isInsideNodeModules(state)) {
711
778
  return;
712
779
  }
713
- path.node.declarations.forEach((declaration) => {
780
+ path2.node.declarations.forEach((declaration) => {
714
781
  if (t6.isArrowFunctionExpression(declaration.init) || t6.isFunctionExpression(declaration.init)) {
715
782
  const componentName = declaration.id && t6.isIdentifier(declaration.id) ? declaration.id.name : null;
716
783
  if (componentName) {
@@ -719,63 +786,83 @@ function index_default() {
719
786
  }
720
787
  });
721
788
  },
722
- ImportDeclaration(path, state) {
789
+ ImportDeclaration(path2, state) {
723
790
  const exoticImport = REPLACE_WITH_UNISTYLES_EXOTIC_PATHS.concat(state.opts.autoRemapImports ?? []).find((exotic) => state.filename?.includes(exotic.path));
724
791
  if (exoticImport) {
725
- return handleExoticImport(path, state, exoticImport);
792
+ return handleExoticImport(path2, state, exoticImport);
726
793
  }
727
- if (isInsideNodeModules(state) && !state.file.replaceWithUnistyles) {
794
+ if (isInsideNodeModules(state)) {
728
795
  return;
729
796
  }
730
- const importSource = path.node.source.value;
797
+ const importSource = path2.node.source.value;
731
798
  if (importSource.includes("react-native-unistyles")) {
732
799
  state.file.hasUnistylesImport = true;
733
- path.node.specifiers.forEach((specifier) => {
800
+ path2.node.specifiers.forEach((specifier) => {
734
801
  if (t6.isImportSpecifier(specifier) && t6.isIdentifier(specifier.imported) && specifier.imported.name === "StyleSheet") {
735
802
  state.file.styleSheetLocalName = specifier.local.name;
736
803
  }
737
804
  });
738
805
  }
739
806
  if (importSource === "react-native") {
740
- path.node.specifiers.forEach((specifier) => {
807
+ path2.node.specifiers.forEach((specifier) => {
741
808
  if (t6.isImportSpecifier(specifier) && t6.isIdentifier(specifier.imported) && REACT_NATIVE_COMPONENT_NAMES.includes(specifier.imported.name)) {
742
809
  state.reactNativeImports[specifier.local.name] = specifier.imported.name;
743
810
  }
744
811
  });
745
812
  }
746
813
  if (importSource.includes("react-native/Libraries")) {
747
- handleExoticImport(path, state, NATIVE_COMPONENTS_PATHS);
814
+ handleExoticImport(path2, state, NATIVE_COMPONENTS_PATHS);
748
815
  }
749
816
  if (!state.file.forceProcessing && Array.isArray(state.opts.autoProcessImports)) {
750
817
  state.file.forceProcessing = state.opts.autoProcessImports.includes(importSource);
751
818
  }
752
819
  },
753
- JSXElement(path, state) {
820
+ JSXElement(path2, state) {
754
821
  if (isInsideNodeModules(state)) {
755
822
  return;
756
823
  }
757
- if (hasStringRef(path)) {
824
+ if (hasStringRef(path2)) {
758
825
  throw new Error("Detected string based ref which is not supported by Unistyles.");
759
826
  }
760
827
  },
761
- BlockStatement(path, state) {
828
+ MemberExpression(path2, state) {
762
829
  if (isInsideNodeModules(state)) {
763
830
  return;
764
831
  }
765
- extractVariants(path, state);
832
+ if (!state.file.reactNativeCommonJSName || !t6.isIdentifier(path2.node.object)) {
833
+ return;
834
+ }
835
+ if (path2.node.object.name !== state.file.reactNativeCommonJSName || !t6.isIdentifier(path2.node.property)) {
836
+ return;
837
+ }
838
+ if (!REACT_NATIVE_COMPONENT_NAMES.includes(path2.node.property.name)) {
839
+ return;
840
+ }
841
+ if (!state.reactNativeImports[path2.node.property.name]) {
842
+ const uniqueId = path2.scope.generateUidIdentifier(`reactNativeUnistyles_${path2.node.property.name}`);
843
+ state.reactNativeImports[path2.node.property.name] = uniqueId.name;
844
+ state.file.addUnistylesRequire = true;
845
+ }
846
+ path2.node.object.name = state.reactNativeImports[path2.node.property.name];
766
847
  },
767
- CallExpression(path, state) {
848
+ CallExpression(path2, state) {
768
849
  if (isInsideNodeModules(state)) {
769
850
  return;
770
851
  }
771
- if (!isUnistylesStyleSheet(path, state) && !isKindOfStyleSheet(path, state)) {
852
+ if (isUnistylesCommonJSRequire(path2, state)) {
853
+ return;
854
+ }
855
+ if (isReactNativeCommonJSRequire(path2, state)) {
856
+ return;
857
+ }
858
+ if (!isUnistylesStyleSheet(path2, state) && !isKindOfStyleSheet(path2, state)) {
772
859
  return;
773
860
  }
774
861
  state.file.hasAnyUnistyle = true;
775
- addStyleSheetTag(path, state);
776
- const arg = path.node.arguments[0];
862
+ addStyleSheetTag(path2, state);
863
+ const arg = t6.isAssignmentExpression(path2.node.arguments[0]) ? path2.node.arguments[0].right : path2.node.arguments[0];
777
864
  if (t6.isObjectExpression(arg)) {
778
- const detectedDependencies = getStylesDependenciesFromObject(path);
865
+ const detectedDependencies = getStylesDependenciesFromObject(path2);
779
866
  if (detectedDependencies) {
780
867
  if (t6.isObjectExpression(arg)) {
781
868
  arg.properties.forEach((property) => {
@@ -787,7 +874,8 @@ function index_default() {
787
874
  }
788
875
  }
789
876
  if (t6.isArrowFunctionExpression(arg) || t6.isFunctionExpression(arg)) {
790
- const detectedDependencies = getStylesDependenciesFromFunction(path);
877
+ const funcPath = t6.isAssignmentExpression(path2.node.arguments[0]) ? path2.get("arguments.0.right") : path2.get("arguments.0");
878
+ const detectedDependencies = getStylesDependenciesFromFunction(funcPath);
791
879
  if (detectedDependencies) {
792
880
  const body = t6.isBlockStatement(arg.body) ? arg.body.body.find((statement) => t6.isReturnStatement(statement))?.argument : arg.body;
793
881
  if (t6.isObjectExpression(body)) {
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../lib/commonjs/reanimated/index",
3
+ "module": "../lib/module/reanimated/index",
4
+ "react-native": "../src/reanimated/index",
5
+ "types": "../lib/typescript/src/reanimated/index"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../lib/commonjs/server/index",
3
+ "module": "../lib/module/server/index",
4
+ "react-native": "../src/server/index",
5
+ "types": "../lib/typescript/src/server/index"
6
+ }
@@ -0,0 +1,4 @@
1
+ import { Image as NativeImage } from 'react-native'
2
+ import { createUnistylesElement } from '../../core'
3
+
4
+ export const Image = createUnistylesElement(NativeImage)
@@ -1,4 +1,37 @@
1
- import { Image as NativeImage } from 'react-native'
2
- import { createUnistylesElement } from '../../core'
1
+ import React, { type ComponentProps, forwardRef } from 'react'
2
+ import { type ImageStyle, Image as NativeImage, type StyleProp, type ViewStyle } from 'react-native'
3
+ import { getClassName } from '../../core'
4
+ import { maybeWarnAboutMultipleUnistyles } from '../../core/warn'
5
+ import type { UnistylesValues } from '../../types'
6
+ import { copyComponentProperties } from '../../utils'
7
+ import { checkForProp } from '../../web/utils'
8
+ import { createUnistylesRef } from '../../web/utils/createUnistylesRef'
3
9
 
4
- export const Image = createUnistylesElement(NativeImage)
10
+ type Props = ComponentProps<typeof NativeImage> & {
11
+ style?: UnistylesValues
12
+ imageStyle?: UnistylesValues
13
+ }
14
+
15
+ const UnistylesImage = forwardRef<unknown, Props>((props, forwardedRef) => {
16
+ const classNames = getClassName(props.style)
17
+ const ref = createUnistylesRef(classNames, forwardedRef)
18
+ const hasWidthStyle = checkForProp(props.style, 'width')
19
+ const hasHeightStyle = checkForProp(props.style, 'height')
20
+
21
+ maybeWarnAboutMultipleUnistyles(props.style as ViewStyle, 'Image')
22
+
23
+ return (
24
+ <NativeImage
25
+ {...props}
26
+ style={[
27
+ classNames,
28
+ // Clear inline width and height extracted from source
29
+ hasWidthStyle && { width: '' },
30
+ hasHeightStyle && { height: '' }
31
+ ] as StyleProp<ImageStyle>}
32
+ ref={ref}
33
+ />
34
+ )
35
+ })
36
+
37
+ export const Image = copyComponentProperties(NativeImage, UnistylesImage)
@@ -2,10 +2,11 @@ import React from 'react'
2
2
  import { forwardRef } from 'react'
3
3
  import { type ImageStyle, ImageBackground as NativeImageBackground, type StyleProp, type ViewStyle } from 'react-native'
4
4
  import { getClassName } from '../../core'
5
+ import { maybeWarnAboutMultipleUnistyles } from '../../core/warn'
5
6
  import type { UnistylesValues } from '../../types'
6
7
  import { copyComponentProperties } from '../../utils'
7
- import { UnistylesShadowRegistry } from '../../web'
8
- import { isServer } from '../../web/utils'
8
+ import { keyInObject } from '../../web/utils'
9
+ import { createUnistylesRef } from '../../web/utils/createUnistylesRef'
9
10
 
10
11
  type Props = {
11
12
  style?: UnistylesValues
@@ -13,44 +14,28 @@ type Props = {
13
14
  }
14
15
 
15
16
  const UnistylesImageBackground = forwardRef<unknown, Props>((props, forwardedRef) => {
16
- let storedRef: NativeImageBackground | null = null
17
- let storedImageRef: NativeImageBackground | null = null
18
17
  const styleClassNames = getClassName(props.style)
19
18
  const imageClassNames = getClassName(props.imageStyle)
19
+ const ref = createUnistylesRef(styleClassNames, forwardedRef)
20
+ const imageRef = createUnistylesRef(imageClassNames)
21
+ const hasWidthStyle = typeof props.imageStyle === 'object' && keyInObject(props.imageStyle, 'width')
22
+ const hasHeightStyle = typeof props.imageStyle === 'object' && keyInObject(props.imageStyle, 'height')
23
+
24
+ maybeWarnAboutMultipleUnistyles(props.style as ViewStyle, 'ImageBackground')
25
+ maybeWarnAboutMultipleUnistyles(props.imageStyle as ViewStyle, 'ImageBackground')
20
26
 
21
27
  return (
22
28
  <NativeImageBackground
23
29
  {...props}
24
30
  style={styleClassNames as StyleProp<ViewStyle>}
25
- imageStyle={imageClassNames as StyleProp<ImageStyle>}
26
- ref={isServer() ? undefined : ref => {
27
- if (!ref) {
28
- // @ts-expect-error hidden from TS
29
- UnistylesShadowRegistry.remove(storedRef, styleClassNames?.hash)
30
- }
31
-
32
- storedRef = ref
33
- // @ts-expect-error hidden from TS
34
- UnistylesShadowRegistry.add(ref, styleClassNames?.hash)
35
-
36
- if (typeof forwardedRef === 'function') {
37
- return forwardedRef(ref)
38
- }
39
-
40
- if (forwardedRef) {
41
- forwardedRef.current = ref
42
- }
43
- }}
44
- imageRef={isServer() ? undefined : ref => {
45
- if (!ref) {
46
- // @ts-expect-error hidden from TS
47
- UnistylesShadowRegistry.remove(storedImageRef, imageClassNames?.hash)
48
- }
49
-
50
- storedImageRef = ref
51
- // @ts-expect-error hidden from TS
52
- UnistylesShadowRegistry.add(ref, imageClassNames?.hash)
53
- }}
31
+ imageStyle={[
32
+ imageClassNames,
33
+ // Clear inline width and height extracted from source
34
+ hasWidthStyle && { width: '' },
35
+ hasHeightStyle && { height: '' }
36
+ ] as StyleProp<ImageStyle>}
37
+ ref={ref}
38
+ imageRef={imageRef}
54
39
  />
55
40
  )
56
41
  })
@@ -50,10 +50,18 @@ export const Pressable = forwardRef<View, PressableProps>(({ variants, style, ..
50
50
  storedRef.current = ref
51
51
  }
52
52
 
53
- // @ts-expect-error - this is hidden from TS
54
- UnistylesShadowRegistry.add(storedRef.current, unistyles)
55
-
56
- return passForwardedRef(props, ref, forwardedRef)
53
+ return passForwardedRef(
54
+ ref,
55
+ forwardedRef,
56
+ () => {
57
+ // @ts-expect-error - this is hidden from TS
58
+ UnistylesShadowRegistry.add(ref, unistyles)
59
+ },
60
+ () => {
61
+ // @ts-expect-error - this is hidden from TS
62
+ UnistylesShadowRegistry.remove(ref)
63
+ }
64
+ )
57
65
  }}
58
66
  style={state => {
59
67
  const isPropStyleAFunction = typeof style === 'function'
@@ -38,15 +38,21 @@ export const createUnistylesElement = (Component: any) => {
38
38
  storedRef.current = getNativeRef(Component, ref)
39
39
  }
40
40
 
41
- passForwardedRef(props, ref, forwardedRef)
42
-
43
41
  // @ts-ignore we don't know the type of the component
44
42
  maybeWarnAboutMultipleUnistyles(props.style, Component.displayName)
45
43
 
46
- return () => {
47
- // @ts-ignore
48
- UnistylesShadowRegistry.remove(ref)
49
- }
44
+ return passForwardedRef(
45
+ ref,
46
+ forwardedRef,
47
+ () => {
48
+ // @ts-ignore this is hidden from TS
49
+ UnistylesShadowRegistry.add(ref, props.style)
50
+ },
51
+ () => {
52
+ // @ts-ignore this is hidden from TS
53
+ UnistylesShadowRegistry.remove(ref)
54
+ }
55
+ )
50
56
  }}
51
57
  />
52
58
  )