@niibase/uniwind 1.0.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 (439) hide show
  1. package/LICENSE +20 -0
  2. package/dist/common/components/index.js +314 -0
  3. package/dist/common/components/native/ActivityIndicator.js +21 -0
  4. package/dist/common/components/native/Button.js +18 -0
  5. package/dist/common/components/native/FlatList.js +30 -0
  6. package/dist/common/components/native/Image.js +21 -0
  7. package/dist/common/components/native/ImageBackground.js +23 -0
  8. package/dist/common/components/native/InputAccessoryView.js +21 -0
  9. package/dist/common/components/native/KeyboardAvoidingView.js +20 -0
  10. package/dist/common/components/native/Modal.js +21 -0
  11. package/dist/common/components/native/Pressable.js +29 -0
  12. package/dist/common/components/native/RefreshControl.js +27 -0
  13. package/dist/common/components/native/SafeAreaView.js +18 -0
  14. package/dist/common/components/native/ScrollView.js +23 -0
  15. package/dist/common/components/native/SectionList.js +27 -0
  16. package/dist/common/components/native/Switch.js +32 -0
  17. package/dist/common/components/native/Text.js +36 -0
  18. package/dist/common/components/native/TextInput.js +53 -0
  19. package/dist/common/components/native/TouchableHighlight.js +35 -0
  20. package/dist/common/components/native/TouchableNativeFeedback.js +32 -0
  21. package/dist/common/components/native/TouchableOpacity.js +32 -0
  22. package/dist/common/components/native/TouchableWithoutFeedback.js +32 -0
  23. package/dist/common/components/native/View.js +18 -0
  24. package/dist/common/components/native/VirtualizedList.js +27 -0
  25. package/dist/common/components/native/useStyle.js +29 -0
  26. package/dist/common/components/utils.js +18 -0
  27. package/dist/common/components/web/ActivityIndicator.js +20 -0
  28. package/dist/common/components/web/Button.js +18 -0
  29. package/dist/common/components/web/FlatList.js +22 -0
  30. package/dist/common/components/web/Image.js +20 -0
  31. package/dist/common/components/web/ImageBackground.js +21 -0
  32. package/dist/common/components/web/KeyboardAvoidingView.js +18 -0
  33. package/dist/common/components/web/Modal.js +17 -0
  34. package/dist/common/components/web/Pressable.js +17 -0
  35. package/dist/common/components/web/RefreshControl.js +17 -0
  36. package/dist/common/components/web/SafeAreaView.js +17 -0
  37. package/dist/common/components/web/ScrollView.js +18 -0
  38. package/dist/common/components/web/SectionList.js +20 -0
  39. package/dist/common/components/web/Switch.js +26 -0
  40. package/dist/common/components/web/Text.js +17 -0
  41. package/dist/common/components/web/TextInput.js +17 -0
  42. package/dist/common/components/web/TouchableHighlight.js +20 -0
  43. package/dist/common/components/web/TouchableNativeFeedback.js +13 -0
  44. package/dist/common/components/web/TouchableOpacity.js +17 -0
  45. package/dist/common/components/web/TouchableWithoutFeedback.js +17 -0
  46. package/dist/common/components/web/View.js +17 -0
  47. package/dist/common/components/web/VirtualizedList.js +20 -0
  48. package/dist/common/components/web/index.js +187 -0
  49. package/dist/common/components/web/metro-injected.js +1 -0
  50. package/dist/common/components/web/rnw.js +42 -0
  51. package/dist/common/core/config/config.common.js +80 -0
  52. package/dist/common/core/config/config.js +51 -0
  53. package/dist/common/core/config/config.native.js +67 -0
  54. package/dist/common/core/config/index.js +16 -0
  55. package/dist/common/core/index.js +16 -0
  56. package/dist/common/core/listener.js +51 -0
  57. package/dist/common/core/logger.js +18 -0
  58. package/dist/common/core/native/index.js +27 -0
  59. package/dist/common/core/native/native-utils.js +36 -0
  60. package/dist/common/core/native/parsers/boxShadow.js +10 -0
  61. package/dist/common/core/native/parsers/fontVariant.js +8 -0
  62. package/dist/common/core/native/parsers/gradient.js +31 -0
  63. package/dist/common/core/native/parsers/index.js +60 -0
  64. package/dist/common/core/native/parsers/textShadow.js +39 -0
  65. package/dist/common/core/native/parsers/transforms.js +44 -0
  66. package/dist/common/core/native/runtime.js +34 -0
  67. package/dist/common/core/native/store.js +181 -0
  68. package/dist/common/core/types.js +1 -0
  69. package/dist/common/core/web/cssListener.js +146 -0
  70. package/dist/common/core/web/formatColor.js +15 -0
  71. package/dist/common/core/web/getWebStyles.js +51 -0
  72. package/dist/common/core/web/index.js +49 -0
  73. package/dist/common/core/web/parseCSSValue.js +15 -0
  74. package/dist/common/css/index.js +26 -0
  75. package/dist/common/css/insets.js +64 -0
  76. package/dist/common/css/processFunctions.js +54 -0
  77. package/dist/common/css/themes.js +95 -0
  78. package/dist/common/css/variants.js +16 -0
  79. package/dist/common/hoc/index.js +16 -0
  80. package/dist/common/hoc/types.js +1 -0
  81. package/dist/common/hoc/withUniwind.js +95 -0
  82. package/dist/common/hoc/withUniwind.native.js +106 -0
  83. package/dist/common/hoc/withUniwindUtils.js +16 -0
  84. package/dist/common/hooks/index.js +49 -0
  85. package/dist/common/hooks/useCSSVariable/getVariableValue.js +19 -0
  86. package/dist/common/hooks/useCSSVariable/getVariableValue.native.js +9 -0
  87. package/dist/common/hooks/useCSSVariable/index.js +16 -0
  88. package/dist/common/hooks/useCSSVariable/useCSSVariable.js +58 -0
  89. package/dist/common/hooks/useResolveClassNames.js +22 -0
  90. package/dist/common/hooks/useResolveClassNames.native.js +29 -0
  91. package/dist/common/hooks/useUniwind.js +28 -0
  92. package/dist/common/hooks/useUniwindAccent.js +13 -0
  93. package/dist/common/hooks/useUniwindAccent.native.js +12 -0
  94. package/dist/common/index.js +38 -0
  95. package/dist/common/types.js +28 -0
  96. package/dist/common/utils/buildDtsFile.js +18 -0
  97. package/dist/common/utils/stringifyThemes.js +8 -0
  98. package/dist/common/vite/index.d.ts +9 -0
  99. package/dist/common/vite/index.js +16 -0
  100. package/dist/common/vite/vite.js +72 -0
  101. package/dist/metro/index.cjs +166 -0
  102. package/dist/metro/index.d.ts +15 -0
  103. package/dist/metro/index.mjs +158 -0
  104. package/dist/metro/metro-transformer.cjs +1565 -0
  105. package/dist/metro/metro-transformer.mjs +1558 -0
  106. package/dist/module/components/index.d.ts +0 -0
  107. package/dist/module/components/index.js +312 -0
  108. package/dist/module/components/native/ActivityIndicator.d.ts +3 -0
  109. package/dist/module/components/native/ActivityIndicator.js +18 -0
  110. package/dist/module/components/native/Button.d.ts +3 -0
  111. package/dist/module/components/native/Button.js +15 -0
  112. package/dist/module/components/native/FlatList.d.ts +3 -0
  113. package/dist/module/components/native/FlatList.js +27 -0
  114. package/dist/module/components/native/Image.d.ts +3 -0
  115. package/dist/module/components/native/Image.js +18 -0
  116. package/dist/module/components/native/ImageBackground.d.ts +3 -0
  117. package/dist/module/components/native/ImageBackground.js +20 -0
  118. package/dist/module/components/native/InputAccessoryView.d.ts +3 -0
  119. package/dist/module/components/native/InputAccessoryView.js +21 -0
  120. package/dist/module/components/native/KeyboardAvoidingView.d.ts +3 -0
  121. package/dist/module/components/native/KeyboardAvoidingView.js +17 -0
  122. package/dist/module/components/native/Modal.d.ts +3 -0
  123. package/dist/module/components/native/Modal.js +18 -0
  124. package/dist/module/components/native/Pressable.d.ts +3 -0
  125. package/dist/module/components/native/Pressable.js +29 -0
  126. package/dist/module/components/native/RefreshControl.d.ts +3 -0
  127. package/dist/module/components/native/RefreshControl.js +24 -0
  128. package/dist/module/components/native/SafeAreaView.d.ts +3 -0
  129. package/dist/module/components/native/SafeAreaView.js +15 -0
  130. package/dist/module/components/native/ScrollView.d.ts +3 -0
  131. package/dist/module/components/native/ScrollView.js +20 -0
  132. package/dist/module/components/native/SectionList.d.ts +3 -0
  133. package/dist/module/components/native/SectionList.js +24 -0
  134. package/dist/module/components/native/Switch.d.ts +3 -0
  135. package/dist/module/components/native/Switch.js +26 -0
  136. package/dist/module/components/native/Text.d.ts +3 -0
  137. package/dist/module/components/native/Text.js +33 -0
  138. package/dist/module/components/native/TextInput.d.ts +3 -0
  139. package/dist/module/components/native/TextInput.js +50 -0
  140. package/dist/module/components/native/TouchableHighlight.d.ts +3 -0
  141. package/dist/module/components/native/TouchableHighlight.js +32 -0
  142. package/dist/module/components/native/TouchableNativeFeedback.d.ts +3 -0
  143. package/dist/module/components/native/TouchableNativeFeedback.js +29 -0
  144. package/dist/module/components/native/TouchableOpacity.d.ts +3 -0
  145. package/dist/module/components/native/TouchableOpacity.js +29 -0
  146. package/dist/module/components/native/TouchableWithoutFeedback.d.ts +3 -0
  147. package/dist/module/components/native/TouchableWithoutFeedback.js +29 -0
  148. package/dist/module/components/native/View.d.ts +3 -0
  149. package/dist/module/components/native/View.js +15 -0
  150. package/dist/module/components/native/VirtualizedList.d.ts +3 -0
  151. package/dist/module/components/native/VirtualizedList.js +24 -0
  152. package/dist/module/components/native/useStyle.d.ts +2 -0
  153. package/dist/module/components/native/useStyle.js +22 -0
  154. package/dist/module/components/utils.d.ts +1 -0
  155. package/dist/module/components/utils.js +11 -0
  156. package/dist/module/components/web/ActivityIndicator.d.ts +3 -0
  157. package/dist/module/components/web/ActivityIndicator.js +17 -0
  158. package/dist/module/components/web/Button.d.ts +3 -0
  159. package/dist/module/components/web/Button.js +15 -0
  160. package/dist/module/components/web/FlatList.d.ts +3 -0
  161. package/dist/module/components/web/FlatList.js +19 -0
  162. package/dist/module/components/web/Image.d.ts +3 -0
  163. package/dist/module/components/web/Image.js +17 -0
  164. package/dist/module/components/web/ImageBackground.d.ts +3 -0
  165. package/dist/module/components/web/ImageBackground.js +18 -0
  166. package/dist/module/components/web/KeyboardAvoidingView.d.ts +3 -0
  167. package/dist/module/components/web/KeyboardAvoidingView.js +15 -0
  168. package/dist/module/components/web/Modal.d.ts +3 -0
  169. package/dist/module/components/web/Modal.js +14 -0
  170. package/dist/module/components/web/Pressable.d.ts +3 -0
  171. package/dist/module/components/web/Pressable.js +14 -0
  172. package/dist/module/components/web/RefreshControl.d.ts +3 -0
  173. package/dist/module/components/web/RefreshControl.js +14 -0
  174. package/dist/module/components/web/SafeAreaView.d.ts +3 -0
  175. package/dist/module/components/web/SafeAreaView.js +14 -0
  176. package/dist/module/components/web/ScrollView.d.ts +3 -0
  177. package/dist/module/components/web/ScrollView.js +15 -0
  178. package/dist/module/components/web/SectionList.d.ts +3 -0
  179. package/dist/module/components/web/SectionList.js +17 -0
  180. package/dist/module/components/web/Switch.d.ts +3 -0
  181. package/dist/module/components/web/Switch.js +20 -0
  182. package/dist/module/components/web/Text.d.ts +3 -0
  183. package/dist/module/components/web/Text.js +14 -0
  184. package/dist/module/components/web/TextInput.d.ts +3 -0
  185. package/dist/module/components/web/TextInput.js +14 -0
  186. package/dist/module/components/web/TouchableHighlight.d.ts +3 -0
  187. package/dist/module/components/web/TouchableHighlight.js +17 -0
  188. package/dist/module/components/web/TouchableNativeFeedback.d.ts +2 -0
  189. package/dist/module/components/web/TouchableNativeFeedback.js +2 -0
  190. package/dist/module/components/web/TouchableOpacity.d.ts +3 -0
  191. package/dist/module/components/web/TouchableOpacity.js +14 -0
  192. package/dist/module/components/web/TouchableWithoutFeedback.d.ts +3 -0
  193. package/dist/module/components/web/TouchableWithoutFeedback.js +14 -0
  194. package/dist/module/components/web/View.d.ts +3 -0
  195. package/dist/module/components/web/View.js +14 -0
  196. package/dist/module/components/web/VirtualizedList.d.ts +3 -0
  197. package/dist/module/components/web/VirtualizedList.js +17 -0
  198. package/dist/module/components/web/index.d.ts +22 -0
  199. package/dist/module/components/web/index.js +22 -0
  200. package/dist/module/components/web/metro-injected.d.ts +0 -0
  201. package/dist/module/components/web/metro-injected.js +0 -0
  202. package/dist/module/components/web/rnw.d.ts +2 -0
  203. package/dist/module/components/web/rnw.js +35 -0
  204. package/dist/module/core/config/config.common.d.ts +18 -0
  205. package/dist/module/core/config/config.common.js +74 -0
  206. package/dist/module/core/config/config.d.ts +11 -0
  207. package/dist/module/core/config/config.js +48 -0
  208. package/dist/module/core/config/config.native.d.ts +12 -0
  209. package/dist/module/core/config/config.native.js +61 -0
  210. package/dist/module/core/config/index.d.ts +1 -0
  211. package/dist/module/core/config/index.js +1 -0
  212. package/dist/module/core/index.d.ts +1 -0
  213. package/dist/module/core/index.js +1 -0
  214. package/dist/module/core/listener.d.ts +12 -0
  215. package/dist/module/core/listener.js +45 -0
  216. package/dist/module/core/logger.d.ts +5 -0
  217. package/dist/module/core/logger.js +11 -0
  218. package/dist/module/core/native/index.d.ts +2 -0
  219. package/dist/module/core/native/index.js +2 -0
  220. package/dist/module/core/native/native-utils.d.ts +4 -0
  221. package/dist/module/core/native/native-utils.js +27 -0
  222. package/dist/module/core/native/parsers/boxShadow.d.ts +1 -0
  223. package/dist/module/core/native/parsers/boxShadow.js +3 -0
  224. package/dist/module/core/native/parsers/fontVariant.d.ts +1 -0
  225. package/dist/module/core/native/parsers/fontVariant.js +1 -0
  226. package/dist/module/core/native/parsers/gradient.d.ts +8 -0
  227. package/dist/module/core/native/parsers/gradient.js +26 -0
  228. package/dist/module/core/native/parsers/index.d.ts +5 -0
  229. package/dist/module/core/native/parsers/index.js +5 -0
  230. package/dist/module/core/native/parsers/textShadow.d.ts +1 -0
  231. package/dist/module/core/native/parsers/textShadow.js +32 -0
  232. package/dist/module/core/native/parsers/transforms.d.ts +1 -0
  233. package/dist/module/core/native/parsers/transforms.js +48 -0
  234. package/dist/module/core/native/runtime.d.ts +2 -0
  235. package/dist/module/core/native/runtime.js +28 -0
  236. package/dist/module/core/native/store.d.ts +19 -0
  237. package/dist/module/core/native/store.js +172 -0
  238. package/dist/module/core/types.d.ts +73 -0
  239. package/dist/module/core/types.js +0 -0
  240. package/dist/module/core/web/cssListener.d.ts +19 -0
  241. package/dist/module/core/web/cssListener.js +137 -0
  242. package/dist/module/core/web/formatColor.d.ts +1 -0
  243. package/dist/module/core/web/formatColor.js +8 -0
  244. package/dist/module/core/web/getWebStyles.d.ts +2 -0
  245. package/dist/module/core/web/getWebStyles.js +49 -0
  246. package/dist/module/core/web/index.d.ts +4 -0
  247. package/dist/module/core/web/index.js +4 -0
  248. package/dist/module/core/web/parseCSSValue.d.ts +1 -0
  249. package/dist/module/core/web/parseCSSValue.js +8 -0
  250. package/dist/module/css/index.d.ts +1 -0
  251. package/dist/module/css/index.js +25 -0
  252. package/dist/module/css/insets.d.ts +1 -0
  253. package/dist/module/css/insets.js +63 -0
  254. package/dist/module/css/processFunctions.d.ts +2 -0
  255. package/dist/module/css/processFunctions.js +36 -0
  256. package/dist/module/css/themes.d.ts +1 -0
  257. package/dist/module/css/themes.js +97 -0
  258. package/dist/module/css/variants.d.ts +1 -0
  259. package/dist/module/css/variants.js +9 -0
  260. package/dist/module/hoc/index.d.ts +1 -0
  261. package/dist/module/hoc/index.js +1 -0
  262. package/dist/module/hoc/types.d.ts +27 -0
  263. package/dist/module/hoc/types.js +0 -0
  264. package/dist/module/hoc/withUniwind.d.ts +2 -0
  265. package/dist/module/hoc/withUniwind.js +76 -0
  266. package/dist/module/hoc/withUniwind.native.d.ts +2 -0
  267. package/dist/module/hoc/withUniwind.native.js +81 -0
  268. package/dist/module/hoc/withUniwindUtils.d.ts +5 -0
  269. package/dist/module/hoc/withUniwindUtils.js +5 -0
  270. package/dist/module/hooks/index.d.ts +4 -0
  271. package/dist/module/hooks/index.js +4 -0
  272. package/dist/module/hooks/useCSSVariable/getVariableValue.d.ts +1 -0
  273. package/dist/module/hooks/useCSSVariable/getVariableValue.js +12 -0
  274. package/dist/module/hooks/useCSSVariable/getVariableValue.native.d.ts +1 -0
  275. package/dist/module/hooks/useCSSVariable/getVariableValue.native.js +2 -0
  276. package/dist/module/hooks/useCSSVariable/index.d.ts +1 -0
  277. package/dist/module/hooks/useCSSVariable/index.js +1 -0
  278. package/dist/module/hooks/useCSSVariable/useCSSVariable.d.ts +13 -0
  279. package/dist/module/hooks/useCSSVariable/useCSSVariable.js +56 -0
  280. package/dist/module/hooks/useResolveClassNames.d.ts +2 -0
  281. package/dist/module/hooks/useResolveClassNames.js +18 -0
  282. package/dist/module/hooks/useResolveClassNames.native.d.ts +2 -0
  283. package/dist/module/hooks/useResolveClassNames.native.js +22 -0
  284. package/dist/module/hooks/useUniwind.d.ts +5 -0
  285. package/dist/module/hooks/useUniwind.js +21 -0
  286. package/dist/module/hooks/useUniwindAccent.d.ts +1 -0
  287. package/dist/module/hooks/useUniwindAccent.js +6 -0
  288. package/dist/module/hooks/useUniwindAccent.native.d.ts +2 -0
  289. package/dist/module/hooks/useUniwindAccent.native.js +5 -0
  290. package/dist/module/index.d.ts +5 -0
  291. package/dist/module/index.js +3 -0
  292. package/dist/module/types.d.ts +21 -0
  293. package/dist/module/types.js +22 -0
  294. package/dist/module/utils/buildDtsFile.d.ts +1 -0
  295. package/dist/module/utils/buildDtsFile.js +22 -0
  296. package/dist/module/utils/stringifyThemes.d.ts +1 -0
  297. package/dist/module/utils/stringifyThemes.js +1 -0
  298. package/dist/module/vite/index.d.ts +9 -0
  299. package/dist/module/vite/index.js +1 -0
  300. package/dist/module/vite/vite.d.ts +8 -0
  301. package/dist/module/vite/vite.js +73 -0
  302. package/dist/shared/uniwind.BZIuaszw.cjs +11 -0
  303. package/dist/shared/uniwind.BgZDHdUR.cjs +81 -0
  304. package/dist/shared/uniwind.Bt3kqZo6.mjs +290 -0
  305. package/dist/shared/uniwind.CyoRUwOj.mjs +9 -0
  306. package/dist/shared/uniwind.D3fvrgEG.mjs +68 -0
  307. package/dist/shared/uniwind.D_6s2EM-.cjs +301 -0
  308. package/dist/vite/index.cjs +80 -0
  309. package/dist/vite/index.d.ts +9 -0
  310. package/dist/vite/index.mjs +74 -0
  311. package/metro/package.json +3 -0
  312. package/package.json +106 -0
  313. package/readme.md +71 -0
  314. package/src/components/index.ts +313 -0
  315. package/src/components/native/ActivityIndicator.tsx +19 -0
  316. package/src/components/native/Button.tsx +16 -0
  317. package/src/components/native/FlatList.tsx +28 -0
  318. package/src/components/native/Image.tsx +19 -0
  319. package/src/components/native/ImageBackground.tsx +21 -0
  320. package/src/components/native/InputAccessoryView.tsx +23 -0
  321. package/src/components/native/KeyboardAvoidingView.tsx +18 -0
  322. package/src/components/native/Modal.tsx +19 -0
  323. package/src/components/native/Pressable.tsx +31 -0
  324. package/src/components/native/RefreshControl.tsx +25 -0
  325. package/src/components/native/SafeAreaView.tsx +16 -0
  326. package/src/components/native/ScrollView.tsx +21 -0
  327. package/src/components/native/SectionList.tsx +25 -0
  328. package/src/components/native/Switch.tsx +28 -0
  329. package/src/components/native/Text.tsx +39 -0
  330. package/src/components/native/TextInput.tsx +52 -0
  331. package/src/components/native/TouchableHighlight.tsx +34 -0
  332. package/src/components/native/TouchableNativeFeedback.tsx +31 -0
  333. package/src/components/native/TouchableOpacity.tsx +31 -0
  334. package/src/components/native/TouchableWithoutFeedback.tsx +31 -0
  335. package/src/components/native/View.tsx +16 -0
  336. package/src/components/native/VirtualizedList.tsx +25 -0
  337. package/src/components/native/useStyle.ts +33 -0
  338. package/src/components/utils.ts +16 -0
  339. package/src/components/web/ActivityIndicator.tsx +18 -0
  340. package/src/components/web/Button.tsx +16 -0
  341. package/src/components/web/FlatList.tsx +20 -0
  342. package/src/components/web/Image.tsx +18 -0
  343. package/src/components/web/ImageBackground.tsx +19 -0
  344. package/src/components/web/KeyboardAvoidingView.tsx +15 -0
  345. package/src/components/web/Modal.tsx +14 -0
  346. package/src/components/web/Pressable.tsx +14 -0
  347. package/src/components/web/RefreshControl.tsx +14 -0
  348. package/src/components/web/SafeAreaView.tsx +14 -0
  349. package/src/components/web/ScrollView.tsx +15 -0
  350. package/src/components/web/SectionList.tsx +17 -0
  351. package/src/components/web/Switch.tsx +21 -0
  352. package/src/components/web/Text.tsx +14 -0
  353. package/src/components/web/TextInput.tsx +14 -0
  354. package/src/components/web/TouchableHighlight.tsx +18 -0
  355. package/src/components/web/TouchableNativeFeedback.tsx +2 -0
  356. package/src/components/web/TouchableOpacity.tsx +14 -0
  357. package/src/components/web/TouchableWithoutFeedback.tsx +14 -0
  358. package/src/components/web/View.tsx +14 -0
  359. package/src/components/web/VirtualizedList.tsx +17 -0
  360. package/src/components/web/index.ts +22 -0
  361. package/src/components/web/metro-injected.ts +1 -0
  362. package/src/components/web/rnw.ts +52 -0
  363. package/src/core/config/config.common.ts +98 -0
  364. package/src/core/config/config.native.ts +79 -0
  365. package/src/core/config/config.ts +64 -0
  366. package/src/core/config/index.ts +1 -0
  367. package/src/core/index.ts +1 -0
  368. package/src/core/listener.ts +59 -0
  369. package/src/core/logger.ts +15 -0
  370. package/src/core/native/index.ts +2 -0
  371. package/src/core/native/native-utils.ts +41 -0
  372. package/src/core/native/parsers/boxShadow.ts +7 -0
  373. package/src/core/native/parsers/fontVariant.ts +3 -0
  374. package/src/core/native/parsers/gradient.ts +39 -0
  375. package/src/core/native/parsers/index.ts +5 -0
  376. package/src/core/native/parsers/textShadow.ts +37 -0
  377. package/src/core/native/parsers/transforms.ts +64 -0
  378. package/src/core/native/runtime.ts +32 -0
  379. package/src/core/native/store.ts +238 -0
  380. package/src/core/types.ts +92 -0
  381. package/src/core/web/cssListener.ts +185 -0
  382. package/src/core/web/formatColor.ts +13 -0
  383. package/src/core/web/getWebStyles.ts +76 -0
  384. package/src/core/web/index.ts +4 -0
  385. package/src/core/web/parseCSSValue.ts +10 -0
  386. package/src/css/index.ts +32 -0
  387. package/src/css/insets.ts +73 -0
  388. package/src/css/processFunctions.ts +39 -0
  389. package/src/css/themes.ts +130 -0
  390. package/src/css/variants.ts +11 -0
  391. package/src/hoc/index.ts +1 -0
  392. package/src/hoc/types.ts +45 -0
  393. package/src/hoc/withUniwind.native.tsx +118 -0
  394. package/src/hoc/withUniwind.tsx +115 -0
  395. package/src/hoc/withUniwindUtils.ts +10 -0
  396. package/src/hooks/index.ts +4 -0
  397. package/src/hooks/useCSSVariable/getVariableValue.native.ts +3 -0
  398. package/src/hooks/useCSSVariable/getVariableValue.ts +19 -0
  399. package/src/hooks/useCSSVariable/index.ts +1 -0
  400. package/src/hooks/useCSSVariable/useCSSVariable.ts +89 -0
  401. package/src/hooks/useResolveClassNames.native.ts +29 -0
  402. package/src/hooks/useResolveClassNames.ts +26 -0
  403. package/src/hooks/useUniwind.ts +26 -0
  404. package/src/hooks/useUniwindAccent.native.ts +8 -0
  405. package/src/hooks/useUniwindAccent.ts +10 -0
  406. package/src/index.ts +5 -0
  407. package/src/metro/addMetaToStylesTemplate.ts +152 -0
  408. package/src/metro/compileVirtual.ts +74 -0
  409. package/src/metro/index.d.ts +15 -0
  410. package/src/metro/index.ts +1 -0
  411. package/src/metro/injectThemes.ts +23 -0
  412. package/src/metro/logger.ts +44 -0
  413. package/src/metro/metro-css-patches.ts +57 -0
  414. package/src/metro/metro-transformer.ts +99 -0
  415. package/src/metro/polyfillWeb.ts +14 -0
  416. package/src/metro/processor/color.ts +76 -0
  417. package/src/metro/processor/css.ts +541 -0
  418. package/src/metro/processor/functions.ts +199 -0
  419. package/src/metro/processor/index.ts +1 -0
  420. package/src/metro/processor/mq.ts +82 -0
  421. package/src/metro/processor/processor.ts +249 -0
  422. package/src/metro/processor/rn.ts +277 -0
  423. package/src/metro/processor/units.ts +58 -0
  424. package/src/metro/processor/var.ts +18 -0
  425. package/src/metro/resolvers.ts +101 -0
  426. package/src/metro/types.ts +74 -0
  427. package/src/metro/utils/common.ts +103 -0
  428. package/src/metro/utils/index.ts +2 -0
  429. package/src/metro/utils/serialize.ts +116 -0
  430. package/src/metro/withUniwindConfig.ts +60 -0
  431. package/src/types.ts +24 -0
  432. package/src/utils/buildDtsFile.ts +27 -0
  433. package/src/utils/stringifyThemes.ts +1 -0
  434. package/src/vite/index.d.ts +9 -0
  435. package/src/vite/index.ts +1 -0
  436. package/src/vite/vite.ts +86 -0
  437. package/types.d.ts +109 -0
  438. package/uniwind.css +262 -0
  439. package/vite/package.json +3 -0
@@ -0,0 +1,1558 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { p as pipe, r as roundToPrecision, i as isNumber, a as isValidJSValue, s as smartSplit, b as addMissingSpaces, t as toCamelCase, c as isDefined, d as deepEqual, e as shouldBeSerialized, n as name } from '../shared/uniwind.D3fvrgEG.mjs';
4
+ import { compile } from '@tailwindcss/node';
5
+ import { Scanner } from '@tailwindcss/oxide';
6
+ import { P as Platform } from '../shared/uniwind.CyoRUwOj.mjs';
7
+ import { L as Logger, p as processFunctions, s as stringifyThemes, b as buildDtsFile, a as buildCSS } from '../shared/uniwind.Bt3kqZo6.mjs';
8
+ import { transform as transform$1 } from 'lightningcss';
9
+ import { converter, parse, formatHex, formatHex8 } from 'culori';
10
+
11
+ const parseStringValue = (value) => {
12
+ if (isValidJSValue(value)) {
13
+ return value;
14
+ }
15
+ if (value.startsWith("function")) {
16
+ return value;
17
+ }
18
+ const tokens = smartSplit(addMissingSpaces(value));
19
+ const parsedTokens = tokens.map((token) => {
20
+ if (token.startsWith('"')) {
21
+ return token.replace(/"/g, "");
22
+ }
23
+ if (/^[a-z]+$/i.test(token.replace(/,/g, ""))) {
24
+ return token;
25
+ }
26
+ if (isNumber(token)) {
27
+ return token;
28
+ }
29
+ const endsWithComma = token.endsWith(",");
30
+ return [
31
+ "${",
32
+ endsWithComma ? token.slice(0, -1) : token,
33
+ "}",
34
+ endsWithComma ? "," : ""
35
+ ].join("");
36
+ });
37
+ return [
38
+ "`",
39
+ parsedTokens.join(" "),
40
+ "`"
41
+ ].join("");
42
+ };
43
+ const serialize = (value) => {
44
+ const typeOfValue = typeof value;
45
+ switch (typeOfValue) {
46
+ case "string":
47
+ return parseStringValue(value);
48
+ case "symbol":
49
+ return String(value);
50
+ case "number":
51
+ case "bigint":
52
+ return String(roundToPrecision(value, 2));
53
+ case "boolean":
54
+ return value.toString();
55
+ case "object":
56
+ if (value === null) {
57
+ return "null";
58
+ }
59
+ if (Array.isArray(value)) {
60
+ return [
61
+ "[",
62
+ value.map(serialize).join(", "),
63
+ "]"
64
+ ].join("");
65
+ }
66
+ return [
67
+ "{",
68
+ Object.entries(value).map(([key, val]) => {
69
+ const serializedKey = isNumber(key) ? key : `"${key}"`;
70
+ return `${serializedKey}: ${serialize(val)}`;
71
+ }).join(", "),
72
+ "}"
73
+ ].join("");
74
+ case "undefined":
75
+ return "undefined";
76
+ case "function":
77
+ return "";
78
+ default:
79
+ return "";
80
+ }
81
+ };
82
+ const serializeJSObject = (obj, serializer) => {
83
+ const serializedObject = pipe(obj)(
84
+ Object.entries,
85
+ (entries) => entries.map(([key, value]) => serializer(key, serialize(value))),
86
+ (entries) => entries.join(","),
87
+ (result) => {
88
+ if (result === "") {
89
+ return "";
90
+ }
91
+ return `${result},`;
92
+ }
93
+ );
94
+ try {
95
+ new Function(`function validateJS() { const obj = ({ ${serializedObject} }) }`);
96
+ } catch {
97
+ Logger.error("Failed to serialize javascript object");
98
+ return "";
99
+ }
100
+ return serializedObject;
101
+ };
102
+
103
+ var StyleDependency = /* @__PURE__ */ ((StyleDependency2) => {
104
+ StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
105
+ StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
106
+ StyleDependency2[StyleDependency2["Dimensions"] = 3] = "Dimensions";
107
+ StyleDependency2[StyleDependency2["Orientation"] = 4] = "Orientation";
108
+ StyleDependency2[StyleDependency2["Insets"] = 5] = "Insets";
109
+ StyleDependency2[StyleDependency2["FontScale"] = 6] = "FontScale";
110
+ StyleDependency2[StyleDependency2["Rtl"] = 7] = "Rtl";
111
+ StyleDependency2[StyleDependency2["AdaptiveThemes"] = 8] = "AdaptiveThemes";
112
+ StyleDependency2[StyleDependency2["Variables"] = 9] = "Variables";
113
+ return StyleDependency2;
114
+ })(StyleDependency || {});
115
+
116
+ const extractVarsFromString = (value) => {
117
+ const thisIndexes = [...value.matchAll(/this\[/g)].map((m) => m.index);
118
+ return thisIndexes.map((index) => {
119
+ const afterIndex = value.slice(index + 5);
120
+ const closingIndex = afterIndex.indexOf("]");
121
+ const varName = afterIndex.slice(0, closingIndex);
122
+ return varName.replace(/[`"\\]/g, "");
123
+ });
124
+ };
125
+ const makeSafeForSerialization = (value) => {
126
+ if (value === null) {
127
+ return null;
128
+ }
129
+ if (typeof value === "string") {
130
+ return `"${value}"`;
131
+ }
132
+ return value;
133
+ };
134
+ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
135
+ const stylesheetsEntries = Object.entries(Processor.stylesheets).map(([className, stylesPerMediaQuery]) => {
136
+ const styles = stylesPerMediaQuery.map((style, index) => {
137
+ const {
138
+ platform,
139
+ rtl,
140
+ theme,
141
+ orientation,
142
+ minWidth,
143
+ maxWidth,
144
+ colorScheme,
145
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
146
+ important,
147
+ importantProperties,
148
+ active,
149
+ focus,
150
+ disabled,
151
+ ...rest
152
+ } = style;
153
+ const entries = Object.entries(rest).flatMap(([property, value]) => Processor.RN.cssToRN(property, value)).map(([property, value]) => [`"${property}"`, `function() { return ${serialize(value)} }`]);
154
+ if (platform && platform !== Platform.Native && platform !== currentPlatform) {
155
+ return null;
156
+ }
157
+ if (entries.length === 0) {
158
+ return null;
159
+ }
160
+ const dependencies = [];
161
+ const stringifiedEntries = JSON.stringify(entries);
162
+ const usedVars = extractVarsFromString(stringifiedEntries);
163
+ const isUsingThemedVar = usedVars.some((usedVarName) => {
164
+ return Object.values(Processor.scopedVars).some((scopedVars) => {
165
+ const scopedVarsNames = Object.keys(scopedVars);
166
+ return scopedVarsNames.includes(usedVarName);
167
+ });
168
+ });
169
+ if (usedVars.length > 0) {
170
+ dependencies.push(StyleDependency.Variables);
171
+ }
172
+ if (theme !== null || isUsingThemedVar || stringifiedEntries.includes("rt.lightDark")) {
173
+ dependencies.push(StyleDependency.Theme);
174
+ }
175
+ if (orientation !== null) {
176
+ dependencies.push(StyleDependency.Orientation);
177
+ }
178
+ if (rtl !== null) {
179
+ dependencies.push(StyleDependency.Rtl);
180
+ }
181
+ if (Number(minWidth) !== 0 || Number(maxWidth) !== Number.MAX_VALUE || stringifiedEntries.includes("rt.screen")) {
182
+ dependencies.push(StyleDependency.Dimensions);
183
+ }
184
+ if (stringifiedEntries.includes("rt.insets")) {
185
+ dependencies.push(StyleDependency.Insets);
186
+ }
187
+ if (stringifiedEntries.includes("rt.fontScale")) {
188
+ dependencies.push(StyleDependency.FontScale);
189
+ }
190
+ return {
191
+ entries,
192
+ minWidth,
193
+ maxWidth,
194
+ theme: makeSafeForSerialization(theme),
195
+ orientation: makeSafeForSerialization(orientation),
196
+ rtl,
197
+ colorScheme: makeSafeForSerialization(colorScheme),
198
+ native: platform !== null,
199
+ dependencies: dependencies.length > 0 ? dependencies : null,
200
+ index,
201
+ className: makeSafeForSerialization(className),
202
+ active,
203
+ focus,
204
+ disabled,
205
+ importantProperties: importantProperties?.map((property) => property.startsWith("--") ? property : toCamelCase).map(makeSafeForSerialization) ?? [],
206
+ complexity: [
207
+ minWidth !== 0,
208
+ theme !== null,
209
+ orientation !== null,
210
+ rtl !== null,
211
+ platform !== null,
212
+ active !== null,
213
+ focus !== null,
214
+ disabled !== null
215
+ ].filter(Boolean).length
216
+ };
217
+ });
218
+ const filteredStyles = styles.filter(isDefined);
219
+ if (filteredStyles.length === 0) {
220
+ return null;
221
+ }
222
+ return [
223
+ className,
224
+ filteredStyles
225
+ ];
226
+ }).filter(isDefined);
227
+ const stylesheets = Object.fromEntries(stylesheetsEntries);
228
+ return stylesheets;
229
+ };
230
+
231
+ const polyfillWeb = (css) => {
232
+ const result = transform$1({
233
+ code: Buffer.from(css),
234
+ filename: "uniwind.css",
235
+ visitor: {
236
+ Function: processFunctions
237
+ }
238
+ });
239
+ return result.code.toString();
240
+ };
241
+
242
+ class Color {
243
+ constructor(Processor) {
244
+ this.Processor = Processor;
245
+ }
246
+ toRgb = converter("rgb");
247
+ black = "#000000";
248
+ logger = new Logger("Color");
249
+ processColor(color) {
250
+ if (typeof color === "string") {
251
+ const parsed = parse(color);
252
+ if (parsed === void 0) {
253
+ this.logger.error(`Failed to convert color ${color}`);
254
+ return this.black;
255
+ }
256
+ return this.format(parsed);
257
+ }
258
+ try {
259
+ if (color.type === "currentcolor") {
260
+ return 'this["currentColor"]';
261
+ }
262
+ if (color.type === "rgb" || color.type === "srgb") {
263
+ const alpha = typeof color.alpha === "number" ? color.alpha : pipe(color.alpha)(
264
+ (x) => this.Processor.CSS.processValue(x),
265
+ Number,
266
+ (x) => isNaN(x) ? 1 : x
267
+ );
268
+ return this.format({
269
+ r: color.r / 255,
270
+ g: color.g / 255,
271
+ b: color.b / 255,
272
+ alpha,
273
+ mode: "rgb"
274
+ });
275
+ }
276
+ const result = this.toRgb({
277
+ mode: color.type,
278
+ ...color
279
+ });
280
+ return this.format(result);
281
+ } catch {
282
+ this.logger.error(`Failed to convert color ${JSON.stringify(color)}`);
283
+ return this.black;
284
+ }
285
+ }
286
+ isColor(value) {
287
+ return typeof value === "string" && parse(value) !== void 0;
288
+ }
289
+ format(color) {
290
+ if (color.alpha === 1 || color.alpha === void 0) {
291
+ return formatHex(color);
292
+ }
293
+ return formatHex8(color);
294
+ }
295
+ }
296
+
297
+ class CSS {
298
+ constructor(Processor) {
299
+ this.Processor = Processor;
300
+ }
301
+ logger = new Logger("CSS");
302
+ processValue(declarationValue) {
303
+ const processedValue = this.getProcessedValue(declarationValue);
304
+ if (typeof processedValue === "string") {
305
+ return this.makeSafeForSerialization(processedValue);
306
+ }
307
+ if (Array.isArray(processedValue)) {
308
+ return processedValue.map((value) => {
309
+ if (typeof value === "string") {
310
+ return this.makeSafeForSerialization(value);
311
+ }
312
+ return value;
313
+ });
314
+ }
315
+ if (typeof processedValue === "object" && processedValue !== null) {
316
+ return Object.fromEntries(
317
+ Object.entries(processedValue).map(([key, value]) => {
318
+ if (typeof value === "string") {
319
+ return [
320
+ key,
321
+ this.makeSafeForSerialization(value)
322
+ ];
323
+ }
324
+ return [
325
+ key,
326
+ value
327
+ ];
328
+ })
329
+ );
330
+ }
331
+ return processedValue;
332
+ }
333
+ getProcessedValue(declarationValue) {
334
+ if (typeof declarationValue !== "object") {
335
+ return declarationValue;
336
+ }
337
+ if ("type" in declarationValue) {
338
+ switch (declarationValue.type) {
339
+ case "function":
340
+ return this.Processor.Functions.processFunction(declarationValue.value);
341
+ case "var":
342
+ return this.Processor.Var.processVar(declarationValue.value);
343
+ case "number":
344
+ return declarationValue.value;
345
+ case "token":
346
+ return this.processValue(declarationValue.value);
347
+ case "length":
348
+ return this.Processor.Units.processAnyLength(declarationValue.value);
349
+ case "color":
350
+ return this.Processor.Color.processColor(declarationValue.value);
351
+ case "integer":
352
+ return declarationValue.value;
353
+ case "comma":
354
+ return ", ";
355
+ case "dimension":
356
+ case "value":
357
+ case "length-percentage":
358
+ return this.Processor.Units.processLength(declarationValue.value);
359
+ case "translate": {
360
+ const [translateX, translateY] = declarationValue.value.map((x) => this.processValue(x));
361
+ return [
362
+ {
363
+ translateX
364
+ },
365
+ {
366
+ translateY
367
+ }
368
+ ];
369
+ }
370
+ case "translateX":
371
+ return {
372
+ translateX: this.Processor.Units.processLength(declarationValue.value)
373
+ };
374
+ case "translateY":
375
+ return {
376
+ translateY: this.Processor.Units.processLength(declarationValue.value)
377
+ };
378
+ case "translateZ": {
379
+ return {
380
+ translateZ: this.processValue(declarationValue.value)
381
+ };
382
+ }
383
+ case "rotate":
384
+ return {
385
+ rotate: `${declarationValue.value.value}${declarationValue.value.type}`
386
+ };
387
+ case "rotateX":
388
+ return {
389
+ rotateX: `${declarationValue.value.value}${declarationValue.value.type}`
390
+ };
391
+ case "rotateY":
392
+ return {
393
+ rotateY: `${declarationValue.value.value}${declarationValue.value.type}`
394
+ };
395
+ case "rotateZ":
396
+ return {
397
+ rotateZ: `${declarationValue.value.value}${declarationValue.value.type}`
398
+ };
399
+ case "scale": {
400
+ const [scaleX, scaleY] = declarationValue.value.map((x) => this.processValue(x));
401
+ if (scaleX === scaleY) {
402
+ return {
403
+ scale: scaleX
404
+ };
405
+ }
406
+ return [
407
+ {
408
+ scaleX
409
+ },
410
+ {
411
+ scaleY
412
+ }
413
+ ];
414
+ }
415
+ case "scaleX":
416
+ return {
417
+ scaleX: this.processValue(declarationValue.value)
418
+ };
419
+ case "scaleY":
420
+ return {
421
+ scaleY: this.processValue(declarationValue.value)
422
+ };
423
+ case "scaleZ":
424
+ return {
425
+ scaleZ: this.processValue(declarationValue.value)
426
+ };
427
+ case "percentage":
428
+ return `${declarationValue.value * 100}%`;
429
+ case "token-list":
430
+ return declarationValue.value.reduce((acc, token) => {
431
+ const tokenValue = this.processValue(token);
432
+ return acc + tokenValue;
433
+ }, "");
434
+ case "rgb":
435
+ case "oklab":
436
+ case "oklch":
437
+ case "hsl":
438
+ case "hwb":
439
+ case "lab":
440
+ case "lch":
441
+ case "srgb":
442
+ return this.Processor.Color.processColor(declarationValue);
443
+ case "delim":
444
+ return ` ${declarationValue.value} `;
445
+ case "ident":
446
+ if (this.Processor.Color.isColor(declarationValue.value)) {
447
+ return this.Processor.Color.processColor(declarationValue.value);
448
+ }
449
+ if (declarationValue.value === "currentcolor") {
450
+ return 'this["currentColor"]';
451
+ }
452
+ return declarationValue.value;
453
+ case "env":
454
+ if (declarationValue.value.name.type === "ua" && declarationValue.value.name.value.startsWith("safe-area-inset-")) {
455
+ const inset = declarationValue.value.name.value.replace("safe-area-inset-", "");
456
+ return `rt.insets.${inset}`;
457
+ }
458
+ this.logUnsupported(`Unsupported env value - ${JSON.stringify(declarationValue.value)}`);
459
+ return void 0;
460
+ case "time": {
461
+ const unit = declarationValue.value.type === "milliseconds" ? "ms" : "s";
462
+ return `${declarationValue.value.value}${unit}`;
463
+ }
464
+ case "cubic-bezier": {
465
+ const bezier = [
466
+ declarationValue.x1,
467
+ declarationValue.y1,
468
+ declarationValue.x2,
469
+ declarationValue.y2
470
+ ];
471
+ return `rt.cubicBezier(${bezier.join(",")})`;
472
+ }
473
+ case "seconds":
474
+ return `${declarationValue.value}s`;
475
+ case "milliseconds":
476
+ return `${declarationValue.value}ms`;
477
+ case "pair":
478
+ return declarationValue.inside.type;
479
+ case "currentcolor":
480
+ return 'this["currentColor"]';
481
+ case "calc":
482
+ return this.Processor.Functions.processCalc(declarationValue.value);
483
+ case "min":
484
+ case "max":
485
+ case "abs":
486
+ return this.Processor.Functions.processMathFunction(declarationValue.type, declarationValue.value);
487
+ case "keyword":
488
+ if ("value" in declarationValue) {
489
+ return declarationValue.value;
490
+ }
491
+ this.logUnsupported(`Unsupported keyword value - ${JSON.stringify(declarationValue)}`);
492
+ return void 0;
493
+ case "min-max":
494
+ case "track-breadth":
495
+ return declarationValue.type;
496
+ case "explicit":
497
+ return `${this.processValue(declarationValue.width)} ${this.processValue(declarationValue.height)}`;
498
+ case "angle":
499
+ return `${declarationValue.value.value}${declarationValue.value.type}`;
500
+ case "gradient":
501
+ if (declarationValue.value.type === "linear") {
502
+ const direction = String(this.processValue(declarationValue.value.direction));
503
+ return [
504
+ direction.includes("deg") ? direction : `to ${direction}`,
505
+ ...declarationValue.value.items.map((item) => this.processValue(item))
506
+ ].join(", ");
507
+ }
508
+ return void 0;
509
+ case "color-stop":
510
+ return [
511
+ this.Processor.Color.processColor(declarationValue.color),
512
+ declarationValue.position ? this.processValue(declarationValue.position) : null
513
+ ].filter(isDefined).join(" ");
514
+ case "side":
515
+ return declarationValue.side;
516
+ case "absolute":
517
+ if ("value" in declarationValue) {
518
+ return typeof declarationValue.value === "string" ? declarationValue.value : this.processValue(declarationValue.value);
519
+ }
520
+ return declarationValue.type;
521
+ case "hash":
522
+ return `#${declarationValue.value}`;
523
+ case "line-style":
524
+ return declarationValue.value;
525
+ case "parenthesis-block":
526
+ return "(";
527
+ case "close-parenthesis":
528
+ return ")";
529
+ case "light-dark":
530
+ return `rt.lightDark( ${this.processValue(declarationValue.light)}, ${this.processValue(declarationValue.dark)} )`;
531
+ case "unresolved-color":
532
+ return this.getProcessedValue(declarationValue.value);
533
+ case "track-list":
534
+ case "sticky":
535
+ case "fit-content":
536
+ case "shape":
537
+ return void 0;
538
+ case "weight":
539
+ case "horizontal":
540
+ case "vertical":
541
+ case "white-space":
542
+ case "string":
543
+ case "self-position":
544
+ case "content-distribution":
545
+ case "content-position":
546
+ return declarationValue.value;
547
+ case "baseline-position":
548
+ return "baseline";
549
+ default:
550
+ if (Object.keys(declarationValue).length === 1) {
551
+ return declarationValue.type;
552
+ }
553
+ this.logUnsupported(`Unsupported value type - ${JSON.stringify(declarationValue.type)}`);
554
+ return void 0;
555
+ }
556
+ }
557
+ if ("top" in declarationValue) {
558
+ return {
559
+ top: this.processValue(declarationValue.top),
560
+ right: this.processValue(declarationValue.right),
561
+ bottom: this.processValue(declarationValue.bottom),
562
+ left: this.processValue(declarationValue.left)
563
+ };
564
+ }
565
+ if ("topLeft" in declarationValue) {
566
+ return {
567
+ topLeft: this.processValue(declarationValue.topLeft),
568
+ topRight: this.processValue(declarationValue.topRight),
569
+ bottomLeft: this.processValue(declarationValue.bottomLeft),
570
+ bottomRight: this.processValue(declarationValue.bottomRight)
571
+ };
572
+ }
573
+ if ("grow" in declarationValue) {
574
+ return {
575
+ flexGrow: declarationValue.grow,
576
+ flexShrink: declarationValue.shrink,
577
+ flexBasis: this.processValue(declarationValue.basis)
578
+ };
579
+ }
580
+ if (Array.isArray(declarationValue)) {
581
+ if (declarationValue.length === 1) {
582
+ return this.processValue(declarationValue[0]);
583
+ }
584
+ return this.addComaBetweenTokens(declarationValue).reduce((acc, value, index, array) => {
585
+ if (typeof value === "object") {
586
+ const nextValue = array.at(index + 1);
587
+ if (deepEqual(value, nextValue)) {
588
+ return acc;
589
+ }
590
+ const result = this.processValue(value);
591
+ return acc === "" && typeof result === "number" ? result : acc + result;
592
+ }
593
+ return acc + value;
594
+ }, "");
595
+ }
596
+ if ("property" in declarationValue) {
597
+ const property = typeof declarationValue.property === "string" ? declarationValue.property : declarationValue.property.property;
598
+ return `${property},`;
599
+ }
600
+ if ("case" in declarationValue) {
601
+ return declarationValue.case;
602
+ }
603
+ if ("angle" in declarationValue) {
604
+ const angles = pipe([
605
+ ["rotateX", declarationValue.x * declarationValue.angle.value],
606
+ ["rotateY", declarationValue.y * declarationValue.angle.value],
607
+ ["rotateZ", declarationValue.z * declarationValue.angle.value]
608
+ ])(
609
+ (x) => x.filter(([, value]) => value !== 0),
610
+ (x) => x.map(([key, value]) => [key, `${value}${declarationValue.angle.type}`]),
611
+ Object.fromEntries
612
+ );
613
+ return angles;
614
+ }
615
+ if (this.isOverflow(declarationValue)) {
616
+ if (declarationValue.x === declarationValue.y) {
617
+ return {
618
+ overflow: declarationValue.x
619
+ };
620
+ }
621
+ return {
622
+ overflowX: declarationValue.x,
623
+ overflowY: declarationValue.y
624
+ };
625
+ }
626
+ if ("auto" in declarationValue) {
627
+ return declarationValue.ratio ? `${declarationValue.ratio[0]}/${declarationValue.ratio[1]}` : "auto";
628
+ }
629
+ if ("x" in declarationValue && "y" in declarationValue) {
630
+ return {
631
+ x: this.processValue(declarationValue.x),
632
+ y: this.processValue(declarationValue.y)
633
+ };
634
+ }
635
+ if ("xOffset" in declarationValue) {
636
+ return [
637
+ "inset" in declarationValue && declarationValue.inset ? "inset" : void 0,
638
+ this.processValue(declarationValue.xOffset),
639
+ this.processValue(declarationValue.yOffset),
640
+ this.processValue(declarationValue.blur),
641
+ this.processValue(declarationValue.spread),
642
+ this.processValue(declarationValue.color)
643
+ ].filter(isDefined).join(" ");
644
+ }
645
+ if ("blockStart" in declarationValue) {
646
+ const startValue = this.processValue(declarationValue.blockStart);
647
+ const endValue = this.processValue(declarationValue.blockEnd);
648
+ return {
649
+ start: startValue,
650
+ end: endValue
651
+ };
652
+ }
653
+ if ("inlineStart" in declarationValue) {
654
+ const startValue = this.processValue(declarationValue.inlineStart);
655
+ const endValue = this.processValue(declarationValue.inlineEnd);
656
+ return {
657
+ start: startValue,
658
+ end: endValue
659
+ };
660
+ }
661
+ if ("start" in declarationValue) {
662
+ const startValue = this.processValue(declarationValue.start);
663
+ const endValue = this.processValue(declarationValue.end);
664
+ return {
665
+ start: startValue,
666
+ end: endValue
667
+ };
668
+ }
669
+ if ("row" in declarationValue) {
670
+ return {
671
+ row: this.processValue(declarationValue.row),
672
+ column: this.processValue(declarationValue.column)
673
+ };
674
+ }
675
+ if ("keyword" in declarationValue) {
676
+ return declarationValue.keyword === "auto" || declarationValue.keyword === "pointer" ? declarationValue.keyword : "auto";
677
+ }
678
+ if ("style" in declarationValue && "width" in declarationValue) {
679
+ return {
680
+ style: this.processValue(declarationValue.style),
681
+ width: declarationValue.width.type === "length" ? this.processValue(declarationValue.width.value) : void 0,
682
+ color: this.Processor.Color.processColor(declarationValue.color)
683
+ };
684
+ }
685
+ if ("duration" in declarationValue) {
686
+ return [
687
+ this.processValue(declarationValue.name),
688
+ this.processValue(declarationValue.duration),
689
+ this.processValue(declarationValue.timingFunction),
690
+ this.processValue(declarationValue.delay),
691
+ this.processValue(declarationValue.iterationCount),
692
+ declarationValue.direction,
693
+ declarationValue.fillMode,
694
+ declarationValue.playState,
695
+ this.processValue(declarationValue.timeline)
696
+ ].filter(Boolean).join(" ");
697
+ }
698
+ this.logUnsupported(`Unsupported value - ${JSON.stringify(declarationValue)}`);
699
+ return void 0;
700
+ }
701
+ isOverflow(value) {
702
+ return typeof value === "object" && "x" in value && ["hidden", "visible"].includes(value.x);
703
+ }
704
+ /**
705
+ * Between some tokens there isn't a comma but it should be.
706
+ * For example this applies to Array of shadows
707
+ */
708
+ addComaBetweenTokens(values) {
709
+ return values.reduce((acc, value, index, array) => {
710
+ const next = array.at(index + 1);
711
+ acc.push(value);
712
+ if (next === void 0) {
713
+ return acc;
714
+ }
715
+ if (typeof next === "object" && "type" in next && next.type === "token" && next.value.type === "comma") {
716
+ return acc;
717
+ }
718
+ if (!(typeof value === "object" && "xOffset" in value && "blur" in value)) {
719
+ return acc;
720
+ }
721
+ acc.push({
722
+ type: "token",
723
+ value: {
724
+ type: "comma"
725
+ }
726
+ });
727
+ return acc;
728
+ }, []);
729
+ }
730
+ logUnsupported(message) {
731
+ this.logger.warn(
732
+ [
733
+ message,
734
+ this.Processor.meta.className !== void 0 ? `for className ${this.Processor.meta.className}` : null
735
+ ].filter(Boolean).join(" ")
736
+ );
737
+ }
738
+ makeSafeForSerialization(value) {
739
+ if (shouldBeSerialized(value)) {
740
+ return value;
741
+ }
742
+ if (value.endsWith("%")) {
743
+ return `"${roundToPrecision(parseFloat(value), 2)}%"`;
744
+ }
745
+ return `"${value}"`;
746
+ }
747
+ }
748
+
749
+ class Functions {
750
+ constructor(Processor) {
751
+ this.Processor = Processor;
752
+ }
753
+ logger = new Logger("Functions");
754
+ processCalc(calc) {
755
+ switch (calc.type) {
756
+ case "sum": {
757
+ const sum = calc.value.map((x) => this.processCalc(x)).join(" + ");
758
+ return this.tryEval(sum);
759
+ }
760
+ case "value":
761
+ return this.Processor.CSS.processValue(calc.value);
762
+ case "function":
763
+ return this.Processor.CSS.processValue(calc.value);
764
+ case "number":
765
+ return String(calc.value);
766
+ default:
767
+ this.logger.warn(`Unsupported calc type - ${calc.type}`);
768
+ return "";
769
+ }
770
+ }
771
+ processFunction(fn) {
772
+ if (typeof fn !== "object") {
773
+ this.logger.warn(`Unsupported function - ${fn}`);
774
+ return fn;
775
+ }
776
+ if (fn.name === "calc") {
777
+ const calc = this.Processor.CSS.processValue(fn.arguments);
778
+ return pipe(calc)(
779
+ String,
780
+ (x) => this.Processor.Functions.tryEval(x)
781
+ );
782
+ }
783
+ if (fn.name === "cubic-bezier") {
784
+ const cubicArguments = pipe(this.Processor.CSS.processValue(fn.arguments))(
785
+ String,
786
+ (x) => x.replace(/,\s/g, ",")
787
+ );
788
+ return `rt.cubicBezier(${cubicArguments})`;
789
+ }
790
+ if (fn.name === "max") {
791
+ return `Math.max(${this.Processor.CSS.processValue(fn.arguments)})`;
792
+ }
793
+ if (fn.name === "linear-gradient") {
794
+ return this.Processor.CSS.processValue(fn.arguments);
795
+ }
796
+ if (fn.name === "color-mix") {
797
+ return this.processColorMix(fn);
798
+ }
799
+ if ([
800
+ "rgb",
801
+ "oklab",
802
+ "oklch",
803
+ "hsl",
804
+ "hwb",
805
+ "lab",
806
+ "lch",
807
+ "srgb"
808
+ ].includes(fn.name)) {
809
+ const color = `${fn.name}(${this.Processor.CSS.processValue(fn.arguments)})`;
810
+ return this.Processor.Color.processColor(color);
811
+ }
812
+ if ([
813
+ "blur",
814
+ "brightness",
815
+ "contrast",
816
+ "grayscale",
817
+ "hue-rotate",
818
+ "invert",
819
+ "opacity",
820
+ "saturate",
821
+ "sepia",
822
+ "conic-gradient",
823
+ "radial-gradient"
824
+ ].includes(fn.name)) {
825
+ return '""';
826
+ }
827
+ if (["skewX", "skewY"].includes(fn.name)) {
828
+ return `"${fn.name}(${this.Processor.CSS.processValue(fn.arguments).replace(/"/g, "")})"`;
829
+ }
830
+ if (fn.name === "hairlineWidth") {
831
+ return "rt.hairlineWidth";
832
+ }
833
+ if (fn.name === "pixelRatio") {
834
+ return `rt.pixelRatio(${this.Processor.CSS.processValue(fn.arguments)})`;
835
+ }
836
+ if (fn.name === "fontScale") {
837
+ return `rt.fontScale(${this.Processor.CSS.processValue(fn.arguments)})`;
838
+ }
839
+ if (fn.name === "drop-shadow") {
840
+ return void 0;
841
+ }
842
+ this.logger.warn(`Unsupported function - ${fn.name}`);
843
+ return fn.name;
844
+ }
845
+ processMathFunction(name, value) {
846
+ if (!Array.isArray(value)) {
847
+ return `Math.${name}(${this.processCalc(value)})`;
848
+ }
849
+ const values = value.map((x) => this.processCalc(x)).join(" , ");
850
+ return `Math.${name}(${values})`;
851
+ }
852
+ tryEval(value) {
853
+ const units = Array.from(
854
+ value.replace(/"/g, "").match(/(?<![A-Za-z-])(?:%|deg|rad|grad|turn)(?=\s|$)/g) ?? []
855
+ );
856
+ if (units.length === 0) {
857
+ return value;
858
+ }
859
+ if (new Set(units).size !== 1) {
860
+ this.logger.error(`Invalid calc, you can't mix multiple units`);
861
+ return value;
862
+ }
863
+ if (units.includes("%") && value.includes("+")) {
864
+ this.logger.error(`Invalid calc, you can't mix % with other units`);
865
+ return value;
866
+ }
867
+ const unit = units.at(0) ?? "";
868
+ try {
869
+ const numericValue = value.replace(/"/g, "").replace(new RegExp(unit, "g"), "");
870
+ return new Function(`return ${numericValue} + '${unit}'`)();
871
+ } catch {
872
+ this.logger.error(`Invalid calc ${value}`);
873
+ return value;
874
+ }
875
+ }
876
+ processColorMix(fn) {
877
+ const tokens = fn.arguments.map(
878
+ (arg) => pipe(arg)(
879
+ (x) => this.Processor.CSS.processValue(x),
880
+ String,
881
+ (x) => x.trim()
882
+ )
883
+ ).filter((token) => !["", ",", "in", "srgb", "rgb", "hsl", "hwb", "lab", "lch", "oklab", "oklch"].includes(token.replace(/"/g, "")));
884
+ return `rt.colorMix(${tokens.join(", ")})`;
885
+ }
886
+ }
887
+
888
+ class MQ {
889
+ constructor(Processor) {
890
+ this.Processor = Processor;
891
+ }
892
+ processMediaQueries(mediaQueries) {
893
+ const mq = this.getInitialMediaQueryResolver();
894
+ mediaQueries.forEach((mediaQuery) => {
895
+ const { condition, mediaType } = mediaQuery;
896
+ if ([Platform.Android, Platform.iOS, Platform.Native].includes(mediaType)) {
897
+ mq.platform = mediaType;
898
+ return;
899
+ }
900
+ if (condition?.type !== "feature") {
901
+ return;
902
+ }
903
+ if (condition.value.type === "range") {
904
+ this.processWidthMediaQuery(condition.value, mq);
905
+ }
906
+ if (condition.value.type === "plain") {
907
+ this.processPlainMediaQuery(condition.value, mq);
908
+ }
909
+ });
910
+ return mq;
911
+ }
912
+ processWidthMediaQuery(query, mq) {
913
+ const { operator, value } = query;
914
+ const result = this.Processor.CSS.processValue(value);
915
+ if (operator === "greater-than-equal" || operator === "greater-than") {
916
+ mq.minWidth = result;
917
+ }
918
+ if (operator === "less-than-equal" || operator === "less-than") {
919
+ mq.maxWidth = result;
920
+ }
921
+ }
922
+ processPlainMediaQuery(query, mq) {
923
+ const { value, name } = query;
924
+ switch (name) {
925
+ case "orientation":
926
+ mq.orientation = value.value;
927
+ break;
928
+ case "prefers-color-scheme":
929
+ mq.colorScheme = value.value;
930
+ break;
931
+ }
932
+ }
933
+ getInitialMediaQueryResolver() {
934
+ return {
935
+ minWidth: 0,
936
+ maxWidth: Number.MAX_VALUE,
937
+ platform: null,
938
+ rtl: null,
939
+ important: false,
940
+ colorScheme: null,
941
+ orientation: null,
942
+ theme: null,
943
+ active: null,
944
+ focus: null,
945
+ disabled: null
946
+ };
947
+ }
948
+ }
949
+
950
+ const cssToRNMap = {
951
+ backgroundSize: (value) => {
952
+ return {
953
+ resizeMode: value
954
+ };
955
+ },
956
+ transitionProperty: (value) => {
957
+ return {
958
+ transitionProperty: value.replace(/"/g, "").split(",").filter((token) => token !== "" && !token.startsWith("--")).map((token) => `"${toCamelCase(token)}"`)
959
+ };
960
+ },
961
+ flex: (value) => {
962
+ if (typeof value === "object") {
963
+ return value;
964
+ }
965
+ return {
966
+ flex: value
967
+ };
968
+ },
969
+ overflow: (value) => {
970
+ if (typeof value === "object") {
971
+ return value;
972
+ }
973
+ return {
974
+ overflow: value
975
+ };
976
+ },
977
+ backdropFilter: () => ({}),
978
+ backgroundImage: (value) => ({
979
+ experimental_backgroundImage: value
980
+ }),
981
+ borderSpacing: () => ({}),
982
+ translate: (value) => {
983
+ if (typeof value === "object" && "x" in value && "y" in value) {
984
+ return {
985
+ translateX: value.x,
986
+ translateY: value.y
987
+ };
988
+ }
989
+ if (typeof value === "string") {
990
+ const [x, y] = value.split(" ");
991
+ return {
992
+ translateX: x,
993
+ translateY: y ?? x
994
+ };
995
+ }
996
+ return {};
997
+ },
998
+ rotate: (value) => {
999
+ if (typeof value === "object") {
1000
+ return value;
1001
+ }
1002
+ return {
1003
+ rotate: value
1004
+ };
1005
+ },
1006
+ scale: (value) => {
1007
+ if (typeof value === "object") {
1008
+ return {
1009
+ scaleX: value.x,
1010
+ scaleY: value.y,
1011
+ scaleZ: value.z
1012
+ };
1013
+ }
1014
+ if (typeof value === "string") {
1015
+ const [x, y, z] = value.split(" ");
1016
+ return {
1017
+ scaleX: x,
1018
+ scaleY: y,
1019
+ scaleZ: z
1020
+ };
1021
+ }
1022
+ return {};
1023
+ },
1024
+ transform: (value) => {
1025
+ if (typeof value === "string" || Array.isArray(value)) {
1026
+ return {
1027
+ transform: value
1028
+ };
1029
+ }
1030
+ if (typeof value === "object") {
1031
+ return Object.keys(value).length === 0 ? { transform: [] } : value;
1032
+ }
1033
+ return {};
1034
+ },
1035
+ fontSize: (value) => {
1036
+ return {
1037
+ fontSize: value,
1038
+ "--uniwind-em": value
1039
+ };
1040
+ },
1041
+ borderInlineWidth: (value) => {
1042
+ const borderWidth = typeof value === "object" ? Object.values(value)[0] : value;
1043
+ return {
1044
+ borderLeftWidth: borderWidth,
1045
+ borderRightWidth: borderWidth
1046
+ };
1047
+ },
1048
+ borderBlockWidth: (value) => {
1049
+ const borderWidth = typeof value === "object" ? Object.values(value)[0] : value;
1050
+ return {
1051
+ borderTopWidth: borderWidth,
1052
+ borderBottomWidth: borderWidth
1053
+ };
1054
+ },
1055
+ borderInlineStyle: (value) => {
1056
+ return {
1057
+ borderStyle: value
1058
+ };
1059
+ },
1060
+ borderBlockStyle: (value) => {
1061
+ return {
1062
+ borderStyle: value
1063
+ };
1064
+ },
1065
+ borderStyle: (value) => {
1066
+ const borderStyle = typeof value === "object" ? Object.values(value)[0] : value;
1067
+ return {
1068
+ borderStyle
1069
+ };
1070
+ },
1071
+ transformOrigin: (value) => {
1072
+ if (typeof value === "object") {
1073
+ return {
1074
+ transformOrigin: `${value.x} ${value.y}`
1075
+ };
1076
+ }
1077
+ return {
1078
+ transformOrigin: value
1079
+ };
1080
+ },
1081
+ fontVariantNumeric: (value) => ({
1082
+ fontVariant: value
1083
+ })
1084
+ };
1085
+ class RN {
1086
+ constructor(Processor) {
1087
+ this.Processor = Processor;
1088
+ }
1089
+ cssToRN(property, value) {
1090
+ const transformedProperty = property.startsWith("--") ? property : pipe(property)(
1091
+ toCamelCase,
1092
+ (x) => {
1093
+ if (x.includes("padding") || x.includes("margin")) {
1094
+ return x.replace("Inline", "Horizontal").replace("Block", "Vertical");
1095
+ }
1096
+ return x;
1097
+ }
1098
+ );
1099
+ const rn = this.transformProperty(
1100
+ transformedProperty,
1101
+ typeof value === "string" ? addMissingSpaces(value) : value
1102
+ );
1103
+ return Object.entries(rn).filter(([, value2]) => isDefined(value2));
1104
+ }
1105
+ transformProperty(property, value) {
1106
+ if (property in cssToRNMap) {
1107
+ return cssToRNMap[property](value);
1108
+ }
1109
+ if (typeof value === "object") {
1110
+ const transformed = this.transformObjectProperty(property, value);
1111
+ if (transformed) {
1112
+ return transformed;
1113
+ }
1114
+ }
1115
+ return {
1116
+ [property]: value
1117
+ };
1118
+ }
1119
+ transformObjectProperty(property, value) {
1120
+ const properties = Object.keys(value);
1121
+ const propertyEnd = property.includes("border") ? property.split("border").at(-1) ?? "" : "";
1122
+ const transformedProperty = property.replace(propertyEnd, "");
1123
+ const isSpacing = property.includes("margin") || property.includes("padding");
1124
+ const wrapProperty = (prop) => `${transformedProperty}${prop}${propertyEnd}`;
1125
+ if (properties.every((property2) => ["row", "column"].includes(property2))) {
1126
+ return {
1127
+ rowGap: value.row,
1128
+ columnGap: value.column
1129
+ };
1130
+ }
1131
+ if (properties.every((property2) => ["start", "end"].includes(property2))) {
1132
+ if (isSpacing && property.includes("Horizontal")) {
1133
+ return {
1134
+ [`${property.replace("Horizontal", "Left")}`]: value.start,
1135
+ [`${property.replace("Horizontal", "Right")}`]: value.end
1136
+ };
1137
+ }
1138
+ if (isSpacing && property.includes("Vertical")) {
1139
+ return {
1140
+ [`${property.replace("Vertical", "Top")}`]: value.start,
1141
+ [`${property.replace("Vertical", "Bottom")}`]: value.end
1142
+ };
1143
+ }
1144
+ return {
1145
+ [wrapProperty("Start")]: value.start,
1146
+ [wrapProperty("End")]: value.end
1147
+ };
1148
+ }
1149
+ if (properties.every((property2) => ["top", "right", "bottom", "left"].includes(property2))) {
1150
+ return {
1151
+ [wrapProperty("Top")]: value.top,
1152
+ [wrapProperty("Right")]: value.right,
1153
+ [wrapProperty("Bottom")]: value.bottom,
1154
+ [wrapProperty("Left")]: value.left
1155
+ };
1156
+ }
1157
+ if (properties.every((property2) => ["topLeft", "topRight", "bottomRight", "bottomLeft"].includes(property2))) {
1158
+ return {
1159
+ [wrapProperty("TopLeft")]: value.topLeft,
1160
+ [wrapProperty("TopRight")]: value.topRight,
1161
+ [wrapProperty("BottomRight")]: value.bottomRight,
1162
+ [wrapProperty("BottomLeft")]: value.bottomLeft
1163
+ };
1164
+ }
1165
+ if (properties.every((property2) => ["style", "width", "color"].includes(property2))) {
1166
+ return {
1167
+ [wrapProperty("Style")]: value.style,
1168
+ [wrapProperty("Width")]: value.width,
1169
+ [wrapProperty("Color")]: value.color
1170
+ };
1171
+ }
1172
+ }
1173
+ }
1174
+
1175
+ class Units {
1176
+ constructor(Processor) {
1177
+ this.Processor = Processor;
1178
+ }
1179
+ logger = new Logger("Units");
1180
+ processLength(length) {
1181
+ if (typeof length === "number") {
1182
+ return length;
1183
+ }
1184
+ if ("unit" in length) {
1185
+ switch (length.unit) {
1186
+ case "px":
1187
+ return this.replaceInfinity(length.value);
1188
+ case "vw":
1189
+ return `rt.screen.width * ${length.value / 100}`;
1190
+ case "vh":
1191
+ return `rt.screen.height * ${length.value / 100}`;
1192
+ case "rem":
1193
+ return length.value * this.Processor.vars["--uniwind-em"];
1194
+ case "em":
1195
+ return `this[\`--uniwind-em\`] * ${length.value}`;
1196
+ default:
1197
+ this.logger.warn(`Unsupported unit - ${length.unit}`);
1198
+ return length.value;
1199
+ }
1200
+ }
1201
+ return this.Processor.CSS.processValue(length);
1202
+ }
1203
+ processAnyLength(length) {
1204
+ if ("type" in length) {
1205
+ switch (length.type) {
1206
+ case "value":
1207
+ case "dimension":
1208
+ return this.processLength(length.value);
1209
+ case "percentage":
1210
+ return `${length.value * 100}%`;
1211
+ default:
1212
+ this.logger.warn(`Unsupported length type - ${length.type}`);
1213
+ return length.value;
1214
+ }
1215
+ }
1216
+ return this.processLength(length);
1217
+ }
1218
+ replaceInfinity(value) {
1219
+ return value === Infinity ? 99999 : value;
1220
+ }
1221
+ }
1222
+
1223
+ class Var {
1224
+ constructor(Processor) {
1225
+ this.Processor = Processor;
1226
+ }
1227
+ processVar(variable) {
1228
+ const value = `this[\`${variable.name.ident}\`]`;
1229
+ if (!variable.fallback || variable.fallback.length === 0) {
1230
+ return value;
1231
+ }
1232
+ const fallback = this.Processor.CSS.processValue(variable.fallback);
1233
+ return `${value} ?? ${fallback}`;
1234
+ }
1235
+ }
1236
+
1237
+ class ProcessorBuilder {
1238
+ constructor(themes, polyfills) {
1239
+ this.themes = themes;
1240
+ this.polyfills = polyfills;
1241
+ this.vars["--uniwind-em"] = polyfills?.rem ?? 16;
1242
+ }
1243
+ stylesheets = {};
1244
+ vars = {};
1245
+ scopedVars = {};
1246
+ CSS = new CSS(this);
1247
+ RN = new RN(this);
1248
+ Var = new Var(this);
1249
+ MQ = new MQ(this);
1250
+ Color = new Color(this);
1251
+ Units = new Units(this);
1252
+ Functions = new Functions(this);
1253
+ meta = {};
1254
+ declarationConfig = this.getDeclarationConfig();
1255
+ transform(css) {
1256
+ transform$1({
1257
+ filename: "tailwind.css",
1258
+ code: Buffer.from(css),
1259
+ visitor: {
1260
+ StyleSheet: (styleSheet) => styleSheet.rules.forEach((rule) => {
1261
+ this.declarationConfig = this.getDeclarationConfig();
1262
+ this.parseRuleRec(rule);
1263
+ })
1264
+ }
1265
+ });
1266
+ }
1267
+ getDeclarationConfig() {
1268
+ return {
1269
+ className: null,
1270
+ rtl: null,
1271
+ mediaQueries: [],
1272
+ root: false,
1273
+ theme: null,
1274
+ active: null,
1275
+ focus: null,
1276
+ disabled: null
1277
+ };
1278
+ }
1279
+ addDeclaration(declaration, important = false) {
1280
+ const isVar = this.declarationConfig.root || this.declarationConfig.className === null;
1281
+ const mq = this.MQ.processMediaQueries(this.declarationConfig.mediaQueries);
1282
+ const style = (() => {
1283
+ if (!isVar) {
1284
+ return this.stylesheets[this.declarationConfig.className]?.at(-1);
1285
+ }
1286
+ if (mq.platform !== null) {
1287
+ const platformKey = `__uniwind-platform-${mq.platform}`;
1288
+ this.scopedVars[platformKey] ??= {};
1289
+ return this.scopedVars[platformKey];
1290
+ }
1291
+ if (this.declarationConfig.theme === null) {
1292
+ return this.vars;
1293
+ }
1294
+ const themeKey = `__uniwind-theme-${this.declarationConfig.theme}`;
1295
+ this.scopedVars[themeKey] ??= {};
1296
+ return this.scopedVars[themeKey];
1297
+ })();
1298
+ if (!isVar) {
1299
+ Object.assign(style, mq);
1300
+ style.importantProperties ??= [];
1301
+ style.rtl = this.declarationConfig.rtl;
1302
+ style.theme = mq.colorScheme ?? this.declarationConfig.theme;
1303
+ style.active = this.declarationConfig.active;
1304
+ style.focus = this.declarationConfig.focus;
1305
+ style.disabled = this.declarationConfig.disabled;
1306
+ this.meta.className = this.declarationConfig.className;
1307
+ }
1308
+ if (declaration.property === "unparsed") {
1309
+ style[declaration.value.propertyId.property] = this.CSS.processValue(declaration.value.value);
1310
+ if (!isVar && important) {
1311
+ style.importantProperties.push(declaration.value.propertyId.property);
1312
+ }
1313
+ return;
1314
+ }
1315
+ if (declaration.property === "custom") {
1316
+ style[declaration.value.name] = this.CSS.processValue(declaration.value.value);
1317
+ if (!isVar && important) {
1318
+ style.importantProperties.push(declaration.value.name);
1319
+ }
1320
+ return;
1321
+ }
1322
+ style[declaration.property] = this.CSS.processValue(declaration.value);
1323
+ if (!isVar && important) {
1324
+ style.importantProperties.push(declaration.property);
1325
+ }
1326
+ }
1327
+ parseRuleRec(rule) {
1328
+ if (this.declarationConfig.className !== null) {
1329
+ const lastStyle = this.stylesheets[this.declarationConfig.className]?.at(-1);
1330
+ if (lastStyle !== void 0 && Object.keys(lastStyle).length > 0) {
1331
+ this.stylesheets[this.declarationConfig.className]?.push({});
1332
+ }
1333
+ }
1334
+ if (rule.type === "style") {
1335
+ rule.value.selectors.forEach((selector) => {
1336
+ const [maybeClassNameSelector] = selector;
1337
+ const newClassName = maybeClassNameSelector?.type === "class" ? maybeClassNameSelector.name : void 0;
1338
+ if (newClassName !== void 0) {
1339
+ this.declarationConfig.className = newClassName;
1340
+ this.stylesheets[newClassName] ??= [];
1341
+ this.stylesheets[newClassName].push({});
1342
+ rule.value.declarations?.declarations?.forEach((declaration) => this.addDeclaration(declaration));
1343
+ rule.value.declarations?.importantDeclarations?.forEach((declaration) => this.addDeclaration(declaration, true));
1344
+ rule.value.rules?.forEach((rule2) => this.parseRuleRec(rule2));
1345
+ return;
1346
+ }
1347
+ let rtl = null;
1348
+ let theme = null;
1349
+ let active = null;
1350
+ let focus = null;
1351
+ let disabled = null;
1352
+ selector.forEach((selector2) => {
1353
+ if (selector2.type === "pseudo-class" && selector2.kind === "where") {
1354
+ selector2.selectors.forEach((selector3) => {
1355
+ selector3.forEach((selector4) => {
1356
+ if (selector4.type === "class" && this.themes.includes(selector4.name)) {
1357
+ theme = selector4.name;
1358
+ }
1359
+ if (selector4.type === "pseudo-class" && selector4.kind === "dir") {
1360
+ rtl = selector4.direction === "rtl";
1361
+ }
1362
+ });
1363
+ });
1364
+ }
1365
+ if (selector2.type === "pseudo-class" && selector2.kind === "active") {
1366
+ active = true;
1367
+ }
1368
+ if (selector2.type === "pseudo-class" && selector2.kind === "focus") {
1369
+ focus = true;
1370
+ }
1371
+ if (selector2.type === "pseudo-class" && selector2.kind === "disabled") {
1372
+ disabled = true;
1373
+ }
1374
+ });
1375
+ if ([rtl, theme, active, focus, disabled].some(Boolean)) {
1376
+ this.declarationConfig.rtl = rtl;
1377
+ this.declarationConfig.theme = theme;
1378
+ this.declarationConfig.active = active;
1379
+ this.declarationConfig.focus = focus;
1380
+ this.declarationConfig.disabled = disabled;
1381
+ rule.value.declarations?.declarations?.forEach((declaration) => this.addDeclaration(declaration));
1382
+ rule.value.declarations?.importantDeclarations?.forEach((declaration) => this.addDeclaration(declaration, true));
1383
+ rule.value.rules?.forEach((rule2) => this.parseRuleRec(rule2));
1384
+ this.declarationConfig.rtl = null;
1385
+ this.declarationConfig.theme = null;
1386
+ this.declarationConfig.active = null;
1387
+ this.declarationConfig.focus = null;
1388
+ this.declarationConfig.disabled = null;
1389
+ return;
1390
+ }
1391
+ selector.forEach((selectorToken) => {
1392
+ if (selectorToken.type === "pseudo-class" && selectorToken.kind === "root") {
1393
+ this.declarationConfig.root = true;
1394
+ rule.value.declarations?.declarations?.forEach((declaration) => this.addDeclaration(declaration));
1395
+ rule.value.declarations?.importantDeclarations?.forEach((declaration) => this.addDeclaration(declaration, true));
1396
+ rule.value.rules?.forEach((rule2) => this.parseRuleRec(rule2));
1397
+ }
1398
+ });
1399
+ });
1400
+ return;
1401
+ }
1402
+ if (rule.type === "supports") {
1403
+ rule.value.rules.forEach((rule2) => this.parseRuleRec(rule2));
1404
+ return;
1405
+ }
1406
+ if (rule.type === "media") {
1407
+ const { mediaQueries } = rule.value.query;
1408
+ this.declarationConfig.mediaQueries.push(...mediaQueries);
1409
+ rule.value.rules.forEach((rule2) => {
1410
+ this.parseRuleRec(rule2);
1411
+ this.declarationConfig = this.getDeclarationConfig();
1412
+ });
1413
+ return;
1414
+ }
1415
+ if (rule.type === "layer-block") {
1416
+ rule.value.rules.forEach((rule2) => this.parseRuleRec(rule2));
1417
+ return;
1418
+ }
1419
+ if (rule.type === "nested-declarations") {
1420
+ rule.value.declarations.declarations?.forEach((declaration) => this.addDeclaration(declaration));
1421
+ rule.value.declarations.importantDeclarations?.forEach((declaration) => this.addDeclaration(declaration, true));
1422
+ return;
1423
+ }
1424
+ if (rule.type === "property" && rule.value.initialValue) {
1425
+ this.vars[rule.value.name] = this.CSS.processValue(rule.value.initialValue);
1426
+ }
1427
+ }
1428
+ }
1429
+
1430
+ const compileVirtual = async ({ css, cssPath, platform, themes, polyfills, debug, candidates }) => {
1431
+ const compiler = await compile(css, {
1432
+ base: path.dirname(cssPath),
1433
+ onDependency: () => void 0
1434
+ });
1435
+ const scanner = new Scanner({
1436
+ sources: [
1437
+ ...compiler.sources,
1438
+ {
1439
+ negated: false,
1440
+ pattern: "**/*",
1441
+ base: path.dirname(cssPath)
1442
+ }
1443
+ ]
1444
+ });
1445
+ const tailwindCSS = compiler.build(candidates ?? scanner.scan());
1446
+ if (platform === Platform.Web) {
1447
+ return polyfillWeb(tailwindCSS);
1448
+ }
1449
+ const Processor = new ProcessorBuilder(themes, polyfills);
1450
+ Logger.debug = debug === true;
1451
+ Processor.transform(tailwindCSS);
1452
+ const stylesheet = serializeJSObject(
1453
+ addMetaToStylesTemplate(Processor, platform),
1454
+ (key, value) => `"${key}": ${value}`
1455
+ );
1456
+ const vars = serializeJSObject(
1457
+ Processor.vars,
1458
+ (key, value) => `get "${key}"() { return ${value} }`
1459
+ );
1460
+ const scopedVars = Object.fromEntries(
1461
+ Object.entries(Processor.scopedVars).map(([scopedVarsName, scopedVars2]) => [
1462
+ scopedVarsName,
1463
+ serializeJSObject(scopedVars2, (key, value) => `get "${key}"() { return ${value} }`)
1464
+ ])
1465
+ );
1466
+ const serializedScopedVars = Object.entries(scopedVars).map(([scopedVarsName, scopedVars2]) => `"${scopedVarsName}": ({ ${scopedVars2} }),`).join("");
1467
+ const currentColorVar = `get currentColor() { return rt.colorScheme === 'dark' ? '#ffffff' : '#000000' },`;
1468
+ return [
1469
+ "({",
1470
+ `scopedVars: ({ ${serializedScopedVars} }),`,
1471
+ `vars: ({ ${currentColorVar} ${vars} }),`,
1472
+ `stylesheet: ({ ${stylesheet} }),`,
1473
+ "})"
1474
+ ].join("");
1475
+ };
1476
+
1477
+ const injectThemes = async ({
1478
+ themes,
1479
+ dtsPath = "uniwind-types.d.ts",
1480
+ input
1481
+ }) => {
1482
+ const stringifiedThemes = stringifyThemes(themes);
1483
+ buildDtsFile(dtsPath, stringifiedThemes);
1484
+ await buildCSS(themes, input);
1485
+ return stringifiedThemes;
1486
+ };
1487
+
1488
+ let worker;
1489
+ try {
1490
+ try {
1491
+ const { unstable_transformerPath } = require("@expo/metro-config");
1492
+ worker = require(unstable_transformerPath);
1493
+ } catch {
1494
+ worker = require("@expo/metro-config/build/transform-worker/transform-worker.js");
1495
+ }
1496
+ } catch {
1497
+ worker = require("metro-transform-worker");
1498
+ }
1499
+ const transform = async (config, projectRoot, filePath, data, options) => {
1500
+ const isCss = options.type !== "asset" && path.join(process.cwd(), config.uniwind.cssEntryFile) === path.join(process.cwd(), filePath);
1501
+ if (filePath.endsWith("/components/web/metro-injected.js")) {
1502
+ const cssPath2 = path.join(process.cwd(), config.uniwind.cssEntryFile);
1503
+ const injectedThemesCode2 = await injectThemes({
1504
+ input: cssPath2,
1505
+ themes: config.uniwind.themes,
1506
+ dtsPath: config.uniwind.dtsFile
1507
+ });
1508
+ data = Buffer.from(
1509
+ [
1510
+ `import { Uniwind } from '${name}';`,
1511
+ `Uniwind.__reinit(() => ({}), ${injectedThemesCode2});`
1512
+ ].join(""),
1513
+ "utf-8"
1514
+ );
1515
+ }
1516
+ if (!isCss) {
1517
+ return worker.transform(config, projectRoot, filePath, data, options);
1518
+ }
1519
+ const cssPath = path.join(process.cwd(), config.uniwind.cssEntryFile);
1520
+ const injectedThemesCode = await injectThemes({
1521
+ input: cssPath,
1522
+ themes: config.uniwind.themes,
1523
+ dtsPath: config.uniwind.dtsFile
1524
+ });
1525
+ const css = fs.readFileSync(filePath, "utf-8");
1526
+ const platform = options.platform;
1527
+ const virtualCode = await compileVirtual({
1528
+ css,
1529
+ platform,
1530
+ themes: config.uniwind.themes,
1531
+ polyfills: config.uniwind.polyfills,
1532
+ cssPath,
1533
+ debug: config.uniwind.debug
1534
+ });
1535
+ const isWeb = platform === Platform.Web;
1536
+ data = Buffer.from(
1537
+ isWeb ? virtualCode : [
1538
+ `import { Uniwind } from '${name}';`,
1539
+ `Uniwind.__reinit(rt => ${virtualCode}, ${injectedThemesCode});`
1540
+ ].join(""),
1541
+ "utf-8"
1542
+ );
1543
+ const transform2 = await worker.transform(
1544
+ config,
1545
+ projectRoot,
1546
+ `${filePath}${isWeb ? "" : ".js"}`,
1547
+ data,
1548
+ options
1549
+ );
1550
+ transform2.output[0].data.css ??= {};
1551
+ transform2.output[0].data.css.skipCache = true;
1552
+ if (!isWeb) {
1553
+ transform2.output[0].data.css.code = "";
1554
+ }
1555
+ return transform2;
1556
+ };
1557
+
1558
+ export { transform };