@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
@@ -0,0 +1,190 @@
1
+ import { Logger } from "../logger.js";
2
+ import { pipe } from "./utils.js";
3
+ export class Functions {
4
+ constructor(Processor) {
5
+ this.Processor = Processor;
6
+ }
7
+ logger = new Logger("Functions");
8
+ processCalc(calc) {
9
+ switch (calc.type) {
10
+ case "sum": {
11
+ const sum = calc.value.map((x) => this.processCalc(x)).join(" + ");
12
+ return this.tryEval(sum);
13
+ }
14
+ case "value":
15
+ return this.Processor.CSS.processValue(calc.value);
16
+ case "function":
17
+ return this.Processor.CSS.processValue(calc.value);
18
+ case "number":
19
+ return String(calc.value);
20
+ default:
21
+ this.logger.warn(`Unsupported calc type - ${calc.type}`);
22
+ return "";
23
+ }
24
+ }
25
+ processFunction(fn) {
26
+ if (typeof fn !== "object") {
27
+ this.logger.warn(`Unsupported function - ${fn}`);
28
+ return fn;
29
+ }
30
+ if (fn.name === "calc") {
31
+ const calc = this.Processor.CSS.processValue(fn.arguments);
32
+ return pipe(calc)(
33
+ String,
34
+ (x) => this.Processor.Functions.tryEval(x)
35
+ );
36
+ }
37
+ if (fn.name === "cubic-bezier") {
38
+ const cubicArguments = pipe(this.Processor.CSS.processValue(fn.arguments))(
39
+ String,
40
+ (x) => x.replace(/,\s/g, ",")
41
+ );
42
+ return `rt.cubicBezier(${cubicArguments})`;
43
+ }
44
+ if (fn.name === "steps") {
45
+ const stepsArguments = pipe(this.Processor.CSS.processValue(fn.arguments))(
46
+ String,
47
+ (x) => x.replace(/,\s/g, ",")
48
+ );
49
+ return `rt.steps(${stepsArguments})`;
50
+ }
51
+ if (fn.name === "linear") {
52
+ const linearArguments = pipe(this.Processor.CSS.processValue(fn.arguments))(
53
+ String,
54
+ (x) => x.replace(/,\s/g, ",")
55
+ );
56
+ return `rt.linear(${linearArguments})`;
57
+ }
58
+ if (fn.name === "max") {
59
+ return `Math.max(${this.Processor.CSS.processValue(fn.arguments)})`;
60
+ }
61
+ if (fn.name === "linear-gradient") {
62
+ return this.Processor.CSS.processValue(fn.arguments);
63
+ }
64
+ if (fn.name === "color-mix") {
65
+ return this.processColorMix(fn);
66
+ }
67
+ if (fn.name === "translate3d") {
68
+ const [x, y] = this.Processor.CSS.processValue(fn.arguments).split(", ").map((x2) => x2.replace(/\s??\s/g, ""));
69
+ return ` translateX(\${${x}}) translateY(\${${y}})`;
70
+ }
71
+ if (fn.name === "scale3d") {
72
+ const [x, y] = this.Processor.CSS.processValue(fn.arguments).split(", ").map((x2) => x2.replace(/\s??\s/g, ""));
73
+ return ` scaleX(\${${x}}) scaleY(\${${y}})`;
74
+ }
75
+ if (fn.name === "rotate") {
76
+ return ` rotate(\${${this.Processor.CSS.processValue(fn.arguments).replace(/\s??\s/g, "")}})`;
77
+ }
78
+ if ([
79
+ "blur",
80
+ "brightness",
81
+ "contrast",
82
+ "grayscale",
83
+ "invert",
84
+ "opacity",
85
+ "saturate",
86
+ "sepia",
87
+ "url",
88
+ "drop-shadow",
89
+ "hue-rotate"
90
+ ].includes(fn.name)) {
91
+ const value = this.Processor.CSS.processValue(fn.arguments);
92
+ return `\`${fn.name}(${typeof value === "string" && value.startsWith("this[") ? `\${${value}}` : value})\``;
93
+ }
94
+ if ([
95
+ "rgb",
96
+ "oklab",
97
+ "oklch",
98
+ "hsl",
99
+ "hwb",
100
+ "lab",
101
+ "lch",
102
+ "srgb"
103
+ ].includes(fn.name)) {
104
+ const color = `${fn.name}(${this.Processor.CSS.processValue(fn.arguments)})`;
105
+ return this.Processor.Color.processColor(color);
106
+ }
107
+ if ([
108
+ "blur",
109
+ "brightness",
110
+ "contrast",
111
+ "grayscale",
112
+ "hue-rotate",
113
+ "invert",
114
+ "opacity",
115
+ "saturate",
116
+ "sepia",
117
+ "conic-gradient",
118
+ "radial-gradient"
119
+ ].includes(fn.name)) {
120
+ return '""';
121
+ }
122
+ if (["skewX", "skewY"].includes(fn.name)) {
123
+ return `"${fn.name}(${this.Processor.CSS.processValue(fn.arguments).replace(/"/g, "")})"`;
124
+ }
125
+ if (fn.name === "hairlineWidth") {
126
+ return "rt.hairlineWidth";
127
+ }
128
+ if (fn.name === "platformSelect") {
129
+ return `rt.platformSelect(${this.Processor.CSS.processValue(fn.arguments)})`;
130
+ }
131
+ if (fn.name === "pixelRatio") {
132
+ if (fn.arguments.length === 0) {
133
+ return "rt.pixelRatio(1)";
134
+ }
135
+ return `rt.pixelRatio(${this.Processor.CSS.processValue(fn.arguments)})`;
136
+ }
137
+ if (fn.name === "fontScale") {
138
+ if (fn.arguments.length === 0) {
139
+ return "rt.fontScale(1)";
140
+ }
141
+ return `rt.fontScale(${this.Processor.CSS.processValue(fn.arguments)})`;
142
+ }
143
+ if (fn.name === "drop-shadow") {
144
+ return void 0;
145
+ }
146
+ this.logger.warn(`Unsupported function - ${fn.name}`);
147
+ return fn.name;
148
+ }
149
+ processMathFunction(name, value) {
150
+ if (!Array.isArray(value)) {
151
+ return `Math.${name}(${this.processCalc(value)})`;
152
+ }
153
+ const values = value.map((x) => this.processCalc(x)).join(" , ");
154
+ return `Math.${name}(${values})`;
155
+ }
156
+ tryEval(value) {
157
+ const units = Array.from(
158
+ value.replace(/"/g, "").match(/(?<![A-Za-z-])(?:%|deg|rad|grad|turn)(?=\s|$)/g) ?? []
159
+ );
160
+ if (units.length === 0) {
161
+ return value;
162
+ }
163
+ if (new Set(units).size !== 1) {
164
+ this.logger.error(`Invalid calc, you can't mix multiple units`);
165
+ return value;
166
+ }
167
+ if (units.includes("%") && value.includes("+")) {
168
+ this.logger.error(`Invalid calc, you can't mix % with other units`);
169
+ return value;
170
+ }
171
+ const unit = units.at(0) ?? "";
172
+ try {
173
+ const numericValue = value.replace(/"/g, "").replace(new RegExp(unit, "g"), "");
174
+ return new Function(`return ${numericValue} + '${unit}'`)();
175
+ } catch {
176
+ this.logger.error(`Invalid calc ${value}`);
177
+ return value;
178
+ }
179
+ }
180
+ processColorMix(fn) {
181
+ const tokens = fn.arguments.map(
182
+ (arg) => pipe(arg)(
183
+ (x) => this.Processor.CSS.processValue(x),
184
+ String,
185
+ (x) => x.trim()
186
+ )
187
+ ).filter((token) => !["", ",", "in", "srgb", "rgb", "hsl", "hwb", "lab", "lch", "oklab", "oklch"].includes(token.replace(/"/g, "")));
188
+ return `rt.colorMix(${tokens.join(", ")})`;
189
+ }
190
+ }
@@ -0,0 +1,3 @@
1
+ export * from './addMetaToStylesTemplate';
2
+ export * from './processor';
3
+ export * from './serialize';
@@ -0,0 +1,3 @@
1
+ export * from "./addMetaToStylesTemplate.js";
2
+ export * from "./processor.js";
3
+ export * from "./serialize.js";
@@ -0,0 +1,12 @@
1
+ import type { MediaQuery } from 'lightningcss';
2
+ import type { ProcessorBuilder } from './processor';
3
+ import type { MediaQueryResolver } from './types';
4
+ export declare class MQ {
5
+ private readonly Processor;
6
+ constructor(Processor: ProcessorBuilder);
7
+ processMediaQueries(mediaQueries: Array<MediaQuery>): MediaQueryResolver;
8
+ private processCondition;
9
+ private processWidthMediaQuery;
10
+ private processPlainMediaQuery;
11
+ private getInitialMediaQueryResolver;
12
+ }
@@ -0,0 +1,78 @@
1
+ import { Platform } from "@/common/consts";
2
+ export class MQ {
3
+ constructor(Processor) {
4
+ this.Processor = Processor;
5
+ }
6
+ processMediaQueries(mediaQueries) {
7
+ const mq = this.getInitialMediaQueryResolver();
8
+ for (const mediaQuery of mediaQueries) {
9
+ const { condition, mediaType } = mediaQuery;
10
+ if ([
11
+ Platform.Android,
12
+ Platform.iOS,
13
+ Platform.Native,
14
+ Platform.AndroidTV,
15
+ Platform.AppleTV,
16
+ Platform.TV
17
+ ].includes(mediaType)) {
18
+ mq.platform = mediaType;
19
+ continue;
20
+ }
21
+ if (condition) this.processCondition(condition, mq);
22
+ }
23
+ return mq;
24
+ }
25
+ processCondition(condition, mq) {
26
+ if (condition.type === "operation") {
27
+ condition.conditions.forEach((nestedCondition) => {
28
+ this.processCondition(nestedCondition, mq);
29
+ });
30
+ } else if (condition.type === "feature") {
31
+ if (condition.value.type === "range") {
32
+ this.processWidthMediaQuery(condition.value, mq);
33
+ }
34
+ if (condition.value.type === "plain") {
35
+ this.processPlainMediaQuery(condition.value, mq);
36
+ }
37
+ }
38
+ }
39
+ processWidthMediaQuery(query, mq) {
40
+ const { operator, value } = query;
41
+ const result = this.Processor.CSS.processValue(value);
42
+ if (operator === "greater-than-equal" || operator === "greater-than") {
43
+ mq.minWidth = result;
44
+ }
45
+ if (operator === "less-than-equal" || operator === "less-than") {
46
+ mq.maxWidth = result;
47
+ }
48
+ }
49
+ processPlainMediaQuery(query, mq) {
50
+ const { value, name } = query;
51
+ switch (name) {
52
+ case "orientation":
53
+ mq.orientation = value.value;
54
+ break;
55
+ case "prefers-color-scheme":
56
+ mq.colorScheme = value.value;
57
+ break;
58
+ default:
59
+ break;
60
+ }
61
+ }
62
+ getInitialMediaQueryResolver() {
63
+ return {
64
+ minWidth: 0,
65
+ maxWidth: Number.MAX_VALUE,
66
+ platform: null,
67
+ rtl: null,
68
+ important: false,
69
+ colorScheme: null,
70
+ orientation: null,
71
+ theme: null,
72
+ active: null,
73
+ focus: null,
74
+ disabled: null,
75
+ dataAttributes: null
76
+ };
77
+ }
78
+ }
@@ -0,0 +1,36 @@
1
+ import type { CSSAnimationKeyframes } from 'react-native-reanimated';
2
+ import type { UniwindBundlerConfig } from '../config';
3
+ import { Color } from './color';
4
+ import { CSS } from './css';
5
+ import { Functions } from './functions';
6
+ import { MQ } from './mq';
7
+ import { RN } from './rn';
8
+ import type { ProcessMetaValues } from './types';
9
+ import { Units } from './units';
10
+ import { Var } from './var';
11
+ export declare class ProcessorBuilder {
12
+ readonly bundlerConfig: UniwindBundlerConfig;
13
+ stylesheets: Record<string, Array<any>>;
14
+ vars: Record<string, any>;
15
+ scopedVars: Record<string, Record<string, any>>;
16
+ keyframes: Record<string, CSSAnimationKeyframes>;
17
+ CSS: CSS;
18
+ RN: RN;
19
+ Var: Var;
20
+ MQ: MQ;
21
+ Color: Color;
22
+ Units: Units;
23
+ Functions: Functions;
24
+ meta: ProcessMetaValues;
25
+ private varsWithMediaQueries;
26
+ private pendingVarReferences;
27
+ private declarationConfig;
28
+ constructor(bundlerConfig: UniwindBundlerConfig);
29
+ transform(css: string): void;
30
+ private getDeclarationConfig;
31
+ private hasMediaQuery;
32
+ private addDeclaration;
33
+ private parseKeyFrames;
34
+ private parseDeclaration;
35
+ private parseRuleRec;
36
+ }
@@ -0,0 +1,336 @@
1
+ import { UNIWIND_PLATFORM_VARIABLES, UNIWIND_THEME_VARIABLES } from "@/common/consts";
2
+ import { transform } from "lightningcss";
3
+ import { parseTransformsMutation } from "../../core/native/parsers/transforms.js";
4
+ import { Color } from "./color.js";
5
+ import { CSS } from "./css.js";
6
+ import { Functions } from "./functions.js";
7
+ import { MQ } from "./mq.js";
8
+ import { RN } from "./rn.js";
9
+ import { Units } from "./units.js";
10
+ import { Var } from "./var.js";
11
+ export class ProcessorBuilder {
12
+ constructor(bundlerConfig) {
13
+ this.bundlerConfig = bundlerConfig;
14
+ this.vars["--uniwind-em"] = this.bundlerConfig.polyfills?.rem ?? 16;
15
+ }
16
+ stylesheets = {};
17
+ vars = {};
18
+ scopedVars = {};
19
+ keyframes = {};
20
+ CSS = new CSS(this);
21
+ RN = new RN(this);
22
+ Var = new Var(this);
23
+ MQ = new MQ(this);
24
+ Color = new Color(this);
25
+ Units = new Units(this);
26
+ Functions = new Functions(this);
27
+ meta = {};
28
+ varsWithMediaQueries = {};
29
+ pendingVarReferences = /* @__PURE__ */ new Map();
30
+ declarationConfig = this.getDeclarationConfig();
31
+ transform(css) {
32
+ transform({
33
+ filename: "tailwind.css",
34
+ code: Buffer.from(css),
35
+ visitor: {
36
+ StyleSheet: (styleSheet) => {
37
+ styleSheet.rules.forEach((rule) => {
38
+ this.declarationConfig = this.getDeclarationConfig();
39
+ this.parseRuleRec(rule);
40
+ });
41
+ for (const [className, [varNames, animated]] of this.pendingVarReferences) {
42
+ if (animated && varNames.length === 1) {
43
+ const varName = varNames[0];
44
+ const varValue = this.vars[varName];
45
+ const styles = this.stylesheets[className]?.at(-2);
46
+ this.CSS.processAnimationVar(varValue, styles, (v) => {
47
+ this.vars[varName] = v;
48
+ });
49
+ continue;
50
+ }
51
+ for (const varName of varNames) {
52
+ const varStyles = this.varsWithMediaQueries[varName];
53
+ if (!varStyles || varStyles.length === 0) {
54
+ continue;
55
+ }
56
+ for (const varStyle of varStyles) {
57
+ this.stylesheets[className].push(varStyle);
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ });
64
+ }
65
+ getDeclarationConfig() {
66
+ return {
67
+ className: null,
68
+ rtl: null,
69
+ mediaQueries: [],
70
+ root: false,
71
+ theme: null,
72
+ active: null,
73
+ focus: null,
74
+ disabled: null,
75
+ dataAttributes: null
76
+ };
77
+ }
78
+ hasMediaQuery(mq) {
79
+ return mq.minWidth !== 0 || mq.maxWidth !== Number.MAX_VALUE || mq.orientation !== null || mq.colorScheme !== null;
80
+ }
81
+ addDeclaration(declaration, important = false) {
82
+ const isVar = this.declarationConfig.root || this.declarationConfig.className === null;
83
+ const mq = this.MQ.processMediaQueries(this.declarationConfig.mediaQueries);
84
+ const { property, value } = this.parseDeclaration(declaration);
85
+ const style = (() => {
86
+ if (!isVar) {
87
+ return this.stylesheets[this.declarationConfig.className]?.at(-1);
88
+ }
89
+ if (mq.platform !== null) {
90
+ const platformKey = `${UNIWIND_PLATFORM_VARIABLES}${mq.platform}`;
91
+ this.scopedVars[platformKey] ??= {};
92
+ return this.scopedVars[platformKey];
93
+ }
94
+ if (this.hasMediaQuery(mq)) {
95
+ this.varsWithMediaQueries[property] ??= [];
96
+ this.varsWithMediaQueries[property].push({});
97
+ return this.varsWithMediaQueries[property].at(-1);
98
+ }
99
+ if (this.declarationConfig.theme === null) {
100
+ return this.vars;
101
+ }
102
+ const themeKey = `${UNIWIND_THEME_VARIABLES}${this.declarationConfig.theme}`;
103
+ this.scopedVars[themeKey] ??= {};
104
+ return this.scopedVars[themeKey];
105
+ })();
106
+ if (!isVar || this.hasMediaQuery(mq)) {
107
+ Object.assign(style, mq);
108
+ style.importantProperties ??= [];
109
+ style.rtl = this.declarationConfig.rtl;
110
+ style.theme = mq.colorScheme ?? this.declarationConfig.theme;
111
+ style.maxWidth = mq.maxWidth;
112
+ style.minWidth = mq.minWidth;
113
+ style.orientation = mq.orientation;
114
+ style.active = this.declarationConfig.active;
115
+ style.focus = this.declarationConfig.focus;
116
+ style.disabled = this.declarationConfig.disabled;
117
+ style.dataAttributes = this.declarationConfig.dataAttributes;
118
+ this.meta.className = this.declarationConfig.className;
119
+ }
120
+ style[property] = value;
121
+ if (!isVar && important) {
122
+ style.importantProperties.push(property);
123
+ }
124
+ const match = typeof value === "string" ? value.match(/this\[`(.*?)`\]/) : null;
125
+ if (match && !isVar) {
126
+ const className = this.declarationConfig.className;
127
+ if (className === null) {
128
+ return;
129
+ }
130
+ if (!this.pendingVarReferences.has(className)) {
131
+ this.pendingVarReferences.set(className, [[], property === "animation"]);
132
+ }
133
+ const classVars = this.pendingVarReferences.get(className);
134
+ const varName = match[1];
135
+ if (!classVars[0].includes(varName)) {
136
+ classVars[0].push(varName);
137
+ }
138
+ }
139
+ }
140
+ parseKeyFrames(animationFrames) {
141
+ const [selectors, styles] = animationFrames;
142
+ const result = {};
143
+ for (let i = 0; i < selectors.length; i++) {
144
+ const selectorString = selectors[i];
145
+ const styleObj = styles[i];
146
+ const individualSelectors = typeof selectorString === "string" ? selectorString.split(",").map((s) => s.trim()).filter(Boolean) : [selectorString];
147
+ const resolvedStyles = {};
148
+ for (const [property, value] of Object.entries(styleObj)) {
149
+ const resolved = this.RN.cssToRN(property, value);
150
+ for (const [resolvedProperty, resolvedValue] of resolved) {
151
+ resolvedStyles[resolvedProperty] = resolvedValue;
152
+ }
153
+ if (property === "transform") {
154
+ parseTransformsMutation(resolvedStyles, true);
155
+ }
156
+ }
157
+ for (const selector of individualSelectors) {
158
+ if (result[selector] !== void 0) {
159
+ result[selector] = {
160
+ ...result[selector],
161
+ ...resolvedStyles
162
+ };
163
+ } else {
164
+ result[selector] = { ...resolvedStyles };
165
+ }
166
+ }
167
+ }
168
+ return result;
169
+ }
170
+ parseDeclaration(declaration) {
171
+ const parseValue = (property, value) => {
172
+ if (property === "animation") {
173
+ return this.CSS.processAnimation(value);
174
+ }
175
+ return this.CSS.processValue(value, property);
176
+ };
177
+ if (declaration.property === "unparsed") {
178
+ const property = declaration.value.propertyId.property;
179
+ return {
180
+ property,
181
+ value: parseValue(property, declaration.value.value)
182
+ };
183
+ }
184
+ if (declaration.property === "custom") {
185
+ const property = declaration.value.name;
186
+ return {
187
+ property,
188
+ value: parseValue(property, declaration.value.value)
189
+ };
190
+ }
191
+ return {
192
+ property: declaration.property,
193
+ value: parseValue(declaration.property, declaration.value)
194
+ };
195
+ }
196
+ parseRuleRec(rule) {
197
+ if (this.declarationConfig.className !== null) {
198
+ const lastStyle = this.stylesheets[this.declarationConfig.className]?.at(-1);
199
+ if (lastStyle !== void 0 && Object.keys(lastStyle).length > 0) {
200
+ this.stylesheets[this.declarationConfig.className]?.push({});
201
+ }
202
+ }
203
+ if (rule.type === "style") {
204
+ rule.value.selectors.forEach((selector) => {
205
+ const [maybeClassNameSelector] = selector;
206
+ const newClassName = maybeClassNameSelector?.type === "class" ? maybeClassNameSelector.name : void 0;
207
+ if (newClassName !== void 0) {
208
+ this.declarationConfig.className = newClassName;
209
+ this.stylesheets[newClassName] ??= [];
210
+ this.stylesheets[newClassName].push({});
211
+ rule.value.declarations?.declarations?.forEach((declaration) => this.addDeclaration(declaration));
212
+ rule.value.declarations?.importantDeclarations?.forEach((declaration) => this.addDeclaration(declaration, true));
213
+ rule.value.rules?.forEach((rule2) => this.parseRuleRec(rule2));
214
+ return;
215
+ }
216
+ let rtl = null;
217
+ let theme = null;
218
+ let active = null;
219
+ let focus = null;
220
+ let disabled = null;
221
+ let dataAttributes = null;
222
+ selector.forEach((selector2) => {
223
+ if (selector2.type === "pseudo-class" && selector2.kind === "where") {
224
+ selector2.selectors.forEach((selector3) => {
225
+ selector3.forEach((selector4) => {
226
+ if (selector4.type === "class" && this.bundlerConfig.themes.includes(selector4.name)) {
227
+ theme = selector4.name;
228
+ }
229
+ if (selector4.type === "pseudo-class" && selector4.kind === "dir") {
230
+ rtl = selector4.direction === "rtl";
231
+ }
232
+ });
233
+ });
234
+ }
235
+ if (selector2.type === "pseudo-class" && selector2.kind === "active") {
236
+ active = true;
237
+ }
238
+ if (selector2.type === "pseudo-class" && selector2.kind === "focus") {
239
+ focus = true;
240
+ }
241
+ if (selector2.type === "pseudo-class" && selector2.kind === "disabled") {
242
+ disabled = true;
243
+ }
244
+ if (selector2.type === "attribute" && selector2.operation === null && selector2.name.startsWith("data-")) {
245
+ dataAttributes ??= {};
246
+ dataAttributes[selector2.name] = `"true"`;
247
+ }
248
+ if (selector2.type === "attribute" && selector2.operation?.operator === "equal" && selector2.name.startsWith("data-")) {
249
+ dataAttributes ??= {};
250
+ dataAttributes[selector2.name] = `"${selector2.operation.value}"`;
251
+ }
252
+ });
253
+ if ([rtl, theme, active, focus, disabled, dataAttributes].some(Boolean)) {
254
+ this.declarationConfig.rtl = rtl;
255
+ this.declarationConfig.theme = theme;
256
+ this.declarationConfig.active = active;
257
+ this.declarationConfig.focus = focus;
258
+ this.declarationConfig.disabled = disabled;
259
+ this.declarationConfig.dataAttributes = dataAttributes;
260
+ rule.value.declarations?.declarations?.forEach((declaration) => this.addDeclaration(declaration));
261
+ rule.value.declarations?.importantDeclarations?.forEach((declaration) => this.addDeclaration(declaration, true));
262
+ rule.value.rules?.forEach((rule2) => this.parseRuleRec(rule2));
263
+ this.declarationConfig.rtl = null;
264
+ this.declarationConfig.theme = null;
265
+ this.declarationConfig.active = null;
266
+ this.declarationConfig.focus = null;
267
+ this.declarationConfig.disabled = null;
268
+ this.declarationConfig.dataAttributes = null;
269
+ return;
270
+ }
271
+ selector.forEach((selectorToken) => {
272
+ if (selectorToken.type === "pseudo-class" && selectorToken.kind === "root") {
273
+ this.declarationConfig.root = true;
274
+ rule.value.declarations?.declarations?.forEach((declaration) => this.addDeclaration(declaration));
275
+ rule.value.declarations?.importantDeclarations?.forEach((declaration) => this.addDeclaration(declaration, true));
276
+ rule.value.rules?.forEach((rule2) => this.parseRuleRec(rule2));
277
+ }
278
+ });
279
+ });
280
+ return;
281
+ }
282
+ if (rule.type === "supports") {
283
+ rule.value.rules.forEach((rule2) => this.parseRuleRec(rule2));
284
+ return;
285
+ }
286
+ if (rule.type === "media") {
287
+ const { mediaQueries } = rule.value.query;
288
+ this.declarationConfig.mediaQueries.push(...mediaQueries);
289
+ rule.value.rules.forEach((rule2) => this.parseRuleRec(rule2));
290
+ this.declarationConfig = this.getDeclarationConfig();
291
+ return;
292
+ }
293
+ if (rule.type === "keyframes") {
294
+ const keyframes = [[], []];
295
+ rule.value.keyframes.forEach((keyframe) => {
296
+ const selectors = keyframe.selectors.map((selector) => {
297
+ switch (selector.type) {
298
+ case "percentage":
299
+ return keyframe.selectors.length > 0 ? `${selector.value * 100}%` : selector.value;
300
+ case "from":
301
+ case "to":
302
+ return selector.type;
303
+ case "timeline-range-percentage":
304
+ return keyframe.selectors.length > 0 ? `${selector.value.percentage}%` : selector.value.percentage;
305
+ default:
306
+ return "";
307
+ }
308
+ });
309
+ keyframes[0].push(selectors.join(", "));
310
+ const keyframeStyle = {};
311
+ keyframe.declarations.declarations?.forEach((declaration) => {
312
+ if (["custom", "unparsed"].includes(declaration.property)) {
313
+ const { property, value } = this.parseDeclaration(declaration);
314
+ keyframeStyle[property] = value;
315
+ } else {
316
+ keyframeStyle[declaration.property] = !Array.isArray(declaration.value) || declaration.property.startsWith("animation-") ? this.CSS.processValue(declaration.value) : declaration.value.flatMap((value) => this.CSS.processValue(value));
317
+ }
318
+ });
319
+ keyframes[1].push(keyframeStyle);
320
+ });
321
+ this.keyframes[rule.value.name.value] = this.parseKeyFrames(keyframes);
322
+ }
323
+ if (rule.type === "layer-block") {
324
+ rule.value.rules.forEach((rule2) => this.parseRuleRec(rule2));
325
+ return;
326
+ }
327
+ if (rule.type === "nested-declarations") {
328
+ rule.value.declarations.declarations?.forEach((declaration) => this.addDeclaration(declaration));
329
+ rule.value.declarations.importantDeclarations?.forEach((declaration) => this.addDeclaration(declaration, true));
330
+ return;
331
+ }
332
+ if (rule.type === "property" && rule.value.initialValue) {
333
+ this.vars[rule.value.name] = this.CSS.processValue(rule.value.initialValue);
334
+ }
335
+ }
336
+ }
@@ -0,0 +1,10 @@
1
+ import type { ProcessorBuilder } from './processor';
2
+ export declare class RN {
3
+ private readonly Processor;
4
+ constructor(Processor: ProcessorBuilder);
5
+ cssToRN(property: string, value: any): Array<[string, any]>;
6
+ private makeResponsive;
7
+ private transformProperty;
8
+ private transformObjectProperty;
9
+ private joinStyles;
10
+ }