@niibase/uniwind 1.6.3 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/common/{css → bundler/artifacts/css}/index.js +1 -4
  3. package/dist/common/{css → bundler/artifacts/css}/themes.js +1 -1
  4. package/dist/common/{utils/buildDtsFile.js → bundler/artifacts/dts.js} +1 -2
  5. package/dist/common/bundler/config.js +69 -0
  6. package/dist/common/bundler/css-compiler/compileCSS.js +18 -0
  7. package/dist/common/bundler/css-compiler/compileNativeCSS.js +19 -0
  8. package/dist/common/bundler/css-compiler/compileTailwind.js +27 -0
  9. package/dist/common/bundler/css-compiler/compileWebCSS.js +15 -0
  10. package/dist/common/{vite → bundler/css-compiler}/index.js +4 -4
  11. package/dist/common/bundler/css-processor/addMetaToStylesTemplate.js +130 -0
  12. package/dist/common/bundler/css-processor/animation.js +112 -0
  13. package/dist/common/bundler/css-processor/color.js +66 -0
  14. package/dist/common/bundler/css-processor/css.js +510 -0
  15. package/dist/common/bundler/css-processor/functions.js +145 -0
  16. package/dist/common/bundler/css-processor/index.js +38 -0
  17. package/dist/common/bundler/css-processor/mq.js +87 -0
  18. package/dist/common/bundler/css-processor/processor.js +353 -0
  19. package/dist/common/bundler/css-processor/rn.js +356 -0
  20. package/dist/common/bundler/css-processor/serialize.js +86 -0
  21. package/dist/common/bundler/css-processor/types.js +1 -0
  22. package/dist/common/bundler/css-processor/units.js +55 -0
  23. package/dist/common/bundler/css-processor/utils.js +63 -0
  24. package/dist/common/bundler/css-processor/var.js +20 -0
  25. package/dist/common/{css-visitor → bundler/css-visitor}/rule-visitor.js +5 -5
  26. package/dist/common/{css-visitor → bundler/css-visitor}/visitor.js +5 -6
  27. package/dist/common/bundler/logger.js +41 -0
  28. package/dist/common/bundler/types.js +1 -0
  29. package/dist/common/common/consts.js +26 -2
  30. package/dist/common/components/index.js +0 -3
  31. package/dist/common/components/web/rnw.js +2 -2
  32. package/dist/common/core/config/config.common.js +15 -9
  33. package/dist/common/core/config/config.js +2 -2
  34. package/dist/common/core/config/config.native.js +3 -3
  35. package/dist/common/core/listener.js +10 -10
  36. package/dist/common/core/native/runtime.js +7 -3
  37. package/dist/common/core/native/store.js +3 -4
  38. package/dist/common/core/web/cssListener.js +2 -2
  39. package/dist/common/hoc/withUniwind.js +5 -5
  40. package/dist/common/hoc/withUniwind.native.js +5 -5
  41. package/dist/common/hooks/useCSSVariable/index.js +7 -11
  42. package/dist/common/hooks/useCSSVariable/useCSSVariable.js +26 -18
  43. package/dist/common/hooks/useUniwind.js +2 -2
  44. package/dist/metro/index.cjs +14 -24
  45. package/dist/metro/index.d.ts +2 -0
  46. package/dist/metro/index.mjs +7 -17
  47. package/dist/metro/{metro-transformer.cjs → transformer.cjs} +306 -173
  48. package/dist/metro/{metro-transformer.mjs → transformer.mjs} +249 -116
  49. package/dist/module/{css → bundler/artifacts/css}/index.d.ts +1 -1
  50. package/dist/module/{css → bundler/artifacts/css}/index.js +1 -4
  51. package/dist/module/{css → bundler/artifacts/css}/themes.js +1 -1
  52. package/dist/module/{utils/buildDtsFile.js → bundler/artifacts/dts.js} +3 -4
  53. package/dist/module/bundler/config.d.ts +16 -0
  54. package/dist/module/bundler/config.js +69 -0
  55. package/dist/module/bundler/css-compiler/compileCSS.d.ts +2 -0
  56. package/dist/module/bundler/css-compiler/compileCSS.js +11 -0
  57. package/dist/module/bundler/css-compiler/compileNativeCSS.d.ts +2 -0
  58. package/dist/module/bundler/css-compiler/compileNativeCSS.js +33 -0
  59. package/dist/module/bundler/css-compiler/compileTailwind.d.ts +2 -0
  60. package/dist/module/bundler/css-compiler/compileTailwind.js +22 -0
  61. package/dist/module/bundler/css-compiler/compileWebCSS.d.ts +2 -0
  62. package/dist/module/bundler/css-compiler/compileWebCSS.js +8 -0
  63. package/dist/module/bundler/css-compiler/index.d.ts +1 -0
  64. package/dist/module/bundler/css-compiler/index.js +1 -0
  65. package/dist/module/bundler/css-processor/addMetaToStylesTemplate.d.ts +3 -0
  66. package/dist/module/bundler/css-processor/addMetaToStylesTemplate.js +136 -0
  67. package/dist/module/bundler/css-processor/animation.d.ts +6 -0
  68. package/dist/module/bundler/css-processor/animation.js +112 -0
  69. package/dist/module/bundler/css-processor/color.d.ts +12 -0
  70. package/dist/module/bundler/css-processor/color.js +63 -0
  71. package/dist/module/bundler/css-processor/css.d.ts +23 -0
  72. package/dist/module/bundler/css-processor/css.js +566 -0
  73. package/dist/module/bundler/css-processor/functions.d.ts +12 -0
  74. package/dist/module/bundler/css-processor/functions.js +190 -0
  75. package/dist/module/bundler/css-processor/index.d.ts +3 -0
  76. package/dist/module/bundler/css-processor/index.js +3 -0
  77. package/dist/module/bundler/css-processor/mq.d.ts +12 -0
  78. package/dist/module/bundler/css-processor/mq.js +78 -0
  79. package/dist/module/bundler/css-processor/processor.d.ts +36 -0
  80. package/dist/module/bundler/css-processor/processor.js +336 -0
  81. package/dist/module/bundler/css-processor/rn.d.ts +10 -0
  82. package/dist/module/bundler/css-processor/rn.js +400 -0
  83. package/dist/module/bundler/css-processor/serialize.d.ts +2 -0
  84. package/dist/module/bundler/css-processor/serialize.js +101 -0
  85. package/dist/module/bundler/css-processor/types.d.ts +28 -0
  86. package/dist/module/bundler/css-processor/types.js +0 -0
  87. package/dist/module/bundler/css-processor/units.d.ts +10 -0
  88. package/dist/module/bundler/css-processor/units.js +48 -0
  89. package/dist/module/bundler/css-processor/utils.d.ts +24 -0
  90. package/dist/{shared/uniwind.PtWWxxnh.mjs → module/bundler/css-processor/utils.js} +11 -15
  91. package/dist/module/bundler/css-processor/var.d.ts +7 -0
  92. package/dist/module/bundler/css-processor/var.js +13 -0
  93. package/dist/module/{css-visitor → bundler/css-visitor}/function-visitor.d.ts +1 -1
  94. package/dist/module/{css-visitor → bundler/css-visitor}/rule-visitor.d.ts +4 -3
  95. package/dist/module/{css-visitor → bundler/css-visitor}/rule-visitor.js +5 -5
  96. package/dist/module/{css-visitor → bundler/css-visitor}/visitor.d.ts +3 -3
  97. package/dist/module/{css-visitor → bundler/css-visitor}/visitor.js +5 -6
  98. package/dist/module/bundler/logger.d.ts +11 -0
  99. package/dist/module/bundler/logger.js +34 -0
  100. package/dist/module/bundler/types.d.ts +15 -0
  101. package/dist/module/bundler/types.js +0 -0
  102. package/dist/module/common/consts.d.ts +21 -0
  103. package/dist/module/common/consts.js +24 -0
  104. package/dist/module/components/ScopedTheme/ScopedTheme.native.d.ts +1 -1
  105. package/dist/module/components/index.js +0 -3
  106. package/dist/module/components/native/Pressable.d.ts +1 -1
  107. package/dist/module/components/native/TouchableHighlight.d.ts +1 -1
  108. package/dist/module/components/native/TouchableOpacity.d.ts +1 -1
  109. package/dist/module/components/native/useAccentColor.d.ts +1 -1
  110. package/dist/module/components/native/useStyle.d.ts +2 -2
  111. package/dist/module/components/react-native-gesture-handler/native/BaseButton.d.ts +1 -1
  112. package/dist/module/components/react-native-gesture-handler/native/BorderlessButton.d.ts +1 -1
  113. package/dist/module/components/react-native-gesture-handler/native/DrawerLayoutAndroid.d.ts +1 -1
  114. package/dist/module/components/react-native-gesture-handler/native/FlatList.d.ts +1 -1
  115. package/dist/module/components/react-native-gesture-handler/native/Pressable.d.ts +1 -1
  116. package/dist/module/components/react-native-gesture-handler/native/PureNativeButton.d.ts +1 -1
  117. package/dist/module/components/react-native-gesture-handler/native/RawButton.d.ts +1 -1
  118. package/dist/module/components/react-native-gesture-handler/native/RectButton.d.ts +1 -1
  119. package/dist/module/components/react-native-gesture-handler/native/RefreshControl.d.ts +1 -1
  120. package/dist/module/components/react-native-gesture-handler/native/ScrollView.d.ts +1 -1
  121. package/dist/module/components/react-native-gesture-handler/native/Switch.d.ts +1 -1
  122. package/dist/module/components/react-native-gesture-handler/native/TextInput.d.ts +1 -1
  123. package/dist/module/components/web/Pressable.d.ts +1 -1
  124. package/dist/module/components/web/TouchableHighlight.d.ts +1 -1
  125. package/dist/module/components/web/TouchableOpacity.d.ts +1 -1
  126. package/dist/module/components/web/rnw.js +1 -1
  127. package/dist/module/core/config/config.common.d.ts +7 -6
  128. package/dist/module/core/config/config.common.js +6 -2
  129. package/dist/module/core/config/config.d.ts +1 -1
  130. package/dist/module/core/config/config.js +1 -1
  131. package/dist/module/core/config/config.native.d.ts +2 -2
  132. package/dist/module/core/config/config.native.js +1 -1
  133. package/dist/module/core/listener.d.ts +1 -1
  134. package/dist/module/core/listener.js +1 -1
  135. package/dist/module/core/native/runtime.js +5 -1
  136. package/dist/module/core/native/store.d.ts +2 -2
  137. package/dist/module/core/native/store.js +1 -2
  138. package/dist/module/core/types.d.ts +6 -3
  139. package/dist/module/core/web/cssListener.js +1 -1
  140. package/dist/module/core/web/getWebStyles.d.ts +1 -1
  141. package/dist/module/hoc/types.d.ts +2 -2
  142. package/dist/module/hoc/withUniwind.d.ts +1 -1
  143. package/dist/module/hoc/withUniwind.js +5 -5
  144. package/dist/module/hoc/withUniwind.native.d.ts +1 -1
  145. package/dist/module/hoc/withUniwind.native.js +5 -5
  146. package/dist/module/hooks/useCSSVariable/getVariableValue.native.d.ts +1 -1
  147. package/dist/module/hooks/useCSSVariable/index.d.ts +1 -1
  148. package/dist/module/hooks/useCSSVariable/index.js +1 -1
  149. package/dist/module/hooks/useCSSVariable/useCSSVariable.d.ts +4 -2
  150. package/dist/module/hooks/useCSSVariable/useCSSVariable.js +23 -16
  151. package/dist/module/hooks/useResolveClassNames.d.ts +1 -1
  152. package/dist/module/hooks/useUniwind.d.ts +1 -1
  153. package/dist/module/hooks/useUniwind.js +1 -1
  154. package/dist/module/index.d.ts +1 -2
  155. package/dist/shared/{uniwind.r2i22V6d.cjs → uniwind.CFiAZ3D-.cjs} +307 -217
  156. package/dist/shared/{uniwind.BGiqYvxb.mjs → uniwind.u-s1XVU8.mjs} +299 -214
  157. package/dist/vite/index.cjs +12 -22
  158. package/dist/vite/index.mjs +9 -19
  159. package/package.json +1 -1
  160. package/src/{metro → bundler/adapters/metro}/index.d.ts +2 -0
  161. package/src/bundler/adapters/metro/index.ts +1 -0
  162. package/src/{metro/withUniwindConfig.ts → bundler/adapters/metro/metro.ts} +7 -22
  163. package/src/{metro/metro-css-patches.ts → bundler/adapters/metro/patches.ts} +2 -1
  164. package/src/{metro → bundler/adapters/metro}/resolvers.ts +8 -8
  165. package/src/bundler/adapters/metro/transformer.ts +85 -0
  166. package/src/{vite → bundler/adapters/vite}/vite.ts +10 -28
  167. package/src/{css → bundler/artifacts/css}/extraUtilities.ts +1 -1
  168. package/src/{css → bundler/artifacts/css}/index.ts +1 -5
  169. package/src/{css → bundler/artifacts/css}/themes.ts +1 -1
  170. package/src/{utils/buildDtsFile.ts → bundler/artifacts/dts.ts} +3 -4
  171. package/src/bundler/config.ts +84 -0
  172. package/src/bundler/css-compiler/compileCSS.ts +15 -0
  173. package/src/bundler/css-compiler/compileNativeCSS.ts +41 -0
  174. package/src/bundler/css-compiler/compileTailwind.ts +25 -0
  175. package/src/bundler/css-compiler/compileWebCSS.ts +10 -0
  176. package/src/bundler/css-compiler/index.ts +1 -0
  177. package/src/{metro → bundler/css-processor}/addMetaToStylesTemplate.ts +33 -14
  178. package/src/{metro/processor → bundler/css-processor}/animation.ts +4 -4
  179. package/src/{metro/processor → bundler/css-processor}/color.ts +4 -3
  180. package/src/{metro/processor → bundler/css-processor}/css.ts +17 -9
  181. package/src/{metro/processor → bundler/css-processor}/functions.ts +2 -2
  182. package/src/bundler/css-processor/index.ts +3 -0
  183. package/src/{metro/processor → bundler/css-processor}/mq.ts +4 -4
  184. package/src/{metro/processor → bundler/css-processor}/processor.ts +13 -11
  185. package/src/{metro/processor → bundler/css-processor}/rn.ts +115 -3
  186. package/src/{metro/utils → bundler/css-processor}/serialize.ts +2 -2
  187. package/src/{metro → bundler/css-processor}/types.ts +3 -17
  188. package/src/{metro/processor → bundler/css-processor}/units.ts +1 -1
  189. package/src/{metro/processor → bundler/css-processor}/var.ts +1 -1
  190. package/src/{css-visitor → bundler/css-visitor}/function-visitor.ts +1 -1
  191. package/src/{css-visitor → bundler/css-visitor}/rule-visitor.ts +6 -5
  192. package/src/{css-visitor → bundler/css-visitor}/visitor.ts +4 -3
  193. package/src/bundler/types.ts +17 -0
  194. package/src/common/consts.ts +25 -0
  195. package/src/components/ScopedTheme/ScopedTheme.native.tsx +1 -1
  196. package/src/components/index.ts +0 -3
  197. package/src/components/native/ActivityIndicator.tsx +2 -1
  198. package/src/components/native/Button.tsx +2 -1
  199. package/src/components/native/FlatList.tsx +2 -1
  200. package/src/components/native/Image.tsx +2 -1
  201. package/src/components/native/ImageBackground.tsx +2 -1
  202. package/src/components/native/InputAccessoryView.tsx +3 -2
  203. package/src/components/native/KeyboardAvoidingView.tsx +2 -1
  204. package/src/components/native/Modal.tsx +2 -1
  205. package/src/components/native/Pressable.tsx +1 -1
  206. package/src/components/native/RefreshControl.tsx +2 -1
  207. package/src/components/native/SafeAreaView.tsx +2 -1
  208. package/src/components/native/ScrollView.tsx +2 -1
  209. package/src/components/native/SectionList.tsx +2 -1
  210. package/src/components/native/Switch.tsx +3 -2
  211. package/src/components/native/Text.tsx +3 -2
  212. package/src/components/native/TextInput.tsx +3 -2
  213. package/src/components/native/TouchableHighlight.tsx +3 -2
  214. package/src/components/native/TouchableNativeFeedback.tsx +3 -2
  215. package/src/components/native/TouchableOpacity.tsx +3 -2
  216. package/src/components/native/TouchableWithoutFeedback.tsx +3 -2
  217. package/src/components/native/View.tsx +2 -1
  218. package/src/components/native/VirtualizedList.tsx +2 -1
  219. package/src/components/native/useAccentColor.ts +1 -1
  220. package/src/components/native/useStyle.ts +2 -2
  221. package/src/components/react-native-gesture-handler/native/BaseButton.tsx +1 -1
  222. package/src/components/react-native-gesture-handler/native/BorderlessButton.tsx +1 -1
  223. package/src/components/react-native-gesture-handler/native/DrawerLayoutAndroid.tsx +1 -1
  224. package/src/components/react-native-gesture-handler/native/FlatList.tsx +1 -1
  225. package/src/components/react-native-gesture-handler/native/GestureHandlerRootView.tsx +1 -1
  226. package/src/components/react-native-gesture-handler/native/Pressable.tsx +1 -1
  227. package/src/components/react-native-gesture-handler/native/PureNativeButton.tsx +1 -1
  228. package/src/components/react-native-gesture-handler/native/RawButton.tsx +1 -1
  229. package/src/components/react-native-gesture-handler/native/RectButton.tsx +1 -1
  230. package/src/components/react-native-gesture-handler/native/RefreshControl.tsx +1 -1
  231. package/src/components/react-native-gesture-handler/native/ScrollView.tsx +1 -1
  232. package/src/components/react-native-gesture-handler/native/Switch.tsx +2 -2
  233. package/src/components/react-native-gesture-handler/native/Text.tsx +2 -2
  234. package/src/components/react-native-gesture-handler/native/TextInput.tsx +2 -2
  235. package/src/components/react-native-gesture-handler/native/TouchableNativeFeedback.tsx +2 -2
  236. package/src/components/react-native-gesture-handler/native/TouchableOpacity.tsx +2 -2
  237. package/src/components/react-native-gesture-handler/native/TouchableWithoutFeedback.tsx +2 -2
  238. package/src/components/web/ActivityIndicator.tsx +2 -1
  239. package/src/components/web/Button.tsx +2 -1
  240. package/src/components/web/FlatList.tsx +2 -1
  241. package/src/components/web/Image.tsx +2 -1
  242. package/src/components/web/ImageBackground.tsx +2 -1
  243. package/src/components/web/KeyboardAvoidingView.tsx +2 -1
  244. package/src/components/web/Modal.tsx +2 -1
  245. package/src/components/web/Pressable.tsx +2 -1
  246. package/src/components/web/RefreshControl.tsx +2 -1
  247. package/src/components/web/SafeAreaView.tsx +2 -1
  248. package/src/components/web/ScrollView.tsx +2 -1
  249. package/src/components/web/SectionList.tsx +2 -1
  250. package/src/components/web/Switch.tsx +2 -1
  251. package/src/components/web/Text.tsx +2 -1
  252. package/src/components/web/TextInput.tsx +2 -1
  253. package/src/components/web/TouchableHighlight.tsx +2 -1
  254. package/src/components/web/TouchableOpacity.tsx +2 -1
  255. package/src/components/web/TouchableWithoutFeedback.tsx +2 -1
  256. package/src/components/web/View.tsx +2 -1
  257. package/src/components/web/VirtualizedList.tsx +2 -1
  258. package/src/components/web/rnw.ts +1 -1
  259. package/src/core/config/config.common.ts +15 -8
  260. package/src/core/config/config.native.ts +3 -3
  261. package/src/core/config/config.ts +2 -2
  262. package/src/core/listener.ts +1 -1
  263. package/src/core/native/runtime.ts +7 -2
  264. package/src/core/native/store.ts +3 -4
  265. package/src/core/types.ts +6 -3
  266. package/src/core/web/cssListener.ts +1 -1
  267. package/src/core/web/getWebStyles.ts +1 -1
  268. package/src/hoc/types.ts +2 -2
  269. package/src/hoc/withUniwind.native.tsx +4 -3
  270. package/src/hoc/withUniwind.tsx +3 -2
  271. package/src/hooks/useCSSVariable/getVariableValue.native.ts +1 -1
  272. package/src/hooks/useCSSVariable/index.ts +1 -1
  273. package/src/hooks/useCSSVariable/useCSSVariable.ts +34 -25
  274. package/src/hooks/useResolveClassNames.ts +1 -1
  275. package/src/hooks/useUniwind.ts +2 -2
  276. package/src/index.ts +1 -2
  277. package/dist/common/types.js +0 -28
  278. package/dist/common/utils/stringifyThemes.js +0 -8
  279. package/dist/common/vite/vite.js +0 -95
  280. package/dist/module/types.d.ts +0 -21
  281. package/dist/module/types.js +0 -22
  282. package/dist/module/utils/stringifyThemes.d.ts +0 -1
  283. package/dist/module/utils/stringifyThemes.js +0 -1
  284. package/dist/module/vite/index.d.ts +0 -9
  285. package/dist/module/vite/index.js +0 -1
  286. package/dist/module/vite/vite.d.ts +0 -8
  287. package/dist/module/vite/vite.js +0 -98
  288. package/dist/shared/uniwind.B5q8hBGv.cjs +0 -18
  289. package/dist/shared/uniwind.Cv73KtI-.cjs +0 -86
  290. package/dist/shared/uniwind.JSWK3vHl.mjs +0 -14
  291. package/src/metro/compileVirtual.ts +0 -85
  292. package/src/metro/index.ts +0 -1
  293. package/src/metro/injectThemes.ts +0 -23
  294. package/src/metro/metro-transformer.ts +0 -116
  295. package/src/metro/processor/index.ts +0 -1
  296. package/src/metro/utils/index.ts +0 -2
  297. package/src/types.ts +0 -23
  298. package/src/utils/stringifyThemes.ts +0 -1
  299. package/src/vite/index.d.ts +0 -9
  300. /package/dist/common/{css → bundler/artifacts/css}/extraUtilities.js +0 -0
  301. /package/dist/common/{css → bundler/artifacts/css}/insets.js +0 -0
  302. /package/dist/common/{css → bundler/artifacts/css}/overwrite.js +0 -0
  303. /package/dist/common/{css → bundler/artifacts/css}/variants.js +0 -0
  304. /package/dist/common/{css-visitor → bundler/css-visitor}/function-visitor.js +0 -0
  305. /package/dist/common/{css-visitor → bundler/css-visitor}/index.js +0 -0
  306. /package/dist/module/{css → bundler/artifacts/css}/extraUtilities.d.ts +0 -0
  307. /package/dist/module/{css → bundler/artifacts/css}/extraUtilities.js +0 -0
  308. /package/dist/module/{css → bundler/artifacts/css}/insets.d.ts +0 -0
  309. /package/dist/module/{css → bundler/artifacts/css}/insets.js +0 -0
  310. /package/dist/module/{css → bundler/artifacts/css}/overwrite.d.ts +0 -0
  311. /package/dist/module/{css → bundler/artifacts/css}/overwrite.js +0 -0
  312. /package/dist/module/{css → bundler/artifacts/css}/themes.d.ts +0 -0
  313. /package/dist/module/{css → bundler/artifacts/css}/variants.d.ts +0 -0
  314. /package/dist/module/{css → bundler/artifacts/css}/variants.js +0 -0
  315. /package/dist/module/{utils/buildDtsFile.d.ts → bundler/artifacts/dts.d.ts} +0 -0
  316. /package/dist/module/{css-visitor → bundler/css-visitor}/function-visitor.js +0 -0
  317. /package/dist/module/{css-visitor → bundler/css-visitor}/index.d.ts +0 -0
  318. /package/dist/module/{css-visitor → bundler/css-visitor}/index.js +0 -0
  319. /package/{dist/common → src/bundler/adapters}/vite/index.d.ts +0 -0
  320. /package/src/{vite → bundler/adapters/vite}/index.ts +0 -0
  321. /package/src/{css → bundler/artifacts/css}/insets.ts +0 -0
  322. /package/src/{css → bundler/artifacts/css}/overwrite.ts +0 -0
  323. /package/src/{css → bundler/artifacts/css}/variants.ts +0 -0
  324. /package/src/{metro/utils/common.ts → bundler/css-processor/utils.ts} +0 -0
  325. /package/src/{css-visitor → bundler/css-visitor}/index.ts +0 -0
  326. /package/src/{metro → bundler}/logger.ts +0 -0
@@ -1,220 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  const fs = require('fs');
4
- const path = require('path');
5
4
  const node = require('@tailwindcss/node');
6
5
  const lightningcss = require('lightningcss');
7
- const common = require('./uniwind.Cv73KtI-.cjs');
6
+ const path = require('path');
8
7
 
9
8
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
10
9
 
11
10
  const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
12
11
  const path__default = /*#__PURE__*/_interopDefaultCompat(path);
13
12
 
14
- const red = "\x1B[91m";
15
- const yellow = "\x1B[33m";
16
- const blue = "\x1B[36m";
17
- const reset = "\x1B[0m";
18
- class Logger {
19
- constructor(name) {
20
- this.name = name;
21
- }
22
- static debug = false;
23
- static log(message, meta = "") {
24
- if (!Logger.debug) {
25
- return;
26
- }
27
- console.log(`${blue}Uniwind ${meta}- ${message}${reset}`);
28
- }
29
- static error(message, meta = "") {
30
- console.log(`${red}Uniwind Error ${meta}- ${message}${reset}`);
31
- }
32
- static warn(message, meta = "") {
33
- if (!Logger.debug) {
34
- return;
35
- }
36
- console.log(`${yellow}Uniwind Warning ${meta}- ${message}${reset}`);
37
- }
38
- log(message) {
39
- Logger.log(message, `[${this.name} Processor] `);
40
- }
41
- error(message) {
42
- Logger.error(message, `[${this.name} Processor] `);
43
- }
44
- warn(message) {
45
- Logger.warn(message, `[${this.name} Processor] `);
46
- }
47
- }
48
-
49
- const ONE_PX = {
50
- type: "token",
51
- value: { type: "dimension", unit: "px", value: 1 }
52
- };
53
- class FunctionVisitor {
54
- platformSelect(fn) {
55
- return fn.arguments.at(0) ?? { type: "token", value: { type: "ident", value: "initial" } };
56
- }
57
- pixelRatio(fn) {
58
- return {
59
- type: "function",
60
- value: {
61
- name: "calc",
62
- arguments: [
63
- fn.arguments.at(0) ?? ONE_PX,
64
- { type: "token", value: { type: "delim", value: "*" } },
65
- ONE_PX
66
- ]
67
- }
68
- };
69
- }
70
- fontScale(fn) {
71
- return {
72
- type: "function",
73
- value: {
74
- name: "calc",
75
- arguments: [
76
- fn.arguments.at(0) ?? ONE_PX,
77
- { type: "token", value: { type: "delim", value: "*" } },
78
- {
79
- type: "token",
80
- value: { type: "dimension", value: 1, unit: "rem" }
81
- }
82
- ]
83
- }
84
- };
85
- }
86
- hairlineWidth() {
87
- return ONE_PX;
88
- }
89
- }
90
-
91
- class RuleVisitor {
92
- constructor(themes) {
93
- this.themes = themes;
94
- }
95
- processedClassNames = /* @__PURE__ */ new Set();
96
- processedVariables = /* @__PURE__ */ new Set();
97
- currentLayerName = "";
98
- "layer-block" = (layer) => {
99
- this.currentLayerName = layer.value.name?.join("") ?? "";
100
- };
101
- style = (styleRule) => {
102
- const firstSelector = styleRule.value.selectors.at(0)?.at(0);
103
- if (this.currentLayerName === "theme" && firstSelector?.type === "pseudo-class" && firstSelector.kind === "root") {
104
- return this.removeNulls(this.processThemeRoot(styleRule));
105
- }
106
- if (firstSelector?.type === "class") {
107
- return this.processClassStyle(styleRule, firstSelector);
108
- }
109
- };
110
- cleanup() {
111
- this.currentLayerName = "";
112
- this.processedClassNames.clear();
113
- this.processedVariables.clear();
114
- }
115
- processThemeRoot(styleRule) {
116
- const themeScopedRules = styleRule.value.rules?.filter((rule) => {
117
- if (rule.type !== "style") {
118
- return false;
119
- }
120
- const firstSelector = rule.value.selectors.at(0)?.at(0);
121
- const secondSelector = rule.value.selectors.at(0)?.at(1);
122
- return firstSelector?.type === "nesting" && secondSelector?.type === "pseudo-class" && secondSelector.kind === "where";
123
- }) ?? [];
124
- const nonThemeRules = styleRule.value.rules?.filter((rule) => !themeScopedRules.includes(rule));
125
- const processedThemeScopedRules = themeScopedRules.map((rule) => {
126
- if (rule.type !== "style") {
127
- return rule;
128
- }
129
- const secondSelector = rule.value.selectors.at(0)?.at(1);
130
- if (secondSelector?.type === "pseudo-class" && secondSelector.kind === "where") {
131
- return this.processThemeStyle(rule, secondSelector);
132
- }
133
- return rule;
134
- });
135
- return [
136
- {
137
- type: "style",
138
- value: {
139
- loc: styleRule.value.loc,
140
- selectors: styleRule.value.selectors,
141
- rules: nonThemeRules,
142
- declarations: styleRule.value.declarations
143
- }
144
- },
145
- ...processedThemeScopedRules
146
- ];
147
- }
148
- processThemeStyle(styleRule, secondSelector) {
149
- const whereSelector = secondSelector.selectors.at(0)?.at(0);
150
- if (whereSelector?.type !== "class") {
151
- return styleRule;
152
- }
153
- const selectedVariant = this.themes.find((theme) => whereSelector.name === theme);
154
- if (selectedVariant === void 0 || this.processedVariables.has(selectedVariant)) {
155
- return styleRule;
156
- }
157
- this.processedVariables.add(selectedVariant);
158
- return {
159
- type: "style",
160
- value: {
161
- loc: styleRule.value.loc,
162
- selectors: [[{ type: "class", name: selectedVariant }]],
163
- declarations: styleRule.value.declarations,
164
- rules: styleRule.value.rules
165
- }
166
- };
167
- }
168
- processClassStyle(styleRule, firstSelector) {
169
- const selectedVariant = this.themes.find((theme) => firstSelector.name.includes(`${theme}:`));
170
- if (selectedVariant === void 0 || this.processedClassNames.has(firstSelector.name)) {
171
- return;
172
- }
173
- this.processedClassNames.add(firstSelector.name);
174
- return {
175
- type: "scope",
176
- value: {
177
- loc: styleRule.value.loc,
178
- rules: [styleRule],
179
- scopeStart: [[{ type: "class", name: selectedVariant }]],
180
- scopeEnd: this.themes.filter((theme) => theme !== selectedVariant).map((theme) => [{ type: "class", name: theme }])
181
- }
182
- };
183
- }
184
- // Fixes lightningcss serialization bug
185
- removeNulls(value) {
186
- if (Array.isArray(value)) {
187
- return value.map((v) => this.removeNulls(v));
188
- }
189
- if (typeof value === "object" && value !== null) {
190
- return Object.fromEntries(
191
- Object.entries(value).filter(([_, value2]) => {
192
- if (value2 === null) {
193
- return false;
194
- }
195
- return true;
196
- }).map(([key, value2]) => [key, this.removeNulls(value2)])
197
- );
198
- }
199
- return value;
200
- }
201
- }
202
-
203
- class UniwindCSSVisitor {
204
- constructor(themes) {
205
- this.themes = themes;
206
- const ruleVisitor = new RuleVisitor(this.themes);
207
- this.Function = new FunctionVisitor();
208
- this.Rule = ruleVisitor;
209
- this.StyleSheet = () => {
210
- ruleVisitor.cleanup();
211
- };
212
- }
213
- Function;
214
- Rule;
215
- StyleSheet;
216
- }
217
-
218
13
  const toKebabCase = (str) => str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
219
14
  const generateExtraUtilities = (map) => {
220
15
  return Object.entries(map).map(
@@ -340,6 +135,37 @@ const overwriteDisabled = `@custom-variant disabled {
340
135
  `;
341
136
  const OVERWRITE_CSS = overwriteDisabled;
342
137
 
138
+ const red = "\x1B[91m";
139
+ const reset = "\x1B[0m";
140
+ class Logger {
141
+ constructor(name) {
142
+ this.name = name;
143
+ }
144
+ static debug = false;
145
+ static log(message, meta = "") {
146
+ {
147
+ return;
148
+ }
149
+ }
150
+ static error(message, meta = "") {
151
+ console.log(`${red}Uniwind Error ${meta}- ${message}${reset}`);
152
+ }
153
+ static warn(message, meta = "") {
154
+ {
155
+ return;
156
+ }
157
+ }
158
+ log(message) {
159
+ Logger.log(message, `[${this.name} Processor] `);
160
+ }
161
+ error(message) {
162
+ Logger.error(message, `[${this.name} Processor] `);
163
+ }
164
+ warn(message) {
165
+ Logger.warn(message, `[${this.name} Processor] `);
166
+ }
167
+ }
168
+
343
169
  const readFileSafe = (filePath) => {
344
170
  try {
345
171
  return fs__default.readFileSync(filePath, "utf-8");
@@ -464,10 +290,8 @@ const generateCSSForVariants = () => {
464
290
  };
465
291
  const VARIANTS_CSS = generateCSSForVariants();
466
292
 
467
- const dirname = typeof __dirname !== "undefined" ? __dirname : undefined;
468
- const buildCSS = async (themes, input) => {
293
+ const buildCSS = async (themes, input, cssFilePath) => {
469
294
  const themesCSS = await generateCSSForThemes(themes, input);
470
- const cssFilePath = path__default.join(dirname, "../../uniwind.css");
471
295
  const oldCSSFile = fs__default.existsSync(cssFilePath) ? fs__default.readFileSync(cssFilePath, "utf-8") : "";
472
296
  const newCssFile = [
473
297
  VARIANTS_CSS,
@@ -488,10 +312,10 @@ const buildCSS = async (themes, input) => {
488
312
  const buildDtsFile = (dtsPath, stringifiedThemes) => {
489
313
  const oldDtsContent = fs__default.existsSync(dtsPath) ? fs__default.readFileSync(dtsPath, "utf-8") : "";
490
314
  const dtsContent = [
491
- `// NOTE: This file is generated by ${common.name} and it should not be edited manually.`,
492
- `/// <reference types="${common.name}/types" />`,
315
+ `// NOTE: This file is generated by uniwind and it should not be edited manually.`,
316
+ `/// <reference types="uniwind/types" />`,
493
317
  "",
494
- `declare module '${common.name}' {`,
318
+ `declare module 'uniwind' {`,
495
319
  ` export interface UniwindConfig {`,
496
320
  ` themes: readonly ${stringifiedThemes}`,
497
321
  ` }`,
@@ -506,10 +330,276 @@ const buildDtsFile = (dtsPath, stringifiedThemes) => {
506
330
  fs__default.writeFileSync(dtsPath, dtsContent);
507
331
  };
508
332
 
509
- const stringifyThemes = (themes = []) => `[${themes.map((theme) => `'${theme}'`).join(", ")}]`;
333
+ const ONE_PX = {
334
+ type: "token",
335
+ value: { type: "dimension", unit: "px", value: 1 }
336
+ };
337
+ class FunctionVisitor {
338
+ platformSelect(fn) {
339
+ return fn.arguments.at(0) ?? { type: "token", value: { type: "ident", value: "initial" } };
340
+ }
341
+ pixelRatio(fn) {
342
+ return {
343
+ type: "function",
344
+ value: {
345
+ name: "calc",
346
+ arguments: [
347
+ fn.arguments.at(0) ?? ONE_PX,
348
+ { type: "token", value: { type: "delim", value: "*" } },
349
+ ONE_PX
350
+ ]
351
+ }
352
+ };
353
+ }
354
+ fontScale(fn) {
355
+ return {
356
+ type: "function",
357
+ value: {
358
+ name: "calc",
359
+ arguments: [
360
+ fn.arguments.at(0) ?? ONE_PX,
361
+ { type: "token", value: { type: "delim", value: "*" } },
362
+ {
363
+ type: "token",
364
+ value: { type: "dimension", value: 1, unit: "rem" }
365
+ }
366
+ ]
367
+ }
368
+ };
369
+ }
370
+ hairlineWidth() {
371
+ return ONE_PX;
372
+ }
373
+ }
374
+
375
+ class RuleVisitor {
376
+ constructor(bundlerConfig) {
377
+ this.bundlerConfig = bundlerConfig;
378
+ }
379
+ processedClassNames = /* @__PURE__ */ new Set();
380
+ processedVariables = /* @__PURE__ */ new Set();
381
+ currentLayerName = "";
382
+ "layer-block" = (layer) => {
383
+ this.currentLayerName = layer.value.name?.join("") ?? "";
384
+ };
385
+ style = (styleRule) => {
386
+ const firstSelector = styleRule.value.selectors.at(0)?.at(0);
387
+ if (this.currentLayerName === "theme" && firstSelector?.type === "pseudo-class" && firstSelector.kind === "root") {
388
+ return this.removeNulls(this.processThemeRoot(styleRule));
389
+ }
390
+ if (firstSelector?.type === "class") {
391
+ return this.processClassStyle(styleRule, firstSelector);
392
+ }
393
+ };
394
+ cleanup() {
395
+ this.currentLayerName = "";
396
+ this.processedClassNames.clear();
397
+ this.processedVariables.clear();
398
+ }
399
+ processThemeRoot(styleRule) {
400
+ const themeScopedRules = styleRule.value.rules?.filter((rule) => {
401
+ if (rule.type !== "style") {
402
+ return false;
403
+ }
404
+ const firstSelector = rule.value.selectors.at(0)?.at(0);
405
+ const secondSelector = rule.value.selectors.at(0)?.at(1);
406
+ return firstSelector?.type === "nesting" && secondSelector?.type === "pseudo-class" && secondSelector.kind === "where";
407
+ }) ?? [];
408
+ const nonThemeRules = styleRule.value.rules?.filter((rule) => !themeScopedRules.includes(rule));
409
+ const processedThemeScopedRules = themeScopedRules.map((rule) => {
410
+ if (rule.type !== "style") {
411
+ return rule;
412
+ }
413
+ const secondSelector = rule.value.selectors.at(0)?.at(1);
414
+ if (secondSelector?.type === "pseudo-class" && secondSelector.kind === "where") {
415
+ return this.processThemeStyle(rule, secondSelector);
416
+ }
417
+ return rule;
418
+ });
419
+ return [
420
+ {
421
+ type: "style",
422
+ value: {
423
+ loc: styleRule.value.loc,
424
+ selectors: styleRule.value.selectors,
425
+ rules: nonThemeRules,
426
+ declarations: styleRule.value.declarations
427
+ }
428
+ },
429
+ ...processedThemeScopedRules
430
+ ];
431
+ }
432
+ processThemeStyle(styleRule, secondSelector) {
433
+ const whereSelector = secondSelector.selectors.at(0)?.at(0);
434
+ if (whereSelector?.type !== "class") {
435
+ return styleRule;
436
+ }
437
+ const selectedVariant = this.bundlerConfig.themes.find((theme) => whereSelector.name === theme);
438
+ if (selectedVariant === void 0 || this.processedVariables.has(selectedVariant)) {
439
+ return styleRule;
440
+ }
441
+ this.processedVariables.add(selectedVariant);
442
+ return {
443
+ type: "style",
444
+ value: {
445
+ loc: styleRule.value.loc,
446
+ selectors: [[{ type: "class", name: selectedVariant }]],
447
+ declarations: styleRule.value.declarations,
448
+ rules: styleRule.value.rules
449
+ }
450
+ };
451
+ }
452
+ processClassStyle(styleRule, firstSelector) {
453
+ const selectedVariant = this.bundlerConfig.themes.find((theme) => firstSelector.name.includes(`${theme}:`));
454
+ if (selectedVariant === void 0 || this.processedClassNames.has(firstSelector.name)) {
455
+ return;
456
+ }
457
+ this.processedClassNames.add(firstSelector.name);
458
+ return {
459
+ type: "scope",
460
+ value: {
461
+ loc: styleRule.value.loc,
462
+ rules: [styleRule],
463
+ scopeStart: [[{ type: "class", name: selectedVariant }]],
464
+ scopeEnd: this.bundlerConfig.themes.filter((theme) => theme !== selectedVariant).map((theme) => [{ type: "class", name: theme }])
465
+ }
466
+ };
467
+ }
468
+ // Fixes lightningcss serialization bug
469
+ removeNulls(value) {
470
+ if (Array.isArray(value)) {
471
+ return value.map((v) => this.removeNulls(v));
472
+ }
473
+ if (typeof value === "object" && value !== null) {
474
+ return Object.fromEntries(
475
+ Object.entries(value).filter(([_, value2]) => {
476
+ if (value2 === null) {
477
+ return false;
478
+ }
479
+ return true;
480
+ }).map(([key, value2]) => [key, this.removeNulls(value2)])
481
+ );
482
+ }
483
+ return value;
484
+ }
485
+ }
486
+
487
+ class UniwindCSSVisitor {
488
+ Function;
489
+ Rule;
490
+ StyleSheet;
491
+ constructor(bundlerConfig) {
492
+ const ruleVisitor = new RuleVisitor(bundlerConfig);
493
+ this.Function = new FunctionVisitor();
494
+ this.Rule = ruleVisitor;
495
+ this.StyleSheet = () => {
496
+ ruleVisitor.cleanup();
497
+ };
498
+ }
499
+ }
500
+
501
+ var Platform = /* @__PURE__ */ ((Platform2) => {
502
+ Platform2["Android"] = "android";
503
+ Platform2["iOS"] = "ios";
504
+ Platform2["Web"] = "web";
505
+ Platform2["Native"] = "native";
506
+ Platform2["TV"] = "tv";
507
+ Platform2["AndroidTV"] = "android-tv";
508
+ Platform2["AppleTV"] = "apple-tv";
509
+ return Platform2;
510
+ })(Platform || {});
511
+ const UNIWIND_PLATFORM_VARIABLES = "__uniwind-platform-";
512
+ const UNIWIND_THEME_VARIABLES = "__uniwind-theme-";
513
+ var StyleDependency = /* @__PURE__ */ ((StyleDependency2) => {
514
+ StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
515
+ StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
516
+ StyleDependency2[StyleDependency2["Dimensions"] = 3] = "Dimensions";
517
+ StyleDependency2[StyleDependency2["Orientation"] = 4] = "Orientation";
518
+ StyleDependency2[StyleDependency2["Insets"] = 5] = "Insets";
519
+ StyleDependency2[StyleDependency2["FontScale"] = 6] = "FontScale";
520
+ StyleDependency2[StyleDependency2["Rtl"] = 7] = "Rtl";
521
+ StyleDependency2[StyleDependency2["AdaptiveThemes"] = 8] = "AdaptiveThemes";
522
+ StyleDependency2[StyleDependency2["Variables"] = 9] = "Variables";
523
+ return StyleDependency2;
524
+ })(StyleDependency || {});
525
+ const DEFAULT_SCREEN_WIDTH = 375;
526
+ const DEFAULT_SCREEN_HEIGHT = 680;
527
+
528
+ const isDefined = (value) => value !== void 0 && value !== null;
529
+
530
+ class UniwindBundlerConfig {
531
+ constructor(config, platform) {
532
+ this.config = config;
533
+ this.platform = platform;
534
+ }
535
+ static fromMetroConfig(config, platform) {
536
+ const getPlatform = () => {
537
+ if (!isDefined(platform)) {
538
+ return Platform.Native;
539
+ }
540
+ if (!config.isTV) {
541
+ return platform;
542
+ }
543
+ if (platform === Platform.Android) {
544
+ return Platform.AndroidTV;
545
+ }
546
+ if (platform === Platform.iOS) {
547
+ return Platform.AppleTV;
548
+ }
549
+ throw new Error(`Platform ${platform} not supported`);
550
+ };
551
+ if (typeof config === "undefined") {
552
+ throw new Error("Uniwind: You need to pass second parameter to withUniwindConfig");
553
+ }
554
+ if (typeof config.cssEntryFile === "undefined") {
555
+ throw new Error(
556
+ 'Uniwind: You need to pass css css entry file to withUniwindConfig, e.g. withUniwindConfig(config, { cssEntryFile: "./global.css" })'
557
+ );
558
+ }
559
+ return new UniwindBundlerConfig(config, getPlatform());
560
+ }
561
+ static fromViteConfig(config) {
562
+ return new UniwindBundlerConfig(config, Platform.Web);
563
+ }
564
+ get cssPath() {
565
+ return path__default.join(process.cwd(), this.config.cssEntryFile);
566
+ }
567
+ get themes() {
568
+ return Array.from(
569
+ /* @__PURE__ */ new Set([
570
+ "light",
571
+ "dark",
572
+ ...this.config.extraThemes ?? []
573
+ ])
574
+ );
575
+ }
576
+ get cssVisitor() {
577
+ return new UniwindCSSVisitor(this);
578
+ }
579
+ get polyfills() {
580
+ return this.config.polyfills;
581
+ }
582
+ get stringifiedThemes() {
583
+ return `[${this.themes.map((theme) => `'${theme}'`).join(", ")}]`;
584
+ }
585
+ toMetroConfig() {
586
+ return this.config;
587
+ }
588
+ async generateArtifacts(cssArtifactPath) {
589
+ await buildCSS(this.themes, this.config.cssEntryFile, cssArtifactPath);
590
+ buildDtsFile(this.config.dtsFile ?? "uniwind-types.d.ts", this.stringifiedThemes);
591
+ }
592
+ }
593
+
594
+ const name = "@niibase/uniwind";
510
595
 
596
+ exports.DEFAULT_SCREEN_HEIGHT = DEFAULT_SCREEN_HEIGHT;
597
+ exports.DEFAULT_SCREEN_WIDTH = DEFAULT_SCREEN_WIDTH;
511
598
  exports.Logger = Logger;
512
- exports.UniwindCSSVisitor = UniwindCSSVisitor;
513
- exports.buildCSS = buildCSS;
514
- exports.buildDtsFile = buildDtsFile;
515
- exports.stringifyThemes = stringifyThemes;
599
+ exports.Platform = Platform;
600
+ exports.StyleDependency = StyleDependency;
601
+ exports.UNIWIND_PLATFORM_VARIABLES = UNIWIND_PLATFORM_VARIABLES;
602
+ exports.UNIWIND_THEME_VARIABLES = UNIWIND_THEME_VARIABLES;
603
+ exports.UniwindBundlerConfig = UniwindBundlerConfig;
604
+ exports.isDefined = isDefined;
605
+ exports.name = name;