react-native-unistyles 3.0.0-beta.4 → 3.0.0-beta.6

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 (543) hide show
  1. package/README.md +18 -3
  2. package/android/src/main/cxx/NativeUnistylesModule.cpp +2 -2
  3. package/android/src/main/cxx/NativeUnistylesModule.h +1 -1
  4. package/android/src/main/java/com/unistyles/NativePlatform+android.kt +1 -2
  5. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +4 -0
  6. package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +2 -1
  7. package/android/src/main/java/com/unistyles/UnistylesModule.kt +0 -4
  8. package/android/src/main/java/com/unistyles/UnistylesPackage.kt +6 -6
  9. package/components/native/ActivityIndicator/package.json +2 -1
  10. package/components/native/Animated/package.json +5 -0
  11. package/components/native/FlatList/package.json +2 -1
  12. package/components/native/Image/package.json +2 -1
  13. package/components/native/ImageBackground/package.json +2 -1
  14. package/components/native/KeyboardAvoidingView/package.json +2 -1
  15. package/components/native/NativeText/package.json +5 -0
  16. package/components/native/NativeView/package.json +5 -0
  17. package/components/native/Pressable/package.json +1 -1
  18. package/components/native/RefreshControl/package.json +2 -1
  19. package/components/native/ScrollView/package.json +2 -1
  20. package/components/native/SectionList/package.json +2 -1
  21. package/components/native/Switch/package.json +2 -1
  22. package/components/native/Text/package.json +2 -1
  23. package/components/native/TextInput/package.json +2 -1
  24. package/components/native/TouchableHighlight/package.json +2 -1
  25. package/components/native/TouchableOpacity/package.json +2 -1
  26. package/components/native/View/package.json +2 -1
  27. package/components/native/VirtualizedList/package.json +2 -1
  28. package/cxx/common/Constants.h +4 -4
  29. package/cxx/common/Helpers.h +1 -1
  30. package/cxx/core/HashGenerator.cpp +23 -0
  31. package/cxx/core/HashGenerator.h +13 -0
  32. package/cxx/core/HostUnistyle.cpp +83 -0
  33. package/cxx/core/HostUnistyle.h +27 -0
  34. package/cxx/core/RNStyle.h +18 -0
  35. package/cxx/core/Unistyle.h +13 -4
  36. package/cxx/core/UnistyleWrapper.h +92 -47
  37. package/cxx/core/UnistylesRegistry.cpp +40 -11
  38. package/cxx/core/UnistylesRegistry.h +5 -4
  39. package/cxx/hybridObjects/HybridNavigationBar.cpp +3 -3
  40. package/cxx/hybridObjects/HybridNavigationBar.h +2 -2
  41. package/cxx/hybridObjects/HybridShadowRegistry.cpp +39 -45
  42. package/cxx/hybridObjects/HybridShadowRegistry.h +0 -10
  43. package/cxx/hybridObjects/HybridStatusBar.cpp +3 -3
  44. package/cxx/hybridObjects/HybridStatusBar.h +2 -2
  45. package/cxx/hybridObjects/HybridStyleSheet.cpp +52 -10
  46. package/cxx/hybridObjects/HybridStyleSheet.h +2 -1
  47. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +15 -15
  48. package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -2
  49. package/cxx/parser/Parser.cpp +26 -27
  50. package/cxx/parser/Parser.h +2 -1
  51. package/ios/NativePlatform+ios.swift +21 -11
  52. package/ios/NativePlatform.swift +2 -2
  53. package/ios/UnistylesModuleOnLoad.h +4 -4
  54. package/ios/UnistylesModuleOnLoad.mm +5 -8
  55. package/lib/commonjs/components/ScopedTheme.js.map +1 -1
  56. package/lib/commonjs/components/index.js +0 -7
  57. package/lib/commonjs/components/index.js.map +1 -1
  58. package/lib/commonjs/components/native/Animated.js +23 -0
  59. package/lib/commonjs/components/native/Animated.js.map +1 -0
  60. package/lib/commonjs/components/native/ImageBackground.js +47 -1
  61. package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
  62. package/lib/commonjs/components/native/ImageBackground.native.js +10 -0
  63. package/lib/commonjs/components/native/ImageBackground.native.js.map +1 -0
  64. package/lib/commonjs/components/native/NativeText.js +13 -0
  65. package/lib/commonjs/components/native/NativeText.js.map +1 -0
  66. package/lib/commonjs/components/native/NativeText.native.js +18 -0
  67. package/lib/commonjs/components/native/NativeText.native.js.map +1 -0
  68. package/lib/commonjs/components/native/NativeView.js +9 -0
  69. package/lib/commonjs/components/native/NativeView.js.map +1 -0
  70. package/lib/commonjs/components/native/NativeView.native.js +20 -0
  71. package/lib/commonjs/components/native/NativeView.native.js.map +1 -0
  72. package/lib/commonjs/components/native/Pressable.js +26 -51
  73. package/lib/commonjs/components/native/Pressable.js.map +1 -1
  74. package/lib/commonjs/components/native/Pressable.native.js +25 -9
  75. package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
  76. package/lib/commonjs/core/createUnistylesElement.js +33 -5
  77. package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
  78. package/lib/commonjs/core/createUnistylesElement.native.js +54 -0
  79. package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -0
  80. package/lib/commonjs/core/createUnistylesImageBackground.js +41 -15
  81. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
  82. package/lib/commonjs/core/getClassname.js +23 -0
  83. package/lib/commonjs/core/getClassname.js.map +1 -0
  84. package/lib/commonjs/core/getClassname.native.js +9 -0
  85. package/lib/commonjs/core/getClassname.native.js.map +1 -0
  86. package/lib/commonjs/core/index.js +14 -7
  87. package/lib/commonjs/core/index.js.map +1 -1
  88. package/lib/commonjs/core/passForwardRef.js +2 -2
  89. package/lib/commonjs/core/passForwardRef.js.map +1 -1
  90. package/lib/commonjs/core/useProxifiedUnistyles/index.js +13 -0
  91. package/lib/commonjs/core/useProxifiedUnistyles/index.js.map +1 -0
  92. package/lib/commonjs/core/useProxifiedUnistyles/listener.js +22 -0
  93. package/lib/commonjs/core/useProxifiedUnistyles/listener.js.map +1 -0
  94. package/lib/commonjs/core/useProxifiedUnistyles/listener.native.js +26 -0
  95. package/lib/commonjs/core/useProxifiedUnistyles/listener.native.js.map +1 -0
  96. package/lib/commonjs/core/useProxifiedUnistyles/types.js +6 -0
  97. package/lib/commonjs/core/useProxifiedUnistyles/types.js.map +1 -0
  98. package/lib/commonjs/core/{withUnistyles/useDependencies.js → useProxifiedUnistyles/useProxifiedUnistyles.js} +22 -22
  99. package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -0
  100. package/lib/commonjs/core/useUnistyles.js +19 -0
  101. package/lib/commonjs/core/useUnistyles.js.map +1 -0
  102. package/lib/commonjs/core/warn.js +16 -0
  103. package/lib/commonjs/core/warn.js.map +1 -0
  104. package/lib/commonjs/core/withUnistyles/withUnistyles.js +19 -55
  105. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
  106. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +32 -65
  107. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
  108. package/lib/commonjs/index.js +23 -4
  109. package/lib/commonjs/index.js.map +1 -1
  110. package/lib/commonjs/server/getServerUnistyles.js +40 -0
  111. package/lib/commonjs/server/getServerUnistyles.js.map +1 -0
  112. package/lib/commonjs/server/hydrateServerUnistyles.js +17 -0
  113. package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -0
  114. package/lib/commonjs/server/index.js +34 -0
  115. package/lib/commonjs/server/index.js.map +1 -0
  116. package/lib/commonjs/server/resetServerUnistyles.js +16 -0
  117. package/lib/commonjs/server/resetServerUnistyles.js.map +1 -0
  118. package/lib/commonjs/server/types.js +8 -0
  119. package/lib/commonjs/server/types.js.map +1 -0
  120. package/lib/commonjs/server/useServerUnistyles.js +27 -0
  121. package/lib/commonjs/server/useServerUnistyles.js.map +1 -0
  122. package/lib/commonjs/specs/ShadowRegistry/index.js +6 -3
  123. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  124. package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
  125. package/lib/commonjs/utils.js +19 -2
  126. package/lib/commonjs/utils.js.map +1 -1
  127. package/lib/commonjs/web/convert/object/filter.js +2 -2
  128. package/lib/commonjs/web/convert/object/filter.js.map +1 -1
  129. package/lib/commonjs/web/convert/style.js +4 -4
  130. package/lib/commonjs/web/convert/style.js.map +1 -1
  131. package/lib/commonjs/web/create.js +20 -15
  132. package/lib/commonjs/web/create.js.map +1 -1
  133. package/lib/commonjs/web/css/core.js +55 -0
  134. package/lib/commonjs/web/css/core.js.map +1 -0
  135. package/lib/commonjs/web/css/index.js +17 -0
  136. package/lib/commonjs/web/css/index.js.map +1 -0
  137. package/lib/commonjs/web/css/state.js +155 -0
  138. package/lib/commonjs/web/css/state.js.map +1 -0
  139. package/lib/commonjs/web/css/utils.js +47 -0
  140. package/lib/commonjs/web/css/utils.js.map +1 -0
  141. package/lib/commonjs/web/index.js +14 -18
  142. package/lib/commonjs/web/index.js.map +1 -1
  143. package/lib/commonjs/web/listener.js +9 -7
  144. package/lib/commonjs/web/listener.js.map +1 -1
  145. package/lib/commonjs/web/registry.js +44 -123
  146. package/lib/commonjs/web/registry.js.map +1 -1
  147. package/lib/commonjs/web/runtime.js +28 -21
  148. package/lib/commonjs/web/runtime.js.map +1 -1
  149. package/lib/commonjs/web/services.js +28 -0
  150. package/lib/commonjs/web/services.js.map +1 -0
  151. package/lib/commonjs/web/shadowRegistry.js +46 -93
  152. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  153. package/lib/commonjs/web/state.js +39 -9
  154. package/lib/commonjs/web/state.js.map +1 -1
  155. package/lib/commonjs/web/types.js +6 -0
  156. package/lib/commonjs/web/types.js.map +1 -0
  157. package/lib/commonjs/web/utils/common.js +29 -9
  158. package/lib/commonjs/web/utils/common.js.map +1 -1
  159. package/lib/commonjs/web/utils/unistyle.js +32 -19
  160. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  161. package/lib/commonjs/web/variants.js +25 -27
  162. package/lib/commonjs/web/variants.js.map +1 -1
  163. package/lib/module/components/ScopedTheme.js.map +1 -1
  164. package/lib/module/components/index.js +0 -1
  165. package/lib/module/components/index.js.map +1 -1
  166. package/lib/module/components/native/Animated.js +19 -0
  167. package/lib/module/components/native/Animated.js.map +1 -0
  168. package/lib/module/components/native/ImageBackground.js +47 -2
  169. package/lib/module/components/native/ImageBackground.js.map +1 -1
  170. package/lib/module/components/native/ImageBackground.native.js +6 -0
  171. package/lib/module/components/native/ImageBackground.native.js.map +1 -0
  172. package/lib/module/components/native/NativeText.js +4 -0
  173. package/lib/module/components/native/NativeText.js.map +1 -0
  174. package/lib/module/components/native/NativeText.native.js +15 -0
  175. package/lib/module/components/native/NativeText.native.js.map +1 -0
  176. package/lib/module/components/native/NativeView.js +5 -0
  177. package/lib/module/components/native/NativeView.js.map +1 -0
  178. package/lib/module/components/native/NativeView.native.js +17 -0
  179. package/lib/module/components/native/NativeView.native.js.map +1 -0
  180. package/lib/module/components/native/Pressable.js +27 -52
  181. package/lib/module/components/native/Pressable.js.map +1 -1
  182. package/lib/module/components/native/Pressable.native.js +26 -10
  183. package/lib/module/components/native/Pressable.native.js.map +1 -1
  184. package/lib/module/core/createUnistylesElement.js +33 -5
  185. package/lib/module/core/createUnistylesElement.js.map +1 -1
  186. package/lib/module/core/createUnistylesElement.native.js +47 -0
  187. package/lib/module/core/createUnistylesElement.native.js.map +1 -0
  188. package/lib/module/core/createUnistylesImageBackground.js +39 -14
  189. package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
  190. package/lib/module/core/getClassname.js +18 -0
  191. package/lib/module/core/getClassname.js.map +1 -0
  192. package/lib/module/core/getClassname.native.js +4 -0
  193. package/lib/module/core/getClassname.native.js.map +1 -0
  194. package/lib/module/core/index.js +2 -1
  195. package/lib/module/core/index.js.map +1 -1
  196. package/lib/module/core/passForwardRef.js +2 -2
  197. package/lib/module/core/passForwardRef.js.map +1 -1
  198. package/lib/module/core/useProxifiedUnistyles/index.js +4 -0
  199. package/lib/module/core/useProxifiedUnistyles/index.js.map +1 -0
  200. package/lib/module/core/useProxifiedUnistyles/listener.js +17 -0
  201. package/lib/module/core/useProxifiedUnistyles/listener.js.map +1 -0
  202. package/lib/module/core/useProxifiedUnistyles/listener.native.js +21 -0
  203. package/lib/module/core/useProxifiedUnistyles/listener.native.js.map +1 -0
  204. package/lib/module/core/useProxifiedUnistyles/types.js +4 -0
  205. package/lib/module/core/useProxifiedUnistyles/types.js.map +1 -0
  206. package/lib/module/core/{withUnistyles/useDependencies.js → useProxifiedUnistyles/useProxifiedUnistyles.js} +19 -19
  207. package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -0
  208. package/lib/module/core/useUnistyles.js +14 -0
  209. package/lib/module/core/useUnistyles.js.map +1 -0
  210. package/lib/module/core/warn.js +11 -0
  211. package/lib/module/core/warn.js.map +1 -0
  212. package/lib/module/core/withUnistyles/withUnistyles.js +19 -55
  213. package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
  214. package/lib/module/core/withUnistyles/withUnistyles.native.js +33 -66
  215. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
  216. package/lib/module/index.js +3 -2
  217. package/lib/module/index.js.map +1 -1
  218. package/lib/module/server/getServerUnistyles.js +34 -0
  219. package/lib/module/server/getServerUnistyles.js.map +1 -0
  220. package/lib/module/server/hydrateServerUnistyles.js +12 -0
  221. package/lib/module/server/hydrateServerUnistyles.js.map +1 -0
  222. package/lib/module/server/index.js +7 -0
  223. package/lib/module/server/index.js.map +1 -0
  224. package/lib/module/server/resetServerUnistyles.js +11 -0
  225. package/lib/module/server/resetServerUnistyles.js.map +1 -0
  226. package/lib/module/server/types.js +4 -0
  227. package/lib/module/server/types.js.map +1 -0
  228. package/lib/module/server/useServerUnistyles.js +22 -0
  229. package/lib/module/server/useServerUnistyles.js.map +1 -0
  230. package/lib/module/specs/ShadowRegistry/index.js +6 -3
  231. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  232. package/lib/module/specs/StyleSheet/index.js.map +1 -1
  233. package/lib/module/utils.js +16 -1
  234. package/lib/module/utils.js.map +1 -1
  235. package/lib/module/web/convert/object/filter.js +2 -2
  236. package/lib/module/web/convert/object/filter.js.map +1 -1
  237. package/lib/module/web/convert/style.js +4 -4
  238. package/lib/module/web/convert/style.js.map +1 -1
  239. package/lib/module/web/create.js +20 -15
  240. package/lib/module/web/create.js.map +1 -1
  241. package/lib/module/web/css/core.js +50 -0
  242. package/lib/module/web/css/core.js.map +1 -0
  243. package/lib/module/web/css/index.js +4 -0
  244. package/lib/module/web/css/index.js.map +1 -0
  245. package/lib/module/web/css/state.js +150 -0
  246. package/lib/module/web/css/state.js.map +1 -0
  247. package/lib/module/web/css/utils.js +41 -0
  248. package/lib/module/web/css/utils.js.map +1 -0
  249. package/lib/module/web/index.js +10 -5
  250. package/lib/module/web/index.js.map +1 -1
  251. package/lib/module/web/listener.js +8 -7
  252. package/lib/module/web/listener.js.map +1 -1
  253. package/lib/module/web/registry.js +44 -124
  254. package/lib/module/web/registry.js.map +1 -1
  255. package/lib/module/web/runtime.js +27 -21
  256. package/lib/module/web/runtime.js.map +1 -1
  257. package/lib/module/web/services.js +23 -0
  258. package/lib/module/web/services.js.map +1 -0
  259. package/lib/module/web/shadowRegistry.js +46 -94
  260. package/lib/module/web/shadowRegistry.js.map +1 -1
  261. package/lib/module/web/state.js +39 -10
  262. package/lib/module/web/state.js.map +1 -1
  263. package/lib/module/web/types.js +4 -0
  264. package/lib/module/web/types.js.map +1 -0
  265. package/lib/module/web/utils/common.js +26 -7
  266. package/lib/module/web/utils/common.js.map +1 -1
  267. package/lib/module/web/utils/unistyle.js +31 -17
  268. package/lib/module/web/utils/unistyle.js.map +1 -1
  269. package/lib/module/web/variants.js +25 -27
  270. package/lib/module/web/variants.js.map +1 -1
  271. package/lib/typescript/src/components/index.d.ts +0 -1
  272. package/lib/typescript/src/components/index.d.ts.map +1 -1
  273. package/lib/typescript/src/components/native/ActivityIndicator.d.ts +1 -1
  274. package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -1
  275. package/lib/typescript/src/components/native/Animated.d.ts +39 -0
  276. package/lib/typescript/src/components/native/Animated.d.ts.map +1 -0
  277. package/lib/typescript/src/components/native/FlatList.d.ts +1 -1
  278. package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -1
  279. package/lib/typescript/src/components/native/Image.d.ts +1 -1
  280. package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
  281. package/lib/typescript/src/components/native/ImageBackground.d.ts +1 -2
  282. package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
  283. package/lib/typescript/src/components/native/ImageBackground.native.d.ts +2 -0
  284. package/lib/typescript/src/components/native/ImageBackground.native.d.ts.map +1 -0
  285. package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts +1 -1
  286. package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -1
  287. package/lib/typescript/src/components/native/NativeText.d.ts +2 -0
  288. package/lib/typescript/src/components/native/NativeText.d.ts.map +1 -0
  289. package/lib/typescript/src/components/native/NativeText.native.d.ts +2 -0
  290. package/lib/typescript/src/components/native/NativeText.native.d.ts.map +1 -0
  291. package/lib/typescript/src/components/native/NativeView.d.ts +3 -0
  292. package/lib/typescript/src/components/native/NativeView.d.ts.map +1 -0
  293. package/lib/typescript/src/components/native/NativeView.native.d.ts +3 -0
  294. package/lib/typescript/src/components/native/NativeView.native.d.ts.map +1 -0
  295. package/lib/typescript/src/components/native/Pressable.d.ts +3 -2
  296. package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -1
  297. package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
  298. package/lib/typescript/src/components/native/RefreshControl.d.ts +1 -1
  299. package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -1
  300. package/lib/typescript/src/components/native/ScrollView.d.ts +1 -1
  301. package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -1
  302. package/lib/typescript/src/components/native/SectionList.d.ts +1 -1
  303. package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -1
  304. package/lib/typescript/src/components/native/Switch.d.ts +1 -1
  305. package/lib/typescript/src/components/native/Switch.d.ts.map +1 -1
  306. package/lib/typescript/src/components/native/Text.d.ts +1 -1
  307. package/lib/typescript/src/components/native/Text.d.ts.map +1 -1
  308. package/lib/typescript/src/components/native/TextInput.d.ts +1 -1
  309. package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -1
  310. package/lib/typescript/src/components/native/TouchableHighlight.d.ts +1 -1
  311. package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -1
  312. package/lib/typescript/src/components/native/TouchableOpacity.d.ts +1 -1
  313. package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -1
  314. package/lib/typescript/src/components/native/View.d.ts +1 -1
  315. package/lib/typescript/src/components/native/View.d.ts.map +1 -1
  316. package/lib/typescript/src/components/native/VirtualizedList.d.ts +1 -1
  317. package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -1
  318. package/lib/typescript/src/core/createUnistylesElement.d.ts +1 -2
  319. package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
  320. package/lib/typescript/src/core/createUnistylesElement.native.d.ts +2 -0
  321. package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -0
  322. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts +2 -3
  323. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
  324. package/lib/typescript/src/core/getClassname.d.ts +7 -0
  325. package/lib/typescript/src/core/getClassname.d.ts.map +1 -0
  326. package/lib/typescript/src/core/getClassname.native.d.ts +2 -0
  327. package/lib/typescript/src/core/getClassname.native.d.ts.map +1 -0
  328. package/lib/typescript/src/core/index.d.ts +2 -1
  329. package/lib/typescript/src/core/index.d.ts.map +1 -1
  330. package/lib/typescript/src/core/passForwardRef.d.ts.map +1 -1
  331. package/lib/typescript/src/core/useProxifiedUnistyles/index.d.ts +2 -0
  332. package/lib/typescript/src/core/useProxifiedUnistyles/index.d.ts.map +1 -0
  333. package/lib/typescript/src/core/useProxifiedUnistyles/listener.d.ts +3 -0
  334. package/lib/typescript/src/core/useProxifiedUnistyles/listener.d.ts.map +1 -0
  335. package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts +3 -0
  336. package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts.map +1 -0
  337. package/lib/typescript/src/core/useProxifiedUnistyles/types.d.ts +7 -0
  338. package/lib/typescript/src/core/useProxifiedUnistyles/types.d.ts.map +1 -0
  339. package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts +8 -0
  340. package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -0
  341. package/lib/typescript/src/core/useUnistyles.d.ts +6 -0
  342. package/lib/typescript/src/core/useUnistyles.d.ts.map +1 -0
  343. package/lib/typescript/src/core/warn.d.ts +3 -0
  344. package/lib/typescript/src/core/warn.d.ts.map +1 -0
  345. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts +0 -3
  346. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
  347. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
  348. package/lib/typescript/src/index.d.ts +3 -2
  349. package/lib/typescript/src/index.d.ts.map +1 -1
  350. package/lib/typescript/src/server/getServerUnistyles.d.ts +4 -0
  351. package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -0
  352. package/lib/typescript/src/server/hydrateServerUnistyles.d.ts +8 -0
  353. package/lib/typescript/src/server/hydrateServerUnistyles.d.ts.map +1 -0
  354. package/lib/typescript/src/server/index.d.ts +5 -0
  355. package/lib/typescript/src/server/index.d.ts.map +1 -0
  356. package/lib/typescript/src/server/resetServerUnistyles.d.ts +2 -0
  357. package/lib/typescript/src/server/resetServerUnistyles.d.ts.map +1 -0
  358. package/lib/typescript/src/server/types.d.ts +5 -0
  359. package/lib/typescript/src/server/types.d.ts.map +1 -0
  360. package/lib/typescript/src/server/useServerUnistyles.d.ts +4 -0
  361. package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -0
  362. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +0 -3
  363. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  364. package/lib/typescript/src/specs/StyleSheet/index.d.ts +5 -1
  365. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  366. package/lib/typescript/src/utils.d.ts +2 -0
  367. package/lib/typescript/src/utils.d.ts.map +1 -1
  368. package/lib/typescript/src/web/convert/style.d.ts.map +1 -1
  369. package/lib/typescript/src/web/create.d.ts.map +1 -1
  370. package/lib/typescript/src/web/css/core.d.ts +3 -0
  371. package/lib/typescript/src/web/css/core.d.ts.map +1 -0
  372. package/lib/typescript/src/web/css/index.d.ts +2 -0
  373. package/lib/typescript/src/web/css/index.d.ts.map +1 -0
  374. package/lib/typescript/src/web/css/state.d.ts +30 -0
  375. package/lib/typescript/src/web/css/state.d.ts.map +1 -0
  376. package/lib/typescript/src/web/css/utils.d.ts +4 -0
  377. package/lib/typescript/src/web/css/utils.d.ts.map +1 -0
  378. package/lib/typescript/src/web/index.d.ts +7 -1
  379. package/lib/typescript/src/web/index.d.ts.map +1 -1
  380. package/lib/typescript/src/web/listener.d.ts +4 -3
  381. package/lib/typescript/src/web/listener.d.ts.map +1 -1
  382. package/lib/typescript/src/web/registry.d.ts +11 -8
  383. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  384. package/lib/typescript/src/web/runtime.d.ts +6 -4
  385. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  386. package/lib/typescript/src/web/services.d.ts +15 -0
  387. package/lib/typescript/src/web/services.d.ts.map +1 -0
  388. package/lib/typescript/src/web/shadowRegistry.d.ts +10 -13
  389. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  390. package/lib/typescript/src/web/state.d.ts +7 -3
  391. package/lib/typescript/src/web/state.d.ts.map +1 -1
  392. package/lib/typescript/src/web/types.d.ts +13 -0
  393. package/lib/typescript/src/web/types.d.ts.map +1 -0
  394. package/lib/typescript/src/web/utils/common.d.ts +2 -1
  395. package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
  396. package/lib/typescript/src/web/utils/unistyle.d.ts +5 -4
  397. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  398. package/lib/typescript/src/web/variants.d.ts +2 -2
  399. package/lib/typescript/src/web/variants.d.ts.map +1 -1
  400. package/nitrogen/generated/android/c++/JColorScheme.hpp +2 -1
  401. package/nitrogen/generated/android/c++/JDimensions.hpp +2 -1
  402. package/nitrogen/generated/android/c++/JFunc_void_UnistylesNativeMiniRuntime.hpp +36 -10
  403. package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.hpp +53 -19
  404. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +5 -5
  405. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +1 -1
  406. package/nitrogen/generated/android/c++/JInsets.hpp +2 -1
  407. package/nitrogen/generated/android/c++/JOrientation.hpp +2 -1
  408. package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +2 -1
  409. package/nitrogen/generated/android/c++/JUnistylesNativeMiniRuntime.hpp +2 -1
  410. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/ColorScheme.kt +1 -1
  411. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Dimensions.kt +10 -5
  412. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_UnistylesNativeMiniRuntime.kt +43 -14
  413. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.kt +43 -14
  414. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +10 -10
  415. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Insets.kt +13 -8
  416. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Orientation.kt +1 -1
  417. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistyleDependency.kt +1 -1
  418. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +19 -14
  419. package/nitrogen/generated/android/unistyles+autolinking.cmake +4 -1
  420. package/nitrogen/generated/android/unistyles+autolinking.gradle +1 -1
  421. package/nitrogen/generated/android/unistylesOnLoad.cpp +7 -3
  422. package/nitrogen/generated/android/unistylesOnLoad.hpp +1 -1
  423. package/nitrogen/generated/ios/Unistyles+autolinking.rb +1 -1
  424. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +21 -6
  425. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +105 -27
  426. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +5 -3
  427. package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.cpp +1 -1
  428. package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +92 -33
  429. package/nitrogen/generated/ios/swift/ColorScheme.swift +1 -1
  430. package/nitrogen/generated/ios/swift/Dimensions.swift +1 -1
  431. package/nitrogen/generated/ios/swift/Func_void_UnistylesNativeMiniRuntime.swift +46 -0
  432. package/nitrogen/generated/ios/swift/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.swift +46 -0
  433. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +36 -23
  434. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec_cxx.swift +327 -0
  435. package/nitrogen/generated/ios/swift/Insets.swift +1 -1
  436. package/nitrogen/generated/ios/swift/Orientation.swift +1 -1
  437. package/nitrogen/generated/ios/swift/UnistyleDependency.swift +1 -1
  438. package/nitrogen/generated/ios/swift/UnistylesNativeMiniRuntime.swift +1 -1
  439. package/nitrogen/generated/shared/c++/ColorScheme.hpp +1 -1
  440. package/nitrogen/generated/shared/c++/Dimensions.hpp +1 -1
  441. package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.cpp +1 -1
  442. package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +1 -1
  443. package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.cpp +1 -1
  444. package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +1 -1
  445. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.cpp +1 -1
  446. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +1 -1
  447. package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.cpp +1 -1
  448. package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +1 -1
  449. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.cpp +1 -1
  450. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +1 -1
  451. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -1
  452. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +1 -1
  453. package/nitrogen/generated/shared/c++/Insets.hpp +1 -1
  454. package/nitrogen/generated/shared/c++/Orientation.hpp +1 -1
  455. package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +2 -2
  456. package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +1 -1
  457. package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +1 -1
  458. package/package.json +23 -14
  459. package/plugin/consts.js +63 -0
  460. package/plugin/exotic.js +54 -0
  461. package/plugin/import.js +1 -21
  462. package/plugin/index.d.ts +89 -0
  463. package/plugin/index.js +58 -96
  464. package/plugin/stylesheet.js +28 -1
  465. package/plugin/variants.js +49 -75
  466. package/src/components/ScopedTheme.tsx +1 -1
  467. package/src/components/index.ts +0 -1
  468. package/src/components/native/Animated.tsx +17 -0
  469. package/src/components/native/ImageBackground.native.tsx +4 -0
  470. package/src/components/native/ImageBackground.tsx +57 -2
  471. package/src/components/native/NativeText.native.tsx +12 -0
  472. package/src/components/native/NativeText.tsx +1 -0
  473. package/src/components/native/NativeView.native.tsx +13 -0
  474. package/src/components/native/NativeView.tsx +3 -0
  475. package/src/components/native/Pressable.native.tsx +32 -15
  476. package/src/components/native/Pressable.tsx +35 -69
  477. package/src/core/createUnistylesElement.native.tsx +51 -0
  478. package/src/core/createUnistylesElement.tsx +47 -8
  479. package/src/core/createUnistylesImageBackground.tsx +44 -18
  480. package/src/core/getClassname.native.ts +1 -0
  481. package/src/core/getClassname.ts +14 -0
  482. package/src/core/index.ts +2 -1
  483. package/src/core/passForwardRef.ts +1 -2
  484. package/src/core/useProxifiedUnistyles/index.ts +1 -0
  485. package/src/core/useProxifiedUnistyles/listener.native.ts +18 -0
  486. package/src/core/useProxifiedUnistyles/listener.ts +13 -0
  487. package/src/core/useProxifiedUnistyles/types.ts +7 -0
  488. package/src/core/{withUnistyles/useDependencies.ts → useProxifiedUnistyles/useProxifiedUnistyles.ts} +19 -26
  489. package/src/core/useUnistyles.ts +11 -0
  490. package/src/core/warn.ts +13 -0
  491. package/src/core/withUnistyles/withUnistyles.native.tsx +39 -68
  492. package/src/core/withUnistyles/withUnistyles.tsx +19 -56
  493. package/src/index.ts +3 -2
  494. package/src/server/getServerUnistyles.tsx +21 -0
  495. package/src/server/hydrateServerUnistyles.ts +17 -0
  496. package/src/server/index.ts +5 -0
  497. package/src/server/resetServerUnistyles.ts +9 -0
  498. package/src/server/types.ts +4 -0
  499. package/src/server/useServerUnistyles.tsx +22 -0
  500. package/src/specs/ShadowRegistry/index.ts +12 -9
  501. package/src/specs/StyleSheet/index.ts +6 -1
  502. package/src/utils.ts +32 -11
  503. package/src/web/convert/object/filter.ts +2 -2
  504. package/src/web/convert/style.ts +8 -7
  505. package/src/web/create.ts +23 -18
  506. package/src/web/css/core.ts +58 -0
  507. package/src/web/css/index.ts +1 -0
  508. package/src/web/css/state.ts +191 -0
  509. package/src/web/css/utils.ts +54 -0
  510. package/src/web/index.ts +18 -5
  511. package/src/web/listener.ts +8 -8
  512. package/src/web/registry.ts +47 -152
  513. package/src/web/runtime.ts +32 -22
  514. package/src/web/services.ts +28 -0
  515. package/src/web/shadowRegistry.ts +46 -104
  516. package/src/web/state.ts +46 -11
  517. package/src/web/types.ts +13 -0
  518. package/src/web/utils/common.ts +32 -8
  519. package/src/web/utils/unistyle.ts +46 -25
  520. package/src/web/variants.ts +27 -27
  521. package/cxx/core/HostStyle.cpp +0 -73
  522. package/cxx/core/HostStyle.h +0 -34
  523. package/lib/commonjs/components/Variants.js +0 -36
  524. package/lib/commonjs/components/Variants.js.map +0 -1
  525. package/lib/commonjs/core/createUnistylesComponent.js +0 -16
  526. package/lib/commonjs/core/createUnistylesComponent.js.map +0 -1
  527. package/lib/commonjs/core/withUnistyles/useDependencies.js.map +0 -1
  528. package/lib/module/components/Variants.js +0 -29
  529. package/lib/module/components/Variants.js.map +0 -1
  530. package/lib/module/core/createUnistylesComponent.js +0 -11
  531. package/lib/module/core/createUnistylesComponent.js.map +0 -1
  532. package/lib/module/core/withUnistyles/useDependencies.js.map +0 -1
  533. package/lib/typescript/src/components/Variants.d.ts +0 -7
  534. package/lib/typescript/src/components/Variants.d.ts.map +0 -1
  535. package/lib/typescript/src/core/createUnistylesComponent.d.ts +0 -14
  536. package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +0 -1
  537. package/lib/typescript/src/core/withUnistyles/useDependencies.d.ts +0 -13
  538. package/lib/typescript/src/core/withUnistyles/useDependencies.d.ts.map +0 -1
  539. package/nitrogen/generated/android/unistylesOnLoad.kt +0 -1
  540. package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +0 -314
  541. package/plugin/style.js +0 -168
  542. package/src/components/Variants.tsx +0 -30
  543. package/src/core/createUnistylesComponent.tsx +0 -14
@@ -2,7 +2,7 @@
2
2
  /// HybridUnistylesStyleSheetSpec.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2024 Marc Rousavy @ Margelo
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -2,7 +2,7 @@
2
2
  /// Insets.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2024 Marc Rousavy @ Margelo
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -2,7 +2,7 @@
2
2
  /// Orientation.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2024 Marc Rousavy @ Margelo
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -2,7 +2,7 @@
2
2
  /// UnistyleDependency.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2024 Marc Rousavy @ Margelo
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -59,7 +59,7 @@ namespace margelo::nitro {
59
59
  int enumValue = static_cast<int>(arg);
60
60
  return JSIConverter<int>::toJSI(runtime, enumValue);
61
61
  }
62
- static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
62
+ static inline bool canConvert(jsi::Runtime&, const jsi::Value& value) {
63
63
  if (!value.isNumber()) {
64
64
  return false;
65
65
  }
@@ -2,7 +2,7 @@
2
2
  /// UnistylesCxxMiniRuntime.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2024 Marc Rousavy @ Margelo
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
@@ -2,7 +2,7 @@
2
2
  /// UnistylesNativeMiniRuntime.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
- /// Copyright © 2024 Marc Rousavy @ Margelo
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.0.0-beta.4",
3
+ "version": "3.0.0-beta.6",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -11,15 +11,15 @@
11
11
  "precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn test'",
12
12
  "release": "release-it"
13
13
  },
14
- "main": "lib/commonjs/index",
15
- "module": "lib/module/index",
14
+ "main": "lib/commonjs/index.js",
15
+ "module": "lib/module/index.js",
16
16
  "types": "lib/typescript/src/index.d.ts",
17
17
  "source": "src/index",
18
18
  "exports": {
19
19
  ".": {
20
20
  "types": "./lib/typescript/src/index.d.ts",
21
- "module": "./lib/module/index",
22
- "default": "./lib/commonjs/index",
21
+ "module": "./lib/module/index.js",
22
+ "default": "./lib/commonjs/index.js",
23
23
  "react-native": "./src/index"
24
24
  },
25
25
  "./components/native/*": {
@@ -31,7 +31,13 @@
31
31
  "module": "./plugin/index.js",
32
32
  "default": "./plugin/index.js"
33
33
  },
34
- "./package.json": "./package.json"
34
+ "./package.json": "./package.json",
35
+ "./server": {
36
+ "types": "./lib/typescript/src/server/index.d.ts",
37
+ "module": "./lib/module/server/index.js",
38
+ "default": "./lib/commonjs/server/index.js",
39
+ "react-native": "./src/server"
40
+ }
35
41
  },
36
42
  "files": [
37
43
  "src",
@@ -76,27 +82,29 @@
76
82
  },
77
83
  "devDependencies": {
78
84
  "@babel/plugin-syntax-jsx": "7.25.9",
85
+ "@babel/preset-flow": "7.25.9",
86
+ "@babel/preset-typescript": "7.26.0",
79
87
  "@biomejs/biome": "1.9.4",
80
88
  "@commitlint/config-conventional": "19.6.0",
81
- "@react-native/normalize-colors": "0.76.3",
89
+ "@react-native/normalize-colors": "0.77.0",
82
90
  "@release-it/conventional-changelog": "8.0.2",
83
91
  "@types/jest": "29.5.14",
84
92
  "@types/react": "18.3.12",
85
93
  "babel-plugin-tester": "11.0.4",
86
- "commitlint": "19.6.0",
87
- "concurrently": "9.1.0",
94
+ "commitlint": "19.6.1",
95
+ "concurrently": "9.1.2",
88
96
  "husky": "9.1.7",
89
97
  "jest": "29.7.0",
90
98
  "metro-react-native-babel-preset": "0.77.0",
91
- "nitro-codegen": "0.18.2",
99
+ "nitro-codegen": "0.21.0",
92
100
  "react": "18.3.1",
93
- "react-native": "0.76.3",
101
+ "react-native": "0.77.0",
94
102
  "react-native-builder-bob": "0.33.1",
95
- "react-native-nitro-modules": "0.18.2",
103
+ "react-native-nitro-modules": "0.21.0",
96
104
  "react-native-web": "0.19.13",
97
105
  "react-test-renderer": "18.3.1",
98
106
  "release-it": "17.6.0",
99
- "typescript": "5.7.2"
107
+ "typescript": "5.7.3"
100
108
  },
101
109
  "peerDependencies": {
102
110
  "@react-native/normalize-colors": "*",
@@ -107,7 +115,8 @@
107
115
  },
108
116
  "workspaces": [
109
117
  "example",
110
- "docs"
118
+ "docs",
119
+ "expo-example"
111
120
  ],
112
121
  "packageManager": "yarn@3.6.1",
113
122
  "engines": {
@@ -0,0 +1,63 @@
1
+ const REACT_NATIVE_COMPONENT_NAMES = [
2
+ 'ActivityIndicator',
3
+ 'View',
4
+ 'Text',
5
+ 'Image',
6
+ 'ImageBackground',
7
+ 'KeyboardAvoidingView',
8
+ 'Pressable',
9
+ 'ScrollView',
10
+ 'FlatList',
11
+ 'SectionList',
12
+ 'Switch',
13
+ 'TextInput',
14
+ 'RefreshControl',
15
+ 'TouchableHighlight',
16
+ 'TouchableOpacity',
17
+ 'VirtualizedList',
18
+ 'Animated'
19
+ // Modal - there is no exposed native handle
20
+ // TouchableWithoutFeedback - can't accept a ref
21
+ ]
22
+
23
+ // auto replace RN imports to Unistyles imports under these paths
24
+ // our implementation simply borrows 'ref' to register it in ShadowRegistry
25
+ // so we won't affect anyone's implementation
26
+ const REPLACE_WITH_UNISTYLES_PATHS = [
27
+ 'react-native-reanimated/src/component',
28
+ 'react-native-gesture-handler/src/components'
29
+ ]
30
+
31
+ // this is more powerful API as it allows to convert unmatched imports to Unistyles
32
+ // { path: string, imports: Array<{ name: string, isDefault: boolean, path: string, mapTo: string }> }
33
+ // path => node_modules path
34
+ // imports:
35
+ // name? <- target import name if isDefault is false
36
+ // isDefault <- is the import default?
37
+ // path <- path to the target import
38
+ // mapTo <- name of the Unistyles component
39
+ const REPLACE_WITH_UNISTYLES_EXOTIC_PATHS = []
40
+
41
+ // this list will additionally detect React Native direct imports
42
+ const NATIVE_COMPONENTS_PATHS = {
43
+ imports: [
44
+ {
45
+ name: 'NativeText',
46
+ isDefault: false,
47
+ path: 'react-native/Libraries/Text/TextNativeComponent',
48
+ mapTo: 'NativeText'
49
+ },
50
+ {
51
+ isDefault: true,
52
+ path: 'react-native/Libraries/Components/View/ViewNativeComponent',
53
+ mapTo: 'NativeView'
54
+ }
55
+ ]
56
+ }
57
+
58
+ module.exports = {
59
+ NATIVE_COMPONENTS_PATHS,
60
+ REACT_NATIVE_COMPONENT_NAMES,
61
+ REPLACE_WITH_UNISTYLES_PATHS,
62
+ REPLACE_WITH_UNISTYLES_EXOTIC_PATHS
63
+ }
@@ -0,0 +1,54 @@
1
+ function handleExoticImport(t, path, state, exoticImport) {
2
+ const specifiers = path.node.specifiers
3
+ const source = path.node.source
4
+
5
+ if (path.node.importKind !== 'value') {
6
+ return
7
+ }
8
+
9
+ specifiers.forEach(specifier => {
10
+ for (const rule of exoticImport.imports) {
11
+ const hasMatchingImportType = (!rule.isDefault && t.isImportSpecifier(specifier)) || (rule.isDefault && t.isImportDefaultSpecifier(specifier))
12
+ const hasMatchingImportName = rule.isDefault || (!rule.isDefault && rule.name === specifier.local.name)
13
+ const hasMatchingPath = rule.path === source.value
14
+
15
+ if (!hasMatchingImportType || !hasMatchingImportName || !hasMatchingPath) {
16
+ continue
17
+ }
18
+
19
+ if (t.isImportDefaultSpecifier(specifier)) {
20
+ const newImport = t.importDeclaration(
21
+ [t.importDefaultSpecifier(t.identifier(specifier.local.name))],
22
+ t.stringLiteral(state.opts.isLocal
23
+ ? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/components/native/${rule.mapTo}`)
24
+ : `react-native-unistyles/components/native/${rule.mapTo}`
25
+ )
26
+ )
27
+
28
+ path.replaceWith(newImport)
29
+ } else {
30
+ const newImport = t.importDeclaration(
31
+ [t.importSpecifier(t.identifier(rule.mapTo), t.identifier(rule.mapTo))],
32
+ t.stringLiteral(state.opts.isLocal
33
+ ? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/components/native/${rule.mapTo}`)
34
+ : `react-native-unistyles/components/native/${rule.mapTo}`
35
+ )
36
+ )
37
+
38
+ path.node.specifiers = specifiers.filter(s => s !== specifier)
39
+
40
+ if (path.node.specifiers.length === 0) {
41
+ path.replaceWith(newImport)
42
+ } else {
43
+ path.insertBefore(newImport)
44
+ }
45
+ }
46
+
47
+ return
48
+ }
49
+ })
50
+ }
51
+
52
+ module.exports = {
53
+ handleExoticImport
54
+ }
package/plugin/import.js CHANGED
@@ -1,3 +1,4 @@
1
+ /** @param {import('./index').UnistylesPluginPass} state */
1
2
  function addUnistylesImport(t, path, state) {
2
3
  const localNames = Object.keys(state.reactNativeImports)
3
4
  const names = Object.values(state.reactNativeImports)
@@ -38,27 +39,6 @@ function addUnistylesImport(t, path, state) {
38
39
  path.node.body.unshift(newImport)
39
40
  })
40
41
 
41
- // import variants
42
- if (state.file.hasVariants) {
43
- const unistylesImport = path.node.body
44
- .find(node => t.isImportDeclaration(node) && node.source.value === 'react-native-unistyles')
45
-
46
- if (unistylesImport) {
47
- // prevent duplications
48
- if (!unistylesImport.specifiers.some(specifier => specifier.local.name === 'Variants')) {
49
- unistylesImport.specifiers.push(t.importSpecifier(t.identifier('Variants'), t.identifier('Variants')))
50
- }
51
- } else {
52
- // Add a new import declaration for "Variants" from "react-native-unistyles"
53
- const newImport = t.importDeclaration(
54
- [t.importSpecifier(t.identifier('Variants'), t.identifier('Variants'))],
55
- t.stringLiteral('react-native-unistyles')
56
- )
57
-
58
- path.node.body.unshift(newImport)
59
- }
60
- }
61
-
62
42
  // cleanup
63
43
  nodesToRemove.forEach(node => path.node.body.splice(path.node.body.indexOf(node), 1))
64
44
  }
@@ -0,0 +1,89 @@
1
+ type RemapImport = {
2
+ name?: string,
3
+ isDefault: boolean,
4
+ path: string,
5
+ mapTo: string
6
+ }
7
+
8
+ type RemapConfig = {
9
+ path: string,
10
+ imports: Array<RemapImport>
11
+ }
12
+
13
+ export interface UnistylesPluginOptions {
14
+ /**
15
+ * Example: "src" or "apps/mobile"
16
+ * Add this option if some of your components don't have `react-native-unistyles` import.
17
+ * Babel plugin will automatically process all files under this root.
18
+ */
19
+ autoProcessRoot?: string,
20
+
21
+ /**
22
+ * Example: ['@codemask/styles']
23
+ * Enable this option if you want to process only files containing specific imports.
24
+ */
25
+ autoProcessImports?: Array<string>,
26
+
27
+ /**
28
+ * Example: [{
29
+ * path: "node_modules/custom-library/components",
30
+ * imports: [
31
+ * {
32
+ * name: "NativeText",
33
+ * isDefault: false,
34
+ * path: "react-native/Libraries/Text/TextNativeComponent",
35
+ * mapTo: "NativeText"
36
+ * },
37
+ * {
38
+ * isDefault: true,
39
+ * path: "react-native/Libraries/Components/View/ViewNativeComponent",
40
+ * mapTo: "NativeView"
41
+ * }
42
+ * ]
43
+ * }]
44
+ *
45
+ * Will map:
46
+ * import { NativeText } from "react-native/Libraries/Text/TextNativeComponent"
47
+ * to Unistyles "NativeText"
48
+ *
49
+ * import View from "react-native/Libraries/Components/View/ViewNativeComponent"
50
+ * to Unistyles "NativeView"
51
+ *
52
+ * This is the most powerful way of remapping imports. If 3rd party library uses imports different from `react-native` we can remap them to `react-native-unistyles` factories.
53
+ * Internally we do that for raw RCTView and RCTText components.
54
+ *
55
+ * path -> must be within node_modules folder
56
+ * imports.name is Optional if library used export default
57
+ * imports.mapTo - name of the component from react-native-unistyles/src/components/native
58
+ */
59
+ autoRemapImports?: Array<RemapConfig>,
60
+
61
+ /**
62
+ * Example: ['external-library/components']
63
+ * Enable this option to process some 3rd party components under `node_modules`.
64
+ * Under these paths we will replace `react-native` imports with `react-native-unistyles` factories that will borrow components refs [read more](https://www.unistyl.es/v3/other/babel-plugin#3-component-factory-borrowing-ref).
65
+ *
66
+ * Defaults to:
67
+ *
68
+ * ```ts
69
+ * ['react-native-reanimated/src/component', 'react-native-gesture-handler/src/components']
70
+ * ```
71
+ */
72
+ autoProcessPaths?: Array<string>,
73
+
74
+ /**
75
+ * In order to list detected dependencies by the Babel plugin you can enable the `debug` flag.
76
+ * It will `console.log` name of the file and component with Unistyles dependencies.
77
+ */
78
+ debug?: boolean,
79
+
80
+ /**
81
+ * Only applicable for Unistyles monorepo for
82
+ * path resolution, don't use it!
83
+ */
84
+ isLocal?: boolean
85
+ }
86
+
87
+ export interface UnistylesPluginPass {
88
+ opts: UnistylesPluginOptions
89
+ }
package/plugin/index.js CHANGED
@@ -1,57 +1,45 @@
1
1
  const { addUnistylesImport, isInsideNodeModules } = require('./import')
2
- const { getStyleMetadata, getStyleAttribute, styleAttributeToArray, handlePressable } = require('./style')
3
2
  const { hasStringRef } = require('./ref')
4
- const { isUnistylesStyleSheet, analyzeDependencies, addStyleSheetTag, getUnistyles } = require('./stylesheet')
5
- const { isUsingVariants, extractVariants, addJSXVariants } = require('./variants')
6
-
7
- const reactNativeComponentNames = [
8
- 'ActivityIndicator',
9
- 'View',
10
- 'Text',
11
- 'Image',
12
- 'ImageBackground',
13
- 'KeyboardAvoidingView',
14
- 'Pressable',
15
- 'ScrollView',
16
- 'FlatList',
17
- 'SectionList',
18
- 'Switch',
19
- 'TextInput',
20
- 'RefreshControl',
21
- 'TouchableHighlight',
22
- 'TouchableOpacity',
23
- 'VirtualizedList'
24
- ]
25
-
26
- // Modal - there is no exposed native handle
27
- // TouchableWithoutFeedback - can't accept a ref
3
+ const { isUnistylesStyleSheet, analyzeDependencies, addStyleSheetTag, getUnistyles, isKindOfStyleSheet, addThemeDependencyToMemberExpression } = require('./stylesheet')
4
+ const { extractVariants } = require('./variants')
5
+ const { REACT_NATIVE_COMPONENT_NAMES, REPLACE_WITH_UNISTYLES_PATHS, REPLACE_WITH_UNISTYLES_EXOTIC_PATHS, NATIVE_COMPONENTS_PATHS } = require('./consts')
6
+ const { handleExoticImport } = require('./exotic')
28
7
 
29
8
  module.exports = function ({ types: t }) {
30
9
  return {
31
10
  name: 'babel-react-native-unistyles',
32
11
  visitor: {
33
12
  Program: {
13
+ /** @param {import('./index').UnistylesPluginPass} state */
34
14
  enter(path, state) {
35
- if (isInsideNodeModules(state)) {
36
- return
37
- }
15
+ state.file.replaceWithUnistyles = REPLACE_WITH_UNISTYLES_PATHS
16
+ .concat(state.opts.autoProcessPaths ?? [])
17
+ .some(path => state.filename.includes(path))
38
18
 
39
19
  state.file.hasAnyUnistyle = false
40
- state.file.hasUnistylesImport = false
41
- state.file.shouldIncludePressable = false
42
20
  state.file.hasVariants = false
43
21
  state.file.styleSheetLocalName = ''
44
22
  state.file.tagNumber = 0
45
- state.file.isClassComponent = false
46
23
  state.reactNativeImports = {}
24
+ state.file.forceProcessing = state.opts.autoProcessRoot
25
+ ? state.filename.includes(`${state.file.opts.root}/${state.opts.autoProcessRoot}/`)
26
+ : false
47
27
  },
48
28
  exit(path, state) {
49
- if (state.file.hasAnyUnistyle || state.file.hasVariants) {
29
+ if (isInsideNodeModules(state) && !state.file.replaceWithUnistyles) {
30
+ return
31
+ }
32
+
33
+ if (state.file.hasAnyUnistyle || state.file.hasVariants || state.file.replaceWithUnistyles || state.file.forceProcessing) {
50
34
  addUnistylesImport(t, path, state)
51
35
  }
52
36
  }
53
37
  },
54
38
  FunctionDeclaration(path, state) {
39
+ if (isInsideNodeModules(state)) {
40
+ return
41
+ }
42
+
55
43
  const componentName = path.node.id
56
44
  ? path.node.id.name
57
45
  : null
@@ -61,13 +49,16 @@ module.exports = function ({ types: t }) {
61
49
  }
62
50
  },
63
51
  ClassDeclaration(path, state) {
52
+ if (isInsideNodeModules(state)) {
53
+ return
54
+ }
55
+
64
56
  const componentName = path.node.id
65
57
  ? path.node.id.name
66
58
  : null
67
59
 
68
60
  if (componentName) {
69
61
  state.file.hasVariants = false
70
- state.file.isClassComponent = true
71
62
  }
72
63
  },
73
64
  VariableDeclaration(path, state) {
@@ -87,16 +78,23 @@ module.exports = function ({ types: t }) {
87
78
  }
88
79
  })
89
80
  },
81
+ /** @param {import('./index').UnistylesPluginPass} state */
90
82
  ImportDeclaration(path, state) {
91
- if (isInsideNodeModules(state)) {
83
+ const exoticImport = REPLACE_WITH_UNISTYLES_EXOTIC_PATHS
84
+ .concat(state.opts.autoRemapImports ?? [])
85
+ .find(exotic => state.filename.includes(exotic.path))
86
+
87
+ if (exoticImport) {
88
+ return handleExoticImport(t, path, state, exoticImport)
89
+ }
90
+
91
+ if (isInsideNodeModules(state) && !state.file.replaceWithUnistyles) {
92
92
  return
93
93
  }
94
94
 
95
95
  const importSource = path.node.source.value
96
96
 
97
97
  if (importSource.includes('react-native-unistyles')) {
98
- state.file.hasUnistylesImport = true
99
-
100
98
  path.node.specifiers.forEach(specifier => {
101
99
  if (specifier.imported && specifier.imported.name === 'StyleSheet') {
102
100
  state.file.styleSheetLocalName = specifier.local.name
@@ -104,20 +102,20 @@ module.exports = function ({ types: t }) {
104
102
  })
105
103
  }
106
104
 
107
- if (importSource.includes('react-native')) {
105
+ if (importSource === 'react-native') {
108
106
  path.node.specifiers.forEach(specifier => {
109
- if (specifier.imported && specifier.imported.name === 'Pressable' && specifier.local.name !== 'NativePressableReactNative') {
110
- state.file.shouldIncludePressable = true
111
- }
112
-
113
- if (specifier.imported && reactNativeComponentNames.includes(specifier.imported.name)) {
107
+ if (specifier.imported && REACT_NATIVE_COMPONENT_NAMES.includes(specifier.imported.name)) {
114
108
  state.reactNativeImports[specifier.local.name] = specifier.imported.name
115
109
  }
116
110
  })
117
111
  }
118
112
 
119
- if (importSource.includes('react-native-web/dist/exports/Pressable')) {
120
- state.file.shouldIncludePressable = true
113
+ if (importSource.includes('react-native/Libraries')) {
114
+ handleExoticImport(t, path, state, NATIVE_COMPONENTS_PATHS)
115
+ }
116
+
117
+ if (!state.file.forceProcessing && Array.isArray(state.opts.autoProcessImports)) {
118
+ state.file.forceProcessing = state.opts.autoProcessImports.includes(importSource)
121
119
  }
122
120
  },
123
121
  JSXElement(path, state) {
@@ -125,63 +123,28 @@ module.exports = function ({ types: t }) {
125
123
  return
126
124
  }
127
125
 
128
- if (state.file.isClassComponent) {
129
- return
130
- }
131
-
132
- const openingElement = path.node.openingElement
133
- const openingElementName = openingElement.name.name
134
- const isReactNativeComponent = Boolean(state.reactNativeImports[openingElementName])
135
- const isAnimatedComponent = (
136
- !isReactNativeComponent &&
137
- openingElement.name.object &&
138
- openingElement.name.object.name === 'Animated'
139
- )
140
-
141
- if (!isReactNativeComponent && !isAnimatedComponent) {
142
- return
143
- }
144
-
145
- const styleAttr = getStyleAttribute(t, path)
146
-
147
- // component has no style prop
148
- if (!styleAttr) {
149
- return
150
- }
151
-
152
- const metadata = getStyleMetadata(t, styleAttr.value.expression, null, state)
153
-
154
- if (openingElementName === 'Pressable') {
155
- return handlePressable(t, path, styleAttr, metadata, state)
156
- }
157
-
158
- // style prop is using unexpected expression
159
- if (metadata.length === 0) {
160
- return
161
- }
162
-
163
- styleAttributeToArray(t, path)
164
-
165
- // to add import
166
- state.file.hasAnyUnistyle = true
167
-
168
126
  if (hasStringRef(t, path)) {
169
127
  throw new Error("Detected string based ref which is not supported by Unistyles.")
170
128
  }
171
129
  },
172
- CallExpression(path, state) {
130
+ BlockStatement(path, state) {
173
131
  if (isInsideNodeModules(state)) {
174
132
  return
175
133
  }
176
134
 
177
- if (isUsingVariants(t, path)) {
178
- extractVariants(t, path, state)
135
+ extractVariants(t, path, state)
136
+ },
137
+ CallExpression(path, state) {
138
+ if (isInsideNodeModules(state)) {
139
+ return
179
140
  }
180
141
 
181
- if (!isUnistylesStyleSheet(t, path, state)) {
142
+ if (!isUnistylesStyleSheet(t, path, state) && !isKindOfStyleSheet(t, path, state)) {
182
143
  return
183
144
  }
184
145
 
146
+ state.file.hasAnyUnistyle = true
147
+
185
148
  addStyleSheetTag(t, path, state)
186
149
 
187
150
  const arg = path.node.arguments[0]
@@ -220,6 +183,13 @@ module.exports = function ({ types: t }) {
220
183
  if (t.isObjectProperty(property)) {
221
184
  const propertyValues = getUnistyles(t, property)
222
185
 
186
+ // maybe user used inlined theme? ({ container: theme.components.container })
187
+ if (propertyValues.length === 0 && t.isMemberExpression(property.value)) {
188
+ if (property.value.object.object.name === themeLocalName) {
189
+ addThemeDependencyToMemberExpression(t, property)
190
+ }
191
+ }
192
+
223
193
  propertyValues.forEach(propertyValue => {
224
194
  analyzeDependencies(t, state, property.key.name, propertyValue, themeLocalName, miniRuntimeLocalName)
225
195
  })
@@ -227,14 +197,6 @@ module.exports = function ({ types: t }) {
227
197
  })
228
198
  }
229
199
  }
230
- },
231
- ReturnStatement(path, state) {
232
- // ignore nested returns in JSX elements
233
- const hasJSXParent = path.findParent(p => p.isJSXElement())
234
-
235
- if (!hasJSXParent && state.file.hasVariants) {
236
- addJSXVariants(t, path, state)
237
- }
238
200
  }
239
201
  }
240
202
  }