react-native-css 3.0.0-nightly.4723140 → 3.0.0-nightly.61014be

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