zyzz 0.0.0 → 0.0.2

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 (678) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +380 -0
  3. package/dist/Config.d.ts +170 -0
  4. package/dist/Config.d.ts.map +1 -0
  5. package/dist/Config.js +249 -0
  6. package/dist/Config.js.map +1 -0
  7. package/dist/Props.d.ts +7 -0
  8. package/dist/Props.d.ts.map +1 -0
  9. package/dist/Props.js +3 -0
  10. package/dist/Props.js.map +1 -0
  11. package/dist/Style.d.ts +167 -0
  12. package/dist/Style.d.ts.map +1 -0
  13. package/dist/Style.js +284 -0
  14. package/dist/Style.js.map +1 -0
  15. package/dist/Theme.d.ts +154 -0
  16. package/dist/Theme.d.ts.map +1 -0
  17. package/dist/Theme.js +257 -0
  18. package/dist/Theme.js.map +1 -0
  19. package/dist/babel/NativeEdits.d.ts +8 -0
  20. package/dist/babel/NativeEdits.d.ts.map +1 -0
  21. package/dist/babel/NativeEdits.js +233 -0
  22. package/dist/babel/NativeEdits.js.map +1 -0
  23. package/dist/babel/NativeJsx.d.ts +10 -0
  24. package/dist/babel/NativeJsx.d.ts.map +1 -0
  25. package/dist/babel/NativeJsx.js +204 -0
  26. package/dist/babel/NativeJsx.js.map +1 -0
  27. package/dist/babel/index.d.ts +51 -0
  28. package/dist/babel/index.d.ts.map +1 -0
  29. package/dist/babel/index.js +220 -0
  30. package/dist/babel/index.js.map +1 -0
  31. package/dist/cli/index.d.ts +3 -0
  32. package/dist/cli/index.d.ts.map +1 -0
  33. package/dist/cli/index.js +178 -0
  34. package/dist/cli/index.js.map +1 -0
  35. package/dist/compiler/Graph.d.ts +64 -0
  36. package/dist/compiler/Graph.d.ts.map +1 -0
  37. package/dist/compiler/Graph.js +1111 -0
  38. package/dist/compiler/Graph.js.map +1 -0
  39. package/dist/compiler/Native.d.ts +53 -0
  40. package/dist/compiler/Native.d.ts.map +1 -0
  41. package/dist/compiler/Native.js +617 -0
  42. package/dist/compiler/Native.js.map +1 -0
  43. package/dist/compiler/Source.d.ts +165 -0
  44. package/dist/compiler/Source.d.ts.map +1 -0
  45. package/dist/compiler/Source.js +990 -0
  46. package/dist/compiler/Source.js.map +1 -0
  47. package/dist/compiler/Transform.d.ts +57 -0
  48. package/dist/compiler/Transform.d.ts.map +1 -0
  49. package/dist/compiler/Transform.js +884 -0
  50. package/dist/compiler/Transform.js.map +1 -0
  51. package/dist/compiler/index.d.ts +13 -0
  52. package/dist/compiler/index.d.ts.map +1 -0
  53. package/dist/compiler/index.js +13 -0
  54. package/dist/compiler/index.js.map +1 -0
  55. package/dist/compiler/internal/Applications.d.ts +35 -0
  56. package/dist/compiler/internal/Applications.d.ts.map +1 -0
  57. package/dist/compiler/internal/Applications.js +248 -0
  58. package/dist/compiler/internal/Applications.js.map +1 -0
  59. package/dist/compiler/internal/AtRules.d.ts +8 -0
  60. package/dist/compiler/internal/AtRules.d.ts.map +1 -0
  61. package/dist/compiler/internal/AtRules.js +180 -0
  62. package/dist/compiler/internal/AtRules.js.map +1 -0
  63. package/dist/compiler/internal/Catalogs.d.ts +19 -0
  64. package/dist/compiler/internal/Catalogs.d.ts.map +1 -0
  65. package/dist/compiler/internal/Catalogs.js +68 -0
  66. package/dist/compiler/internal/Catalogs.js.map +1 -0
  67. package/dist/compiler/internal/ColorProfiles.d.ts +3 -0
  68. package/dist/compiler/internal/ColorProfiles.d.ts.map +1 -0
  69. package/dist/compiler/internal/ColorProfiles.js +84 -0
  70. package/dist/compiler/internal/ColorProfiles.js.map +1 -0
  71. package/dist/compiler/internal/CompositionBindings.d.ts +16 -0
  72. package/dist/compiler/internal/CompositionBindings.d.ts.map +1 -0
  73. package/dist/compiler/internal/CompositionBindings.js +89 -0
  74. package/dist/compiler/internal/CompositionBindings.js.map +1 -0
  75. package/dist/compiler/internal/Compositions.d.ts +32 -0
  76. package/dist/compiler/internal/Compositions.d.ts.map +1 -0
  77. package/dist/compiler/internal/Compositions.js +464 -0
  78. package/dist/compiler/internal/Compositions.js.map +1 -0
  79. package/dist/compiler/internal/Configurations.d.ts +21 -0
  80. package/dist/compiler/internal/Configurations.d.ts.map +1 -0
  81. package/dist/compiler/internal/Configurations.js +171 -0
  82. package/dist/compiler/internal/Configurations.js.map +1 -0
  83. package/dist/compiler/internal/Contract.d.ts +27 -0
  84. package/dist/compiler/internal/Contract.d.ts.map +1 -0
  85. package/dist/compiler/internal/Contract.js +600 -0
  86. package/dist/compiler/internal/Contract.js.map +1 -0
  87. package/dist/compiler/internal/Contributions.d.ts +54 -0
  88. package/dist/compiler/internal/Contributions.d.ts.map +1 -0
  89. package/dist/compiler/internal/Contributions.js +1109 -0
  90. package/dist/compiler/internal/Contributions.js.map +1 -0
  91. package/dist/compiler/internal/Descriptors.d.ts +15 -0
  92. package/dist/compiler/internal/Descriptors.d.ts.map +1 -0
  93. package/dist/compiler/internal/Descriptors.js +183 -0
  94. package/dist/compiler/internal/Descriptors.js.map +1 -0
  95. package/dist/compiler/internal/Dynamic.d.ts +14 -0
  96. package/dist/compiler/internal/Dynamic.d.ts.map +1 -0
  97. package/dist/compiler/internal/Dynamic.js +172 -0
  98. package/dist/compiler/internal/Dynamic.js.map +1 -0
  99. package/dist/compiler/internal/Edits.d.ts +12 -0
  100. package/dist/compiler/internal/Edits.d.ts.map +1 -0
  101. package/dist/compiler/internal/Edits.js +5 -0
  102. package/dist/compiler/internal/Edits.js.map +1 -0
  103. package/dist/compiler/internal/Expression.d.ts +12 -0
  104. package/dist/compiler/internal/Expression.d.ts.map +1 -0
  105. package/dist/compiler/internal/Expression.js +98 -0
  106. package/dist/compiler/internal/Expression.js.map +1 -0
  107. package/dist/compiler/internal/Functions.d.ts +5 -0
  108. package/dist/compiler/internal/Functions.d.ts.map +1 -0
  109. package/dist/compiler/internal/Functions.js +191 -0
  110. package/dist/compiler/internal/Functions.js.map +1 -0
  111. package/dist/compiler/internal/Identifiers.d.ts +9 -0
  112. package/dist/compiler/internal/Identifiers.d.ts.map +1 -0
  113. package/dist/compiler/internal/Identifiers.js +106 -0
  114. package/dist/compiler/internal/Identifiers.js.map +1 -0
  115. package/dist/compiler/internal/Keyframes.d.ts +5 -0
  116. package/dist/compiler/internal/Keyframes.d.ts.map +1 -0
  117. package/dist/compiler/internal/Keyframes.js +51 -0
  118. package/dist/compiler/internal/Keyframes.js.map +1 -0
  119. package/dist/compiler/internal/Namespaces.d.ts +17 -0
  120. package/dist/compiler/internal/Namespaces.d.ts.map +1 -0
  121. package/dist/compiler/internal/Namespaces.js +265 -0
  122. package/dist/compiler/internal/Namespaces.js.map +1 -0
  123. package/dist/compiler/internal/NativeBindings.d.ts +74 -0
  124. package/dist/compiler/internal/NativeBindings.d.ts.map +1 -0
  125. package/dist/compiler/internal/NativeBindings.js +117 -0
  126. package/dist/compiler/internal/NativeBindings.js.map +1 -0
  127. package/dist/compiler/internal/PackedStyles.d.ts +35 -0
  128. package/dist/compiler/internal/PackedStyles.d.ts.map +1 -0
  129. package/dist/compiler/internal/PackedStyles.js +345 -0
  130. package/dist/compiler/internal/PackedStyles.js.map +1 -0
  131. package/dist/compiler/internal/Properties.d.ts +5 -0
  132. package/dist/compiler/internal/Properties.d.ts.map +1 -0
  133. package/dist/compiler/internal/Properties.js +82 -0
  134. package/dist/compiler/internal/Properties.js.map +1 -0
  135. package/dist/compiler/internal/RecipeConditions.d.ts +41 -0
  136. package/dist/compiler/internal/RecipeConditions.d.ts.map +1 -0
  137. package/dist/compiler/internal/RecipeConditions.js +82 -0
  138. package/dist/compiler/internal/RecipeConditions.js.map +1 -0
  139. package/dist/compiler/internal/RecipePayloads.d.ts +31 -0
  140. package/dist/compiler/internal/RecipePayloads.d.ts.map +1 -0
  141. package/dist/compiler/internal/RecipePayloads.js +99 -0
  142. package/dist/compiler/internal/RecipePayloads.js.map +1 -0
  143. package/dist/compiler/internal/Recipes.d.ts +32 -0
  144. package/dist/compiler/internal/Recipes.d.ts.map +1 -0
  145. package/dist/compiler/internal/Recipes.js +339 -0
  146. package/dist/compiler/internal/Recipes.js.map +1 -0
  147. package/dist/compiler/internal/Relative.d.ts +19 -0
  148. package/dist/compiler/internal/Relative.d.ts.map +1 -0
  149. package/dist/compiler/internal/Relative.js +62 -0
  150. package/dist/compiler/internal/Relative.js.map +1 -0
  151. package/dist/compiler/internal/Scope.d.ts +10 -0
  152. package/dist/compiler/internal/Scope.d.ts.map +1 -0
  153. package/dist/compiler/internal/Scope.js +28 -0
  154. package/dist/compiler/internal/Scope.js.map +1 -0
  155. package/dist/compiler/internal/Selectors.d.ts +12 -0
  156. package/dist/compiler/internal/Selectors.d.ts.map +1 -0
  157. package/dist/compiler/internal/Selectors.js +265 -0
  158. package/dist/compiler/internal/Selectors.js.map +1 -0
  159. package/dist/compiler/internal/Static.d.ts +39 -0
  160. package/dist/compiler/internal/Static.d.ts.map +1 -0
  161. package/dist/compiler/internal/Static.js +532 -0
  162. package/dist/compiler/internal/Static.js.map +1 -0
  163. package/dist/compiler/internal/Stylesheets.d.ts +47 -0
  164. package/dist/compiler/internal/Stylesheets.d.ts.map +1 -0
  165. package/dist/compiler/internal/Stylesheets.js +272 -0
  166. package/dist/compiler/internal/Stylesheets.js.map +1 -0
  167. package/dist/compiler/internal/Syntax.d.ts +17 -0
  168. package/dist/compiler/internal/Syntax.d.ts.map +1 -0
  169. package/dist/compiler/internal/Syntax.js +19 -0
  170. package/dist/compiler/internal/Syntax.js.map +1 -0
  171. package/dist/compiler/internal/Themes.d.ts +158 -0
  172. package/dist/compiler/internal/Themes.d.ts.map +1 -0
  173. package/dist/compiler/internal/Themes.js +1169 -0
  174. package/dist/compiler/internal/Themes.js.map +1 -0
  175. package/dist/compiler/internal/Variables.d.ts +31 -0
  176. package/dist/compiler/internal/Variables.d.ts.map +1 -0
  177. package/dist/compiler/internal/Variables.js +376 -0
  178. package/dist/compiler/internal/Variables.js.map +1 -0
  179. package/dist/compiler/internal/ViewTransitions.d.ts +3 -0
  180. package/dist/compiler/internal/ViewTransitions.d.ts.map +1 -0
  181. package/dist/compiler/internal/ViewTransitions.js +68 -0
  182. package/dist/compiler/internal/ViewTransitions.js.map +1 -0
  183. package/dist/cx.d.ts +18 -0
  184. package/dist/cx.d.ts.map +1 -0
  185. package/dist/cx.js +60 -0
  186. package/dist/cx.js.map +1 -0
  187. package/dist/default.d.ts +2008 -0
  188. package/dist/default.d.ts.map +1 -0
  189. package/dist/default.js +243 -0
  190. package/dist/default.js.map +7 -0
  191. package/dist/default.js.zyzz.json +1 -0
  192. package/dist/index.d.ts +21 -0
  193. package/dist/index.d.ts.map +1 -0
  194. package/dist/index.js +19 -0
  195. package/dist/index.js.map +1 -0
  196. package/dist/internal/Authoring.d.ts +26 -0
  197. package/dist/internal/Authoring.d.ts.map +1 -0
  198. package/dist/internal/Authoring.js +134 -0
  199. package/dist/internal/Authoring.js.map +1 -0
  200. package/dist/internal/Binding.d.ts +64 -0
  201. package/dist/internal/Binding.d.ts.map +1 -0
  202. package/dist/internal/Binding.js +27 -0
  203. package/dist/internal/Binding.js.map +1 -0
  204. package/dist/internal/BindingDomains.d.ts +11 -0
  205. package/dist/internal/BindingDomains.d.ts.map +1 -0
  206. package/dist/internal/BindingDomains.js +459 -0
  207. package/dist/internal/BindingDomains.js.map +1 -0
  208. package/dist/internal/Cascade.d.ts +45 -0
  209. package/dist/internal/Cascade.d.ts.map +1 -0
  210. package/dist/internal/Cascade.js +165 -0
  211. package/dist/internal/Cascade.js.map +1 -0
  212. package/dist/internal/Compound.d.ts +132 -0
  213. package/dist/internal/Compound.d.ts.map +1 -0
  214. package/dist/internal/Compound.js +2 -0
  215. package/dist/internal/Compound.js.map +1 -0
  216. package/dist/internal/Condition.d.ts +33 -0
  217. package/dist/internal/Condition.d.ts.map +1 -0
  218. package/dist/internal/Condition.js +180 -0
  219. package/dist/internal/Condition.js.map +1 -0
  220. package/dist/internal/Corner.d.ts +9 -0
  221. package/dist/internal/Corner.d.ts.map +1 -0
  222. package/dist/internal/Corner.js +14 -0
  223. package/dist/internal/Corner.js.map +1 -0
  224. package/dist/internal/FunctionSyntax.d.ts +27 -0
  225. package/dist/internal/FunctionSyntax.d.ts.map +1 -0
  226. package/dist/internal/FunctionSyntax.js +91 -0
  227. package/dist/internal/FunctionSyntax.js.map +1 -0
  228. package/dist/internal/FunctionValue.d.ts +19 -0
  229. package/dist/internal/FunctionValue.d.ts.map +1 -0
  230. package/dist/internal/FunctionValue.js +2 -0
  231. package/dist/internal/FunctionValue.js.map +1 -0
  232. package/dist/internal/Geometry.d.ts +8 -0
  233. package/dist/internal/Geometry.d.ts.map +1 -0
  234. package/dist/internal/Geometry.js +2 -0
  235. package/dist/internal/Geometry.js.map +1 -0
  236. package/dist/internal/Grid.d.ts +15 -0
  237. package/dist/internal/Grid.d.ts.map +1 -0
  238. package/dist/internal/Grid.js +2 -0
  239. package/dist/internal/Grid.js.map +1 -0
  240. package/dist/internal/Identifier.d.ts +15 -0
  241. package/dist/internal/Identifier.d.ts.map +1 -0
  242. package/dist/internal/Identifier.js +2 -0
  243. package/dist/internal/Identifier.js.map +1 -0
  244. package/dist/internal/Identity.d.ts +16 -0
  245. package/dist/internal/Identity.d.ts.map +1 -0
  246. package/dist/internal/Identity.js +78 -0
  247. package/dist/internal/Identity.js.map +1 -0
  248. package/dist/internal/Lexical.d.ts +89 -0
  249. package/dist/internal/Lexical.d.ts.map +1 -0
  250. package/dist/internal/Lexical.js +15 -0
  251. package/dist/internal/Lexical.js.map +1 -0
  252. package/dist/internal/Literal.d.ts +3459 -0
  253. package/dist/internal/Literal.d.ts.map +1 -0
  254. package/dist/internal/Literal.js +3371 -0
  255. package/dist/internal/Literal.js.map +1 -0
  256. package/dist/internal/NativeProperties.d.ts +596 -0
  257. package/dist/internal/NativeProperties.d.ts.map +1 -0
  258. package/dist/internal/NativeProperties.js +2 -0
  259. package/dist/internal/NativeProperties.js.map +1 -0
  260. package/dist/internal/Numeric.d.ts +23 -0
  261. package/dist/internal/Numeric.d.ts.map +1 -0
  262. package/dist/internal/Numeric.js +2 -0
  263. package/dist/internal/Numeric.js.map +1 -0
  264. package/dist/internal/Query.d.ts +15 -0
  265. package/dist/internal/Query.d.ts.map +1 -0
  266. package/dist/internal/Query.js +58 -0
  267. package/dist/internal/Query.js.map +1 -0
  268. package/dist/internal/Recipe.d.ts +17 -0
  269. package/dist/internal/Recipe.d.ts.map +1 -0
  270. package/dist/internal/Recipe.js +2 -0
  271. package/dist/internal/Recipe.js.map +1 -0
  272. package/dist/internal/RuleReference.d.ts +23 -0
  273. package/dist/internal/RuleReference.d.ts.map +1 -0
  274. package/dist/internal/RuleReference.js +65 -0
  275. package/dist/internal/RuleReference.js.map +1 -0
  276. package/dist/internal/Scheme.d.ts +12 -0
  277. package/dist/internal/Scheme.d.ts.map +1 -0
  278. package/dist/internal/Scheme.js +16 -0
  279. package/dist/internal/Scheme.js.map +1 -0
  280. package/dist/internal/Shorthands.d.ts +20 -0
  281. package/dist/internal/Shorthands.d.ts.map +1 -0
  282. package/dist/internal/Shorthands.js +49 -0
  283. package/dist/internal/Shorthands.js.map +1 -0
  284. package/dist/internal/Targets.d.ts +43 -0
  285. package/dist/internal/Targets.d.ts.map +1 -0
  286. package/dist/internal/Targets.js +60 -0
  287. package/dist/internal/Targets.js.map +1 -0
  288. package/dist/internal/Token.d.ts +104 -0
  289. package/dist/internal/Token.d.ts.map +1 -0
  290. package/dist/internal/Token.js +162 -0
  291. package/dist/internal/Token.js.map +1 -0
  292. package/dist/internal/Tuple.d.ts +23 -0
  293. package/dist/internal/Tuple.d.ts.map +1 -0
  294. package/dist/internal/Tuple.js +2 -0
  295. package/dist/internal/Tuple.js.map +1 -0
  296. package/dist/internal/Value.d.ts +74 -0
  297. package/dist/internal/Value.d.ts.map +1 -0
  298. package/dist/internal/Value.js +60 -0
  299. package/dist/internal/Value.js.map +1 -0
  300. package/dist/metro/Graph.d.ts +8 -0
  301. package/dist/metro/Graph.d.ts.map +1 -0
  302. package/dist/metro/Graph.js +63 -0
  303. package/dist/metro/Graph.js.map +1 -0
  304. package/dist/metro/Watch.d.ts +21 -0
  305. package/dist/metro/Watch.d.ts.map +1 -0
  306. package/dist/metro/Watch.js +51 -0
  307. package/dist/metro/Watch.js.map +1 -0
  308. package/dist/metro/index.d.ts +30 -0
  309. package/dist/metro/index.d.ts.map +1 -0
  310. package/dist/metro/index.js +52 -0
  311. package/dist/metro/index.js.map +1 -0
  312. package/dist/metro/transformer.d.ts +21 -0
  313. package/dist/metro/transformer.d.ts.map +1 -0
  314. package/dist/metro/transformer.js +71 -0
  315. package/dist/metro/transformer.js.map +1 -0
  316. package/dist/next/index.d.ts +18 -0
  317. package/dist/next/index.d.ts.map +1 -0
  318. package/dist/next/index.js +92 -0
  319. package/dist/next/index.js.map +1 -0
  320. package/dist/next/loader.d.ts +16 -0
  321. package/dist/next/loader.d.ts.map +1 -0
  322. package/dist/next/loader.js +282 -0
  323. package/dist/next/loader.js.map +1 -0
  324. package/dist/node/Host.d.ts +80 -0
  325. package/dist/node/Host.d.ts.map +1 -0
  326. package/dist/node/Host.js +882 -0
  327. package/dist/node/Host.js.map +1 -0
  328. package/dist/node/index.d.ts +7 -0
  329. package/dist/node/index.d.ts.map +1 -0
  330. package/dist/node/index.js +7 -0
  331. package/dist/node/index.js.map +1 -0
  332. package/dist/react-native/Host.d.ts +76 -0
  333. package/dist/react-native/Host.d.ts.map +1 -0
  334. package/dist/react-native/Host.js +209 -0
  335. package/dist/react-native/Host.js.map +1 -0
  336. package/dist/react-native/StyleSheet.d.ts +226 -0
  337. package/dist/react-native/StyleSheet.d.ts.map +1 -0
  338. package/dist/react-native/StyleSheet.js +606 -0
  339. package/dist/react-native/StyleSheet.js.map +1 -0
  340. package/dist/react-native/Variants.d.ts +38 -0
  341. package/dist/react-native/Variants.d.ts.map +1 -0
  342. package/dist/react-native/Variants.js +66 -0
  343. package/dist/react-native/Variants.js.map +1 -0
  344. package/dist/react-native/index.d.ts +8 -0
  345. package/dist/react-native/index.d.ts.map +1 -0
  346. package/dist/react-native/index.js +8 -0
  347. package/dist/react-native/index.js.map +1 -0
  348. package/dist/react-native/internal/Color.d.ts +7 -0
  349. package/dist/react-native/internal/Color.d.ts.map +1 -0
  350. package/dist/react-native/internal/Color.js +93 -0
  351. package/dist/react-native/internal/Color.js.map +1 -0
  352. package/dist/react-native/internal/NativeSchema.d.ts +5138 -0
  353. package/dist/react-native/internal/NativeSchema.d.ts.map +1 -0
  354. package/dist/react-native/internal/NativeSchema.js +3097 -0
  355. package/dist/react-native/internal/NativeSchema.js.map +1 -0
  356. package/dist/react-native/internal/Scalar.d.ts +95 -0
  357. package/dist/react-native/internal/Scalar.d.ts.map +1 -0
  358. package/dist/react-native/internal/Scalar.js +199 -0
  359. package/dist/react-native/internal/Scalar.js.map +1 -0
  360. package/dist/react-native/internal/Values.d.ts +5 -0
  361. package/dist/react-native/internal/Values.d.ts.map +1 -0
  362. package/dist/react-native/internal/Values.js +65 -0
  363. package/dist/react-native/internal/Values.js.map +1 -0
  364. package/dist/react-native/react.d.ts +22 -0
  365. package/dist/react-native/react.d.ts.map +1 -0
  366. package/dist/react-native/react.js +26 -0
  367. package/dist/react-native/react.js.map +1 -0
  368. package/dist/reset.css +244 -0
  369. package/dist/runtime/Appearance.d.ts +55 -0
  370. package/dist/runtime/Appearance.d.ts.map +1 -0
  371. package/dist/runtime/Appearance.js +84 -0
  372. package/dist/runtime/Appearance.js.map +1 -0
  373. package/dist/runtime/Composition.d.ts +46 -0
  374. package/dist/runtime/Composition.d.ts.map +1 -0
  375. package/dist/runtime/Composition.js +52 -0
  376. package/dist/runtime/Composition.js.map +1 -0
  377. package/dist/runtime/CompositionHtml.d.ts +15 -0
  378. package/dist/runtime/CompositionHtml.d.ts.map +1 -0
  379. package/dist/runtime/CompositionHtml.js +20 -0
  380. package/dist/runtime/CompositionHtml.js.map +1 -0
  381. package/dist/runtime/ConditionalRecipe.d.ts +30 -0
  382. package/dist/runtime/ConditionalRecipe.d.ts.map +1 -0
  383. package/dist/runtime/ConditionalRecipe.js +39 -0
  384. package/dist/runtime/ConditionalRecipe.js.map +1 -0
  385. package/dist/runtime/Dynamic.d.ts +19 -0
  386. package/dist/runtime/Dynamic.d.ts.map +1 -0
  387. package/dist/runtime/Dynamic.js +22 -0
  388. package/dist/runtime/Dynamic.js.map +1 -0
  389. package/dist/runtime/Html.d.ts +32 -0
  390. package/dist/runtime/Html.d.ts.map +1 -0
  391. package/dist/runtime/Html.js +63 -0
  392. package/dist/runtime/Html.js.map +1 -0
  393. package/dist/runtime/Native.d.ts +48 -0
  394. package/dist/runtime/Native.d.ts.map +1 -0
  395. package/dist/runtime/Native.js +78 -0
  396. package/dist/runtime/Native.js.map +1 -0
  397. package/dist/runtime/NativeContext.d.ts +17 -0
  398. package/dist/runtime/NativeContext.d.ts.map +1 -0
  399. package/dist/runtime/NativeContext.js +47 -0
  400. package/dist/runtime/NativeContext.js.map +1 -0
  401. package/dist/runtime/NativeDynamic.d.ts +47 -0
  402. package/dist/runtime/NativeDynamic.d.ts.map +1 -0
  403. package/dist/runtime/NativeDynamic.js +141 -0
  404. package/dist/runtime/NativeDynamic.js.map +1 -0
  405. package/dist/runtime/PayloadRecipe.d.ts +22 -0
  406. package/dist/runtime/PayloadRecipe.d.ts.map +1 -0
  407. package/dist/runtime/PayloadRecipe.js +59 -0
  408. package/dist/runtime/PayloadRecipe.js.map +1 -0
  409. package/dist/runtime/Props.d.ts +21 -0
  410. package/dist/runtime/Props.d.ts.map +1 -0
  411. package/dist/runtime/Props.js +17 -0
  412. package/dist/runtime/Props.js.map +1 -0
  413. package/dist/runtime/Recipe.d.ts +52 -0
  414. package/dist/runtime/Recipe.d.ts.map +1 -0
  415. package/dist/runtime/Recipe.js +30 -0
  416. package/dist/runtime/Recipe.js.map +1 -0
  417. package/dist/runtime/Selection.d.ts +31 -0
  418. package/dist/runtime/Selection.d.ts.map +1 -0
  419. package/dist/runtime/Selection.js +30 -0
  420. package/dist/runtime/Selection.js.map +1 -0
  421. package/dist/runtime/Variable.d.ts +6 -0
  422. package/dist/runtime/Variable.d.ts.map +1 -0
  423. package/dist/runtime/Variable.js +10 -0
  424. package/dist/runtime/Variable.js.map +1 -0
  425. package/dist/runtime/index.d.ts +33 -0
  426. package/dist/runtime/index.d.ts.map +1 -0
  427. package/dist/runtime/index.js +33 -0
  428. package/dist/runtime/index.js.map +1 -0
  429. package/dist/styleFunction.d.ts +72 -0
  430. package/dist/styleFunction.d.ts.map +1 -0
  431. package/dist/styleFunction.js +18 -0
  432. package/dist/styleFunction.js.map +1 -0
  433. package/dist/themes/LICENSE.tailwind +21 -0
  434. package/dist/variable.d.ts +50 -0
  435. package/dist/variable.d.ts.map +1 -0
  436. package/dist/variable.js +20 -0
  437. package/dist/variable.js.map +1 -0
  438. package/dist/variants.d.ts +84 -0
  439. package/dist/variants.d.ts.map +1 -0
  440. package/dist/variants.js +21 -0
  441. package/dist/variants.js.map +1 -0
  442. package/dist/vite/index.d.ts +24 -0
  443. package/dist/vite/index.d.ts.map +1 -0
  444. package/dist/vite/index.js +1089 -0
  445. package/dist/vite/index.js.map +1 -0
  446. package/dist/web/Css.d.ts +81 -0
  447. package/dist/web/Css.d.ts.map +1 -0
  448. package/dist/web/Css.js +593 -0
  449. package/dist/web/Css.js.map +1 -0
  450. package/dist/web/colorProfile.d.ts +28 -0
  451. package/dist/web/colorProfile.d.ts.map +1 -0
  452. package/dist/web/colorProfile.js +8 -0
  453. package/dist/web/colorProfile.js.map +1 -0
  454. package/dist/web/counterStyle.d.ts +48 -0
  455. package/dist/web/counterStyle.d.ts.map +1 -0
  456. package/dist/web/counterStyle.js +8 -0
  457. package/dist/web/counterStyle.js.map +1 -0
  458. package/dist/web/cssFunction.d.ts +80 -0
  459. package/dist/web/cssFunction.d.ts.map +1 -0
  460. package/dist/web/cssFunction.js +18 -0
  461. package/dist/web/cssFunction.js.map +1 -0
  462. package/dist/web/customMedia.d.ts +12 -0
  463. package/dist/web/customMedia.d.ts.map +1 -0
  464. package/dist/web/customMedia.js +7 -0
  465. package/dist/web/customMedia.js.map +1 -0
  466. package/dist/web/fontFace.d.ts +26 -0
  467. package/dist/web/fontFace.d.ts.map +1 -0
  468. package/dist/web/fontFace.js +7 -0
  469. package/dist/web/fontFace.js.map +1 -0
  470. package/dist/web/fontFeatureValues.d.ts +40 -0
  471. package/dist/web/fontFeatureValues.d.ts.map +1 -0
  472. package/dist/web/fontFeatureValues.js +7 -0
  473. package/dist/web/fontFeatureValues.js.map +1 -0
  474. package/dist/web/fontPaletteValues.d.ts +21 -0
  475. package/dist/web/fontPaletteValues.d.ts.map +1 -0
  476. package/dist/web/fontPaletteValues.js +9 -0
  477. package/dist/web/fontPaletteValues.js.map +1 -0
  478. package/dist/web/global.d.ts +19 -0
  479. package/dist/web/global.d.ts.map +1 -0
  480. package/dist/web/global.js +6 -0
  481. package/dist/web/global.js.map +1 -0
  482. package/dist/web/importCss.d.ts +18 -0
  483. package/dist/web/importCss.d.ts.map +1 -0
  484. package/dist/web/importCss.js +7 -0
  485. package/dist/web/importCss.js.map +1 -0
  486. package/dist/web/index.d.ts +22 -0
  487. package/dist/web/index.d.ts.map +1 -0
  488. package/dist/web/index.js +22 -0
  489. package/dist/web/index.js.map +1 -0
  490. package/dist/web/internal/Block.d.ts +18 -0
  491. package/dist/web/internal/Block.d.ts.map +1 -0
  492. package/dist/web/internal/Block.js +13 -0
  493. package/dist/web/internal/Block.js.map +1 -0
  494. package/dist/web/internal/ClassName.d.ts +19 -0
  495. package/dist/web/internal/ClassName.d.ts.map +1 -0
  496. package/dist/web/internal/ClassName.js +77 -0
  497. package/dist/web/internal/ClassName.js.map +1 -0
  498. package/dist/web/internal/Context.d.ts +11 -0
  499. package/dist/web/internal/Context.d.ts.map +1 -0
  500. package/dist/web/internal/Context.js +2 -0
  501. package/dist/web/internal/Context.js.map +1 -0
  502. package/dist/web/internal/Contributions.d.ts +70 -0
  503. package/dist/web/internal/Contributions.d.ts.map +1 -0
  504. package/dist/web/internal/Contributions.js +109 -0
  505. package/dist/web/internal/Contributions.js.map +1 -0
  506. package/dist/web/internal/Namespace.d.ts +13 -0
  507. package/dist/web/internal/Namespace.d.ts.map +1 -0
  508. package/dist/web/internal/Namespace.js +13 -0
  509. package/dist/web/internal/Namespace.js.map +1 -0
  510. package/dist/web/internal/Themes.d.ts +13 -0
  511. package/dist/web/internal/Themes.d.ts.map +1 -0
  512. package/dist/web/internal/Themes.js +96 -0
  513. package/dist/web/internal/Themes.js.map +1 -0
  514. package/dist/web/keyframes.d.ts +14 -0
  515. package/dist/web/keyframes.d.ts.map +1 -0
  516. package/dist/web/keyframes.js +8 -0
  517. package/dist/web/keyframes.js.map +1 -0
  518. package/dist/web/layers.d.ts +4 -0
  519. package/dist/web/layers.d.ts.map +1 -0
  520. package/dist/web/layers.js +7 -0
  521. package/dist/web/layers.js.map +1 -0
  522. package/dist/web/namespace.d.ts +14 -0
  523. package/dist/web/namespace.d.ts.map +1 -0
  524. package/dist/web/namespace.js +7 -0
  525. package/dist/web/namespace.js.map +1 -0
  526. package/dist/web/page.d.ts +38 -0
  527. package/dist/web/page.d.ts.map +1 -0
  528. package/dist/web/page.js +7 -0
  529. package/dist/web/page.js.map +1 -0
  530. package/dist/web/positionTry.d.ts +14 -0
  531. package/dist/web/positionTry.d.ts.map +1 -0
  532. package/dist/web/positionTry.js +9 -0
  533. package/dist/web/positionTry.js.map +1 -0
  534. package/dist/web/property.d.ts +24 -0
  535. package/dist/web/property.d.ts.map +1 -0
  536. package/dist/web/property.js +7 -0
  537. package/dist/web/property.js.map +1 -0
  538. package/dist/web/viewTransition.d.ts +29 -0
  539. package/dist/web/viewTransition.d.ts.map +1 -0
  540. package/dist/web/viewTransition.js +7 -0
  541. package/dist/web/viewTransition.js.map +1 -0
  542. package/package.json +136 -10
  543. package/src/Config.ts +690 -0
  544. package/src/Props.ts +8 -0
  545. package/src/Style.ts +748 -0
  546. package/src/Theme.ts +713 -0
  547. package/src/babel/NativeEdits.ts +273 -0
  548. package/src/babel/NativeJsx.ts +260 -0
  549. package/src/babel/index.ts +332 -0
  550. package/src/cli/index.ts +196 -0
  551. package/src/compiler/Graph.ts +1586 -0
  552. package/src/compiler/Native.ts +801 -0
  553. package/src/compiler/Source.ts +1550 -0
  554. package/src/compiler/Transform.ts +1235 -0
  555. package/src/compiler/index.ts +12 -0
  556. package/src/compiler/internal/Applications.ts +378 -0
  557. package/src/compiler/internal/AtRules.ts +202 -0
  558. package/src/compiler/internal/Catalogs.ts +114 -0
  559. package/src/compiler/internal/ColorProfiles.ts +93 -0
  560. package/src/compiler/internal/CompositionBindings.ts +120 -0
  561. package/src/compiler/internal/Compositions.ts +629 -0
  562. package/src/compiler/internal/Configurations.ts +244 -0
  563. package/src/compiler/internal/Contract.ts +846 -0
  564. package/src/compiler/internal/Contributions.ts +1507 -0
  565. package/src/compiler/internal/Descriptors.ts +238 -0
  566. package/src/compiler/internal/Dynamic.ts +266 -0
  567. package/src/compiler/internal/Edits.ts +13 -0
  568. package/src/compiler/internal/Expression.ts +135 -0
  569. package/src/compiler/internal/Functions.ts +206 -0
  570. package/src/compiler/internal/Identifiers.ts +124 -0
  571. package/src/compiler/internal/Keyframes.ts +62 -0
  572. package/src/compiler/internal/Namespaces.ts +296 -0
  573. package/src/compiler/internal/NativeBindings.ts +151 -0
  574. package/src/compiler/internal/PackedStyles.ts +464 -0
  575. package/src/compiler/internal/Properties.ts +121 -0
  576. package/src/compiler/internal/RecipeConditions.ts +139 -0
  577. package/src/compiler/internal/RecipePayloads.ts +132 -0
  578. package/src/compiler/internal/Recipes.ts +531 -0
  579. package/src/compiler/internal/Relative.ts +87 -0
  580. package/src/compiler/internal/Scope.ts +36 -0
  581. package/src/compiler/internal/Selectors.ts +334 -0
  582. package/src/compiler/internal/Static.ts +783 -0
  583. package/src/compiler/internal/Stylesheets.ts +361 -0
  584. package/src/compiler/internal/Syntax.ts +31 -0
  585. package/src/compiler/internal/Themes.ts +1794 -0
  586. package/src/compiler/internal/Variables.ts +497 -0
  587. package/src/compiler/internal/ViewTransitions.ts +82 -0
  588. package/src/cx.ts +98 -0
  589. package/src/default.ts +484 -0
  590. package/src/index.ts +20 -0
  591. package/src/internal/Authoring.ts +199 -0
  592. package/src/internal/Binding.ts +187 -0
  593. package/src/internal/BindingDomains.ts +458 -0
  594. package/src/internal/Cascade.ts +165 -0
  595. package/src/internal/Compound.ts +522 -0
  596. package/src/internal/Condition.ts +283 -0
  597. package/src/internal/Corner.ts +17 -0
  598. package/src/internal/FunctionSyntax.ts +271 -0
  599. package/src/internal/FunctionValue.ts +96 -0
  600. package/src/internal/Geometry.ts +30 -0
  601. package/src/internal/Grid.ts +67 -0
  602. package/src/internal/Identifier.ts +14 -0
  603. package/src/internal/Identity.ts +89 -0
  604. package/src/internal/Lexical.ts +202 -0
  605. package/src/internal/Literal.ts +3820 -0
  606. package/src/internal/NativeProperties.ts +936 -0
  607. package/src/internal/Numeric.ts +77 -0
  608. package/src/internal/Query.ts +87 -0
  609. package/src/internal/Recipe.ts +17 -0
  610. package/src/internal/RuleReference.ts +102 -0
  611. package/src/internal/Scheme.ts +20 -0
  612. package/src/internal/Shorthands.ts +120 -0
  613. package/src/internal/Targets.ts +162 -0
  614. package/src/internal/Token.ts +380 -0
  615. package/src/internal/Tuple.ts +29 -0
  616. package/src/internal/Value.ts +320 -0
  617. package/src/metro/Graph.ts +78 -0
  618. package/src/metro/Watch.ts +88 -0
  619. package/src/metro/index.ts +99 -0
  620. package/src/metro/transformer.ts +97 -0
  621. package/src/next/index.ts +114 -0
  622. package/src/next/loader.ts +369 -0
  623. package/src/node/Host.ts +1204 -0
  624. package/src/node/index.ts +6 -0
  625. package/src/react-native/Host.ts +289 -0
  626. package/src/react-native/StyleSheet.ts +1084 -0
  627. package/src/react-native/Variants.ts +122 -0
  628. package/src/react-native/index.ts +7 -0
  629. package/src/react-native/internal/Color.ts +110 -0
  630. package/src/react-native/internal/NativeSchema.ts +3096 -0
  631. package/src/react-native/internal/Scalar.ts +253 -0
  632. package/src/react-native/internal/Values.ts +87 -0
  633. package/src/react-native/react.ts +47 -0
  634. package/src/reset.css +244 -0
  635. package/src/runtime/Appearance.ts +155 -0
  636. package/src/runtime/Composition.ts +87 -0
  637. package/src/runtime/CompositionHtml.ts +38 -0
  638. package/src/runtime/ConditionalRecipe.ts +70 -0
  639. package/src/runtime/Dynamic.ts +51 -0
  640. package/src/runtime/Html.ts +91 -0
  641. package/src/runtime/Native.ts +144 -0
  642. package/src/runtime/NativeContext.ts +74 -0
  643. package/src/runtime/NativeDynamic.ts +246 -0
  644. package/src/runtime/PayloadRecipe.ts +96 -0
  645. package/src/runtime/Props.ts +33 -0
  646. package/src/runtime/Recipe.ts +74 -0
  647. package/src/runtime/Selection.ts +82 -0
  648. package/src/runtime/Variable.ts +15 -0
  649. package/src/runtime/index.ts +45 -0
  650. package/src/styleFunction.ts +138 -0
  651. package/src/themes/LICENSE.tailwind +21 -0
  652. package/src/variable.ts +105 -0
  653. package/src/variants.ts +218 -0
  654. package/src/vite/index.ts +1473 -0
  655. package/src/web/Css.ts +801 -0
  656. package/src/web/colorProfile.ts +60 -0
  657. package/src/web/counterStyle.ts +82 -0
  658. package/src/web/cssFunction.ts +181 -0
  659. package/src/web/customMedia.ts +16 -0
  660. package/src/web/fontFace.ts +41 -0
  661. package/src/web/fontFeatureValues.ts +79 -0
  662. package/src/web/fontPaletteValues.ts +42 -0
  663. package/src/web/global.ts +39 -0
  664. package/src/web/importCss.ts +23 -0
  665. package/src/web/index.ts +22 -0
  666. package/src/web/internal/Block.ts +29 -0
  667. package/src/web/internal/ClassName.ts +112 -0
  668. package/src/web/internal/Context.ts +16 -0
  669. package/src/web/internal/Contributions.ts +219 -0
  670. package/src/web/internal/Namespace.ts +21 -0
  671. package/src/web/internal/Themes.ts +133 -0
  672. package/src/web/keyframes.ts +43 -0
  673. package/src/web/layers.ts +6 -0
  674. package/src/web/namespace.ts +19 -0
  675. package/src/web/page.ts +140 -0
  676. package/src/web/positionTry.ts +71 -0
  677. package/src/web/property.ts +35 -0
  678. package/src/web/viewTransition.ts +89 -0
@@ -0,0 +1,1550 @@
1
+ /**
2
+ * Extracts literal styles and local themes through lexical source analysis.
3
+ * @module
4
+ */
5
+ import * as Identity from '../internal/Identity.js'
6
+ import * as Identifiers from './internal/Identifiers.js'
7
+ import type * as Ast from '@oxc-project/types'
8
+ import * as AtRules from './internal/AtRules.js'
9
+ import * as Binding from '../internal/Binding.js'
10
+ import * as Condition from '../internal/Condition.js'
11
+ import type * as Composition from '../runtime/Composition.js'
12
+ import * as Compositions from './internal/Compositions.js'
13
+ import * as Contributions from './internal/Contributions.js'
14
+ import * as Css from '../web/Css.js'
15
+ import * as Dynamic from './internal/Dynamic.js'
16
+ import * as Expression from './internal/Expression.js'
17
+ import * as Selectors from './internal/Selectors.js'
18
+ import type * as Namespace from '../web/internal/Namespace.js'
19
+ import * as Syntax from './internal/Syntax.js'
20
+ import * as RuleReference from '../internal/RuleReference.js'
21
+ import type * as Recipe from '../runtime/Recipe.js'
22
+ import type * as StaticRecipe from '../internal/Recipe.js'
23
+ import type * as RecipePayloads from './internal/RecipePayloads.js'
24
+ import * as Recipes from './internal/Recipes.js'
25
+ import * as PackedStyles from './internal/PackedStyles.js'
26
+ import * as Scope from './internal/Scope.js'
27
+ import type * as Shorthands from '../internal/Shorthands.js'
28
+ import * as Static from './internal/Static.js'
29
+ import * as Style from '../Style.js'
30
+ import type * as Theme from '../Theme.js'
31
+ import * as Themes from './internal/Themes.js'
32
+ import * as ThemeValues from '../web/internal/Themes.js'
33
+ import * as Token from '../internal/Token.js'
34
+ import * as Variables from './internal/Variables.js'
35
+ import * as Walker from 'oxc-walker'
36
+
37
+ // JavaScript extraction supplies untyped values. Keep structural checks without
38
+ // asserting that those values already satisfy the TypeScript authoring contract.
39
+ const define = Style.define as unknown as (
40
+ styles: Record<string, unknown>,
41
+ options: Style.define.Options,
42
+ ) => Style.Definition
43
+
44
+ /** A direct definition call available for a later source rewriter. */
45
+ export type Call = {
46
+ /** Resolved native alternatives for this authoring contract. */
47
+ readonly nativeContext?:
48
+ | {
49
+ /** Default label selected when the provider omits its theme. */
50
+ readonly defaultTheme: string
51
+ /** Compatible alternatives from the owning configuration. */
52
+ readonly themes: Readonly<Record<string, Theme.Definition>>
53
+ }
54
+ | undefined
55
+ /** Class identity available without source rewriting. */
56
+ readonly portable?: string | undefined
57
+ /** Flattened definition identities for nested compositions. */
58
+ readonly portableInputs?: readonly string[] | undefined
59
+ /** Ownership retained by a separately compiled callable. */
60
+ readonly ownership?: Composition.Owner | undefined
61
+ /** CSS-only presence alternative for a runtime composition. */
62
+ readonly compositionCase?: boolean | undefined
63
+ /** Names of precompiled presence alternatives in bitmask order. */
64
+ readonly compositionCases?: readonly string[] | undefined
65
+ /** Fixed runtime applications over an already resolved CSS sequence. */
66
+ readonly runtimeComposition?:
67
+ | readonly {
68
+ /** Original resolved application start retained for selective HTML preparation. */
69
+ readonly applicationStart?: number | undefined
70
+ /** Presence bit for a conditional argument. */
71
+ readonly condition?: number | undefined
72
+ /** Application argument end. */
73
+ readonly end: number
74
+ /** Replaced generated class owner. */
75
+ readonly name: string
76
+ /** Attribute and private variable ownership. */
77
+ readonly owners: readonly Composition.Owner[]
78
+ /** Application argument start. */
79
+ readonly start: number
80
+ }[]
81
+ | undefined
82
+ /** Binding reads preserved by compile-time composition. */
83
+ readonly composition?: readonly string[] | undefined
84
+ /** Finite recipe selection metadata, with all alternatives retained in CSS. */
85
+ readonly recipe?: Recipe.Definition | undefined
86
+ /** Ordered dynamic alternatives retained with scalar binding references. */
87
+ readonly dynamicRecipe?: StaticRecipe.Definition | undefined
88
+ /** Ordered static alternatives retained without CSS selector lowering. */
89
+ readonly staticRecipe?: StaticRecipe.Definition | undefined
90
+ /** Typed payload signatures retained across transformed declarations. */
91
+ readonly recipeTypes?:
92
+ | { readonly [axis: string]: { readonly [choice: string]: string } }
93
+ | undefined
94
+ /** Stable selector identity retained independently of declaration deduplication. */
95
+ readonly identity?: string | undefined
96
+ /** Expanded immutable source data retained for declaration mapping. */
97
+ readonly body?: Ast.ObjectExpression | undefined
98
+ /** Alias targets retained for declaration source locations. */
99
+ readonly shorthands?: Shorthands.Map | undefined
100
+ /** Native HTML attribute output selected by the bound configuration. */
101
+ readonly output?: 'html' | undefined
102
+ /** Typed runtime slots for callback definitions. */
103
+ readonly slots?: Dynamic.Slots | undefined
104
+ /** Authored scalar input type retained in packed declarations. */
105
+ readonly valuesType?: string | undefined
106
+ /** Exclusive UTF-16 offset of the complete call. */
107
+ readonly end: number
108
+ /** Matching name in the extracted style definition. */
109
+ readonly name: string
110
+ /** Inclusive UTF-16 offset of the complete call. */
111
+ readonly start: number
112
+ }
113
+
114
+ /** A source-owned extraction failure. */
115
+ export type Diagnostic = {
116
+ /** Stable failure category. */
117
+ readonly code:
118
+ | 'invalid_literal'
119
+ | 'invalid_module'
120
+ | 'syntax_error'
121
+ | 'unsupported_syntax'
122
+ /** Exclusive UTF-16 source offset. */
123
+ readonly end: number
124
+ /** Explanation of the supported input boundary. */
125
+ readonly message: string
126
+ /** Portable module identity supplied by the host. */
127
+ readonly source: string
128
+ /** Inclusive UTF-16 source offset. */
129
+ readonly start: number
130
+ }
131
+
132
+ /**
133
+ * Extracts direct style calls and local Theme definitions imported from zyzz.
134
+ * Parses TypeScript and JSX without reading files, loading config, or evaluating source.
135
+ * @param options - Source text and a portable package-relative module identity.
136
+ * @returns Frozen style/theme definitions and rewrite spans. Source text is unchanged.
137
+ * @throws {ExtractError} For syntax errors, unsupported imported references, or invalid literals.
138
+ */
139
+ export function extract(options: extract.Options): extract.ReturnType {
140
+ const calls: Call[] = []
141
+ const diagnostics: Diagnostic[] = []
142
+ const pending: Ast.CallExpression[] = []
143
+ const recipes = new Set<number>()
144
+ const styles: Style.NamedStyle[] = []
145
+
146
+ function report(
147
+ code: Diagnostic['code'],
148
+ message: string,
149
+ node?: Pick<Ast.Node, 'end' | 'start'>,
150
+ ) {
151
+ diagnostics.push({
152
+ code,
153
+ end: node?.end ?? 0,
154
+ message,
155
+ source: options.moduleId,
156
+ start: node?.start ?? 0,
157
+ })
158
+ }
159
+
160
+ if (
161
+ !options.moduleId ||
162
+ options.moduleId.includes('\\') ||
163
+ options.moduleId.includes(':') ||
164
+ options.moduleId
165
+ .split('/')
166
+ .some((part) => !part || part === '.' || part === '..')
167
+ ) {
168
+ report(
169
+ 'invalid_module',
170
+ 'Expected a portable package-relative module ID without absolute paths, backslashes, or traversal segments.',
171
+ )
172
+ throw new ExtractError(diagnostics)
173
+ }
174
+
175
+ const namespace = identity(options.moduleId)
176
+ const parsed = options[Themes.context]?.parsed ?? Syntax.parse(options)
177
+
178
+ if (parsed.errors.length) {
179
+ for (const error of parsed.errors) {
180
+ const span = error.labels[0]
181
+
182
+ report('syntax_error', error.message, span)
183
+ }
184
+
185
+ throw new ExtractError(diagnostics)
186
+ }
187
+
188
+ const program = parsed.program
189
+ const scopeTracker = new Scope.Tracker({ preserveExitedScopes: true })
190
+
191
+ Walker.walk(program, { scopeTracker })
192
+ scopeTracker.freeze()
193
+
194
+ const staticData = Static.create(
195
+ program,
196
+ scopeTracker,
197
+ options[Themes.context]?.constants,
198
+ )
199
+
200
+ const contributions = (() => {
201
+ try {
202
+ return Contributions.scan(
203
+ program,
204
+ scopeTracker,
205
+ namespace,
206
+ options[Themes.context]?.links,
207
+ options[Themes.context]?.factories,
208
+ )
209
+ } catch (error) {
210
+ if (!(error instanceof Themes.InvalidError)) throw error
211
+
212
+ report('unsupported_syntax', error.message, error)
213
+ throw new ExtractError(diagnostics)
214
+ }
215
+ })()
216
+
217
+ const variables = (() => {
218
+ try {
219
+ return Variables.collect(
220
+ program,
221
+ namespace,
222
+ scopeTracker,
223
+ options[Themes.context]?.links,
224
+ options.moduleId,
225
+ )
226
+ } catch (error) {
227
+ if (!(error instanceof Themes.InvalidError)) throw error
228
+
229
+ report('unsupported_syntax', error.message, error)
230
+ throw new ExtractError(diagnostics)
231
+ }
232
+ })()
233
+
234
+ const themes = (() => {
235
+ try {
236
+ return Themes.collect(program, {
237
+ staticBindings: staticData.bindings,
238
+ namespace,
239
+ contributionCalls: new Set(
240
+ contributions.calls.map((call) => call.start),
241
+ ),
242
+ linked: options[Themes.context] !== undefined,
243
+ links: options[Themes.context]?.links,
244
+ })
245
+ } catch (error) {
246
+ if (!(error instanceof Themes.InvalidError)) throw error
247
+
248
+ report('unsupported_syntax', error.message, error)
249
+ throw new ExtractError(diagnostics)
250
+ }
251
+ })()
252
+
253
+ const ancestors: Ast.Node[] = []
254
+ const typeAncestors = new Set<Ast.Node>()
255
+ const typeNodes = new Set([
256
+ 'TSInterfaceDeclaration',
257
+ 'TSTypeAliasDeclaration',
258
+ 'TSTypeAnnotation',
259
+ 'TSTypeParameterDeclaration',
260
+ 'TSTypeParameterInstantiation',
261
+ 'TSTypeQuery',
262
+ ])
263
+
264
+ Walker.walk(program, {
265
+ enter(node, parent) {
266
+ const declaration = staticData.visitor.enter(node, parent)
267
+ ancestors.push(node)
268
+ if (
269
+ (parent &&
270
+ 'typeAnnotation' in parent &&
271
+ parent.typeAnnotation === node) ||
272
+ typeNodes.has(node.type) ||
273
+ (node.type === 'ExportNamedDeclaration' &&
274
+ (node.source !== null || node.exportKind === 'type')) ||
275
+ (node.type === 'ExportSpecifier' && node.exportKind === 'type')
276
+ )
277
+ typeAncestors.add(node)
278
+
279
+ if (
280
+ (node.type !== 'Identifier' && node.type !== 'JSXIdentifier') ||
281
+ !parent ||
282
+ (node.type === 'Identifier'
283
+ ? declaration === undefined
284
+ : !Walker.isReferenceIdentifier(node, parent))
285
+ )
286
+ return
287
+
288
+ // Both passes visit identical scopes; skipping type subtrees changes scope IDs.
289
+ if (typeAncestors.size) return
290
+
291
+ const binding =
292
+ node.type === 'Identifier'
293
+ ? declaration ?? null
294
+ : scopeTracker.getDeclaration(node.name)
295
+
296
+ contributions.read(node, parent, binding)
297
+
298
+ try {
299
+ if (variables.reference(node, parent, binding)) return
300
+ } catch (error) {
301
+ if (!(error instanceof Themes.InvalidError)) throw error
302
+
303
+ report('unsupported_syntax', error.message, error)
304
+
305
+ return
306
+ }
307
+
308
+ if (themes)
309
+ try {
310
+ if (themes.reference(node, parent, ancestors, binding)) return
311
+ } catch (error) {
312
+ if (!(error instanceof Themes.InvalidError)) throw error
313
+
314
+ report('unsupported_syntax', error.message, error)
315
+
316
+ return
317
+ }
318
+
319
+ if (
320
+ binding?.type !== 'Import' ||
321
+ binding.importNode.source.value !== 'zyzz' ||
322
+ binding.importNode.importKind === 'type'
323
+ )
324
+ return
325
+
326
+ const specifier = binding.node
327
+
328
+ if (specifier.type === 'ImportNamespaceSpecifier') {
329
+ if (parent.type === 'MemberExpression' && parent.object === node) {
330
+ const name = (() => {
331
+ if (parent.property.type === 'Identifier' && !parent.computed) {
332
+ return parent.property.name
333
+ }
334
+
335
+ if (parent.property.type === 'Literal') {
336
+ return parent.property.value
337
+ }
338
+
339
+ return undefined
340
+ })()
341
+
342
+ if (
343
+ name === 'Config' ||
344
+ name === 'cx' ||
345
+ name === 'style' ||
346
+ name === 'Theme' ||
347
+ name === 'variable' ||
348
+ name === 'variants'
349
+ )
350
+ report(
351
+ 'unsupported_syntax',
352
+ `Import ${name} by name; namespace authoring calls are not supported yet.`,
353
+ parent,
354
+ )
355
+ }
356
+
357
+ return
358
+ }
359
+
360
+ if (
361
+ specifier.type !== 'ImportSpecifier' ||
362
+ specifier.importKind === 'type' ||
363
+ !['style', 'variants'].includes(
364
+ specifier.imported.type === 'Identifier'
365
+ ? specifier.imported.name
366
+ : specifier.imported.value,
367
+ )
368
+ )
369
+ return
370
+
371
+ // Follow only assignment targets; computed keys and default values are reads.
372
+ let target: Ast.Node = node
373
+ let write: Ast.Node | undefined
374
+
375
+ for (let index = ancestors.length - 2; index >= 0; index--) {
376
+ const ancestor = ancestors[index]!
377
+
378
+ if (
379
+ (ancestor.type === 'AssignmentExpression' &&
380
+ ancestor.left === target) ||
381
+ (ancestor.type === 'UpdateExpression' &&
382
+ ancestor.argument === target) ||
383
+ ((ancestor.type === 'ForInStatement' ||
384
+ ancestor.type === 'ForOfStatement') &&
385
+ ancestor.left === target)
386
+ ) {
387
+ write = ancestor
388
+ break
389
+ }
390
+
391
+ if (
392
+ (ancestor.type === 'Property' && ancestor.value === target) ||
393
+ ancestor.type === 'ObjectPattern' ||
394
+ ancestor.type === 'ArrayPattern' ||
395
+ (ancestor.type === 'RestElement' && ancestor.argument === target) ||
396
+ (ancestor.type === 'AssignmentPattern' && ancestor.left === target)
397
+ )
398
+ target = ancestor
399
+ else break
400
+ }
401
+
402
+ if (write)
403
+ report(
404
+ 'unsupported_syntax',
405
+ 'Imported style bindings cannot be reassigned.',
406
+ write,
407
+ )
408
+ else if (
409
+ parent.type === 'CallExpression' &&
410
+ parent.callee === node &&
411
+ !parent.optional
412
+ ) {
413
+ pending.push(parent)
414
+ if (
415
+ (specifier.imported.type === 'Identifier'
416
+ ? specifier.imported.name
417
+ : specifier.imported.value) === 'variants'
418
+ )
419
+ recipes.add(parent.start)
420
+ } else
421
+ report(
422
+ 'unsupported_syntax',
423
+ 'Use a direct style call; aliases, re-exports, and indirect references are not supported yet.',
424
+ node,
425
+ )
426
+ },
427
+ leave(node) {
428
+ ancestors.pop()
429
+ typeAncestors.delete(node)
430
+ staticData.visitor.leave()
431
+ },
432
+ scopeTracker,
433
+ })
434
+
435
+ Contributions.resolve(contributions)
436
+
437
+ // Imports and reference lists can have a different order from authored calls.
438
+ if (themes)
439
+ for (const entry of themes.styles.values()) {
440
+ pending.push(entry.call)
441
+ if (entry.recipe) recipes.add(entry.call.start)
442
+ }
443
+
444
+ pending.sort((a, b) => a.start - b.start)
445
+
446
+ const staticCalls = new Set(pending.map((call) => call.start))
447
+ const opaque = new Set(variables.references.keys())
448
+ const normalized = new Map<number, Ast.Node | Error>()
449
+ const selectorKeys = new Set<number>()
450
+ for (const call of pending) {
451
+ if (!call.arguments[0]) continue
452
+ try {
453
+ const value = staticData.normalize(call.arguments[0], staticCalls, opaque)
454
+ normalized.set(call.start, value)
455
+ const body =
456
+ value.type === 'ArrowFunctionExpression'
457
+ ? staticData.normalize(value.body, staticCalls, opaque)
458
+ : value
459
+
460
+ Walker.walk(body, {
461
+ enter(node) {
462
+ if (
463
+ node.type !== 'Property' ||
464
+ node.computed ||
465
+ node.value.type !== 'ObjectExpression' ||
466
+ !(
467
+ (node.key.type === 'Identifier' &&
468
+ node.key.name === 'selectors') ||
469
+ (node.key.type === 'Literal' && node.key.value === 'selectors')
470
+ )
471
+ )
472
+ return
473
+
474
+ for (const property of node.value.properties)
475
+ if (property.type === 'Property')
476
+ selectorKeys.add(property.key.start)
477
+ },
478
+ })
479
+ } catch (error) {
480
+ if (!(error instanceof Themes.InvalidError)) throw error
481
+ normalized.set(call.start, error)
482
+ }
483
+ }
484
+
485
+ for (const call of pending) {
486
+ try {
487
+ Identifiers.explicit(call)
488
+ } catch (error) {
489
+ report('unsupported_syntax', (error as Error).message, call)
490
+ }
491
+ }
492
+ if (diagnostics.length) throw new ExtractError(diagnostics)
493
+
494
+ const selectors = (() => {
495
+ try {
496
+ return Selectors.scan(
497
+ program,
498
+ scopeTracker,
499
+ namespace,
500
+ pending,
501
+ options[Themes.context]?.links,
502
+ selectorKeys,
503
+ )
504
+ } catch (error) {
505
+ if (!(error instanceof Themes.InvalidError)) throw error
506
+
507
+ report('unsupported_syntax', error.message, error)
508
+ throw new ExtractError(diagnostics)
509
+ }
510
+ })()
511
+
512
+ for (const call of pending) {
513
+ const explicitId = (() => {
514
+ try {
515
+ return Identifiers.explicit(call)
516
+ } catch (error) {
517
+ report('unsupported_syntax', (error as Error).message, call)
518
+ return undefined
519
+ }
520
+ })()
521
+ const definitionId =
522
+ explicitId === undefined
523
+ ? `${namespace}-${call.start}`
524
+ : Identity.requireId(explicitId, 'style')
525
+ let argument = call.arguments[0]
526
+
527
+ if (call.arguments.length === 0)
528
+ argument = {
529
+ end: call.end - 1,
530
+ properties: [],
531
+ start: call.end - 1,
532
+ type: 'ObjectExpression',
533
+ }
534
+
535
+ while (
536
+ argument?.type === 'TSAsExpression' ||
537
+ argument?.type === 'TSSatisfiesExpression'
538
+ )
539
+ argument = argument.expression
540
+
541
+ const original = argument
542
+
543
+ try {
544
+ const value = normalized.get(call.start)
545
+ if (value instanceof Error) throw value
546
+ if (value) argument = value as Ast.Expression
547
+ } catch (error) {
548
+ if (!(error instanceof Themes.InvalidError)) throw error
549
+
550
+ report('unsupported_syntax', error.message, error)
551
+ continue
552
+ }
553
+
554
+ const diagnosticCount = diagnostics.length
555
+
556
+ const dynamic = (() => {
557
+ if (!argument) return undefined
558
+
559
+ try {
560
+ return Dynamic.read(argument, definitionId, staticData.type)
561
+ } catch (error) {
562
+ if (!(error instanceof Themes.InvalidError)) throw error
563
+
564
+ report('unsupported_syntax', error.message, error)
565
+
566
+ return undefined
567
+ }
568
+ })()
569
+ if (diagnostics.length !== diagnosticCount) continue
570
+
571
+ let dynamicValues: RecipePayloads.Bindings | undefined = dynamic
572
+
573
+ function resolveDynamic(node: Ast.Node) {
574
+ try {
575
+ return dynamicValues?.resolve(node)
576
+ } catch (error) {
577
+ if (!(error instanceof Themes.InvalidError)) throw error
578
+
579
+ report('unsupported_syntax', error.message, error)
580
+
581
+ return undefined
582
+ }
583
+ }
584
+
585
+ if (dynamic) {
586
+ try {
587
+ argument = staticData.normalize(
588
+ dynamic.body,
589
+ staticCalls,
590
+ opaque,
591
+ ) as Ast.Expression
592
+ } catch (error) {
593
+ if (!(error instanceof Themes.InvalidError)) throw error
594
+
595
+ report('unsupported_syntax', error.message, error)
596
+ continue
597
+ }
598
+ }
599
+
600
+ if (call.arguments.length > 2 || argument?.type !== 'ObjectExpression') {
601
+ report(
602
+ 'unsupported_syntax',
603
+ 'Expected one literal object or typed callback; spreads and referenced definitions are not supported.',
604
+ call,
605
+ )
606
+ continue
607
+ }
608
+
609
+ const before = diagnostics.length
610
+ let recipe: Recipe.Definition | undefined
611
+ let recipeTypes: Call['recipeTypes']
612
+ let staticRecipe: StaticRecipe.Definition<Ast.ObjectExpression> | undefined
613
+ let dynamicRecipe: StaticRecipe.Definition<Ast.ObjectExpression> | undefined
614
+ if (recipes.has(call.start)) {
615
+ try {
616
+ if (dynamic)
617
+ throw new Themes.InvalidError(
618
+ 'Recipes require static top-level objects.',
619
+ original ?? call,
620
+ )
621
+ const expanded = Recipes.expand(argument, {
622
+ identity: definitionId,
623
+ normalize: (node) => staticData.normalize(node, staticCalls, opaque),
624
+ queries: themes?.styles.get(call.start)?.theme[Token.definition]
625
+ .queries,
626
+ resolveType: staticData.type,
627
+ source: options.source,
628
+ })
629
+ argument = expanded.body
630
+ recipe = expanded.recipe
631
+ staticRecipe = expanded.staticRecipe
632
+ dynamicRecipe = expanded.dynamicRecipe
633
+ recipeTypes = expanded.types
634
+ dynamicValues = expanded.bindings
635
+ } catch (error) {
636
+ if (!(error instanceof Themes.InvalidError)) throw error
637
+ report('unsupported_syntax', error.message, error)
638
+ continue
639
+ }
640
+ }
641
+ const name = `style-${namespace}-${call.start}`
642
+ const locations: Style.SourceLocation[] = []
643
+ const conditionKeys = new Map<string, Ast.Node>()
644
+
645
+ function object(
646
+ argument: Ast.ObjectExpression,
647
+ prefix: readonly string[] = [],
648
+ ): Record<string, unknown> {
649
+ const values: Record<string, unknown> = Object.create(null)
650
+ const target = prefix.lastIndexOf('targets')
651
+ if (target !== -1 && prefix.length > 64) {
652
+ report(
653
+ 'unsupported_syntax',
654
+ 'Target nesting exceeds 64 levels.',
655
+ argument,
656
+ )
657
+ return values
658
+ }
659
+ const depth = prefix.length + 2
660
+
661
+ function localSlot(node: Ast.Node) {
662
+ const slot = resolveDynamic(node)
663
+
664
+ if (
665
+ slot &&
666
+ prefix.some(
667
+ (key) =>
668
+ !Condition.local(key) && !selectors.localConditions.has(key),
669
+ )
670
+ ) {
671
+ report(
672
+ 'unsupported_syntax',
673
+ 'Dynamic values require conditions that select the styled element.',
674
+ node,
675
+ )
676
+
677
+ return undefined
678
+ }
679
+
680
+ return slot
681
+ }
682
+
683
+ const properties: Ast.ObjectExpression['properties'] = []
684
+ for (const entry of argument.properties) {
685
+ const key =
686
+ entry.type === 'Property' && !entry.computed
687
+ ? entry.key.type === 'Identifier'
688
+ ? entry.key.name
689
+ : entry.key.type === 'Literal'
690
+ ? entry.key.value
691
+ : undefined
692
+ : undefined
693
+ if (key !== 'selectors' && key !== 'variables') {
694
+ properties.push(entry)
695
+ continue
696
+ }
697
+ if (
698
+ entry.type !== 'Property' ||
699
+ entry.kind !== 'init' ||
700
+ entry.method ||
701
+ entry.shorthand ||
702
+ entry.value.type !== 'ObjectExpression'
703
+ ) {
704
+ report(
705
+ 'unsupported_syntax',
706
+ `${key} requires an explicit literal object.`,
707
+ entry,
708
+ )
709
+ continue
710
+ }
711
+ for (const property of entry.value.properties) {
712
+ if (
713
+ property.type !== 'Property' ||
714
+ (key === 'selectors'
715
+ ? !selectors.conditions.has(property.key.start)
716
+ : !property.computed ||
717
+ !variables.references.has(property.key.start))
718
+ ) {
719
+ report(
720
+ 'unsupported_syntax',
721
+ key === 'selectors'
722
+ ? 'Selectors require explicit & targets.'
723
+ : 'Variable assignments require declared variable keys.',
724
+ property,
725
+ )
726
+ continue
727
+ }
728
+ properties.push(property)
729
+ }
730
+ }
731
+
732
+ for (const property of properties) {
733
+ if (
734
+ property.type !== 'Property' ||
735
+ property.kind !== 'init' ||
736
+ property.method ||
737
+ (property.computed &&
738
+ !selectors.conditions.has(property.key.start) &&
739
+ !variables.references.has(property.key.start) &&
740
+ !contributions.queryKeys.has(property.key.start)) ||
741
+ property.shorthand ||
742
+ (!selectors.conditions.has(property.key.start) &&
743
+ !variables.references.has(property.key.start) &&
744
+ property.key.type !== 'Identifier' &&
745
+ (property.key.type !== 'Literal' ||
746
+ typeof property.key.value !== 'string'))
747
+ ) {
748
+ report(
749
+ 'unsupported_syntax',
750
+ 'Only explicit literal properties are supported; spreads, computed keys, shorthand, and methods are not evaluated.',
751
+ property,
752
+ )
753
+ continue
754
+ }
755
+
756
+ const key =
757
+ variables.references.get(property.key.start)?.reference.name ??
758
+ selectors.conditions.get(property.key.start) ??
759
+ contributions.queryKeys.get(property.key.start) ??
760
+ (property.key.type === 'Identifier'
761
+ ? property.key.name
762
+ : property.key.type === 'Literal'
763
+ ? String(property.key.value)
764
+ : '')
765
+
766
+ if (Object.hasOwn(values, key)) {
767
+ report(
768
+ 'unsupported_syntax',
769
+ 'Duplicate properties are not supported in source definitions yet.',
770
+ property,
771
+ )
772
+ continue
773
+ }
774
+
775
+ if (
776
+ (key === 'targets' || target !== -1) &&
777
+ staticData.absent(property.value)
778
+ )
779
+ continue
780
+
781
+ if (key === 'targets' || prefix.at(-1) === 'targets') {
782
+ const input = Expression.unwrap(property.value)
783
+ if (input.type !== 'ObjectExpression') {
784
+ report(
785
+ 'unsupported_syntax',
786
+ 'Target branches require static declaration objects.',
787
+ input,
788
+ )
789
+ continue
790
+ }
791
+ values[key] = object(input, [...prefix, key])
792
+ continue
793
+ }
794
+ if (target !== -1 && prefix[target + 1] !== 'web') {
795
+ function nativeValue(input: Ast.Node, depth = 0): unknown {
796
+ const node = Expression.unwrap(input)
797
+ if (depth > 64) {
798
+ report(
799
+ 'unsupported_syntax',
800
+ 'Native value nesting exceeds 64 levels.',
801
+ node,
802
+ )
803
+ return undefined
804
+ }
805
+ if (node.type === 'ObjectExpression')
806
+ return object(node, [...prefix, key])
807
+ if (node.type === 'ArrayExpression')
808
+ return node.elements.map((entry) => {
809
+ if (!entry || entry.type === 'SpreadElement') {
810
+ report(
811
+ 'unsupported_syntax',
812
+ 'Native arrays require dense static entries.',
813
+ node,
814
+ )
815
+ return undefined
816
+ }
817
+ return nativeValue(entry, depth + 1)
818
+ })
819
+ if (
820
+ node.type === 'Literal' &&
821
+ (node.value === null ||
822
+ ['boolean', 'number', 'string'].includes(typeof node.value))
823
+ )
824
+ return node.value
825
+ if (
826
+ node.type === 'UnaryExpression' &&
827
+ ['+', '-'].includes(node.operator) &&
828
+ node.argument.type === 'Literal' &&
829
+ typeof node.argument.value === 'number'
830
+ )
831
+ return (node.operator === '-' ? -1 : 1) * node.argument.value
832
+ if (node.type === 'TemplateLiteral') {
833
+ const value = Expression.template(node)
834
+ if (typeof value === 'string') return value
835
+ }
836
+ report(
837
+ 'unsupported_syntax',
838
+ 'Native branches require static literal values.',
839
+ node,
840
+ )
841
+ return undefined
842
+ }
843
+ values[key] = nativeValue(property.value)
844
+ continue
845
+ }
846
+ if (Condition.is(key)) {
847
+ conditionKeys.set(
848
+ JSON.stringify([name, ...prefix, key]),
849
+ property.key,
850
+ )
851
+
852
+ const input = Expression.unwrap(property.value)
853
+
854
+ if (input.type !== 'ObjectExpression') {
855
+ report(
856
+ 'unsupported_syntax',
857
+ 'Conditions require literal declaration objects.',
858
+ input,
859
+ )
860
+ continue
861
+ }
862
+
863
+ locations.push({
864
+ source: options.moduleId,
865
+ start: property.start,
866
+ end: property.end,
867
+ path: [name, ...prefix, key],
868
+ })
869
+ values[key] = object(input, [...prefix, key])
870
+ continue
871
+ }
872
+
873
+ const targets = themes?.styles.get(call.start)?.theme[Token.definition]
874
+ .contract.shorthands?.[key] ?? [key as Style.Declaration['property']]
875
+
876
+ function value(node: Ast.Node, path: readonly string[]): unknown {
877
+ const unwrapped = Expression.unwrap(node)
878
+ const token =
879
+ variables.references.get(unwrapped.start) ??
880
+ themes?.tokens.get(unwrapped.start)
881
+ const reference =
882
+ localSlot(node) ??
883
+ (token && token.end === unwrapped.end ? token.reference : undefined)
884
+
885
+ if (
886
+ dynamicValues &&
887
+ reference &&
888
+ Object.values(dynamicValues.slots).includes(
889
+ reference as Binding.Reference,
890
+ ) &&
891
+ path.length > depth
892
+ ) {
893
+ report(
894
+ 'unsupported_syntax',
895
+ 'Dynamic fallback entries are not supported.',
896
+ node,
897
+ )
898
+
899
+ return undefined
900
+ }
901
+
902
+ node = Expression.unwrap(node)
903
+
904
+ const animation = contributions.references.get(node.start)
905
+ if (animation) {
906
+ const kind = contributions.kinds.get(animation)
907
+ if (
908
+ kind &&
909
+ targets.some((target) => !RuleReference.accepts(kind, target))
910
+ ) {
911
+ report(
912
+ 'unsupported_syntax',
913
+ 'Named stylesheet reference is incompatible with this property.',
914
+ node,
915
+ )
916
+ return undefined
917
+ }
918
+ return animation
919
+ }
920
+
921
+ const template =
922
+ node.type === 'TemplateLiteral'
923
+ ? Expression.template(node, 0, (expression, prefix) => {
924
+ const animation = contributions.references.get(
925
+ Expression.unwrap(expression).start,
926
+ )
927
+ if (animation) {
928
+ const kind = contributions.kinds.get(animation)
929
+ if (
930
+ kind &&
931
+ targets.some(
932
+ (target) =>
933
+ !RuleReference.acceptsExpression(
934
+ kind,
935
+ target,
936
+ prefix,
937
+ ),
938
+ )
939
+ ) {
940
+ report(
941
+ 'unsupported_syntax',
942
+ 'Named stylesheet reference is incompatible with this property.',
943
+ expression,
944
+ )
945
+ return undefined
946
+ }
947
+ return animation
948
+ }
949
+
950
+ const token =
951
+ variables.references.get(expression.start) ??
952
+ themes?.tokens.get(expression.start)
953
+ const slot = localSlot(expression)
954
+
955
+ if (slot) {
956
+ if (path.length > depth) {
957
+ report(
958
+ 'unsupported_syntax',
959
+ 'Dynamic fallback entries are not supported.',
960
+ expression,
961
+ )
962
+
963
+ return undefined
964
+ }
965
+
966
+ return slot
967
+ }
968
+
969
+ return token?.end === expression.end
970
+ ? token.reference
971
+ : undefined
972
+ })
973
+ : undefined
974
+
975
+ if (Token.isExpression(template)) {
976
+ for (const part of template.parts) {
977
+ if (
978
+ typeof part !== 'string' &&
979
+ !(Binding.is(part)
980
+ ? (dynamicValues !== undefined &&
981
+ Object.values(dynamicValues.slots).includes(part)) ||
982
+ targets.every((target) =>
983
+ Binding.accepts(part.type, target),
984
+ )
985
+ : targets.every((target) =>
986
+ Token.accepts(part.group, target),
987
+ ))
988
+ ) {
989
+ report(
990
+ 'unsupported_syntax',
991
+ Binding.is(part)
992
+ ? 'Variable domain is incompatible with this property.'
993
+ : 'Theme variable domain is incompatible with this property.',
994
+ node,
995
+ )
996
+
997
+ return undefined
998
+ }
999
+ }
1000
+ }
1001
+
1002
+ if (
1003
+ reference &&
1004
+ Token.is(reference) &&
1005
+ !targets.every((target) =>
1006
+ Token.accepts(reference.group, target),
1007
+ ) &&
1008
+ !targets.every((target) =>
1009
+ dynamicValues?.accepts(
1010
+ reference as unknown as Binding.Reference,
1011
+ target,
1012
+ ),
1013
+ )
1014
+ ) {
1015
+ report(
1016
+ 'unsupported_syntax',
1017
+ 'Theme variable domain is incompatible with this property.',
1018
+ node,
1019
+ )
1020
+
1021
+ return undefined
1022
+ }
1023
+
1024
+ if (
1025
+ reference &&
1026
+ Binding.is(reference) &&
1027
+ !(
1028
+ dynamicValues &&
1029
+ Object.values(dynamicValues.slots).includes(reference) &&
1030
+ reference.type !== 'number'
1031
+ ) &&
1032
+ !targets.every(
1033
+ (target) =>
1034
+ Binding.accepts(reference.type, target) ||
1035
+ dynamicValues?.accepts(
1036
+ reference as unknown as Binding.Reference,
1037
+ target,
1038
+ ),
1039
+ )
1040
+ ) {
1041
+ report(
1042
+ 'unsupported_syntax',
1043
+ 'Variable domain is incompatible with this property.',
1044
+ node,
1045
+ )
1046
+
1047
+ return undefined
1048
+ }
1049
+
1050
+ let result: unknown
1051
+
1052
+ if (reference) result = reference
1053
+ else if (template !== undefined) result = template
1054
+ else if (
1055
+ node.type === 'Literal' &&
1056
+ (typeof node.value === 'string' || typeof node.value === 'number')
1057
+ )
1058
+ result = node.value
1059
+ else if (
1060
+ node.type === 'UnaryExpression' &&
1061
+ (node.operator === '-' || node.operator === '+') &&
1062
+ node.argument.type === 'Literal' &&
1063
+ typeof node.argument.value === 'number'
1064
+ )
1065
+ result =
1066
+ node.operator === '-' ? -node.argument.value : node.argument.value
1067
+ else if (node.type === 'ArrayExpression' && path.length === depth) {
1068
+ result = node.elements.map((element, index) => {
1069
+ if (!element || element.type === 'SpreadElement') {
1070
+ report(
1071
+ 'unsupported_syntax',
1072
+ 'Fallback arrays require dense literal entries without spreads.',
1073
+ element ?? node,
1074
+ )
1075
+
1076
+ return undefined
1077
+ }
1078
+
1079
+ return value(element, [...path, String(index)])
1080
+ })
1081
+ } else {
1082
+ report(
1083
+ 'unsupported_syntax',
1084
+ 'Expected a literal string or number; expressions are not evaluated.',
1085
+ node,
1086
+ )
1087
+
1088
+ return undefined
1089
+ }
1090
+
1091
+ locations.push({
1092
+ end: node.end,
1093
+ path,
1094
+ source: options.moduleId,
1095
+ start: node.start,
1096
+ })
1097
+
1098
+ return result
1099
+ }
1100
+
1101
+ values[key] = value(property.value, [name, ...prefix, key])
1102
+ }
1103
+
1104
+ return values
1105
+ }
1106
+
1107
+ const values = object(argument)
1108
+ if (diagnostics.length !== before) continue
1109
+
1110
+ try {
1111
+ const definition = define(
1112
+ { [name]: values },
1113
+ { locations, theme: themes?.styles.get(call.start)?.theme },
1114
+ )
1115
+
1116
+ function validate(style: Style.NamedStyle, path: readonly string[]) {
1117
+ if (style.targets?.web)
1118
+ validate(style.targets.web, [...path, 'targets', 'web'])
1119
+ for (const rule of style.rules ?? []) {
1120
+ if (rule.condition !== undefined) {
1121
+ const location =
1122
+ conditionKeys.get(JSON.stringify([...path, rule.condition])) ??
1123
+ call
1124
+
1125
+ try {
1126
+ AtRules.transform({
1127
+ filename: options.moduleId,
1128
+ code: Buffer.from(`.z{${rule.condition}{color:red;}}`),
1129
+ errorRecovery: false,
1130
+ })
1131
+ } catch (error) {
1132
+ report(
1133
+ 'unsupported_syntax',
1134
+ `Invalid selector or condition: ${(error as Error).message}`,
1135
+ location,
1136
+ )
1137
+ }
1138
+ }
1139
+
1140
+ validate(
1141
+ rule.style,
1142
+ rule.condition === undefined ? path : [...path, rule.condition],
1143
+ )
1144
+ }
1145
+ }
1146
+
1147
+ for (const style of definition.styles) validate(style, [style.name])
1148
+
1149
+ if (diagnostics.length !== before) continue
1150
+
1151
+ const cssOutput = themes?.styles.get(call.start)?.theme[Token.definition]
1152
+ .contract.cssOutput
1153
+ styles.push(
1154
+ ...definition.styles.map((style) =>
1155
+ cssOutput ? Object.freeze({ ...style, cssOutput }) : style,
1156
+ ),
1157
+ )
1158
+
1159
+ const shorthands = themes?.styles.get(call.start)?.theme[Token.definition]
1160
+ .contract.shorthands
1161
+
1162
+ const retained = staticRecipe ?? dynamicRecipe
1163
+ const targetRecipe = retained && {
1164
+ ...retained,
1165
+ rules: retained.rules.map(({ matches, value }, index) => ({
1166
+ matches,
1167
+ value: define(
1168
+ { [`${name}-${index}`]: object(value) },
1169
+ { locations, theme: themes?.styles.get(call.start)?.theme },
1170
+ ),
1171
+ })),
1172
+ }
1173
+ calls.push({
1174
+ ...(recipe ? { recipe, recipeTypes } : {}),
1175
+ ...(staticRecipe
1176
+ ? { staticRecipe: targetRecipe }
1177
+ : dynamicRecipe
1178
+ ? { dynamicRecipe: targetRecipe }
1179
+ : {}),
1180
+ ...(selectors.identities.has(call.start)
1181
+ ? { identity: selectors.identities.get(call.start)! }
1182
+ : {}),
1183
+ ...(argument !== (dynamic?.body ?? original) &&
1184
+ argument.type === 'ObjectExpression'
1185
+ ? { body: argument }
1186
+ : {}),
1187
+ ...(shorthands ? { shorthands } : {}),
1188
+ ...(themes?.styles.get(call.start)?.output
1189
+ ? { output: 'html' as const }
1190
+ : {}),
1191
+ ...(dynamic
1192
+ ? {
1193
+ slots: dynamic.slots,
1194
+ valuesType: options.source.slice(
1195
+ dynamic.type.start,
1196
+ dynamic.type.end,
1197
+ ),
1198
+ }
1199
+ : {}),
1200
+ ...(options.compiler === false
1201
+ ? {
1202
+ portable: (() => {
1203
+ if (explicitId !== undefined) return `z-style-${definitionId}`
1204
+ if (
1205
+ dynamic ||
1206
+ recipe ||
1207
+ (!definition.styles[0]!.declarations.length &&
1208
+ !definition.styles[0]!.rules &&
1209
+ !definition.styles[0]!.targets)
1210
+ )
1211
+ return undefined
1212
+ return Identity.style(definition.styles[0]!)
1213
+ })(),
1214
+ }
1215
+ : {}),
1216
+ end: call.end,
1217
+ name,
1218
+ start: call.start,
1219
+ })
1220
+ } catch (error) {
1221
+ if (!(error instanceof Style.InvalidError)) throw error
1222
+
1223
+ for (const diagnostic of error.diagnostics)
1224
+ diagnostics.push({
1225
+ code: 'invalid_literal',
1226
+ end: diagnostic.location?.end ?? call.end,
1227
+ message: diagnostic.message,
1228
+ source: options.moduleId,
1229
+ start: diagnostic.location?.start ?? call.start,
1230
+ })
1231
+ }
1232
+ }
1233
+
1234
+ try {
1235
+ for (const entry of options.target === 'native'
1236
+ ? []
1237
+ : Compositions.collect({
1238
+ calls,
1239
+ identity: namespace,
1240
+ links: options[Themes.context]?.links,
1241
+ program,
1242
+ source: options.source,
1243
+ styles,
1244
+ })) {
1245
+ calls.push(...(entry.cases ?? []).map((entry) => entry.call), entry.call)
1246
+ styles.push(
1247
+ ...(entry.cases ?? []).map((entry) => entry.style),
1248
+ entry.style,
1249
+ )
1250
+ }
1251
+ } catch (error) {
1252
+ if (!(error instanceof Themes.InvalidError)) throw error
1253
+ report('unsupported_syntax', error.message, error)
1254
+ }
1255
+
1256
+ if (themes && !diagnostics.length)
1257
+ for (const [start, token] of themes.tokens) {
1258
+ if (
1259
+ !staticData.used.has(start) &&
1260
+ !themes.staticTokens.some((node) => node.start === start) &&
1261
+ ![...calls, ...contributions.calls].some(
1262
+ (call) => start >= call.start && token.end <= call.end,
1263
+ )
1264
+ )
1265
+ report(
1266
+ 'unsupported_syntax',
1267
+ 'Theme references require a compiled style declaration.',
1268
+ { start, end: token.end },
1269
+ )
1270
+ }
1271
+
1272
+ let contributionData: readonly Css.Contribution[] = []
1273
+ const contributionStarts = [...variables.registrationStarts]
1274
+
1275
+ try {
1276
+ for (const [index, registration] of variables.registrations.entries()) {
1277
+ try {
1278
+ const css = Css.compile({
1279
+ styles: { styles: [] },
1280
+ contributions: [registration],
1281
+ }).css
1282
+ AtRules.transform({
1283
+ filename: options.moduleId,
1284
+ code: new TextEncoder().encode(css),
1285
+ errorRecovery: false,
1286
+ })
1287
+ } catch (error) {
1288
+ throw new Themes.InvalidError(
1289
+ (error as Error).message,
1290
+ variables.registrationLocations[index]!,
1291
+ )
1292
+ }
1293
+ }
1294
+
1295
+ contributionData = [
1296
+ ...variables.registrations,
1297
+ ...Contributions.extract(
1298
+ contributions,
1299
+ themes?.tokens ?? new Map(),
1300
+ contributionStarts,
1301
+ ),
1302
+ ...(themes?.calls ?? []).flatMap((call) =>
1303
+ call.options?.layers
1304
+ ? [
1305
+ {
1306
+ kind: 'layers' as const,
1307
+ names: call.options.layers as readonly string[],
1308
+ },
1309
+ ]
1310
+ : [],
1311
+ ),
1312
+ ]
1313
+
1314
+ if (contributionData.length) {
1315
+ const rendered = Css.compile({
1316
+ styles: { styles: [] },
1317
+ contributions: contributionData,
1318
+ themes: themes?.themes,
1319
+ }).css
1320
+ AtRules.transform({
1321
+ filename: options.moduleId,
1322
+ code: new TextEncoder().encode(rendered),
1323
+ errorRecovery: false,
1324
+ ...(!options[Themes.context]
1325
+ ? {
1326
+ visitor: {
1327
+ Rule(rule) {
1328
+ if (
1329
+ rule.type === 'import' &&
1330
+ rule.value.url &&
1331
+ !/^(?:\/|[?#]|[a-z][a-z\d+.-]*:)/i.test(rule.value.url)
1332
+ )
1333
+ throw new Error(
1334
+ 'Relative contribution assets require Graph.compile and a relocation host.',
1335
+ )
1336
+ },
1337
+ Url(url) {
1338
+ if (
1339
+ url.url &&
1340
+ !/^(?:\/|[?#]|[a-z][a-z\d+.-]*:)/i.test(url.url)
1341
+ )
1342
+ throw new Error(
1343
+ 'Relative contribution assets require Graph.compile and a relocation host.',
1344
+ )
1345
+ },
1346
+ },
1347
+ }
1348
+ : {}),
1349
+ })
1350
+ }
1351
+ } catch (error) {
1352
+ report(
1353
+ 'unsupported_syntax',
1354
+ (error as Error).message,
1355
+ error instanceof Themes.InvalidError ? error : contributions.calls[0],
1356
+ )
1357
+ }
1358
+
1359
+ for (const token of themes?.staticTokens ?? [])
1360
+ if (!staticData.used.has(Expression.unwrap(token).start))
1361
+ report(
1362
+ 'unsupported_syntax',
1363
+ 'Token references must be direct property values in bound theme style calls.',
1364
+ token,
1365
+ )
1366
+
1367
+ if (diagnostics.length) throw new ExtractError(diagnostics)
1368
+
1369
+ function exportedStyle(link: Themes.Link): Themes.Link {
1370
+ const call = calls.find((call) => call.identity === link.binding)
1371
+ const style = call && styles.find((style) => style.name === call.name)
1372
+ return {
1373
+ ...link,
1374
+ ...(call && style ? { style: PackedStyles.create(call, style) } : {}),
1375
+ ...(link.members
1376
+ ? {
1377
+ members: Object.fromEntries(
1378
+ Object.entries(link.members).map(([name, member]) => [
1379
+ name,
1380
+ exportedStyle(member),
1381
+ ]),
1382
+ ),
1383
+ }
1384
+ : {}),
1385
+ }
1386
+ }
1387
+
1388
+ return Object.freeze({
1389
+ namespaces: contributionData.filter(
1390
+ (value): value is Extract<Css.Contribution, { kind: 'namespace' }> =>
1391
+ value.kind === 'namespace',
1392
+ ),
1393
+ ...(contributionData.length
1394
+ ? { contributions: contributionData, contributionStarts }
1395
+ : {}),
1396
+ ...(contributions.calls.length
1397
+ ? { contributionCalls: contributions.calls }
1398
+ : {}),
1399
+ ...(options[Themes.context]
1400
+ ? {
1401
+ themeExports: Object.freeze({
1402
+ ...themes?.exports,
1403
+ ...Object.fromEntries(
1404
+ Object.entries(selectors.exports).map(([name, link]) => [
1405
+ name,
1406
+ exportedStyle(link),
1407
+ ]),
1408
+ ),
1409
+ ...contributions.exports,
1410
+ ...variables.exports,
1411
+ }),
1412
+ }
1413
+ : {}),
1414
+ calls: Object.freeze(
1415
+ calls
1416
+ .sort((a, b) => a.start - b.start)
1417
+ .map((call) => {
1418
+ const nativeContext =
1419
+ options.target === 'native'
1420
+ ? themes?.nativeContext(call.start, call.end)
1421
+ : undefined
1422
+ return Object.freeze(
1423
+ nativeContext ? { ...call, nativeContext } : call,
1424
+ )
1425
+ }),
1426
+ ),
1427
+ styles: Object.freeze({ styles: Object.freeze(styles) }),
1428
+ ...(variables.calls.length
1429
+ ? { variableCalls: Object.freeze(variables.calls) }
1430
+ : {}),
1431
+ themeAliases: Object.freeze(themes?.aliases ?? []),
1432
+ ...(themes?.appearances.size
1433
+ ? { themeAppearances: Object.freeze([...themes.appearances]) }
1434
+ : {}),
1435
+ ...(themes?.scripts.size
1436
+ ? { themeScripts: Object.freeze([...themes.scripts]) }
1437
+ : {}),
1438
+ ...(themes?.selections.size
1439
+ ? { themeSelections: Object.freeze([...themes.selections]) }
1440
+ : {}),
1441
+ themeCalls: Object.freeze(themes?.calls ?? []),
1442
+ ...(themes?.staticTokens.length
1443
+ ? {
1444
+ staticThemeReferences: Object.freeze(
1445
+ (themes?.staticTokens ?? []).map((node) => ({
1446
+ start: node.start,
1447
+ end: node.end,
1448
+ value: ThemeValues.create().serialize(
1449
+ themes!.tokens.get(node.start)!.reference,
1450
+ ),
1451
+ })),
1452
+ ),
1453
+ }
1454
+ : {}),
1455
+ themeReferences: Object.freeze(themes?.references ?? []),
1456
+ themes: themes?.themes ?? Object.freeze({}),
1457
+ })
1458
+ }
1459
+
1460
+ /** Input and output of source extraction. */
1461
+ export declare namespace extract {
1462
+ /** Structured source failure. */
1463
+ type ErrorType = ExtractError
1464
+
1465
+ /** Source text supplied by an adapter. */
1466
+ type Options = {
1467
+ /** Native extraction retains applications for native props composition. */
1468
+ readonly target?: 'native' | 'web' | undefined
1469
+ /** Collect portable runtime identities when source rewriting is disabled. */
1470
+ readonly compiler?: boolean | undefined
1471
+ /** Portable identity including package and module path; no filesystem access occurs. */
1472
+ readonly moduleId: string
1473
+ /** Compiler-owned graph context. */
1474
+ readonly [Themes.context]?: Themes.Context | undefined
1475
+ /** Complete module text, parsed as TypeScript with JSX. */
1476
+ readonly source: string
1477
+ }
1478
+
1479
+ /** Ordered public compiler input and spans for later rewriting. */
1480
+ type ReturnType = {
1481
+ /** Module-owned namespace bindings retained when contributions are shared. */
1482
+ readonly namespaces?: readonly Namespace.Definition[] | undefined
1483
+ /** Static stylesheet effects and their source replacements. */
1484
+ readonly contributionStarts?: readonly number[] | undefined
1485
+ readonly contributions?: readonly Css.Contribution[] | undefined
1486
+ readonly contributionCalls?: readonly Contributions.Call[] | undefined
1487
+ /** Explicit variable contracts replaced by fixed slot data. */
1488
+ readonly variableCalls?: readonly Variables.Call[] | undefined
1489
+ /** Direct calls in source order. */
1490
+ readonly calls: readonly Call[]
1491
+ /** Validated definitions accepted by Css.compile. */
1492
+ readonly styles: Style.Definition
1493
+ /** Local bound-authoring initializers and their retained token types. */
1494
+ readonly themeAliases: readonly Themes.Alias[]
1495
+ /** Configuration identities retaining their root controls. */
1496
+ readonly themeAppearances?: readonly string[] | undefined
1497
+ /** Configuration identities retaining their initialization helper. */
1498
+ readonly themeScripts?: readonly string[] | undefined
1499
+ /** Configuration identities whose theme selector is called, passed, or bound. */
1500
+ readonly themeSelections?: readonly string[] | undefined
1501
+ /** Local factory spans replaced by compiled scope data. */
1502
+ readonly themeCalls: readonly Themes.Call[]
1503
+ /** Scope reads replaced by class constants. */
1504
+ readonly staticThemeReferences?:
1505
+ | readonly {
1506
+ readonly start: number
1507
+ readonly end: number
1508
+ readonly value: string
1509
+ }[]
1510
+ | undefined
1511
+ readonly themeReferences: readonly Themes.Reference[]
1512
+ /** Resolved authoring exports when extracted as part of a source graph. */
1513
+ readonly themeExports?: Readonly<Record<string, Themes.Link>> | undefined
1514
+ /** Stable scope keys and validated local theme definitions. */
1515
+ readonly themes: Readonly<Record<string, Theme.Definition>>
1516
+ }
1517
+ }
1518
+
1519
+ /** Aggregated source diagnostics; no partial result is returned. */
1520
+ export class ExtractError extends Error {
1521
+ /** Freezes source diagnostics in source order. */
1522
+ constructor(diagnostics: readonly Diagnostic[]) {
1523
+ const ordered = [...diagnostics].sort((a, b) => a.start - b.start)
1524
+
1525
+ super(
1526
+ ordered
1527
+ .map((item) => `${item.source}:${item.start}: ${item.message}`)
1528
+ .join('\n'),
1529
+ )
1530
+ this.diagnostics = Object.freeze(
1531
+ ordered.map((item) => Object.freeze({ ...item })),
1532
+ )
1533
+ }
1534
+ /** Immutable source failures. */
1535
+ readonly diagnostics: readonly Diagnostic[]
1536
+ /** Stable namespaced error identifier. */
1537
+ override name = 'Source.ExtractError'
1538
+ }
1539
+
1540
+ function identity(value: string): string {
1541
+ let first = 2166136261
1542
+ let second = 2246822507
1543
+
1544
+ for (let index = 0; index < value.length; index++) {
1545
+ first = Math.imul(first ^ value.charCodeAt(index), 16777619)
1546
+ second = Math.imul(second ^ value.charCodeAt(index), 3266489909)
1547
+ }
1548
+
1549
+ return `${(first >>> 0).toString(36)}${(second >>> 0).toString(36)}`
1550
+ }