react-native-css 3.0.0-nightly.4723140 → 3.0.0-nightly.75f8b74

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 (494) hide show
  1. package/README.md +184 -1
  2. package/dist/commonjs/babel/allowedModules.js +23 -0
  3. package/dist/commonjs/babel/allowedModules.js.map +1 -0
  4. package/dist/commonjs/babel/helpers.js +18 -122
  5. package/dist/commonjs/babel/helpers.js.map +1 -1
  6. package/dist/commonjs/babel/import-plugin.js +62 -58
  7. package/dist/commonjs/babel/import-plugin.js.map +1 -1
  8. package/dist/commonjs/babel/react-native-web.js +118 -0
  9. package/dist/commonjs/babel/react-native-web.js.map +1 -0
  10. package/dist/commonjs/babel/react-native.js +118 -0
  11. package/dist/commonjs/babel/react-native.js.map +1 -0
  12. package/dist/commonjs/compiler/atRules.js +101 -0
  13. package/dist/commonjs/compiler/atRules.js.map +1 -0
  14. package/dist/commonjs/compiler/attributes.test.js +20 -0
  15. package/dist/commonjs/compiler/attributes.test.js.map +1 -0
  16. package/dist/commonjs/compiler/compiler.js +143 -344
  17. package/dist/commonjs/compiler/compiler.js.map +1 -1
  18. package/dist/commonjs/compiler/compiler.types.js.map +1 -1
  19. package/dist/commonjs/compiler/container-query.js +10 -10
  20. package/dist/commonjs/compiler/container-query.js.map +1 -1
  21. package/dist/commonjs/compiler/declarations.js +1239 -987
  22. package/dist/commonjs/compiler/declarations.js.map +1 -1
  23. package/dist/commonjs/compiler/inheritance.test.js +78 -0
  24. package/dist/commonjs/compiler/inheritance.test.js.map +1 -0
  25. package/dist/commonjs/compiler/keyframes.js +15 -24
  26. package/dist/commonjs/compiler/keyframes.js.map +1 -1
  27. package/dist/commonjs/compiler/media-query.js +22 -22
  28. package/dist/commonjs/compiler/media-query.js.map +1 -1
  29. package/dist/commonjs/compiler/selectors.js +264 -184
  30. package/dist/commonjs/compiler/selectors.js.map +1 -1
  31. package/dist/commonjs/compiler/split-by-delimiter.js +21 -0
  32. package/dist/commonjs/compiler/split-by-delimiter.js.map +1 -0
  33. package/dist/commonjs/compiler/stylesheet.js +385 -0
  34. package/dist/commonjs/compiler/stylesheet.js.map +1 -0
  35. package/dist/commonjs/components/Text.js +2 -0
  36. package/dist/commonjs/components/Text.js.map +1 -1
  37. package/dist/commonjs/components/View.js +2 -0
  38. package/dist/commonjs/components/View.js.map +1 -1
  39. package/dist/commonjs/index.js +11 -0
  40. package/dist/commonjs/index.js.map +1 -1
  41. package/dist/commonjs/jest/index.js +12 -23
  42. package/dist/commonjs/jest/index.js.map +1 -1
  43. package/dist/commonjs/metro/index.js +111 -50
  44. package/dist/commonjs/metro/index.js.map +1 -1
  45. package/dist/commonjs/metro/injection-code.js +24 -4
  46. package/dist/commonjs/metro/injection-code.js.map +1 -1
  47. package/dist/commonjs/metro/resolver.js +62 -0
  48. package/dist/commonjs/metro/resolver.js.map +1 -0
  49. package/dist/commonjs/metro/typescript.js +1 -1
  50. package/dist/commonjs/poison.pill.js +36 -0
  51. package/dist/commonjs/poison.pill.js.map +1 -0
  52. package/dist/commonjs/runtime/native/conditions/guards.js +10 -4
  53. package/dist/commonjs/runtime/native/conditions/guards.js.map +1 -1
  54. package/dist/commonjs/runtime/native/conditions/media-query.js +2 -0
  55. package/dist/commonjs/runtime/native/conditions/media-query.js.map +1 -1
  56. package/dist/commonjs/runtime/native/index.js +11 -1
  57. package/dist/commonjs/runtime/native/index.js.map +1 -1
  58. package/dist/commonjs/runtime/native/injection.js +18 -0
  59. package/dist/commonjs/runtime/native/injection.js.map +1 -1
  60. package/dist/commonjs/runtime/native/react/rules.js +23 -27
  61. package/dist/commonjs/runtime/native/react/rules.js.map +1 -1
  62. package/dist/commonjs/runtime/native/reactivity.js +1 -5
  63. package/dist/commonjs/runtime/native/reactivity.js.map +1 -1
  64. package/dist/commonjs/runtime/native/styles/animation.js +70 -72
  65. package/dist/commonjs/runtime/native/styles/animation.js.map +1 -1
  66. package/dist/commonjs/runtime/native/styles/border.js +12 -0
  67. package/dist/commonjs/runtime/native/styles/border.js.map +1 -0
  68. package/dist/commonjs/runtime/native/styles/box-shadow.js +40 -0
  69. package/dist/commonjs/runtime/native/styles/box-shadow.js.map +1 -0
  70. package/dist/commonjs/runtime/native/styles/calc.js +33 -61
  71. package/dist/commonjs/runtime/native/styles/calc.js.map +1 -1
  72. package/dist/commonjs/runtime/native/styles/calculate-props.js +123 -0
  73. package/dist/commonjs/runtime/native/styles/calculate-props.js.map +1 -0
  74. package/dist/commonjs/runtime/native/styles/constants.js +2 -1
  75. package/dist/commonjs/runtime/native/styles/constants.js.map +1 -1
  76. package/dist/commonjs/runtime/native/styles/filters.js +84 -0
  77. package/dist/commonjs/runtime/native/styles/filters.js.map +1 -0
  78. package/dist/commonjs/runtime/native/styles/index.js +2 -110
  79. package/dist/commonjs/runtime/native/styles/index.js.map +1 -1
  80. package/dist/commonjs/runtime/native/styles/platform-functions.js +46 -0
  81. package/dist/commonjs/runtime/native/styles/platform-functions.js.map +1 -0
  82. package/dist/commonjs/runtime/native/styles/resolve.js +46 -13
  83. package/dist/commonjs/runtime/native/styles/resolve.js.map +1 -1
  84. package/dist/commonjs/runtime/native/styles/shorthand.js +34 -17
  85. package/dist/commonjs/runtime/native/styles/shorthand.js.map +1 -1
  86. package/dist/commonjs/runtime/native/styles/transform.js +9 -3
  87. package/dist/commonjs/runtime/native/styles/transform.js.map +1 -1
  88. package/dist/commonjs/runtime/native/styles/units.js +7 -4
  89. package/dist/commonjs/runtime/native/styles/units.js.map +1 -1
  90. package/dist/commonjs/runtime/native/styles/variables.js +57 -36
  91. package/dist/commonjs/runtime/native/styles/variables.js.map +1 -1
  92. package/dist/commonjs/runtime/utils/objects.js +18 -5
  93. package/dist/commonjs/runtime/utils/objects.js.map +1 -1
  94. package/dist/commonjs/runtime/utils/style-value.js +7 -0
  95. package/dist/commonjs/runtime/utils/style-value.js.map +1 -1
  96. package/dist/commonjs/runtime/web/index.js +1 -0
  97. package/dist/commonjs/runtime/web/index.js.map +1 -1
  98. package/dist/commonjs/runtime/web/metro.js +6 -0
  99. package/dist/commonjs/runtime/web/metro.js.map +1 -0
  100. package/dist/module/babel/allowedModules.js +19 -0
  101. package/dist/module/babel/allowedModules.js.map +1 -0
  102. package/dist/module/babel/helpers.js +17 -116
  103. package/dist/module/babel/helpers.js.map +1 -1
  104. package/dist/module/babel/import-plugin.js +63 -59
  105. package/dist/module/babel/import-plugin.js.map +1 -1
  106. package/dist/module/babel/react-native-web.js +112 -0
  107. package/dist/module/babel/react-native-web.js.map +1 -0
  108. package/dist/module/babel/react-native.js +112 -0
  109. package/dist/module/babel/react-native.js.map +1 -0
  110. package/dist/module/compiler/atRules.js +97 -0
  111. package/dist/module/compiler/atRules.js.map +1 -0
  112. package/dist/module/compiler/attributes.test.js +20 -0
  113. package/dist/module/compiler/attributes.test.js.map +1 -0
  114. package/dist/module/compiler/compiler.js +144 -345
  115. package/dist/module/compiler/compiler.js.map +1 -1
  116. package/dist/module/compiler/compiler.types.js +0 -12
  117. package/dist/module/compiler/compiler.types.js.map +1 -1
  118. package/dist/module/compiler/container-query.js +10 -10
  119. package/dist/module/compiler/container-query.js.map +1 -1
  120. package/dist/module/compiler/declarations.js +1178 -991
  121. package/dist/module/compiler/declarations.js.map +1 -1
  122. package/dist/module/compiler/inheritance.test.js +78 -0
  123. package/dist/module/compiler/inheritance.test.js.map +1 -0
  124. package/dist/module/compiler/keyframes.js +15 -24
  125. package/dist/module/compiler/keyframes.js.map +1 -1
  126. package/dist/module/compiler/media-query.js +22 -22
  127. package/dist/module/compiler/media-query.js.map +1 -1
  128. package/dist/module/compiler/selectors.js +264 -184
  129. package/dist/module/compiler/selectors.js.map +1 -1
  130. package/dist/module/compiler/split-by-delimiter.js +17 -0
  131. package/dist/module/compiler/split-by-delimiter.js.map +1 -0
  132. package/dist/module/compiler/stylesheet.js +380 -0
  133. package/dist/module/compiler/stylesheet.js.map +1 -0
  134. package/dist/module/components/Text.js +1 -0
  135. package/dist/module/components/Text.js.map +1 -1
  136. package/dist/module/components/View.js +1 -0
  137. package/dist/module/components/View.js.map +1 -1
  138. package/dist/module/index.js +1 -0
  139. package/dist/module/index.js.map +1 -1
  140. package/dist/module/jest/index.js +12 -8
  141. package/dist/module/jest/index.js.map +1 -1
  142. package/dist/module/metro/index.js +111 -50
  143. package/dist/module/metro/index.js.map +1 -1
  144. package/dist/module/metro/injection-code.js +22 -3
  145. package/dist/module/metro/injection-code.js.map +1 -1
  146. package/dist/module/metro/resolver.js +57 -0
  147. package/dist/module/metro/resolver.js.map +1 -0
  148. package/dist/module/metro/typescript.js +1 -1
  149. package/dist/module/poison.pill.js +34 -0
  150. package/dist/module/poison.pill.js.map +1 -0
  151. package/dist/module/runtime/native/conditions/guards.js +10 -4
  152. package/dist/module/runtime/native/conditions/guards.js.map +1 -1
  153. package/dist/module/runtime/native/conditions/media-query.js +2 -0
  154. package/dist/module/runtime/native/conditions/media-query.js.map +1 -1
  155. package/dist/module/runtime/native/index.js +1 -2
  156. package/dist/module/runtime/native/index.js.map +1 -1
  157. package/dist/module/runtime/native/injection.js +18 -0
  158. package/dist/module/runtime/native/injection.js.map +1 -1
  159. package/dist/module/runtime/native/react/rules.js +22 -27
  160. package/dist/module/runtime/native/react/rules.js.map +1 -1
  161. package/dist/module/runtime/native/reactivity.js +1 -5
  162. package/dist/module/runtime/native/reactivity.js.map +1 -1
  163. package/dist/module/runtime/native/styles/animation.js +68 -71
  164. package/dist/module/runtime/native/styles/animation.js.map +1 -1
  165. package/dist/module/runtime/native/styles/border.js +8 -0
  166. package/dist/module/runtime/native/styles/border.js.map +1 -0
  167. package/dist/module/runtime/native/styles/box-shadow.js +35 -0
  168. package/dist/module/runtime/native/styles/box-shadow.js.map +1 -0
  169. package/dist/module/runtime/native/styles/calc.js +33 -62
  170. package/dist/module/runtime/native/styles/calc.js.map +1 -1
  171. package/dist/module/runtime/native/styles/calculate-props.js +118 -0
  172. package/dist/module/runtime/native/styles/calculate-props.js.map +1 -0
  173. package/dist/module/runtime/native/styles/constants.js +1 -0
  174. package/dist/module/runtime/native/styles/constants.js.map +1 -1
  175. package/dist/module/runtime/native/styles/filters.js +70 -0
  176. package/dist/module/runtime/native/styles/filters.js.map +1 -0
  177. package/dist/module/runtime/native/styles/index.js +2 -110
  178. package/dist/module/runtime/native/styles/index.js.map +1 -1
  179. package/dist/module/runtime/native/styles/platform-functions.js +36 -0
  180. package/dist/module/runtime/native/styles/platform-functions.js.map +1 -0
  181. package/dist/module/runtime/native/styles/resolve.js +47 -14
  182. package/dist/module/runtime/native/styles/resolve.js.map +1 -1
  183. package/dist/module/runtime/native/styles/shorthand.js +34 -17
  184. package/dist/module/runtime/native/styles/shorthand.js.map +1 -1
  185. package/dist/module/runtime/native/styles/transform.js +9 -3
  186. package/dist/module/runtime/native/styles/transform.js.map +1 -1
  187. package/dist/module/runtime/native/styles/units.js +7 -4
  188. package/dist/module/runtime/native/styles/units.js.map +1 -1
  189. package/dist/module/runtime/native/styles/variables.js +57 -36
  190. package/dist/module/runtime/native/styles/variables.js.map +1 -1
  191. package/dist/module/runtime/utils/objects.js +16 -4
  192. package/dist/module/runtime/utils/objects.js.map +1 -1
  193. package/dist/module/runtime/utils/style-value.js +6 -0
  194. package/dist/module/runtime/utils/style-value.js.map +1 -1
  195. package/dist/module/runtime/web/index.js +2 -0
  196. package/dist/module/runtime/web/index.js.map +1 -1
  197. package/dist/module/runtime/web/metro.js +5 -0
  198. package/dist/module/runtime/web/metro.js.map +1 -0
  199. package/dist/typescript/commonjs/example/app.config.d.ts +4 -0
  200. package/dist/typescript/commonjs/example/app.config.d.ts.map +1 -0
  201. package/dist/typescript/commonjs/example/src/App.d.ts.map +1 -1
  202. package/dist/typescript/commonjs/src/babel/allowedModules.d.ts +2 -0
  203. package/dist/typescript/commonjs/src/babel/allowedModules.d.ts.map +1 -0
  204. package/dist/typescript/commonjs/src/babel/helpers.d.ts +3 -8
  205. package/dist/typescript/commonjs/src/babel/helpers.d.ts.map +1 -1
  206. package/dist/typescript/commonjs/src/babel/import-plugin.d.ts.map +1 -1
  207. package/dist/typescript/commonjs/src/babel/react-native-web.d.ts +8 -0
  208. package/dist/typescript/commonjs/src/babel/react-native-web.d.ts.map +1 -0
  209. package/dist/typescript/commonjs/src/babel/react-native.d.ts +8 -0
  210. package/dist/typescript/commonjs/src/babel/react-native.d.ts.map +1 -0
  211. package/dist/typescript/commonjs/src/compiler/atRules.d.ts +34 -0
  212. package/dist/typescript/commonjs/src/compiler/atRules.d.ts.map +1 -0
  213. package/dist/typescript/commonjs/src/compiler/attributes.test.d.ts +2 -0
  214. package/dist/typescript/commonjs/src/compiler/attributes.test.d.ts.map +1 -0
  215. package/dist/typescript/commonjs/src/compiler/compiler.d.ts +1 -1
  216. package/dist/typescript/commonjs/src/compiler/compiler.d.ts.map +1 -1
  217. package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts +27 -108
  218. package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts.map +1 -1
  219. package/dist/typescript/commonjs/src/compiler/container-query.d.ts +2 -2
  220. package/dist/typescript/commonjs/src/compiler/container-query.d.ts.map +1 -1
  221. package/dist/typescript/commonjs/src/compiler/declarations.d.ts +118 -25
  222. package/dist/typescript/commonjs/src/compiler/declarations.d.ts.map +1 -1
  223. package/dist/typescript/commonjs/src/compiler/inheritance.test.d.ts +2 -0
  224. package/dist/typescript/commonjs/src/compiler/inheritance.test.d.ts.map +1 -0
  225. package/dist/typescript/commonjs/src/compiler/keyframes.d.ts +5 -4
  226. package/dist/typescript/commonjs/src/compiler/keyframes.d.ts.map +1 -1
  227. package/dist/typescript/commonjs/src/compiler/media-query.d.ts +4 -4
  228. package/dist/typescript/commonjs/src/compiler/media-query.d.ts.map +1 -1
  229. package/dist/typescript/commonjs/src/compiler/selectors.d.ts +10 -5
  230. package/dist/typescript/commonjs/src/compiler/selectors.d.ts.map +1 -1
  231. package/dist/typescript/commonjs/src/compiler/split-by-delimiter.d.ts +2 -0
  232. package/dist/typescript/commonjs/src/compiler/split-by-delimiter.d.ts.map +1 -0
  233. package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts +54 -0
  234. package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts.map +1 -0
  235. package/dist/typescript/commonjs/src/components/Text.d.ts +1 -1
  236. package/dist/typescript/commonjs/src/components/Text.d.ts.map +1 -1
  237. package/dist/typescript/commonjs/src/components/View.d.ts +1 -1
  238. package/dist/typescript/commonjs/src/components/View.d.ts.map +1 -1
  239. package/dist/typescript/commonjs/src/index.d.ts +1 -0
  240. package/dist/typescript/commonjs/src/index.d.ts.map +1 -1
  241. package/dist/typescript/commonjs/src/jest/index.d.ts +4 -5
  242. package/dist/typescript/commonjs/src/jest/index.d.ts.map +1 -1
  243. package/dist/typescript/commonjs/src/metro/index.d.ts +5 -4
  244. package/dist/typescript/commonjs/src/metro/index.d.ts.map +1 -1
  245. package/dist/typescript/commonjs/src/metro/injection-code.d.ts +15 -1
  246. package/dist/typescript/commonjs/src/metro/injection-code.d.ts.map +1 -1
  247. package/dist/typescript/commonjs/src/metro/resolver.d.ts +4 -0
  248. package/dist/typescript/commonjs/src/metro/resolver.d.ts.map +1 -0
  249. package/dist/typescript/commonjs/src/poison.pill.d.ts +2 -0
  250. package/dist/typescript/commonjs/src/poison.pill.d.ts.map +1 -0
  251. package/dist/typescript/commonjs/src/runtime/native/api.d.ts +1 -1
  252. package/dist/typescript/commonjs/src/runtime/native/conditions/guards.d.ts.map +1 -1
  253. package/dist/typescript/commonjs/src/runtime/native/index.d.ts +1 -1
  254. package/dist/typescript/commonjs/src/runtime/native/index.d.ts.map +1 -1
  255. package/dist/typescript/commonjs/src/runtime/native/react/rules.d.ts +2 -1
  256. package/dist/typescript/commonjs/src/runtime/native/react/rules.d.ts.map +1 -1
  257. package/dist/typescript/commonjs/src/runtime/native/react/useNativeCss.d.ts +1 -1
  258. package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts +1 -1
  259. package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts.map +1 -1
  260. package/dist/typescript/commonjs/src/runtime/native/styles/animation.d.ts +3 -2
  261. package/dist/typescript/commonjs/src/runtime/native/styles/animation.d.ts.map +1 -1
  262. package/dist/typescript/commonjs/src/runtime/native/styles/border.d.ts +2 -0
  263. package/dist/typescript/commonjs/src/runtime/native/styles/border.d.ts.map +1 -0
  264. package/dist/typescript/commonjs/src/runtime/native/styles/box-shadow.d.ts +3 -0
  265. package/dist/typescript/commonjs/src/runtime/native/styles/box-shadow.d.ts.map +1 -0
  266. package/dist/typescript/commonjs/src/runtime/native/styles/calc.d.ts.map +1 -1
  267. package/dist/typescript/commonjs/src/runtime/native/styles/calculate-props.d.ts +10 -0
  268. package/dist/typescript/commonjs/src/runtime/native/styles/calculate-props.d.ts.map +1 -0
  269. package/dist/typescript/commonjs/src/runtime/native/styles/constants.d.ts +1 -0
  270. package/dist/typescript/commonjs/src/runtime/native/styles/constants.d.ts.map +1 -1
  271. package/dist/typescript/commonjs/src/runtime/native/styles/filters.d.ts +12 -0
  272. package/dist/typescript/commonjs/src/runtime/native/styles/filters.d.ts.map +1 -0
  273. package/dist/typescript/commonjs/src/runtime/native/styles/index.d.ts +3 -4
  274. package/dist/typescript/commonjs/src/runtime/native/styles/index.d.ts.map +1 -1
  275. package/dist/typescript/commonjs/src/runtime/native/styles/platform-functions.d.ts +8 -0
  276. package/dist/typescript/commonjs/src/runtime/native/styles/platform-functions.d.ts.map +1 -0
  277. package/dist/typescript/commonjs/src/runtime/native/styles/resolve.d.ts +6 -2
  278. package/dist/typescript/commonjs/src/runtime/native/styles/resolve.d.ts.map +1 -1
  279. package/dist/typescript/commonjs/src/runtime/native/styles/shorthand.d.ts +3 -4
  280. package/dist/typescript/commonjs/src/runtime/native/styles/shorthand.d.ts.map +1 -1
  281. package/dist/typescript/commonjs/src/runtime/native/styles/text-shadow.d.ts +1 -1
  282. package/dist/typescript/commonjs/src/runtime/native/styles/text-shadow.d.ts.map +1 -1
  283. package/dist/typescript/commonjs/src/runtime/native/styles/transform.d.ts.map +1 -1
  284. package/dist/typescript/commonjs/src/runtime/native/styles/units.d.ts.map +1 -1
  285. package/dist/typescript/commonjs/src/runtime/native/styles/variables.d.ts +1 -1
  286. package/dist/typescript/commonjs/src/runtime/native/styles/variables.d.ts.map +1 -1
  287. package/dist/typescript/commonjs/src/runtime/runtime.types.d.ts +0 -15
  288. package/dist/typescript/commonjs/src/runtime/runtime.types.d.ts.map +1 -1
  289. package/dist/typescript/commonjs/src/runtime/utils/components.d.ts +1 -1
  290. package/dist/typescript/commonjs/src/runtime/utils/objects.d.ts +2 -1
  291. package/dist/typescript/commonjs/src/runtime/utils/objects.d.ts.map +1 -1
  292. package/dist/typescript/commonjs/src/runtime/utils/style-value.d.ts +3 -2
  293. package/dist/typescript/commonjs/src/runtime/utils/style-value.d.ts.map +1 -1
  294. package/dist/typescript/commonjs/src/runtime/web/index.d.ts +1 -0
  295. package/dist/typescript/commonjs/src/runtime/web/index.d.ts.map +1 -1
  296. package/dist/typescript/commonjs/src/runtime/web/metro.d.ts +2 -0
  297. package/dist/typescript/commonjs/src/runtime/web/metro.d.ts.map +1 -0
  298. package/dist/typescript/module/example/app.config.d.ts +4 -0
  299. package/dist/typescript/module/example/app.config.d.ts.map +1 -0
  300. package/dist/typescript/module/example/src/App.d.ts.map +1 -1
  301. package/dist/typescript/module/src/babel/allowedModules.d.ts +2 -0
  302. package/dist/typescript/module/src/babel/allowedModules.d.ts.map +1 -0
  303. package/dist/typescript/module/src/babel/helpers.d.ts +3 -8
  304. package/dist/typescript/module/src/babel/helpers.d.ts.map +1 -1
  305. package/dist/typescript/module/src/babel/import-plugin.d.ts.map +1 -1
  306. package/dist/typescript/module/src/babel/react-native-web.d.ts +8 -0
  307. package/dist/typescript/module/src/babel/react-native-web.d.ts.map +1 -0
  308. package/dist/typescript/module/src/babel/react-native.d.ts +8 -0
  309. package/dist/typescript/module/src/babel/react-native.d.ts.map +1 -0
  310. package/dist/typescript/module/src/compiler/atRules.d.ts +34 -0
  311. package/dist/typescript/module/src/compiler/atRules.d.ts.map +1 -0
  312. package/dist/typescript/module/src/compiler/attributes.test.d.ts +2 -0
  313. package/dist/typescript/module/src/compiler/attributes.test.d.ts.map +1 -0
  314. package/dist/typescript/module/src/compiler/compiler.d.ts +1 -1
  315. package/dist/typescript/module/src/compiler/compiler.d.ts.map +1 -1
  316. package/dist/typescript/module/src/compiler/compiler.types.d.ts +27 -108
  317. package/dist/typescript/module/src/compiler/compiler.types.d.ts.map +1 -1
  318. package/dist/typescript/module/src/compiler/container-query.d.ts +2 -2
  319. package/dist/typescript/module/src/compiler/container-query.d.ts.map +1 -1
  320. package/dist/typescript/module/src/compiler/declarations.d.ts +118 -25
  321. package/dist/typescript/module/src/compiler/declarations.d.ts.map +1 -1
  322. package/dist/typescript/module/src/compiler/inheritance.test.d.ts +2 -0
  323. package/dist/typescript/module/src/compiler/inheritance.test.d.ts.map +1 -0
  324. package/dist/typescript/module/src/compiler/keyframes.d.ts +5 -4
  325. package/dist/typescript/module/src/compiler/keyframes.d.ts.map +1 -1
  326. package/dist/typescript/module/src/compiler/media-query.d.ts +4 -4
  327. package/dist/typescript/module/src/compiler/media-query.d.ts.map +1 -1
  328. package/dist/typescript/module/src/compiler/selectors.d.ts +10 -5
  329. package/dist/typescript/module/src/compiler/selectors.d.ts.map +1 -1
  330. package/dist/typescript/module/src/compiler/split-by-delimiter.d.ts +2 -0
  331. package/dist/typescript/module/src/compiler/split-by-delimiter.d.ts.map +1 -0
  332. package/dist/typescript/module/src/compiler/stylesheet.d.ts +54 -0
  333. package/dist/typescript/module/src/compiler/stylesheet.d.ts.map +1 -0
  334. package/dist/typescript/module/src/components/Text.d.ts +1 -1
  335. package/dist/typescript/module/src/components/Text.d.ts.map +1 -1
  336. package/dist/typescript/module/src/components/View.d.ts +1 -1
  337. package/dist/typescript/module/src/components/View.d.ts.map +1 -1
  338. package/dist/typescript/module/src/index.d.ts +1 -0
  339. package/dist/typescript/module/src/index.d.ts.map +1 -1
  340. package/dist/typescript/module/src/jest/index.d.ts +4 -5
  341. package/dist/typescript/module/src/jest/index.d.ts.map +1 -1
  342. package/dist/typescript/module/src/metro/index.d.ts +5 -4
  343. package/dist/typescript/module/src/metro/index.d.ts.map +1 -1
  344. package/dist/typescript/module/src/metro/injection-code.d.ts +15 -1
  345. package/dist/typescript/module/src/metro/injection-code.d.ts.map +1 -1
  346. package/dist/typescript/module/src/metro/resolver.d.ts +4 -0
  347. package/dist/typescript/module/src/metro/resolver.d.ts.map +1 -0
  348. package/dist/typescript/module/src/poison.pill.d.ts +2 -0
  349. package/dist/typescript/module/src/poison.pill.d.ts.map +1 -0
  350. package/dist/typescript/module/src/runtime/native/api.d.ts +1 -1
  351. package/dist/typescript/module/src/runtime/native/conditions/guards.d.ts.map +1 -1
  352. package/dist/typescript/module/src/runtime/native/index.d.ts +1 -1
  353. package/dist/typescript/module/src/runtime/native/index.d.ts.map +1 -1
  354. package/dist/typescript/module/src/runtime/native/react/rules.d.ts +2 -1
  355. package/dist/typescript/module/src/runtime/native/react/rules.d.ts.map +1 -1
  356. package/dist/typescript/module/src/runtime/native/react/useNativeCss.d.ts +1 -1
  357. package/dist/typescript/module/src/runtime/native/reactivity.d.ts +1 -1
  358. package/dist/typescript/module/src/runtime/native/reactivity.d.ts.map +1 -1
  359. package/dist/typescript/module/src/runtime/native/styles/animation.d.ts +3 -2
  360. package/dist/typescript/module/src/runtime/native/styles/animation.d.ts.map +1 -1
  361. package/dist/typescript/module/src/runtime/native/styles/border.d.ts +2 -0
  362. package/dist/typescript/module/src/runtime/native/styles/border.d.ts.map +1 -0
  363. package/dist/typescript/module/src/runtime/native/styles/box-shadow.d.ts +3 -0
  364. package/dist/typescript/module/src/runtime/native/styles/box-shadow.d.ts.map +1 -0
  365. package/dist/typescript/module/src/runtime/native/styles/calc.d.ts.map +1 -1
  366. package/dist/typescript/module/src/runtime/native/styles/calculate-props.d.ts +10 -0
  367. package/dist/typescript/module/src/runtime/native/styles/calculate-props.d.ts.map +1 -0
  368. package/dist/typescript/module/src/runtime/native/styles/constants.d.ts +1 -0
  369. package/dist/typescript/module/src/runtime/native/styles/constants.d.ts.map +1 -1
  370. package/dist/typescript/module/src/runtime/native/styles/filters.d.ts +12 -0
  371. package/dist/typescript/module/src/runtime/native/styles/filters.d.ts.map +1 -0
  372. package/dist/typescript/module/src/runtime/native/styles/index.d.ts +3 -4
  373. package/dist/typescript/module/src/runtime/native/styles/index.d.ts.map +1 -1
  374. package/dist/typescript/module/src/runtime/native/styles/platform-functions.d.ts +8 -0
  375. package/dist/typescript/module/src/runtime/native/styles/platform-functions.d.ts.map +1 -0
  376. package/dist/typescript/module/src/runtime/native/styles/resolve.d.ts +6 -2
  377. package/dist/typescript/module/src/runtime/native/styles/resolve.d.ts.map +1 -1
  378. package/dist/typescript/module/src/runtime/native/styles/shorthand.d.ts +3 -4
  379. package/dist/typescript/module/src/runtime/native/styles/shorthand.d.ts.map +1 -1
  380. package/dist/typescript/module/src/runtime/native/styles/text-shadow.d.ts +1 -1
  381. package/dist/typescript/module/src/runtime/native/styles/text-shadow.d.ts.map +1 -1
  382. package/dist/typescript/module/src/runtime/native/styles/transform.d.ts.map +1 -1
  383. package/dist/typescript/module/src/runtime/native/styles/units.d.ts.map +1 -1
  384. package/dist/typescript/module/src/runtime/native/styles/variables.d.ts +1 -1
  385. package/dist/typescript/module/src/runtime/native/styles/variables.d.ts.map +1 -1
  386. package/dist/typescript/module/src/runtime/runtime.types.d.ts +0 -15
  387. package/dist/typescript/module/src/runtime/runtime.types.d.ts.map +1 -1
  388. package/dist/typescript/module/src/runtime/utils/components.d.ts +1 -1
  389. package/dist/typescript/module/src/runtime/utils/objects.d.ts +2 -1
  390. package/dist/typescript/module/src/runtime/utils/objects.d.ts.map +1 -1
  391. package/dist/typescript/module/src/runtime/utils/style-value.d.ts +3 -2
  392. package/dist/typescript/module/src/runtime/utils/style-value.d.ts.map +1 -1
  393. package/dist/typescript/module/src/runtime/web/index.d.ts +1 -0
  394. package/dist/typescript/module/src/runtime/web/index.d.ts.map +1 -1
  395. package/dist/typescript/module/src/runtime/web/metro.d.ts +2 -0
  396. package/dist/typescript/module/src/runtime/web/metro.d.ts.map +1 -0
  397. package/package.json +69 -14
  398. package/src/babel/allowedModules.ts +24 -0
  399. package/src/babel/helpers.ts +16 -158
  400. package/src/babel/import-plugin.ts +125 -132
  401. package/src/babel/react-native-web.ts +226 -0
  402. package/src/babel/react-native.ts +226 -0
  403. package/src/compiler/atRules.ts +144 -0
  404. package/src/compiler/attributes.test.ts +28 -0
  405. package/src/compiler/compiler.ts +154 -482
  406. package/src/compiler/compiler.types.ts +30 -135
  407. package/src/compiler/container-query.ts +12 -12
  408. package/src/compiler/declarations.ts +1803 -1967
  409. package/src/compiler/inheritance.test.ts +121 -0
  410. package/src/compiler/keyframes.ts +28 -42
  411. package/src/compiler/media-query.ts +27 -26
  412. package/src/compiler/selectors.ts +289 -271
  413. package/src/compiler/split-by-delimiter.ts +19 -0
  414. package/src/compiler/stylesheet.ts +546 -0
  415. package/src/components/Text.tsx +2 -0
  416. package/src/components/View.tsx +2 -0
  417. package/src/index.ts +2 -0
  418. package/src/jest/index.ts +19 -9
  419. package/src/metro/index.ts +161 -64
  420. package/src/metro/injection-code.ts +33 -3
  421. package/src/metro/resolver.ts +89 -0
  422. package/src/metro/typescript.ts +1 -1
  423. package/src/poison.pill.ts +32 -0
  424. package/src/runtime/native/conditions/guards.ts +12 -4
  425. package/src/runtime/native/conditions/media-query.ts +2 -0
  426. package/src/runtime/native/index.ts +1 -2
  427. package/src/runtime/native/injection.ts +30 -0
  428. package/src/runtime/native/react/rules.ts +26 -33
  429. package/src/runtime/native/reactivity.ts +3 -7
  430. package/src/runtime/native/styles/animation.ts +143 -104
  431. package/src/runtime/native/styles/border.ts +10 -0
  432. package/src/runtime/native/styles/box-shadow.ts +54 -0
  433. package/src/runtime/native/styles/calc.ts +37 -60
  434. package/src/runtime/native/styles/calculate-props.ts +165 -0
  435. package/src/runtime/native/styles/constants.ts +1 -0
  436. package/src/runtime/native/styles/filters.ts +98 -0
  437. package/src/runtime/native/styles/index.ts +2 -138
  438. package/src/runtime/native/styles/platform-functions.ts +50 -0
  439. package/src/runtime/native/styles/resolve.ts +91 -17
  440. package/src/runtime/native/styles/shorthand.ts +61 -41
  441. package/src/runtime/native/styles/transform.ts +10 -4
  442. package/src/runtime/native/styles/units.ts +9 -4
  443. package/src/runtime/native/styles/variables.ts +51 -35
  444. package/src/runtime/runtime.types.ts +0 -25
  445. package/src/runtime/utils/objects.ts +20 -5
  446. package/src/runtime/utils/style-value.ts +14 -2
  447. package/src/runtime/web/index.ts +3 -0
  448. package/src/runtime/web/metro.ts +2 -0
  449. package/types.d.ts +70 -0
  450. package/dist/commonjs/compiler/add.js +0 -175
  451. package/dist/commonjs/compiler/add.js.map +0 -1
  452. package/dist/commonjs/components/ActivityIndicator.js +0 -20
  453. package/dist/commonjs/components/ActivityIndicator.js.map +0 -1
  454. package/dist/commonjs/components/SafeAreaProvider/index.js +0 -41
  455. package/dist/commonjs/components/SafeAreaProvider/index.js.map +0 -1
  456. package/dist/commonjs/components/SafeAreaProvider/index.web.js +0 -13
  457. package/dist/commonjs/components/SafeAreaProvider/index.web.js.map +0 -1
  458. package/dist/commonjs/components/TextInput.js +0 -20
  459. package/dist/commonjs/components/TextInput.js.map +0 -1
  460. package/dist/module/compiler/add.js +0 -168
  461. package/dist/module/compiler/add.js.map +0 -1
  462. package/dist/module/components/ActivityIndicator.js +0 -16
  463. package/dist/module/components/ActivityIndicator.js.map +0 -1
  464. package/dist/module/components/SafeAreaProvider/index.js +0 -36
  465. package/dist/module/components/SafeAreaProvider/index.js.map +0 -1
  466. package/dist/module/components/SafeAreaProvider/index.web.js +0 -4
  467. package/dist/module/components/SafeAreaProvider/index.web.js.map +0 -1
  468. package/dist/module/components/TextInput.js +0 -16
  469. package/dist/module/components/TextInput.js.map +0 -1
  470. package/dist/typescript/commonjs/src/compiler/add.d.ts +0 -10
  471. package/dist/typescript/commonjs/src/compiler/add.d.ts.map +0 -1
  472. package/dist/typescript/commonjs/src/components/ActivityIndicator.d.ts +0 -3
  473. package/dist/typescript/commonjs/src/components/ActivityIndicator.d.ts.map +0 -1
  474. package/dist/typescript/commonjs/src/components/SafeAreaProvider/index.d.ts +0 -4
  475. package/dist/typescript/commonjs/src/components/SafeAreaProvider/index.d.ts.map +0 -1
  476. package/dist/typescript/commonjs/src/components/SafeAreaProvider/index.web.d.ts +0 -2
  477. package/dist/typescript/commonjs/src/components/SafeAreaProvider/index.web.d.ts.map +0 -1
  478. package/dist/typescript/commonjs/src/components/TextInput.d.ts +0 -13
  479. package/dist/typescript/commonjs/src/components/TextInput.d.ts.map +0 -1
  480. package/dist/typescript/module/src/compiler/add.d.ts +0 -10
  481. package/dist/typescript/module/src/compiler/add.d.ts.map +0 -1
  482. package/dist/typescript/module/src/components/ActivityIndicator.d.ts +0 -3
  483. package/dist/typescript/module/src/components/ActivityIndicator.d.ts.map +0 -1
  484. package/dist/typescript/module/src/components/SafeAreaProvider/index.d.ts +0 -4
  485. package/dist/typescript/module/src/components/SafeAreaProvider/index.d.ts.map +0 -1
  486. package/dist/typescript/module/src/components/SafeAreaProvider/index.web.d.ts +0 -2
  487. package/dist/typescript/module/src/components/SafeAreaProvider/index.web.d.ts.map +0 -1
  488. package/dist/typescript/module/src/components/TextInput.d.ts +0 -13
  489. package/dist/typescript/module/src/components/TextInput.d.ts.map +0 -1
  490. package/src/compiler/add.ts +0 -257
  491. package/src/components/ActivityIndicator.tsx +0 -19
  492. package/src/components/SafeAreaProvider/index.tsx +0 -50
  493. package/src/components/SafeAreaProvider/index.web.tsx +0 -1
  494. package/src/components/TextInput.tsx +0 -20
@@ -1,259 +1,245 @@
1
- /* eslint-disable */
2
1
  // cSpell:ignore rcap,vmin,svmin,lvmin,dvmin,cqmin,vmax,svmax,lvmax,dvmax,cqmax,currentcolor,oklab,oklch,prophoto
3
2
 
3
+ import Color from "colorjs.io";
4
4
  import type {
5
- AlignContent,
6
- AlignItems,
7
- AlignSelf,
8
5
  Angle,
6
+ BorderBlockColor,
9
7
  BorderSideWidth,
10
8
  BorderStyle,
11
- BoxShadow,
12
9
  ColorOrAuto,
13
10
  CssColor,
14
11
  Declaration,
15
12
  DimensionPercentageFor_LengthValue,
16
- Display,
17
13
  EnvironmentVariable,
18
- FontFamily,
19
14
  FontSize,
20
15
  FontStyle,
21
16
  FontVariantCaps,
22
17
  FontWeight,
23
18
  GapValue,
24
- JustifyContent,
19
+ Gradient,
20
+ GradientItemFor_DimensionPercentageFor_LengthValue,
25
21
  Length,
26
22
  LengthPercentageOrAuto,
27
23
  LengthValue,
24
+ LineDirection,
28
25
  LineHeight,
29
26
  LineStyle,
30
27
  MaxSize,
31
28
  NumberOrPercentage,
32
- OverflowKeyword,
33
- PropertyId,
34
29
  Scale,
35
30
  Size,
36
- SVGPaint,
37
- TextAlign,
38
- TextDecorationLine,
39
- TextDecorationStyle,
40
- TextShadow,
31
+ Size2DFor_DimensionPercentageFor_LengthValue,
41
32
  Time,
42
33
  Token,
43
34
  TokenOrValue,
44
35
  Translate,
45
36
  UnresolvedColor,
46
- UserSelect,
47
- VerticalAlign,
48
37
  } from "lightningcss";
49
38
 
50
- import { emVariableName } from "../runtime/native/styles/constants";
51
- import { isStyleDescriptorArray } from "../runtime/utils/style-value";
52
- import type { AddFn } from "./add";
53
39
  import type {
54
- FeatureFlagRecord,
55
40
  StyleDescriptor,
56
41
  StyleFunction,
42
+ StyleRule,
57
43
  } from "./compiler.types";
58
44
  import { parseEasingFunction, parseIterationCount } from "./keyframes";
59
45
  import { toRNProperty } from "./selectors";
46
+ import type { StylesheetBuilder } from "./stylesheet";
47
+
48
+ const CommaSeparator = Symbol("CommaSeparator");
49
+
50
+ type DeclarationType<P extends Declaration["property"]> = Extract<
51
+ Declaration,
52
+ { property: P }
53
+ >;
54
+
55
+ type Parser<T extends Declaration["property"] = Declaration["property"]> = (
56
+ declaration: Extract<Declaration, { property: T }>,
57
+ builder: StylesheetBuilder,
58
+ propertyName: string,
59
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
60
+ ) => StyleDescriptor | void;
60
61
 
61
62
  const propertyRename: Record<string, string> = {
62
- "margin-inline-start": "margin-start",
63
- "margin-inline-end": "margin-end",
64
- "padding-inline-start": "padding-start",
65
- "padding-inline-end": "padding-end",
63
+ "background-image": "experimental_backgroundImage",
66
64
  };
67
65
 
68
- const validProperties = [
69
- "align-content",
70
- "align-items",
71
- "align-self",
66
+ const unparsedRuntimeParsing = new Set([
72
67
  "animation",
73
- "animation-delay",
74
- "animation-direction",
75
- "animation-duration",
76
- "animation-fill-mode",
77
- "animation-iteration-count",
78
- "animation-name",
79
- "animation-play-state",
80
- "animation-timing-function",
81
- "aspect-ratio",
82
- "background-color",
83
- "block-size",
84
- "border",
85
- "border-block",
86
- "border-block-color",
87
- "border-block-end",
88
- "border-block-end-color",
89
- "border-block-end-width",
90
- "border-block-start",
91
- "border-block-start-color",
92
- "border-block-start-width",
93
- "border-block-width",
94
- "border-bottom",
95
- "border-bottom-color",
96
- "border-bottom-left-radius",
97
- "border-bottom-right-radius",
98
- "border-bottom-width",
99
- "border-color",
100
- "border-end-end-radius",
101
- "border-end-start-radius",
102
- "border-inline",
103
- "border-inline-color",
104
- "border-inline-end",
105
- "border-inline-end-color",
106
- "border-inline-end-width",
107
- "border-inline-start",
108
- "border-inline-start-color",
109
- "border-inline-start-width",
110
- "border-inline-width",
111
- "border-left",
112
- "border-left-color",
113
- "border-left-width",
114
- "border-radius",
115
- "border-right",
116
- "border-right-color",
117
- "border-right-width",
118
- "border-start-end-radius",
119
- "border-start-start-radius",
120
- "border-style",
121
- "border-top",
122
- "border-top-color",
123
- "border-top-left-radius",
124
- "border-top-right-radius",
125
- "border-top-width",
126
- "border-width",
127
- "bottom",
128
- "box-shadow",
129
- "caret-color",
130
- "color",
131
- "column-gap",
132
- "container",
133
- "container-name",
134
- "container-type",
135
- "display",
136
- "fill",
137
- "flex",
138
- "flex-basis",
139
- "flex-direction",
140
- "flex-flow",
141
- "flex-grow",
142
- "flex-shrink",
143
- "flex-wrap",
144
- "font",
145
- "font-family",
146
- "font-size",
147
- "font-style",
148
- "font-variant-caps",
149
- "font-weight",
150
- "gap",
151
- "height",
152
- "inline-size",
153
- "inset",
154
- "inset-block",
155
- "inset-block-end",
156
- "inset-block-start",
157
- "inset-inline",
158
- "inset-inline-end",
159
- "inset-inline-start",
160
- "justify-content",
161
- "left",
162
- "letter-spacing",
163
- "line-height",
164
- "margin",
165
- "margin-block",
166
- "margin-block-end",
167
- "margin-block-start",
168
- "margin-bottom",
169
- "margin-inline",
170
- "margin-inline-end",
171
- "margin-inline-start",
172
- "margin-left",
173
- "margin-right",
174
- "margin-top",
175
- "max-block-size",
176
- "max-height",
177
- "max-inline-size",
178
- "max-width",
179
- "min-block-size",
180
- "min-height",
181
- "min-inline-size",
182
- "min-width",
183
- "opacity",
184
- "overflow",
185
- "padding",
186
- "padding-block",
187
- "padding-block-end",
188
- "padding-block-start",
189
- "padding-bottom",
190
- "padding-inline",
191
- "padding-inline-end",
192
- "padding-inline-start",
193
- "padding-left",
194
- "padding-right",
195
- "padding-top",
196
- "pointer-events",
197
- "position",
198
- "right",
199
- "rotate",
200
- "row-gap",
201
- "scale",
202
- "stroke",
203
- "stroke-width",
204
- "text-align",
205
- "text-decoration",
206
- "text-decoration-color",
207
- "text-decoration-line",
208
- "text-decoration-style",
209
68
  "text-shadow",
210
- "text-transform",
211
- "top",
212
69
  "transform",
213
- "transition",
214
- "transition-delay",
215
- "transition-duration",
216
- "transition-property",
217
- "transition-timing-function",
218
- "translate",
219
- "user-select",
220
- "vertical-align",
221
- "width",
222
- "z-index",
223
- ] as const;
224
-
225
- const validPropertiesLoose = new Set<string>(validProperties);
226
-
227
- export interface ParseDeclarationOptions {
228
- inlineRem?: number | false;
229
- features?: FeatureFlagRecord;
230
- allowAuto?: boolean;
231
- }
232
-
233
- export interface ParserOptions extends ParseDeclarationOptions {
234
- add: AddFn;
235
- addWarning: AddWarningShort;
236
- }
237
-
238
- declare function AddWarning(type: "property", property: string): undefined;
239
- declare function AddWarning(type: "function", name: string): undefined;
240
- declare function AddWarning(
241
- type: "value",
242
- property: string,
243
- value: any,
244
- ): undefined;
245
- export type AddWarningFn = typeof AddWarning;
70
+ "box-shadow",
71
+ "border",
72
+ ]);
73
+
74
+ const parsers: {
75
+ [K in Declaration["property"]]?: Parser<K>;
76
+ } = {
77
+ "align-content": parseAlignContent,
78
+ "align-items": parseAlignItems,
79
+ "align-self": parseAlignSelf,
80
+ "animation": addAnimationValue,
81
+ "animation-delay": addAnimationValue,
82
+ "animation-direction": addAnimationValue,
83
+ "animation-duration": addAnimationValue,
84
+ "animation-fill-mode": addAnimationValue,
85
+ "animation-iteration-count": addAnimationValue,
86
+ "animation-name": addAnimationValue,
87
+ "animation-play-state": addAnimationValue,
88
+ "animation-timing-function": addAnimationValue,
89
+ "aspect-ratio": parseAspectRatio,
90
+ "background-color": parseColorDeclaration,
91
+ "background-image": parseBackgroundImage,
92
+ "block-size": parseSizeDeclaration,
93
+ "border": parseBorder,
94
+ "border-block": parseBorderBlock,
95
+ "border-block-color": parseBorderBlockColor,
96
+ "border-block-end": parseBorderBlockEnd,
97
+ "border-block-end-color": parseColorDeclaration,
98
+ "border-block-end-width": parseBorderSideWidthDeclaration,
99
+ "border-block-start": parseBorderBlockStart,
100
+ "border-block-start-color": parseColorDeclaration,
101
+ "border-block-start-width": parseBorderSideWidthDeclaration,
102
+ "border-block-width": parseBorderBlockWidth,
103
+ "border-bottom": parseBorderSide,
104
+ "border-bottom-color": parseColorDeclaration,
105
+ "border-bottom-left-radius": parseSize2DDimensionPercentageDeclaration,
106
+ "border-bottom-right-radius": parseSize2DDimensionPercentageDeclaration,
107
+ "border-bottom-width": parseBorderSideWidthDeclaration,
108
+ "border-color": parseBorderColor,
109
+ "border-end-end-radius": parseSize2DDimensionPercentageDeclaration,
110
+ "border-end-start-radius": parseSize2DDimensionPercentageDeclaration,
111
+ "border-inline": parseBorderInline,
112
+ "border-inline-color": parseBorderBlockColor,
113
+ "border-inline-end": parseBorderInlineEnd,
114
+ "border-inline-end-color": parseColorDeclaration,
115
+ "border-inline-end-width": parseBorderSideWidthDeclaration,
116
+ "border-inline-start": parseBorderInlineStart,
117
+ "border-inline-start-color": parseColorDeclaration,
118
+ "border-inline-start-width": parseBorderSideWidthDeclaration,
119
+ "border-inline-width": parseBorderBlockWidth,
120
+ "border-left": parseBorderSide,
121
+ "border-left-color": parseColorDeclaration,
122
+ "border-left-width": parseBorderSideWidthDeclaration,
123
+ "border-radius": parseBorderRadius,
124
+ "border-right": parseBorderSide,
125
+ "border-right-color": parseColorDeclaration,
126
+ "border-right-width": parseBorderSideWidthDeclaration,
127
+ "border-start-end-radius": parseSize2DDimensionPercentageDeclaration,
128
+ "border-start-start-radius": parseSize2DDimensionPercentageDeclaration,
129
+ "border-style": parseBorderStyleDeclaration,
130
+ "border-top": parseBorderSide,
131
+ "border-top-color": parseColorDeclaration,
132
+ "border-top-left-radius": parseSize2DDimensionPercentageDeclaration,
133
+ "border-top-right-radius": parseSize2DDimensionPercentageDeclaration,
134
+ "border-top-width": parseBorderSideWidthDeclaration,
135
+ "border-width": parseBorderWidth,
136
+ "bottom": parseSizeDeclaration,
137
+ "box-shadow": parseBoxShadow,
138
+ "caret-color": parseColorOrAuto,
139
+ "color": parseFontColorDeclaration,
140
+ "column-gap": parseGap,
141
+ "container": parseContainer,
142
+ "container-name": parseContainerName,
143
+ "container-type": parseContainerType,
144
+ "display": parseDisplay,
145
+ "fill": parseSVGPaint,
146
+ "filter": parseFilter,
147
+ "flex": parseFlex,
148
+ "flex-basis": parseLengthPercentageOrAutoDeclaration,
149
+ "flex-direction": ({ value }) => value,
150
+ "flex-flow": parseFlexFlow,
151
+ "flex-grow": ({ value }) => value,
152
+ "flex-shrink": ({ value }) => value,
153
+ "flex-wrap": ({ value }) => value,
154
+ "font": parseFont,
155
+ "font-family": parseFontFamily,
156
+ "font-size": parseFontSizeDeclaration,
157
+ "font-style": parseFontStyleDeclaration,
158
+ "font-variant-caps": parseFontVariantCapsDeclaration,
159
+ "font-weight": parseFontWeightDeclaration,
160
+ "gap": parseGap,
161
+ "height": parseSizeDeclaration,
162
+ "inline-size": parseSizeDeclaration,
163
+ "inset": parseInset,
164
+ "inset-block": parseInsetBlock,
165
+ "inset-block-end": parseLengthPercentageOrAutoDeclaration,
166
+ "inset-block-start": parseLengthPercentageOrAutoDeclaration,
167
+ "inset-inline": parseInsetInline,
168
+ "inset-inline-end": parseLengthPercentageOrAutoDeclaration,
169
+ "inset-inline-start": parseLengthPercentageOrAutoDeclaration,
170
+ "justify-content": parseJustifyContent,
171
+ "left": parseSizeDeclaration,
172
+ "letter-spacing": parseLetterSpacing,
173
+ "line-height": parseLineHeightDeclaration,
174
+ "margin": parseMargin,
175
+ "margin-block": parseMarginBlock,
176
+ "margin-block-end": parseLengthPercentageOrAutoDeclaration,
177
+ "margin-block-start": parseLengthPercentageOrAutoDeclaration,
178
+ "margin-bottom": parseSizeDeclaration,
179
+ "margin-inline": parseMarginInline,
180
+ "margin-inline-end": parseLengthPercentageOrAutoDeclaration,
181
+ "margin-inline-start": parseLengthPercentageOrAutoDeclaration,
182
+ "margin-left": parseSizeDeclaration,
183
+ "margin-right": parseSizeDeclaration,
184
+ "margin-top": parseSizeDeclaration,
185
+ "max-block-size": parseSizeDeclaration,
186
+ "max-height": parseSizeDeclaration,
187
+ "max-inline-size": parseSizeDeclaration,
188
+ "max-width": parseSizeDeclaration,
189
+ "min-block-size": parseSizeDeclaration,
190
+ "min-height": parseSizeDeclaration,
191
+ "min-inline-size": parseSizeDeclaration,
192
+ "min-width": parseSizeDeclaration,
193
+ "opacity": ({ value }) => value,
194
+ "overflow": parseOverflow,
195
+ "padding": parsePadding,
196
+ "padding-block": parsePaddingBlock,
197
+ "padding-block-end": parseLengthPercentageOrAutoDeclaration,
198
+ "padding-block-start": parseLengthPercentageOrAutoDeclaration,
199
+ "padding-bottom": parseSizeDeclaration,
200
+ "padding-inline": parsePaddingInline,
201
+ "padding-inline-end": parseLengthPercentageOrAutoDeclaration,
202
+ "padding-inline-start": parseLengthPercentageOrAutoDeclaration,
203
+ "padding-left": parseSizeDeclaration,
204
+ "padding-right": parseSizeDeclaration,
205
+ "padding-top": parseSizeDeclaration,
206
+ "position": parsePosition,
207
+ "right": parseSizeDeclaration,
208
+ "rotate": parseRotate,
209
+ "row-gap": parseGap,
210
+ "scale": parseScale,
211
+ "stroke": parseSVGPaint,
212
+ "stroke-width": parseLengthDeclaration,
213
+ "text-align": parseTextAlign,
214
+ "text-decoration": parseTextDecoration,
215
+ "text-decoration-color": parseColorDeclaration,
216
+ "text-decoration-line": parseTextDecorationLineDeclaration,
217
+ "text-decoration-style": parseTextDecorationStyle,
218
+ "text-shadow": parseTextShadow,
219
+ "text-transform": ({ value }) => value.case,
220
+ "top": parseSizeDeclaration,
221
+ "transform": parseTransform,
222
+ "transition": addTransitionValue,
223
+ "transition-delay": addTransitionValue,
224
+ "transition-duration": addTransitionValue,
225
+ "transition-property": addTransitionValue,
226
+ "transition-timing-function": addTransitionValue,
227
+ "translate": parseTranslate,
228
+ "user-select": parseUserSelect,
229
+ "vertical-align": parseVerticalAlign,
230
+ "width": parseSizeDeclaration,
231
+ "z-index": parseZIndex,
232
+ };
233
+
234
+ // This is missing LightningCSS types
235
+ (parsers as Record<string, Parser>)["pointer-events"] =
236
+ parsePointerEvents as Parser;
246
237
 
247
- declare function AddWarningShort(type: "property", value: never): undefined;
248
- declare function AddWarningShort(type: "value", value: any): undefined;
249
- declare function AddWarningShort(type: "function", name: any): undefined;
250
- type AddWarningShort = typeof AddWarningShort;
238
+ const validProperties = new Set(Object.keys(parsers));
251
239
 
252
240
  export function parseDeclaration(
253
241
  declaration: Declaration,
254
- options: ParseDeclarationOptions,
255
- add: AddFn,
256
- addWarning: AddWarningFn,
242
+ builder: StylesheetBuilder,
257
243
  ) {
258
244
  if ("vendorPrefix" in declaration && declaration.vendorPrefix.length) {
259
245
  return;
@@ -270,1404 +256,680 @@ export function parseDeclaration(
270
256
  }
271
257
 
272
258
  if (declaration.property === "unparsed") {
273
- return parseDeclarationUnparsed(declaration, options, add, addWarning);
259
+ parseDeclarationUnparsed(declaration, builder);
274
260
  } else if (declaration.property === "custom") {
275
- return parseDeclarationCustom(declaration, options, add, addWarning);
261
+ parseDeclarationCustom(declaration, builder);
262
+ } else {
263
+ parseWithParser(declaration, builder);
276
264
  }
265
+ }
277
266
 
278
- if (!isValid(declaration)) {
279
- return addWarning("property", declaration.property);
280
- }
267
+ function parseWithParser(declaration: Declaration, builder: StylesheetBuilder) {
268
+ if (declaration.property in parsers) {
269
+ const parser = parsers[declaration.property] as Parser;
281
270
 
282
- const parseOptions: ParserOptions = {
283
- ...options,
284
- add,
285
- addWarning(value: any) {
286
- return addWarning("value", declaration.property, value);
287
- },
288
- };
271
+ builder.descriptorProperty = declaration.property;
289
272
 
290
- function handleStyleShorthand(
291
- name: string,
292
- options: Record<string, StyleDescriptor>,
293
- ) {
294
- if (allEqual(...Object.values(options))) {
295
- return add("style", name, Object.values(options)[0]);
296
- } else {
297
- for (const [name, value] of Object.entries(options)) {
298
- add("style", name, value);
299
- }
273
+ const value = parser(declaration, builder, declaration.property);
274
+
275
+ if (value !== undefined) {
276
+ builder.addDescriptor(
277
+ propertyRename[declaration.property] ?? declaration.property,
278
+ value,
279
+ );
300
280
  }
281
+ } else {
282
+ builder.addWarning("property", declaration.property);
301
283
  }
284
+ }
302
285
 
303
- switch (declaration.property) {
304
- case "background-color":
305
- return add(
306
- "style",
307
- declaration.property,
308
- parseColor(declaration.value, parseOptions),
309
- );
310
- case "opacity":
311
- return add("style", declaration.property, declaration.value);
312
- case "color":
313
- return add(
314
- "style",
315
- declaration.property,
316
- parseColor(declaration.value, parseOptions),
317
- );
318
- case "display":
319
- return add(
320
- "style",
321
- declaration.property,
322
- parseDisplay(declaration.value, parseOptions),
323
- );
324
- case "width":
325
- return add(
326
- "style",
327
- declaration.property,
328
- parseSize(declaration.value, parseOptions),
329
- );
330
- case "height":
331
- return add(
332
- "style",
333
- declaration.property,
334
- parseSize(declaration.value, parseOptions),
335
- );
336
- case "min-width":
337
- return add(
338
- "style",
339
- declaration.property,
340
- parseSize(declaration.value, parseOptions),
341
- );
342
- case "min-height":
343
- return add(
344
- "style",
345
- declaration.property,
346
- parseSize(declaration.value, parseOptions),
347
- );
348
- case "max-width":
349
- return add(
350
- "style",
351
- declaration.property,
352
- parseSize(declaration.value, parseOptions),
353
- );
354
- case "max-height":
355
- return add(
356
- "style",
357
- declaration.property,
358
- parseSize(declaration.value, parseOptions),
359
- );
360
- case "block-size":
361
- return add("style", "width", parseSize(declaration.value, parseOptions));
362
- case "inline-size":
363
- return add("style", "height", parseSize(declaration.value, parseOptions));
364
- case "min-block-size":
365
- return add(
366
- "style",
367
- "min-width",
368
- parseSize(declaration.value, parseOptions),
369
- );
370
- case "min-inline-size":
371
- return add(
372
- "style",
373
- "min-height",
374
- parseSize(declaration.value, parseOptions),
375
- );
376
- case "max-block-size":
377
- return add(
378
- "style",
379
- "max-width",
380
- parseSize(declaration.value, parseOptions),
381
- );
382
- case "max-inline-size":
383
- return add(
384
- "style",
385
- "max-height",
386
- parseSize(declaration.value, parseOptions),
387
- );
388
- case "overflow":
389
- return add(
390
- "style",
391
- declaration.property,
392
- parseOverflow(declaration.value.x, parseOptions),
393
- );
394
- case "position":
395
- const value: any = (declaration as any).value.type;
396
- if (value === "absolute" || value === "relative") {
397
- return add("style", declaration.property, value);
398
- } else {
399
- parseOptions.addWarning("value", value);
400
- }
401
- return;
402
- case "top":
403
- return add(
404
- "style",
405
- declaration.property,
406
- parseSize(declaration.value, parseOptions),
407
- );
408
- case "bottom":
409
- return add(
410
- "style",
411
- declaration.property,
412
- parseSize(declaration.value, parseOptions),
413
- );
414
- case "left":
415
- return add(
416
- "style",
417
- declaration.property,
418
- parseSize(declaration.value, parseOptions),
419
- );
420
- case "right":
421
- return add(
422
- "style",
423
- declaration.property,
424
- parseSize(declaration.value, parseOptions),
425
- );
426
- case "inset-block-start":
427
- return add(
428
- "style",
429
- declaration.property,
430
- parseLengthPercentageOrAuto(declaration.value, parseOptions),
431
- );
432
- case "inset-block-end":
433
- return add(
434
- "style",
435
- declaration.property,
436
- parseLengthPercentageOrAuto(declaration.value, parseOptions),
437
- );
438
- case "inset-inline-start":
439
- return add(
440
- "style",
441
- declaration.property,
442
- parseLengthPercentageOrAuto(declaration.value, parseOptions),
443
- );
444
- case "inset-inline-end":
445
- return add(
446
- "style",
447
- declaration.property,
448
- parseLengthPercentageOrAuto(declaration.value, parseOptions),
449
- );
450
- case "inset-block":
451
- return handleStyleShorthand("inset-block", {
452
- "inset-block-start": parseLengthPercentageOrAuto(
453
- declaration.value.blockStart,
454
- parseOptions,
455
- ),
456
- "inset-block-end": parseLengthPercentageOrAuto(
457
- declaration.value.blockEnd,
458
- parseOptions,
459
- ),
460
- });
461
- case "inset-inline":
462
- return handleStyleShorthand("inset-inline", {
463
- "inset-block-start": parseLengthPercentageOrAuto(
464
- declaration.value.inlineStart,
465
- parseOptions,
466
- ),
467
- "inset-block-end": parseLengthPercentageOrAuto(
468
- declaration.value.inlineEnd,
469
- parseOptions,
470
- ),
471
- });
472
- case "inset":
473
- handleStyleShorthand("inset", {
474
- top: parseLengthPercentageOrAuto(declaration.value.top, {
475
- ...parseOptions,
476
- addWarning: buildAddWarning(addWarning, "top"),
477
- }),
478
- bottom: parseLengthPercentageOrAuto(declaration.value.bottom, {
479
- ...parseOptions,
480
- addWarning: buildAddWarning(addWarning, "bottom"),
481
- }),
482
- left: parseLengthPercentageOrAuto(declaration.value.left, {
483
- ...parseOptions,
484
- addWarning: buildAddWarning(addWarning, "left"),
485
- }),
486
- right: parseLengthPercentageOrAuto(declaration.value.right, {
487
- ...parseOptions,
488
- addWarning: buildAddWarning(addWarning, "right"),
489
- }),
490
- });
491
- return;
492
- case "border-top-color":
493
- return add(
494
- "style",
495
- declaration.property,
496
- parseColor(declaration.value, parseOptions),
497
- );
498
- case "border-bottom-color":
499
- return add(
500
- "style",
501
- declaration.property,
502
- parseColor(declaration.value, parseOptions),
503
- );
504
- case "border-left-color":
505
- return add(
506
- "style",
507
- declaration.property,
508
- parseColor(declaration.value, parseOptions),
509
- );
510
- case "border-right-color":
511
- return add(
512
- "style",
513
- declaration.property,
514
- parseColor(declaration.value, parseOptions),
515
- );
516
- case "border-block-start-color":
517
- return add(
518
- "style",
519
- "border-top-color",
520
- parseColor(declaration.value, parseOptions),
521
- );
522
- case "border-block-end-color":
523
- return add(
524
- "style",
525
- "border-bottom-color",
526
- parseColor(declaration.value, parseOptions),
527
- );
528
- case "border-inline-start-color":
529
- return add(
530
- "style",
531
- "border-left-color",
532
- parseColor(declaration.value, parseOptions),
533
- );
534
- case "border-inline-end-color":
535
- return add(
536
- "style",
537
- "border-right-color",
538
- parseColor(declaration.value, parseOptions),
539
- );
540
- case "border-top-width":
541
- return add(
542
- "style",
543
- declaration.property,
544
- parseBorderSideWidth(declaration.value, parseOptions),
545
- );
546
- case "border-bottom-width":
547
- return add(
548
- "style",
549
- declaration.property,
550
- parseBorderSideWidth(declaration.value, parseOptions),
551
- );
552
- case "border-left-width":
553
- return add(
554
- "style",
555
- declaration.property,
556
- parseBorderSideWidth(declaration.value, parseOptions),
557
- );
558
- case "border-right-width":
559
- return add(
560
- "style",
561
- declaration.property,
562
- parseBorderSideWidth(declaration.value, parseOptions),
563
- );
564
- case "border-block-start-width":
565
- return add(
566
- "style",
567
- "border-top-width",
568
- parseBorderSideWidth(declaration.value, parseOptions),
569
- );
570
- case "border-block-end-width":
571
- return add(
572
- "style",
573
- "border-bottom-width",
574
- parseBorderSideWidth(declaration.value, parseOptions),
575
- );
576
- case "border-inline-start-width":
577
- return add(
578
- "style",
579
- "border-left-width",
580
- parseBorderSideWidth(declaration.value, parseOptions),
581
- );
582
- case "border-inline-end-width":
583
- return add(
584
- "style",
585
- "border-right-width",
586
- parseBorderSideWidth(declaration.value, parseOptions),
587
- );
588
- case "border-top-left-radius":
589
- return add(
590
- "style",
591
- declaration.property,
592
- parseLength(declaration.value[0], parseOptions),
593
- );
594
- case "border-top-right-radius":
595
- return add(
596
- "style",
597
- declaration.property,
598
- parseLength(declaration.value[0], parseOptions),
599
- );
600
- case "border-bottom-left-radius":
601
- return add(
602
- "style",
603
- declaration.property,
604
- parseLength(declaration.value[0], parseOptions),
605
- );
606
- case "border-bottom-right-radius":
607
- return add(
608
- "style",
609
- declaration.property,
610
- parseLength(declaration.value[0], parseOptions),
611
- );
612
- case "border-start-start-radius":
613
- return add(
614
- "style",
615
- declaration.property,
616
- parseLength(declaration.value[0], parseOptions),
617
- );
618
- case "border-start-end-radius":
619
- return add(
620
- "style",
621
- declaration.property,
622
- parseLength(declaration.value[0], parseOptions),
623
- );
624
- case "border-end-start-radius":
625
- return add(
626
- "style",
627
- declaration.property,
628
- parseLength(declaration.value[0], parseOptions),
629
- );
630
- case "border-end-end-radius":
631
- return add(
632
- "style",
633
- declaration.property,
634
- parseLength(declaration.value[0], parseOptions),
635
- );
636
- case "border-radius":
637
- handleStyleShorthand("border-radius", {
638
- "border-bottom-left-radius": parseLength(
639
- declaration.value.bottomLeft[0],
640
- parseOptions,
641
- ),
642
- "border-bottom-right-radius": parseLength(
643
- declaration.value.bottomRight[0],
644
- parseOptions,
645
- ),
646
- "border-top-left-radius": parseLength(
647
- declaration.value.topLeft[0],
648
- parseOptions,
649
- ),
650
- "border-top-right-radius": parseLength(
651
- declaration.value.topRight[0],
652
- parseOptions,
653
- ),
654
- });
655
- return;
656
- case "border-color":
657
- handleStyleShorthand("border-color", {
658
- "border-top-color": parseColor(declaration.value.top, {
659
- ...parseOptions,
660
- addWarning: buildAddWarning(addWarning, "border-top-color"),
661
- }),
662
- "border-bottom-color": parseColor(declaration.value.bottom, {
663
- ...parseOptions,
664
- addWarning: buildAddWarning(addWarning, "border-bottom-color"),
665
- }),
666
- "border-left-color": parseColor(declaration.value.left, {
667
- ...parseOptions,
668
- addWarning: buildAddWarning(addWarning, "border-left-color"),
669
- }),
670
- "border-right-color": parseColor(declaration.value.right, {
671
- ...parseOptions,
672
- addWarning: buildAddWarning(addWarning, "border-right-color"),
673
- }),
674
- });
675
- return;
676
- case "border-style":
677
- return add(
678
- "style",
679
- declaration.property,
680
- parseBorderStyle(declaration.value, parseOptions),
681
- );
682
- case "border-width":
683
- handleStyleShorthand("border-width", {
684
- "border-top-width": parseBorderSideWidth(
685
- declaration.value.top,
686
- parseOptions,
687
- ),
688
- "border-bottom-width": parseBorderSideWidth(
689
- declaration.value.bottom,
690
- parseOptions,
691
- ),
692
- "border-left-width": parseBorderSideWidth(
693
- declaration.value.left,
694
- parseOptions,
695
- ),
696
- "border-right-width": parseBorderSideWidth(
697
- declaration.value.right,
698
- parseOptions,
699
- ),
700
- });
701
- return;
702
- case "border-block-color":
703
- add(
704
- "style",
705
- "border-top-color",
706
- parseColor(declaration.value.start, parseOptions),
707
- );
708
- add(
709
- "style",
710
- "border-bottom-color",
711
- parseColor(declaration.value.end, parseOptions),
712
- );
713
- return;
714
- case "border-block-width":
715
- add(
716
- "style",
717
- "border-top-width",
718
- parseBorderSideWidth(declaration.value.start, parseOptions),
719
- );
720
- add(
721
- "style",
722
- "border-bottom-width",
723
- parseBorderSideWidth(declaration.value.end, parseOptions),
724
- );
725
- return;
726
- case "border-inline-color":
727
- add(
728
- "style",
729
- "border-left-color",
730
- parseColor(declaration.value.start, parseOptions),
731
- );
732
- add(
733
- "style",
734
- "border-right-color",
735
- parseColor(declaration.value.end, parseOptions),
736
- );
737
- return;
738
- case "border-inline-width":
739
- add(
740
- "style",
741
- "border-left-width",
742
- parseBorderSideWidth(declaration.value.start, parseOptions),
743
- );
744
- add(
745
- "style",
746
- "border-right-width",
747
- parseBorderSideWidth(declaration.value.end, parseOptions),
748
- );
749
- return;
750
- case "border":
751
- handleStyleShorthand("border", {
752
- "border-width": parseBorderSideWidth(
753
- declaration.value.width,
754
- parseOptions,
755
- ),
756
- "border-style": parseBorderStyle(declaration.value.style, parseOptions),
757
- });
758
- return;
759
- case "border-top":
760
- add(
761
- "style",
762
- declaration.property + "-color",
763
- parseColor(declaration.value.color, parseOptions),
764
- );
765
- add(
766
- "style",
767
- declaration.property + "-width",
768
- parseBorderSideWidth(declaration.value.width, parseOptions),
769
- );
770
- return;
771
- case "border-bottom":
772
- add(
773
- "style",
774
- declaration.property + "-color",
775
- parseColor(declaration.value.color, parseOptions),
776
- );
777
- add(
778
- "style",
779
- declaration.property + "-width",
780
- parseBorderSideWidth(declaration.value.width, parseOptions),
781
- );
782
- return;
783
- case "border-left":
784
- add(
785
- "style",
786
- declaration.property + "-color",
787
- parseColor(declaration.value.color, parseOptions),
788
- );
789
- add(
790
- "style",
791
- declaration.property + "-width",
792
- parseBorderSideWidth(declaration.value.width, parseOptions),
793
- );
794
- return;
795
- case "border-right":
796
- add(
797
- "style",
798
- declaration.property + "-color",
799
- parseColor(declaration.value.color, parseOptions),
800
- );
801
- add(
802
- "style",
803
- declaration.property + "-width",
804
- parseBorderSideWidth(declaration.value.width, parseOptions),
805
- );
806
- return;
807
- case "border-block":
808
- add(
809
- "style",
810
- "border-top-color",
811
- parseColor(declaration.value.color, parseOptions),
812
- );
813
- add(
814
- "style",
815
- "border-bottom-color",
816
- parseColor(declaration.value.color, parseOptions),
817
- );
818
- add(
819
- "style",
820
- "border-top-width",
821
- parseBorderSideWidth(declaration.value.width, parseOptions),
822
- );
823
- add(
824
- "style",
825
- "border-bottom-width",
826
- parseBorderSideWidth(declaration.value.width, parseOptions),
827
- );
828
- return;
829
- case "border-block-start":
830
- add(
831
- "style",
832
- "border-top-color",
833
- parseColor(declaration.value.color, parseOptions),
834
- );
835
- add(
836
- "style",
837
- "border-top-width",
838
- parseBorderSideWidth(declaration.value.width, parseOptions),
839
- );
840
- return;
841
- case "border-block-end":
842
- add(
843
- "style",
844
- "border-bottom-color",
845
- parseColor(declaration.value.color, parseOptions),
846
- );
847
- add(
848
- "style",
849
- "border-bottom-width",
850
- parseBorderSideWidth(declaration.value.width, parseOptions),
851
- );
852
- return;
853
- case "border-inline":
854
- add(
855
- "style",
856
- "border-left-color",
857
- parseColor(declaration.value.color, parseOptions),
858
- );
859
- add(
860
- "style",
861
- "border-right-color",
862
- parseColor(declaration.value.color, parseOptions),
863
- );
864
- add(
865
- "style",
866
- "border-left-width",
867
- parseBorderSideWidth(declaration.value.width, parseOptions),
868
- );
869
- add(
870
- "style",
871
- "border-right-width",
872
- parseBorderSideWidth(declaration.value.width, parseOptions),
873
- );
874
- return;
875
- case "border-inline-start":
876
- add(
877
- "style",
878
- "border-left-color",
879
- parseColor(declaration.value.color, parseOptions),
880
- );
881
- add(
882
- "style",
883
- "border-left-width",
884
- parseBorderSideWidth(declaration.value.width, parseOptions),
885
- );
886
- return;
887
- case "border-inline-end":
888
- add(
889
- "style",
890
- "border-right-color",
891
- parseColor(declaration.value.color, parseOptions),
892
- );
893
- add(
894
- "style",
895
- "border-right-width",
896
- parseBorderSideWidth(declaration.value.width, parseOptions),
897
- );
898
- return;
899
- case "flex-direction":
900
- return add("style", declaration.property, declaration.value);
901
- case "flex-wrap":
902
- return add("style", declaration.property, declaration.value);
903
- case "flex-flow":
904
- add("style", "flexWrap", declaration.value.wrap);
905
- add("style", "flexDirection", declaration.value.direction);
906
- break;
907
- case "flex-grow":
908
- return add("style", declaration.property, declaration.value);
909
- case "flex-shrink":
910
- return add("style", declaration.property, declaration.value);
911
- case "flex-basis":
912
- return add(
913
- "style",
914
- declaration.property,
915
- parseLengthPercentageOrAuto(declaration.value, parseOptions),
916
- );
917
- case "flex":
918
- add("style", "flex-grow", declaration.value.grow);
919
- add("style", "flex-shrink", declaration.value.shrink);
920
- add(
921
- "style",
922
- "flex-basis",
923
- parseLengthPercentageOrAuto(declaration.value.basis, parseOptions),
924
- );
925
- break;
926
- case "align-content":
927
- return add(
928
- "style",
929
- declaration.property,
930
- parseAlignContent(declaration.value, parseOptions),
931
- );
932
- case "justify-content":
933
- return add(
934
- "style",
935
- declaration.property,
936
- parseJustifyContent(declaration.value, parseOptions),
937
- );
938
- case "align-self":
939
- return add(
940
- "style",
941
- declaration.property,
942
- parseAlignSelf(declaration.value, parseOptions),
943
- );
944
- case "align-items":
945
- return add(
946
- "style",
947
- declaration.property,
948
- parseAlignItems(declaration.value, parseOptions),
949
- );
950
- case "row-gap":
951
- return add("style", "row-gap", parseGap(declaration.value, parseOptions));
952
- case "column-gap":
953
- return add(
954
- "style",
955
- "column-gap",
956
- parseGap(declaration.value, parseOptions),
957
- );
958
- case "gap":
959
- add("style", "row-gap", parseGap(declaration.value.row, parseOptions));
960
- add(
961
- "style",
962
- "column-gap",
963
- parseGap(declaration.value.column, parseOptions),
964
- );
965
- return;
966
- case "margin":
967
- handleStyleShorthand("margin", {
968
- "margin-top": parseSize(declaration.value.top, parseOptions, {
969
- allowAuto: true,
970
- }),
971
- "margin-bottom": parseSize(declaration.value.bottom, parseOptions, {
972
- allowAuto: true,
973
- }),
974
- "margin-left": parseSize(declaration.value.left, parseOptions, {
975
- allowAuto: true,
976
- }),
977
- "margin-right": parseSize(declaration.value.right, parseOptions, {
978
- allowAuto: true,
979
- }),
980
- });
981
- return;
982
- case "margin-top":
983
- return add(
984
- "style",
985
- declaration.property,
986
- parseSize(declaration.value, parseOptions, {
987
- allowAuto: true,
988
- }),
989
- );
990
- case "margin-bottom":
991
- return add(
992
- "style",
993
- declaration.property,
994
- parseSize(declaration.value, parseOptions, {
995
- allowAuto: true,
996
- }),
997
- );
998
- case "margin-left":
999
- return add(
1000
- "style",
1001
- declaration.property,
1002
- parseSize(declaration.value, parseOptions, {
1003
- allowAuto: true,
1004
- }),
1005
- );
1006
- case "margin-right":
1007
- return add(
1008
- "style",
1009
- declaration.property,
1010
- parseSize(declaration.value, parseOptions, {
1011
- allowAuto: true,
1012
- }),
1013
- );
1014
- case "margin-block-start":
1015
- return add(
1016
- "style",
1017
- "margin-start",
1018
- parseLengthPercentageOrAuto(declaration.value, parseOptions, {
1019
- allowAuto: true,
1020
- }),
1021
- );
1022
- case "margin-block-end":
1023
- return add(
1024
- "style",
1025
- "margin-end",
1026
- parseLengthPercentageOrAuto(declaration.value, parseOptions, {
1027
- allowAuto: true,
1028
- }),
1029
- );
1030
- case "margin-inline-start":
1031
- return add(
1032
- "style",
1033
- "margin-start",
1034
- parseLengthPercentageOrAuto(declaration.value, parseOptions, {
1035
- allowAuto: true,
1036
- }),
1037
- );
1038
- case "margin-inline-end":
1039
- return add(
1040
- "style",
1041
- "margin-end",
1042
- parseLengthPercentageOrAuto(declaration.value, parseOptions, {
1043
- allowAuto: true,
1044
- }),
1045
- );
1046
- case "margin-block":
1047
- handleStyleShorthand("margin-block", {
1048
- "margin-start": parseLengthPercentageOrAuto(
1049
- declaration.value.blockStart,
1050
- parseOptions,
1051
- ),
1052
- "margin-end": parseLengthPercentageOrAuto(
1053
- declaration.value.blockEnd,
1054
- parseOptions,
1055
- ),
1056
- });
1057
- return;
1058
- case "margin-inline":
1059
- handleStyleShorthand("margin-inline", {
1060
- "margin-start": parseLengthPercentageOrAuto(
1061
- declaration.value.inlineStart,
1062
- parseOptions,
1063
- ),
1064
- "margin-end": parseLengthPercentageOrAuto(
1065
- declaration.value.inlineEnd,
1066
- parseOptions,
1067
- ),
1068
- });
1069
- return;
1070
- case "padding":
1071
- handleStyleShorthand("padding", {
1072
- "padding-top": parseSize(declaration.value.top, parseOptions),
1073
- "padding-left": parseSize(declaration.value.left, parseOptions),
1074
- "padding-right": parseSize(declaration.value.right, parseOptions),
1075
- "padding-bottom": parseSize(declaration.value.bottom, parseOptions),
1076
- });
1077
- break;
1078
- case "padding-top":
1079
- return add(
1080
- "style",
1081
- declaration.property,
1082
- parseSize(declaration.value, parseOptions),
1083
- );
1084
- case "padding-bottom":
1085
- return add(
1086
- "style",
1087
- declaration.property,
1088
- parseSize(declaration.value, parseOptions),
1089
- );
1090
- case "padding-left":
1091
- return add(
1092
- "style",
1093
- declaration.property,
1094
- parseSize(declaration.value, parseOptions),
1095
- );
1096
- case "padding-right":
1097
- return add(
1098
- "style",
1099
- declaration.property,
1100
- parseSize(declaration.value, parseOptions),
1101
- );
1102
- case "padding-block-start":
1103
- return add(
1104
- "style",
1105
- "padding-start",
1106
- parseLengthPercentageOrAuto(declaration.value, parseOptions),
1107
- );
1108
- case "padding-block-end":
1109
- return add(
1110
- "style",
1111
- "padding-end",
1112
- parseLengthPercentageOrAuto(declaration.value, parseOptions),
1113
- );
1114
- case "padding-inline-start":
1115
- return add(
1116
- "style",
1117
- "padding-start",
1118
- parseLengthPercentageOrAuto(declaration.value, parseOptions),
1119
- );
1120
- case "padding-inline-end":
1121
- return add(
1122
- "style",
1123
- "padding-end",
1124
- parseLengthPercentageOrAuto(declaration.value, parseOptions),
1125
- );
1126
- case "padding-block":
1127
- handleStyleShorthand("padding-block", {
1128
- "padding-start": parseLengthPercentageOrAuto(
1129
- declaration.value.blockStart,
1130
- parseOptions,
1131
- ),
1132
- "padding-end": parseLengthPercentageOrAuto(
1133
- declaration.value.blockEnd,
1134
- parseOptions,
1135
- ),
1136
- });
1137
- return;
1138
- case "padding-inline":
1139
- handleStyleShorthand("padding-inline", {
1140
- "padding-start": parseLengthPercentageOrAuto(
1141
- declaration.value.inlineStart,
1142
- parseOptions,
1143
- ),
1144
- "padding-end": parseLengthPercentageOrAuto(
1145
- declaration.value.inlineEnd,
1146
- parseOptions,
1147
- ),
1148
- });
1149
- return;
1150
- case "font-weight":
1151
- return add(
1152
- "style",
1153
- declaration.property,
1154
- parseFontWeight(declaration.value, parseOptions),
1155
- );
1156
- case "font-size": {
1157
- add(
1158
- "style",
1159
- declaration.property,
1160
- parseFontSize(declaration.value, parseOptions),
1161
- );
286
+ function parseInsetBlock(
287
+ { value }: DeclarationType<"inset-block">,
288
+ builder: StylesheetBuilder,
289
+ ) {
290
+ builder.addShorthand("inset-block", {
291
+ "inset-block-start": parseLengthPercentageOrAuto(value.blockStart, builder),
292
+ "inset-block-end": parseLengthPercentageOrAuto(value.blockEnd, builder),
293
+ });
294
+ }
1162
295
 
1163
- add(
1164
- "style",
1165
- `--${emVariableName}`,
1166
- parseFontSize(declaration.value, parseOptions),
1167
- );
1168
- return;
1169
- }
1170
- case "font-family":
1171
- return add(
1172
- "style",
1173
- declaration.property,
1174
- parseFontFamily(declaration.value),
1175
- );
1176
- case "font-style":
1177
- return add(
1178
- "style",
1179
- declaration.property,
1180
- parseFontStyle(declaration.value, parseOptions),
1181
- );
1182
- case "font-variant-caps":
1183
- return add(
1184
- "style",
1185
- declaration.property,
1186
- parseFontVariantCaps(declaration.value, parseOptions),
1187
- );
1188
- case "line-height":
1189
- return add(
1190
- "style",
1191
- declaration.property,
1192
- parseLineHeight(declaration.value, parseOptions),
1193
- );
1194
- case "font":
1195
- add(
1196
- "style",
1197
- declaration.property + "-family",
1198
- parseFontFamily(declaration.value.family),
1199
- );
1200
- add(
1201
- "style",
1202
- "line-height",
1203
- parseLineHeight(declaration.value.lineHeight, parseOptions),
1204
- );
1205
- add(
1206
- "style",
1207
- declaration.property + "-size",
1208
- parseFontSize(declaration.value.size, parseOptions),
1209
- );
1210
- add(
1211
- "style",
1212
- declaration.property + "-style",
1213
- parseFontStyle(declaration.value.style, parseOptions),
1214
- );
1215
- add(
1216
- "style",
1217
- declaration.property + "-variant",
1218
- parseFontVariantCaps(declaration.value.variantCaps, parseOptions),
1219
- );
1220
- add(
1221
- "style",
1222
- declaration.property + "-weight",
1223
- parseFontWeight(declaration.value.weight, parseOptions),
1224
- );
1225
- return;
1226
- case "vertical-align":
1227
- return add(
1228
- "style",
1229
- declaration.property,
1230
- parseVerticalAlign(declaration.value, parseOptions),
1231
- );
1232
- case "transition-property":
1233
- case "transition-duration":
1234
- case "transition-delay":
1235
- case "transition-timing-function":
1236
- case "transition":
1237
- return addTransitionValue(declaration, parseOptions);
1238
- case "animation-duration":
1239
- return add(
1240
- "animation",
1241
- "animationDuration",
1242
- declaration.value.map((t) => parseTime(t)),
1243
- );
1244
- case "animation-timing-function":
1245
- case "animation-iteration-count":
1246
- case "animation-name":
1247
- case "animation-delay":
1248
- case "animation-direction":
1249
- case "animation-play-state":
1250
- case "animation-fill-mode":
1251
- case "animation":
1252
- return addAnimationValue(declaration, parseOptions);
1253
- case "transform": {
1254
- add("style", "transform", [
1255
- {},
1256
- "@transform",
1257
- declaration.value.flatMap((t): StyleDescriptor[] => {
1258
- switch (t.type) {
1259
- case "perspective":
1260
- return [
1261
- [{}, "@perspective", [parseLength(t.value, parseOptions)]],
1262
- ];
1263
- case "translate":
1264
- return [
1265
- [
1266
- {},
1267
- "@translateX",
1268
- [
1269
- parseLengthOrCoercePercentageToRuntime(
1270
- t.value[0],
1271
- parseOptions,
1272
- ),
1273
- ],
1274
- ],
1275
- [
1276
- [
1277
- {},
1278
- "@translateY",
1279
- [
1280
- parseLengthOrCoercePercentageToRuntime(
1281
- t.value[1],
1282
- parseOptions,
1283
- ),
1284
- ],
1285
- ],
1286
- ],
1287
- ];
1288
- case "translateX":
1289
- return [
1290
- [
1291
- {},
1292
- "@translateX",
1293
- [
1294
- parseLengthOrCoercePercentageToRuntime(
1295
- t.value,
1296
- parseOptions,
1297
- ),
1298
- ],
1299
- ],
1300
- ];
1301
- case "translateY":
1302
- return [
1303
- [
1304
- {},
1305
- "@translateY",
1306
- [
1307
- parseLengthOrCoercePercentageToRuntime(
1308
- t.value,
1309
- parseOptions,
1310
- ),
1311
- ],
1312
- ],
1313
- ];
1314
- case "rotate":
1315
- return [[{}, "@rotate", [parseAngle(t.value, parseOptions)]]];
1316
- case "rotateX":
1317
- return [[{}, "@rotateX", [parseAngle(t.value, parseOptions)]]];
1318
- case "rotateY":
1319
- return [[{}, "@rotateY", [parseAngle(t.value, parseOptions)]]];
1320
- case "rotateZ":
1321
- return [[{}, "@rotateZ", [parseAngle(t.value, parseOptions)]]];
1322
- case "scale":
1323
- return [
1324
- [{}, "@scaleX", [parseLength(t.value[0], parseOptions)]],
1325
- [{}, "@scaleY", [parseLength(t.value[0], parseOptions)]],
1326
- ];
1327
- case "scaleX":
1328
- return [[{}, "scaleX", [parseLength(t.value, parseOptions)]]];
1329
- case "scaleY":
1330
- return [[{}, "scaleY", [parseLength(t.value, parseOptions)]]];
1331
- case "skew":
1332
- return [
1333
- [{}, "skewX", [parseAngle(t.value[0], parseOptions)]],
1334
- [{}, "skewY", [parseAngle(t.value[0], parseOptions)]],
1335
- ];
1336
- case "skewX":
1337
- return [[{}, "skewX", [parseAngle(t.value, parseOptions)]]];
1338
- case "skewY":
1339
- return [[{}, "skewY", [parseAngle(t.value, parseOptions)]]];
1340
- case "translateZ":
1341
- case "translate3d":
1342
- case "scaleZ":
1343
- case "scale3d":
1344
- case "rotate3d":
1345
- case "matrix":
1346
- case "matrix3d":
1347
- return [[]];
1348
- }
1349
- }),
1350
- ]);
1351
- return;
1352
- }
1353
- case "translate":
1354
- add("style", "translateX", [
1355
- {},
1356
- "translateX",
1357
- [parseTranslate(declaration.value, "x", parseOptions)],
1358
- ]);
1359
- add("style", "translateY", [
1360
- {},
1361
- "translateX",
1362
- [parseTranslate(declaration.value, "y", parseOptions)],
1363
- ]);
1364
- return;
1365
- case "rotate":
1366
- add("style", "rotateX", [
1367
- {},
1368
- "rotateX",
1369
- [parseAngle(declaration.value.x, parseOptions)],
1370
- ]);
1371
- add("style", "rotateY", [
1372
- {},
1373
- "rotateY",
1374
- [parseAngle(declaration.value.y, parseOptions)],
1375
- ]);
1376
- add("style", "rotateZ", [
1377
- {},
1378
- "rotateZ",
1379
- [parseAngle(declaration.value.z, parseOptions)],
1380
- ]);
1381
- return;
1382
- case "scale":
1383
- add("style", "scaleX", [
1384
- {},
1385
- "scaleX",
1386
- [parseScale(declaration.value, "x", parseOptions)],
1387
- ]);
1388
- add("style", "scaleY", [
1389
- {},
1390
- "scaleY",
1391
- [parseScale(declaration.value, "y", parseOptions)],
1392
- ]);
1393
- return;
1394
- case "text-transform":
1395
- return add("style", declaration.property, declaration.value.case);
1396
- case "letter-spacing":
1397
- if (declaration.value.type !== "normal") {
1398
- return add(
1399
- "style",
1400
- declaration.property,
1401
- parseLength(declaration.value.value, parseOptions),
1402
- );
1403
- }
1404
- return;
1405
- case "text-decoration-line":
1406
- return add(
1407
- "style",
1408
- declaration.property,
1409
- parseTextDecorationLine(declaration.value, parseOptions),
1410
- );
1411
- case "text-decoration-color":
1412
- return add(
1413
- "style",
1414
- declaration.property,
1415
- parseColor(declaration.value, parseOptions),
1416
- );
1417
- case "text-decoration":
1418
- add(
1419
- "style",
1420
- "text-decoration-color",
1421
- parseColor(declaration.value.color, parseOptions),
1422
- );
1423
- add(
1424
- "style",
1425
- "text-decoration-line",
1426
- parseTextDecorationLine(declaration.value.line, parseOptions),
1427
- );
1428
- return;
1429
- case "text-shadow":
1430
- return parseTextShadow(add, declaration.value, parseOptions);
1431
- case "z-index":
1432
- if (declaration.value.type === "integer") {
1433
- add(
1434
- "style",
1435
- declaration.property,
1436
- parseLength(declaration.value.value, parseOptions),
1437
- );
1438
- } else {
1439
- parseOptions.addWarning("value", declaration.value.type);
296
+ function parseInsetInline(
297
+ { value }: DeclarationType<"inset-inline">,
298
+ builder: StylesheetBuilder,
299
+ ) {
300
+ builder.addShorthand("inset-inline", {
301
+ "inset-block-start": parseLengthPercentageOrAuto(
302
+ value.inlineStart,
303
+ builder,
304
+ ),
305
+ "inset-block-end": parseLengthPercentageOrAuto(value.inlineEnd, builder),
306
+ });
307
+ }
308
+
309
+ function parseInset(
310
+ { value }: DeclarationType<"inset">,
311
+ builder: StylesheetBuilder,
312
+ ) {
313
+ builder.addShorthand("inset", {
314
+ top: parseLengthPercentageOrAuto(value.top, builder),
315
+ bottom: parseLengthPercentageOrAuto(value.bottom, builder),
316
+ left: parseLengthPercentageOrAuto(value.left, builder),
317
+ right: parseLengthPercentageOrAuto(value.right, builder),
318
+ });
319
+ }
320
+
321
+ function parseBorderRadius(
322
+ { value }: DeclarationType<"border-radius">,
323
+ builder: StylesheetBuilder,
324
+ ) {
325
+ builder.addShorthand("border-radius", {
326
+ "border-bottom-left-radius": parseSize2DDimensionPercentage(
327
+ value.bottomLeft,
328
+ builder,
329
+ ),
330
+ "border-bottom-right-radius": parseSize2DDimensionPercentage(
331
+ value.bottomRight,
332
+ builder,
333
+ ),
334
+ "border-top-left-radius": parseSize2DDimensionPercentage(
335
+ value.topLeft,
336
+ builder,
337
+ ),
338
+ "border-top-right-radius": parseSize2DDimensionPercentage(
339
+ value.topRight,
340
+ builder,
341
+ ),
342
+ });
343
+ }
344
+
345
+ function parseBorderColor(
346
+ { value }: DeclarationType<"border-color">,
347
+ builder: StylesheetBuilder,
348
+ ) {
349
+ builder.addShorthand("border-color", {
350
+ "border-top-color": parseColor(value.top, builder),
351
+ "border-bottom-color": parseColor(value.bottom, builder),
352
+ "border-left-color": parseColor(value.left, builder),
353
+ "border-right-color": parseColor(value.right, builder),
354
+ });
355
+ }
356
+
357
+ function parseBorderWidth(
358
+ { value }: DeclarationType<"border-width">,
359
+ builder: StylesheetBuilder,
360
+ ) {
361
+ builder.addShorthand("border-width", {
362
+ "border-top-width": parseBorderSideWidth(value.top, builder),
363
+ "border-bottom-width": parseBorderSideWidth(value.bottom, builder),
364
+ "border-left-width": parseBorderSideWidth(value.left, builder),
365
+ "border-right-width": parseBorderSideWidth(value.right, builder),
366
+ });
367
+ }
368
+
369
+ function parseBorder(
370
+ { value }: DeclarationType<"border">,
371
+ builder: StylesheetBuilder,
372
+ ) {
373
+ builder.addShorthand("border", {
374
+ "border-width": parseBorderSideWidth(value.width, builder),
375
+ "border-style": parseBorderStyle(value.style, builder),
376
+ "border-color": parseColor(value.color, builder),
377
+ });
378
+ }
379
+
380
+ function parseBorderSide(
381
+ {
382
+ value,
383
+ property,
384
+ }: DeclarationType<
385
+ "border-top" | "border-bottom" | "border-left" | "border-right"
386
+ >,
387
+ builder: StylesheetBuilder,
388
+ ) {
389
+ builder.addDescriptor(property + "-color", parseColor(value.color, builder));
390
+ builder.addDescriptor(
391
+ property + "-width",
392
+ parseBorderSideWidth(value.width, builder),
393
+ );
394
+ }
395
+
396
+ function parseBorderBlock(
397
+ { value }: DeclarationType<"border-block">,
398
+ builder: StylesheetBuilder,
399
+ ) {
400
+ builder.addDescriptor("border-top-color", parseColor(value.color, builder));
401
+ builder.addDescriptor(
402
+ "border-bottom-color",
403
+ parseColor(value.color, builder),
404
+ );
405
+ builder.addDescriptor(
406
+ "border-top-width",
407
+ parseBorderSideWidth(value.width, builder),
408
+ );
409
+ builder.addDescriptor(
410
+ "border-bottom-width",
411
+ parseBorderSideWidth(value.width, builder),
412
+ );
413
+ }
414
+
415
+ function parseBorderBlockStart(
416
+ { value }: DeclarationType<"border-block-start">,
417
+ builder: StylesheetBuilder,
418
+ ) {
419
+ builder.addDescriptor("border-top-color", parseColor(value.color, builder));
420
+ builder.addDescriptor(
421
+ "border-top-width",
422
+ parseBorderSideWidth(value.width, builder),
423
+ );
424
+ }
425
+
426
+ function parseBorderBlockEnd(
427
+ { value }: DeclarationType<"border-block-end">,
428
+ builder: StylesheetBuilder,
429
+ ) {
430
+ builder.addDescriptor(
431
+ "border-bottom-color",
432
+ parseColor(value.color, builder),
433
+ );
434
+ builder.addDescriptor(
435
+ "border-bottom-width",
436
+ parseBorderSideWidth(value.width, builder),
437
+ );
438
+ }
439
+
440
+ function parseBorderInline(
441
+ { value }: DeclarationType<"border-inline">,
442
+ builder: StylesheetBuilder,
443
+ ) {
444
+ builder.addDescriptor("border-left-color", parseColor(value.color, builder));
445
+ builder.addDescriptor("border-right-color", parseColor(value.color, builder));
446
+ builder.addDescriptor(
447
+ "border-left-width",
448
+ parseBorderSideWidth(value.width, builder),
449
+ );
450
+ builder.addDescriptor(
451
+ "border-right-width",
452
+ parseBorderSideWidth(value.width, builder),
453
+ );
454
+ }
455
+
456
+ function parseBorderInlineStart(
457
+ { value }: DeclarationType<"border-inline-start">,
458
+ builder: StylesheetBuilder,
459
+ ) {
460
+ builder.addDescriptor("border-left-color", parseColor(value.color, builder));
461
+ builder.addDescriptor(
462
+ "border-left-width",
463
+ parseBorderSideWidth(value.width, builder),
464
+ );
465
+ }
466
+
467
+ function parseBorderInlineEnd(
468
+ { value }: DeclarationType<"border-inline-end">,
469
+ builder: StylesheetBuilder,
470
+ ) {
471
+ builder.addDescriptor("border-right-color", parseColor(value.color, builder));
472
+ builder.addDescriptor(
473
+ "border-right-width",
474
+ parseBorderSideWidth(value.width, builder),
475
+ );
476
+ }
477
+
478
+ function parseFlexFlow(
479
+ { value }: DeclarationType<"flex-flow">,
480
+ builder: StylesheetBuilder,
481
+ ) {
482
+ builder.addDescriptor("flexWrap", value.wrap);
483
+ builder.addDescriptor("flexDirection", value.direction);
484
+ }
485
+
486
+ function parseFlex(
487
+ { value }: DeclarationType<"flex">,
488
+ builder: StylesheetBuilder,
489
+ ) {
490
+ builder.addDescriptor("flex-grow", value.grow);
491
+ builder.addDescriptor("flex-shrink", value.shrink);
492
+ builder.addDescriptor(
493
+ "flex-basis",
494
+ parseLengthPercentageOrAuto(value.basis, builder),
495
+ );
496
+ }
497
+
498
+ function parseMargin(
499
+ { value }: DeclarationType<"margin">,
500
+ builder: StylesheetBuilder,
501
+ ) {
502
+ builder.addShorthand("margin", {
503
+ "margin-top": parseSize(value.top, builder, { allowAuto: true }),
504
+ "margin-bottom": parseSize(value.bottom, builder, { allowAuto: true }),
505
+ "margin-left": parseSize(value.left, builder, { allowAuto: true }),
506
+ "margin-right": parseSize(value.right, builder, { allowAuto: true }),
507
+ });
508
+ }
509
+
510
+ function parseMarginBlock(
511
+ { value }: DeclarationType<"margin-block">,
512
+ builder: StylesheetBuilder,
513
+ ) {
514
+ builder.addShorthand("margin-block", {
515
+ "margin-block-start": parseLengthPercentageOrAuto(
516
+ value.blockStart,
517
+ builder,
518
+ ),
519
+ "margin-block-end": parseLengthPercentageOrAuto(value.blockEnd, builder),
520
+ });
521
+ }
522
+
523
+ function parseMarginInline(
524
+ { value }: DeclarationType<"margin-inline">,
525
+ builder: StylesheetBuilder,
526
+ ) {
527
+ builder.addShorthand("margin-inline", {
528
+ "margin-inline-start": parseLengthPercentageOrAuto(
529
+ value.inlineStart,
530
+ builder,
531
+ ),
532
+ "margin-inline-end": parseLengthPercentageOrAuto(value.inlineEnd, builder),
533
+ });
534
+ }
535
+
536
+ function parsePadding(
537
+ { value }: DeclarationType<"padding">,
538
+ builder: StylesheetBuilder,
539
+ ) {
540
+ builder.addShorthand("padding", {
541
+ "padding-top": parseSize(value.top, builder),
542
+ "padding-bottom": parseSize(value.bottom, builder),
543
+ "padding-left": parseSize(value.left, builder),
544
+ "padding-right": parseSize(value.right, builder),
545
+ });
546
+ }
547
+
548
+ function parsePaddingBlock(
549
+ { value }: DeclarationType<"padding-block">,
550
+ builder: StylesheetBuilder,
551
+ ) {
552
+ builder.addShorthand("padding-block", {
553
+ "padding-block-start": parseLengthPercentageOrAuto(
554
+ value.blockStart,
555
+ builder,
556
+ ),
557
+ "padding-block-end": parseLengthPercentageOrAuto(value.blockEnd, builder),
558
+ });
559
+ }
560
+
561
+ function parsePaddingInline(
562
+ { value }: DeclarationType<"padding-inline">,
563
+ builder: StylesheetBuilder,
564
+ ) {
565
+ builder.addShorthand("padding-inline", {
566
+ "padding-inline-start": parseLengthPercentageOrAuto(
567
+ value.inlineStart,
568
+ builder,
569
+ ),
570
+ "padding-inline-end": parseLengthPercentageOrAuto(value.inlineEnd, builder),
571
+ });
572
+ }
573
+
574
+ function parseFont(
575
+ { value }: DeclarationType<"font">,
576
+ builder: StylesheetBuilder,
577
+ ) {
578
+ builder.addDescriptor("font-family", value.family[0]);
579
+ builder.addDescriptor(
580
+ "line-height",
581
+ parseLineHeight(value.lineHeight, builder),
582
+ );
583
+ builder.addDescriptor("font-size", parseFontSize(value.size, builder));
584
+ builder.addDescriptor("font-style", parseFontStyle(value.style, builder));
585
+ builder.addDescriptor(
586
+ "font-variant-caps",
587
+ parseFontVariantCaps(value.variantCaps, builder),
588
+ );
589
+ builder.addDescriptor("font-weight", parseFontWeight(value.weight, builder));
590
+ }
591
+
592
+ function parseTransform(
593
+ { value }: DeclarationType<"transform">,
594
+ builder: StylesheetBuilder,
595
+ ) {
596
+ builder.addDescriptor("transform", [
597
+ {},
598
+ "@transform",
599
+ value.flatMap((t): StyleDescriptor[] => {
600
+ switch (t.type) {
601
+ case "perspective":
602
+ return [[{}, "@perspective", parseLength(t.value, builder)]];
603
+ case "translate":
604
+ return [
605
+ [
606
+ {},
607
+ "@translateX",
608
+ parseLengthOrCoercePercentageToRuntime(t.value[0], builder),
609
+ ],
610
+ [
611
+ [
612
+ {},
613
+ "@translateY",
614
+ parseLengthOrCoercePercentageToRuntime(t.value[1], builder),
615
+ ],
616
+ ],
617
+ ];
618
+ case "translateX":
619
+ return [
620
+ [
621
+ {},
622
+ "@translateX",
623
+ parseLengthOrCoercePercentageToRuntime(t.value, builder),
624
+ ],
625
+ ];
626
+ case "translateY":
627
+ return [
628
+ [
629
+ {},
630
+ "@translateY",
631
+ parseLengthOrCoercePercentageToRuntime(t.value, builder),
632
+ ],
633
+ ];
634
+ case "rotate":
635
+ return [[{}, "@rotate", parseAngle(t.value, builder)]];
636
+ case "rotateX":
637
+ return [[{}, "@rotateX", parseAngle(t.value, builder)]];
638
+ case "rotateY":
639
+ return [[{}, "@rotateY", parseAngle(t.value, builder)]];
640
+ case "rotateZ":
641
+ return [[{}, "@rotateZ", parseAngle(t.value, builder)]];
642
+ case "scale":
643
+ return [
644
+ [{}, "@scaleX", parseLength(t.value[0], builder)],
645
+ [{}, "@scaleY", parseLength(t.value[1], builder)],
646
+ ];
647
+ case "scaleX":
648
+ return [[{}, "scaleX", parseLength(t.value, builder)]];
649
+ case "scaleY":
650
+ return [[{}, "scaleY", parseLength(t.value, builder)]];
651
+ case "skew":
652
+ return [
653
+ [{}, "skewX", parseAngle(t.value[0], builder)],
654
+ [{}, "skewY", parseAngle(t.value[1], builder)],
655
+ ];
656
+ case "skewX":
657
+ return [[{}, "skewX", parseAngle(t.value, builder)]];
658
+ case "skewY":
659
+ return [[{}, "skewY", parseAngle(t.value, builder)]];
660
+ case "translateZ":
661
+ case "translate3d":
662
+ case "scaleZ":
663
+ case "scale3d":
664
+ case "rotate3d":
665
+ case "matrix":
666
+ case "matrix3d":
667
+ return [[]];
1440
668
  }
1441
- return;
1442
- case "container-type":
1443
- return;
1444
- case "container-name":
1445
- return add(
1446
- "container",
1447
- declaration.property,
1448
- declaration.value.type === "none" ? false : declaration.value.value,
1449
- );
1450
- case "container":
1451
- return add(
1452
- "container",
1453
- "container-name",
1454
- declaration.value.name.type === "none"
1455
- ? false
1456
- : declaration.value.name.value,
1457
- );
1458
- case "text-decoration-style":
1459
- return add(
1460
- "style",
1461
- declaration.property,
1462
- parseTextDecorationStyle(declaration.value, parseOptions),
1463
- );
1464
- case "text-align":
1465
- return add(
1466
- "style",
1467
- declaration.property,
1468
- parseTextAlign(declaration.value, parseOptions),
1469
- );
1470
- case "box-shadow": {
1471
- return parseBoxShadow(declaration.value, parseOptions);
1472
- }
1473
- case "aspect-ratio": {
1474
- return add(
1475
- "style",
1476
- declaration.property,
1477
- parseAspectRatio(declaration.value),
1478
- );
1479
- }
1480
- case "user-select": {
1481
- return add(
1482
- "style",
1483
- declaration.property,
1484
- parseUserSelect(declaration.value, parseOptions),
1485
- );
1486
- }
1487
- case "fill": {
1488
- return add(
1489
- "style",
1490
- declaration.property,
1491
- parseSVGPaint(declaration.value, parseOptions),
1492
- );
1493
- }
1494
- case "stroke": {
1495
- return add(
1496
- "style",
1497
- declaration.property,
1498
- parseSVGPaint(declaration.value, parseOptions),
1499
- );
1500
- }
1501
- case "stroke-width": {
1502
- return add(
1503
- "style",
1504
- declaration.property,
1505
- parseDimensionPercentageFor_LengthValue(
1506
- declaration.value,
1507
- parseOptions,
1508
- ),
1509
- );
1510
- }
1511
- case "caret-color": {
1512
- return add(
1513
- "style",
1514
- declaration.property,
1515
- parseColorOrAuto(declaration.value, parseOptions),
1516
- );
1517
- }
1518
- default: {
1519
- /**
1520
- * This is used to know when lightningcss has added a new property and we need to add it to the
1521
- * switch.
1522
- *
1523
- * If your build fails here, its because you have a newer version of lightningcss installed.
1524
- */
1525
- declaration satisfies never;
1526
- }
669
+ }),
670
+ ]);
671
+ return;
672
+ }
673
+
674
+ function parseTranslate(
675
+ { value }: DeclarationType<"translate">,
676
+ builder: StylesheetBuilder,
677
+ ) {
678
+ builder.addDescriptor("translateX", [
679
+ {},
680
+ "translateX",
681
+ parseTranslateProp(value, "x", builder),
682
+ ]);
683
+ builder.addDescriptor("translateY", [
684
+ {},
685
+ "translateY",
686
+ parseTranslateProp(value, "y", builder),
687
+ ]);
688
+ }
689
+
690
+ function parseRotate(
691
+ { value }: DeclarationType<"rotate">,
692
+ builder: StylesheetBuilder,
693
+ ) {
694
+ builder.addDescriptor("rotateX", [
695
+ {},
696
+ "rotateX",
697
+ parseAngle(value.x, builder),
698
+ ]);
699
+ builder.addDescriptor("rotateY", [
700
+ {},
701
+ "rotateY",
702
+ parseAngle(value.y, builder),
703
+ ]);
704
+ builder.addDescriptor("rotateZ", [
705
+ {},
706
+ "rotateZ",
707
+ parseAngle(value.z, builder),
708
+ ]);
709
+ }
710
+
711
+ function parseScale(
712
+ { value }: DeclarationType<"scale">,
713
+ builder: StylesheetBuilder,
714
+ ) {
715
+ builder.addDescriptor("scaleX", [
716
+ {},
717
+ "scaleX",
718
+ parseScaleValue(value, "x", builder),
719
+ ]);
720
+ builder.addDescriptor("scaleY", [
721
+ {},
722
+ "scaleY",
723
+ parseScaleValue(value, "y", builder),
724
+ ]);
725
+ }
726
+
727
+ export function parseScaleValue(
728
+ translate: Scale,
729
+ prop: keyof Extract<Scale, object>,
730
+ builder: StylesheetBuilder,
731
+ ): StyleDescriptor {
732
+ if (translate === "none") {
733
+ return 0;
1527
734
  }
735
+
736
+ return parseLength(translate[prop], builder);
1528
737
  }
1529
738
 
1530
- function buildAddWarning(
1531
- addWarning: AddWarningFn,
1532
- property: string,
1533
- ): AddWarningShort {
1534
- return function (type, value) {
1535
- if (type === "property") {
1536
- return addWarning(type, property);
1537
- } else if (type === "value") {
1538
- return addWarning(type, property, value);
1539
- }
1540
- };
739
+ function parseLetterSpacing(
740
+ { value }: DeclarationType<"letter-spacing">,
741
+ builder: StylesheetBuilder,
742
+ ) {
743
+ if (value.type === "normal") {
744
+ return;
745
+ }
746
+ return parseLength(value.value, builder);
747
+ }
748
+
749
+ function parseTextDecoration(
750
+ { value }: DeclarationType<"text-decoration">,
751
+ builder: StylesheetBuilder,
752
+ ) {
753
+ builder.addDescriptor(
754
+ "text-decoration-color",
755
+ parseColor(value.color, builder),
756
+ );
757
+ builder.addDescriptor(
758
+ "text-decoration-line",
759
+ parseTextDecorationLine(value.line, builder),
760
+ );
761
+ }
762
+
763
+ function parseZIndex(
764
+ { value }: DeclarationType<"z-index">,
765
+ builder: StylesheetBuilder,
766
+ ): StyleDescriptor {
767
+ if (value.type === "integer") {
768
+ return parseLength(value.value, builder);
769
+ } else {
770
+ builder.addWarning("value", value.type);
771
+ return;
772
+ }
773
+ }
774
+
775
+ function parseContainerType(_value: unknown, _builder: StylesheetBuilder) {
776
+ return;
777
+ }
778
+
779
+ function parseContainerName(
780
+ { value }: DeclarationType<"container-name">,
781
+ builder: StylesheetBuilder,
782
+ ) {
783
+ builder.addContainer(value.type === "none" ? false : value.value);
784
+ return;
785
+ }
786
+
787
+ function parseContainer(
788
+ { value }: DeclarationType<"container">,
789
+ builder: StylesheetBuilder,
790
+ ) {
791
+ builder.addContainer(value.name.type === "none" ? false : value.name.value);
792
+ return;
1541
793
  }
1542
794
 
1543
- function parseDeclarationUnparsed(
795
+ export function parseDeclarationUnparsed(
1544
796
  declaration: Extract<Declaration, { property: "unparsed" }>,
1545
- options: ParseDeclarationOptions,
1546
- add: AddFn,
1547
- addWarning: AddWarningFn,
797
+ builder: StylesheetBuilder,
1548
798
  ) {
1549
799
  let property = declaration.value.propertyId.property;
1550
800
 
1551
- if (!isValid(declaration.value.propertyId)) {
1552
- return addWarning("property", property);
801
+ if (!(property in parsers)) {
802
+ builder.addWarning("property", property);
803
+ return;
1553
804
  }
1554
805
 
1555
- const parseOptions: ParserOptions = {
1556
- ...options,
1557
- add,
1558
- addWarning: buildAddWarning(addWarning, property),
1559
- };
1560
-
1561
806
  /**
1562
807
  * React Native doesn't support all the logical properties
1563
808
  */
1564
- if (propertyRename[declaration.value.propertyId.property]) {
1565
- property = propertyRename[declaration.value.propertyId.property]!;
809
+ const rename = propertyRename[property];
810
+ if (rename) {
811
+ property = rename;
1566
812
  }
1567
813
 
1568
814
  /**
1569
815
  * Unparsed shorthand properties need to be parsed at runtime
1570
816
  */
1571
- if (runtimeShorthands.has(property)) {
1572
- let args = parseUnparsed(declaration.value.value, parseOptions);
1573
- if (!isStyleDescriptorArray(args)) {
1574
- args = [args];
1575
- }
817
+ builder.descriptorProperty = property;
818
+
819
+ if (unparsedRuntimeParsing.has(property)) {
820
+ const args = parseUnparsed(declaration.value.value, builder);
1576
821
 
1577
822
  if (property === "animation") {
1578
- return add("style", "animation", [
823
+ builder.addDescriptor("animation", [
1579
824
  {},
1580
825
  `@${toRNProperty(property)}`,
1581
826
  args,
1582
827
  ]);
1583
828
  } else {
1584
- return add("style", property, [
829
+ builder.addDescriptor(property, [
1585
830
  {},
1586
831
  `@${toRNProperty(property)}`,
1587
832
  args,
1588
833
  1,
1589
834
  ]);
1590
835
  }
1591
- }
836
+ } else {
837
+ const value = parseUnparsed(declaration.value.value, builder);
1592
838
 
1593
- return add(
1594
- "style",
1595
- property,
1596
- parseUnparsed(declaration.value.value, parseOptions),
1597
- );
839
+ builder.addDescriptor(property, value);
840
+
841
+ if (property === "font-size") {
842
+ builder.addDescriptor("--__rn-css-em", value);
843
+ }
844
+
845
+ if (property === "color") {
846
+ builder.addDescriptor("--__rn-css-current-color", value);
847
+ }
848
+ }
1598
849
  }
1599
850
 
1600
- function parseDeclarationCustom(
851
+ export function parseDeclarationCustom(
1601
852
  declaration: Extract<Declaration, { property: "custom" }>,
1602
- options: ParseDeclarationOptions,
1603
- add: AddFn,
1604
- addWarning: AddWarningFn,
1605
- ) {
1606
- const parseOptions: ParserOptions = {
1607
- ...options,
1608
- add,
1609
- addWarning(type, value) {
1610
- if (type === "property") {
1611
- return addWarning(type, property);
1612
- } else if (type === "value") {
1613
- return addWarning(type, property, value);
1614
- }
1615
- },
1616
- };
1617
-
1618
- let property = declaration.value.name;
853
+ builder: StylesheetBuilder,
854
+ ) {
855
+ const property = declaration.value.name;
1619
856
  if (
1620
- validPropertiesLoose.has(property) ||
857
+ validProperties.has(property) ||
1621
858
  property.startsWith("--") ||
1622
859
  property.startsWith("-rn-")
1623
860
  ) {
1624
- return add(
1625
- "style",
861
+ builder.addDescriptor(
1626
862
  property,
1627
- parseUnparsed(declaration.value.value, {
1628
- ...parseOptions,
1629
- allowAuto: allowAuto.has(property),
1630
- }),
863
+ parseUnparsed(declaration.value.value, builder, allowAuto.has(property)),
1631
864
  );
1632
865
  } else {
1633
- return addWarning("property", declaration.value.name);
866
+ builder.addWarning("property", declaration.value.name);
1634
867
  }
1635
868
  }
1636
869
 
1637
- function isValid<T extends Declaration | PropertyId>(
1638
- declaration: T,
1639
- ): declaration is Extract<T, { property: (typeof validProperties)[number] }> {
1640
- return validPropertiesLoose.has(declaration.property);
1641
- }
1642
-
1643
- function reduceParseUnparsed(
870
+ export function reduceParseUnparsed(
1644
871
  tokenOrValues: TokenOrValue[],
1645
- options: ParserOptions,
1646
- ): StyleDescriptor[] | undefined {
872
+ builder: StylesheetBuilder,
873
+ ): StyleDescriptor {
1647
874
  const result = tokenOrValues
1648
- .map((tokenOrValue) => parseUnparsed(tokenOrValue, options))
875
+ .map((tokenOrValue) => parseUnparsed(tokenOrValue, builder))
1649
876
  .filter((v) => v !== undefined);
1650
877
 
1651
878
  if (result.length === 0) {
1652
879
  return undefined;
1653
- } else {
1654
- return result;
1655
880
  }
881
+
882
+ let currentGroup: StyleDescriptor = [];
883
+ let groups: StyleDescriptor[] = [currentGroup];
884
+
885
+ for (const value of result) {
886
+ if ((value as unknown) === CommaSeparator) {
887
+ currentGroup = [];
888
+ groups.push(currentGroup);
889
+ } else {
890
+ currentGroup.push(value);
891
+ }
892
+ }
893
+
894
+ groups = groups.flatMap((group): StyleDescriptor[] => {
895
+ if (!Array.isArray(group)) {
896
+ return [];
897
+ }
898
+
899
+ if (group.length === 0) {
900
+ return [];
901
+ } else if (group.length === 1) {
902
+ const first = group[0];
903
+
904
+ if (first === undefined) {
905
+ return [];
906
+ } else {
907
+ return [first];
908
+ }
909
+ } else {
910
+ return [group];
911
+ }
912
+ });
913
+
914
+ return groups.length === 1 ? groups[0] : groups;
1656
915
  }
1657
916
 
1658
- function unparsedFunction(
917
+ export function unparsedFunction(
1659
918
  token: Extract<TokenOrValue, { type: "function" }>,
1660
- options: ParserOptions,
919
+ builder: StylesheetBuilder,
1661
920
  ): StyleFunction {
1662
- const args = reduceParseUnparsed(token.value.arguments, options);
1663
- return [{}, token.value.name, args];
921
+ return [
922
+ {},
923
+ token.value.name,
924
+ reduceParseUnparsed(token.value.arguments, builder),
925
+ ];
1664
926
  }
1665
927
 
1666
928
  /**
1667
929
  * When the CSS cannot be parsed (often due to a runtime condition like a CSS variable)
1668
- * This function best efforts parsing it into a function that we can evaluate at runtime
930
+ * This export function best efforts parsing it into a export function that we can evaluate at runtime
1669
931
  */
1670
- function parseUnparsed(
932
+ export function parseUnparsed(
1671
933
  tokenOrValue:
1672
934
  | TokenOrValue
1673
935
  | TokenOrValue[]
@@ -1675,7 +937,8 @@ function parseUnparsed(
1675
937
  | number
1676
938
  | undefined
1677
939
  | null,
1678
- options: ParserOptions,
940
+ builder: StylesheetBuilder,
941
+ allowAuto = false,
1679
942
  ): StyleDescriptor {
1680
943
  if (tokenOrValue === undefined || tokenOrValue === null) {
1681
944
  return;
@@ -1686,6 +949,8 @@ function parseUnparsed(
1686
949
  return true;
1687
950
  } else if (tokenOrValue === "false") {
1688
951
  return false;
952
+ } else if (tokenOrValue === "currentcolor") {
953
+ return [{}, "var", "__rn-css-current-color"] as const;
1689
954
  } else {
1690
955
  return tokenOrValue;
1691
956
  }
@@ -1696,21 +961,21 @@ function parseUnparsed(
1696
961
  }
1697
962
 
1698
963
  if (Array.isArray(tokenOrValue)) {
1699
- const args = reduceParseUnparsed(tokenOrValue, options);
964
+ const args = reduceParseUnparsed(tokenOrValue, builder);
1700
965
  if (!args) return;
1701
- if (args.length === 1) return args[0];
966
+ if (Array.isArray(args) && args.length === 1) return args[0];
1702
967
  return args;
1703
968
  }
1704
969
 
1705
970
  switch (tokenOrValue.type) {
1706
971
  case "unresolved-color": {
1707
- return parseUnresolvedColor(tokenOrValue.value, options);
972
+ return parseUnresolvedColor(tokenOrValue.value, builder);
1708
973
  }
1709
974
  case "var": {
1710
- const args: StyleDescriptor[] = [tokenOrValue.value.name.ident.slice(2)];
1711
- const fallback = parseUnparsed(tokenOrValue.value.fallback, options);
975
+ let args: StyleDescriptor = tokenOrValue.value.name.ident.slice(2);
976
+ const fallback = parseUnparsed(tokenOrValue.value.fallback, builder);
1712
977
  if (fallback !== undefined) {
1713
- args.push(fallback);
978
+ args = [args, fallback];
1714
979
  }
1715
980
 
1716
981
  return [{}, "var", args, 1];
@@ -1729,28 +994,33 @@ function parseUnparsed(
1729
994
  case "translateX":
1730
995
  case "translateY":
1731
996
  tokenOrValue.value.name = `@${tokenOrValue.value.name}`;
1732
- return unparsedFunction(tokenOrValue, options);
1733
- case "platformColor":
1734
- case "getPixelSizeForLayoutSize":
1735
- case "roundToNearestPixel":
1736
- case "pixelScale":
997
+ return unparsedFunction(tokenOrValue, builder);
998
+ case "brightness":
999
+ case "contrast":
1000
+ case "cubic-bezier":
1001
+ case "drop-shadow":
1737
1002
  case "fontScale":
1738
- case "shadow":
1739
- case "rgb":
1740
- case "rgba":
1003
+ case "grayscale":
1741
1004
  case "hsl":
1742
1005
  case "hsla":
1743
- return unparsedFunction(tokenOrValue, options);
1006
+ case "hue-rotate":
1007
+ case "invert":
1008
+ case "linear-gradient":
1009
+ case "opacity":
1010
+ case "pixelScale":
1011
+ case "pixelSizeForLayoutSize":
1012
+ case "platformColor":
1013
+ case "radial-gradient":
1014
+ case "rgb":
1015
+ case "rgba":
1016
+ case "roundToNearestPixel":
1017
+ case "saturate":
1018
+ case "sepia":
1019
+ case "shadow":
1020
+ case "steps":
1021
+ return unparsedFunction(tokenOrValue, builder);
1744
1022
  case "hairlineWidth":
1745
1023
  return [{}, tokenOrValue.value.name, []];
1746
- case "platformSelect":
1747
- case "fontScaleSelect":
1748
- case "pixelScaleSelect":
1749
- return parseRNRuntimeSpecificsFunction(
1750
- tokenOrValue.value.name,
1751
- tokenOrValue.value.arguments,
1752
- options,
1753
- );
1754
1024
  case "calc":
1755
1025
  case "max":
1756
1026
  case "min":
@@ -1758,51 +1028,55 @@ function parseUnparsed(
1758
1028
  return parseCalcFn(
1759
1029
  tokenOrValue.value.name,
1760
1030
  tokenOrValue.value.arguments,
1761
- options,
1031
+ builder,
1762
1032
  );
1763
1033
  default: {
1764
- options.addWarning("function", tokenOrValue.value.name);
1034
+ builder.addWarning("function", tokenOrValue.value.name);
1765
1035
  return;
1766
1036
  }
1767
1037
  }
1768
1038
  }
1769
1039
  case "length":
1770
- return parseLength(tokenOrValue.value, options);
1040
+ return parseLength(tokenOrValue.value, builder);
1771
1041
  case "angle":
1772
- return parseAngle(tokenOrValue.value, options);
1042
+ return parseAngle(tokenOrValue.value, builder);
1773
1043
  case "token":
1774
1044
  switch (tokenOrValue.value.type) {
1775
1045
  case "string":
1776
- case "number":
1777
1046
  case "ident": {
1778
1047
  const value = tokenOrValue.value.value;
1779
- if (typeof value === "string") {
1780
- if (!options.allowAuto && value === "auto") {
1781
- return options.addWarning("value", value);
1782
- }
1048
+ if (!allowAuto && value === "auto") {
1049
+ builder.addWarning("value", value);
1050
+ return;
1051
+ }
1783
1052
 
1784
- if (value === "inherit") {
1785
- return options.addWarning("value", value);
1786
- }
1053
+ if (value === "inherit") {
1054
+ builder.addWarning("value", value);
1055
+ return;
1056
+ } else if (value === "currentcolor") {
1057
+ return [{}, "var", "__rn-css-current-color"] as const;
1058
+ }
1787
1059
 
1788
- if (value === "true") {
1789
- return true;
1790
- } else if (value === "false") {
1791
- return false;
1792
- } else {
1793
- return value;
1794
- }
1060
+ if (value === "true") {
1061
+ return true;
1062
+ } else if (value === "false") {
1063
+ return false;
1795
1064
  } else {
1796
1065
  return value;
1797
1066
  }
1798
1067
  }
1068
+ case "number": {
1069
+ return round(tokenOrValue.value.value);
1070
+ }
1799
1071
  case "function":
1800
- options.addWarning("value", tokenOrValue.value.value);
1072
+ builder.addWarning("value", tokenOrValue.value.value);
1801
1073
  return;
1802
1074
  case "percentage":
1803
1075
  return `${round(tokenOrValue.value.value * 100)}%`;
1804
1076
  case "dimension":
1805
- return parseDimension(tokenOrValue.value, options);
1077
+ return parseDimension(tokenOrValue.value, builder);
1078
+ case "comma":
1079
+ return CommaSeparator as unknown as StyleDescriptor;
1806
1080
  case "at-keyword":
1807
1081
  case "hash":
1808
1082
  case "id-hash":
@@ -1812,7 +1086,6 @@ function parseUnparsed(
1812
1086
  case "comment":
1813
1087
  case "colon":
1814
1088
  case "semicolon":
1815
- case "comma":
1816
1089
  case "include-match":
1817
1090
  case "dash-match":
1818
1091
  case "prefix-match":
@@ -1835,9 +1108,9 @@ function parseUnparsed(
1835
1108
  }
1836
1109
  }
1837
1110
  case "color":
1838
- return parseColor(tokenOrValue.value, options);
1111
+ return parseColor(tokenOrValue.value, builder);
1839
1112
  case "env":
1840
- return parseEnv(tokenOrValue.value, options);
1113
+ return parseEnv(tokenOrValue.value, builder);
1841
1114
  case "time":
1842
1115
  return parseTime(tokenOrValue.value);
1843
1116
  case "url":
@@ -1853,6 +1126,20 @@ function parseUnparsed(
1853
1126
  return;
1854
1127
  }
1855
1128
 
1129
+ export function parseLengthDeclaration(
1130
+ declaration: {
1131
+ value:
1132
+ | number
1133
+ | Length
1134
+ | DimensionPercentageFor_LengthValue
1135
+ | NumberOrPercentage
1136
+ | LengthValue;
1137
+ },
1138
+ builder: StylesheetBuilder,
1139
+ ) {
1140
+ return parseLength(declaration.value, builder);
1141
+ }
1142
+
1856
1143
  export function parseLength(
1857
1144
  length:
1858
1145
  | number
@@ -1860,9 +1147,9 @@ export function parseLength(
1860
1147
  | DimensionPercentageFor_LengthValue
1861
1148
  | NumberOrPercentage
1862
1149
  | LengthValue,
1863
- options: ParserOptions,
1150
+ builder: StylesheetBuilder,
1864
1151
  ): StyleDescriptor {
1865
- const { inlineRem = 14 } = options;
1152
+ const { inlineRem = 14 } = builder.getOptions();
1866
1153
 
1867
1154
  if (typeof length === "number") {
1868
1155
  return length;
@@ -1876,12 +1163,12 @@ export function parseLength(
1876
1163
  if (typeof inlineRem === "number") {
1877
1164
  return length.value * inlineRem;
1878
1165
  } else {
1879
- return [{}, "rem", [length.value]];
1166
+ return [{}, "rem", length.value];
1880
1167
  }
1881
1168
  case "vw":
1882
1169
  case "vh":
1883
1170
  case "em":
1884
- return [{}, length.unit, [length.value], 1];
1171
+ return [{}, length.unit, length.value, 1];
1885
1172
  case "in":
1886
1173
  case "cm":
1887
1174
  case "mm":
@@ -1926,7 +1213,7 @@ export function parseLength(
1926
1213
  case "lvmax":
1927
1214
  case "dvmax":
1928
1215
  case "cqmax":
1929
- options.addWarning("value", `${length.value}${length.unit}`);
1216
+ builder.addWarning("value", `${length.value}${length.unit}`);
1930
1217
  return undefined;
1931
1218
  default: {
1932
1219
  length.unit satisfies never;
@@ -1946,7 +1233,7 @@ export function parseLength(
1946
1233
  }
1947
1234
  case "dimension":
1948
1235
  case "value": {
1949
- return parseLength(length.value, options);
1236
+ return parseLength(length.value, builder);
1950
1237
  }
1951
1238
  }
1952
1239
  }
@@ -1954,7 +1241,7 @@ export function parseLength(
1954
1241
  return;
1955
1242
  }
1956
1243
 
1957
- function parseAngle(angle: Angle | number, options: ParserOptions) {
1244
+ export function parseAngle(angle: Angle | number, builder: StylesheetBuilder) {
1958
1245
  if (typeof angle === "number") {
1959
1246
  return `${angle}deg`;
1960
1247
  }
@@ -1964,26 +1251,71 @@ function parseAngle(angle: Angle | number, options: ParserOptions) {
1964
1251
  case "rad":
1965
1252
  return `${angle.value}${angle.type}`;
1966
1253
  default:
1967
- options.addWarning("value", angle.value);
1254
+ builder.addWarning("value", angle.value);
1968
1255
  return undefined;
1969
1256
  }
1970
1257
  }
1971
1258
 
1972
- function parseSize(
1259
+ export function parseSizeDeclaration(
1260
+ declaration: { value: Size | MaxSize },
1261
+ builder: StylesheetBuilder,
1262
+ ) {
1263
+ return parseSize(declaration.value, builder);
1264
+ }
1265
+
1266
+ export function parsePointerEvents(
1267
+ { value }: { value: string },
1268
+ builder: StylesheetBuilder,
1269
+ ) {
1270
+ switch (value) {
1271
+ case "none":
1272
+ case "box-none":
1273
+ case "box-only":
1274
+ case "auto":
1275
+ return value;
1276
+ case "visible":
1277
+ case "visiblePainted":
1278
+ case "visibleFill":
1279
+ case "visibleStroke":
1280
+ case "painted":
1281
+ case "fill":
1282
+ case "stroke":
1283
+ builder.addWarning("value", value);
1284
+ }
1285
+
1286
+ return;
1287
+ }
1288
+
1289
+ export function parseSize(
1973
1290
  size: Size | MaxSize,
1974
- options: ParserOptions,
1291
+ builder: StylesheetBuilder,
1292
+ options?: { allowAuto?: boolean },
1293
+ ): StyleDescriptor;
1294
+ export function parseSize(
1295
+ size: Size | MaxSize,
1296
+ builder: StylesheetBuilder,
1297
+ property: string,
1298
+ options?: { allowAuto?: boolean },
1299
+ ): StyleDescriptor;
1300
+ export function parseSize(
1301
+ size: Size | MaxSize,
1302
+ builder: StylesheetBuilder,
1303
+ options?: string | { allowAuto?: boolean },
1975
1304
  { allowAuto = false } = {},
1976
1305
  ) {
1306
+ allowAuto =
1307
+ (typeof options === "object" ? options.allowAuto : allowAuto) ?? false;
1308
+
1977
1309
  switch (size.type) {
1978
1310
  case "length-percentage":
1979
- return parseLength(size.value, options);
1311
+ return parseLength(size.value, builder);
1980
1312
  case "none":
1981
1313
  return size.type;
1982
1314
  case "auto":
1983
1315
  if (allowAuto) {
1984
1316
  return size.type;
1985
1317
  } else {
1986
- options.addWarning("value", size.type);
1318
+ builder.addWarning("value", size.type);
1987
1319
  return undefined;
1988
1320
  }
1989
1321
  case "min-content":
@@ -1992,7 +1324,7 @@ function parseSize(
1992
1324
  case "fit-content-function":
1993
1325
  case "stretch":
1994
1326
  case "contain":
1995
- options.addWarning("value", size.type);
1327
+ builder.addWarning("value", size.type);
1996
1328
  return undefined;
1997
1329
  default: {
1998
1330
  size satisfies never;
@@ -2002,72 +1334,197 @@ function parseSize(
2002
1334
  return;
2003
1335
  }
2004
1336
 
2005
- function parseColorOrAuto(color: ColorOrAuto, options: ParserOptions) {
2006
- if (color.type === "auto") {
2007
- options.addWarning("value", `Invalid color value ${color.type}`);
1337
+ export function parseColorOrAuto(
1338
+ { value }: { value: ColorOrAuto },
1339
+ builder: StylesheetBuilder,
1340
+ ) {
1341
+ if (value.type === "auto") {
1342
+ builder.addWarning("value", `Invalid color value ${value.type}`);
2008
1343
  return;
2009
1344
  } else {
2010
- return parseColor(color.value, options);
1345
+ return parseColor(value.value, builder);
2011
1346
  }
2012
1347
  }
2013
1348
 
2014
- function parseColor(color: CssColor, options: ParserOptions) {
2015
- if (typeof color === "string") {
2016
- // TODO: Could web system colors be mapped to native?
1349
+ export function parseFontColorDeclaration(
1350
+ declaration: Extract<Declaration, { value: CssColor }>,
1351
+ builder: StylesheetBuilder,
1352
+ ) {
1353
+ parseColorDeclaration(declaration, builder);
1354
+
1355
+ builder.addDescriptor(
1356
+ "--__rn-css-color",
1357
+ parseColor(declaration.value, builder),
1358
+ );
1359
+ }
1360
+
1361
+ export function parseColorDeclaration(
1362
+ declaration: Extract<Declaration, { value: CssColor }>,
1363
+ builder: StylesheetBuilder,
1364
+ ) {
1365
+ builder.addDescriptor(
1366
+ declaration.property,
1367
+ parseColor(declaration.value, builder),
1368
+ );
1369
+ }
1370
+
1371
+ export function parseColor(cssColor: CssColor, builder: StylesheetBuilder) {
1372
+ if (typeof cssColor === "string") {
1373
+ if (namedColors.has(cssColor)) {
1374
+ return cssColor;
1375
+ }
2017
1376
  return;
2018
1377
  }
2019
1378
 
2020
- switch (color.type) {
2021
- case "rgb": {
2022
- // Hex is smaller than rgb, so we convert it
2023
- const hexValues: string[] = [
2024
- color.r.toString(16).padStart(2, "0"),
2025
- color.g.toString(16).padStart(2, "0"),
2026
- color.b.toString(16).padStart(2, "0"),
2027
- ];
1379
+ let color: Color | undefined;
2028
1380
 
2029
- if (color.alpha !== 1) {
2030
- hexValues.push(
2031
- Math.round(color.alpha * 255)
2032
- .toString(16)
2033
- .padStart(2, "0"),
2034
- );
2035
- }
1381
+ const { hexColors = true, colorPrecision } = builder.getOptions();
2036
1382
 
2037
- return `#${hexValues.join("")}`;
1383
+ switch (cssColor.type) {
1384
+ case "currentcolor":
1385
+ return [{}, "var", "__rn-css-current-color"] as const;
1386
+ case "light-dark": {
1387
+ const extraRule: StyleRule = {
1388
+ s: [],
1389
+ m: [["=", "prefers-color-scheme", "dark"]],
1390
+ };
1391
+
1392
+ builder.addUnnamedDescriptor(
1393
+ parseColor(cssColor.dark, builder),
1394
+ false,
1395
+ extraRule,
1396
+ );
1397
+ builder.addExtraRule(extraRule);
1398
+ return parseColor(cssColor.light, builder);
1399
+ }
1400
+ case "rgb": {
1401
+ color = new Color({
1402
+ space: "sRGB",
1403
+ coords: [cssColor.r / 255, cssColor.g / 255, cssColor.b / 255],
1404
+ alpha: cssColor.alpha,
1405
+ });
1406
+ break;
2038
1407
  }
2039
1408
  case "hsl":
2040
- return `hsla(${color.h}, ${color.s}, ${color.l}, ${color.alpha})`;
2041
- case "currentcolor":
2042
- options.addWarning("value", color.type);
2043
- return;
2044
- case "light-dark":
1409
+ color = new Color({
1410
+ space: cssColor.type,
1411
+ coords: [cssColor.h, cssColor.s, cssColor.l],
1412
+ alpha: cssColor.alpha,
1413
+ });
1414
+ break;
1415
+ case "hwb":
1416
+ color = new Color({
1417
+ space: cssColor.type,
1418
+ coords: [cssColor.h, cssColor.w, cssColor.b],
1419
+ alpha: cssColor.alpha,
1420
+ });
1421
+ break;
2045
1422
  case "lab":
1423
+ color = new Color({
1424
+ space: cssColor.type,
1425
+ coords: [cssColor.l, cssColor.a, cssColor.b],
1426
+ alpha: cssColor.alpha,
1427
+ });
1428
+ break;
2046
1429
  case "lch":
1430
+ color = new Color({
1431
+ space: cssColor.type,
1432
+ coords: [cssColor.l, cssColor.c, cssColor.h],
1433
+ alpha: cssColor.alpha,
1434
+ });
1435
+ break;
2047
1436
  case "oklab":
1437
+ color = new Color({
1438
+ space: cssColor.type,
1439
+ coords: [cssColor.l, cssColor.a, cssColor.b],
1440
+ alpha: cssColor.alpha,
1441
+ });
1442
+ break;
2048
1443
  case "oklch":
1444
+ color = new Color({
1445
+ space: cssColor.type,
1446
+ coords: [cssColor.l, cssColor.c, cssColor.h],
1447
+ alpha: cssColor.alpha,
1448
+ });
1449
+ break;
2049
1450
  case "srgb":
1451
+ color = new Color({
1452
+ space: cssColor.type,
1453
+ coords: [cssColor.r, cssColor.g, cssColor.b],
1454
+ alpha: cssColor.alpha,
1455
+ });
1456
+ break;
2050
1457
  case "srgb-linear":
1458
+ color = new Color({
1459
+ space: cssColor.type,
1460
+ coords: [cssColor.r, cssColor.g, cssColor.b],
1461
+ alpha: cssColor.alpha,
1462
+ });
1463
+ break;
2051
1464
  case "display-p3":
1465
+ color = new Color({
1466
+ space: "p3",
1467
+ coords: [cssColor.r, cssColor.g, cssColor.b],
1468
+ alpha: cssColor.alpha,
1469
+ });
1470
+ break;
2052
1471
  case "a98-rgb":
1472
+ color = new Color({
1473
+ space: "a98rgb",
1474
+ coords: [cssColor.r, cssColor.g, cssColor.b],
1475
+ alpha: cssColor.alpha,
1476
+ });
1477
+ break;
2053
1478
  case "prophoto-rgb":
1479
+ color = new Color({
1480
+ space: "prophoto",
1481
+ coords: [cssColor.r, cssColor.g, cssColor.b],
1482
+ alpha: cssColor.alpha,
1483
+ });
1484
+ break;
2054
1485
  case "rec2020":
1486
+ color = new Color({
1487
+ space: cssColor.type,
1488
+ coords: [cssColor.r, cssColor.g, cssColor.b],
1489
+ alpha: cssColor.alpha,
1490
+ });
1491
+ break;
2055
1492
  case "xyz-d50":
1493
+ color = new Color({
1494
+ space: cssColor.type,
1495
+ coords: [cssColor.x, cssColor.y, cssColor.z],
1496
+ alpha: cssColor.alpha,
1497
+ });
1498
+ break;
2056
1499
  case "xyz-d65":
2057
- case "hwb":
2058
- options.addWarning("value", `Invalid color unit ${color.type}`);
2059
- return undefined;
1500
+ color = new Color({
1501
+ space: cssColor.type,
1502
+ coords: [cssColor.x, cssColor.y, cssColor.z],
1503
+ alpha: cssColor.alpha,
1504
+ });
1505
+ break;
2060
1506
  default: {
2061
- color satisfies never;
1507
+ cssColor satisfies never;
2062
1508
  }
2063
1509
  }
2064
1510
 
2065
- return;
1511
+ if (!hexColors || colorPrecision) {
1512
+ return color?.toString({ precision: colorPrecision ?? 3 });
1513
+ } else {
1514
+ return color?.toString({ format: "hex" });
1515
+ }
1516
+ }
1517
+
1518
+ export function parseLengthPercentageOrAutoDeclaration(
1519
+ value: { value: LengthPercentageOrAuto },
1520
+ builder: StylesheetBuilder,
1521
+ ) {
1522
+ return parseLengthPercentageOrAuto(value.value, builder);
2066
1523
  }
2067
1524
 
2068
- function parseLengthPercentageOrAuto(
1525
+ export function parseLengthPercentageOrAuto(
2069
1526
  lengthPercentageOrAuto: LengthPercentageOrAuto,
2070
- options: ParserOptions,
1527
+ builder: StylesheetBuilder,
2071
1528
  { allowAuto = false } = {},
2072
1529
  ) {
2073
1530
  switch (lengthPercentageOrAuto.type) {
@@ -2075,11 +1532,11 @@ function parseLengthPercentageOrAuto(
2075
1532
  if (allowAuto) {
2076
1533
  return lengthPercentageOrAuto.type;
2077
1534
  } else {
2078
- options.addWarning("value", lengthPercentageOrAuto.type);
1535
+ builder.addWarning("value", lengthPercentageOrAuto.type);
2079
1536
  return undefined;
2080
1537
  }
2081
1538
  case "length-percentage":
2082
- return parseLength(lengthPercentageOrAuto.value, options);
1539
+ return parseLength(lengthPercentageOrAuto.value, builder);
2083
1540
  default: {
2084
1541
  lengthPercentageOrAuto satisfies never;
2085
1542
  }
@@ -2088,9 +1545,9 @@ function parseLengthPercentageOrAuto(
2088
1545
  return;
2089
1546
  }
2090
1547
 
2091
- function parseJustifyContent(
2092
- justifyContent: JustifyContent,
2093
- options: ParserOptions,
1548
+ export function parseJustifyContent(
1549
+ declaration: DeclarationType<"justify-content">,
1550
+ builder: StylesheetBuilder,
2094
1551
  ) {
2095
1552
  const allowed = new Set([
2096
1553
  "flex-start",
@@ -2103,30 +1560,33 @@ function parseJustifyContent(
2103
1560
 
2104
1561
  let value: string | undefined;
2105
1562
 
2106
- switch (justifyContent.type) {
1563
+ switch (declaration.value.type) {
2107
1564
  case "normal":
2108
1565
  case "left":
2109
1566
  case "right":
2110
- value = justifyContent.type;
1567
+ value = declaration.value.type;
2111
1568
  break;
2112
1569
  case "content-distribution":
2113
1570
  case "content-position":
2114
- value = justifyContent.value;
1571
+ value = declaration.value.value;
2115
1572
  break;
2116
1573
  default: {
2117
- justifyContent satisfies never;
1574
+ declaration.value satisfies never;
2118
1575
  }
2119
1576
  }
2120
1577
 
2121
1578
  if (value && !allowed.has(value)) {
2122
- options.addWarning("value", value);
1579
+ builder.addWarning("value", value);
2123
1580
  return;
2124
1581
  }
2125
1582
 
2126
1583
  return value;
2127
1584
  }
2128
1585
 
2129
- function parseAlignContent(alignContent: AlignContent, options: ParserOptions) {
1586
+ export function parseAlignContent(
1587
+ declaration: DeclarationType<"align-content">,
1588
+ builder: StylesheetBuilder,
1589
+ ) {
2130
1590
  const allowed = new Set([
2131
1591
  "flex-start",
2132
1592
  "flex-end",
@@ -2138,29 +1598,32 @@ function parseAlignContent(alignContent: AlignContent, options: ParserOptions) {
2138
1598
 
2139
1599
  let value: string | undefined;
2140
1600
 
2141
- switch (alignContent.type) {
1601
+ switch (declaration.value.type) {
2142
1602
  case "normal":
2143
1603
  case "baseline-position":
2144
- value = alignContent.type;
1604
+ value = declaration.value.type;
2145
1605
  break;
2146
1606
  case "content-distribution":
2147
1607
  case "content-position":
2148
- value = alignContent.value;
1608
+ value = declaration.value.value;
2149
1609
  break;
2150
1610
  default: {
2151
- alignContent satisfies never;
1611
+ declaration.value satisfies never;
2152
1612
  }
2153
1613
  }
2154
1614
 
2155
1615
  if (value && !allowed.has(value)) {
2156
- options.addWarning("value", value);
1616
+ builder.addWarning("value", value);
2157
1617
  return;
2158
1618
  }
2159
1619
 
2160
1620
  return value;
2161
1621
  }
2162
1622
 
2163
- function parseAlignItems(alignItems: AlignItems, options: ParserOptions) {
1623
+ export function parseAlignItems(
1624
+ alignItems: DeclarationType<"align-items">,
1625
+ builder: StylesheetBuilder,
1626
+ ) {
2164
1627
  const allowed = new Set([
2165
1628
  "auto",
2166
1629
  "flex-start",
@@ -2172,33 +1635,36 @@ function parseAlignItems(alignItems: AlignItems, options: ParserOptions) {
2172
1635
 
2173
1636
  let value: string | undefined;
2174
1637
 
2175
- switch (alignItems.type) {
1638
+ switch (alignItems.value.type) {
2176
1639
  case "normal":
2177
1640
  value = "auto";
2178
1641
  break;
2179
1642
  case "stretch":
2180
- value = alignItems.type;
1643
+ value = alignItems.value.type;
2181
1644
  break;
2182
1645
  case "baseline-position":
2183
1646
  value = "baseline";
2184
1647
  break;
2185
1648
  case "self-position":
2186
- value = alignItems.value;
1649
+ value = alignItems.value.value;
2187
1650
  break;
2188
1651
  default: {
2189
- alignItems satisfies never;
1652
+ alignItems.value satisfies never;
2190
1653
  }
2191
1654
  }
2192
1655
 
2193
1656
  if (value && !allowed.has(value)) {
2194
- options.addWarning("value", value);
1657
+ builder.addWarning("value", value);
2195
1658
  return;
2196
1659
  }
2197
1660
 
2198
1661
  return value;
2199
1662
  }
2200
1663
 
2201
- function parseAlignSelf(alignSelf: AlignSelf, options: ParserOptions) {
1664
+ export function parseAlignSelf(
1665
+ alignSelf: DeclarationType<"align-self">,
1666
+ builder: StylesheetBuilder,
1667
+ ) {
2202
1668
  const allowed = new Set([
2203
1669
  "auto",
2204
1670
  "flex-start",
@@ -2210,34 +1676,44 @@ function parseAlignSelf(alignSelf: AlignSelf, options: ParserOptions) {
2210
1676
 
2211
1677
  let value: string | undefined;
2212
1678
 
2213
- switch (alignSelf.type) {
1679
+ switch (alignSelf.value.type) {
2214
1680
  case "normal":
2215
1681
  case "auto":
2216
1682
  value = "auto";
2217
1683
  break;
2218
1684
  case "stretch":
2219
- value = alignSelf.type;
1685
+ value = alignSelf.value.type;
2220
1686
  break;
2221
1687
  case "baseline-position":
2222
1688
  value = "baseline";
2223
1689
  break;
2224
1690
  case "self-position":
2225
- value = alignSelf.value;
1691
+ value = alignSelf.value.value;
2226
1692
  break;
2227
1693
  default: {
2228
- alignSelf satisfies never;
1694
+ alignSelf.value satisfies never;
2229
1695
  }
2230
1696
  }
2231
1697
 
2232
1698
  if (value && !allowed.has(value)) {
2233
- options.addWarning("value", value);
1699
+ builder.addWarning("value", value);
2234
1700
  return;
2235
1701
  }
2236
1702
 
2237
1703
  return value;
2238
1704
  }
2239
1705
 
2240
- function parseFontWeight(fontWeight: FontWeight, options: ParserOptions) {
1706
+ export function parseFontWeightDeclaration(
1707
+ declaration: DeclarationType<"font-weight">,
1708
+ builder: StylesheetBuilder,
1709
+ ) {
1710
+ return parseFontWeight(declaration.value, builder);
1711
+ }
1712
+
1713
+ export function parseFontWeight(
1714
+ fontWeight: FontWeight,
1715
+ builder: StylesheetBuilder,
1716
+ ) {
2241
1717
  switch (fontWeight.type) {
2242
1718
  case "absolute":
2243
1719
  if (fontWeight.value.type === "weight") {
@@ -2247,7 +1723,7 @@ function parseFontWeight(fontWeight: FontWeight, options: ParserOptions) {
2247
1723
  }
2248
1724
  case "bolder":
2249
1725
  case "lighter":
2250
- options.addWarning("value", fontWeight.type);
1726
+ builder.addWarning("value", fontWeight.type);
2251
1727
  return;
2252
1728
  default: {
2253
1729
  fontWeight satisfies never;
@@ -2257,55 +1733,67 @@ function parseFontWeight(fontWeight: FontWeight, options: ParserOptions) {
2257
1733
  return;
2258
1734
  }
2259
1735
 
2260
- function parseTextShadow(
2261
- add: AddFn,
2262
- [textShadow]: TextShadow[],
2263
- options: ParserOptions,
1736
+ export function parseTextShadow(
1737
+ declaration: DeclarationType<"text-shadow">,
1738
+ builder: StylesheetBuilder,
2264
1739
  ) {
1740
+ const [textShadow] = declaration.value;
1741
+
2265
1742
  if (!textShadow) {
2266
1743
  return;
2267
1744
  }
2268
- add("style", "textShadowColor", parseColor(textShadow.color, options));
2269
- add(
2270
- "style",
1745
+ builder.addDescriptor(
1746
+ "textShadowColor",
1747
+ parseColor(textShadow.color, builder),
1748
+ );
1749
+ builder.addDescriptor(
2271
1750
  "textShadowOffset.width",
2272
- parseLength(textShadow.xOffset, options),
1751
+ parseLength(textShadow.xOffset, builder),
2273
1752
  );
2274
- add(
2275
- "style",
1753
+ builder.addDescriptor(
2276
1754
  "textShadowOffset.height",
2277
- parseLength(textShadow.yOffset, options),
1755
+ parseLength(textShadow.yOffset, builder),
1756
+ );
1757
+ builder.addDescriptor(
1758
+ "textShadowRadius",
1759
+ parseLength(textShadow.blur, builder),
2278
1760
  );
2279
- add("style", "textShadowRadius", parseLength(textShadow.blur, options));
2280
1761
  }
2281
1762
 
2282
- function parseTextDecorationStyle(
2283
- textDecorationStyle: TextDecorationStyle,
2284
- options: ParserOptions,
1763
+ export function parseTextDecorationStyle(
1764
+ declaration: DeclarationType<"text-decoration-style">,
1765
+ builder: StylesheetBuilder,
2285
1766
  ) {
2286
1767
  const allowed = new Set(["solid", "double", "dotted", "dashed"]);
2287
1768
 
2288
- if (allowed.has(textDecorationStyle)) {
2289
- return textDecorationStyle;
1769
+ if (allowed.has(declaration.value)) {
1770
+ return declaration.value;
2290
1771
  }
2291
1772
 
2292
- options.addWarning("value", textDecorationStyle);
2293
- return undefined;
1773
+ builder.addWarning("value", declaration.value);
1774
+ return;
1775
+ }
1776
+
1777
+ export function parseTextDecorationLineDeclaration(
1778
+ declaration: DeclarationType<"text-decoration-line">,
1779
+ builder: StylesheetBuilder,
1780
+ ) {
1781
+ return parseTextDecorationLine(declaration.value, builder);
2294
1782
  }
2295
1783
 
2296
- function parseTextDecorationLine(
2297
- textDecorationLine: TextDecorationLine,
2298
- options: ParserOptions,
1784
+ export function parseTextDecorationLine(
1785
+ value: DeclarationType<"text-decoration-line">["value"],
1786
+ builder: StylesheetBuilder,
2299
1787
  ) {
2300
- if (!Array.isArray(textDecorationLine)) {
2301
- if (textDecorationLine === "none") {
2302
- return textDecorationLine;
1788
+ if (!Array.isArray(value)) {
1789
+ if (value === "none") {
1790
+ return value;
2303
1791
  }
2304
- options.addWarning("value", textDecorationLine);
1792
+ builder.addWarning("value", value);
2305
1793
  return;
2306
1794
  }
2307
1795
 
2308
- const set = new Set(textDecorationLine);
1796
+ const set = new Set(value);
2309
1797
 
2310
1798
  if (set.has("underline")) {
2311
1799
  if (set.has("line-through")) {
@@ -2317,102 +1805,166 @@ function parseTextDecorationLine(
2317
1805
  return "line-through";
2318
1806
  }
2319
1807
 
2320
- options.addWarning("value", textDecorationLine.join(" "));
1808
+ builder.addWarning("value", value.join(" "));
2321
1809
  return undefined;
2322
1810
  }
2323
1811
 
2324
- function parseOverflow(overflow: OverflowKeyword, options: ParserOptions) {
1812
+ export function parsePosition(
1813
+ { value }: DeclarationType<"position">,
1814
+ builder: StylesheetBuilder,
1815
+ ) {
1816
+ if (value.type === "absolute" || value.type === "relative") {
1817
+ return value.type;
1818
+ }
1819
+
1820
+ builder.addWarning("value", value.type);
1821
+ return;
1822
+ }
1823
+
1824
+ export function parseOverflow(
1825
+ { value }: DeclarationType<"overflow">,
1826
+ builder: StylesheetBuilder,
1827
+ ) {
2325
1828
  const allowed = new Set(["visible", "hidden"]);
2326
1829
 
2327
- if (allowed.has(overflow)) {
2328
- return overflow;
1830
+ if (allowed.has(value.x)) {
1831
+ return value.x;
2329
1832
  }
2330
1833
 
2331
- options.addWarning("value", overflow);
1834
+ builder.addWarning("value", value.x);
2332
1835
  return undefined;
2333
1836
  }
2334
1837
 
2335
- function parseBorderStyle(
2336
- borderStyle: BorderStyle | LineStyle,
2337
- options: ParserOptions,
1838
+ export function parseBorderStyleDeclaration(
1839
+ declaration: DeclarationType<"border-style">,
1840
+ builder: StylesheetBuilder,
1841
+ ) {
1842
+ return parseBorderStyle(declaration.value, builder);
1843
+ }
1844
+
1845
+ export function parseBorderStyle(
1846
+ value: BorderStyle | LineStyle,
1847
+ builder: StylesheetBuilder,
2338
1848
  ) {
2339
1849
  const allowed = new Set(["solid", "dotted", "dashed"]);
2340
1850
 
2341
- if (typeof borderStyle === "string") {
2342
- if (allowed.has(borderStyle)) {
2343
- return borderStyle;
1851
+ if (typeof value === "string") {
1852
+ if (allowed.has(value)) {
1853
+ return value;
2344
1854
  } else {
2345
- options.addWarning("value", borderStyle);
1855
+ builder.addWarning("value", value);
2346
1856
  return undefined;
2347
1857
  }
2348
1858
  } else if (
2349
- borderStyle.top === borderStyle.bottom &&
2350
- borderStyle.top === borderStyle.left &&
2351
- borderStyle.top === borderStyle.right &&
2352
- allowed.has(borderStyle.top)
1859
+ value.top === value.bottom &&
1860
+ value.top === value.left &&
1861
+ value.top === value.right &&
1862
+ allowed.has(value.top)
2353
1863
  ) {
2354
- return borderStyle.top;
1864
+ return value.top;
2355
1865
  }
2356
1866
 
2357
- options.addWarning("value", borderStyle.top);
1867
+ builder.addWarning("value", value.top);
2358
1868
 
2359
1869
  return undefined;
2360
1870
  }
2361
1871
 
2362
- function parseBorderSideWidth(
2363
- borderSideWidth: BorderSideWidth,
2364
- options: ParserOptions,
1872
+ export function parseBorderBlockColor(
1873
+ { value }: { value: BorderBlockColor },
1874
+ builder: StylesheetBuilder,
1875
+ ) {
1876
+ builder.addDescriptor("border-top-color", parseColor(value.start, builder));
1877
+ builder.addDescriptor("border-bottom-color", parseColor(value.end, builder));
1878
+ return;
1879
+ }
1880
+
1881
+ export function parseBorderBlockWidth(
1882
+ declaration: DeclarationType<"border-block-width" | "border-inline-width">,
1883
+ builder: StylesheetBuilder,
1884
+ ) {
1885
+ builder.addDescriptor(
1886
+ "border-top-width",
1887
+ parseBorderSideWidth(declaration.value.start, builder),
1888
+ );
1889
+ builder.addDescriptor(
1890
+ "border-bottom-width",
1891
+ parseBorderSideWidth(declaration.value.end, builder),
1892
+ );
1893
+ }
1894
+
1895
+ export function parseBorderSideWidthDeclaration(
1896
+ declaration: { value: BorderSideWidth },
1897
+ builder: StylesheetBuilder,
1898
+ ) {
1899
+ return parseBorderSideWidth(declaration.value, builder);
1900
+ }
1901
+
1902
+ export function parseBorderSideWidth(
1903
+ value: BorderSideWidth,
1904
+ builder: StylesheetBuilder,
2365
1905
  ) {
2366
- if (borderSideWidth.type === "length") {
2367
- return parseLength(borderSideWidth.value, options);
1906
+ if (value.type === "length") {
1907
+ return parseLength(value.value, builder);
2368
1908
  }
2369
1909
 
2370
- options.addWarning("value", borderSideWidth.type);
1910
+ builder.addWarning("value", value.type);
2371
1911
  return undefined;
2372
1912
  }
2373
1913
 
2374
- function parseVerticalAlign(
2375
- verticalAlign: VerticalAlign,
2376
- options: ParserOptions,
1914
+ export function parseVerticalAlign(
1915
+ { value }: DeclarationType<"vertical-align">,
1916
+ builder: StylesheetBuilder,
2377
1917
  ) {
2378
- if (verticalAlign.type === "length") {
1918
+ if (value.type === "length") {
2379
1919
  return undefined;
2380
1920
  }
2381
1921
 
2382
1922
  const allowed = new Set(["auto", "top", "bottom", "middle"]);
2383
1923
 
2384
- if (allowed.has(verticalAlign.value)) {
2385
- return verticalAlign.value;
1924
+ if (allowed.has(value.value)) {
1925
+ return value.value;
2386
1926
  }
2387
1927
 
2388
- options.addWarning("value", verticalAlign.value);
1928
+ builder.addWarning("value", value.value);
2389
1929
  return undefined;
2390
1930
  }
2391
1931
 
2392
- function parseFontFamily(fontFamily: FontFamily[]) {
1932
+ function parseFontFamily({ value }: DeclarationType<"font-family">) {
2393
1933
  // React Native only allows one font family - better hope this is the right one :)
2394
- return fontFamily[0];
1934
+ return value[0];
2395
1935
  }
2396
1936
 
2397
- function parseLineHeight(
2398
- lineHeight: LineHeight,
2399
- options: ParserOptions,
1937
+ export function parseLineHeightDeclaration(
1938
+ declaration: DeclarationType<"line-height">,
1939
+ builder: StylesheetBuilder,
1940
+ ) {
1941
+ return parseLineHeight(declaration.value, builder);
1942
+ }
1943
+
1944
+ export function parseLineHeight(
1945
+ value: LineHeight,
1946
+ builder: StylesheetBuilder,
2400
1947
  ): StyleDescriptor {
2401
- switch (lineHeight.type) {
1948
+ switch (value.type) {
2402
1949
  case "normal":
2403
1950
  return undefined;
2404
1951
  case "number":
2405
- return [{}, "em", [lineHeight.value], 1];
1952
+ return [{}, "em", [value.value], 1];
2406
1953
  case "length": {
2407
- const length = lineHeight.value;
1954
+ const length = value.value;
2408
1955
 
2409
1956
  switch (length.type) {
2410
1957
  case "dimension":
2411
- return parseLength(length, options);
1958
+ return parseLength(length, builder);
2412
1959
  case "percentage":
2413
1960
  case "calc":
2414
- options.addWarning("value", length.value);
2415
- return undefined;
1961
+ builder.addWarning(
1962
+ "value",
1963
+ typeof length.value === "number"
1964
+ ? length.value
1965
+ : JSON.stringify(length.value),
1966
+ );
1967
+ return;
2416
1968
  default: {
2417
1969
  length satisfies never;
2418
1970
  }
@@ -2421,48 +1973,71 @@ function parseLineHeight(
2421
1973
  return;
2422
1974
  }
2423
1975
  default: {
2424
- lineHeight satisfies never;
1976
+ value satisfies never;
2425
1977
  }
2426
1978
  }
2427
1979
 
2428
1980
  return;
2429
1981
  }
2430
1982
 
2431
- function parseFontSize(fontSize: FontSize, options: ParserOptions) {
2432
- switch (fontSize.type) {
1983
+ export function parseFontSizeDeclaration(
1984
+ declaration: DeclarationType<"font-size">,
1985
+ builder: StylesheetBuilder,
1986
+ ) {
1987
+ const fontSize = parseFontSize(declaration.value, builder);
1988
+ builder.addDescriptor("fontSize", fontSize);
1989
+ builder.addDescriptor("--__rn-css-em", fontSize);
1990
+ }
1991
+
1992
+ export function parseFontSize(value: FontSize, builder: StylesheetBuilder) {
1993
+ switch (value.type) {
2433
1994
  case "length":
2434
- return parseLength(fontSize.value, options);
1995
+ return parseLength(value.value, builder);
2435
1996
  case "absolute":
2436
1997
  case "relative":
2437
- options.addWarning("value", fontSize.value);
1998
+ builder.addWarning("value", value.value);
2438
1999
  return undefined;
2439
2000
  default: {
2440
- fontSize satisfies never;
2001
+ value satisfies never;
2441
2002
  }
2442
2003
  }
2443
2004
 
2444
2005
  return;
2445
2006
  }
2446
2007
 
2447
- function parseFontStyle(fontStyle: FontStyle, options: ParserOptions) {
2448
- switch (fontStyle.type) {
2008
+ export function parseFontStyleDeclaration(
2009
+ declaration: DeclarationType<"font-style">,
2010
+ builder: StylesheetBuilder,
2011
+ ) {
2012
+ return parseFontStyle(declaration.value, builder);
2013
+ }
2014
+
2015
+ export function parseFontStyle(value: FontStyle, builder: StylesheetBuilder) {
2016
+ switch (value.type) {
2449
2017
  case "normal":
2450
2018
  case "italic":
2451
- return fontStyle.type;
2019
+ return value.type;
2452
2020
  case "oblique":
2453
- options.addWarning("value", fontStyle.type);
2021
+ builder.addWarning("value", value.type);
2454
2022
  return undefined;
2455
2023
  default: {
2456
- fontStyle satisfies never;
2024
+ value satisfies never;
2457
2025
  }
2458
2026
  }
2459
2027
 
2460
2028
  return;
2461
2029
  }
2462
2030
 
2463
- function parseFontVariantCaps(
2464
- fontVariantCaps: FontVariantCaps,
2465
- options: ParserOptions,
2031
+ export function parseFontVariantCapsDeclaration(
2032
+ declaration: DeclarationType<"font-variant-caps">,
2033
+ builder: StylesheetBuilder,
2034
+ ) {
2035
+ return parseFontVariantCaps(declaration.value, builder);
2036
+ }
2037
+
2038
+ export function parseFontVariantCaps(
2039
+ value: FontVariantCaps,
2040
+ builder: StylesheetBuilder,
2466
2041
  ) {
2467
2042
  const allowed = new Set([
2468
2043
  "small-caps",
@@ -2471,207 +2046,179 @@ function parseFontVariantCaps(
2471
2046
  "tabular-nums",
2472
2047
  "proportional-nums",
2473
2048
  ]);
2474
- if (allowed.has(fontVariantCaps)) {
2475
- return fontVariantCaps;
2049
+ if (allowed.has(value)) {
2050
+ return value;
2476
2051
  }
2477
2052
 
2478
- options.addWarning("value", fontVariantCaps);
2053
+ builder.addWarning("value", value);
2479
2054
  return undefined;
2480
2055
  }
2481
2056
 
2482
- function parseLengthOrCoercePercentageToRuntime(
2057
+ export function parseLengthOrCoercePercentageToRuntime(
2483
2058
  value: Length | DimensionPercentageFor_LengthValue | NumberOrPercentage,
2484
- options: ParserOptions,
2059
+ builder: StylesheetBuilder,
2485
2060
  ): StyleDescriptor {
2486
- return parseLength(value, options);
2061
+ return parseLength(value, builder);
2487
2062
  }
2488
2063
 
2489
- function parseGap(value: GapValue, options: ParserOptions) {
2490
- if (value.type === "normal") {
2491
- options.addWarning("value", value.type);
2064
+ export function parseGap(
2065
+ declaration: DeclarationType<"gap" | "column-gap" | "row-gap">,
2066
+ builder: StylesheetBuilder,
2067
+ ) {
2068
+ if ("column" in declaration.value) {
2069
+ builder.addDescriptor(
2070
+ "row-gap",
2071
+ parseGapValue(declaration.value.row, builder),
2072
+ );
2073
+ builder.addDescriptor(
2074
+ "column-gap",
2075
+ parseGapValue(declaration.value.column, builder),
2076
+ );
2077
+
2492
2078
  return;
2493
- }
2079
+ } else {
2080
+ if (declaration.value.type === "normal") {
2081
+ builder.addWarning("value", declaration.value.type);
2082
+ return;
2083
+ }
2494
2084
 
2495
- return parseLength(value.value, options);
2085
+ return parseLength(declaration.value.value, builder);
2086
+ }
2496
2087
  }
2497
2088
 
2498
- function parseRNRuntimeSpecificsFunction(
2499
- name: string,
2500
- args: TokenOrValue[],
2501
- options: ParserOptions,
2089
+ function parseGapValue(
2090
+ value: GapValue,
2091
+ builder: StylesheetBuilder,
2502
2092
  ): StyleDescriptor {
2503
- let key: string | undefined;
2504
- const runtimeArgs: Record<string, StyleDescriptor> = {};
2505
-
2506
- for (const token of args) {
2507
- if (!key) {
2508
- if (
2509
- token.type === "token" &&
2510
- (token.value.type === "ident" || token.value.type === "number")
2511
- ) {
2512
- key = token.value.value.toString();
2513
- continue;
2514
- }
2515
- } else {
2516
- if (token.type !== "token") {
2517
- const value = parseUnparsed(token, options);
2518
- if (value === undefined) {
2519
- return;
2520
- }
2521
- runtimeArgs[key] = value;
2522
- key = undefined;
2523
- } else {
2524
- switch (token.value.type) {
2525
- case "string":
2526
- case "number":
2527
- case "ident": {
2528
- if (key) {
2529
- runtimeArgs[key] = parseUnparsed(token, options);
2530
- key = undefined;
2531
- continue;
2532
- } else {
2533
- return;
2534
- }
2535
- }
2536
- case "delim":
2537
- case "comma":
2538
- continue;
2539
- case "function":
2540
- case "at-keyword":
2541
- case "hash":
2542
- case "id-hash":
2543
- case "unquoted-url":
2544
- case "percentage":
2545
- case "dimension":
2546
- case "white-space":
2547
- case "comment":
2548
- case "colon":
2549
- case "semicolon":
2550
- case "include-match":
2551
- case "dash-match":
2552
- case "prefix-match":
2553
- case "suffix-match":
2554
- case "substring-match":
2555
- case "cdo":
2556
- case "cdc":
2557
- case "parenthesis-block":
2558
- case "square-bracket-block":
2559
- case "curly-bracket-block":
2560
- case "bad-url":
2561
- case "bad-string":
2562
- case "close-parenthesis":
2563
- case "close-square-bracket":
2564
- case "close-curly-bracket":
2565
- return undefined;
2566
- }
2567
- }
2568
- }
2093
+ if (value.type === "normal") {
2094
+ return;
2095
+ } else {
2096
+ return parseLength(value.value, builder);
2569
2097
  }
2570
-
2571
- return [{}, name, Object.entries(runtimeArgs)];
2572
2098
  }
2573
2099
 
2574
- function parseTextAlign(textAlign: TextAlign, options: ParserOptions) {
2100
+ export function parseTextAlign(
2101
+ { value }: DeclarationType<"text-align">,
2102
+ builder: StylesheetBuilder,
2103
+ ) {
2575
2104
  const allowed = new Set(["auto", "left", "right", "center", "justify"]);
2576
- if (allowed.has(textAlign)) {
2577
- return textAlign;
2105
+ if (allowed.has(value)) {
2106
+ return value;
2578
2107
  }
2579
2108
 
2580
- options.addWarning("value", textAlign);
2109
+ builder.addWarning("value", value);
2581
2110
  return undefined;
2582
2111
  }
2583
2112
 
2584
- function parseBoxShadow(boxShadows: BoxShadow[], options: ParserOptions) {
2585
- if (boxShadows.length > 1) {
2586
- options.addWarning("value", "multiple box shadows");
2587
- return;
2588
- }
2589
-
2590
- const boxShadow = boxShadows[0];
2591
-
2592
- if (!boxShadow) {
2593
- return;
2113
+ export function parseBoxShadow(
2114
+ { value }: DeclarationType<"box-shadow">,
2115
+ builder: StylesheetBuilder,
2116
+ ) {
2117
+ for (const [index, shadow] of value.entries()) {
2118
+ builder.addDescriptor(
2119
+ `boxShadow.[${index}].color`,
2120
+ parseColor(shadow.color, builder),
2121
+ );
2122
+ builder.addDescriptor(
2123
+ `boxShadow.[${index}].offsetX`,
2124
+ parseLength(shadow.xOffset, builder),
2125
+ );
2126
+ builder.addDescriptor(
2127
+ `boxShadow.[${index}].offsetY`,
2128
+ parseLength(shadow.yOffset, builder),
2129
+ );
2130
+ builder.addDescriptor(
2131
+ `boxShadow.[${index}].blurRadius`,
2132
+ parseLength(shadow.blur, builder),
2133
+ );
2134
+ builder.addDescriptor(
2135
+ `boxShadow.[${index}].spreadDistance`,
2136
+ parseLength(shadow.spread, builder),
2137
+ );
2138
+ builder.addDescriptor(
2139
+ `boxShadow.[${index}].inset`,
2140
+ shadow.inset ? true : undefined,
2141
+ );
2594
2142
  }
2595
-
2596
- options.add("style", "shadowColor", parseColor(boxShadow.color, options));
2597
- options.add("style", "shadowRadius", parseLength(boxShadow.spread, options));
2598
- // options.add("style",
2599
- // ["shadowOffsetWidth"],
2600
- // parseLength(boxShadow.xOffset, options, ["", ""),
2601
- // );
2602
- // options.add("style",
2603
- // ["shadowOffset", "height"],
2604
- // parseLength(boxShadow.yOffset, options),
2605
- // );
2606
2143
  }
2607
2144
 
2608
- function parseDisplay(display: Display, options: ParserOptions) {
2609
- if (display.type === "keyword") {
2610
- if (display.value === "none") {
2611
- return display.value;
2145
+ export function parseDisplay(
2146
+ { value }: DeclarationType<"display">,
2147
+ builder: StylesheetBuilder,
2148
+ ) {
2149
+ if (value.type === "keyword") {
2150
+ if (value.value === "none") {
2151
+ return value.value;
2612
2152
  } else {
2613
- return options.addWarning("value", display.value);
2153
+ builder.addWarning("value", value.value);
2154
+ return;
2614
2155
  }
2615
- } else if (display.type === "pair") {
2616
- if (display.outside === "block") {
2617
- switch (display.inside.type) {
2156
+ } else {
2157
+ if (value.outside === "block") {
2158
+ switch (value.inside.type) {
2618
2159
  case "flow":
2619
- if (display.isListItem) {
2620
- return options.addWarning("value", "list-item");
2160
+ if (value.isListItem) {
2161
+ builder.addWarning("value", "list-item");
2621
2162
  } else {
2622
- return options.addWarning("value", "block");
2163
+ builder.addWarning("value", "block");
2623
2164
  }
2165
+ return;
2166
+ case "flex":
2167
+ return value.inside.type;
2624
2168
  case "flow-root":
2625
- return options.addWarning("value", "flow-root");
2626
2169
  case "table":
2627
- return options.addWarning("value", display.inside.type);
2628
- case "flex":
2629
- return display.inside.type;
2630
2170
  case "box":
2631
2171
  case "grid":
2632
2172
  case "ruby":
2633
- return options.addWarning("value", display.inside.type);
2173
+ builder.addWarning("value", value.inside.type);
2174
+ return;
2634
2175
  }
2635
2176
  } else {
2636
- switch (display.inside.type) {
2177
+ switch (value.inside.type) {
2637
2178
  case "flow":
2638
- return options.addWarning("value", "inline");
2179
+ builder.addWarning("value", "inline");
2180
+ return;
2639
2181
  case "flow-root":
2640
- return options.addWarning("value", "inline-block");
2182
+ builder.addWarning("value", "inline-block");
2183
+ return;
2641
2184
  case "table":
2642
- return options.addWarning("value", "inline-table");
2185
+ builder.addWarning("value", "inline-table");
2186
+ return;
2643
2187
  case "flex":
2644
- return options.addWarning("value", "inline-flex");
2188
+ builder.addWarning("value", "inline-flex");
2189
+ return;
2645
2190
  case "box":
2646
2191
  case "grid":
2647
- return options.addWarning("value", "inline-grid");
2192
+ builder.addWarning("value", "inline-grid");
2193
+ return;
2648
2194
  case "ruby":
2649
- return options.addWarning("value", display.inside.type);
2195
+ builder.addWarning("value", value.inside.type);
2196
+ return;
2650
2197
  }
2651
2198
  }
2652
2199
  }
2653
-
2654
- return;
2655
2200
  }
2656
2201
 
2657
- function parseAspectRatio(
2658
- // This is missing types
2659
- aspectRatio: any,
2660
- ): StyleDescriptor {
2661
- if (aspectRatio.auto) {
2202
+ export function parseAspectRatio({
2203
+ value,
2204
+ }: DeclarationType<"aspect-ratio">): StyleDescriptor {
2205
+ if (!value.ratio) {
2206
+ return;
2207
+ } else if (value.auto) {
2662
2208
  return "auto";
2663
2209
  } else {
2664
- if (aspectRatio.ratio[0] === aspectRatio.ratio[1]) {
2210
+ const [width, height] = value.ratio;
2211
+ if (width === height) {
2665
2212
  return 1;
2666
2213
  } else {
2667
- return aspectRatio.ratio.join(" / ");
2214
+ return `${width}/${height}`;
2668
2215
  }
2669
2216
  }
2670
2217
  }
2671
2218
 
2672
- function parseDimension(
2219
+ export function parseDimension(
2673
2220
  { unit, value }: Extract<Token, { type: "dimension" }>,
2674
- options: ParserOptions,
2221
+ builder: StylesheetBuilder,
2675
2222
  ): StyleDescriptor {
2676
2223
  switch (unit) {
2677
2224
  case "px":
@@ -2682,52 +2229,60 @@ function parseDimension(
2682
2229
  case "rnw":
2683
2230
  return [{}, unit, [value / 100], 1];
2684
2231
  default: {
2685
- return options.addWarning("value", `${value}${unit}`);
2232
+ builder.addWarning("value", `${value}${unit}`);
2233
+ return;
2686
2234
  }
2687
2235
  }
2688
2236
  }
2689
2237
 
2690
- function parseUserSelect(value: UserSelect, options: ParserOptions) {
2238
+ export function parseUserSelect(
2239
+ { value }: DeclarationType<"user-select">,
2240
+ builder: StylesheetBuilder,
2241
+ ) {
2691
2242
  const allowed = ["auto", "text", "none", "contain", "all"];
2692
2243
  if (allowed.includes(value)) {
2693
2244
  return value;
2694
2245
  } else {
2695
- return options.addWarning("value", value);
2246
+ builder.addWarning("value", value);
2247
+ return;
2696
2248
  }
2697
2249
  }
2698
2250
 
2699
- function parseSVGPaint(value: SVGPaint, options: ParserOptions) {
2251
+ export function parseSVGPaint(
2252
+ { value }: DeclarationType<"fill" | "stroke">,
2253
+ builder: StylesheetBuilder,
2254
+ ) {
2700
2255
  if (value.type === "none") {
2701
2256
  return "transparent";
2702
2257
  } else if (value.type === "color") {
2703
- return parseColor(value.value, options);
2258
+ return parseColor(value.value, builder);
2704
2259
  }
2705
2260
 
2706
2261
  return;
2707
2262
  }
2708
2263
 
2709
- function round(number: number) {
2264
+ export function round(number: number) {
2710
2265
  return Math.round((number + Number.EPSILON) * 100) / 100;
2711
2266
  }
2712
2267
 
2713
- function parseDimensionPercentageFor_LengthValue(
2268
+ export function parseDimensionPercentageFor_LengthValue(
2714
2269
  value: DimensionPercentageFor_LengthValue,
2715
- options: ParserOptions,
2270
+ builder: StylesheetBuilder,
2716
2271
  ) {
2717
2272
  if (value.type === "calc") {
2718
2273
  return undefined;
2719
2274
  } else if (value.type === "percentage") {
2720
2275
  return `${value.value}%`;
2721
2276
  } else {
2722
- return parseLength(value.value, options);
2277
+ return parseLength(value.value, builder);
2723
2278
  }
2724
2279
  }
2725
2280
 
2726
2281
  const allowAuto = new Set(["pointer-events"]);
2727
2282
 
2728
- function parseEnv(
2283
+ export function parseEnv(
2729
2284
  value: EnvironmentVariable,
2730
- options: ParserOptions,
2285
+ builder: StylesheetBuilder,
2731
2286
  ): StyleFunction | undefined {
2732
2287
  switch (value.name.type) {
2733
2288
  case "ua":
@@ -2741,7 +2296,7 @@ function parseEnv(
2741
2296
  "var",
2742
2297
  [
2743
2298
  `--react-native-css-${value.name.value}`,
2744
- parseUnparsed(value.fallback, options),
2299
+ parseUnparsed(value.fallback, builder),
2745
2300
  ],
2746
2301
  1,
2747
2302
  ];
@@ -2763,9 +2318,9 @@ function parseEnv(
2763
2318
  export function parseCalcFn(
2764
2319
  name: string,
2765
2320
  tokens: TokenOrValue[],
2766
- options: ParserOptions,
2321
+ builder: StylesheetBuilder,
2767
2322
  ): StyleDescriptor {
2768
- const args = parseCalcArguments(tokens, options);
2323
+ const args = parseCalcArguments(tokens, builder);
2769
2324
  if (args) {
2770
2325
  return [{}, name, args];
2771
2326
  }
@@ -2773,7 +2328,10 @@ export function parseCalcFn(
2773
2328
  return;
2774
2329
  }
2775
2330
 
2776
- function parseCalcArguments([...args]: TokenOrValue[], options: ParserOptions) {
2331
+ export function parseCalcArguments(
2332
+ [...args]: TokenOrValue[],
2333
+ builder: StylesheetBuilder,
2334
+ ) {
2777
2335
  const parsed: StyleDescriptor[] = [];
2778
2336
 
2779
2337
  let mode: "number" | "percentage" | undefined;
@@ -2781,13 +2339,13 @@ function parseCalcArguments([...args]: TokenOrValue[], options: ParserOptions) {
2781
2339
  for (const [currentIndex, arg] of args.entries()) {
2782
2340
  switch (arg.type) {
2783
2341
  case "env": {
2784
- parsed.push(parseEnv(arg.value, options));
2342
+ parsed.push(parseEnv(arg.value, builder));
2785
2343
  break;
2786
2344
  }
2787
2345
  case "var":
2788
2346
  case "function":
2789
2347
  case "unresolved-color": {
2790
- const value = parseUnparsed(arg, options);
2348
+ const value = parseUnparsed(arg, builder);
2791
2349
 
2792
2350
  if (value === undefined) {
2793
2351
  return undefined;
@@ -2797,7 +2355,7 @@ function parseCalcArguments([...args]: TokenOrValue[], options: ParserOptions) {
2797
2355
  break;
2798
2356
  }
2799
2357
  case "length": {
2800
- const value = parseLength(arg.value, options);
2358
+ const value = parseLength(arg.value, builder);
2801
2359
 
2802
2360
  if (value !== undefined) {
2803
2361
  parsed.push(value);
@@ -2825,12 +2383,12 @@ function parseCalcArguments([...args]: TokenOrValue[], options: ParserOptions) {
2825
2383
  }
2826
2384
  break;
2827
2385
  case "percentage":
2828
- if (!mode) mode = "percentage";
2386
+ mode ??= "percentage";
2829
2387
  if (mode !== "percentage") return;
2830
2388
  parsed.push(`${arg.value.value * 100}%`);
2831
2389
  break;
2832
2390
  case "number": {
2833
- if (!mode) mode = "number";
2391
+ mode ??= "number";
2834
2392
  if (mode !== "number") return;
2835
2393
  parsed.push(arg.value.value);
2836
2394
  break;
@@ -2842,6 +2400,7 @@ function parseCalcArguments([...args]: TokenOrValue[], options: ParserOptions) {
2842
2400
  */
2843
2401
  let closeParenthesisIndex = -1;
2844
2402
  for (let index = args.length - 1; index > 0; index--) {
2403
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2845
2404
  const value = args[index]!;
2846
2405
  if (
2847
2406
  value.type === "token" &&
@@ -2862,7 +2421,7 @@ function parseCalcArguments([...args]: TokenOrValue[], options: ParserOptions) {
2862
2421
  // Then drop the surrounding parenthesis
2863
2422
  .slice(1, -1);
2864
2423
 
2865
- parsed.push(parseCalcFn("calc", innerCalcArgs, options));
2424
+ parsed.push(parseCalcFn("calc", innerCalcArgs, builder));
2866
2425
 
2867
2426
  break;
2868
2427
  }
@@ -2900,33 +2459,21 @@ function parseCalcArguments([...args]: TokenOrValue[], options: ParserOptions) {
2900
2459
  return parsed;
2901
2460
  }
2902
2461
 
2903
- export function parseTranslate(
2904
- translate: Translate,
2462
+ export function parseTranslateProp(
2463
+ value: Translate,
2905
2464
  prop: keyof Extract<Translate, object>,
2906
- options: ParserOptions,
2907
- ): StyleDescriptor {
2908
- if (translate === "none") {
2909
- return 0;
2910
- }
2911
-
2912
- return parseLength(translate[prop], options);
2913
- }
2914
-
2915
- export function parseScale(
2916
- translate: Scale,
2917
- prop: keyof Extract<Scale, object>,
2918
- options: ParserOptions,
2465
+ builder: StylesheetBuilder,
2919
2466
  ): StyleDescriptor {
2920
- if (translate === "none") {
2467
+ if (value === "none") {
2921
2468
  return 0;
2922
2469
  }
2923
2470
 
2924
- return parseLength(translate[prop], options);
2471
+ return parseLength(value[prop], builder);
2925
2472
  }
2926
2473
 
2927
2474
  export function parseUnresolvedColor(
2928
2475
  color: UnresolvedColor,
2929
- options: ParserOptions,
2476
+ builder: StylesheetBuilder,
2930
2477
  ): StyleDescriptor {
2931
2478
  switch (color.type) {
2932
2479
  case "rgb":
@@ -2937,17 +2484,27 @@ export function parseUnresolvedColor(
2937
2484
  round(color.r * 255),
2938
2485
  round(color.g * 255),
2939
2486
  round(color.b * 255),
2940
- parseUnparsed(color.alpha, options),
2487
+ parseUnparsed(color.alpha, builder),
2941
2488
  ],
2942
2489
  ];
2943
2490
  case "hsl":
2944
2491
  return [
2945
2492
  {},
2946
2493
  color.type,
2947
- [color.h, color.s, color.l, parseUnparsed(color.alpha, options)],
2494
+ [color.h, color.s, color.l, parseUnparsed(color.alpha, builder)],
2948
2495
  ];
2949
- case "light-dark":
2950
- return undefined;
2496
+ case "light-dark": {
2497
+ const extraRule = builder.extendRule({
2498
+ m: [["=", "prefers-color-scheme", "dark"]],
2499
+ });
2500
+ builder.addUnnamedDescriptor(
2501
+ reduceParseUnparsed(color.dark, builder),
2502
+ false,
2503
+ extraRule,
2504
+ );
2505
+ builder.addExtraRule(extraRule);
2506
+ return reduceParseUnparsed(color.light, builder);
2507
+ }
2951
2508
  default:
2952
2509
  color satisfies never;
2953
2510
  }
@@ -2955,12 +2512,12 @@ export function parseUnresolvedColor(
2955
2512
  return;
2956
2513
  }
2957
2514
 
2958
- function allEqual(...params: unknown[]) {
2515
+ export function allEqual(...params: unknown[]) {
2959
2516
  return params.every((param, index, array) => {
2960
2517
  return index === 0 ? true : equal(array[0], param);
2961
2518
  });
2962
2519
  }
2963
- function equal(a: unknown, b: unknown) {
2520
+ export function equal(a: unknown, b: unknown) {
2964
2521
  if (a === b) return true;
2965
2522
  if (typeof a !== typeof b) return false;
2966
2523
  if (a === null || b === null) return false;
@@ -2988,20 +2545,34 @@ function equal(a: unknown, b: unknown) {
2988
2545
  return false;
2989
2546
  }
2990
2547
 
2991
- function parseTime(time: Time) {
2548
+ export function parseTime(time: Time) {
2992
2549
  return time.type === "milliseconds" ? time.value : time.value * 1000;
2993
2550
  }
2994
2551
 
2995
- function addTransitionValue(
2552
+ export function parseSize2DDimensionPercentageDeclaration(
2553
+ declaration: { value: Size2DFor_DimensionPercentageFor_LengthValue },
2554
+ builder: StylesheetBuilder,
2555
+ ) {
2556
+ return parseSize2DDimensionPercentage(declaration.value, builder);
2557
+ }
2558
+
2559
+ export function parseSize2DDimensionPercentage(
2560
+ value: Size2DFor_DimensionPercentageFor_LengthValue,
2561
+ builder: StylesheetBuilder,
2562
+ ) {
2563
+ return parseLength(value[0], builder);
2564
+ }
2565
+
2566
+ export function addTransitionValue(
2996
2567
  declaration: Extract<
2997
2568
  Declaration,
2998
2569
  { property: `transition${string}` | "transition" }
2999
2570
  >,
3000
- options: ParserOptions,
2571
+ builder: StylesheetBuilder,
3001
2572
  ) {
3002
2573
  switch (declaration.property) {
3003
- case "transition":
3004
- const grouped: Record<string, any[]> = {};
2574
+ case "transition": {
2575
+ const grouped: Record<string, unknown[]> = {};
3005
2576
 
3006
2577
  for (const animation of declaration.value) {
3007
2578
  for (const [key, value] of Object.entries(animation)) {
@@ -3015,49 +2586,56 @@ function addTransitionValue(
3015
2586
  {
3016
2587
  property: `transition-${kebabCase(property)}`,
3017
2588
  value,
3018
- } as any,
3019
- options,
2589
+ } as Extract<
2590
+ Declaration,
2591
+ { property: `transition${string}` | "transition" }
2592
+ >,
2593
+ builder,
3020
2594
  );
3021
2595
  }
3022
2596
  break;
2597
+ }
3023
2598
  case "transition-property": {
3024
- return options.add(
3025
- "transition",
2599
+ builder.addDescriptor(
3026
2600
  declaration.property,
3027
- declaration.value.map((v) => v.property),
2601
+ declaration.value
2602
+ .map((v) => v.property)
2603
+ .filter((v) => v in parsers || v === "all" || v === "none")
2604
+ .map((v) => toRNProperty(v)),
3028
2605
  );
2606
+ return;
3029
2607
  }
3030
2608
  case "transition-duration":
3031
- return options.add(
3032
- "transition",
2609
+ builder.addDescriptor(
3033
2610
  declaration.property,
3034
2611
  declaration.value.map((t) => parseTime(t)),
3035
2612
  );
2613
+ return;
3036
2614
  case "transition-delay":
3037
- return options.add(
3038
- "transition",
2615
+ builder.addDescriptor(
3039
2616
  declaration.property,
3040
2617
  declaration.value.map((t) => parseTime(t)),
3041
2618
  );
2619
+ return;
3042
2620
  case "transition-timing-function":
3043
- return options.add(
3044
- "transition",
2621
+ builder.addDescriptor(
3045
2622
  declaration.property,
3046
- parseEasingFunction(declaration.value) as any,
2623
+ parseEasingFunction(declaration.value),
3047
2624
  );
2625
+ return;
3048
2626
  }
3049
2627
  }
3050
2628
 
3051
- function addAnimationValue(
2629
+ export function addAnimationValue(
3052
2630
  declaration: Extract<
3053
2631
  Declaration,
3054
2632
  { property: `animation${string}` | "animation" }
3055
2633
  >,
3056
- options: ParserOptions,
2634
+ builder: StylesheetBuilder,
3057
2635
  ) {
3058
2636
  switch (declaration.property) {
3059
2637
  case "animation": {
3060
- const grouped: Record<string, any[]> = {};
2638
+ const grouped: Record<string, unknown[]> = {};
3061
2639
 
3062
2640
  for (const animation of declaration.value) {
3063
2641
  for (const [key, value] of Object.entries(animation)) {
@@ -3071,47 +2649,46 @@ function addAnimationValue(
3071
2649
  {
3072
2650
  property: `animation-${kebabCase(property)}`,
3073
2651
  value,
3074
- } as any,
3075
- options,
2652
+ } as Extract<
2653
+ Declaration,
2654
+ { property: `animation${string}` | "animation" }
2655
+ >,
2656
+ builder,
3076
2657
  );
3077
2658
  }
3078
2659
  break;
3079
2660
  }
3080
2661
  case "animation-delay": {
3081
- options.add(
3082
- "animation",
2662
+ builder.addDescriptor(
3083
2663
  declaration.property,
3084
2664
  declaration.value.map((t) => parseTime(t)),
3085
2665
  );
3086
2666
  break;
3087
2667
  }
3088
2668
  case "animation-direction": {
3089
- options.add("animation", declaration.property, declaration.value);
2669
+ builder.addDescriptor(declaration.property, declaration.value);
3090
2670
  break;
3091
2671
  }
3092
2672
  case "animation-duration": {
3093
- options.add(
3094
- "animation",
2673
+ builder.addDescriptor(
3095
2674
  declaration.property,
3096
2675
  declaration.value.map((t) => parseTime(t)),
3097
2676
  );
3098
2677
  break;
3099
2678
  }
3100
2679
  case "animation-fill-mode": {
3101
- options.add("animation", declaration.property, declaration.value);
2680
+ builder.addDescriptor(declaration.property, declaration.value);
3102
2681
  break;
3103
2682
  }
3104
2683
  case "animation-iteration-count": {
3105
- options.add(
3106
- "animation",
2684
+ builder.addDescriptor(
3107
2685
  declaration.property,
3108
2686
  parseIterationCount(declaration.value),
3109
2687
  );
3110
2688
  break;
3111
2689
  }
3112
2690
  case "animation-name": {
3113
- options.add(
3114
- "animation",
2691
+ builder.addDescriptor(
3115
2692
  declaration.property,
3116
2693
  declaration.value.map((v) =>
3117
2694
  v.type === "none"
@@ -3122,25 +2699,284 @@ function addAnimationValue(
3122
2699
  break;
3123
2700
  }
3124
2701
  case "animation-play-state": {
3125
- options.add("animation", declaration.property, declaration.value);
2702
+ builder.addDescriptor(declaration.property, declaration.value);
3126
2703
  break;
3127
2704
  }
3128
2705
  case "animation-timing-function": {
3129
- options.add(
3130
- "animation",
2706
+ builder.addDescriptor(
3131
2707
  declaration.property,
3132
- parseEasingFunction(declaration.value) as any,
2708
+ parseEasingFunction(declaration.value),
3133
2709
  );
3134
2710
  break;
3135
2711
  }
3136
2712
  }
3137
2713
  }
3138
2714
 
3139
- function kebabCase(str: string) {
2715
+ export function kebabCase(str: string) {
3140
2716
  return str.replace(
3141
2717
  /[A-Z]+(?![a-z])|[A-Z]/g,
3142
2718
  ($, ofs) => (ofs ? "-" : "") + $.toLowerCase(),
3143
2719
  );
3144
2720
  }
3145
2721
 
3146
- const runtimeShorthands = new Set(["animation", "text-shadow", "transform"]);
2722
+ function parseBackgroundImage(
2723
+ declaration: DeclarationType<"background-image">,
2724
+ builder: StylesheetBuilder,
2725
+ ) {
2726
+ builder.addDescriptor(
2727
+ "experimental_backgroundImage",
2728
+ declaration.value.flatMap((image): StyleDescriptor[] => {
2729
+ switch (image.type) {
2730
+ case "gradient": {
2731
+ const gradient = parseGradient(image.value, builder);
2732
+ return gradient ? [gradient] : [];
2733
+ }
2734
+ case "none":
2735
+ return ["none"];
2736
+ }
2737
+
2738
+ return [];
2739
+ }),
2740
+ );
2741
+ return;
2742
+ }
2743
+
2744
+ function parseGradient(
2745
+ gradient: Gradient,
2746
+ builder: StylesheetBuilder,
2747
+ ): StyleDescriptor {
2748
+ switch (gradient.type) {
2749
+ case "linear": {
2750
+ return [
2751
+ {},
2752
+ "@linear-gradient",
2753
+ [
2754
+ parseLineDirection(gradient.direction, builder),
2755
+ ...gradient.items.map((item) => parseGradientItem(item, builder)),
2756
+ ],
2757
+ ];
2758
+ }
2759
+ }
2760
+
2761
+ return;
2762
+ }
2763
+
2764
+ function parseLineDirection(
2765
+ lineDirection: LineDirection,
2766
+ builder: StylesheetBuilder,
2767
+ ): StyleDescriptor {
2768
+ switch (lineDirection.type) {
2769
+ case "corner":
2770
+ return `to ${lineDirection.horizontal} ${lineDirection.vertical}`;
2771
+ case "horizontal":
2772
+ case "vertical":
2773
+ return `to ${lineDirection.value}`;
2774
+ case "angle":
2775
+ return parseAngle(lineDirection.value, builder);
2776
+ default: {
2777
+ lineDirection satisfies never;
2778
+ }
2779
+ }
2780
+
2781
+ return;
2782
+ }
2783
+
2784
+ function parseGradientItem(
2785
+ item: GradientItemFor_DimensionPercentageFor_LengthValue,
2786
+ builder: StylesheetBuilder,
2787
+ ): StyleDescriptor {
2788
+ switch (item.type) {
2789
+ case "color-stop": {
2790
+ const args: StyleDescriptor[] = [parseColor(item.color, builder)];
2791
+ if (item.position) {
2792
+ args.push(parseLength(item.position, builder));
2793
+ }
2794
+
2795
+ return [{}, "@colorStop", args, 1];
2796
+ }
2797
+ case "hint":
2798
+ return parseLength(item.value, builder);
2799
+ }
2800
+ }
2801
+
2802
+ function parseFilter(
2803
+ declaration: DeclarationType<"filter">,
2804
+ builder: StylesheetBuilder,
2805
+ ) {
2806
+ if (declaration.value.type === "none") {
2807
+ return "unset";
2808
+ }
2809
+
2810
+ return declaration.value.value
2811
+ .map((value) => {
2812
+ switch (value.type) {
2813
+ case "opacity":
2814
+ case "blur":
2815
+ case "brightness":
2816
+ case "contrast":
2817
+ case "grayscale":
2818
+ case "invert":
2819
+ case "saturate":
2820
+ case "sepia":
2821
+ return {
2822
+ [value.type]: parseLength(value.value, builder),
2823
+ } as unknown as StyleDescriptor;
2824
+ case "hue-rotate":
2825
+ return {
2826
+ [value.type]: parseAngle(value.value, builder),
2827
+ } as unknown as StyleDescriptor;
2828
+ case "drop-shadow":
2829
+ case "url":
2830
+ return;
2831
+ }
2832
+ })
2833
+ .filter((value) => value !== undefined);
2834
+ }
2835
+
2836
+ const namedColors = new Set([
2837
+ "aliceblue",
2838
+ "antiquewhite",
2839
+ "aqua",
2840
+ "aquamarine",
2841
+ "azure",
2842
+ "beige",
2843
+ "bisque",
2844
+ "black",
2845
+ "blanchedalmond",
2846
+ "blue",
2847
+ "blueviolet",
2848
+ "brown",
2849
+ "burlywood",
2850
+ "cadetblue",
2851
+ "chartreuse",
2852
+ "chocolate",
2853
+ "coral",
2854
+ "cornflowerblue",
2855
+ "cornsilk",
2856
+ "crimson",
2857
+ "cyan",
2858
+ "darkblue",
2859
+ "darkcyan",
2860
+ "darkgoldenrod",
2861
+ "darkgray",
2862
+ "darkgreen",
2863
+ "darkgrey",
2864
+ "darkkhaki",
2865
+ "darkmagenta",
2866
+ "darkolivegreen",
2867
+ "darkorange",
2868
+ "darkorchid",
2869
+ "darkred",
2870
+ "darksalmon",
2871
+ "darkseagreen",
2872
+ "darkslateblue",
2873
+ "darkslategrey",
2874
+ "darkturquoise",
2875
+ "darkviolet",
2876
+ "deeppink",
2877
+ "deepskyblue",
2878
+ "dimgray",
2879
+ "dimgrey",
2880
+ "dodgerblue",
2881
+ "firebrick",
2882
+ "floralwhite",
2883
+ "forestgreen",
2884
+ "fuchsia",
2885
+ "gainsboro",
2886
+ "ghostwhite",
2887
+ "gold",
2888
+ "goldenrod",
2889
+ "gray",
2890
+ "green",
2891
+ "greenyellow",
2892
+ "grey",
2893
+ "honeydew",
2894
+ "hotpink",
2895
+ "indianred",
2896
+ "indigo",
2897
+ "ivory",
2898
+ "khaki",
2899
+ "lavender",
2900
+ "lavenderblush",
2901
+ "lawngreen",
2902
+ "lemonchiffon",
2903
+ "lightblue",
2904
+ "lightcoral",
2905
+ "lightcyan",
2906
+ "lightgoldenrodyellow",
2907
+ "lightgray",
2908
+ "lightgreen",
2909
+ "lightgrey",
2910
+ "lightpink",
2911
+ "lightsalmon",
2912
+ "lightseagreen",
2913
+ "lightskyblue",
2914
+ "lightslategrey",
2915
+ "lightsteelblue",
2916
+ "lightyellow",
2917
+ "lime",
2918
+ "limegreen",
2919
+ "linen",
2920
+ "magenta",
2921
+ "maroon",
2922
+ "mediumaquamarine",
2923
+ "mediumblue",
2924
+ "mediumorchid",
2925
+ "mediumpurple",
2926
+ "mediumseagreen",
2927
+ "mediumslateblue",
2928
+ "mediumspringgreen",
2929
+ "mediumturquoise",
2930
+ "mediumvioletred",
2931
+ "midnightblue",
2932
+ "mintcream",
2933
+ "mistyrose",
2934
+ "moccasin",
2935
+ "navajowhite",
2936
+ "navy",
2937
+ "oldlace",
2938
+ "olive",
2939
+ "olivedrab",
2940
+ "orange",
2941
+ "orangered",
2942
+ "orchid",
2943
+ "palegoldenrod",
2944
+ "palegreen",
2945
+ "paleturquoise",
2946
+ "palevioletred",
2947
+ "papayawhip",
2948
+ "peachpuff",
2949
+ "peru",
2950
+ "pink",
2951
+ "plum",
2952
+ "powderblue",
2953
+ "purple",
2954
+ "rebeccapurple",
2955
+ "red",
2956
+ "rosybrown",
2957
+ "royalblue",
2958
+ "saddlebrown",
2959
+ "salmon",
2960
+ "sandybrown",
2961
+ "seagreen",
2962
+ "seashell",
2963
+ "sienna",
2964
+ "silver",
2965
+ "skyblue",
2966
+ "slateblue",
2967
+ "slategray",
2968
+ "snow",
2969
+ "springgreen",
2970
+ "steelblue",
2971
+ "tan",
2972
+ "teal",
2973
+ "thistle",
2974
+ "tomato",
2975
+ "turquoise",
2976
+ "violet",
2977
+ "wheat",
2978
+ "white",
2979
+ "whitesmoke",
2980
+ "yellow",
2981
+ "yellowgreen",
2982
+ ]);