react-native-css 2.1.2 → 3.0.0-nightly.26b272f

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