react-native-unistyles 3.5.3 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) hide show
  1. package/README.md +6 -8
  2. package/android/build.gradle +42 -0
  3. package/android/src/legacy/java/com/unistyles/NativePlatform+extraWindows.kt +16 -0
  4. package/android/src/main/cxx/NativeUnistylesModule.cpp +5 -11
  5. package/android/src/main/cxx/NativeUnistylesModule.h +0 -4
  6. package/android/src/main/java/com/unistyles/NativePlatform+android.kt +82 -39
  7. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +73 -0
  8. package/android/src/main/java/com/unistyles/UnistylesModule.kt +2 -13
  9. package/android/src/rn86/java/com/unistyles/NativePlatform+extraWindows.kt +28 -0
  10. package/cxx/common/PerformanceTracing.h +85 -0
  11. package/cxx/converters/BackgroundImageConverter.cpp +198 -11
  12. package/cxx/converters/BackgroundImageConverter.h +1 -0
  13. package/cxx/converters/BackgroundLayerConverter.cpp +523 -0
  14. package/cxx/converters/BackgroundLayerConverter.h +14 -0
  15. package/cxx/converters/FontVariationSettingsConverter.cpp +104 -0
  16. package/cxx/converters/FontVariationSettingsConverter.h +17 -0
  17. package/cxx/core/HostUnistyle.cpp +6 -0
  18. package/cxx/core/UnistyleWrapper.h +16 -1
  19. package/cxx/hybridObjects/HybridShadowRegistry.cpp +13 -0
  20. package/cxx/hybridObjects/HybridStyleSheet.cpp +11 -0
  21. package/cxx/hybridObjects/HybridStyleSheet.h +1 -0
  22. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +10 -30
  23. package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -2
  24. package/cxx/parser/Parser.cpp +92 -5
  25. package/cxx/shadowTree/ShadowTreeDiagnostics.cpp +74 -0
  26. package/cxx/shadowTree/ShadowTreeManager.cpp +3 -0
  27. package/ios/NativePlatform+ios.swift +22 -11
  28. package/ios/NativePlatformListener+ios.swift +9 -0
  29. package/lib/commonjs/components/NamedTheme.js +4 -4
  30. package/lib/commonjs/components/NamedTheme.js.map +1 -1
  31. package/lib/commonjs/components/ScopedThemeContext.js +3 -1
  32. package/lib/commonjs/components/ScopedThemeContext.js.map +1 -1
  33. package/lib/commonjs/components/native/deep/ActivityIndicator.js +19 -0
  34. package/lib/commonjs/components/native/deep/ActivityIndicator.js.map +1 -0
  35. package/lib/commonjs/components/native/deep/Animated.js +19 -0
  36. package/lib/commonjs/components/native/deep/Animated.js.map +1 -0
  37. package/lib/commonjs/components/native/deep/FlatList.js +19 -0
  38. package/lib/commonjs/components/native/deep/FlatList.js.map +1 -0
  39. package/lib/commonjs/components/native/deep/Image.js +19 -0
  40. package/lib/commonjs/components/native/deep/Image.js.map +1 -0
  41. package/lib/commonjs/components/native/deep/ImageBackground.js +19 -0
  42. package/lib/commonjs/components/native/deep/ImageBackground.js.map +1 -0
  43. package/lib/commonjs/components/native/deep/KeyboardAvoidingView.js +19 -0
  44. package/lib/commonjs/components/native/deep/KeyboardAvoidingView.js.map +1 -0
  45. package/lib/commonjs/components/native/deep/Pressable.js +19 -0
  46. package/lib/commonjs/components/native/deep/Pressable.js.map +1 -0
  47. package/lib/commonjs/components/native/deep/RefreshControl.js +19 -0
  48. package/lib/commonjs/components/native/deep/RefreshControl.js.map +1 -0
  49. package/lib/commonjs/components/native/deep/SafeAreaView.js +19 -0
  50. package/lib/commonjs/components/native/deep/SafeAreaView.js.map +1 -0
  51. package/lib/commonjs/components/native/deep/ScrollView.js +19 -0
  52. package/lib/commonjs/components/native/deep/ScrollView.js.map +1 -0
  53. package/lib/commonjs/components/native/deep/SectionList.js +19 -0
  54. package/lib/commonjs/components/native/deep/SectionList.js.map +1 -0
  55. package/lib/commonjs/components/native/deep/Switch.js +19 -0
  56. package/lib/commonjs/components/native/deep/Switch.js.map +1 -0
  57. package/lib/commonjs/components/native/deep/Text.js +19 -0
  58. package/lib/commonjs/components/native/deep/Text.js.map +1 -0
  59. package/lib/commonjs/components/native/deep/TextInput.js +19 -0
  60. package/lib/commonjs/components/native/deep/TextInput.js.map +1 -0
  61. package/lib/commonjs/components/native/deep/TextNativeComponent.js +28 -0
  62. package/lib/commonjs/components/native/deep/TextNativeComponent.js.map +1 -0
  63. package/lib/commonjs/components/native/deep/TouchableHighlight.js +19 -0
  64. package/lib/commonjs/components/native/deep/TouchableHighlight.js.map +1 -0
  65. package/lib/commonjs/components/native/deep/TouchableOpacity.js +19 -0
  66. package/lib/commonjs/components/native/deep/TouchableOpacity.js.map +1 -0
  67. package/lib/commonjs/components/native/deep/View.js +19 -0
  68. package/lib/commonjs/components/native/deep/View.js.map +1 -0
  69. package/lib/commonjs/components/native/deep/ViewNativeComponent.js +26 -0
  70. package/lib/commonjs/components/native/deep/ViewNativeComponent.js.map +1 -0
  71. package/lib/commonjs/components/native/deep/VirtualizedList.js +19 -0
  72. package/lib/commonjs/components/native/deep/VirtualizedList.js.map +1 -0
  73. package/lib/commonjs/components/native/index.js +43 -0
  74. package/lib/commonjs/components/native/index.js.map +1 -0
  75. package/lib/commonjs/core/createUnistylesActivityIndicator.js +13 -3
  76. package/lib/commonjs/core/createUnistylesActivityIndicator.js.map +1 -1
  77. package/lib/commonjs/core/createUnistylesElement.native.js +6 -0
  78. package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
  79. package/lib/commonjs/core/createUnistylesImageBackground.js +26 -19
  80. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
  81. package/lib/commonjs/core/createUnistylesTouchableHighlight.js +6 -0
  82. package/lib/commonjs/core/createUnistylesTouchableHighlight.js.map +1 -1
  83. package/lib/commonjs/core/getClassname.js +15 -0
  84. package/lib/commonjs/core/getClassname.js.map +1 -1
  85. package/lib/commonjs/core/hasUnistyles.js +26 -0
  86. package/lib/commonjs/core/hasUnistyles.js.map +1 -0
  87. package/lib/commonjs/core/withUnistyles/withUnistyles.js +10 -7
  88. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
  89. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +22 -3
  90. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
  91. package/lib/commonjs/mocks.js +27 -3
  92. package/lib/commonjs/mocks.js.map +1 -1
  93. package/lib/commonjs/specs/ShadowRegistry/index.js +69 -76
  94. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  95. package/lib/commonjs/specs/ShadowRegistry/styleSource.js +65 -0
  96. package/lib/commonjs/specs/ShadowRegistry/styleSource.js.map +1 -0
  97. package/lib/commonjs/specs/ShadowRegistry/tracing.js +26 -0
  98. package/lib/commonjs/specs/ShadowRegistry/tracing.js.map +1 -0
  99. package/lib/commonjs/unifiber/src/adapters/reanimated.js +157 -0
  100. package/lib/commonjs/unifiber/src/adapters/reanimated.js.map +1 -0
  101. package/lib/commonjs/unifiber/src/adapters/registry.js +67 -0
  102. package/lib/commonjs/unifiber/src/adapters/registry.js.map +1 -0
  103. package/lib/commonjs/unifiber/src/diagnostics.js +59 -0
  104. package/lib/commonjs/unifiber/src/diagnostics.js.map +1 -0
  105. package/lib/commonjs/unifiber/src/fiber.js +199 -0
  106. package/lib/commonjs/unifiber/src/fiber.js.map +1 -0
  107. package/lib/commonjs/unifiber/src/host.js +214 -0
  108. package/lib/commonjs/unifiber/src/host.js.map +1 -0
  109. package/lib/commonjs/unifiber/src/index.js +38 -0
  110. package/lib/commonjs/unifiber/src/index.js.map +1 -0
  111. package/lib/commonjs/utils.js +52 -1
  112. package/lib/commonjs/utils.js.map +1 -1
  113. package/lib/commonjs/web/convert/index.js +19 -1
  114. package/lib/commonjs/web/convert/index.js.map +1 -1
  115. package/lib/commonjs/web/convert/module.d.ts +3 -0
  116. package/lib/commonjs/web/convert/object/backgroundLayers.js +30 -0
  117. package/lib/commonjs/web/convert/object/backgroundLayers.js.map +1 -0
  118. package/lib/commonjs/web/convert/object/fontVariationSettings.js +12 -0
  119. package/lib/commonjs/web/convert/object/fontVariationSettings.js.map +1 -0
  120. package/lib/commonjs/web/convert/object/index.js +22 -0
  121. package/lib/commonjs/web/convert/object/index.js.map +1 -1
  122. package/lib/commonjs/web/convert/utils.js +7 -1
  123. package/lib/commonjs/web/convert/utils.js.map +1 -1
  124. package/lib/commonjs/web/registry.js +6 -4
  125. package/lib/commonjs/web/registry.js.map +1 -1
  126. package/lib/commonjs/web/runtime.js +9 -6
  127. package/lib/commonjs/web/runtime.js.map +1 -1
  128. package/lib/commonjs/web/utils/unistyle.js +9 -3
  129. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  130. package/lib/module/components/NamedTheme.js +4 -4
  131. package/lib/module/components/NamedTheme.js.map +1 -1
  132. package/lib/module/components/ScopedThemeContext.js +3 -1
  133. package/lib/module/components/ScopedThemeContext.js.map +1 -1
  134. package/lib/module/components/native/deep/ActivityIndicator.js +5 -0
  135. package/lib/module/components/native/deep/ActivityIndicator.js.map +1 -0
  136. package/lib/module/components/native/deep/Animated.js +5 -0
  137. package/lib/module/components/native/deep/Animated.js.map +1 -0
  138. package/lib/module/components/native/deep/FlatList.js +5 -0
  139. package/lib/module/components/native/deep/FlatList.js.map +1 -0
  140. package/lib/module/components/native/deep/Image.js +5 -0
  141. package/lib/module/components/native/deep/Image.js.map +1 -0
  142. package/lib/module/components/native/deep/ImageBackground.js +5 -0
  143. package/lib/module/components/native/deep/ImageBackground.js.map +1 -0
  144. package/lib/module/components/native/deep/KeyboardAvoidingView.js +5 -0
  145. package/lib/module/components/native/deep/KeyboardAvoidingView.js.map +1 -0
  146. package/lib/module/components/native/deep/Pressable.js +5 -0
  147. package/lib/module/components/native/deep/Pressable.js.map +1 -0
  148. package/lib/module/components/native/deep/RefreshControl.js +5 -0
  149. package/lib/module/components/native/deep/RefreshControl.js.map +1 -0
  150. package/lib/module/components/native/deep/SafeAreaView.js +5 -0
  151. package/lib/module/components/native/deep/SafeAreaView.js.map +1 -0
  152. package/lib/module/components/native/deep/ScrollView.js +5 -0
  153. package/lib/module/components/native/deep/ScrollView.js.map +1 -0
  154. package/lib/module/components/native/deep/SectionList.js +5 -0
  155. package/lib/module/components/native/deep/SectionList.js.map +1 -0
  156. package/lib/module/components/native/deep/Switch.js +5 -0
  157. package/lib/module/components/native/deep/Switch.js.map +1 -0
  158. package/lib/module/components/native/deep/Text.js +5 -0
  159. package/lib/module/components/native/deep/Text.js.map +1 -0
  160. package/lib/module/components/native/deep/TextInput.js +5 -0
  161. package/lib/module/components/native/deep/TextInput.js.map +1 -0
  162. package/lib/module/components/native/deep/TextNativeComponent.js +8 -0
  163. package/lib/module/components/native/deep/TextNativeComponent.js.map +1 -0
  164. package/lib/module/components/native/deep/TouchableHighlight.js +5 -0
  165. package/lib/module/components/native/deep/TouchableHighlight.js.map +1 -0
  166. package/lib/module/components/native/deep/TouchableOpacity.js +5 -0
  167. package/lib/module/components/native/deep/TouchableOpacity.js.map +1 -0
  168. package/lib/module/components/native/deep/View.js +5 -0
  169. package/lib/module/components/native/deep/View.js.map +1 -0
  170. package/lib/module/components/native/deep/ViewNativeComponent.js +8 -0
  171. package/lib/module/components/native/deep/ViewNativeComponent.js.map +1 -0
  172. package/lib/module/components/native/deep/VirtualizedList.js +5 -0
  173. package/lib/module/components/native/deep/VirtualizedList.js.map +1 -0
  174. package/lib/module/components/native/index.js +43 -0
  175. package/lib/module/components/native/index.js.map +1 -0
  176. package/lib/module/core/createUnistylesActivityIndicator.js +13 -3
  177. package/lib/module/core/createUnistylesActivityIndicator.js.map +1 -1
  178. package/lib/module/core/createUnistylesElement.native.js +6 -0
  179. package/lib/module/core/createUnistylesElement.native.js.map +1 -1
  180. package/lib/module/core/createUnistylesImageBackground.js +26 -19
  181. package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
  182. package/lib/module/core/createUnistylesTouchableHighlight.js +6 -0
  183. package/lib/module/core/createUnistylesTouchableHighlight.js.map +1 -1
  184. package/lib/module/core/getClassname.js +16 -1
  185. package/lib/module/core/getClassname.js.map +1 -1
  186. package/lib/module/core/hasUnistyles.js +21 -0
  187. package/lib/module/core/hasUnistyles.js.map +1 -0
  188. package/lib/module/core/withUnistyles/withUnistyles.js +9 -6
  189. package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
  190. package/lib/module/core/withUnistyles/withUnistyles.native.js +24 -5
  191. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
  192. package/lib/module/mocks.js +27 -3
  193. package/lib/module/mocks.js.map +1 -1
  194. package/lib/module/specs/ShadowRegistry/index.js +69 -76
  195. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  196. package/lib/module/specs/ShadowRegistry/styleSource.js +60 -0
  197. package/lib/module/specs/ShadowRegistry/styleSource.js.map +1 -0
  198. package/lib/module/specs/ShadowRegistry/tracing.js +21 -0
  199. package/lib/module/specs/ShadowRegistry/tracing.js.map +1 -0
  200. package/lib/module/unifiber/src/adapters/reanimated.js +152 -0
  201. package/lib/module/unifiber/src/adapters/reanimated.js.map +1 -0
  202. package/lib/module/unifiber/src/adapters/registry.js +62 -0
  203. package/lib/module/unifiber/src/adapters/registry.js.map +1 -0
  204. package/lib/module/unifiber/src/diagnostics.js +52 -0
  205. package/lib/module/unifiber/src/diagnostics.js.map +1 -0
  206. package/lib/module/unifiber/src/fiber.js +183 -0
  207. package/lib/module/unifiber/src/fiber.js.map +1 -0
  208. package/lib/module/unifiber/src/host.js +191 -0
  209. package/lib/module/unifiber/src/host.js.map +1 -0
  210. package/lib/module/unifiber/src/index.js +33 -0
  211. package/lib/module/unifiber/src/index.js.map +1 -0
  212. package/lib/module/utils.js +50 -0
  213. package/lib/module/utils.js.map +1 -1
  214. package/lib/module/web/convert/index.js +22 -3
  215. package/lib/module/web/convert/index.js.map +1 -1
  216. package/lib/module/web/convert/module.d.ts +3 -0
  217. package/lib/module/web/convert/object/backgroundLayers.js +25 -0
  218. package/lib/module/web/convert/object/backgroundLayers.js.map +1 -0
  219. package/lib/module/web/convert/object/fontVariationSettings.js +7 -0
  220. package/lib/module/web/convert/object/fontVariationSettings.js.map +1 -0
  221. package/lib/module/web/convert/object/index.js +2 -0
  222. package/lib/module/web/convert/object/index.js.map +1 -1
  223. package/lib/module/web/convert/utils.js +4 -0
  224. package/lib/module/web/convert/utils.js.map +1 -1
  225. package/lib/module/web/registry.js +6 -4
  226. package/lib/module/web/registry.js.map +1 -1
  227. package/lib/module/web/runtime.js +9 -6
  228. package/lib/module/web/runtime.js.map +1 -1
  229. package/lib/module/web/utils/unistyle.js +10 -4
  230. package/lib/module/web/utils/unistyle.js.map +1 -1
  231. package/lib/typescript/src/components/ScopedThemeContext.d.ts +2 -1
  232. package/lib/typescript/src/components/ScopedThemeContext.d.ts.map +1 -1
  233. package/lib/typescript/src/components/native/deep/ActivityIndicator.d.ts +2 -0
  234. package/lib/typescript/src/components/native/deep/ActivityIndicator.d.ts.map +1 -0
  235. package/lib/typescript/src/components/native/deep/Animated.d.ts +2 -0
  236. package/lib/typescript/src/components/native/deep/Animated.d.ts.map +1 -0
  237. package/lib/typescript/src/components/native/deep/FlatList.d.ts +2 -0
  238. package/lib/typescript/src/components/native/deep/FlatList.d.ts.map +1 -0
  239. package/lib/typescript/src/components/native/deep/Image.d.ts +2 -0
  240. package/lib/typescript/src/components/native/deep/Image.d.ts.map +1 -0
  241. package/lib/typescript/src/components/native/deep/ImageBackground.d.ts +2 -0
  242. package/lib/typescript/src/components/native/deep/ImageBackground.d.ts.map +1 -0
  243. package/lib/typescript/src/components/native/deep/KeyboardAvoidingView.d.ts +2 -0
  244. package/lib/typescript/src/components/native/deep/KeyboardAvoidingView.d.ts.map +1 -0
  245. package/lib/typescript/src/components/native/deep/Pressable.d.ts +2 -0
  246. package/lib/typescript/src/components/native/deep/Pressable.d.ts.map +1 -0
  247. package/lib/typescript/src/components/native/deep/RefreshControl.d.ts +2 -0
  248. package/lib/typescript/src/components/native/deep/RefreshControl.d.ts.map +1 -0
  249. package/lib/typescript/src/components/native/deep/SafeAreaView.d.ts +2 -0
  250. package/lib/typescript/src/components/native/deep/SafeAreaView.d.ts.map +1 -0
  251. package/lib/typescript/src/components/native/deep/ScrollView.d.ts +2 -0
  252. package/lib/typescript/src/components/native/deep/ScrollView.d.ts.map +1 -0
  253. package/lib/typescript/src/components/native/deep/SectionList.d.ts +2 -0
  254. package/lib/typescript/src/components/native/deep/SectionList.d.ts.map +1 -0
  255. package/lib/typescript/src/components/native/deep/Switch.d.ts +2 -0
  256. package/lib/typescript/src/components/native/deep/Switch.d.ts.map +1 -0
  257. package/lib/typescript/src/components/native/deep/Text.d.ts +2 -0
  258. package/lib/typescript/src/components/native/deep/Text.d.ts.map +1 -0
  259. package/lib/typescript/src/components/native/deep/TextInput.d.ts +2 -0
  260. package/lib/typescript/src/components/native/deep/TextInput.d.ts.map +1 -0
  261. package/lib/typescript/src/components/native/deep/TextNativeComponent.d.ts +3 -0
  262. package/lib/typescript/src/components/native/deep/TextNativeComponent.d.ts.map +1 -0
  263. package/lib/typescript/src/components/native/deep/TouchableHighlight.d.ts +2 -0
  264. package/lib/typescript/src/components/native/deep/TouchableHighlight.d.ts.map +1 -0
  265. package/lib/typescript/src/components/native/deep/TouchableOpacity.d.ts +2 -0
  266. package/lib/typescript/src/components/native/deep/TouchableOpacity.d.ts.map +1 -0
  267. package/lib/typescript/src/components/native/deep/View.d.ts +2 -0
  268. package/lib/typescript/src/components/native/deep/View.d.ts.map +1 -0
  269. package/lib/typescript/src/components/native/deep/ViewNativeComponent.d.ts +3 -0
  270. package/lib/typescript/src/components/native/deep/ViewNativeComponent.d.ts.map +1 -0
  271. package/lib/typescript/src/components/native/deep/VirtualizedList.d.ts +2 -0
  272. package/lib/typescript/src/components/native/deep/VirtualizedList.d.ts.map +1 -0
  273. package/lib/typescript/src/components/native/index.d.ts +4 -0
  274. package/lib/typescript/src/components/native/index.d.ts.map +1 -0
  275. package/lib/typescript/src/components/scopeChildren.d.ts +1 -1
  276. package/lib/typescript/src/core/createUnistylesActivityIndicator.d.ts.map +1 -1
  277. package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
  278. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
  279. package/lib/typescript/src/core/createUnistylesTouchableHighlight.d.ts.map +1 -1
  280. package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
  281. package/lib/typescript/src/core/hasUnistyles.d.ts +2 -0
  282. package/lib/typescript/src/core/hasUnistyles.d.ts.map +1 -0
  283. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts +6 -3
  284. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
  285. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts +7 -4
  286. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
  287. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  288. package/lib/typescript/src/specs/ShadowRegistry/styleSource.d.ts +11 -0
  289. package/lib/typescript/src/specs/ShadowRegistry/styleSource.d.ts.map +1 -0
  290. package/lib/typescript/src/specs/ShadowRegistry/tracing.d.ts +2 -0
  291. package/lib/typescript/src/specs/ShadowRegistry/tracing.d.ts.map +1 -0
  292. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +4 -41
  293. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
  294. package/lib/typescript/src/unifiber/src/adapters/reanimated.d.ts +17 -0
  295. package/lib/typescript/src/unifiber/src/adapters/reanimated.d.ts.map +1 -0
  296. package/lib/typescript/src/unifiber/src/adapters/registry.d.ts +23 -0
  297. package/lib/typescript/src/unifiber/src/adapters/registry.d.ts.map +1 -0
  298. package/lib/typescript/src/unifiber/src/diagnostics.d.ts +10 -0
  299. package/lib/typescript/src/unifiber/src/diagnostics.d.ts.map +1 -0
  300. package/lib/typescript/src/unifiber/src/fiber.d.ts +48 -0
  301. package/lib/typescript/src/unifiber/src/fiber.d.ts.map +1 -0
  302. package/lib/typescript/src/unifiber/src/host.d.ts +32 -0
  303. package/lib/typescript/src/unifiber/src/host.d.ts.map +1 -0
  304. package/lib/typescript/src/unifiber/src/index.d.ts +49 -0
  305. package/lib/typescript/src/unifiber/src/index.d.ts.map +1 -0
  306. package/lib/typescript/src/utils.d.ts +1 -0
  307. package/lib/typescript/src/utils.d.ts.map +1 -1
  308. package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
  309. package/lib/typescript/src/web/convert/object/backgroundLayers.d.ts +4 -0
  310. package/lib/typescript/src/web/convert/object/backgroundLayers.d.ts.map +1 -0
  311. package/lib/typescript/src/web/convert/object/fontVariationSettings.d.ts +4 -0
  312. package/lib/typescript/src/web/convert/object/fontVariationSettings.d.ts.map +1 -0
  313. package/lib/typescript/src/web/convert/object/index.d.ts +2 -0
  314. package/lib/typescript/src/web/convert/object/index.d.ts.map +1 -1
  315. package/lib/typescript/src/web/convert/utils.d.ts +2 -0
  316. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  317. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  318. package/lib/typescript/src/web/runtime.d.ts +1 -0
  319. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  320. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  321. package/metro/babel-transformer.js +1102 -0
  322. package/metro/index.d.ts +31 -0
  323. package/metro/index.js +170 -0
  324. package/package.json +50 -32
  325. package/plugin/index.d.ts +7 -0
  326. package/plugin/index.js +115 -33
  327. package/src/components/NamedTheme.tsx +5 -5
  328. package/src/components/ScopedThemeContext.ts +6 -2
  329. package/src/components/native/deep/ActivityIndicator.ts +2 -0
  330. package/src/components/native/deep/Animated.ts +2 -0
  331. package/src/components/native/deep/FlatList.ts +2 -0
  332. package/src/components/native/deep/Image.ts +2 -0
  333. package/src/components/native/deep/ImageBackground.ts +2 -0
  334. package/src/components/native/deep/KeyboardAvoidingView.ts +2 -0
  335. package/src/components/native/deep/Pressable.ts +2 -0
  336. package/src/components/native/deep/RefreshControl.ts +2 -0
  337. package/src/components/native/deep/SafeAreaView.ts +2 -0
  338. package/src/components/native/deep/ScrollView.ts +2 -0
  339. package/src/components/native/deep/SectionList.ts +2 -0
  340. package/src/components/native/deep/Switch.ts +2 -0
  341. package/src/components/native/deep/Text.ts +2 -0
  342. package/src/components/native/deep/TextInput.ts +2 -0
  343. package/src/components/native/deep/TextNativeComponent.ts +5 -0
  344. package/src/components/native/deep/TouchableHighlight.ts +2 -0
  345. package/src/components/native/deep/TouchableOpacity.ts +2 -0
  346. package/src/components/native/deep/View.ts +2 -0
  347. package/src/components/native/deep/ViewNativeComponent.ts +5 -0
  348. package/src/components/native/deep/VirtualizedList.ts +2 -0
  349. package/src/components/native/index.ts +41 -0
  350. package/src/core/createUnistylesActivityIndicator.tsx +11 -4
  351. package/src/core/createUnistylesElement.native.tsx +5 -0
  352. package/src/core/createUnistylesImageBackground.tsx +33 -25
  353. package/src/core/createUnistylesTouchableHighlight.tsx +5 -0
  354. package/src/core/getClassname.ts +10 -1
  355. package/src/core/hasUnistyles.ts +20 -0
  356. package/src/core/withUnistyles/withUnistyles.native.tsx +28 -6
  357. package/src/core/withUnistyles/withUnistyles.tsx +6 -6
  358. package/src/mocks.ts +14 -5
  359. package/src/specs/ShadowRegistry/index.ts +62 -103
  360. package/src/specs/ShadowRegistry/styleSource.ts +78 -0
  361. package/src/specs/ShadowRegistry/tracing.ts +23 -0
  362. package/src/specs/ShadowRegistry/types.ts +3 -43
  363. package/src/unifiber/LICENSE +21 -0
  364. package/src/unifiber/README.md +92 -0
  365. package/src/unifiber/src/adapters/reanimated.ts +204 -0
  366. package/src/unifiber/src/adapters/registry.ts +102 -0
  367. package/src/unifiber/src/diagnostics.ts +55 -0
  368. package/src/unifiber/src/fiber.ts +262 -0
  369. package/src/unifiber/src/host.ts +236 -0
  370. package/src/unifiber/src/index.ts +43 -0
  371. package/src/utils.ts +51 -0
  372. package/src/web/convert/index.ts +39 -3
  373. package/src/web/convert/object/backgroundLayers.ts +33 -0
  374. package/src/web/convert/object/fontVariationSettings.ts +7 -0
  375. package/src/web/convert/object/index.ts +2 -0
  376. package/src/web/convert/utils.ts +11 -0
  377. package/src/web/registry.ts +7 -8
  378. package/src/web/runtime.ts +7 -7
  379. package/src/web/utils/unistyle.ts +11 -4
  380. package/lib/commonjs/web/convert/module.d.js +0 -2
  381. package/lib/commonjs/web/convert/module.d.js.map +0 -1
  382. package/lib/module/web/convert/module.d.js +0 -2
  383. package/lib/module/web/convert/module.d.js.map +0 -1
  384. package/lib/typescript/src/__tests__/mocks.spec.d.ts +0 -2
  385. package/lib/typescript/src/__tests__/mocks.spec.d.ts.map +0 -1
  386. package/lib/typescript/src/__tests__/passForwardRef.spec.d.ts +0 -2
  387. package/lib/typescript/src/__tests__/passForwardRef.spec.d.ts.map +0 -1
  388. package/lib/typescript/src/__tests__/scoped-theme.spec.d.ts +0 -2
  389. package/lib/typescript/src/__tests__/scoped-theme.spec.d.ts.map +0 -1
  390. package/lib/typescript/src/__tests__/shadow-registry.spec.d.ts +0 -2
  391. package/lib/typescript/src/__tests__/shadow-registry.spec.d.ts.map +0 -1
  392. package/lib/typescript/src/__tests__/web-child-selector.spec.d.ts +0 -2
  393. package/lib/typescript/src/__tests__/web-child-selector.spec.d.ts.map +0 -1
  394. package/lib/typescript/src/__tests__/web-listener.spec.d.ts +0 -2
  395. package/lib/typescript/src/__tests__/web-listener.spec.d.ts.map +0 -1
  396. package/lib/typescript/src/__tests__/web-pointer-events.spec.d.ts +0 -2
  397. package/lib/typescript/src/__tests__/web-pointer-events.spec.d.ts.map +0 -1
  398. package/lib/typescript/src/__tests__/web-runtime.spec.d.ts +0 -2
  399. package/lib/typescript/src/__tests__/web-runtime.spec.d.ts.map +0 -1
  400. package/lib/typescript/src/__tests__/withUnistyles.spec.d.ts +0 -2
  401. package/lib/typescript/src/__tests__/withUnistyles.spec.d.ts.map +0 -1
@@ -0,0 +1,1102 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // metro/src/babel-transformer.ts
31
+ var babel_transformer_exports = {};
32
+ __export(babel_transformer_exports, {
33
+ getCacheKey: () => getCacheKey,
34
+ transform: () => transform
35
+ });
36
+ module.exports = __toCommonJS(babel_transformer_exports);
37
+ var import_node_fs = __toESM(require("node:fs"));
38
+ var import_node_path4 = __toESM(require("node:path"));
39
+
40
+ // plugin/src/consts.ts
41
+ var REACT_NATIVE_COMPONENT_NAMES = [
42
+ "ActivityIndicator",
43
+ "View",
44
+ "Text",
45
+ "Image",
46
+ "ImageBackground",
47
+ "KeyboardAvoidingView",
48
+ "Pressable",
49
+ "ScrollView",
50
+ "FlatList",
51
+ "SectionList",
52
+ "Switch",
53
+ "TextInput",
54
+ "RefreshControl",
55
+ "TouchableHighlight",
56
+ "TouchableOpacity",
57
+ "VirtualizedList",
58
+ "Animated",
59
+ "SafeAreaView"
60
+ // Modal - there is no exposed native handle
61
+ // TouchableWithoutFeedback - can't accept a ref
62
+ ];
63
+ var REPLACE_WITH_UNISTYLES_PATHS = [
64
+ "react-native-reanimated/src/component",
65
+ "react-native-reanimated/lib/module/component"
66
+ ];
67
+ var REPLACE_WITH_UNISTYLES_EXOTIC_PATHS = [];
68
+ var NATIVE_COMPONENTS_PATHS = {
69
+ imports: [
70
+ {
71
+ name: "NativeText",
72
+ isDefault: false,
73
+ path: "react-native/Libraries/Text/TextNativeComponent",
74
+ mapTo: "NativeText"
75
+ },
76
+ {
77
+ isDefault: true,
78
+ path: "react-native/Libraries/Components/View/ViewNativeComponent",
79
+ mapTo: "NativeView"
80
+ },
81
+ {
82
+ name: "unstable_NativeText",
83
+ isDefault: false,
84
+ path: "react-native",
85
+ mapTo: "NativeText"
86
+ },
87
+ {
88
+ name: "unstable_NativeView",
89
+ isDefault: false,
90
+ path: "react-native",
91
+ mapTo: "NativeView"
92
+ }
93
+ ]
94
+ };
95
+ var METRO_UPSTREAM_TRANSFORMER_ENV = "UNISTYLES_METRO_UPSTREAM_TRANSFORMER";
96
+ var METRO_OPTIONS_ENV = "UNISTYLES_METRO_OPTIONS";
97
+
98
+ // metro/src/transformer.ts
99
+ var import_node_path3 = __toESM(require("node:path"));
100
+
101
+ // plugin/src/index.ts
102
+ var t6 = __toESM(require("@babel/types"));
103
+ var import_node_path2 = __toESM(require("node:path"));
104
+
105
+ // plugin/src/exotic.ts
106
+ var t2 = __toESM(require("@babel/types"));
107
+
108
+ // plugin/src/import.ts
109
+ var t = __toESM(require("@babel/types"));
110
+ function getComponentPath(state, name) {
111
+ if (!state.opts.isLocal) {
112
+ return `react-native-unistyles/components/native/${name}`;
113
+ }
114
+ if (state.opts.localPath) {
115
+ return `${state.opts.localPath}/src/components/native/${name}`;
116
+ }
117
+ return state.file.opts.filename?.split("react-native-unistyles").at(0)?.concat(`react-native-unistyles/src/components/native/${name}`) ?? "";
118
+ }
119
+ function addUnistylesImport(path3, state) {
120
+ const localNames = Object.keys(state.reactNativeImports);
121
+ const names = Object.values(state.reactNativeImports);
122
+ const pairs = Object.entries(state.reactNativeImports);
123
+ const nodesToRemove = [];
124
+ path3.node.body.forEach((node) => {
125
+ if (t.isImportDeclaration(node) && node.source.value === "react-native") {
126
+ node.specifiers = node.specifiers.filter(
127
+ (specifier) => !localNames.some((name) => name === specifier.local.name)
128
+ );
129
+ if (node.specifiers.length === 0) {
130
+ nodesToRemove.push(node);
131
+ }
132
+ }
133
+ });
134
+ names.forEach((name) => {
135
+ const rnWebImport = path3.node.body.find(
136
+ (node) => t.isImportDeclaration(node) && node.source.value === `react-native-web/dist/exports/${name}`
137
+ );
138
+ if (rnWebImport) {
139
+ rnWebImport.specifiers = [];
140
+ }
141
+ });
142
+ pairs.forEach(([localName, name]) => {
143
+ const newImport = t.importDeclaration(
144
+ [t.importSpecifier(t.identifier(localName), t.identifier(name))],
145
+ t.stringLiteral(getComponentPath(state, name))
146
+ );
147
+ path3.node.body.unshift(newImport);
148
+ });
149
+ nodesToRemove.forEach((node) => path3.node.body.splice(path3.node.body.indexOf(node), 1));
150
+ }
151
+ function isInsideNodeModules(state) {
152
+ if (state.opts.isMetro) {
153
+ return false;
154
+ }
155
+ return state.file.opts.filename?.includes("node_modules") && !state.file.replaceWithUnistyles;
156
+ }
157
+ function addUnistylesRequire(path3, state) {
158
+ Object.entries(state.reactNativeImports).forEach(([componentName, uniqueName]) => {
159
+ const newRequire = t.variableDeclaration("const", [
160
+ t.variableDeclarator(
161
+ t.identifier(uniqueName),
162
+ t.callExpression(t.identifier("require"), [
163
+ t.stringLiteral(`react-native-unistyles/components/native/${componentName}`)
164
+ ])
165
+ )
166
+ ]);
167
+ path3.node.body.unshift(newRequire);
168
+ });
169
+ }
170
+
171
+ // plugin/src/exotic.ts
172
+ function handleExoticImport(path3, state, exoticImport) {
173
+ const specifiers = path3.node.specifiers;
174
+ const source = path3.node.source;
175
+ if (path3.node.importKind !== "value") {
176
+ return;
177
+ }
178
+ specifiers.forEach((specifier) => {
179
+ for (const rule of exoticImport.imports) {
180
+ const hasMatchingImportType = !rule.isDefault && t2.isImportSpecifier(specifier) || rule.isDefault && t2.isImportDefaultSpecifier(specifier);
181
+ const isTypeOnly = t2.isImportSpecifier(specifier) && specifier.importKind !== "value";
182
+ const hasMatchingImportName = rule.isDefault || t2.isImportSpecifier(specifier) && rule.name === getImportedName(specifier);
183
+ const hasMatchingPath = rule.path === source.value;
184
+ if (isTypeOnly || !hasMatchingImportType || !hasMatchingImportName || !hasMatchingPath) {
185
+ continue;
186
+ }
187
+ if (t2.isImportDefaultSpecifier(specifier)) {
188
+ const newImport = t2.importDeclaration(
189
+ [t2.importDefaultSpecifier(t2.identifier(specifier.local.name))],
190
+ t2.stringLiteral(getComponentPath(state, rule.mapTo))
191
+ );
192
+ path3.replaceWith(newImport);
193
+ } else {
194
+ const newImport = t2.importDeclaration(
195
+ [t2.importSpecifier(t2.identifier(specifier.local.name), t2.identifier(rule.mapTo))],
196
+ t2.stringLiteral(getComponentPath(state, rule.mapTo))
197
+ );
198
+ path3.node.specifiers = path3.node.specifiers.filter((s) => s !== specifier);
199
+ if (path3.node.specifiers.length === 0) {
200
+ path3.replaceWith(newImport);
201
+ } else {
202
+ path3.insertBefore(newImport);
203
+ }
204
+ }
205
+ return;
206
+ }
207
+ });
208
+ }
209
+ function getImportedName(specifier) {
210
+ return t2.isIdentifier(specifier.imported) ? specifier.imported.name : specifier.imported.value;
211
+ }
212
+
213
+ // plugin/src/paths.ts
214
+ var import_node_path = __toESM(require("node:path"));
215
+ var isWindows = process.platform === "win32";
216
+ var toWinPath = (pathString) => {
217
+ return import_node_path.default.normalize(pathString).replace(/\//g, "\\");
218
+ };
219
+ var toPlatformPath = (pathString) => {
220
+ return isWindows ? toWinPath(pathString) : pathString;
221
+ };
222
+
223
+ // plugin/src/ref.ts
224
+ var t3 = __toESM(require("@babel/types"));
225
+ function hasStringRef(path3) {
226
+ return path3.node.openingElement.attributes.find(
227
+ (attr) => t3.isJSXAttribute(attr) && t3.isJSXIdentifier(attr.name, { name: "ref" }) && t3.isStringLiteral(attr.value)
228
+ );
229
+ }
230
+
231
+ // plugin/src/stylesheet.ts
232
+ var t4 = __toESM(require("@babel/types"));
233
+ var UnistyleDependency = {
234
+ Theme: 0,
235
+ ThemeName: 1,
236
+ AdaptiveThemes: 2,
237
+ Breakpoints: 3,
238
+ Variants: 4,
239
+ ColorScheme: 5,
240
+ Dimensions: 6,
241
+ Orientation: 7,
242
+ ContentSizeCategory: 8,
243
+ Insets: 9,
244
+ PixelRatio: 10,
245
+ FontScale: 11,
246
+ StatusBar: 12,
247
+ NavigationBar: 13,
248
+ Ime: 14,
249
+ Rtl: 15
250
+ };
251
+ function getStyleKeyName(key) {
252
+ if (!key) {
253
+ return null;
254
+ }
255
+ if (t4.isIdentifier(key)) {
256
+ return key.name;
257
+ }
258
+ if (t4.isStringLiteral(key) || t4.isNumericLiteral(key) || t4.isBooleanLiteral(key)) {
259
+ return String(key.value);
260
+ }
261
+ return null;
262
+ }
263
+ function getProperty(property) {
264
+ if (!property) {
265
+ return void 0;
266
+ }
267
+ if (t4.isIdentifier(property)) {
268
+ const prop = property;
269
+ return {
270
+ properties: [prop.name]
271
+ };
272
+ }
273
+ if (t4.isObjectPattern(property)) {
274
+ const prop = property;
275
+ const matchingProperties = prop.properties.flatMap((p) => getProperty(p));
276
+ return {
277
+ properties: matchingProperties.flatMap((properties) => properties?.properties).filter((prop2) => prop2 !== void 0)
278
+ };
279
+ }
280
+ if (t4.isObjectProperty(property) && t4.isIdentifier(property.value)) {
281
+ const prop = property.key;
282
+ return {
283
+ properties: [prop.name]
284
+ };
285
+ }
286
+ if (t4.isObjectProperty(property) && t4.isObjectPattern(property.value)) {
287
+ const matchingProperties = property.value.properties.flatMap((p) => getProperty(p));
288
+ const prop = property.key;
289
+ return {
290
+ parent: prop.name,
291
+ properties: matchingProperties.flatMap((properties) => properties?.properties).filter((prop2) => prop2 !== void 0)
292
+ };
293
+ }
294
+ return void 0;
295
+ }
296
+ function toUnistylesDependency(dependency) {
297
+ switch (dependency) {
298
+ case "theme": {
299
+ return UnistyleDependency.Theme;
300
+ }
301
+ case "themeName": {
302
+ return UnistyleDependency.ThemeName;
303
+ }
304
+ case "adaptiveThemes":
305
+ case "hasAdaptiveThemes": {
306
+ return UnistyleDependency.AdaptiveThemes;
307
+ }
308
+ case "breakpoint": {
309
+ return UnistyleDependency.Breakpoints;
310
+ }
311
+ case "colorScheme": {
312
+ return UnistyleDependency.ColorScheme;
313
+ }
314
+ case "screen": {
315
+ return UnistyleDependency.Dimensions;
316
+ }
317
+ case "isPortrait":
318
+ case "isLandscape": {
319
+ return UnistyleDependency.Orientation;
320
+ }
321
+ case "contentSizeCategory": {
322
+ return UnistyleDependency.ContentSizeCategory;
323
+ }
324
+ case "ime": {
325
+ return UnistyleDependency.Ime;
326
+ }
327
+ case "insets": {
328
+ return UnistyleDependency.Insets;
329
+ }
330
+ case "pixelRatio": {
331
+ return UnistyleDependency.PixelRatio;
332
+ }
333
+ case "fontScale": {
334
+ return UnistyleDependency.FontScale;
335
+ }
336
+ case "statusBar": {
337
+ return UnistyleDependency.StatusBar;
338
+ }
339
+ case "navigationBar": {
340
+ return UnistyleDependency.NavigationBar;
341
+ }
342
+ case "variants": {
343
+ return UnistyleDependency.Variants;
344
+ }
345
+ case "rtl": {
346
+ return UnistyleDependency.Rtl;
347
+ }
348
+ default:
349
+ return null;
350
+ }
351
+ }
352
+ function getReturnStatementsFromBody(node, results = []) {
353
+ if (t4.isReturnStatement(node)) {
354
+ results.push(node);
355
+ }
356
+ if (t4.isBlockStatement(node)) {
357
+ node.body.forEach((child) => getReturnStatementsFromBody(child, results));
358
+ }
359
+ if (t4.isIfStatement(node)) {
360
+ getReturnStatementsFromBody(node.consequent, results);
361
+ if (node.alternate) {
362
+ getReturnStatementsFromBody(node.alternate, results);
363
+ }
364
+ }
365
+ return results;
366
+ }
367
+ function countReturnStatements(node) {
368
+ if (t4.isFunction(node) || t4.isClass(node)) {
369
+ return 0;
370
+ }
371
+ if (t4.isReturnStatement(node)) {
372
+ return 1;
373
+ }
374
+ return (t4.VISITOR_KEYS[node.type] ?? []).reduce((count, key) => {
375
+ const child = node[key];
376
+ const children = (Array.isArray(child) ? child : [child]).filter(
377
+ (childNode) => t4.isNode(childNode)
378
+ );
379
+ return count + children.reduce((childCount, childNode) => childCount + countReturnStatements(childNode), 0);
380
+ }, 0);
381
+ }
382
+ function collectReturnedObjects(node, targets, unsupported) {
383
+ if (t4.isObjectExpression(node)) {
384
+ targets.push(node);
385
+ return;
386
+ }
387
+ if (t4.isConditionalExpression(node)) {
388
+ collectReturnedObjects(node.consequent, targets, unsupported);
389
+ collectReturnedObjects(node.alternate, targets, unsupported);
390
+ return;
391
+ }
392
+ if (t4.isLogicalExpression(node)) {
393
+ if (node.operator !== "&&") {
394
+ collectReturnedObjects(node.left, targets, unsupported);
395
+ }
396
+ collectReturnedObjects(node.right, targets, unsupported);
397
+ return;
398
+ }
399
+ if (t4.isTSAsExpression(node) || t4.isTSSatisfiesExpression(node) || t4.isParenthesizedExpression(node)) {
400
+ collectReturnedObjects(node.expression, targets, unsupported);
401
+ return;
402
+ }
403
+ if (t4.isNullLiteral(node) || t4.isBooleanLiteral(node) || t4.isIdentifier(node) && node.name === "undefined") {
404
+ return;
405
+ }
406
+ unsupported.push(node);
407
+ }
408
+ function isUnistylesStyleSheet(path3, state) {
409
+ const { callee } = path3.node;
410
+ if (!t4.isMemberExpression(callee) || !t4.isIdentifier(callee.property)) {
411
+ return false;
412
+ }
413
+ const isImport = callee.property.name === "create" && t4.isIdentifier(callee.object) && callee.object.name === state.file.styleSheetLocalName;
414
+ 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";
415
+ return isImport || isRequire;
416
+ }
417
+ function isUnistylesCommonJSRequire(path3, state) {
418
+ const isRequire = t4.isIdentifier(path3.node.callee) && path3.node.arguments.length > 0 && t4.isStringLiteral(path3.node.arguments[0]) && path3.node.arguments[0].value === "react-native-unistyles";
419
+ if (isRequire && t4.isVariableDeclarator(path3.parent) && t4.isIdentifier(path3.parent.id)) {
420
+ state.file.hasUnistylesImport = true;
421
+ state.file.styleSheetLocalName = path3.parent.id.name;
422
+ }
423
+ return isRequire;
424
+ }
425
+ function isReactNativeCommonJSRequire(path3, state) {
426
+ const isRequire = t4.isIdentifier(path3.node.callee) && path3.node.arguments.length > 0 && path3.node.callee.name === "require";
427
+ const requireImportName = path3.node.arguments.find((node) => t4.isStringLiteral(node));
428
+ const isReactNativeRequire = isRequire && requireImportName && (requireImportName.value === "react-native" || requireImportName.value === "react-native-web/dist/index");
429
+ if (isReactNativeRequire && t4.isVariableDeclarator(path3.parent) && t4.isIdentifier(path3.parent.id)) {
430
+ state.file.reactNativeCommonJSName = path3.parent.id.name;
431
+ }
432
+ return isRequire;
433
+ }
434
+ function isKindOfStyleSheet(path3, state) {
435
+ if (!state.file.forceProcessing && !state.file.hasUnistylesImport) {
436
+ return false;
437
+ }
438
+ if (path3.node.arguments.length !== 1) {
439
+ return false;
440
+ }
441
+ const { callee } = path3.node;
442
+ const isCreateCall = t4.isMemberExpression(callee) && t4.isIdentifier(callee.property) && callee.property.name === "create" && (t4.isIdentifier(callee.object) || t4.isMemberExpression(callee.object));
443
+ if (!isCreateCall) {
444
+ return false;
445
+ }
446
+ const argument = path3.node.arguments[0];
447
+ if (t4.isArrowFunctionExpression(argument)) {
448
+ if (argument.params.length > 2) {
449
+ return false;
450
+ }
451
+ if (t4.isObjectExpression(argument.body) && argument.body.properties.length > 0) {
452
+ return true;
453
+ }
454
+ if (t4.isBlockStatement(argument.body)) {
455
+ const returnStatements = getReturnStatementsFromBody(argument.body);
456
+ return returnStatements.some(
457
+ (ret) => ret.argument && t4.isObjectExpression(ret.argument) && ret.argument.properties.length > 0
458
+ );
459
+ }
460
+ return false;
461
+ }
462
+ if (t4.isObjectExpression(argument)) {
463
+ return argument.properties.some(
464
+ (property) => t4.isObjectProperty(property) && t4.isObjectExpression(property.value)
465
+ );
466
+ }
467
+ return false;
468
+ }
469
+ function getStylesDependenciesFromObject(path3) {
470
+ const detectedStylesWithVariants = /* @__PURE__ */ new Set();
471
+ const stylesheet = path3.node.arguments[0];
472
+ if (t4.isObjectExpression(stylesheet)) {
473
+ stylesheet?.properties.forEach((property) => {
474
+ if (!t4.isObjectProperty(property)) {
475
+ return;
476
+ }
477
+ const styleKey = getStyleKeyName(property.key);
478
+ if (!styleKey) {
479
+ return;
480
+ }
481
+ if (t4.isObjectExpression(property.value)) {
482
+ property.value.properties.forEach((innerProp) => {
483
+ if (t4.isObjectProperty(innerProp) && t4.isIdentifier(innerProp.key) && innerProp.key.name === "variants") {
484
+ detectedStylesWithVariants.add({
485
+ label: "variants",
486
+ key: styleKey
487
+ });
488
+ }
489
+ });
490
+ }
491
+ if (t4.isArrowFunctionExpression(property.value)) {
492
+ if (t4.isObjectExpression(property.value.body)) {
493
+ property.value.body.properties.forEach((innerProp) => {
494
+ if (t4.isObjectProperty(innerProp) && t4.isIdentifier(innerProp.key) && innerProp.key.name === "variants") {
495
+ detectedStylesWithVariants.add({
496
+ label: "variants",
497
+ key: styleKey
498
+ });
499
+ }
500
+ });
501
+ }
502
+ }
503
+ });
504
+ }
505
+ const variants = Array.from(detectedStylesWithVariants);
506
+ return variants.reduce((acc, { key, label }) => {
507
+ if (acc[key]) {
508
+ acc[key] = [...acc[key], label];
509
+ return acc;
510
+ }
511
+ acc[key] = [label];
512
+ return acc;
513
+ }, {});
514
+ }
515
+ function getStylesDependenciesFromFunction(funcPath) {
516
+ if (!funcPath) {
517
+ return;
518
+ }
519
+ if (Array.isArray(funcPath)) {
520
+ return;
521
+ }
522
+ if (!t4.isFunctionExpression(funcPath.node) && !t4.isArrowFunctionExpression(funcPath.node)) {
523
+ return;
524
+ }
525
+ const params = funcPath.node.params;
526
+ const [themeParam, rtParam] = params;
527
+ const themeNames = [];
528
+ if (t4.isObjectPattern(themeParam)) {
529
+ for (const prop of themeParam.properties) {
530
+ const property = getProperty(prop);
531
+ if (property) {
532
+ themeNames.push(property);
533
+ }
534
+ }
535
+ }
536
+ if (t4.isIdentifier(themeParam)) {
537
+ themeNames.push({
538
+ properties: [themeParam.name]
539
+ });
540
+ }
541
+ const rtNames = [];
542
+ if (t4.isObjectPattern(rtParam)) {
543
+ for (const prop of rtParam.properties) {
544
+ const property = getProperty(prop);
545
+ if (property) {
546
+ rtNames.push(property);
547
+ }
548
+ }
549
+ }
550
+ if (t4.isIdentifier(rtParam)) {
551
+ rtNames.push({
552
+ properties: [rtParam.name]
553
+ });
554
+ }
555
+ let returnedObjectPath = null;
556
+ if (t4.isObjectExpression(funcPath.node.body)) {
557
+ returnedObjectPath = funcPath.get("body");
558
+ } else {
559
+ funcPath.traverse({
560
+ ReturnStatement(retPath) {
561
+ if (!returnedObjectPath && retPath.get("argument").isObjectExpression()) {
562
+ const argumentPath = retPath.get("argument");
563
+ if (argumentPath.isObjectExpression()) {
564
+ returnedObjectPath = argumentPath;
565
+ }
566
+ }
567
+ }
568
+ });
569
+ }
570
+ if (!returnedObjectPath) {
571
+ return;
572
+ }
573
+ const detectedStylesWithVariants = /* @__PURE__ */ new Set();
574
+ const properties = returnedObjectPath.get("properties");
575
+ properties.forEach((propPath) => {
576
+ const stylePath = propPath.get("key");
577
+ if (Array.isArray(stylePath)) {
578
+ return;
579
+ }
580
+ const styleKey = getStyleKeyName(stylePath.node);
581
+ if (!styleKey) {
582
+ return;
583
+ }
584
+ const valuePath = propPath.get("value");
585
+ if (Array.isArray(valuePath)) {
586
+ return;
587
+ }
588
+ if (valuePath.isObjectExpression()) {
589
+ const hasVariants = valuePath.get("properties").some((innerProp) => {
590
+ const innerKey = innerProp.get("key");
591
+ if (Array.isArray(innerKey)) {
592
+ return;
593
+ }
594
+ return innerKey.isIdentifier() && innerKey.node.name === "variants";
595
+ });
596
+ if (hasVariants) {
597
+ detectedStylesWithVariants.add({
598
+ label: "variants",
599
+ key: styleKey
600
+ });
601
+ }
602
+ }
603
+ if (valuePath.isArrowFunctionExpression()) {
604
+ if (t4.isObjectExpression(valuePath.node.body)) {
605
+ const hasVariants = valuePath.node.body.properties.some((innerProp) => {
606
+ return t4.isObjectProperty(innerProp) && t4.isIdentifier(innerProp.key) && innerProp.key.name === "variants";
607
+ });
608
+ if (hasVariants) {
609
+ detectedStylesWithVariants.add({
610
+ label: "variants",
611
+ key: styleKey
612
+ });
613
+ }
614
+ }
615
+ }
616
+ });
617
+ const detectedStylesWithTheme = /* @__PURE__ */ new Set();
618
+ themeNames.forEach(({ properties: properties2 }) => {
619
+ properties2.forEach((property) => {
620
+ const binding = funcPath.scope.getBinding(property);
621
+ if (!binding) {
622
+ return;
623
+ }
624
+ binding.referencePaths.forEach((refPath) => {
625
+ const containerProp = refPath.findParent(
626
+ (parent) => parent.isObjectProperty() && parent.parentPath === returnedObjectPath
627
+ );
628
+ if (!containerProp) {
629
+ return;
630
+ }
631
+ const keyNode = containerProp.get("key");
632
+ if (Array.isArray(keyNode)) {
633
+ return;
634
+ }
635
+ const keyValue = keyNode.isLiteral() ? keyNode.isStringLiteral() || keyNode.isNumericLiteral() || keyNode.isBooleanLiteral() ? String(keyNode.node.value) : null : null;
636
+ const styleKey = keyNode.isIdentifier() ? keyNode.node.name : keyValue;
637
+ if (styleKey) {
638
+ detectedStylesWithTheme.add({
639
+ label: "theme",
640
+ key: styleKey
641
+ });
642
+ }
643
+ });
644
+ });
645
+ });
646
+ const detectedStylesWithRt = /* @__PURE__ */ new Set();
647
+ const localRtName = t4.isIdentifier(rtParam) ? rtParam.name : void 0;
648
+ rtNames.forEach(({ properties: properties2, parent }) => {
649
+ properties2.forEach((property) => {
650
+ const rtBinding = funcPath.scope.getBinding(property);
651
+ if (!rtBinding) {
652
+ return;
653
+ }
654
+ const isValidDependency = Boolean(toUnistylesDependency(property));
655
+ let validRtName = property;
656
+ if (!isValidDependency && (!localRtName || localRtName && localRtName !== property)) {
657
+ if (!parent) {
658
+ return;
659
+ }
660
+ if (!toUnistylesDependency(parent)) {
661
+ return;
662
+ }
663
+ validRtName = parent;
664
+ }
665
+ rtBinding.referencePaths.forEach((refPath) => {
666
+ let usedLabel = validRtName;
667
+ if (refPath.parentPath?.isMemberExpression() && refPath.parentPath.get("object") === refPath) {
668
+ const memberExpr = refPath.parentPath;
669
+ const propPath = memberExpr.get("property");
670
+ if (propPath.isIdentifier()) {
671
+ if (localRtName) {
672
+ usedLabel = propPath.node.name;
673
+ }
674
+ if (usedLabel === "insets" && memberExpr.parentPath.isMemberExpression() && memberExpr.parentPath.get("object") === memberExpr) {
675
+ const secondPropPath = memberExpr.parentPath.get("property");
676
+ if (secondPropPath.isIdentifier() && secondPropPath.node.name === "ime") {
677
+ usedLabel = "ime";
678
+ }
679
+ }
680
+ if (usedLabel === "insets" && (memberExpr.parentPath.isBinaryExpression() || memberExpr.parentPath.isLogicalExpression())) {
681
+ const secondPropPath = memberExpr.node.property;
682
+ if (t4.isIdentifier(secondPropPath) && secondPropPath.name === "ime") {
683
+ usedLabel = "ime";
684
+ }
685
+ }
686
+ }
687
+ }
688
+ const containerProp = refPath.findParent(
689
+ (parent2) => parent2.isObjectProperty() && parent2.parentPath === returnedObjectPath
690
+ );
691
+ if (!containerProp) {
692
+ return;
693
+ }
694
+ const keyNode = containerProp.get("key");
695
+ if (Array.isArray(keyNode)) {
696
+ return;
697
+ }
698
+ const keyValue = keyNode.isLiteral() ? keyNode.isStringLiteral() || keyNode.isNumericLiteral() || keyNode.isBooleanLiteral() ? String(keyNode.node.value) : null : null;
699
+ const styleKey = keyNode.isIdentifier() ? keyNode.node.name : keyValue;
700
+ if (styleKey) {
701
+ detectedStylesWithRt.add({
702
+ label: usedLabel,
703
+ key: styleKey
704
+ });
705
+ }
706
+ });
707
+ });
708
+ });
709
+ const variants = Array.from(detectedStylesWithVariants);
710
+ const theme = Array.from(detectedStylesWithTheme);
711
+ const rt = Array.from(detectedStylesWithRt);
712
+ return theme.concat(rt).concat(variants).reduce((acc, { key, label }) => {
713
+ if (acc[key]) {
714
+ acc[key] = [...acc[key], label];
715
+ return acc;
716
+ }
717
+ acc[key] = [label];
718
+ return acc;
719
+ }, {});
720
+ }
721
+ function addDependencies(state, styleName, unistyle, detectedDependencies) {
722
+ const debugMessage = (deps, unsupportedReason) => {
723
+ if (state.opts.debug) {
724
+ const mappedDeps = deps.map(
725
+ (dep) => Object.keys(UnistyleDependency).find(
726
+ (key) => UnistyleDependency[key] === dep
727
+ )
728
+ ).join(", ");
729
+ const style = `${state.filename?.replace(`${state.file.opts.root}/`, "")}: styles.${styleName}`;
730
+ if (unsupportedReason) {
731
+ console.warn(
732
+ `Unistyles \u{1F984}: ${style}: detected [${mappedDeps}], but ${unsupportedReason}. Return an object literal, or a ternary/logical expression of object literals.`
733
+ );
734
+ return;
735
+ }
736
+ console.log(`${style}: [${mappedDeps}]`);
737
+ }
738
+ };
739
+ const styleDependencies = detectedDependencies.map(toUnistylesDependency);
740
+ if (styleDependencies.length > 0) {
741
+ const uniqueDependencies = Array.from(new Set(styleDependencies));
742
+ const targets = [];
743
+ const unsupported = [];
744
+ let unsupportedReturns = 0;
745
+ if (t4.isArrowFunctionExpression(unistyle.value) || t4.isFunctionExpression(unistyle.value)) {
746
+ if (t4.isBlockStatement(unistyle.value.body)) {
747
+ const returnStatements = getReturnStatementsFromBody(unistyle.value.body);
748
+ unsupportedReturns = countReturnStatements(unistyle.value.body) - returnStatements.length;
749
+ returnStatements.forEach((node) => {
750
+ if (t4.isIdentifier(node.argument)) {
751
+ node.argument = t4.objectExpression([t4.spreadElement(node.argument)]);
752
+ }
753
+ if (node.argument) {
754
+ collectReturnedObjects(node.argument, targets, unsupported);
755
+ }
756
+ });
757
+ } else {
758
+ collectReturnedObjects(unistyle.value.body, targets, unsupported);
759
+ }
760
+ } else if (t4.isMemberExpression(unistyle.value)) {
761
+ unistyle.value = t4.objectExpression([t4.spreadElement(unistyle.value)]);
762
+ targets.push(unistyle.value);
763
+ } else {
764
+ collectReturnedObjects(unistyle.value, targets, unsupported);
765
+ }
766
+ if (unsupported.length > 0 || unsupportedReturns > 0) {
767
+ const reasons = unsupported.map((node) => `${node.type}${node.loc ? ` (line ${node.loc.start.line})` : ""}`).concat(
768
+ unsupportedReturns > 0 ? `${unsupportedReturns} return statement(s) inside switch, loop or try blocks` : []
769
+ );
770
+ const consequence = targets.length > 0 ? "the style may not update when these dependencies change, eg. when one of these values is returned first" : "the style won't update when these dependencies change";
771
+ debugMessage(uniqueDependencies, `they can't be attached to: ${reasons.join(", ")}, so ${consequence}`);
772
+ } else if (targets.length === 0) {
773
+ debugMessage(
774
+ uniqueDependencies,
775
+ "no returned object was found to attach them to, so the style won't update when these dependencies change"
776
+ );
777
+ } else {
778
+ debugMessage(uniqueDependencies);
779
+ }
780
+ if (targets.length > 0) {
781
+ targets.forEach((target) => {
782
+ target.properties.push(
783
+ t4.objectProperty(
784
+ t4.identifier("uni__dependencies"),
785
+ t4.arrayExpression(
786
+ uniqueDependencies.filter((dep) => dep !== void 0 && dep !== null).map((dep) => t4.numericLiteral(dep))
787
+ )
788
+ )
789
+ );
790
+ });
791
+ }
792
+ }
793
+ }
794
+
795
+ // plugin/src/variants.ts
796
+ var t5 = __toESM(require("@babel/types"));
797
+ var scopedVariants = /* @__PURE__ */ new WeakMap();
798
+ function extractVariants(path3, state) {
799
+ const maybeVariants = path3.node.body.filter(
800
+ (node2) => t5.isExpressionStatement(node2) && t5.isCallExpression(node2.expression) && t5.isMemberExpression(node2.expression.callee)
801
+ );
802
+ if (maybeVariants.length === 0) {
803
+ return;
804
+ }
805
+ const targetVariant = maybeVariants.find((variant) => {
806
+ if (!t5.isExpressionStatement(variant) || !t5.isCallExpression(variant.expression) || !t5.isMemberExpression(variant.expression.callee) || !t5.isIdentifier(variant.expression.callee.object)) {
807
+ return false;
808
+ }
809
+ const calleeName2 = variant.expression.callee.object.name;
810
+ return t5.isIdentifier(variant.expression.callee.object, { name: calleeName2 }) && t5.isIdentifier(variant.expression.callee.property, { name: "useVariants" }) && variant.expression.arguments.length === 1;
811
+ });
812
+ if (!targetVariant) {
813
+ return;
814
+ }
815
+ const node = targetVariant.expression;
816
+ if (!t5.isCallExpression(node)) {
817
+ return;
818
+ }
819
+ const callee = node.callee;
820
+ if (!t5.isMemberExpression(callee) || !t5.isIdentifier(callee.object)) {
821
+ return;
822
+ }
823
+ const calleeName = callee.object.name;
824
+ const binding = path3.scope.getBinding(calleeName);
825
+ const existingShadowName = binding && t5.isVariableDeclarator(binding.path.node) ? scopedVariants.get(binding.path.node) : void 0;
826
+ const shadowName = existingShadowName ?? path3.scope.generateUidIdentifier(calleeName).name;
827
+ const newCallExpression = t5.callExpression(
828
+ t5.memberExpression(t5.identifier(shadowName), t5.identifier("useVariants")),
829
+ node.arguments
830
+ );
831
+ const finalDeclarator = t5.variableDeclarator(t5.identifier(calleeName), newCallExpression);
832
+ const finalDeclaration = t5.variableDeclaration("const", [finalDeclarator]);
833
+ scopedVariants.set(finalDeclarator, shadowName);
834
+ const pathIndex = path3.node.body.findIndex((bodyPath) => bodyPath === targetVariant);
835
+ const rest = path3.node.body.slice(pathIndex + 1);
836
+ const statement = t5.blockStatement([finalDeclaration, ...rest]);
837
+ state.file.hasVariants = true;
838
+ if (existingShadowName) {
839
+ path3.node.body = [...path3.node.body.slice(0, pathIndex), statement];
840
+ return;
841
+ }
842
+ const shadowDeclaration = t5.variableDeclaration("const", [
843
+ t5.variableDeclarator(t5.identifier(shadowName), t5.identifier(calleeName))
844
+ ]);
845
+ path3.node.body = [...path3.node.body.slice(0, pathIndex), shadowDeclaration, statement];
846
+ path3.scope.registerDeclaration(path3.get(`body.${pathIndex}`));
847
+ }
848
+
849
+ // plugin/src/index.ts
850
+ function src_default() {
851
+ if (process.env.NODE_ENV === "test") {
852
+ return {
853
+ name: "babel-react-native-unistyles",
854
+ visitor: {}
855
+ };
856
+ }
857
+ return {
858
+ name: "babel-react-native-unistyles",
859
+ visitor: {
860
+ Program: {
861
+ enter(path3, state) {
862
+ if (!state.opts.isMetro && process.env[METRO_UPSTREAM_TRANSFORMER_ENV]) {
863
+ throw new Error(
864
+ "Unistyles \u{1F984}: react-native-unistyles/metro is enabled in metro.config.js, remove react-native-unistyles/plugin from babel.config.js"
865
+ );
866
+ }
867
+ if (!state.opts.root && !state.opts.isMetro) {
868
+ throw new Error(
869
+ "Unistyles \u{1F984}: Babel plugin requires `root` option to be set. Please check https://www.unistyl.es/v3/other/babel-plugin#extra-configuration"
870
+ );
871
+ }
872
+ const appRoot = toPlatformPath(import_node_path2.default.join(state.file.opts.root, state.opts.root ?? ""));
873
+ if (!state.opts.isMetro && state.file.opts.root === appRoot) {
874
+ throw new Error(
875
+ "Unistyles \u{1F984}: Root option can't resolve to project root as it will include node_modules folder. Please check https://www.unistyl.es/v3/other/babel-plugin#extra-configuration"
876
+ );
877
+ }
878
+ state.file.replaceWithUnistyles = REPLACE_WITH_UNISTYLES_PATHS.concat(
879
+ state.opts.autoProcessPaths ?? []
880
+ ).map(toPlatformPath).some((path4) => state.filename?.includes(path4));
881
+ state.file.hasAnyUnistyle = false;
882
+ state.file.hasUnistylesImport = false;
883
+ state.file.addUnistylesRequire = false;
884
+ state.file.hasVariants = false;
885
+ state.file.styleSheetLocalName = "";
886
+ state.file.reactNativeCommonJSName = "";
887
+ state.reactNativeImports = {};
888
+ state.file.forceProcessing = state.opts.isMetro || (state.filename?.includes(appRoot) ?? false);
889
+ path3.traverse({
890
+ BlockStatement(blockPath) {
891
+ if (isInsideNodeModules(state)) {
892
+ return;
893
+ }
894
+ extractVariants(blockPath, state);
895
+ }
896
+ });
897
+ },
898
+ exit(path3, state) {
899
+ if (state.opts.isMetro || isInsideNodeModules(state)) {
900
+ return;
901
+ }
902
+ if (state.file.addUnistylesRequire) {
903
+ return addUnistylesRequire(path3, state);
904
+ }
905
+ if (state.file.hasAnyUnistyle || state.file.hasVariants || state.file.replaceWithUnistyles || state.file.forceProcessing) {
906
+ addUnistylesImport(path3, state);
907
+ }
908
+ }
909
+ },
910
+ FunctionDeclaration(path3, state) {
911
+ if (isInsideNodeModules(state)) {
912
+ return;
913
+ }
914
+ const componentName = path3.node.id ? path3.node.id.name : null;
915
+ if (componentName) {
916
+ state.file.hasVariants = false;
917
+ }
918
+ },
919
+ ClassDeclaration(path3, state) {
920
+ if (isInsideNodeModules(state)) {
921
+ return;
922
+ }
923
+ const componentName = path3.node.id ? path3.node.id.name : null;
924
+ if (componentName) {
925
+ state.file.hasVariants = false;
926
+ }
927
+ },
928
+ VariableDeclaration(path3, state) {
929
+ if (isInsideNodeModules(state)) {
930
+ return;
931
+ }
932
+ path3.node.declarations.forEach((declaration) => {
933
+ if (t6.isArrowFunctionExpression(declaration.init) || t6.isFunctionExpression(declaration.init)) {
934
+ const componentName = declaration.id && t6.isIdentifier(declaration.id) ? declaration.id.name : null;
935
+ if (componentName) {
936
+ state.file.hasVariants = false;
937
+ }
938
+ }
939
+ });
940
+ },
941
+ ImportDeclaration(path3, state) {
942
+ const exoticImport = state.opts.isMetro ? void 0 : REPLACE_WITH_UNISTYLES_EXOTIC_PATHS.concat(state.opts.autoRemapImports ?? []).find(
943
+ (exotic) => state.filename?.includes(exotic.path)
944
+ );
945
+ if (exoticImport) {
946
+ return handleExoticImport(path3, state, exoticImport);
947
+ }
948
+ if (isInsideNodeModules(state)) {
949
+ return;
950
+ }
951
+ const importSource = path3.node.source.value;
952
+ if (importSource.includes("react-native-unistyles")) {
953
+ state.file.hasUnistylesImport = true;
954
+ path3.node.specifiers.forEach((specifier) => {
955
+ if (t6.isImportSpecifier(specifier) && t6.isIdentifier(specifier.imported) && specifier.imported.name === "StyleSheet") {
956
+ state.file.styleSheetLocalName = specifier.local.name;
957
+ }
958
+ });
959
+ }
960
+ if (state.opts.isMetro) {
961
+ return;
962
+ }
963
+ if (importSource === "react-native") {
964
+ path3.node.specifiers.forEach((specifier) => {
965
+ if (t6.isImportSpecifier(specifier) && t6.isIdentifier(specifier.imported) && REACT_NATIVE_COMPONENT_NAMES.includes(specifier.imported.name)) {
966
+ state.reactNativeImports[specifier.local.name] = specifier.imported.name;
967
+ }
968
+ });
969
+ }
970
+ if (importSource === "react-native" || importSource.includes("react-native/Libraries")) {
971
+ handleExoticImport(path3, state, NATIVE_COMPONENTS_PATHS);
972
+ }
973
+ if (!state.file.forceProcessing && Array.isArray(state.opts.autoProcessImports)) {
974
+ state.file.forceProcessing = state.opts.autoProcessImports.includes(importSource);
975
+ }
976
+ },
977
+ JSXElement(path3, state) {
978
+ if (isInsideNodeModules(state)) {
979
+ return;
980
+ }
981
+ if (hasStringRef(path3)) {
982
+ throw new Error("Detected string based ref which is not supported by Unistyles.");
983
+ }
984
+ },
985
+ MemberExpression(path3, state) {
986
+ if (state.opts.isMetro || isInsideNodeModules(state)) {
987
+ return;
988
+ }
989
+ if (!state.file.reactNativeCommonJSName || !t6.isIdentifier(path3.node.object)) {
990
+ return;
991
+ }
992
+ if (path3.node.object.name !== state.file.reactNativeCommonJSName || !t6.isIdentifier(path3.node.property)) {
993
+ return;
994
+ }
995
+ if (!REACT_NATIVE_COMPONENT_NAMES.includes(path3.node.property.name)) {
996
+ return;
997
+ }
998
+ if (!state.reactNativeImports[path3.node.property.name]) {
999
+ const uniqueId = path3.scope.generateUidIdentifier(`reactNativeUnistyles_${path3.node.property.name}`);
1000
+ state.reactNativeImports[path3.node.property.name] = uniqueId.name;
1001
+ state.file.addUnistylesRequire = true;
1002
+ }
1003
+ path3.node.object.name = state.reactNativeImports[path3.node.property.name];
1004
+ },
1005
+ CallExpression(path3, state) {
1006
+ if (isInsideNodeModules(state)) {
1007
+ return;
1008
+ }
1009
+ if (isUnistylesCommonJSRequire(path3, state)) {
1010
+ return;
1011
+ }
1012
+ if (isReactNativeCommonJSRequire(path3, state)) {
1013
+ return;
1014
+ }
1015
+ if (!isUnistylesStyleSheet(path3, state) && !isKindOfStyleSheet(path3, state)) {
1016
+ return;
1017
+ }
1018
+ state.file.hasAnyUnistyle = true;
1019
+ const arg = t6.isAssignmentExpression(path3.node.arguments[0]) ? path3.node.arguments[0].right : path3.node.arguments[0];
1020
+ if (t6.isObjectExpression(arg)) {
1021
+ const detectedDependencies = getStylesDependenciesFromObject(path3);
1022
+ if (detectedDependencies) {
1023
+ if (t6.isObjectExpression(arg)) {
1024
+ arg.properties.forEach((property) => {
1025
+ if (!t6.isObjectProperty(property)) {
1026
+ return;
1027
+ }
1028
+ const styleKey = getStyleKeyName(property.key);
1029
+ if (styleKey && Object.prototype.hasOwnProperty.call(detectedDependencies, styleKey)) {
1030
+ addDependencies(state, styleKey, property, detectedDependencies[styleKey] ?? []);
1031
+ }
1032
+ });
1033
+ }
1034
+ }
1035
+ }
1036
+ if (t6.isArrowFunctionExpression(arg) || t6.isFunctionExpression(arg)) {
1037
+ const funcPath = t6.isAssignmentExpression(path3.node.arguments[0]) ? path3.get("arguments.0.right") : path3.get("arguments.0");
1038
+ const detectedDependencies = getStylesDependenciesFromFunction(funcPath);
1039
+ if (detectedDependencies) {
1040
+ const body = t6.isBlockStatement(arg.body) ? arg.body.body.find((statement) => t6.isReturnStatement(statement))?.argument : arg.body;
1041
+ if (t6.isObjectExpression(body)) {
1042
+ body.properties.forEach((property) => {
1043
+ if (!t6.isObjectProperty(property)) {
1044
+ return;
1045
+ }
1046
+ const styleKey = getStyleKeyName(property.key);
1047
+ if (styleKey && Object.prototype.hasOwnProperty.call(detectedDependencies, styleKey)) {
1048
+ addDependencies(state, styleKey, property, detectedDependencies[styleKey] ?? []);
1049
+ }
1050
+ });
1051
+ }
1052
+ }
1053
+ }
1054
+ }
1055
+ }
1056
+ };
1057
+ }
1058
+
1059
+ // metro/src/transformer.ts
1060
+ var MAYBE_UNISTYLES = /\.create\s*\(|\.useVariants\s*\(/;
1061
+ var createBabelTransformer = ({ upstream, options, unistylesRoot, path: path3 = import_node_path3.default }) => {
1062
+ const pluginItem = [src_default, { debug: options.debug, isMetro: true }, "react-native-unistyles"];
1063
+ const shouldProcess = ({ filename, src, options: { projectRoot } }) => {
1064
+ if (!MAYBE_UNISTYLES.test(src)) {
1065
+ return false;
1066
+ }
1067
+ const filePath = path3.resolve(projectRoot, filename);
1068
+ if (filePath.startsWith(`${unistylesRoot}${path3.sep}`)) {
1069
+ return false;
1070
+ }
1071
+ return !filePath.includes(`${path3.sep}node_modules${path3.sep}`) || src.includes("react-native-unistyles");
1072
+ };
1073
+ const transform2 = (args) => {
1074
+ if (!shouldProcess(args)) {
1075
+ return upstream.transform(args);
1076
+ }
1077
+ return upstream.transform({
1078
+ ...args,
1079
+ plugins: [...args.plugins ?? [], pluginItem]
1080
+ });
1081
+ };
1082
+ const getCacheKey2 = (...args) => upstream.getCacheKey?.(...args) ?? "";
1083
+ return { shouldProcess, transform: transform2, getCacheKey: getCacheKey2 };
1084
+ };
1085
+
1086
+ // metro/src/babel-transformer.ts
1087
+ var upstreamPath = process.env[METRO_UPSTREAM_TRANSFORMER_ENV];
1088
+ if (!upstreamPath) {
1089
+ throw new Error(
1090
+ "Unistyles \u{1F984}: react-native-unistyles/metro/babel-transformer can be only set by withUnistylesConfig in metro.config.js"
1091
+ );
1092
+ }
1093
+ var { transform, getCacheKey } = createBabelTransformer({
1094
+ upstream: require(upstreamPath),
1095
+ options: JSON.parse(process.env[METRO_OPTIONS_ENV] ?? "{}"),
1096
+ unistylesRoot: import_node_fs.default.realpathSync(import_node_path4.default.join(__dirname, ".."))
1097
+ });
1098
+ // Annotate the CommonJS export names for ESM import in node:
1099
+ 0 && (module.exports = {
1100
+ getCacheKey,
1101
+ transform
1102
+ });