react-native-unistyles 3.5.3 → 3.6.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 (283) hide show
  1. package/README.md +3 -0
  2. package/cxx/converters/BackgroundImageConverter.cpp +198 -11
  3. package/cxx/converters/BackgroundImageConverter.h +1 -0
  4. package/cxx/core/HostUnistyle.cpp +6 -0
  5. package/cxx/hybridObjects/HybridShadowRegistry.cpp +5 -0
  6. package/cxx/parser/Parser.cpp +29 -7
  7. package/ios/NativePlatform+ios.swift +22 -11
  8. package/ios/NativePlatformListener+ios.swift +9 -0
  9. package/lib/commonjs/components/native/deep/ActivityIndicator.js +19 -0
  10. package/lib/commonjs/components/native/deep/ActivityIndicator.js.map +1 -0
  11. package/lib/commonjs/components/native/deep/Animated.js +19 -0
  12. package/lib/commonjs/components/native/deep/Animated.js.map +1 -0
  13. package/lib/commonjs/components/native/deep/FlatList.js +19 -0
  14. package/lib/commonjs/components/native/deep/FlatList.js.map +1 -0
  15. package/lib/commonjs/components/native/deep/Image.js +19 -0
  16. package/lib/commonjs/components/native/deep/Image.js.map +1 -0
  17. package/lib/commonjs/components/native/deep/ImageBackground.js +19 -0
  18. package/lib/commonjs/components/native/deep/ImageBackground.js.map +1 -0
  19. package/lib/commonjs/components/native/deep/KeyboardAvoidingView.js +19 -0
  20. package/lib/commonjs/components/native/deep/KeyboardAvoidingView.js.map +1 -0
  21. package/lib/commonjs/components/native/deep/Pressable.js +19 -0
  22. package/lib/commonjs/components/native/deep/Pressable.js.map +1 -0
  23. package/lib/commonjs/components/native/deep/RefreshControl.js +19 -0
  24. package/lib/commonjs/components/native/deep/RefreshControl.js.map +1 -0
  25. package/lib/commonjs/components/native/deep/SafeAreaView.js +19 -0
  26. package/lib/commonjs/components/native/deep/SafeAreaView.js.map +1 -0
  27. package/lib/commonjs/components/native/deep/ScrollView.js +19 -0
  28. package/lib/commonjs/components/native/deep/ScrollView.js.map +1 -0
  29. package/lib/commonjs/components/native/deep/SectionList.js +19 -0
  30. package/lib/commonjs/components/native/deep/SectionList.js.map +1 -0
  31. package/lib/commonjs/components/native/deep/Switch.js +19 -0
  32. package/lib/commonjs/components/native/deep/Switch.js.map +1 -0
  33. package/lib/commonjs/components/native/deep/Text.js +19 -0
  34. package/lib/commonjs/components/native/deep/Text.js.map +1 -0
  35. package/lib/commonjs/components/native/deep/TextInput.js +19 -0
  36. package/lib/commonjs/components/native/deep/TextInput.js.map +1 -0
  37. package/lib/commonjs/components/native/deep/TextNativeComponent.js +28 -0
  38. package/lib/commonjs/components/native/deep/TextNativeComponent.js.map +1 -0
  39. package/lib/commonjs/components/native/deep/TouchableHighlight.js +19 -0
  40. package/lib/commonjs/components/native/deep/TouchableHighlight.js.map +1 -0
  41. package/lib/commonjs/components/native/deep/TouchableOpacity.js +19 -0
  42. package/lib/commonjs/components/native/deep/TouchableOpacity.js.map +1 -0
  43. package/lib/commonjs/components/native/deep/View.js +19 -0
  44. package/lib/commonjs/components/native/deep/View.js.map +1 -0
  45. package/lib/commonjs/components/native/deep/ViewNativeComponent.js +26 -0
  46. package/lib/commonjs/components/native/deep/ViewNativeComponent.js.map +1 -0
  47. package/lib/commonjs/components/native/deep/VirtualizedList.js +19 -0
  48. package/lib/commonjs/components/native/deep/VirtualizedList.js.map +1 -0
  49. package/lib/commonjs/components/native/index.js +43 -0
  50. package/lib/commonjs/components/native/index.js.map +1 -0
  51. package/lib/commonjs/core/createUnistylesActivityIndicator.js +13 -3
  52. package/lib/commonjs/core/createUnistylesActivityIndicator.js.map +1 -1
  53. package/lib/commonjs/core/createUnistylesElement.native.js +6 -0
  54. package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
  55. package/lib/commonjs/core/createUnistylesImageBackground.js +20 -17
  56. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
  57. package/lib/commonjs/core/createUnistylesTouchableHighlight.js +6 -0
  58. package/lib/commonjs/core/createUnistylesTouchableHighlight.js.map +1 -1
  59. package/lib/commonjs/core/getClassname.js +15 -0
  60. package/lib/commonjs/core/getClassname.js.map +1 -1
  61. package/lib/commonjs/core/hasUnistyles.js +26 -0
  62. package/lib/commonjs/core/hasUnistyles.js.map +1 -0
  63. package/lib/commonjs/specs/ShadowRegistry/index.js +57 -74
  64. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  65. package/lib/commonjs/specs/ShadowRegistry/styleSource.js +65 -0
  66. package/lib/commonjs/specs/ShadowRegistry/styleSource.js.map +1 -0
  67. package/lib/commonjs/unifiber/src/adapters/reanimated.js +157 -0
  68. package/lib/commonjs/unifiber/src/adapters/reanimated.js.map +1 -0
  69. package/lib/commonjs/unifiber/src/adapters/registry.js +67 -0
  70. package/lib/commonjs/unifiber/src/adapters/registry.js.map +1 -0
  71. package/lib/commonjs/unifiber/src/diagnostics.js +59 -0
  72. package/lib/commonjs/unifiber/src/diagnostics.js.map +1 -0
  73. package/lib/commonjs/unifiber/src/fiber.js +199 -0
  74. package/lib/commonjs/unifiber/src/fiber.js.map +1 -0
  75. package/lib/commonjs/unifiber/src/host.js +214 -0
  76. package/lib/commonjs/unifiber/src/host.js.map +1 -0
  77. package/lib/commonjs/unifiber/src/index.js +38 -0
  78. package/lib/commonjs/unifiber/src/index.js.map +1 -0
  79. package/lib/commonjs/web/utils/unistyle.js +11 -3
  80. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  81. package/lib/module/components/native/deep/ActivityIndicator.js +5 -0
  82. package/lib/module/components/native/deep/ActivityIndicator.js.map +1 -0
  83. package/lib/module/components/native/deep/Animated.js +5 -0
  84. package/lib/module/components/native/deep/Animated.js.map +1 -0
  85. package/lib/module/components/native/deep/FlatList.js +5 -0
  86. package/lib/module/components/native/deep/FlatList.js.map +1 -0
  87. package/lib/module/components/native/deep/Image.js +5 -0
  88. package/lib/module/components/native/deep/Image.js.map +1 -0
  89. package/lib/module/components/native/deep/ImageBackground.js +5 -0
  90. package/lib/module/components/native/deep/ImageBackground.js.map +1 -0
  91. package/lib/module/components/native/deep/KeyboardAvoidingView.js +5 -0
  92. package/lib/module/components/native/deep/KeyboardAvoidingView.js.map +1 -0
  93. package/lib/module/components/native/deep/Pressable.js +5 -0
  94. package/lib/module/components/native/deep/Pressable.js.map +1 -0
  95. package/lib/module/components/native/deep/RefreshControl.js +5 -0
  96. package/lib/module/components/native/deep/RefreshControl.js.map +1 -0
  97. package/lib/module/components/native/deep/SafeAreaView.js +5 -0
  98. package/lib/module/components/native/deep/SafeAreaView.js.map +1 -0
  99. package/lib/module/components/native/deep/ScrollView.js +5 -0
  100. package/lib/module/components/native/deep/ScrollView.js.map +1 -0
  101. package/lib/module/components/native/deep/SectionList.js +5 -0
  102. package/lib/module/components/native/deep/SectionList.js.map +1 -0
  103. package/lib/module/components/native/deep/Switch.js +5 -0
  104. package/lib/module/components/native/deep/Switch.js.map +1 -0
  105. package/lib/module/components/native/deep/Text.js +5 -0
  106. package/lib/module/components/native/deep/Text.js.map +1 -0
  107. package/lib/module/components/native/deep/TextInput.js +5 -0
  108. package/lib/module/components/native/deep/TextInput.js.map +1 -0
  109. package/lib/module/components/native/deep/TextNativeComponent.js +8 -0
  110. package/lib/module/components/native/deep/TextNativeComponent.js.map +1 -0
  111. package/lib/module/components/native/deep/TouchableHighlight.js +5 -0
  112. package/lib/module/components/native/deep/TouchableHighlight.js.map +1 -0
  113. package/lib/module/components/native/deep/TouchableOpacity.js +5 -0
  114. package/lib/module/components/native/deep/TouchableOpacity.js.map +1 -0
  115. package/lib/module/components/native/deep/View.js +5 -0
  116. package/lib/module/components/native/deep/View.js.map +1 -0
  117. package/lib/module/components/native/deep/ViewNativeComponent.js +8 -0
  118. package/lib/module/components/native/deep/ViewNativeComponent.js.map +1 -0
  119. package/lib/module/components/native/deep/VirtualizedList.js +5 -0
  120. package/lib/module/components/native/deep/VirtualizedList.js.map +1 -0
  121. package/lib/module/components/native/index.js +43 -0
  122. package/lib/module/components/native/index.js.map +1 -0
  123. package/lib/module/core/createUnistylesActivityIndicator.js +13 -3
  124. package/lib/module/core/createUnistylesActivityIndicator.js.map +1 -1
  125. package/lib/module/core/createUnistylesElement.native.js +6 -0
  126. package/lib/module/core/createUnistylesElement.native.js.map +1 -1
  127. package/lib/module/core/createUnistylesImageBackground.js +20 -17
  128. package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
  129. package/lib/module/core/createUnistylesTouchableHighlight.js +6 -0
  130. package/lib/module/core/createUnistylesTouchableHighlight.js.map +1 -1
  131. package/lib/module/core/getClassname.js +16 -1
  132. package/lib/module/core/getClassname.js.map +1 -1
  133. package/lib/module/core/hasUnistyles.js +21 -0
  134. package/lib/module/core/hasUnistyles.js.map +1 -0
  135. package/lib/module/specs/ShadowRegistry/index.js +57 -74
  136. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  137. package/lib/module/specs/ShadowRegistry/styleSource.js +60 -0
  138. package/lib/module/specs/ShadowRegistry/styleSource.js.map +1 -0
  139. package/lib/module/unifiber/src/adapters/reanimated.js +152 -0
  140. package/lib/module/unifiber/src/adapters/reanimated.js.map +1 -0
  141. package/lib/module/unifiber/src/adapters/registry.js +62 -0
  142. package/lib/module/unifiber/src/adapters/registry.js.map +1 -0
  143. package/lib/module/unifiber/src/diagnostics.js +52 -0
  144. package/lib/module/unifiber/src/diagnostics.js.map +1 -0
  145. package/lib/module/unifiber/src/fiber.js +183 -0
  146. package/lib/module/unifiber/src/fiber.js.map +1 -0
  147. package/lib/module/unifiber/src/host.js +191 -0
  148. package/lib/module/unifiber/src/host.js.map +1 -0
  149. package/lib/module/unifiber/src/index.js +33 -0
  150. package/lib/module/unifiber/src/index.js.map +1 -0
  151. package/lib/module/web/utils/unistyle.js +11 -3
  152. package/lib/module/web/utils/unistyle.js.map +1 -1
  153. package/lib/typescript/src/components/native/deep/ActivityIndicator.d.ts +2 -0
  154. package/lib/typescript/src/components/native/deep/ActivityIndicator.d.ts.map +1 -0
  155. package/lib/typescript/src/components/native/deep/Animated.d.ts +2 -0
  156. package/lib/typescript/src/components/native/deep/Animated.d.ts.map +1 -0
  157. package/lib/typescript/src/components/native/deep/FlatList.d.ts +2 -0
  158. package/lib/typescript/src/components/native/deep/FlatList.d.ts.map +1 -0
  159. package/lib/typescript/src/components/native/deep/Image.d.ts +2 -0
  160. package/lib/typescript/src/components/native/deep/Image.d.ts.map +1 -0
  161. package/lib/typescript/src/components/native/deep/ImageBackground.d.ts +2 -0
  162. package/lib/typescript/src/components/native/deep/ImageBackground.d.ts.map +1 -0
  163. package/lib/typescript/src/components/native/deep/KeyboardAvoidingView.d.ts +2 -0
  164. package/lib/typescript/src/components/native/deep/KeyboardAvoidingView.d.ts.map +1 -0
  165. package/lib/typescript/src/components/native/deep/Pressable.d.ts +2 -0
  166. package/lib/typescript/src/components/native/deep/Pressable.d.ts.map +1 -0
  167. package/lib/typescript/src/components/native/deep/RefreshControl.d.ts +2 -0
  168. package/lib/typescript/src/components/native/deep/RefreshControl.d.ts.map +1 -0
  169. package/lib/typescript/src/components/native/deep/SafeAreaView.d.ts +2 -0
  170. package/lib/typescript/src/components/native/deep/SafeAreaView.d.ts.map +1 -0
  171. package/lib/typescript/src/components/native/deep/ScrollView.d.ts +2 -0
  172. package/lib/typescript/src/components/native/deep/ScrollView.d.ts.map +1 -0
  173. package/lib/typescript/src/components/native/deep/SectionList.d.ts +2 -0
  174. package/lib/typescript/src/components/native/deep/SectionList.d.ts.map +1 -0
  175. package/lib/typescript/src/components/native/deep/Switch.d.ts +2 -0
  176. package/lib/typescript/src/components/native/deep/Switch.d.ts.map +1 -0
  177. package/lib/typescript/src/components/native/deep/Text.d.ts +2 -0
  178. package/lib/typescript/src/components/native/deep/Text.d.ts.map +1 -0
  179. package/lib/typescript/src/components/native/deep/TextInput.d.ts +2 -0
  180. package/lib/typescript/src/components/native/deep/TextInput.d.ts.map +1 -0
  181. package/lib/typescript/src/components/native/deep/TextNativeComponent.d.ts +3 -0
  182. package/lib/typescript/src/components/native/deep/TextNativeComponent.d.ts.map +1 -0
  183. package/lib/typescript/src/components/native/deep/TouchableHighlight.d.ts +2 -0
  184. package/lib/typescript/src/components/native/deep/TouchableHighlight.d.ts.map +1 -0
  185. package/lib/typescript/src/components/native/deep/TouchableOpacity.d.ts +2 -0
  186. package/lib/typescript/src/components/native/deep/TouchableOpacity.d.ts.map +1 -0
  187. package/lib/typescript/src/components/native/deep/View.d.ts +2 -0
  188. package/lib/typescript/src/components/native/deep/View.d.ts.map +1 -0
  189. package/lib/typescript/src/components/native/deep/ViewNativeComponent.d.ts +3 -0
  190. package/lib/typescript/src/components/native/deep/ViewNativeComponent.d.ts.map +1 -0
  191. package/lib/typescript/src/components/native/deep/VirtualizedList.d.ts +2 -0
  192. package/lib/typescript/src/components/native/deep/VirtualizedList.d.ts.map +1 -0
  193. package/lib/typescript/src/components/native/index.d.ts +4 -0
  194. package/lib/typescript/src/components/native/index.d.ts.map +1 -0
  195. package/lib/typescript/src/components/scopeChildren.d.ts +1 -1
  196. package/lib/typescript/src/core/createUnistylesActivityIndicator.d.ts.map +1 -1
  197. package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
  198. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
  199. package/lib/typescript/src/core/createUnistylesTouchableHighlight.d.ts.map +1 -1
  200. package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
  201. package/lib/typescript/src/core/hasUnistyles.d.ts +2 -0
  202. package/lib/typescript/src/core/hasUnistyles.d.ts.map +1 -0
  203. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  204. package/lib/typescript/src/specs/ShadowRegistry/styleSource.d.ts +11 -0
  205. package/lib/typescript/src/specs/ShadowRegistry/styleSource.d.ts.map +1 -0
  206. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +4 -41
  207. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
  208. package/lib/typescript/src/unifiber/src/adapters/reanimated.d.ts +17 -0
  209. package/lib/typescript/src/unifiber/src/adapters/reanimated.d.ts.map +1 -0
  210. package/lib/typescript/src/unifiber/src/adapters/registry.d.ts +23 -0
  211. package/lib/typescript/src/unifiber/src/adapters/registry.d.ts.map +1 -0
  212. package/lib/typescript/src/unifiber/src/diagnostics.d.ts +10 -0
  213. package/lib/typescript/src/unifiber/src/diagnostics.d.ts.map +1 -0
  214. package/lib/typescript/src/unifiber/src/fiber.d.ts +48 -0
  215. package/lib/typescript/src/unifiber/src/fiber.d.ts.map +1 -0
  216. package/lib/typescript/src/unifiber/src/host.d.ts +32 -0
  217. package/lib/typescript/src/unifiber/src/host.d.ts.map +1 -0
  218. package/lib/typescript/src/unifiber/src/index.d.ts +49 -0
  219. package/lib/typescript/src/unifiber/src/index.d.ts.map +1 -0
  220. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  221. package/metro/babel-transformer.js +1040 -0
  222. package/metro/index.d.ts +31 -0
  223. package/metro/index.js +170 -0
  224. package/package.json +26 -8
  225. package/plugin/index.d.ts +7 -0
  226. package/plugin/index.js +36 -16
  227. package/src/components/native/deep/ActivityIndicator.ts +2 -0
  228. package/src/components/native/deep/Animated.ts +2 -0
  229. package/src/components/native/deep/FlatList.ts +2 -0
  230. package/src/components/native/deep/Image.ts +2 -0
  231. package/src/components/native/deep/ImageBackground.ts +2 -0
  232. package/src/components/native/deep/KeyboardAvoidingView.ts +2 -0
  233. package/src/components/native/deep/Pressable.ts +2 -0
  234. package/src/components/native/deep/RefreshControl.ts +2 -0
  235. package/src/components/native/deep/SafeAreaView.ts +2 -0
  236. package/src/components/native/deep/ScrollView.ts +2 -0
  237. package/src/components/native/deep/SectionList.ts +2 -0
  238. package/src/components/native/deep/Switch.ts +2 -0
  239. package/src/components/native/deep/Text.ts +2 -0
  240. package/src/components/native/deep/TextInput.ts +2 -0
  241. package/src/components/native/deep/TextNativeComponent.ts +5 -0
  242. package/src/components/native/deep/TouchableHighlight.ts +2 -0
  243. package/src/components/native/deep/TouchableOpacity.ts +2 -0
  244. package/src/components/native/deep/View.ts +2 -0
  245. package/src/components/native/deep/ViewNativeComponent.ts +5 -0
  246. package/src/components/native/deep/VirtualizedList.ts +2 -0
  247. package/src/components/native/index.ts +41 -0
  248. package/src/core/createUnistylesActivityIndicator.tsx +11 -4
  249. package/src/core/createUnistylesElement.native.tsx +5 -0
  250. package/src/core/createUnistylesImageBackground.tsx +27 -23
  251. package/src/core/createUnistylesTouchableHighlight.tsx +5 -0
  252. package/src/core/getClassname.ts +10 -1
  253. package/src/core/hasUnistyles.ts +20 -0
  254. package/src/specs/ShadowRegistry/index.ts +50 -102
  255. package/src/specs/ShadowRegistry/styleSource.ts +78 -0
  256. package/src/specs/ShadowRegistry/types.ts +3 -43
  257. package/src/unifiber/LICENSE +21 -0
  258. package/src/unifiber/README.md +92 -0
  259. package/src/unifiber/src/adapters/reanimated.ts +204 -0
  260. package/src/unifiber/src/adapters/registry.ts +102 -0
  261. package/src/unifiber/src/diagnostics.ts +55 -0
  262. package/src/unifiber/src/fiber.ts +262 -0
  263. package/src/unifiber/src/host.ts +236 -0
  264. package/src/unifiber/src/index.ts +43 -0
  265. package/src/web/utils/unistyle.ts +12 -3
  266. package/lib/typescript/src/__tests__/mocks.spec.d.ts +0 -2
  267. package/lib/typescript/src/__tests__/mocks.spec.d.ts.map +0 -1
  268. package/lib/typescript/src/__tests__/passForwardRef.spec.d.ts +0 -2
  269. package/lib/typescript/src/__tests__/passForwardRef.spec.d.ts.map +0 -1
  270. package/lib/typescript/src/__tests__/scoped-theme.spec.d.ts +0 -2
  271. package/lib/typescript/src/__tests__/scoped-theme.spec.d.ts.map +0 -1
  272. package/lib/typescript/src/__tests__/shadow-registry.spec.d.ts +0 -2
  273. package/lib/typescript/src/__tests__/shadow-registry.spec.d.ts.map +0 -1
  274. package/lib/typescript/src/__tests__/web-child-selector.spec.d.ts +0 -2
  275. package/lib/typescript/src/__tests__/web-child-selector.spec.d.ts.map +0 -1
  276. package/lib/typescript/src/__tests__/web-listener.spec.d.ts +0 -2
  277. package/lib/typescript/src/__tests__/web-listener.spec.d.ts.map +0 -1
  278. package/lib/typescript/src/__tests__/web-pointer-events.spec.d.ts +0 -2
  279. package/lib/typescript/src/__tests__/web-pointer-events.spec.d.ts.map +0 -1
  280. package/lib/typescript/src/__tests__/web-runtime.spec.d.ts +0 -2
  281. package/lib/typescript/src/__tests__/web-runtime.spec.d.ts.map +0 -1
  282. package/lib/typescript/src/__tests__/withUnistyles.spec.d.ts +0 -2
  283. package/lib/typescript/src/__tests__/withUnistyles.spec.d.ts.map +0 -1
@@ -0,0 +1,1040 @@
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 isUnistylesStyleSheet(path3, state) {
368
+ const { callee } = path3.node;
369
+ if (!t4.isMemberExpression(callee) || !t4.isIdentifier(callee.property)) {
370
+ return false;
371
+ }
372
+ const isImport = callee.property.name === "create" && t4.isIdentifier(callee.object) && callee.object.name === state.file.styleSheetLocalName;
373
+ 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";
374
+ return isImport || isRequire;
375
+ }
376
+ function isUnistylesCommonJSRequire(path3, state) {
377
+ 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";
378
+ if (isRequire && t4.isVariableDeclarator(path3.parent) && t4.isIdentifier(path3.parent.id)) {
379
+ state.file.hasUnistylesImport = true;
380
+ state.file.styleSheetLocalName = path3.parent.id.name;
381
+ }
382
+ return isRequire;
383
+ }
384
+ function isReactNativeCommonJSRequire(path3, state) {
385
+ const isRequire = t4.isIdentifier(path3.node.callee) && path3.node.arguments.length > 0 && path3.node.callee.name === "require";
386
+ const requireImportName = path3.node.arguments.find((node) => t4.isStringLiteral(node));
387
+ const isReactNativeRequire = isRequire && requireImportName && (requireImportName.value === "react-native" || requireImportName.value === "react-native-web/dist/index");
388
+ if (isReactNativeRequire && t4.isVariableDeclarator(path3.parent) && t4.isIdentifier(path3.parent.id)) {
389
+ state.file.reactNativeCommonJSName = path3.parent.id.name;
390
+ }
391
+ return isRequire;
392
+ }
393
+ function isKindOfStyleSheet(path3, state) {
394
+ if (!state.file.forceProcessing && !state.file.hasUnistylesImport) {
395
+ return false;
396
+ }
397
+ if (path3.node.arguments.length !== 1) {
398
+ return false;
399
+ }
400
+ const { callee } = path3.node;
401
+ const isCreateCall = t4.isMemberExpression(callee) && t4.isIdentifier(callee.property) && callee.property.name === "create" && (t4.isIdentifier(callee.object) || t4.isMemberExpression(callee.object));
402
+ if (!isCreateCall) {
403
+ return false;
404
+ }
405
+ const argument = path3.node.arguments[0];
406
+ if (t4.isArrowFunctionExpression(argument)) {
407
+ if (argument.params.length > 2) {
408
+ return false;
409
+ }
410
+ if (t4.isObjectExpression(argument.body) && argument.body.properties.length > 0) {
411
+ return true;
412
+ }
413
+ if (t4.isBlockStatement(argument.body)) {
414
+ const returnStatements = getReturnStatementsFromBody(argument.body);
415
+ return returnStatements.some(
416
+ (ret) => ret.argument && t4.isObjectExpression(ret.argument) && ret.argument.properties.length > 0
417
+ );
418
+ }
419
+ return false;
420
+ }
421
+ if (t4.isObjectExpression(argument)) {
422
+ return argument.properties.some(
423
+ (property) => t4.isObjectProperty(property) && t4.isObjectExpression(property.value)
424
+ );
425
+ }
426
+ return false;
427
+ }
428
+ function getStylesDependenciesFromObject(path3) {
429
+ const detectedStylesWithVariants = /* @__PURE__ */ new Set();
430
+ const stylesheet = path3.node.arguments[0];
431
+ if (t4.isObjectExpression(stylesheet)) {
432
+ stylesheet?.properties.forEach((property) => {
433
+ if (!t4.isObjectProperty(property)) {
434
+ return;
435
+ }
436
+ const styleKey = getStyleKeyName(property.key);
437
+ if (!styleKey) {
438
+ return;
439
+ }
440
+ if (t4.isObjectExpression(property.value)) {
441
+ property.value.properties.forEach((innerProp) => {
442
+ if (t4.isObjectProperty(innerProp) && t4.isIdentifier(innerProp.key) && innerProp.key.name === "variants") {
443
+ detectedStylesWithVariants.add({
444
+ label: "variants",
445
+ key: styleKey
446
+ });
447
+ }
448
+ });
449
+ }
450
+ if (t4.isArrowFunctionExpression(property.value)) {
451
+ if (t4.isObjectExpression(property.value.body)) {
452
+ property.value.body.properties.forEach((innerProp) => {
453
+ if (t4.isObjectProperty(innerProp) && t4.isIdentifier(innerProp.key) && innerProp.key.name === "variants") {
454
+ detectedStylesWithVariants.add({
455
+ label: "variants",
456
+ key: styleKey
457
+ });
458
+ }
459
+ });
460
+ }
461
+ }
462
+ });
463
+ }
464
+ const variants = Array.from(detectedStylesWithVariants);
465
+ return variants.reduce((acc, { key, label }) => {
466
+ if (acc[key]) {
467
+ acc[key] = [...acc[key], label];
468
+ return acc;
469
+ }
470
+ acc[key] = [label];
471
+ return acc;
472
+ }, {});
473
+ }
474
+ function getStylesDependenciesFromFunction(funcPath) {
475
+ if (!funcPath) {
476
+ return;
477
+ }
478
+ if (Array.isArray(funcPath)) {
479
+ return;
480
+ }
481
+ if (!t4.isFunctionExpression(funcPath.node) && !t4.isArrowFunctionExpression(funcPath.node)) {
482
+ return;
483
+ }
484
+ const params = funcPath.node.params;
485
+ const [themeParam, rtParam] = params;
486
+ const themeNames = [];
487
+ if (t4.isObjectPattern(themeParam)) {
488
+ for (const prop of themeParam.properties) {
489
+ const property = getProperty(prop);
490
+ if (property) {
491
+ themeNames.push(property);
492
+ }
493
+ }
494
+ }
495
+ if (t4.isIdentifier(themeParam)) {
496
+ themeNames.push({
497
+ properties: [themeParam.name]
498
+ });
499
+ }
500
+ const rtNames = [];
501
+ if (t4.isObjectPattern(rtParam)) {
502
+ for (const prop of rtParam.properties) {
503
+ const property = getProperty(prop);
504
+ if (property) {
505
+ rtNames.push(property);
506
+ }
507
+ }
508
+ }
509
+ if (t4.isIdentifier(rtParam)) {
510
+ rtNames.push({
511
+ properties: [rtParam.name]
512
+ });
513
+ }
514
+ let returnedObjectPath = null;
515
+ if (t4.isObjectExpression(funcPath.node.body)) {
516
+ returnedObjectPath = funcPath.get("body");
517
+ } else {
518
+ funcPath.traverse({
519
+ ReturnStatement(retPath) {
520
+ if (!returnedObjectPath && retPath.get("argument").isObjectExpression()) {
521
+ const argumentPath = retPath.get("argument");
522
+ if (argumentPath.isObjectExpression()) {
523
+ returnedObjectPath = argumentPath;
524
+ }
525
+ }
526
+ }
527
+ });
528
+ }
529
+ if (!returnedObjectPath) {
530
+ return;
531
+ }
532
+ const detectedStylesWithVariants = /* @__PURE__ */ new Set();
533
+ const properties = returnedObjectPath.get("properties");
534
+ properties.forEach((propPath) => {
535
+ const stylePath = propPath.get("key");
536
+ if (Array.isArray(stylePath)) {
537
+ return;
538
+ }
539
+ const styleKey = getStyleKeyName(stylePath.node);
540
+ if (!styleKey) {
541
+ return;
542
+ }
543
+ const valuePath = propPath.get("value");
544
+ if (Array.isArray(valuePath)) {
545
+ return;
546
+ }
547
+ if (valuePath.isObjectExpression()) {
548
+ const hasVariants = valuePath.get("properties").some((innerProp) => {
549
+ const innerKey = innerProp.get("key");
550
+ if (Array.isArray(innerKey)) {
551
+ return;
552
+ }
553
+ return innerKey.isIdentifier() && innerKey.node.name === "variants";
554
+ });
555
+ if (hasVariants) {
556
+ detectedStylesWithVariants.add({
557
+ label: "variants",
558
+ key: styleKey
559
+ });
560
+ }
561
+ }
562
+ if (valuePath.isArrowFunctionExpression()) {
563
+ if (t4.isObjectExpression(valuePath.node.body)) {
564
+ const hasVariants = valuePath.node.body.properties.some((innerProp) => {
565
+ return t4.isObjectProperty(innerProp) && t4.isIdentifier(innerProp.key) && innerProp.key.name === "variants";
566
+ });
567
+ if (hasVariants) {
568
+ detectedStylesWithVariants.add({
569
+ label: "variants",
570
+ key: styleKey
571
+ });
572
+ }
573
+ }
574
+ }
575
+ });
576
+ const detectedStylesWithTheme = /* @__PURE__ */ new Set();
577
+ themeNames.forEach(({ properties: properties2 }) => {
578
+ properties2.forEach((property) => {
579
+ const binding = funcPath.scope.getBinding(property);
580
+ if (!binding) {
581
+ return;
582
+ }
583
+ binding.referencePaths.forEach((refPath) => {
584
+ const containerProp = refPath.findParent(
585
+ (parent) => parent.isObjectProperty() && parent.parentPath === returnedObjectPath
586
+ );
587
+ if (!containerProp) {
588
+ return;
589
+ }
590
+ const keyNode = containerProp.get("key");
591
+ if (Array.isArray(keyNode)) {
592
+ return;
593
+ }
594
+ const keyValue = keyNode.isLiteral() ? keyNode.isStringLiteral() || keyNode.isNumericLiteral() || keyNode.isBooleanLiteral() ? String(keyNode.node.value) : null : null;
595
+ const styleKey = keyNode.isIdentifier() ? keyNode.node.name : keyValue;
596
+ if (styleKey) {
597
+ detectedStylesWithTheme.add({
598
+ label: "theme",
599
+ key: styleKey
600
+ });
601
+ }
602
+ });
603
+ });
604
+ });
605
+ const detectedStylesWithRt = /* @__PURE__ */ new Set();
606
+ const localRtName = t4.isIdentifier(rtParam) ? rtParam.name : void 0;
607
+ rtNames.forEach(({ properties: properties2, parent }) => {
608
+ properties2.forEach((property) => {
609
+ const rtBinding = funcPath.scope.getBinding(property);
610
+ if (!rtBinding) {
611
+ return;
612
+ }
613
+ const isValidDependency = Boolean(toUnistylesDependency(property));
614
+ let validRtName = property;
615
+ if (!isValidDependency && (!localRtName || localRtName && localRtName !== property)) {
616
+ if (!parent) {
617
+ return;
618
+ }
619
+ if (!toUnistylesDependency(parent)) {
620
+ return;
621
+ }
622
+ validRtName = parent;
623
+ }
624
+ rtBinding.referencePaths.forEach((refPath) => {
625
+ let usedLabel = validRtName;
626
+ if (refPath.parentPath?.isMemberExpression() && refPath.parentPath.get("object") === refPath) {
627
+ const memberExpr = refPath.parentPath;
628
+ const propPath = memberExpr.get("property");
629
+ if (propPath.isIdentifier()) {
630
+ if (localRtName) {
631
+ usedLabel = propPath.node.name;
632
+ }
633
+ if (usedLabel === "insets" && memberExpr.parentPath.isMemberExpression() && memberExpr.parentPath.get("object") === memberExpr) {
634
+ const secondPropPath = memberExpr.parentPath.get("property");
635
+ if (secondPropPath.isIdentifier() && secondPropPath.node.name === "ime") {
636
+ usedLabel = "ime";
637
+ }
638
+ }
639
+ if (usedLabel === "insets" && (memberExpr.parentPath.isBinaryExpression() || memberExpr.parentPath.isLogicalExpression())) {
640
+ const secondPropPath = memberExpr.node.property;
641
+ if (t4.isIdentifier(secondPropPath) && secondPropPath.name === "ime") {
642
+ usedLabel = "ime";
643
+ }
644
+ }
645
+ }
646
+ }
647
+ const containerProp = refPath.findParent(
648
+ (parent2) => parent2.isObjectProperty() && parent2.parentPath === returnedObjectPath
649
+ );
650
+ if (!containerProp) {
651
+ return;
652
+ }
653
+ const keyNode = containerProp.get("key");
654
+ if (Array.isArray(keyNode)) {
655
+ return;
656
+ }
657
+ const keyValue = keyNode.isLiteral() ? keyNode.isStringLiteral() || keyNode.isNumericLiteral() || keyNode.isBooleanLiteral() ? String(keyNode.node.value) : null : null;
658
+ const styleKey = keyNode.isIdentifier() ? keyNode.node.name : keyValue;
659
+ if (styleKey) {
660
+ detectedStylesWithRt.add({
661
+ label: usedLabel,
662
+ key: styleKey
663
+ });
664
+ }
665
+ });
666
+ });
667
+ });
668
+ const variants = Array.from(detectedStylesWithVariants);
669
+ const theme = Array.from(detectedStylesWithTheme);
670
+ const rt = Array.from(detectedStylesWithRt);
671
+ return theme.concat(rt).concat(variants).reduce((acc, { key, label }) => {
672
+ if (acc[key]) {
673
+ acc[key] = [...acc[key], label];
674
+ return acc;
675
+ }
676
+ acc[key] = [label];
677
+ return acc;
678
+ }, {});
679
+ }
680
+ function addDependencies(state, styleName, unistyle, detectedDependencies) {
681
+ const debugMessage = (deps) => {
682
+ if (state.opts.debug) {
683
+ const mappedDeps = deps.map(
684
+ (dep) => Object.keys(UnistyleDependency).find(
685
+ (key) => UnistyleDependency[key] === dep
686
+ )
687
+ ).join(", ");
688
+ console.log(
689
+ `${state.filename?.replace(`${state.file.opts.root}/`, "")}: styles.${styleName}: [${mappedDeps}]`
690
+ );
691
+ }
692
+ };
693
+ const styleDependencies = detectedDependencies.map(toUnistylesDependency);
694
+ if (styleDependencies.length > 0) {
695
+ const uniqueDependencies = Array.from(new Set(styleDependencies));
696
+ debugMessage(uniqueDependencies);
697
+ let targets = [];
698
+ if (t4.isArrowFunctionExpression(unistyle.value) || t4.isFunctionExpression(unistyle.value)) {
699
+ if (t4.isObjectExpression(unistyle.value.body)) {
700
+ targets.push(unistyle.value.body);
701
+ }
702
+ if (t4.isBlockStatement(unistyle.value.body)) {
703
+ targets = getReturnStatementsFromBody(unistyle.value.body).map((node) => {
704
+ if (t4.isIdentifier(node.argument)) {
705
+ node.argument = t4.objectExpression([t4.spreadElement(node.argument)]);
706
+ }
707
+ return node.argument;
708
+ }).filter((node) => t4.isObjectExpression(node));
709
+ }
710
+ }
711
+ if (t4.isObjectExpression(unistyle.value)) {
712
+ targets.push(unistyle.value);
713
+ }
714
+ if (t4.isMemberExpression(unistyle.value)) {
715
+ unistyle.value = t4.objectExpression([t4.spreadElement(unistyle.value)]);
716
+ targets.push(unistyle.value);
717
+ }
718
+ if (targets.length > 0) {
719
+ targets.forEach((target) => {
720
+ target.properties.push(
721
+ t4.objectProperty(
722
+ t4.identifier("uni__dependencies"),
723
+ t4.arrayExpression(
724
+ uniqueDependencies.filter((dep) => dep !== void 0 && dep !== null).map((dep) => t4.numericLiteral(dep))
725
+ )
726
+ )
727
+ );
728
+ });
729
+ }
730
+ }
731
+ }
732
+
733
+ // plugin/src/variants.ts
734
+ var t5 = __toESM(require("@babel/types"));
735
+ var scopedVariants = /* @__PURE__ */ new WeakMap();
736
+ function extractVariants(path3, state) {
737
+ const maybeVariants = path3.node.body.filter(
738
+ (node2) => t5.isExpressionStatement(node2) && t5.isCallExpression(node2.expression) && t5.isMemberExpression(node2.expression.callee)
739
+ );
740
+ if (maybeVariants.length === 0) {
741
+ return;
742
+ }
743
+ const targetVariant = maybeVariants.find((variant) => {
744
+ if (!t5.isExpressionStatement(variant) || !t5.isCallExpression(variant.expression) || !t5.isMemberExpression(variant.expression.callee) || !t5.isIdentifier(variant.expression.callee.object)) {
745
+ return false;
746
+ }
747
+ const calleeName2 = variant.expression.callee.object.name;
748
+ return t5.isIdentifier(variant.expression.callee.object, { name: calleeName2 }) && t5.isIdentifier(variant.expression.callee.property, { name: "useVariants" }) && variant.expression.arguments.length === 1;
749
+ });
750
+ if (!targetVariant) {
751
+ return;
752
+ }
753
+ const node = targetVariant.expression;
754
+ if (!t5.isCallExpression(node)) {
755
+ return;
756
+ }
757
+ const callee = node.callee;
758
+ if (!t5.isMemberExpression(callee) || !t5.isIdentifier(callee.object)) {
759
+ return;
760
+ }
761
+ const calleeName = callee.object.name;
762
+ const binding = path3.scope.getBinding(calleeName);
763
+ const existingShadowName = binding && t5.isVariableDeclarator(binding.path.node) ? scopedVariants.get(binding.path.node) : void 0;
764
+ const shadowName = existingShadowName ?? path3.scope.generateUidIdentifier(calleeName).name;
765
+ const newCallExpression = t5.callExpression(
766
+ t5.memberExpression(t5.identifier(shadowName), t5.identifier("useVariants")),
767
+ node.arguments
768
+ );
769
+ const finalDeclarator = t5.variableDeclarator(t5.identifier(calleeName), newCallExpression);
770
+ const finalDeclaration = t5.variableDeclaration("const", [finalDeclarator]);
771
+ scopedVariants.set(finalDeclarator, shadowName);
772
+ const pathIndex = path3.node.body.findIndex((bodyPath) => bodyPath === targetVariant);
773
+ const rest = path3.node.body.slice(pathIndex + 1);
774
+ const statement = t5.blockStatement([finalDeclaration, ...rest]);
775
+ state.file.hasVariants = true;
776
+ if (existingShadowName) {
777
+ path3.node.body = [...path3.node.body.slice(0, pathIndex), statement];
778
+ return;
779
+ }
780
+ const shadowDeclaration = t5.variableDeclaration("const", [
781
+ t5.variableDeclarator(t5.identifier(shadowName), t5.identifier(calleeName))
782
+ ]);
783
+ path3.node.body = [...path3.node.body.slice(0, pathIndex), shadowDeclaration, statement];
784
+ path3.scope.registerDeclaration(path3.get(`body.${pathIndex}`));
785
+ }
786
+
787
+ // plugin/src/index.ts
788
+ function src_default() {
789
+ if (process.env.NODE_ENV === "test") {
790
+ return {
791
+ name: "babel-react-native-unistyles",
792
+ visitor: {}
793
+ };
794
+ }
795
+ return {
796
+ name: "babel-react-native-unistyles",
797
+ visitor: {
798
+ Program: {
799
+ enter(path3, state) {
800
+ if (!state.opts.isMetro && process.env[METRO_UPSTREAM_TRANSFORMER_ENV]) {
801
+ throw new Error(
802
+ "Unistyles \u{1F984}: react-native-unistyles/metro is enabled in metro.config.js, remove react-native-unistyles/plugin from babel.config.js"
803
+ );
804
+ }
805
+ if (!state.opts.root && !state.opts.isMetro) {
806
+ throw new Error(
807
+ "Unistyles \u{1F984}: Babel plugin requires `root` option to be set. Please check https://www.unistyl.es/v3/other/babel-plugin#extra-configuration"
808
+ );
809
+ }
810
+ const appRoot = toPlatformPath(import_node_path2.default.join(state.file.opts.root, state.opts.root ?? ""));
811
+ if (!state.opts.isMetro && state.file.opts.root === appRoot) {
812
+ throw new Error(
813
+ "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"
814
+ );
815
+ }
816
+ state.file.replaceWithUnistyles = REPLACE_WITH_UNISTYLES_PATHS.concat(
817
+ state.opts.autoProcessPaths ?? []
818
+ ).map(toPlatformPath).some((path4) => state.filename?.includes(path4));
819
+ state.file.hasAnyUnistyle = false;
820
+ state.file.hasUnistylesImport = false;
821
+ state.file.addUnistylesRequire = false;
822
+ state.file.hasVariants = false;
823
+ state.file.styleSheetLocalName = "";
824
+ state.file.reactNativeCommonJSName = "";
825
+ state.reactNativeImports = {};
826
+ state.file.forceProcessing = state.opts.isMetro || (state.filename?.includes(appRoot) ?? false);
827
+ path3.traverse({
828
+ BlockStatement(blockPath) {
829
+ if (isInsideNodeModules(state)) {
830
+ return;
831
+ }
832
+ extractVariants(blockPath, state);
833
+ }
834
+ });
835
+ },
836
+ exit(path3, state) {
837
+ if (state.opts.isMetro || isInsideNodeModules(state)) {
838
+ return;
839
+ }
840
+ if (state.file.addUnistylesRequire) {
841
+ return addUnistylesRequire(path3, state);
842
+ }
843
+ if (state.file.hasAnyUnistyle || state.file.hasVariants || state.file.replaceWithUnistyles || state.file.forceProcessing) {
844
+ addUnistylesImport(path3, state);
845
+ }
846
+ }
847
+ },
848
+ FunctionDeclaration(path3, state) {
849
+ if (isInsideNodeModules(state)) {
850
+ return;
851
+ }
852
+ const componentName = path3.node.id ? path3.node.id.name : null;
853
+ if (componentName) {
854
+ state.file.hasVariants = false;
855
+ }
856
+ },
857
+ ClassDeclaration(path3, state) {
858
+ if (isInsideNodeModules(state)) {
859
+ return;
860
+ }
861
+ const componentName = path3.node.id ? path3.node.id.name : null;
862
+ if (componentName) {
863
+ state.file.hasVariants = false;
864
+ }
865
+ },
866
+ VariableDeclaration(path3, state) {
867
+ if (isInsideNodeModules(state)) {
868
+ return;
869
+ }
870
+ path3.node.declarations.forEach((declaration) => {
871
+ if (t6.isArrowFunctionExpression(declaration.init) || t6.isFunctionExpression(declaration.init)) {
872
+ const componentName = declaration.id && t6.isIdentifier(declaration.id) ? declaration.id.name : null;
873
+ if (componentName) {
874
+ state.file.hasVariants = false;
875
+ }
876
+ }
877
+ });
878
+ },
879
+ ImportDeclaration(path3, state) {
880
+ const exoticImport = state.opts.isMetro ? void 0 : REPLACE_WITH_UNISTYLES_EXOTIC_PATHS.concat(state.opts.autoRemapImports ?? []).find(
881
+ (exotic) => state.filename?.includes(exotic.path)
882
+ );
883
+ if (exoticImport) {
884
+ return handleExoticImport(path3, state, exoticImport);
885
+ }
886
+ if (isInsideNodeModules(state)) {
887
+ return;
888
+ }
889
+ const importSource = path3.node.source.value;
890
+ if (importSource.includes("react-native-unistyles")) {
891
+ state.file.hasUnistylesImport = true;
892
+ path3.node.specifiers.forEach((specifier) => {
893
+ if (t6.isImportSpecifier(specifier) && t6.isIdentifier(specifier.imported) && specifier.imported.name === "StyleSheet") {
894
+ state.file.styleSheetLocalName = specifier.local.name;
895
+ }
896
+ });
897
+ }
898
+ if (state.opts.isMetro) {
899
+ return;
900
+ }
901
+ if (importSource === "react-native") {
902
+ path3.node.specifiers.forEach((specifier) => {
903
+ if (t6.isImportSpecifier(specifier) && t6.isIdentifier(specifier.imported) && REACT_NATIVE_COMPONENT_NAMES.includes(specifier.imported.name)) {
904
+ state.reactNativeImports[specifier.local.name] = specifier.imported.name;
905
+ }
906
+ });
907
+ }
908
+ if (importSource === "react-native" || importSource.includes("react-native/Libraries")) {
909
+ handleExoticImport(path3, state, NATIVE_COMPONENTS_PATHS);
910
+ }
911
+ if (!state.file.forceProcessing && Array.isArray(state.opts.autoProcessImports)) {
912
+ state.file.forceProcessing = state.opts.autoProcessImports.includes(importSource);
913
+ }
914
+ },
915
+ JSXElement(path3, state) {
916
+ if (isInsideNodeModules(state)) {
917
+ return;
918
+ }
919
+ if (hasStringRef(path3)) {
920
+ throw new Error("Detected string based ref which is not supported by Unistyles.");
921
+ }
922
+ },
923
+ MemberExpression(path3, state) {
924
+ if (state.opts.isMetro || isInsideNodeModules(state)) {
925
+ return;
926
+ }
927
+ if (!state.file.reactNativeCommonJSName || !t6.isIdentifier(path3.node.object)) {
928
+ return;
929
+ }
930
+ if (path3.node.object.name !== state.file.reactNativeCommonJSName || !t6.isIdentifier(path3.node.property)) {
931
+ return;
932
+ }
933
+ if (!REACT_NATIVE_COMPONENT_NAMES.includes(path3.node.property.name)) {
934
+ return;
935
+ }
936
+ if (!state.reactNativeImports[path3.node.property.name]) {
937
+ const uniqueId = path3.scope.generateUidIdentifier(`reactNativeUnistyles_${path3.node.property.name}`);
938
+ state.reactNativeImports[path3.node.property.name] = uniqueId.name;
939
+ state.file.addUnistylesRequire = true;
940
+ }
941
+ path3.node.object.name = state.reactNativeImports[path3.node.property.name];
942
+ },
943
+ CallExpression(path3, state) {
944
+ if (isInsideNodeModules(state)) {
945
+ return;
946
+ }
947
+ if (isUnistylesCommonJSRequire(path3, state)) {
948
+ return;
949
+ }
950
+ if (isReactNativeCommonJSRequire(path3, state)) {
951
+ return;
952
+ }
953
+ if (!isUnistylesStyleSheet(path3, state) && !isKindOfStyleSheet(path3, state)) {
954
+ return;
955
+ }
956
+ state.file.hasAnyUnistyle = true;
957
+ const arg = t6.isAssignmentExpression(path3.node.arguments[0]) ? path3.node.arguments[0].right : path3.node.arguments[0];
958
+ if (t6.isObjectExpression(arg)) {
959
+ const detectedDependencies = getStylesDependenciesFromObject(path3);
960
+ if (detectedDependencies) {
961
+ if (t6.isObjectExpression(arg)) {
962
+ arg.properties.forEach((property) => {
963
+ if (!t6.isObjectProperty(property)) {
964
+ return;
965
+ }
966
+ const styleKey = getStyleKeyName(property.key);
967
+ if (styleKey && Object.prototype.hasOwnProperty.call(detectedDependencies, styleKey)) {
968
+ addDependencies(state, styleKey, property, detectedDependencies[styleKey] ?? []);
969
+ }
970
+ });
971
+ }
972
+ }
973
+ }
974
+ if (t6.isArrowFunctionExpression(arg) || t6.isFunctionExpression(arg)) {
975
+ const funcPath = t6.isAssignmentExpression(path3.node.arguments[0]) ? path3.get("arguments.0.right") : path3.get("arguments.0");
976
+ const detectedDependencies = getStylesDependenciesFromFunction(funcPath);
977
+ if (detectedDependencies) {
978
+ const body = t6.isBlockStatement(arg.body) ? arg.body.body.find((statement) => t6.isReturnStatement(statement))?.argument : arg.body;
979
+ if (t6.isObjectExpression(body)) {
980
+ body.properties.forEach((property) => {
981
+ if (!t6.isObjectProperty(property)) {
982
+ return;
983
+ }
984
+ const styleKey = getStyleKeyName(property.key);
985
+ if (styleKey && Object.prototype.hasOwnProperty.call(detectedDependencies, styleKey)) {
986
+ addDependencies(state, styleKey, property, detectedDependencies[styleKey] ?? []);
987
+ }
988
+ });
989
+ }
990
+ }
991
+ }
992
+ }
993
+ }
994
+ };
995
+ }
996
+
997
+ // metro/src/transformer.ts
998
+ var MAYBE_UNISTYLES = /\.create\s*\(|\.useVariants\s*\(/;
999
+ var createBabelTransformer = ({ upstream, options, unistylesRoot, path: path3 = import_node_path3.default }) => {
1000
+ const pluginItem = [src_default, { debug: options.debug, isMetro: true }, "react-native-unistyles"];
1001
+ const shouldProcess = ({ filename, src, options: { projectRoot } }) => {
1002
+ if (!MAYBE_UNISTYLES.test(src)) {
1003
+ return false;
1004
+ }
1005
+ const filePath = path3.resolve(projectRoot, filename);
1006
+ if (filePath.startsWith(`${unistylesRoot}${path3.sep}`)) {
1007
+ return false;
1008
+ }
1009
+ return !filePath.includes(`${path3.sep}node_modules${path3.sep}`) || src.includes("react-native-unistyles");
1010
+ };
1011
+ const transform2 = (args) => {
1012
+ if (!shouldProcess(args)) {
1013
+ return upstream.transform(args);
1014
+ }
1015
+ return upstream.transform({
1016
+ ...args,
1017
+ plugins: [...args.plugins ?? [], pluginItem]
1018
+ });
1019
+ };
1020
+ const getCacheKey2 = (...args) => upstream.getCacheKey?.(...args) ?? "";
1021
+ return { shouldProcess, transform: transform2, getCacheKey: getCacheKey2 };
1022
+ };
1023
+
1024
+ // metro/src/babel-transformer.ts
1025
+ var upstreamPath = process.env[METRO_UPSTREAM_TRANSFORMER_ENV];
1026
+ if (!upstreamPath) {
1027
+ throw new Error(
1028
+ "Unistyles \u{1F984}: react-native-unistyles/metro/babel-transformer can be only set by withUnistylesConfig in metro.config.js"
1029
+ );
1030
+ }
1031
+ var { transform, getCacheKey } = createBabelTransformer({
1032
+ upstream: require(upstreamPath),
1033
+ options: JSON.parse(process.env[METRO_OPTIONS_ENV] ?? "{}"),
1034
+ unistylesRoot: import_node_fs.default.realpathSync(import_node_path4.default.join(__dirname, ".."))
1035
+ });
1036
+ // Annotate the CommonJS export names for ESM import in node:
1037
+ 0 && (module.exports = {
1038
+ getCacheKey,
1039
+ transform
1040
+ });