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,21 +1,189 @@
1
1
  "use strict";
2
2
 
3
- /* eslint-disable */
4
3
  // cSpell:ignore rcap,vmin,svmin,lvmin,dvmin,cqmin,vmax,svmax,lvmax,dvmax,cqmax,currentcolor,oklab,oklch,prophoto
5
4
 
6
- import { emVariableName } from "../runtime/native/styles/constants.js";
7
- import { isStyleDescriptorArray } from "../runtime/utils/style-value.js";
5
+ import Color from "colorjs.io";
8
6
  import { parseEasingFunction, parseIterationCount } from "./keyframes.js";
9
7
  import { toRNProperty } from "./selectors.js";
8
+ const CommaSeparator = Symbol("CommaSeparator");
10
9
  const propertyRename = {
11
- "margin-inline-start": "margin-start",
12
- "margin-inline-end": "margin-end",
13
- "padding-inline-start": "padding-start",
14
- "padding-inline-end": "padding-end"
10
+ "background-image": "experimental_backgroundImage"
15
11
  };
16
- const validProperties = ["align-content", "align-items", "align-self", "animation", "animation-delay", "animation-direction", "animation-duration", "animation-fill-mode", "animation-iteration-count", "animation-name", "animation-play-state", "animation-timing-function", "aspect-ratio", "background-color", "block-size", "border", "border-block", "border-block-color", "border-block-end", "border-block-end-color", "border-block-end-width", "border-block-start", "border-block-start-color", "border-block-start-width", "border-block-width", "border-bottom", "border-bottom-color", "border-bottom-left-radius", "border-bottom-right-radius", "border-bottom-width", "border-color", "border-end-end-radius", "border-end-start-radius", "border-inline", "border-inline-color", "border-inline-end", "border-inline-end-color", "border-inline-end-width", "border-inline-start", "border-inline-start-color", "border-inline-start-width", "border-inline-width", "border-left", "border-left-color", "border-left-width", "border-radius", "border-right", "border-right-color", "border-right-width", "border-start-end-radius", "border-start-start-radius", "border-style", "border-top", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-top-width", "border-width", "bottom", "box-shadow", "caret-color", "color", "column-gap", "container", "container-name", "container-type", "display", "fill", "flex", "flex-basis", "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap", "font", "font-family", "font-size", "font-style", "font-variant-caps", "font-weight", "gap", "height", "inline-size", "inset", "inset-block", "inset-block-end", "inset-block-start", "inset-inline", "inset-inline-end", "inset-inline-start", "justify-content", "left", "letter-spacing", "line-height", "margin", "margin-block", "margin-block-end", "margin-block-start", "margin-bottom", "margin-inline", "margin-inline-end", "margin-inline-start", "margin-left", "margin-right", "margin-top", "max-block-size", "max-height", "max-inline-size", "max-width", "min-block-size", "min-height", "min-inline-size", "min-width", "opacity", "overflow", "padding", "padding-block", "padding-block-end", "padding-block-start", "padding-bottom", "padding-inline", "padding-inline-end", "padding-inline-start", "padding-left", "padding-right", "padding-top", "pointer-events", "position", "right", "rotate", "row-gap", "scale", "stroke", "stroke-width", "text-align", "text-decoration", "text-decoration-color", "text-decoration-line", "text-decoration-style", "text-shadow", "text-transform", "top", "transform", "transition", "transition-delay", "transition-duration", "transition-property", "transition-timing-function", "translate", "user-select", "vertical-align", "width", "z-index"];
17
- const validPropertiesLoose = new Set(validProperties);
18
- export function parseDeclaration(declaration, options, add, addWarning) {
12
+ const unparsedRuntimeParsing = new Set(["animation", "text-shadow", "transform", "box-shadow", "border"]);
13
+ const parsers = {
14
+ "align-content": parseAlignContent,
15
+ "align-items": parseAlignItems,
16
+ "align-self": parseAlignSelf,
17
+ "animation": addAnimationValue,
18
+ "animation-delay": addAnimationValue,
19
+ "animation-direction": addAnimationValue,
20
+ "animation-duration": addAnimationValue,
21
+ "animation-fill-mode": addAnimationValue,
22
+ "animation-iteration-count": addAnimationValue,
23
+ "animation-name": addAnimationValue,
24
+ "animation-play-state": addAnimationValue,
25
+ "animation-timing-function": addAnimationValue,
26
+ "aspect-ratio": parseAspectRatio,
27
+ "background-color": parseColorDeclaration,
28
+ "background-image": parseBackgroundImage,
29
+ "block-size": parseSizeDeclaration,
30
+ "border": parseBorder,
31
+ "border-block": parseBorderBlock,
32
+ "border-block-color": parseBorderBlockColor,
33
+ "border-block-end": parseBorderBlockEnd,
34
+ "border-block-end-color": parseColorDeclaration,
35
+ "border-block-end-width": parseBorderSideWidthDeclaration,
36
+ "border-block-start": parseBorderBlockStart,
37
+ "border-block-start-color": parseColorDeclaration,
38
+ "border-block-start-width": parseBorderSideWidthDeclaration,
39
+ "border-block-width": parseBorderBlockWidth,
40
+ "border-bottom": parseBorderSide,
41
+ "border-bottom-color": parseColorDeclaration,
42
+ "border-bottom-left-radius": parseSize2DDimensionPercentageDeclaration,
43
+ "border-bottom-right-radius": parseSize2DDimensionPercentageDeclaration,
44
+ "border-bottom-width": parseBorderSideWidthDeclaration,
45
+ "border-color": parseBorderColor,
46
+ "border-end-end-radius": parseSize2DDimensionPercentageDeclaration,
47
+ "border-end-start-radius": parseSize2DDimensionPercentageDeclaration,
48
+ "border-inline": parseBorderInline,
49
+ "border-inline-color": parseBorderBlockColor,
50
+ "border-inline-end": parseBorderInlineEnd,
51
+ "border-inline-end-color": parseColorDeclaration,
52
+ "border-inline-end-width": parseBorderSideWidthDeclaration,
53
+ "border-inline-start": parseBorderInlineStart,
54
+ "border-inline-start-color": parseColorDeclaration,
55
+ "border-inline-start-width": parseBorderSideWidthDeclaration,
56
+ "border-inline-width": parseBorderBlockWidth,
57
+ "border-left": parseBorderSide,
58
+ "border-left-color": parseColorDeclaration,
59
+ "border-left-width": parseBorderSideWidthDeclaration,
60
+ "border-radius": parseBorderRadius,
61
+ "border-right": parseBorderSide,
62
+ "border-right-color": parseColorDeclaration,
63
+ "border-right-width": parseBorderSideWidthDeclaration,
64
+ "border-start-end-radius": parseSize2DDimensionPercentageDeclaration,
65
+ "border-start-start-radius": parseSize2DDimensionPercentageDeclaration,
66
+ "border-style": parseBorderStyleDeclaration,
67
+ "border-top": parseBorderSide,
68
+ "border-top-color": parseColorDeclaration,
69
+ "border-top-left-radius": parseSize2DDimensionPercentageDeclaration,
70
+ "border-top-right-radius": parseSize2DDimensionPercentageDeclaration,
71
+ "border-top-width": parseBorderSideWidthDeclaration,
72
+ "border-width": parseBorderWidth,
73
+ "bottom": parseSizeDeclaration,
74
+ "box-shadow": parseBoxShadow,
75
+ "caret-color": parseColorOrAuto,
76
+ "color": parseFontColorDeclaration,
77
+ "column-gap": parseGap,
78
+ "container": parseContainer,
79
+ "container-name": parseContainerName,
80
+ "container-type": parseContainerType,
81
+ "display": parseDisplay,
82
+ "fill": parseSVGPaint,
83
+ "filter": parseFilter,
84
+ "flex": parseFlex,
85
+ "flex-basis": parseLengthPercentageOrAutoDeclaration,
86
+ "flex-direction": ({
87
+ value
88
+ }) => value,
89
+ "flex-flow": parseFlexFlow,
90
+ "flex-grow": ({
91
+ value
92
+ }) => value,
93
+ "flex-shrink": ({
94
+ value
95
+ }) => value,
96
+ "flex-wrap": ({
97
+ value
98
+ }) => value,
99
+ "font": parseFont,
100
+ "font-family": parseFontFamily,
101
+ "font-size": parseFontSizeDeclaration,
102
+ "font-style": parseFontStyleDeclaration,
103
+ "font-variant-caps": parseFontVariantCapsDeclaration,
104
+ "font-weight": parseFontWeightDeclaration,
105
+ "gap": parseGap,
106
+ "height": parseSizeDeclaration,
107
+ "inline-size": parseSizeDeclaration,
108
+ "inset": parseInset,
109
+ "inset-block": parseInsetBlock,
110
+ "inset-block-end": parseLengthPercentageOrAutoDeclaration,
111
+ "inset-block-start": parseLengthPercentageOrAutoDeclaration,
112
+ "inset-inline": parseInsetInline,
113
+ "inset-inline-end": parseLengthPercentageOrAutoDeclaration,
114
+ "inset-inline-start": parseLengthPercentageOrAutoDeclaration,
115
+ "justify-content": parseJustifyContent,
116
+ "left": parseSizeDeclaration,
117
+ "letter-spacing": parseLetterSpacing,
118
+ "line-height": parseLineHeightDeclaration,
119
+ "margin": parseMargin,
120
+ "margin-block": parseMarginBlock,
121
+ "margin-block-end": parseLengthPercentageOrAutoDeclaration,
122
+ "margin-block-start": parseLengthPercentageOrAutoDeclaration,
123
+ "margin-bottom": parseSizeDeclaration,
124
+ "margin-inline": parseMarginInline,
125
+ "margin-inline-end": parseLengthPercentageOrAutoDeclaration,
126
+ "margin-inline-start": parseLengthPercentageOrAutoDeclaration,
127
+ "margin-left": parseSizeDeclaration,
128
+ "margin-right": parseSizeDeclaration,
129
+ "margin-top": parseSizeDeclaration,
130
+ "max-block-size": parseSizeDeclaration,
131
+ "max-height": parseSizeDeclaration,
132
+ "max-inline-size": parseSizeDeclaration,
133
+ "max-width": parseSizeDeclaration,
134
+ "min-block-size": parseSizeDeclaration,
135
+ "min-height": parseSizeDeclaration,
136
+ "min-inline-size": parseSizeDeclaration,
137
+ "min-width": parseSizeDeclaration,
138
+ "opacity": ({
139
+ value
140
+ }) => value,
141
+ "overflow": parseOverflow,
142
+ "padding": parsePadding,
143
+ "padding-block": parsePaddingBlock,
144
+ "padding-block-end": parseLengthPercentageOrAutoDeclaration,
145
+ "padding-block-start": parseLengthPercentageOrAutoDeclaration,
146
+ "padding-bottom": parseSizeDeclaration,
147
+ "padding-inline": parsePaddingInline,
148
+ "padding-inline-end": parseLengthPercentageOrAutoDeclaration,
149
+ "padding-inline-start": parseLengthPercentageOrAutoDeclaration,
150
+ "padding-left": parseSizeDeclaration,
151
+ "padding-right": parseSizeDeclaration,
152
+ "padding-top": parseSizeDeclaration,
153
+ "position": parsePosition,
154
+ "right": parseSizeDeclaration,
155
+ "rotate": parseRotate,
156
+ "row-gap": parseGap,
157
+ "scale": parseScale,
158
+ "stroke": parseSVGPaint,
159
+ "stroke-width": parseLengthDeclaration,
160
+ "text-align": parseTextAlign,
161
+ "text-decoration": parseTextDecoration,
162
+ "text-decoration-color": parseColorDeclaration,
163
+ "text-decoration-line": parseTextDecorationLineDeclaration,
164
+ "text-decoration-style": parseTextDecorationStyle,
165
+ "text-shadow": parseTextShadow,
166
+ "text-transform": ({
167
+ value
168
+ }) => value.case,
169
+ "top": parseSizeDeclaration,
170
+ "transform": parseTransform,
171
+ "transition": addTransitionValue,
172
+ "transition-delay": addTransitionValue,
173
+ "transition-duration": addTransitionValue,
174
+ "transition-property": addTransitionValue,
175
+ "transition-timing-function": addTransitionValue,
176
+ "translate": parseTranslate,
177
+ "user-select": parseUserSelect,
178
+ "vertical-align": parseVerticalAlign,
179
+ "width": parseSizeDeclaration,
180
+ "z-index": parseZIndex
181
+ };
182
+
183
+ // This is missing LightningCSS types
184
+ parsers["pointer-events"] = parsePointerEvents;
185
+ const validProperties = new Set(Object.keys(parsers));
186
+ export function parseDeclaration(declaration, builder) {
19
187
  if ("vendorPrefix" in declaration && declaration.vendorPrefix.length) {
20
188
  return;
21
189
  }
@@ -23,661 +191,417 @@ export function parseDeclaration(declaration, options, add, addWarning) {
23
191
  return;
24
192
  }
25
193
  if (declaration.property === "unparsed") {
26
- return parseDeclarationUnparsed(declaration, options, add, addWarning);
194
+ parseDeclarationUnparsed(declaration, builder);
27
195
  } else if (declaration.property === "custom") {
28
- return parseDeclarationCustom(declaration, options, add, addWarning);
29
- }
30
- if (!isValid(declaration)) {
31
- return addWarning("property", declaration.property);
196
+ parseDeclarationCustom(declaration, builder);
197
+ } else {
198
+ parseWithParser(declaration, builder);
32
199
  }
33
- const parseOptions = {
34
- ...options,
35
- add,
36
- addWarning(value) {
37
- return addWarning("value", declaration.property, value);
200
+ }
201
+ function parseWithParser(declaration, builder) {
202
+ if (declaration.property in parsers) {
203
+ const parser = parsers[declaration.property];
204
+ builder.descriptorProperty = declaration.property;
205
+ const value = parser(declaration, builder, declaration.property);
206
+ if (value !== undefined) {
207
+ builder.addDescriptor(propertyRename[declaration.property] ?? declaration.property, value);
38
208
  }
39
- };
40
- function handleStyleShorthand(name, options) {
41
- if (allEqual(...Object.values(options))) {
42
- return add("style", name, Object.values(options)[0]);
43
- } else {
44
- for (const [name, value] of Object.entries(options)) {
45
- add("style", name, value);
46
- }
209
+ } else {
210
+ builder.addWarning("property", declaration.property);
211
+ }
212
+ }
213
+ function parseInsetBlock({
214
+ value
215
+ }, builder) {
216
+ builder.addShorthand("inset-block", {
217
+ "inset-block-start": parseLengthPercentageOrAuto(value.blockStart, builder),
218
+ "inset-block-end": parseLengthPercentageOrAuto(value.blockEnd, builder)
219
+ });
220
+ }
221
+ function parseInsetInline({
222
+ value
223
+ }, builder) {
224
+ builder.addShorthand("inset-inline", {
225
+ "inset-block-start": parseLengthPercentageOrAuto(value.inlineStart, builder),
226
+ "inset-block-end": parseLengthPercentageOrAuto(value.inlineEnd, builder)
227
+ });
228
+ }
229
+ function parseInset({
230
+ value
231
+ }, builder) {
232
+ builder.addShorthand("inset", {
233
+ top: parseLengthPercentageOrAuto(value.top, builder),
234
+ bottom: parseLengthPercentageOrAuto(value.bottom, builder),
235
+ left: parseLengthPercentageOrAuto(value.left, builder),
236
+ right: parseLengthPercentageOrAuto(value.right, builder)
237
+ });
238
+ }
239
+ function parseBorderRadius({
240
+ value
241
+ }, builder) {
242
+ builder.addShorthand("border-radius", {
243
+ "border-bottom-left-radius": parseSize2DDimensionPercentage(value.bottomLeft, builder),
244
+ "border-bottom-right-radius": parseSize2DDimensionPercentage(value.bottomRight, builder),
245
+ "border-top-left-radius": parseSize2DDimensionPercentage(value.topLeft, builder),
246
+ "border-top-right-radius": parseSize2DDimensionPercentage(value.topRight, builder)
247
+ });
248
+ }
249
+ function parseBorderColor({
250
+ value
251
+ }, builder) {
252
+ builder.addShorthand("border-color", {
253
+ "border-top-color": parseColor(value.top, builder),
254
+ "border-bottom-color": parseColor(value.bottom, builder),
255
+ "border-left-color": parseColor(value.left, builder),
256
+ "border-right-color": parseColor(value.right, builder)
257
+ });
258
+ }
259
+ function parseBorderWidth({
260
+ value
261
+ }, builder) {
262
+ builder.addShorthand("border-width", {
263
+ "border-top-width": parseBorderSideWidth(value.top, builder),
264
+ "border-bottom-width": parseBorderSideWidth(value.bottom, builder),
265
+ "border-left-width": parseBorderSideWidth(value.left, builder),
266
+ "border-right-width": parseBorderSideWidth(value.right, builder)
267
+ });
268
+ }
269
+ function parseBorder({
270
+ value
271
+ }, builder) {
272
+ builder.addShorthand("border", {
273
+ "border-width": parseBorderSideWidth(value.width, builder),
274
+ "border-style": parseBorderStyle(value.style, builder),
275
+ "border-color": parseColor(value.color, builder)
276
+ });
277
+ }
278
+ function parseBorderSide({
279
+ value,
280
+ property
281
+ }, builder) {
282
+ builder.addDescriptor(property + "-color", parseColor(value.color, builder));
283
+ builder.addDescriptor(property + "-width", parseBorderSideWidth(value.width, builder));
284
+ }
285
+ function parseBorderBlock({
286
+ value
287
+ }, builder) {
288
+ builder.addDescriptor("border-top-color", parseColor(value.color, builder));
289
+ builder.addDescriptor("border-bottom-color", parseColor(value.color, builder));
290
+ builder.addDescriptor("border-top-width", parseBorderSideWidth(value.width, builder));
291
+ builder.addDescriptor("border-bottom-width", parseBorderSideWidth(value.width, builder));
292
+ }
293
+ function parseBorderBlockStart({
294
+ value
295
+ }, builder) {
296
+ builder.addDescriptor("border-top-color", parseColor(value.color, builder));
297
+ builder.addDescriptor("border-top-width", parseBorderSideWidth(value.width, builder));
298
+ }
299
+ function parseBorderBlockEnd({
300
+ value
301
+ }, builder) {
302
+ builder.addDescriptor("border-bottom-color", parseColor(value.color, builder));
303
+ builder.addDescriptor("border-bottom-width", parseBorderSideWidth(value.width, builder));
304
+ }
305
+ function parseBorderInline({
306
+ value
307
+ }, builder) {
308
+ builder.addDescriptor("border-left-color", parseColor(value.color, builder));
309
+ builder.addDescriptor("border-right-color", parseColor(value.color, builder));
310
+ builder.addDescriptor("border-left-width", parseBorderSideWidth(value.width, builder));
311
+ builder.addDescriptor("border-right-width", parseBorderSideWidth(value.width, builder));
312
+ }
313
+ function parseBorderInlineStart({
314
+ value
315
+ }, builder) {
316
+ builder.addDescriptor("border-left-color", parseColor(value.color, builder));
317
+ builder.addDescriptor("border-left-width", parseBorderSideWidth(value.width, builder));
318
+ }
319
+ function parseBorderInlineEnd({
320
+ value
321
+ }, builder) {
322
+ builder.addDescriptor("border-right-color", parseColor(value.color, builder));
323
+ builder.addDescriptor("border-right-width", parseBorderSideWidth(value.width, builder));
324
+ }
325
+ function parseFlexFlow({
326
+ value
327
+ }, builder) {
328
+ builder.addDescriptor("flexWrap", value.wrap);
329
+ builder.addDescriptor("flexDirection", value.direction);
330
+ }
331
+ function parseFlex({
332
+ value
333
+ }, builder) {
334
+ builder.addDescriptor("flex-grow", value.grow);
335
+ builder.addDescriptor("flex-shrink", value.shrink);
336
+ builder.addDescriptor("flex-basis", parseLengthPercentageOrAuto(value.basis, builder));
337
+ }
338
+ function parseMargin({
339
+ value
340
+ }, builder) {
341
+ builder.addShorthand("margin", {
342
+ "margin-top": parseSize(value.top, builder, {
343
+ allowAuto: true
344
+ }),
345
+ "margin-bottom": parseSize(value.bottom, builder, {
346
+ allowAuto: true
347
+ }),
348
+ "margin-left": parseSize(value.left, builder, {
349
+ allowAuto: true
350
+ }),
351
+ "margin-right": parseSize(value.right, builder, {
352
+ allowAuto: true
353
+ })
354
+ });
355
+ }
356
+ function parseMarginBlock({
357
+ value
358
+ }, builder) {
359
+ builder.addShorthand("margin-block", {
360
+ "margin-block-start": parseLengthPercentageOrAuto(value.blockStart, builder),
361
+ "margin-block-end": parseLengthPercentageOrAuto(value.blockEnd, builder)
362
+ });
363
+ }
364
+ function parseMarginInline({
365
+ value
366
+ }, builder) {
367
+ builder.addShorthand("margin-inline", {
368
+ "margin-inline-start": parseLengthPercentageOrAuto(value.inlineStart, builder),
369
+ "margin-inline-end": parseLengthPercentageOrAuto(value.inlineEnd, builder)
370
+ });
371
+ }
372
+ function parsePadding({
373
+ value
374
+ }, builder) {
375
+ builder.addShorthand("padding", {
376
+ "padding-top": parseSize(value.top, builder),
377
+ "padding-bottom": parseSize(value.bottom, builder),
378
+ "padding-left": parseSize(value.left, builder),
379
+ "padding-right": parseSize(value.right, builder)
380
+ });
381
+ }
382
+ function parsePaddingBlock({
383
+ value
384
+ }, builder) {
385
+ builder.addShorthand("padding-block", {
386
+ "padding-block-start": parseLengthPercentageOrAuto(value.blockStart, builder),
387
+ "padding-block-end": parseLengthPercentageOrAuto(value.blockEnd, builder)
388
+ });
389
+ }
390
+ function parsePaddingInline({
391
+ value
392
+ }, builder) {
393
+ builder.addShorthand("padding-inline", {
394
+ "padding-inline-start": parseLengthPercentageOrAuto(value.inlineStart, builder),
395
+ "padding-inline-end": parseLengthPercentageOrAuto(value.inlineEnd, builder)
396
+ });
397
+ }
398
+ function parseFont({
399
+ value
400
+ }, builder) {
401
+ builder.addDescriptor("font-family", value.family[0]);
402
+ builder.addDescriptor("line-height", parseLineHeight(value.lineHeight, builder));
403
+ builder.addDescriptor("font-size", parseFontSize(value.size, builder));
404
+ builder.addDescriptor("font-style", parseFontStyle(value.style, builder));
405
+ builder.addDescriptor("font-variant-caps", parseFontVariantCaps(value.variantCaps, builder));
406
+ builder.addDescriptor("font-weight", parseFontWeight(value.weight, builder));
407
+ }
408
+ function parseTransform({
409
+ value
410
+ }, builder) {
411
+ builder.addDescriptor("transform", [{}, "@transform", value.flatMap(t => {
412
+ switch (t.type) {
413
+ case "perspective":
414
+ return [[{}, "@perspective", parseLength(t.value, builder)]];
415
+ case "translate":
416
+ return [[{}, "@translateX", parseLengthOrCoercePercentageToRuntime(t.value[0], builder)], [[{}, "@translateY", parseLengthOrCoercePercentageToRuntime(t.value[1], builder)]]];
417
+ case "translateX":
418
+ return [[{}, "@translateX", parseLengthOrCoercePercentageToRuntime(t.value, builder)]];
419
+ case "translateY":
420
+ return [[{}, "@translateY", parseLengthOrCoercePercentageToRuntime(t.value, builder)]];
421
+ case "rotate":
422
+ return [[{}, "@rotate", parseAngle(t.value, builder)]];
423
+ case "rotateX":
424
+ return [[{}, "@rotateX", parseAngle(t.value, builder)]];
425
+ case "rotateY":
426
+ return [[{}, "@rotateY", parseAngle(t.value, builder)]];
427
+ case "rotateZ":
428
+ return [[{}, "@rotateZ", parseAngle(t.value, builder)]];
429
+ case "scale":
430
+ return [[{}, "@scaleX", parseLength(t.value[0], builder)], [{}, "@scaleY", parseLength(t.value[1], builder)]];
431
+ case "scaleX":
432
+ return [[{}, "scaleX", parseLength(t.value, builder)]];
433
+ case "scaleY":
434
+ return [[{}, "scaleY", parseLength(t.value, builder)]];
435
+ case "skew":
436
+ return [[{}, "skewX", parseAngle(t.value[0], builder)], [{}, "skewY", parseAngle(t.value[1], builder)]];
437
+ case "skewX":
438
+ return [[{}, "skewX", parseAngle(t.value, builder)]];
439
+ case "skewY":
440
+ return [[{}, "skewY", parseAngle(t.value, builder)]];
441
+ case "translateZ":
442
+ case "translate3d":
443
+ case "scaleZ":
444
+ case "scale3d":
445
+ case "rotate3d":
446
+ case "matrix":
447
+ case "matrix3d":
448
+ return [[]];
47
449
  }
450
+ })]);
451
+ return;
452
+ }
453
+ function parseTranslate({
454
+ value
455
+ }, builder) {
456
+ builder.addDescriptor("translateX", [{}, "translateX", parseTranslateProp(value, "x", builder)]);
457
+ builder.addDescriptor("translateY", [{}, "translateY", parseTranslateProp(value, "y", builder)]);
458
+ }
459
+ function parseRotate({
460
+ value
461
+ }, builder) {
462
+ builder.addDescriptor("rotateX", [{}, "rotateX", parseAngle(value.x, builder)]);
463
+ builder.addDescriptor("rotateY", [{}, "rotateY", parseAngle(value.y, builder)]);
464
+ builder.addDescriptor("rotateZ", [{}, "rotateZ", parseAngle(value.z, builder)]);
465
+ }
466
+ function parseScale({
467
+ value
468
+ }, builder) {
469
+ builder.addDescriptor("scaleX", [{}, "scaleX", parseScaleValue(value, "x", builder)]);
470
+ builder.addDescriptor("scaleY", [{}, "scaleY", parseScaleValue(value, "y", builder)]);
471
+ }
472
+ export function parseScaleValue(translate, prop, builder) {
473
+ if (translate === "none") {
474
+ return 0;
48
475
  }
49
- switch (declaration.property) {
50
- case "background-color":
51
- return add("style", declaration.property, parseColor(declaration.value, parseOptions));
52
- case "opacity":
53
- return add("style", declaration.property, declaration.value);
54
- case "color":
55
- return add("style", declaration.property, parseColor(declaration.value, parseOptions));
56
- case "display":
57
- return add("style", declaration.property, parseDisplay(declaration.value, parseOptions));
58
- case "width":
59
- return add("style", declaration.property, parseSize(declaration.value, parseOptions));
60
- case "height":
61
- return add("style", declaration.property, parseSize(declaration.value, parseOptions));
62
- case "min-width":
63
- return add("style", declaration.property, parseSize(declaration.value, parseOptions));
64
- case "min-height":
65
- return add("style", declaration.property, parseSize(declaration.value, parseOptions));
66
- case "max-width":
67
- return add("style", declaration.property, parseSize(declaration.value, parseOptions));
68
- case "max-height":
69
- return add("style", declaration.property, parseSize(declaration.value, parseOptions));
70
- case "block-size":
71
- return add("style", "width", parseSize(declaration.value, parseOptions));
72
- case "inline-size":
73
- return add("style", "height", parseSize(declaration.value, parseOptions));
74
- case "min-block-size":
75
- return add("style", "min-width", parseSize(declaration.value, parseOptions));
76
- case "min-inline-size":
77
- return add("style", "min-height", parseSize(declaration.value, parseOptions));
78
- case "max-block-size":
79
- return add("style", "max-width", parseSize(declaration.value, parseOptions));
80
- case "max-inline-size":
81
- return add("style", "max-height", parseSize(declaration.value, parseOptions));
82
- case "overflow":
83
- return add("style", declaration.property, parseOverflow(declaration.value.x, parseOptions));
84
- case "position":
85
- const value = declaration.value.type;
86
- if (value === "absolute" || value === "relative") {
87
- return add("style", declaration.property, value);
88
- } else {
89
- parseOptions.addWarning("value", value);
90
- }
91
- return;
92
- case "top":
93
- return add("style", declaration.property, parseSize(declaration.value, parseOptions));
94
- case "bottom":
95
- return add("style", declaration.property, parseSize(declaration.value, parseOptions));
96
- case "left":
97
- return add("style", declaration.property, parseSize(declaration.value, parseOptions));
98
- case "right":
99
- return add("style", declaration.property, parseSize(declaration.value, parseOptions));
100
- case "inset-block-start":
101
- return add("style", declaration.property, parseLengthPercentageOrAuto(declaration.value, parseOptions));
102
- case "inset-block-end":
103
- return add("style", declaration.property, parseLengthPercentageOrAuto(declaration.value, parseOptions));
104
- case "inset-inline-start":
105
- return add("style", declaration.property, parseLengthPercentageOrAuto(declaration.value, parseOptions));
106
- case "inset-inline-end":
107
- return add("style", declaration.property, parseLengthPercentageOrAuto(declaration.value, parseOptions));
108
- case "inset-block":
109
- return handleStyleShorthand("inset-block", {
110
- "inset-block-start": parseLengthPercentageOrAuto(declaration.value.blockStart, parseOptions),
111
- "inset-block-end": parseLengthPercentageOrAuto(declaration.value.blockEnd, parseOptions)
112
- });
113
- case "inset-inline":
114
- return handleStyleShorthand("inset-inline", {
115
- "inset-block-start": parseLengthPercentageOrAuto(declaration.value.inlineStart, parseOptions),
116
- "inset-block-end": parseLengthPercentageOrAuto(declaration.value.inlineEnd, parseOptions)
117
- });
118
- case "inset":
119
- handleStyleShorthand("inset", {
120
- top: parseLengthPercentageOrAuto(declaration.value.top, {
121
- ...parseOptions,
122
- addWarning: buildAddWarning(addWarning, "top")
123
- }),
124
- bottom: parseLengthPercentageOrAuto(declaration.value.bottom, {
125
- ...parseOptions,
126
- addWarning: buildAddWarning(addWarning, "bottom")
127
- }),
128
- left: parseLengthPercentageOrAuto(declaration.value.left, {
129
- ...parseOptions,
130
- addWarning: buildAddWarning(addWarning, "left")
131
- }),
132
- right: parseLengthPercentageOrAuto(declaration.value.right, {
133
- ...parseOptions,
134
- addWarning: buildAddWarning(addWarning, "right")
135
- })
136
- });
137
- return;
138
- case "border-top-color":
139
- return add("style", declaration.property, parseColor(declaration.value, parseOptions));
140
- case "border-bottom-color":
141
- return add("style", declaration.property, parseColor(declaration.value, parseOptions));
142
- case "border-left-color":
143
- return add("style", declaration.property, parseColor(declaration.value, parseOptions));
144
- case "border-right-color":
145
- return add("style", declaration.property, parseColor(declaration.value, parseOptions));
146
- case "border-block-start-color":
147
- return add("style", "border-top-color", parseColor(declaration.value, parseOptions));
148
- case "border-block-end-color":
149
- return add("style", "border-bottom-color", parseColor(declaration.value, parseOptions));
150
- case "border-inline-start-color":
151
- return add("style", "border-left-color", parseColor(declaration.value, parseOptions));
152
- case "border-inline-end-color":
153
- return add("style", "border-right-color", parseColor(declaration.value, parseOptions));
154
- case "border-top-width":
155
- return add("style", declaration.property, parseBorderSideWidth(declaration.value, parseOptions));
156
- case "border-bottom-width":
157
- return add("style", declaration.property, parseBorderSideWidth(declaration.value, parseOptions));
158
- case "border-left-width":
159
- return add("style", declaration.property, parseBorderSideWidth(declaration.value, parseOptions));
160
- case "border-right-width":
161
- return add("style", declaration.property, parseBorderSideWidth(declaration.value, parseOptions));
162
- case "border-block-start-width":
163
- return add("style", "border-top-width", parseBorderSideWidth(declaration.value, parseOptions));
164
- case "border-block-end-width":
165
- return add("style", "border-bottom-width", parseBorderSideWidth(declaration.value, parseOptions));
166
- case "border-inline-start-width":
167
- return add("style", "border-left-width", parseBorderSideWidth(declaration.value, parseOptions));
168
- case "border-inline-end-width":
169
- return add("style", "border-right-width", parseBorderSideWidth(declaration.value, parseOptions));
170
- case "border-top-left-radius":
171
- return add("style", declaration.property, parseLength(declaration.value[0], parseOptions));
172
- case "border-top-right-radius":
173
- return add("style", declaration.property, parseLength(declaration.value[0], parseOptions));
174
- case "border-bottom-left-radius":
175
- return add("style", declaration.property, parseLength(declaration.value[0], parseOptions));
176
- case "border-bottom-right-radius":
177
- return add("style", declaration.property, parseLength(declaration.value[0], parseOptions));
178
- case "border-start-start-radius":
179
- return add("style", declaration.property, parseLength(declaration.value[0], parseOptions));
180
- case "border-start-end-radius":
181
- return add("style", declaration.property, parseLength(declaration.value[0], parseOptions));
182
- case "border-end-start-radius":
183
- return add("style", declaration.property, parseLength(declaration.value[0], parseOptions));
184
- case "border-end-end-radius":
185
- return add("style", declaration.property, parseLength(declaration.value[0], parseOptions));
186
- case "border-radius":
187
- handleStyleShorthand("border-radius", {
188
- "border-bottom-left-radius": parseLength(declaration.value.bottomLeft[0], parseOptions),
189
- "border-bottom-right-radius": parseLength(declaration.value.bottomRight[0], parseOptions),
190
- "border-top-left-radius": parseLength(declaration.value.topLeft[0], parseOptions),
191
- "border-top-right-radius": parseLength(declaration.value.topRight[0], parseOptions)
192
- });
193
- return;
194
- case "border-color":
195
- handleStyleShorthand("border-color", {
196
- "border-top-color": parseColor(declaration.value.top, {
197
- ...parseOptions,
198
- addWarning: buildAddWarning(addWarning, "border-top-color")
199
- }),
200
- "border-bottom-color": parseColor(declaration.value.bottom, {
201
- ...parseOptions,
202
- addWarning: buildAddWarning(addWarning, "border-bottom-color")
203
- }),
204
- "border-left-color": parseColor(declaration.value.left, {
205
- ...parseOptions,
206
- addWarning: buildAddWarning(addWarning, "border-left-color")
207
- }),
208
- "border-right-color": parseColor(declaration.value.right, {
209
- ...parseOptions,
210
- addWarning: buildAddWarning(addWarning, "border-right-color")
211
- })
212
- });
213
- return;
214
- case "border-style":
215
- return add("style", declaration.property, parseBorderStyle(declaration.value, parseOptions));
216
- case "border-width":
217
- handleStyleShorthand("border-width", {
218
- "border-top-width": parseBorderSideWidth(declaration.value.top, parseOptions),
219
- "border-bottom-width": parseBorderSideWidth(declaration.value.bottom, parseOptions),
220
- "border-left-width": parseBorderSideWidth(declaration.value.left, parseOptions),
221
- "border-right-width": parseBorderSideWidth(declaration.value.right, parseOptions)
222
- });
223
- return;
224
- case "border-block-color":
225
- add("style", "border-top-color", parseColor(declaration.value.start, parseOptions));
226
- add("style", "border-bottom-color", parseColor(declaration.value.end, parseOptions));
227
- return;
228
- case "border-block-width":
229
- add("style", "border-top-width", parseBorderSideWidth(declaration.value.start, parseOptions));
230
- add("style", "border-bottom-width", parseBorderSideWidth(declaration.value.end, parseOptions));
231
- return;
232
- case "border-inline-color":
233
- add("style", "border-left-color", parseColor(declaration.value.start, parseOptions));
234
- add("style", "border-right-color", parseColor(declaration.value.end, parseOptions));
235
- return;
236
- case "border-inline-width":
237
- add("style", "border-left-width", parseBorderSideWidth(declaration.value.start, parseOptions));
238
- add("style", "border-right-width", parseBorderSideWidth(declaration.value.end, parseOptions));
239
- return;
240
- case "border":
241
- handleStyleShorthand("border", {
242
- "border-width": parseBorderSideWidth(declaration.value.width, parseOptions),
243
- "border-style": parseBorderStyle(declaration.value.style, parseOptions)
244
- });
245
- return;
246
- case "border-top":
247
- add("style", declaration.property + "-color", parseColor(declaration.value.color, parseOptions));
248
- add("style", declaration.property + "-width", parseBorderSideWidth(declaration.value.width, parseOptions));
249
- return;
250
- case "border-bottom":
251
- add("style", declaration.property + "-color", parseColor(declaration.value.color, parseOptions));
252
- add("style", declaration.property + "-width", parseBorderSideWidth(declaration.value.width, parseOptions));
253
- return;
254
- case "border-left":
255
- add("style", declaration.property + "-color", parseColor(declaration.value.color, parseOptions));
256
- add("style", declaration.property + "-width", parseBorderSideWidth(declaration.value.width, parseOptions));
257
- return;
258
- case "border-right":
259
- add("style", declaration.property + "-color", parseColor(declaration.value.color, parseOptions));
260
- add("style", declaration.property + "-width", parseBorderSideWidth(declaration.value.width, parseOptions));
261
- return;
262
- case "border-block":
263
- add("style", "border-top-color", parseColor(declaration.value.color, parseOptions));
264
- add("style", "border-bottom-color", parseColor(declaration.value.color, parseOptions));
265
- add("style", "border-top-width", parseBorderSideWidth(declaration.value.width, parseOptions));
266
- add("style", "border-bottom-width", parseBorderSideWidth(declaration.value.width, parseOptions));
267
- return;
268
- case "border-block-start":
269
- add("style", "border-top-color", parseColor(declaration.value.color, parseOptions));
270
- add("style", "border-top-width", parseBorderSideWidth(declaration.value.width, parseOptions));
271
- return;
272
- case "border-block-end":
273
- add("style", "border-bottom-color", parseColor(declaration.value.color, parseOptions));
274
- add("style", "border-bottom-width", parseBorderSideWidth(declaration.value.width, parseOptions));
275
- return;
276
- case "border-inline":
277
- add("style", "border-left-color", parseColor(declaration.value.color, parseOptions));
278
- add("style", "border-right-color", parseColor(declaration.value.color, parseOptions));
279
- add("style", "border-left-width", parseBorderSideWidth(declaration.value.width, parseOptions));
280
- add("style", "border-right-width", parseBorderSideWidth(declaration.value.width, parseOptions));
281
- return;
282
- case "border-inline-start":
283
- add("style", "border-left-color", parseColor(declaration.value.color, parseOptions));
284
- add("style", "border-left-width", parseBorderSideWidth(declaration.value.width, parseOptions));
285
- return;
286
- case "border-inline-end":
287
- add("style", "border-right-color", parseColor(declaration.value.color, parseOptions));
288
- add("style", "border-right-width", parseBorderSideWidth(declaration.value.width, parseOptions));
289
- return;
290
- case "flex-direction":
291
- return add("style", declaration.property, declaration.value);
292
- case "flex-wrap":
293
- return add("style", declaration.property, declaration.value);
294
- case "flex-flow":
295
- add("style", "flexWrap", declaration.value.wrap);
296
- add("style", "flexDirection", declaration.value.direction);
297
- break;
298
- case "flex-grow":
299
- return add("style", declaration.property, declaration.value);
300
- case "flex-shrink":
301
- return add("style", declaration.property, declaration.value);
302
- case "flex-basis":
303
- return add("style", declaration.property, parseLengthPercentageOrAuto(declaration.value, parseOptions));
304
- case "flex":
305
- add("style", "flex-grow", declaration.value.grow);
306
- add("style", "flex-shrink", declaration.value.shrink);
307
- add("style", "flex-basis", parseLengthPercentageOrAuto(declaration.value.basis, parseOptions));
308
- break;
309
- case "align-content":
310
- return add("style", declaration.property, parseAlignContent(declaration.value, parseOptions));
311
- case "justify-content":
312
- return add("style", declaration.property, parseJustifyContent(declaration.value, parseOptions));
313
- case "align-self":
314
- return add("style", declaration.property, parseAlignSelf(declaration.value, parseOptions));
315
- case "align-items":
316
- return add("style", declaration.property, parseAlignItems(declaration.value, parseOptions));
317
- case "row-gap":
318
- return add("style", "row-gap", parseGap(declaration.value, parseOptions));
319
- case "column-gap":
320
- return add("style", "column-gap", parseGap(declaration.value, parseOptions));
321
- case "gap":
322
- add("style", "row-gap", parseGap(declaration.value.row, parseOptions));
323
- add("style", "column-gap", parseGap(declaration.value.column, parseOptions));
324
- return;
325
- case "margin":
326
- handleStyleShorthand("margin", {
327
- "margin-top": parseSize(declaration.value.top, parseOptions, {
328
- allowAuto: true
329
- }),
330
- "margin-bottom": parseSize(declaration.value.bottom, parseOptions, {
331
- allowAuto: true
332
- }),
333
- "margin-left": parseSize(declaration.value.left, parseOptions, {
334
- allowAuto: true
335
- }),
336
- "margin-right": parseSize(declaration.value.right, parseOptions, {
337
- allowAuto: true
338
- })
339
- });
340
- return;
341
- case "margin-top":
342
- return add("style", declaration.property, parseSize(declaration.value, parseOptions, {
343
- allowAuto: true
344
- }));
345
- case "margin-bottom":
346
- return add("style", declaration.property, parseSize(declaration.value, parseOptions, {
347
- allowAuto: true
348
- }));
349
- case "margin-left":
350
- return add("style", declaration.property, parseSize(declaration.value, parseOptions, {
351
- allowAuto: true
352
- }));
353
- case "margin-right":
354
- return add("style", declaration.property, parseSize(declaration.value, parseOptions, {
355
- allowAuto: true
356
- }));
357
- case "margin-block-start":
358
- return add("style", "margin-start", parseLengthPercentageOrAuto(declaration.value, parseOptions, {
359
- allowAuto: true
360
- }));
361
- case "margin-block-end":
362
- return add("style", "margin-end", parseLengthPercentageOrAuto(declaration.value, parseOptions, {
363
- allowAuto: true
364
- }));
365
- case "margin-inline-start":
366
- return add("style", "margin-start", parseLengthPercentageOrAuto(declaration.value, parseOptions, {
367
- allowAuto: true
368
- }));
369
- case "margin-inline-end":
370
- return add("style", "margin-end", parseLengthPercentageOrAuto(declaration.value, parseOptions, {
371
- allowAuto: true
372
- }));
373
- case "margin-block":
374
- handleStyleShorthand("margin-block", {
375
- "margin-start": parseLengthPercentageOrAuto(declaration.value.blockStart, parseOptions),
376
- "margin-end": parseLengthPercentageOrAuto(declaration.value.blockEnd, parseOptions)
377
- });
378
- return;
379
- case "margin-inline":
380
- handleStyleShorthand("margin-inline", {
381
- "margin-start": parseLengthPercentageOrAuto(declaration.value.inlineStart, parseOptions),
382
- "margin-end": parseLengthPercentageOrAuto(declaration.value.inlineEnd, parseOptions)
383
- });
384
- return;
385
- case "padding":
386
- handleStyleShorthand("padding", {
387
- "padding-top": parseSize(declaration.value.top, parseOptions),
388
- "padding-left": parseSize(declaration.value.left, parseOptions),
389
- "padding-right": parseSize(declaration.value.right, parseOptions),
390
- "padding-bottom": parseSize(declaration.value.bottom, parseOptions)
391
- });
392
- break;
393
- case "padding-top":
394
- return add("style", declaration.property, parseSize(declaration.value, parseOptions));
395
- case "padding-bottom":
396
- return add("style", declaration.property, parseSize(declaration.value, parseOptions));
397
- case "padding-left":
398
- return add("style", declaration.property, parseSize(declaration.value, parseOptions));
399
- case "padding-right":
400
- return add("style", declaration.property, parseSize(declaration.value, parseOptions));
401
- case "padding-block-start":
402
- return add("style", "padding-start", parseLengthPercentageOrAuto(declaration.value, parseOptions));
403
- case "padding-block-end":
404
- return add("style", "padding-end", parseLengthPercentageOrAuto(declaration.value, parseOptions));
405
- case "padding-inline-start":
406
- return add("style", "padding-start", parseLengthPercentageOrAuto(declaration.value, parseOptions));
407
- case "padding-inline-end":
408
- return add("style", "padding-end", parseLengthPercentageOrAuto(declaration.value, parseOptions));
409
- case "padding-block":
410
- handleStyleShorthand("padding-block", {
411
- "padding-start": parseLengthPercentageOrAuto(declaration.value.blockStart, parseOptions),
412
- "padding-end": parseLengthPercentageOrAuto(declaration.value.blockEnd, parseOptions)
413
- });
414
- return;
415
- case "padding-inline":
416
- handleStyleShorthand("padding-inline", {
417
- "padding-start": parseLengthPercentageOrAuto(declaration.value.inlineStart, parseOptions),
418
- "padding-end": parseLengthPercentageOrAuto(declaration.value.inlineEnd, parseOptions)
419
- });
420
- return;
421
- case "font-weight":
422
- return add("style", declaration.property, parseFontWeight(declaration.value, parseOptions));
423
- case "font-size":
424
- {
425
- add("style", declaration.property, parseFontSize(declaration.value, parseOptions));
426
- add("style", `--${emVariableName}`, parseFontSize(declaration.value, parseOptions));
427
- return;
428
- }
429
- case "font-family":
430
- return add("style", declaration.property, parseFontFamily(declaration.value));
431
- case "font-style":
432
- return add("style", declaration.property, parseFontStyle(declaration.value, parseOptions));
433
- case "font-variant-caps":
434
- return add("style", declaration.property, parseFontVariantCaps(declaration.value, parseOptions));
435
- case "line-height":
436
- return add("style", declaration.property, parseLineHeight(declaration.value, parseOptions));
437
- case "font":
438
- add("style", declaration.property + "-family", parseFontFamily(declaration.value.family));
439
- add("style", "line-height", parseLineHeight(declaration.value.lineHeight, parseOptions));
440
- add("style", declaration.property + "-size", parseFontSize(declaration.value.size, parseOptions));
441
- add("style", declaration.property + "-style", parseFontStyle(declaration.value.style, parseOptions));
442
- add("style", declaration.property + "-variant", parseFontVariantCaps(declaration.value.variantCaps, parseOptions));
443
- add("style", declaration.property + "-weight", parseFontWeight(declaration.value.weight, parseOptions));
444
- return;
445
- case "vertical-align":
446
- return add("style", declaration.property, parseVerticalAlign(declaration.value, parseOptions));
447
- case "transition-property":
448
- case "transition-duration":
449
- case "transition-delay":
450
- case "transition-timing-function":
451
- case "transition":
452
- return addTransitionValue(declaration, parseOptions);
453
- case "animation-duration":
454
- return add("animation", "animationDuration", declaration.value.map(t => parseTime(t)));
455
- case "animation-timing-function":
456
- case "animation-iteration-count":
457
- case "animation-name":
458
- case "animation-delay":
459
- case "animation-direction":
460
- case "animation-play-state":
461
- case "animation-fill-mode":
462
- case "animation":
463
- return addAnimationValue(declaration, parseOptions);
464
- case "transform":
465
- {
466
- add("style", "transform", [{}, "@transform", declaration.value.flatMap(t => {
467
- switch (t.type) {
468
- case "perspective":
469
- return [[{}, "@perspective", [parseLength(t.value, parseOptions)]]];
470
- case "translate":
471
- return [[{}, "@translateX", [parseLengthOrCoercePercentageToRuntime(t.value[0], parseOptions)]], [[{}, "@translateY", [parseLengthOrCoercePercentageToRuntime(t.value[1], parseOptions)]]]];
472
- case "translateX":
473
- return [[{}, "@translateX", [parseLengthOrCoercePercentageToRuntime(t.value, parseOptions)]]];
474
- case "translateY":
475
- return [[{}, "@translateY", [parseLengthOrCoercePercentageToRuntime(t.value, parseOptions)]]];
476
- case "rotate":
477
- return [[{}, "@rotate", [parseAngle(t.value, parseOptions)]]];
478
- case "rotateX":
479
- return [[{}, "@rotateX", [parseAngle(t.value, parseOptions)]]];
480
- case "rotateY":
481
- return [[{}, "@rotateY", [parseAngle(t.value, parseOptions)]]];
482
- case "rotateZ":
483
- return [[{}, "@rotateZ", [parseAngle(t.value, parseOptions)]]];
484
- case "scale":
485
- return [[{}, "@scaleX", [parseLength(t.value[0], parseOptions)]], [{}, "@scaleY", [parseLength(t.value[0], parseOptions)]]];
486
- case "scaleX":
487
- return [[{}, "scaleX", [parseLength(t.value, parseOptions)]]];
488
- case "scaleY":
489
- return [[{}, "scaleY", [parseLength(t.value, parseOptions)]]];
490
- case "skew":
491
- return [[{}, "skewX", [parseAngle(t.value[0], parseOptions)]], [{}, "skewY", [parseAngle(t.value[0], parseOptions)]]];
492
- case "skewX":
493
- return [[{}, "skewX", [parseAngle(t.value, parseOptions)]]];
494
- case "skewY":
495
- return [[{}, "skewY", [parseAngle(t.value, parseOptions)]]];
496
- case "translateZ":
497
- case "translate3d":
498
- case "scaleZ":
499
- case "scale3d":
500
- case "rotate3d":
501
- case "matrix":
502
- case "matrix3d":
503
- return [[]];
504
- }
505
- })]);
506
- return;
507
- }
508
- case "translate":
509
- add("style", "translateX", [{}, "translateX", [parseTranslate(declaration.value, "x", parseOptions)]]);
510
- add("style", "translateY", [{}, "translateX", [parseTranslate(declaration.value, "y", parseOptions)]]);
511
- return;
512
- case "rotate":
513
- add("style", "rotateX", [{}, "rotateX", [parseAngle(declaration.value.x, parseOptions)]]);
514
- add("style", "rotateY", [{}, "rotateY", [parseAngle(declaration.value.y, parseOptions)]]);
515
- add("style", "rotateZ", [{}, "rotateZ", [parseAngle(declaration.value.z, parseOptions)]]);
516
- return;
517
- case "scale":
518
- add("style", "scaleX", [{}, "scaleX", [parseScale(declaration.value, "x", parseOptions)]]);
519
- add("style", "scaleY", [{}, "scaleY", [parseScale(declaration.value, "y", parseOptions)]]);
520
- return;
521
- case "text-transform":
522
- return add("style", declaration.property, declaration.value.case);
523
- case "letter-spacing":
524
- if (declaration.value.type !== "normal") {
525
- return add("style", declaration.property, parseLength(declaration.value.value, parseOptions));
526
- }
527
- return;
528
- case "text-decoration-line":
529
- return add("style", declaration.property, parseTextDecorationLine(declaration.value, parseOptions));
530
- case "text-decoration-color":
531
- return add("style", declaration.property, parseColor(declaration.value, parseOptions));
532
- case "text-decoration":
533
- add("style", "text-decoration-color", parseColor(declaration.value.color, parseOptions));
534
- add("style", "text-decoration-line", parseTextDecorationLine(declaration.value.line, parseOptions));
535
- return;
536
- case "text-shadow":
537
- return parseTextShadow(add, declaration.value, parseOptions);
538
- case "z-index":
539
- if (declaration.value.type === "integer") {
540
- add("style", declaration.property, parseLength(declaration.value.value, parseOptions));
541
- } else {
542
- parseOptions.addWarning("value", declaration.value.type);
543
- }
544
- return;
545
- case "container-type":
546
- return;
547
- case "container-name":
548
- return add("container", declaration.property, declaration.value.type === "none" ? false : declaration.value.value);
549
- case "container":
550
- return add("container", "container-name", declaration.value.name.type === "none" ? false : declaration.value.name.value);
551
- case "text-decoration-style":
552
- return add("style", declaration.property, parseTextDecorationStyle(declaration.value, parseOptions));
553
- case "text-align":
554
- return add("style", declaration.property, parseTextAlign(declaration.value, parseOptions));
555
- case "box-shadow":
556
- {
557
- return parseBoxShadow(declaration.value, parseOptions);
558
- }
559
- case "aspect-ratio":
560
- {
561
- return add("style", declaration.property, parseAspectRatio(declaration.value));
562
- }
563
- case "user-select":
564
- {
565
- return add("style", declaration.property, parseUserSelect(declaration.value, parseOptions));
566
- }
567
- case "fill":
568
- {
569
- return add("style", declaration.property, parseSVGPaint(declaration.value, parseOptions));
570
- }
571
- case "stroke":
572
- {
573
- return add("style", declaration.property, parseSVGPaint(declaration.value, parseOptions));
574
- }
575
- case "stroke-width":
576
- {
577
- return add("style", declaration.property, parseDimensionPercentageFor_LengthValue(declaration.value, parseOptions));
578
- }
579
- case "caret-color":
580
- {
581
- return add("style", declaration.property, parseColorOrAuto(declaration.value, parseOptions));
582
- }
583
- default:
584
- {
585
- /**
586
- * This is used to know when lightningcss has added a new property and we need to add it to the
587
- * switch.
588
- *
589
- * If your build fails here, its because you have a newer version of lightningcss installed.
590
- */
591
- declaration;
592
- }
476
+ return parseLength(translate[prop], builder);
477
+ }
478
+ function parseLetterSpacing({
479
+ value
480
+ }, builder) {
481
+ if (value.type === "normal") {
482
+ return;
593
483
  }
484
+ return parseLength(value.value, builder);
594
485
  }
595
- function buildAddWarning(addWarning, property) {
596
- return function (type, value) {
597
- if (type === "property") {
598
- return addWarning(type, property);
599
- } else if (type === "value") {
600
- return addWarning(type, property, value);
601
- }
602
- };
486
+ function parseTextDecoration({
487
+ value
488
+ }, builder) {
489
+ builder.addDescriptor("text-decoration-color", parseColor(value.color, builder));
490
+ builder.addDescriptor("text-decoration-line", parseTextDecorationLine(value.line, builder));
603
491
  }
604
- function parseDeclarationUnparsed(declaration, options, add, addWarning) {
492
+ function parseZIndex({
493
+ value
494
+ }, builder) {
495
+ if (value.type === "integer") {
496
+ return parseLength(value.value, builder);
497
+ } else {
498
+ builder.addWarning("value", value.type);
499
+ return;
500
+ }
501
+ }
502
+ function parseContainerType(_value, _builder) {
503
+ return;
504
+ }
505
+ function parseContainerName({
506
+ value
507
+ }, builder) {
508
+ builder.addContainer(value.type === "none" ? false : value.value);
509
+ return;
510
+ }
511
+ function parseContainer({
512
+ value
513
+ }, builder) {
514
+ builder.addContainer(value.name.type === "none" ? false : value.name.value);
515
+ return;
516
+ }
517
+ export function parseDeclarationUnparsed(declaration, builder) {
605
518
  let property = declaration.value.propertyId.property;
606
- if (!isValid(declaration.value.propertyId)) {
607
- return addWarning("property", property);
608
- }
609
- const parseOptions = {
610
- ...options,
611
- add,
612
- addWarning: buildAddWarning(addWarning, property)
613
- };
519
+ if (!(property in parsers)) {
520
+ builder.addWarning("property", property);
521
+ return;
522
+ }
614
523
 
615
524
  /**
616
525
  * React Native doesn't support all the logical properties
617
526
  */
618
- if (propertyRename[declaration.value.propertyId.property]) {
619
- property = propertyRename[declaration.value.propertyId.property];
527
+ const rename = propertyRename[property];
528
+ if (rename) {
529
+ property = rename;
620
530
  }
621
531
 
622
532
  /**
623
533
  * Unparsed shorthand properties need to be parsed at runtime
624
534
  */
625
- if (runtimeShorthands.has(property)) {
626
- let args = parseUnparsed(declaration.value.value, parseOptions);
627
- if (!isStyleDescriptorArray(args)) {
628
- args = [args];
629
- }
535
+ builder.descriptorProperty = property;
536
+ if (unparsedRuntimeParsing.has(property)) {
537
+ const args = parseUnparsed(declaration.value.value, builder);
630
538
  if (property === "animation") {
631
- return add("style", "animation", [{}, `@${toRNProperty(property)}`, args]);
539
+ builder.addDescriptor("animation", [{}, `@${toRNProperty(property)}`, args]);
632
540
  } else {
633
- return add("style", property, [{}, `@${toRNProperty(property)}`, args, 1]);
541
+ builder.addDescriptor(property, [{}, `@${toRNProperty(property)}`, args, 1]);
634
542
  }
635
- }
636
- return add("style", property, parseUnparsed(declaration.value.value, parseOptions));
637
- }
638
- function parseDeclarationCustom(declaration, options, add, addWarning) {
639
- const parseOptions = {
640
- ...options,
641
- add,
642
- addWarning(type, value) {
643
- if (type === "property") {
644
- return addWarning(type, property);
645
- } else if (type === "value") {
646
- return addWarning(type, property, value);
647
- }
648
- }
649
- };
650
- let property = declaration.value.name;
651
- if (validPropertiesLoose.has(property) || property.startsWith("--") || property.startsWith("-rn-")) {
652
- return add("style", property, parseUnparsed(declaration.value.value, {
653
- ...parseOptions,
654
- allowAuto: allowAuto.has(property)
655
- }));
656
543
  } else {
657
- return addWarning("property", declaration.value.name);
544
+ const value = parseUnparsed(declaration.value.value, builder);
545
+ builder.addDescriptor(property, value);
546
+ if (property === "font-size") {
547
+ builder.addDescriptor("--__rn-css-em", value);
548
+ }
549
+ if (property === "color") {
550
+ builder.addDescriptor("--__rn-css-current-color", value);
551
+ }
658
552
  }
659
553
  }
660
- function isValid(declaration) {
661
- return validPropertiesLoose.has(declaration.property);
554
+ export function parseDeclarationCustom(declaration, builder) {
555
+ const property = declaration.value.name;
556
+ if (validProperties.has(property) || property.startsWith("--") || property.startsWith("-rn-")) {
557
+ builder.addDescriptor(property, parseUnparsed(declaration.value.value, builder, allowAuto.has(property)));
558
+ } else {
559
+ builder.addWarning("property", declaration.value.name);
560
+ }
662
561
  }
663
- function reduceParseUnparsed(tokenOrValues, options) {
664
- const result = tokenOrValues.map(tokenOrValue => parseUnparsed(tokenOrValue, options)).filter(v => v !== undefined);
562
+ export function reduceParseUnparsed(tokenOrValues, builder) {
563
+ const result = tokenOrValues.map(tokenOrValue => parseUnparsed(tokenOrValue, builder)).filter(v => v !== undefined);
665
564
  if (result.length === 0) {
666
565
  return undefined;
667
- } else {
668
- return result;
669
566
  }
567
+ let currentGroup = [];
568
+ let groups = [currentGroup];
569
+ for (const value of result) {
570
+ if (value === CommaSeparator) {
571
+ currentGroup = [];
572
+ groups.push(currentGroup);
573
+ } else {
574
+ currentGroup.push(value);
575
+ }
576
+ }
577
+ groups = groups.flatMap(group => {
578
+ if (!Array.isArray(group)) {
579
+ return [];
580
+ }
581
+ if (group.length === 0) {
582
+ return [];
583
+ } else if (group.length === 1) {
584
+ const first = group[0];
585
+ if (first === undefined) {
586
+ return [];
587
+ } else {
588
+ return [first];
589
+ }
590
+ } else {
591
+ return [group];
592
+ }
593
+ });
594
+ return groups.length === 1 ? groups[0] : groups;
670
595
  }
671
- function unparsedFunction(token, options) {
672
- const args = reduceParseUnparsed(token.value.arguments, options);
673
- return [{}, token.value.name, args];
596
+ export function unparsedFunction(token, builder) {
597
+ return [{}, token.value.name, reduceParseUnparsed(token.value.arguments, builder)];
674
598
  }
675
599
 
676
600
  /**
677
601
  * When the CSS cannot be parsed (often due to a runtime condition like a CSS variable)
678
- * This function best efforts parsing it into a function that we can evaluate at runtime
602
+ * This export function best efforts parsing it into a export function that we can evaluate at runtime
679
603
  */
680
- function parseUnparsed(tokenOrValue, options) {
604
+ export function parseUnparsed(tokenOrValue, builder, allowAuto = false) {
681
605
  if (tokenOrValue === undefined || tokenOrValue === null) {
682
606
  return;
683
607
  }
@@ -686,6 +610,8 @@ function parseUnparsed(tokenOrValue, options) {
686
610
  return true;
687
611
  } else if (tokenOrValue === "false") {
688
612
  return false;
613
+ } else if (tokenOrValue === "currentcolor") {
614
+ return [{}, "var", "__rn-css-current-color"];
689
615
  } else {
690
616
  return tokenOrValue;
691
617
  }
@@ -694,22 +620,22 @@ function parseUnparsed(tokenOrValue, options) {
694
620
  return round(tokenOrValue);
695
621
  }
696
622
  if (Array.isArray(tokenOrValue)) {
697
- const args = reduceParseUnparsed(tokenOrValue, options);
623
+ const args = reduceParseUnparsed(tokenOrValue, builder);
698
624
  if (!args) return;
699
- if (args.length === 1) return args[0];
625
+ if (Array.isArray(args) && args.length === 1) return args[0];
700
626
  return args;
701
627
  }
702
628
  switch (tokenOrValue.type) {
703
629
  case "unresolved-color":
704
630
  {
705
- return parseUnresolvedColor(tokenOrValue.value, options);
631
+ return parseUnresolvedColor(tokenOrValue.value, builder);
706
632
  }
707
633
  case "var":
708
634
  {
709
- const args = [tokenOrValue.value.name.ident.slice(2)];
710
- const fallback = parseUnparsed(tokenOrValue.value.fallback, options);
635
+ let args = tokenOrValue.value.name.ident.slice(2);
636
+ const fallback = parseUnparsed(tokenOrValue.value.fallback, builder);
711
637
  if (fallback !== undefined) {
712
- args.push(fallback);
638
+ args = [args, fallback];
713
639
  }
714
640
  return [{}, "var", args, 1];
715
641
  }
@@ -728,72 +654,86 @@ function parseUnparsed(tokenOrValue, options) {
728
654
  case "translateX":
729
655
  case "translateY":
730
656
  tokenOrValue.value.name = `@${tokenOrValue.value.name}`;
731
- return unparsedFunction(tokenOrValue, options);
732
- case "platformColor":
733
- case "getPixelSizeForLayoutSize":
734
- case "roundToNearestPixel":
735
- case "pixelScale":
657
+ return unparsedFunction(tokenOrValue, builder);
658
+ case "brightness":
659
+ case "contrast":
660
+ case "cubic-bezier":
661
+ case "drop-shadow":
736
662
  case "fontScale":
737
- case "shadow":
738
- case "rgb":
739
- case "rgba":
663
+ case "grayscale":
740
664
  case "hsl":
741
665
  case "hsla":
742
- return unparsedFunction(tokenOrValue, options);
666
+ case "hue-rotate":
667
+ case "invert":
668
+ case "linear-gradient":
669
+ case "opacity":
670
+ case "pixelScale":
671
+ case "pixelSizeForLayoutSize":
672
+ case "platformColor":
673
+ case "radial-gradient":
674
+ case "rgb":
675
+ case "rgba":
676
+ case "roundToNearestPixel":
677
+ case "saturate":
678
+ case "sepia":
679
+ case "shadow":
680
+ case "steps":
681
+ return unparsedFunction(tokenOrValue, builder);
743
682
  case "hairlineWidth":
744
683
  return [{}, tokenOrValue.value.name, []];
745
- case "platformSelect":
746
- case "fontScaleSelect":
747
- case "pixelScaleSelect":
748
- return parseRNRuntimeSpecificsFunction(tokenOrValue.value.name, tokenOrValue.value.arguments, options);
749
684
  case "calc":
750
685
  case "max":
751
686
  case "min":
752
687
  case "clamp":
753
- return parseCalcFn(tokenOrValue.value.name, tokenOrValue.value.arguments, options);
688
+ return parseCalcFn(tokenOrValue.value.name, tokenOrValue.value.arguments, builder);
754
689
  default:
755
690
  {
756
- options.addWarning("function", tokenOrValue.value.name);
691
+ builder.addWarning("function", tokenOrValue.value.name);
757
692
  return;
758
693
  }
759
694
  }
760
695
  }
761
696
  case "length":
762
- return parseLength(tokenOrValue.value, options);
697
+ return parseLength(tokenOrValue.value, builder);
763
698
  case "angle":
764
- return parseAngle(tokenOrValue.value, options);
699
+ return parseAngle(tokenOrValue.value, builder);
765
700
  case "token":
766
701
  switch (tokenOrValue.value.type) {
767
702
  case "string":
768
- case "number":
769
703
  case "ident":
770
704
  {
771
705
  const value = tokenOrValue.value.value;
772
- if (typeof value === "string") {
773
- if (!options.allowAuto && value === "auto") {
774
- return options.addWarning("value", value);
775
- }
776
- if (value === "inherit") {
777
- return options.addWarning("value", value);
778
- }
779
- if (value === "true") {
780
- return true;
781
- } else if (value === "false") {
782
- return false;
783
- } else {
784
- return value;
785
- }
706
+ if (!allowAuto && value === "auto") {
707
+ builder.addWarning("value", value);
708
+ return;
709
+ }
710
+ if (value === "inherit") {
711
+ builder.addWarning("value", value);
712
+ return;
713
+ } else if (value === "currentcolor") {
714
+ return [{}, "var", "__rn-css-current-color"];
715
+ }
716
+ if (value === "true") {
717
+ return true;
718
+ } else if (value === "false") {
719
+ return false;
786
720
  } else {
787
721
  return value;
788
722
  }
789
723
  }
724
+ case "number":
725
+ {
726
+ return round(tokenOrValue.value.value);
727
+ }
790
728
  case "function":
791
- options.addWarning("value", tokenOrValue.value.value);
729
+ builder.addWarning("value", tokenOrValue.value.value);
792
730
  return;
793
731
  case "percentage":
794
732
  return `${round(tokenOrValue.value.value * 100)}%`;
795
733
  case "dimension":
796
- return parseDimension(tokenOrValue.value, options);
734
+ return parseDimension(tokenOrValue.value, builder);
735
+ case "comma":
736
+ return CommaSeparator;
797
737
  case "at-keyword":
798
738
  case "hash":
799
739
  case "id-hash":
@@ -803,7 +743,6 @@ function parseUnparsed(tokenOrValue, options) {
803
743
  case "comment":
804
744
  case "colon":
805
745
  case "semicolon":
806
- case "comma":
807
746
  case "include-match":
808
747
  case "dash-match":
809
748
  case "prefix-match":
@@ -827,9 +766,9 @@ function parseUnparsed(tokenOrValue, options) {
827
766
  }
828
767
  }
829
768
  case "color":
830
- return parseColor(tokenOrValue.value, options);
769
+ return parseColor(tokenOrValue.value, builder);
831
770
  case "env":
832
- return parseEnv(tokenOrValue.value, options);
771
+ return parseEnv(tokenOrValue.value, builder);
833
772
  case "time":
834
773
  return parseTime(tokenOrValue.value);
835
774
  case "url":
@@ -844,10 +783,13 @@ function parseUnparsed(tokenOrValue, options) {
844
783
  }
845
784
  return;
846
785
  }
847
- export function parseLength(length, options) {
786
+ export function parseLengthDeclaration(declaration, builder) {
787
+ return parseLength(declaration.value, builder);
788
+ }
789
+ export function parseLength(length, builder) {
848
790
  const {
849
791
  inlineRem = 14
850
- } = options;
792
+ } = builder.getOptions();
851
793
  if (typeof length === "number") {
852
794
  return length;
853
795
  }
@@ -859,12 +801,12 @@ export function parseLength(length, options) {
859
801
  if (typeof inlineRem === "number") {
860
802
  return length.value * inlineRem;
861
803
  } else {
862
- return [{}, "rem", [length.value]];
804
+ return [{}, "rem", length.value];
863
805
  }
864
806
  case "vw":
865
807
  case "vh":
866
808
  case "em":
867
- return [{}, length.unit, [length.value], 1];
809
+ return [{}, length.unit, length.value, 1];
868
810
  case "in":
869
811
  case "cm":
870
812
  case "mm":
@@ -909,7 +851,7 @@ export function parseLength(length, options) {
909
851
  case "lvmax":
910
852
  case "dvmax":
911
853
  case "cqmax":
912
- options.addWarning("value", `${length.value}${length.unit}`);
854
+ builder.addWarning("value", `${length.value}${length.unit}`);
913
855
  return undefined;
914
856
  default:
915
857
  {
@@ -934,13 +876,13 @@ export function parseLength(length, options) {
934
876
  case "dimension":
935
877
  case "value":
936
878
  {
937
- return parseLength(length.value, options);
879
+ return parseLength(length.value, builder);
938
880
  }
939
881
  }
940
882
  }
941
883
  return;
942
884
  }
943
- function parseAngle(angle, options) {
885
+ export function parseAngle(angle, builder) {
944
886
  if (typeof angle === "number") {
945
887
  return `${angle}deg`;
946
888
  }
@@ -949,23 +891,47 @@ function parseAngle(angle, options) {
949
891
  case "rad":
950
892
  return `${angle.value}${angle.type}`;
951
893
  default:
952
- options.addWarning("value", angle.value);
894
+ builder.addWarning("value", angle.value);
953
895
  return undefined;
954
896
  }
955
897
  }
956
- function parseSize(size, options, {
898
+ export function parseSizeDeclaration(declaration, builder) {
899
+ return parseSize(declaration.value, builder);
900
+ }
901
+ export function parsePointerEvents({
902
+ value
903
+ }, builder) {
904
+ switch (value) {
905
+ case "none":
906
+ case "box-none":
907
+ case "box-only":
908
+ case "auto":
909
+ return value;
910
+ case "visible":
911
+ case "visiblePainted":
912
+ case "visibleFill":
913
+ case "visibleStroke":
914
+ case "painted":
915
+ case "fill":
916
+ case "stroke":
917
+ builder.addWarning("value", value);
918
+ }
919
+ return;
920
+ }
921
+ export function parseSize(size, builder, options, {
957
922
  allowAuto = false
958
923
  } = {}) {
924
+ allowAuto = (typeof options === "object" ? options.allowAuto : allowAuto) ?? false;
959
925
  switch (size.type) {
960
926
  case "length-percentage":
961
- return parseLength(size.value, options);
927
+ return parseLength(size.value, builder);
962
928
  case "none":
963
929
  return size.type;
964
930
  case "auto":
965
931
  if (allowAuto) {
966
932
  return size.type;
967
933
  } else {
968
- options.addWarning("value", size.type);
934
+ builder.addWarning("value", size.type);
969
935
  return undefined;
970
936
  }
971
937
  case "min-content":
@@ -974,7 +940,7 @@ function parseSize(size, options, {
974
940
  case "fit-content-function":
975
941
  case "stretch":
976
942
  case "contain":
977
- options.addWarning("value", size.type);
943
+ builder.addWarning("value", size.type);
978
944
  return undefined;
979
945
  default:
980
946
  {
@@ -983,58 +949,174 @@ function parseSize(size, options, {
983
949
  }
984
950
  return;
985
951
  }
986
- function parseColorOrAuto(color, options) {
987
- if (color.type === "auto") {
988
- options.addWarning("value", `Invalid color value ${color.type}`);
952
+ export function parseColorOrAuto({
953
+ value
954
+ }, builder) {
955
+ if (value.type === "auto") {
956
+ builder.addWarning("value", `Invalid color value ${value.type}`);
989
957
  return;
990
958
  } else {
991
- return parseColor(color.value, options);
959
+ return parseColor(value.value, builder);
992
960
  }
993
961
  }
994
- function parseColor(color, options) {
995
- if (typeof color === "string") {
996
- // TODO: Could web system colors be mapped to native?
962
+ export function parseFontColorDeclaration(declaration, builder) {
963
+ parseColorDeclaration(declaration, builder);
964
+ builder.addDescriptor("--__rn-css-color", parseColor(declaration.value, builder));
965
+ }
966
+ export function parseColorDeclaration(declaration, builder) {
967
+ builder.addDescriptor(declaration.property, parseColor(declaration.value, builder));
968
+ }
969
+ export function parseColor(cssColor, builder) {
970
+ if (typeof cssColor === "string") {
971
+ if (namedColors.has(cssColor)) {
972
+ return cssColor;
973
+ }
997
974
  return;
998
975
  }
999
- switch (color.type) {
976
+ let color;
977
+ const {
978
+ hexColors = true,
979
+ colorPrecision
980
+ } = builder.getOptions();
981
+ switch (cssColor.type) {
982
+ case "currentcolor":
983
+ return [{}, "var", "__rn-css-current-color"];
984
+ case "light-dark":
985
+ {
986
+ const extraRule = {
987
+ s: [],
988
+ m: [["=", "prefers-color-scheme", "dark"]]
989
+ };
990
+ builder.addUnnamedDescriptor(parseColor(cssColor.dark, builder), false, extraRule);
991
+ builder.addExtraRule(extraRule);
992
+ return parseColor(cssColor.light, builder);
993
+ }
1000
994
  case "rgb":
1001
995
  {
1002
- // Hex is smaller than rgb, so we convert it
1003
- const hexValues = [color.r.toString(16).padStart(2, "0"), color.g.toString(16).padStart(2, "0"), color.b.toString(16).padStart(2, "0")];
1004
- if (color.alpha !== 1) {
1005
- hexValues.push(Math.round(color.alpha * 255).toString(16).padStart(2, "0"));
1006
- }
1007
- return `#${hexValues.join("")}`;
996
+ color = new Color({
997
+ space: "sRGB",
998
+ coords: [cssColor.r / 255, cssColor.g / 255, cssColor.b / 255],
999
+ alpha: cssColor.alpha
1000
+ });
1001
+ break;
1008
1002
  }
1009
1003
  case "hsl":
1010
- return `hsla(${color.h}, ${color.s}, ${color.l}, ${color.alpha})`;
1011
- case "currentcolor":
1012
- options.addWarning("value", color.type);
1013
- return;
1014
- case "light-dark":
1004
+ color = new Color({
1005
+ space: cssColor.type,
1006
+ coords: [cssColor.h, cssColor.s, cssColor.l],
1007
+ alpha: cssColor.alpha
1008
+ });
1009
+ break;
1010
+ case "hwb":
1011
+ color = new Color({
1012
+ space: cssColor.type,
1013
+ coords: [cssColor.h, cssColor.w, cssColor.b],
1014
+ alpha: cssColor.alpha
1015
+ });
1016
+ break;
1015
1017
  case "lab":
1018
+ color = new Color({
1019
+ space: cssColor.type,
1020
+ coords: [cssColor.l, cssColor.a, cssColor.b],
1021
+ alpha: cssColor.alpha
1022
+ });
1023
+ break;
1016
1024
  case "lch":
1025
+ color = new Color({
1026
+ space: cssColor.type,
1027
+ coords: [cssColor.l, cssColor.c, cssColor.h],
1028
+ alpha: cssColor.alpha
1029
+ });
1030
+ break;
1017
1031
  case "oklab":
1032
+ color = new Color({
1033
+ space: cssColor.type,
1034
+ coords: [cssColor.l, cssColor.a, cssColor.b],
1035
+ alpha: cssColor.alpha
1036
+ });
1037
+ break;
1018
1038
  case "oklch":
1039
+ color = new Color({
1040
+ space: cssColor.type,
1041
+ coords: [cssColor.l, cssColor.c, cssColor.h],
1042
+ alpha: cssColor.alpha
1043
+ });
1044
+ break;
1019
1045
  case "srgb":
1046
+ color = new Color({
1047
+ space: cssColor.type,
1048
+ coords: [cssColor.r, cssColor.g, cssColor.b],
1049
+ alpha: cssColor.alpha
1050
+ });
1051
+ break;
1020
1052
  case "srgb-linear":
1053
+ color = new Color({
1054
+ space: cssColor.type,
1055
+ coords: [cssColor.r, cssColor.g, cssColor.b],
1056
+ alpha: cssColor.alpha
1057
+ });
1058
+ break;
1021
1059
  case "display-p3":
1060
+ color = new Color({
1061
+ space: "p3",
1062
+ coords: [cssColor.r, cssColor.g, cssColor.b],
1063
+ alpha: cssColor.alpha
1064
+ });
1065
+ break;
1022
1066
  case "a98-rgb":
1067
+ color = new Color({
1068
+ space: "a98rgb",
1069
+ coords: [cssColor.r, cssColor.g, cssColor.b],
1070
+ alpha: cssColor.alpha
1071
+ });
1072
+ break;
1023
1073
  case "prophoto-rgb":
1074
+ color = new Color({
1075
+ space: "prophoto",
1076
+ coords: [cssColor.r, cssColor.g, cssColor.b],
1077
+ alpha: cssColor.alpha
1078
+ });
1079
+ break;
1024
1080
  case "rec2020":
1081
+ color = new Color({
1082
+ space: cssColor.type,
1083
+ coords: [cssColor.r, cssColor.g, cssColor.b],
1084
+ alpha: cssColor.alpha
1085
+ });
1086
+ break;
1025
1087
  case "xyz-d50":
1088
+ color = new Color({
1089
+ space: cssColor.type,
1090
+ coords: [cssColor.x, cssColor.y, cssColor.z],
1091
+ alpha: cssColor.alpha
1092
+ });
1093
+ break;
1026
1094
  case "xyz-d65":
1027
- case "hwb":
1028
- options.addWarning("value", `Invalid color unit ${color.type}`);
1029
- return undefined;
1095
+ color = new Color({
1096
+ space: cssColor.type,
1097
+ coords: [cssColor.x, cssColor.y, cssColor.z],
1098
+ alpha: cssColor.alpha
1099
+ });
1100
+ break;
1030
1101
  default:
1031
1102
  {
1032
- color;
1103
+ cssColor;
1033
1104
  }
1034
1105
  }
1035
- return;
1106
+ if (!hexColors || colorPrecision) {
1107
+ return color?.toString({
1108
+ precision: colorPrecision ?? 3
1109
+ });
1110
+ } else {
1111
+ return color?.toString({
1112
+ format: "hex"
1113
+ });
1114
+ }
1115
+ }
1116
+ export function parseLengthPercentageOrAutoDeclaration(value, builder) {
1117
+ return parseLengthPercentageOrAuto(value.value, builder);
1036
1118
  }
1037
- function parseLengthPercentageOrAuto(lengthPercentageOrAuto, options, {
1119
+ export function parseLengthPercentageOrAuto(lengthPercentageOrAuto, builder, {
1038
1120
  allowAuto = false
1039
1121
  } = {}) {
1040
1122
  switch (lengthPercentageOrAuto.type) {
@@ -1042,11 +1124,11 @@ function parseLengthPercentageOrAuto(lengthPercentageOrAuto, options, {
1042
1124
  if (allowAuto) {
1043
1125
  return lengthPercentageOrAuto.type;
1044
1126
  } else {
1045
- options.addWarning("value", lengthPercentageOrAuto.type);
1127
+ builder.addWarning("value", lengthPercentageOrAuto.type);
1046
1128
  return undefined;
1047
1129
  }
1048
1130
  case "length-percentage":
1049
- return parseLength(lengthPercentageOrAuto.value, options);
1131
+ return parseLength(lengthPercentageOrAuto.value, builder);
1050
1132
  default:
1051
1133
  {
1052
1134
  lengthPercentageOrAuto;
@@ -1054,109 +1136,112 @@ function parseLengthPercentageOrAuto(lengthPercentageOrAuto, options, {
1054
1136
  }
1055
1137
  return;
1056
1138
  }
1057
- function parseJustifyContent(justifyContent, options) {
1139
+ export function parseJustifyContent(declaration, builder) {
1058
1140
  const allowed = new Set(["flex-start", "flex-end", "center", "space-between", "space-around", "space-evenly"]);
1059
1141
  let value;
1060
- switch (justifyContent.type) {
1142
+ switch (declaration.value.type) {
1061
1143
  case "normal":
1062
1144
  case "left":
1063
1145
  case "right":
1064
- value = justifyContent.type;
1146
+ value = declaration.value.type;
1065
1147
  break;
1066
1148
  case "content-distribution":
1067
1149
  case "content-position":
1068
- value = justifyContent.value;
1150
+ value = declaration.value.value;
1069
1151
  break;
1070
1152
  default:
1071
1153
  {
1072
- justifyContent;
1154
+ declaration.value;
1073
1155
  }
1074
1156
  }
1075
1157
  if (value && !allowed.has(value)) {
1076
- options.addWarning("value", value);
1158
+ builder.addWarning("value", value);
1077
1159
  return;
1078
1160
  }
1079
1161
  return value;
1080
1162
  }
1081
- function parseAlignContent(alignContent, options) {
1163
+ export function parseAlignContent(declaration, builder) {
1082
1164
  const allowed = new Set(["flex-start", "flex-end", "center", "stretch", "space-between", "space-around"]);
1083
1165
  let value;
1084
- switch (alignContent.type) {
1166
+ switch (declaration.value.type) {
1085
1167
  case "normal":
1086
1168
  case "baseline-position":
1087
- value = alignContent.type;
1169
+ value = declaration.value.type;
1088
1170
  break;
1089
1171
  case "content-distribution":
1090
1172
  case "content-position":
1091
- value = alignContent.value;
1173
+ value = declaration.value.value;
1092
1174
  break;
1093
1175
  default:
1094
1176
  {
1095
- alignContent;
1177
+ declaration.value;
1096
1178
  }
1097
1179
  }
1098
1180
  if (value && !allowed.has(value)) {
1099
- options.addWarning("value", value);
1181
+ builder.addWarning("value", value);
1100
1182
  return;
1101
1183
  }
1102
1184
  return value;
1103
1185
  }
1104
- function parseAlignItems(alignItems, options) {
1186
+ export function parseAlignItems(alignItems, builder) {
1105
1187
  const allowed = new Set(["auto", "flex-start", "flex-end", "center", "stretch", "baseline"]);
1106
1188
  let value;
1107
- switch (alignItems.type) {
1189
+ switch (alignItems.value.type) {
1108
1190
  case "normal":
1109
1191
  value = "auto";
1110
1192
  break;
1111
1193
  case "stretch":
1112
- value = alignItems.type;
1194
+ value = alignItems.value.type;
1113
1195
  break;
1114
1196
  case "baseline-position":
1115
1197
  value = "baseline";
1116
1198
  break;
1117
1199
  case "self-position":
1118
- value = alignItems.value;
1200
+ value = alignItems.value.value;
1119
1201
  break;
1120
1202
  default:
1121
1203
  {
1122
- alignItems;
1204
+ alignItems.value;
1123
1205
  }
1124
1206
  }
1125
1207
  if (value && !allowed.has(value)) {
1126
- options.addWarning("value", value);
1208
+ builder.addWarning("value", value);
1127
1209
  return;
1128
1210
  }
1129
1211
  return value;
1130
1212
  }
1131
- function parseAlignSelf(alignSelf, options) {
1213
+ export function parseAlignSelf(alignSelf, builder) {
1132
1214
  const allowed = new Set(["auto", "flex-start", "flex-end", "center", "stretch", "baseline"]);
1133
1215
  let value;
1134
- switch (alignSelf.type) {
1216
+ switch (alignSelf.value.type) {
1135
1217
  case "normal":
1136
1218
  case "auto":
1137
1219
  value = "auto";
1138
1220
  break;
1139
1221
  case "stretch":
1140
- value = alignSelf.type;
1222
+ value = alignSelf.value.type;
1141
1223
  break;
1142
1224
  case "baseline-position":
1143
1225
  value = "baseline";
1144
1226
  break;
1145
1227
  case "self-position":
1146
- value = alignSelf.value;
1228
+ value = alignSelf.value.value;
1147
1229
  break;
1148
1230
  default:
1149
1231
  {
1150
- alignSelf;
1232
+ alignSelf.value;
1151
1233
  }
1152
1234
  }
1153
1235
  if (value && !allowed.has(value)) {
1154
- options.addWarning("value", value);
1236
+ builder.addWarning("value", value);
1155
1237
  return;
1156
1238
  }
1157
1239
  return value;
1158
1240
  }
1159
- function parseFontWeight(fontWeight, options) {
1241
+ export function parseFontWeightDeclaration(declaration, builder) {
1242
+ return parseFontWeight(declaration.value, builder);
1243
+ }
1244
+ export function parseFontWeight(fontWeight, builder) {
1160
1245
  switch (fontWeight.type) {
1161
1246
  case "absolute":
1162
1247
  if (fontWeight.value.type === "weight") {
@@ -1166,7 +1251,7 @@ function parseFontWeight(fontWeight, options) {
1166
1251
  }
1167
1252
  case "bolder":
1168
1253
  case "lighter":
1169
- options.addWarning("value", fontWeight.type);
1254
+ builder.addWarning("value", fontWeight.type);
1170
1255
  return;
1171
1256
  default:
1172
1257
  {
@@ -1175,32 +1260,36 @@ function parseFontWeight(fontWeight, options) {
1175
1260
  }
1176
1261
  return;
1177
1262
  }
1178
- function parseTextShadow(add, [textShadow], options) {
1263
+ export function parseTextShadow(declaration, builder) {
1264
+ const [textShadow] = declaration.value;
1179
1265
  if (!textShadow) {
1180
1266
  return;
1181
1267
  }
1182
- add("style", "textShadowColor", parseColor(textShadow.color, options));
1183
- add("style", "textShadowOffset.width", parseLength(textShadow.xOffset, options));
1184
- add("style", "textShadowOffset.height", parseLength(textShadow.yOffset, options));
1185
- add("style", "textShadowRadius", parseLength(textShadow.blur, options));
1268
+ builder.addDescriptor("textShadowColor", parseColor(textShadow.color, builder));
1269
+ builder.addDescriptor("textShadowOffset.width", parseLength(textShadow.xOffset, builder));
1270
+ builder.addDescriptor("textShadowOffset.height", parseLength(textShadow.yOffset, builder));
1271
+ builder.addDescriptor("textShadowRadius", parseLength(textShadow.blur, builder));
1186
1272
  }
1187
- function parseTextDecorationStyle(textDecorationStyle, options) {
1273
+ export function parseTextDecorationStyle(declaration, builder) {
1188
1274
  const allowed = new Set(["solid", "double", "dotted", "dashed"]);
1189
- if (allowed.has(textDecorationStyle)) {
1190
- return textDecorationStyle;
1275
+ if (allowed.has(declaration.value)) {
1276
+ return declaration.value;
1191
1277
  }
1192
- options.addWarning("value", textDecorationStyle);
1193
- return undefined;
1278
+ builder.addWarning("value", declaration.value);
1279
+ return;
1280
+ }
1281
+ export function parseTextDecorationLineDeclaration(declaration, builder) {
1282
+ return parseTextDecorationLine(declaration.value, builder);
1194
1283
  }
1195
- function parseTextDecorationLine(textDecorationLine, options) {
1196
- if (!Array.isArray(textDecorationLine)) {
1197
- if (textDecorationLine === "none") {
1198
- return textDecorationLine;
1284
+ export function parseTextDecorationLine(value, builder) {
1285
+ if (!Array.isArray(value)) {
1286
+ if (value === "none") {
1287
+ return value;
1199
1288
  }
1200
- options.addWarning("value", textDecorationLine);
1289
+ builder.addWarning("value", value);
1201
1290
  return;
1202
1291
  }
1203
- const set = new Set(textDecorationLine);
1292
+ const set = new Set(value);
1204
1293
  if (set.has("underline")) {
1205
1294
  if (set.has("line-through")) {
1206
1295
  return "underline line-through";
@@ -1210,70 +1299,105 @@ function parseTextDecorationLine(textDecorationLine, options) {
1210
1299
  } else if (set.has("line-through")) {
1211
1300
  return "line-through";
1212
1301
  }
1213
- options.addWarning("value", textDecorationLine.join(" "));
1302
+ builder.addWarning("value", value.join(" "));
1214
1303
  return undefined;
1215
1304
  }
1216
- function parseOverflow(overflow, options) {
1305
+ export function parsePosition({
1306
+ value
1307
+ }, builder) {
1308
+ if (value.type === "absolute" || value.type === "relative") {
1309
+ return value.type;
1310
+ }
1311
+ builder.addWarning("value", value.type);
1312
+ return;
1313
+ }
1314
+ export function parseOverflow({
1315
+ value
1316
+ }, builder) {
1217
1317
  const allowed = new Set(["visible", "hidden"]);
1218
- if (allowed.has(overflow)) {
1219
- return overflow;
1318
+ if (allowed.has(value.x)) {
1319
+ return value.x;
1220
1320
  }
1221
- options.addWarning("value", overflow);
1321
+ builder.addWarning("value", value.x);
1222
1322
  return undefined;
1223
1323
  }
1224
- function parseBorderStyle(borderStyle, options) {
1324
+ export function parseBorderStyleDeclaration(declaration, builder) {
1325
+ return parseBorderStyle(declaration.value, builder);
1326
+ }
1327
+ export function parseBorderStyle(value, builder) {
1225
1328
  const allowed = new Set(["solid", "dotted", "dashed"]);
1226
- if (typeof borderStyle === "string") {
1227
- if (allowed.has(borderStyle)) {
1228
- return borderStyle;
1329
+ if (typeof value === "string") {
1330
+ if (allowed.has(value)) {
1331
+ return value;
1229
1332
  } else {
1230
- options.addWarning("value", borderStyle);
1333
+ builder.addWarning("value", value);
1231
1334
  return undefined;
1232
1335
  }
1233
- } else if (borderStyle.top === borderStyle.bottom && borderStyle.top === borderStyle.left && borderStyle.top === borderStyle.right && allowed.has(borderStyle.top)) {
1234
- return borderStyle.top;
1336
+ } else if (value.top === value.bottom && value.top === value.left && value.top === value.right && allowed.has(value.top)) {
1337
+ return value.top;
1235
1338
  }
1236
- options.addWarning("value", borderStyle.top);
1339
+ builder.addWarning("value", value.top);
1237
1340
  return undefined;
1238
1341
  }
1239
- function parseBorderSideWidth(borderSideWidth, options) {
1240
- if (borderSideWidth.type === "length") {
1241
- return parseLength(borderSideWidth.value, options);
1342
+ export function parseBorderBlockColor({
1343
+ value
1344
+ }, builder) {
1345
+ builder.addDescriptor("border-top-color", parseColor(value.start, builder));
1346
+ builder.addDescriptor("border-bottom-color", parseColor(value.end, builder));
1347
+ return;
1348
+ }
1349
+ export function parseBorderBlockWidth(declaration, builder) {
1350
+ builder.addDescriptor("border-top-width", parseBorderSideWidth(declaration.value.start, builder));
1351
+ builder.addDescriptor("border-bottom-width", parseBorderSideWidth(declaration.value.end, builder));
1352
+ }
1353
+ export function parseBorderSideWidthDeclaration(declaration, builder) {
1354
+ return parseBorderSideWidth(declaration.value, builder);
1355
+ }
1356
+ export function parseBorderSideWidth(value, builder) {
1357
+ if (value.type === "length") {
1358
+ return parseLength(value.value, builder);
1242
1359
  }
1243
- options.addWarning("value", borderSideWidth.type);
1360
+ builder.addWarning("value", value.type);
1244
1361
  return undefined;
1245
1362
  }
1246
- function parseVerticalAlign(verticalAlign, options) {
1247
- if (verticalAlign.type === "length") {
1363
+ export function parseVerticalAlign({
1364
+ value
1365
+ }, builder) {
1366
+ if (value.type === "length") {
1248
1367
  return undefined;
1249
1368
  }
1250
1369
  const allowed = new Set(["auto", "top", "bottom", "middle"]);
1251
- if (allowed.has(verticalAlign.value)) {
1252
- return verticalAlign.value;
1370
+ if (allowed.has(value.value)) {
1371
+ return value.value;
1253
1372
  }
1254
- options.addWarning("value", verticalAlign.value);
1373
+ builder.addWarning("value", value.value);
1255
1374
  return undefined;
1256
1375
  }
1257
- function parseFontFamily(fontFamily) {
1376
+ function parseFontFamily({
1377
+ value
1378
+ }) {
1258
1379
  // React Native only allows one font family - better hope this is the right one :)
1259
- return fontFamily[0];
1380
+ return value[0];
1260
1381
  }
1261
- function parseLineHeight(lineHeight, options) {
1262
- switch (lineHeight.type) {
1382
+ export function parseLineHeightDeclaration(declaration, builder) {
1383
+ return parseLineHeight(declaration.value, builder);
1384
+ }
1385
+ export function parseLineHeight(value, builder) {
1386
+ switch (value.type) {
1263
1387
  case "normal":
1264
1388
  return undefined;
1265
1389
  case "number":
1266
- return [{}, "em", [lineHeight.value], 1];
1390
+ return [{}, "em", [value.value], 1];
1267
1391
  case "length":
1268
1392
  {
1269
- const length = lineHeight.value;
1393
+ const length = value.value;
1270
1394
  switch (length.type) {
1271
1395
  case "dimension":
1272
- return parseLength(length, options);
1396
+ return parseLength(length, builder);
1273
1397
  case "percentage":
1274
1398
  case "calc":
1275
- options.addWarning("value", length.value);
1276
- return undefined;
1399
+ builder.addWarning("value", typeof length.value === "number" ? length.value : JSON.stringify(length.value));
1400
+ return;
1277
1401
  default:
1278
1402
  {
1279
1403
  length;
@@ -1283,218 +1407,173 @@ function parseLineHeight(lineHeight, options) {
1283
1407
  }
1284
1408
  default:
1285
1409
  {
1286
- lineHeight;
1410
+ value;
1287
1411
  }
1288
1412
  }
1289
1413
  return;
1290
1414
  }
1291
- function parseFontSize(fontSize, options) {
1292
- switch (fontSize.type) {
1415
+ export function parseFontSizeDeclaration(declaration, builder) {
1416
+ const fontSize = parseFontSize(declaration.value, builder);
1417
+ builder.addDescriptor("fontSize", fontSize);
1418
+ builder.addDescriptor("--__rn-css-em", fontSize);
1419
+ }
1420
+ export function parseFontSize(value, builder) {
1421
+ switch (value.type) {
1293
1422
  case "length":
1294
- return parseLength(fontSize.value, options);
1423
+ return parseLength(value.value, builder);
1295
1424
  case "absolute":
1296
1425
  case "relative":
1297
- options.addWarning("value", fontSize.value);
1426
+ builder.addWarning("value", value.value);
1298
1427
  return undefined;
1299
1428
  default:
1300
1429
  {
1301
- fontSize;
1430
+ value;
1302
1431
  }
1303
1432
  }
1304
1433
  return;
1305
1434
  }
1306
- function parseFontStyle(fontStyle, options) {
1307
- switch (fontStyle.type) {
1435
+ export function parseFontStyleDeclaration(declaration, builder) {
1436
+ return parseFontStyle(declaration.value, builder);
1437
+ }
1438
+ export function parseFontStyle(value, builder) {
1439
+ switch (value.type) {
1308
1440
  case "normal":
1309
1441
  case "italic":
1310
- return fontStyle.type;
1442
+ return value.type;
1311
1443
  case "oblique":
1312
- options.addWarning("value", fontStyle.type);
1444
+ builder.addWarning("value", value.type);
1313
1445
  return undefined;
1314
1446
  default:
1315
1447
  {
1316
- fontStyle;
1448
+ value;
1317
1449
  }
1318
1450
  }
1319
1451
  return;
1320
1452
  }
1321
- function parseFontVariantCaps(fontVariantCaps, options) {
1453
+ export function parseFontVariantCapsDeclaration(declaration, builder) {
1454
+ return parseFontVariantCaps(declaration.value, builder);
1455
+ }
1456
+ export function parseFontVariantCaps(value, builder) {
1322
1457
  const allowed = new Set(["small-caps", "oldstyle-nums", "lining-nums", "tabular-nums", "proportional-nums"]);
1323
- if (allowed.has(fontVariantCaps)) {
1324
- return fontVariantCaps;
1458
+ if (allowed.has(value)) {
1459
+ return value;
1325
1460
  }
1326
- options.addWarning("value", fontVariantCaps);
1461
+ builder.addWarning("value", value);
1327
1462
  return undefined;
1328
1463
  }
1329
- function parseLengthOrCoercePercentageToRuntime(value, options) {
1330
- return parseLength(value, options);
1464
+ export function parseLengthOrCoercePercentageToRuntime(value, builder) {
1465
+ return parseLength(value, builder);
1331
1466
  }
1332
- function parseGap(value, options) {
1333
- if (value.type === "normal") {
1334
- options.addWarning("value", value.type);
1467
+ export function parseGap(declaration, builder) {
1468
+ if ("column" in declaration.value) {
1469
+ builder.addDescriptor("row-gap", parseGap(declaration, builder));
1470
+ builder.addDescriptor("column-gap", parseGap(declaration, builder));
1335
1471
  return;
1336
- }
1337
- return parseLength(value.value, options);
1338
- }
1339
- function parseRNRuntimeSpecificsFunction(name, args, options) {
1340
- let key;
1341
- const runtimeArgs = {};
1342
- for (const token of args) {
1343
- if (!key) {
1344
- if (token.type === "token" && (token.value.type === "ident" || token.value.type === "number")) {
1345
- key = token.value.value.toString();
1346
- continue;
1347
- }
1348
- } else {
1349
- if (token.type !== "token") {
1350
- const value = parseUnparsed(token, options);
1351
- if (value === undefined) {
1352
- return;
1353
- }
1354
- runtimeArgs[key] = value;
1355
- key = undefined;
1356
- } else {
1357
- switch (token.value.type) {
1358
- case "string":
1359
- case "number":
1360
- case "ident":
1361
- {
1362
- if (key) {
1363
- runtimeArgs[key] = parseUnparsed(token, options);
1364
- key = undefined;
1365
- continue;
1366
- } else {
1367
- return;
1368
- }
1369
- }
1370
- case "delim":
1371
- case "comma":
1372
- continue;
1373
- case "function":
1374
- case "at-keyword":
1375
- case "hash":
1376
- case "id-hash":
1377
- case "unquoted-url":
1378
- case "percentage":
1379
- case "dimension":
1380
- case "white-space":
1381
- case "comment":
1382
- case "colon":
1383
- case "semicolon":
1384
- case "include-match":
1385
- case "dash-match":
1386
- case "prefix-match":
1387
- case "suffix-match":
1388
- case "substring-match":
1389
- case "cdo":
1390
- case "cdc":
1391
- case "parenthesis-block":
1392
- case "square-bracket-block":
1393
- case "curly-bracket-block":
1394
- case "bad-url":
1395
- case "bad-string":
1396
- case "close-parenthesis":
1397
- case "close-square-bracket":
1398
- case "close-curly-bracket":
1399
- return undefined;
1400
- }
1401
- }
1472
+ } else {
1473
+ if (declaration.value.type === "normal") {
1474
+ builder.addWarning("value", declaration.value.type);
1475
+ return;
1402
1476
  }
1477
+ return parseLength(declaration.value.value, builder);
1403
1478
  }
1404
- return [{}, name, Object.entries(runtimeArgs)];
1405
1479
  }
1406
- function parseTextAlign(textAlign, options) {
1480
+ export function parseTextAlign({
1481
+ value
1482
+ }, builder) {
1407
1483
  const allowed = new Set(["auto", "left", "right", "center", "justify"]);
1408
- if (allowed.has(textAlign)) {
1409
- return textAlign;
1484
+ if (allowed.has(value)) {
1485
+ return value;
1410
1486
  }
1411
- options.addWarning("value", textAlign);
1487
+ builder.addWarning("value", value);
1412
1488
  return undefined;
1413
1489
  }
1414
- function parseBoxShadow(boxShadows, options) {
1415
- if (boxShadows.length > 1) {
1416
- options.addWarning("value", "multiple box shadows");
1417
- return;
1418
- }
1419
- const boxShadow = boxShadows[0];
1420
- if (!boxShadow) {
1421
- return;
1490
+ export function parseBoxShadow({
1491
+ value
1492
+ }, builder) {
1493
+ for (const [index, shadow] of value.entries()) {
1494
+ builder.addDescriptor(`boxShadow.[${index}].color`, parseColor(shadow.color, builder));
1495
+ builder.addDescriptor(`boxShadow.[${index}].offsetX`, parseLength(shadow.xOffset, builder));
1496
+ builder.addDescriptor(`boxShadow.[${index}].offsetY`, parseLength(shadow.yOffset, builder));
1497
+ builder.addDescriptor(`boxShadow.[${index}].blurRadius`, parseLength(shadow.blur, builder));
1498
+ builder.addDescriptor(`boxShadow.[${index}].spreadDistance`, parseLength(shadow.spread, builder));
1499
+ builder.addDescriptor(`boxShadow.[${index}].inset`, shadow.inset ? true : undefined);
1422
1500
  }
1423
- options.add("style", "shadowColor", parseColor(boxShadow.color, options));
1424
- options.add("style", "shadowRadius", parseLength(boxShadow.spread, options));
1425
- // options.add("style",
1426
- // ["shadowOffsetWidth"],
1427
- // parseLength(boxShadow.xOffset, options, ["", ""),
1428
- // );
1429
- // options.add("style",
1430
- // ["shadowOffset", "height"],
1431
- // parseLength(boxShadow.yOffset, options),
1432
- // );
1433
- }
1434
- function parseDisplay(display, options) {
1435
- if (display.type === "keyword") {
1436
- if (display.value === "none") {
1437
- return display.value;
1501
+ }
1502
+ export function parseDisplay({
1503
+ value
1504
+ }, builder) {
1505
+ if (value.type === "keyword") {
1506
+ if (value.value === "none") {
1507
+ return value.value;
1438
1508
  } else {
1439
- return options.addWarning("value", display.value);
1509
+ builder.addWarning("value", value.value);
1510
+ return;
1440
1511
  }
1441
- } else if (display.type === "pair") {
1442
- if (display.outside === "block") {
1443
- switch (display.inside.type) {
1512
+ } else {
1513
+ if (value.outside === "block") {
1514
+ switch (value.inside.type) {
1444
1515
  case "flow":
1445
- if (display.isListItem) {
1446
- return options.addWarning("value", "list-item");
1516
+ if (value.isListItem) {
1517
+ builder.addWarning("value", "list-item");
1447
1518
  } else {
1448
- return options.addWarning("value", "block");
1519
+ builder.addWarning("value", "block");
1449
1520
  }
1521
+ return;
1522
+ case "flex":
1523
+ return value.inside.type;
1450
1524
  case "flow-root":
1451
- return options.addWarning("value", "flow-root");
1452
1525
  case "table":
1453
- return options.addWarning("value", display.inside.type);
1454
- case "flex":
1455
- return display.inside.type;
1456
1526
  case "box":
1457
1527
  case "grid":
1458
1528
  case "ruby":
1459
- return options.addWarning("value", display.inside.type);
1529
+ builder.addWarning("value", value.inside.type);
1530
+ return;
1460
1531
  }
1461
1532
  } else {
1462
- switch (display.inside.type) {
1533
+ switch (value.inside.type) {
1463
1534
  case "flow":
1464
- return options.addWarning("value", "inline");
1535
+ builder.addWarning("value", "inline");
1536
+ return;
1465
1537
  case "flow-root":
1466
- return options.addWarning("value", "inline-block");
1538
+ builder.addWarning("value", "inline-block");
1539
+ return;
1467
1540
  case "table":
1468
- return options.addWarning("value", "inline-table");
1541
+ builder.addWarning("value", "inline-table");
1542
+ return;
1469
1543
  case "flex":
1470
- return options.addWarning("value", "inline-flex");
1544
+ builder.addWarning("value", "inline-flex");
1545
+ return;
1471
1546
  case "box":
1472
1547
  case "grid":
1473
- return options.addWarning("value", "inline-grid");
1548
+ builder.addWarning("value", "inline-grid");
1549
+ return;
1474
1550
  case "ruby":
1475
- return options.addWarning("value", display.inside.type);
1551
+ builder.addWarning("value", value.inside.type);
1552
+ return;
1476
1553
  }
1477
1554
  }
1478
1555
  }
1479
- return;
1480
1556
  }
1481
- function parseAspectRatio(
1482
- // This is missing types
1483
- aspectRatio) {
1484
- if (aspectRatio.auto) {
1557
+ export function parseAspectRatio({
1558
+ value
1559
+ }) {
1560
+ if (!value.ratio) {
1561
+ return;
1562
+ } else if (value.auto) {
1485
1563
  return "auto";
1486
1564
  } else {
1487
- if (aspectRatio.ratio[0] === aspectRatio.ratio[1]) {
1565
+ const [width, height] = value.ratio;
1566
+ if (width === height) {
1488
1567
  return 1;
1489
1568
  } else {
1490
- return aspectRatio.ratio.join(" / ");
1569
+ return `${width}/${height}`;
1491
1570
  }
1492
1571
  }
1493
1572
  }
1494
- function parseDimension({
1573
+ export function parseDimension({
1495
1574
  unit,
1496
1575
  value
1497
- }, options) {
1576
+ }, builder) {
1498
1577
  switch (unit) {
1499
1578
  case "px":
1500
1579
  return value;
@@ -1505,40 +1584,46 @@ function parseDimension({
1505
1584
  return [{}, unit, [value / 100], 1];
1506
1585
  default:
1507
1586
  {
1508
- return options.addWarning("value", `${value}${unit}`);
1587
+ builder.addWarning("value", `${value}${unit}`);
1588
+ return;
1509
1589
  }
1510
1590
  }
1511
1591
  }
1512
- function parseUserSelect(value, options) {
1592
+ export function parseUserSelect({
1593
+ value
1594
+ }, builder) {
1513
1595
  const allowed = ["auto", "text", "none", "contain", "all"];
1514
1596
  if (allowed.includes(value)) {
1515
1597
  return value;
1516
1598
  } else {
1517
- return options.addWarning("value", value);
1599
+ builder.addWarning("value", value);
1600
+ return;
1518
1601
  }
1519
1602
  }
1520
- function parseSVGPaint(value, options) {
1603
+ export function parseSVGPaint({
1604
+ value
1605
+ }, builder) {
1521
1606
  if (value.type === "none") {
1522
1607
  return "transparent";
1523
1608
  } else if (value.type === "color") {
1524
- return parseColor(value.value, options);
1609
+ return parseColor(value.value, builder);
1525
1610
  }
1526
1611
  return;
1527
1612
  }
1528
- function round(number) {
1613
+ export function round(number) {
1529
1614
  return Math.round((number + Number.EPSILON) * 100) / 100;
1530
1615
  }
1531
- function parseDimensionPercentageFor_LengthValue(value, options) {
1616
+ export function parseDimensionPercentageFor_LengthValue(value, builder) {
1532
1617
  if (value.type === "calc") {
1533
1618
  return undefined;
1534
1619
  } else if (value.type === "percentage") {
1535
1620
  return `${value.value}%`;
1536
1621
  } else {
1537
- return parseLength(value.value, options);
1622
+ return parseLength(value.value, builder);
1538
1623
  }
1539
1624
  }
1540
1625
  const allowAuto = new Set(["pointer-events"]);
1541
- function parseEnv(value, options) {
1626
+ export function parseEnv(value, builder) {
1542
1627
  switch (value.name.type) {
1543
1628
  case "ua":
1544
1629
  switch (value.name.value) {
@@ -1546,7 +1631,7 @@ function parseEnv(value, options) {
1546
1631
  case "safe-area-inset-right":
1547
1632
  case "safe-area-inset-bottom":
1548
1633
  case "safe-area-inset-left":
1549
- return [{}, "var", [`--react-native-css-${value.name.value}`, parseUnparsed(value.fallback, options)], 1];
1634
+ return [{}, "var", [`--react-native-css-${value.name.value}`, parseUnparsed(value.fallback, builder)], 1];
1550
1635
  case "viewport-segment-width":
1551
1636
  case "viewport-segment-height":
1552
1637
  case "viewport-segment-top":
@@ -1560,28 +1645,28 @@ function parseEnv(value, options) {
1560
1645
  }
1561
1646
  return;
1562
1647
  }
1563
- export function parseCalcFn(name, tokens, options) {
1564
- const args = parseCalcArguments(tokens, options);
1648
+ export function parseCalcFn(name, tokens, builder) {
1649
+ const args = parseCalcArguments(tokens, builder);
1565
1650
  if (args) {
1566
1651
  return [{}, name, args];
1567
1652
  }
1568
1653
  return;
1569
1654
  }
1570
- function parseCalcArguments([...args], options) {
1655
+ export function parseCalcArguments([...args], builder) {
1571
1656
  const parsed = [];
1572
1657
  let mode;
1573
1658
  for (const [currentIndex, arg] of args.entries()) {
1574
1659
  switch (arg.type) {
1575
1660
  case "env":
1576
1661
  {
1577
- parsed.push(parseEnv(arg.value, options));
1662
+ parsed.push(parseEnv(arg.value, builder));
1578
1663
  break;
1579
1664
  }
1580
1665
  case "var":
1581
1666
  case "function":
1582
1667
  case "unresolved-color":
1583
1668
  {
1584
- const value = parseUnparsed(arg, options);
1669
+ const value = parseUnparsed(arg, builder);
1585
1670
  if (value === undefined) {
1586
1671
  return undefined;
1587
1672
  }
@@ -1590,7 +1675,7 @@ function parseCalcArguments([...args], options) {
1590
1675
  }
1591
1676
  case "length":
1592
1677
  {
1593
- const value = parseLength(arg.value, options);
1678
+ const value = parseLength(arg.value, builder);
1594
1679
  if (value !== undefined) {
1595
1680
  parsed.push(value);
1596
1681
  }
@@ -1616,13 +1701,13 @@ function parseCalcArguments([...args], options) {
1616
1701
  }
1617
1702
  break;
1618
1703
  case "percentage":
1619
- if (!mode) mode = "percentage";
1704
+ mode ??= "percentage";
1620
1705
  if (mode !== "percentage") return;
1621
1706
  parsed.push(`${arg.value.value * 100}%`);
1622
1707
  break;
1623
1708
  case "number":
1624
1709
  {
1625
- if (!mode) mode = "number";
1710
+ mode ??= "number";
1626
1711
  if (mode !== "number") return;
1627
1712
  parsed.push(arg.value.value);
1628
1713
  break;
@@ -1635,6 +1720,7 @@ function parseCalcArguments([...args], options) {
1635
1720
  */
1636
1721
  let closeParenthesisIndex = -1;
1637
1722
  for (let index = args.length - 1; index > 0; index--) {
1723
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1638
1724
  const value = args[index];
1639
1725
  if (value.type === "token" && value.value.type === "close-parenthesis") {
1640
1726
  closeParenthesisIndex = index;
@@ -1649,7 +1735,7 @@ function parseCalcArguments([...args], options) {
1649
1735
  .splice(currentIndex, closeParenthesisIndex - currentIndex + 1)
1650
1736
  // Then drop the surrounding parenthesis
1651
1737
  .slice(1, -1);
1652
- parsed.push(parseCalcFn("calc", innerCalcArgs, options));
1738
+ parsed.push(parseCalcFn("calc", innerCalcArgs, builder));
1653
1739
  break;
1654
1740
  }
1655
1741
  case "close-parenthesis":
@@ -1684,37 +1770,38 @@ function parseCalcArguments([...args], options) {
1684
1770
  }
1685
1771
  return parsed;
1686
1772
  }
1687
- export function parseTranslate(translate, prop, options) {
1688
- if (translate === "none") {
1773
+ export function parseTranslateProp(value, prop, builder) {
1774
+ if (value === "none") {
1689
1775
  return 0;
1690
1776
  }
1691
- return parseLength(translate[prop], options);
1777
+ return parseLength(value[prop], builder);
1692
1778
  }
1693
- export function parseScale(translate, prop, options) {
1694
- if (translate === "none") {
1695
- return 0;
1696
- }
1697
- return parseLength(translate[prop], options);
1698
- }
1699
- export function parseUnresolvedColor(color, options) {
1779
+ export function parseUnresolvedColor(color, builder) {
1700
1780
  switch (color.type) {
1701
1781
  case "rgb":
1702
- return [{}, "rgba", [round(color.r * 255), round(color.g * 255), round(color.b * 255), parseUnparsed(color.alpha, options)]];
1782
+ return [{}, "rgba", [round(color.r * 255), round(color.g * 255), round(color.b * 255), parseUnparsed(color.alpha, builder)]];
1703
1783
  case "hsl":
1704
- return [{}, color.type, [color.h, color.s, color.l, parseUnparsed(color.alpha, options)]];
1784
+ return [{}, color.type, [color.h, color.s, color.l, parseUnparsed(color.alpha, builder)]];
1705
1785
  case "light-dark":
1706
- return undefined;
1786
+ {
1787
+ const extraRule = builder.extendRule({
1788
+ m: [["=", "prefers-color-scheme", "dark"]]
1789
+ });
1790
+ builder.addUnnamedDescriptor(reduceParseUnparsed(color.dark, builder), false, extraRule);
1791
+ builder.addExtraRule(extraRule);
1792
+ return reduceParseUnparsed(color.light, builder);
1793
+ }
1707
1794
  default:
1708
1795
  color;
1709
1796
  }
1710
1797
  return;
1711
1798
  }
1712
- function allEqual(...params) {
1799
+ export function allEqual(...params) {
1713
1800
  return params.every((param, index, array) => {
1714
1801
  return index === 0 ? true : equal(array[0], param);
1715
1802
  });
1716
1803
  }
1717
- function equal(a, b) {
1804
+ export function equal(a, b) {
1718
1805
  if (a === b) return true;
1719
1806
  if (typeof a !== typeof b) return false;
1720
1807
  if (a === null || b === null) return false;
@@ -1734,39 +1821,51 @@ function equal(a, b) {
1734
1821
  }
1735
1822
  return false;
1736
1823
  }
1737
- function parseTime(time) {
1824
+ export function parseTime(time) {
1738
1825
  return time.type === "milliseconds" ? time.value : time.value * 1000;
1739
1826
  }
1740
- function addTransitionValue(declaration, options) {
1827
+ export function parseSize2DDimensionPercentageDeclaration(declaration, builder) {
1828
+ return parseSize2DDimensionPercentage(declaration.value, builder);
1829
+ }
1830
+ export function parseSize2DDimensionPercentage(value, builder) {
1831
+ return parseLength(value[0], builder);
1832
+ }
1833
+ export function addTransitionValue(declaration, builder) {
1741
1834
  switch (declaration.property) {
1742
1835
  case "transition":
1743
- const grouped = {};
1744
- for (const animation of declaration.value) {
1745
- for (const [key, value] of Object.entries(animation)) {
1746
- grouped[key] ??= [];
1747
- grouped[key].push(value);
1836
+ {
1837
+ const grouped = {};
1838
+ for (const animation of declaration.value) {
1839
+ for (const [key, value] of Object.entries(animation)) {
1840
+ grouped[key] ??= [];
1841
+ grouped[key].push(value);
1842
+ }
1748
1843
  }
1844
+ for (const [property, value] of Object.entries(grouped)) {
1845
+ addTransitionValue({
1846
+ property: `transition-${kebabCase(property)}`,
1847
+ value
1848
+ }, builder);
1849
+ }
1850
+ break;
1749
1851
  }
1750
- for (const [property, value] of Object.entries(grouped)) {
1751
- addTransitionValue({
1752
- property: `transition-${kebabCase(property)}`,
1753
- value
1754
- }, options);
1755
- }
1756
- break;
1757
1852
  case "transition-property":
1758
1853
  {
1759
- return options.add("transition", declaration.property, declaration.value.map(v => v.property));
1854
+ builder.addDescriptor(declaration.property, declaration.value.map(v => v.property).filter(v => v in parsers || v === "all" || v === "none").map(v => toRNProperty(v)));
1855
+ return;
1760
1856
  }
1761
1857
  case "transition-duration":
1762
- return options.add("transition", declaration.property, declaration.value.map(t => parseTime(t)));
1858
+ builder.addDescriptor(declaration.property, declaration.value.map(t => parseTime(t)));
1859
+ return;
1763
1860
  case "transition-delay":
1764
- return options.add("transition", declaration.property, declaration.value.map(t => parseTime(t)));
1861
+ builder.addDescriptor(declaration.property, declaration.value.map(t => parseTime(t)));
1862
+ return;
1765
1863
  case "transition-timing-function":
1766
- return options.add("transition", declaration.property, parseEasingFunction(declaration.value));
1864
+ builder.addDescriptor(declaration.property, parseEasingFunction(declaration.value));
1865
+ return;
1767
1866
  }
1768
1867
  }
1769
- function addAnimationValue(declaration, options) {
1868
+ export function addAnimationValue(declaration, builder) {
1770
1869
  switch (declaration.property) {
1771
1870
  case "animation":
1772
1871
  {
@@ -1781,54 +1880,135 @@ function addAnimationValue(declaration, options) {
1781
1880
  addAnimationValue({
1782
1881
  property: `animation-${kebabCase(property)}`,
1783
1882
  value
1784
- }, options);
1883
+ }, builder);
1785
1884
  }
1786
1885
  break;
1787
1886
  }
1788
1887
  case "animation-delay":
1789
1888
  {
1790
- options.add("animation", declaration.property, declaration.value.map(t => parseTime(t)));
1889
+ builder.addDescriptor(declaration.property, declaration.value.map(t => parseTime(t)));
1791
1890
  break;
1792
1891
  }
1793
1892
  case "animation-direction":
1794
1893
  {
1795
- options.add("animation", declaration.property, declaration.value);
1894
+ builder.addDescriptor(declaration.property, declaration.value);
1796
1895
  break;
1797
1896
  }
1798
1897
  case "animation-duration":
1799
1898
  {
1800
- options.add("animation", declaration.property, declaration.value.map(t => parseTime(t)));
1899
+ builder.addDescriptor(declaration.property, declaration.value.map(t => parseTime(t)));
1801
1900
  break;
1802
1901
  }
1803
1902
  case "animation-fill-mode":
1804
1903
  {
1805
- options.add("animation", declaration.property, declaration.value);
1904
+ builder.addDescriptor(declaration.property, declaration.value);
1806
1905
  break;
1807
1906
  }
1808
1907
  case "animation-iteration-count":
1809
1908
  {
1810
- options.add("animation", declaration.property, parseIterationCount(declaration.value));
1909
+ builder.addDescriptor(declaration.property, parseIterationCount(declaration.value));
1811
1910
  break;
1812
1911
  }
1813
1912
  case "animation-name":
1814
1913
  {
1815
- options.add("animation", declaration.property, declaration.value.map(v => v.type === "none" ? "none" : [{}, "animationName", [v.value], 1]));
1914
+ builder.addDescriptor(declaration.property, declaration.value.map(v => v.type === "none" ? "none" : [{}, "animationName", [v.value], 1]));
1816
1915
  break;
1817
1916
  }
1818
1917
  case "animation-play-state":
1819
1918
  {
1820
- options.add("animation", declaration.property, declaration.value);
1919
+ builder.addDescriptor(declaration.property, declaration.value);
1821
1920
  break;
1822
1921
  }
1823
1922
  case "animation-timing-function":
1824
1923
  {
1825
- options.add("animation", declaration.property, parseEasingFunction(declaration.value));
1924
+ builder.addDescriptor(declaration.property, parseEasingFunction(declaration.value));
1826
1925
  break;
1827
1926
  }
1828
1927
  }
1829
1928
  }
1830
- function kebabCase(str) {
1929
+ export function kebabCase(str) {
1831
1930
  return str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase());
1832
1931
  }
1833
- const runtimeShorthands = new Set(["animation", "text-shadow", "transform"]);
1932
+ function parseBackgroundImage(declaration, builder) {
1933
+ builder.addDescriptor("experimental_backgroundImage", declaration.value.flatMap(image => {
1934
+ switch (image.type) {
1935
+ case "gradient":
1936
+ {
1937
+ const gradient = parseGradient(image.value, builder);
1938
+ return gradient ? [gradient] : [];
1939
+ }
1940
+ case "none":
1941
+ return ["none"];
1942
+ }
1943
+ return [];
1944
+ }));
1945
+ return;
1946
+ }
1947
+ function parseGradient(gradient, builder) {
1948
+ switch (gradient.type) {
1949
+ case "linear":
1950
+ {
1951
+ return [{}, "@linear-gradient", [parseLineDirection(gradient.direction, builder), ...gradient.items.map(item => parseGradientItem(item, builder))]];
1952
+ }
1953
+ }
1954
+ return;
1955
+ }
1956
+ function parseLineDirection(lineDirection, builder) {
1957
+ switch (lineDirection.type) {
1958
+ case "corner":
1959
+ return `to ${lineDirection.horizontal} ${lineDirection.vertical}`;
1960
+ case "horizontal":
1961
+ case "vertical":
1962
+ return `to ${lineDirection.value}`;
1963
+ case "angle":
1964
+ return parseAngle(lineDirection.value, builder);
1965
+ default:
1966
+ {
1967
+ lineDirection;
1968
+ }
1969
+ }
1970
+ return;
1971
+ }
1972
+ function parseGradientItem(item, builder) {
1973
+ switch (item.type) {
1974
+ case "color-stop":
1975
+ {
1976
+ const args = [parseColor(item.color, builder)];
1977
+ if (item.position) {
1978
+ args.push(parseLength(item.position, builder));
1979
+ }
1980
+ return [{}, "@colorStop", args, 1];
1981
+ }
1982
+ case "hint":
1983
+ return parseLength(item.value, builder);
1984
+ }
1985
+ }
1986
+ function parseFilter(declaration, builder) {
1987
+ if (declaration.value.type === "none") {
1988
+ return "unset";
1989
+ }
1990
+ return declaration.value.value.map(value => {
1991
+ switch (value.type) {
1992
+ case "opacity":
1993
+ case "blur":
1994
+ case "brightness":
1995
+ case "contrast":
1996
+ case "grayscale":
1997
+ case "invert":
1998
+ case "saturate":
1999
+ case "sepia":
2000
+ return {
2001
+ [value.type]: parseLength(value.value, builder)
2002
+ };
2003
+ case "hue-rotate":
2004
+ return {
2005
+ [value.type]: parseAngle(value.value, builder)
2006
+ };
2007
+ case "drop-shadow":
2008
+ case "url":
2009
+ return;
2010
+ }
2011
+ }).filter(value => value !== undefined);
2012
+ }
2013
+ const namedColors = new Set(["aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkgrey", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategrey", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dimgrey", "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "green", "greenyellow", "grey", "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategrey", "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", "whitesmoke", "yellow", "yellowgreen"]);
1834
2014
  //# sourceMappingURL=declarations.js.map