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,1794 @@
1
+ /**
2
+ * Extracts local theme data and validates its lexical source references.
3
+ * @module
4
+ */
5
+ import type * as Syntax from './Syntax.js'
6
+ import * as Identity from '../../internal/Identity.js'
7
+ import * as Identifiers from './Identifiers.js'
8
+ import type { cssFunction } from '../../web/cssFunction.js'
9
+ import type * as RuleReference from '../../internal/RuleReference.js'
10
+ import type * as Ast from '@oxc-project/types'
11
+ import type * as Walker from 'oxc-walker'
12
+ import type * as Binding from '../../internal/Binding.js'
13
+ import * as Config from '../../Config.js'
14
+ import * as Expression from './Expression.js'
15
+ import * as Configurations from './Configurations.js'
16
+ import * as Token from '../../internal/Token.js'
17
+ import * as Theme from '../../Theme.js'
18
+ import type * as Source from '../Source.js'
19
+ import type * as PackedStyles from './PackedStyles.js'
20
+
21
+ /** Local bound-authoring initializer replaced while retaining its inferred type. */
22
+ export type Alias = Call & {
23
+ /** Ordered authoring members replaced in a shared destructuring initializer. */
24
+ readonly bindings?: readonly ('style' | 'variants')[] | undefined
25
+ /** Whether the initializer supplies destructured authoring bindings. */
26
+ readonly destructured: boolean
27
+ /** Retains an immutable theme/configuration alias value with an explicit type. */
28
+ readonly retained?: boolean | undefined
29
+ }
30
+
31
+ /** Theme factory span and generated scope key. */
32
+ export type Call = {
33
+ /** Whether this bound authoring alias declares recipes. */
34
+ readonly recipe?: boolean | undefined
35
+ /** Static CSS function signature shared during extraction and packed serialization. */
36
+ readonly function?:
37
+ | {
38
+ parameters: readonly cssFunction.Parameter[]
39
+ returns: cssFunction.Syntax
40
+ }
41
+ | undefined
42
+ /** Named stylesheet identity domain. */
43
+ readonly reference?: RuleReference.Kind | undefined
44
+ /** Canonical defining module for multi-entry variable contracts. */
45
+ readonly variableOwner?: string | undefined
46
+ readonly output?: 'html' | undefined
47
+ /** Portable explicit variable references. */
48
+ readonly variables?: Readonly<Record<string, Binding.Reference>> | undefined
49
+ /** Whether the compiled configuration supplies root controls. */
50
+ readonly appearance?: boolean | undefined
51
+ /** Whether the compiled configuration supplies initialization. */
52
+ readonly script?: boolean | undefined
53
+ /** Bound root initialization script export. */
54
+ readonly initialization?: boolean | undefined
55
+ /** Bound root controls export. */
56
+ readonly root?: boolean | undefined
57
+ /** Config helper represented by this linked binding. */
58
+ readonly selection?: boolean | undefined
59
+ /** Legacy packed catalogs have static members but are not callable. */
60
+ /** Legacy packed catalog exposes members but lacks callable-selection capability. */
61
+ readonly catalogOnly?: boolean | undefined
62
+ /** Validated inline configuration options retained for packed declarations. */
63
+ readonly options?: Readonly<Record<string, unknown>> | undefined
64
+ /** JSON-encoded member path tuples and their compiled scope keys. */
65
+ readonly members?: Readonly<Record<string, string>> | undefined
66
+ /** Complete authoring type retained for configuration declarations. */
67
+ readonly type?: string | undefined
68
+ /** Exclusive source offset. */
69
+ readonly end: number
70
+ /** Stable module/binding scope key. */
71
+ readonly name: string
72
+ /** Inclusive source offset. */
73
+ readonly start: number
74
+ /** Literal token contract retained in rewritten TypeScript type assertions. */
75
+ readonly tokenType: string
76
+ }
77
+
78
+ /** Internal context passed between graph extraction and module rewriting. */
79
+ export const context = Symbol('zyzz.source.graph')
80
+
81
+ /** Resolved authoring contract within a supplied source graph. */
82
+ export type Link = {
83
+ /** Complete callable style and ownership data for cross-module composition. */
84
+ readonly style?: PackedStyles.Definition | undefined
85
+ readonly binding: string
86
+ readonly call: Call
87
+ readonly definition: Theme.Definition
88
+ readonly kind:
89
+ | 'config'
90
+ | 'style'
91
+ | 'theme'
92
+ | 'style-reference'
93
+ | 'animation'
94
+ | 'rule-reference'
95
+ | 'variables'
96
+ readonly members?: Readonly<Record<string, Link>> | undefined
97
+ }
98
+
99
+ /** Shared graph data; no filesystem or runtime evaluation is involved. */
100
+ export type Context = {
101
+ /** Canonical identifier names collected during graph validation. */
102
+ readonly identifiers?: ReadonlySet<string> | undefined
103
+ /** Syntax owned by the current graph compilation. */
104
+ readonly parsed?: ReturnType<typeof Syntax.parse> | undefined
105
+ /** Packed exports indexed by the importing module's source specifier. */
106
+ readonly libraries?:
107
+ | Readonly<Record<string, Readonly<Record<string, Link>>>>
108
+ | undefined
109
+ /** Immutable literal imports resolved from supplied source modules. */
110
+ readonly constants?: Readonly<Record<string, Ast.Node>> | undefined
111
+ /** Published class lists of imported callable definitions. */
112
+ readonly styleClasses?: Readonly<Record<string, string>> | undefined
113
+ /** Locally imported stylesheet factories resolved through source barrels. */
114
+ readonly factories?: Readonly<Record<string, string>> | undefined
115
+ readonly extracted?: Source.extract.ReturnType | undefined
116
+ readonly links: Readonly<Record<string, Link>>
117
+ readonly owners?:
118
+ | Readonly<Record<string, { call: Call; moduleId: string; source: string }>>
119
+ | undefined
120
+ }
121
+
122
+ /** Collects immutable module-level themes without evaluating source. */
123
+ export function collect(program: Ast.Program, options: collect.Options) {
124
+ const staticTokens: Ast.Node[] = []
125
+ const aliases: Alias[] = []
126
+ const aliasBindings = new Map<number, Alias>()
127
+ const aliasReferences = new Set<number>()
128
+ const appearances = new Set<string>()
129
+ const selections = new Set<string>()
130
+ const calls: Call[] = []
131
+ const scripts = new Set<string>()
132
+ const definitions = new Map<number, Call>()
133
+ const factories = new Set<number>()
134
+ const imports = new Set<number>()
135
+ const configImports = new Set<number>()
136
+ const configs = new Map<string, Link>()
137
+ const configBindings = new Map<number, Link>()
138
+ const factoryReferences = new Set<number>()
139
+ const references: Reference[] = []
140
+
141
+ const styles = new Map<
142
+ number,
143
+ {
144
+ call: Ast.CallExpression
145
+ recipe?: boolean | undefined
146
+ output?: 'html' | undefined
147
+ theme: Theme.Definition
148
+ }
149
+ >()
150
+
151
+ const themes: Record<string, Theme.Definition> = Object.create(null)
152
+ const tokens = new Map<number, { end: number; reference: Token.Reference }>()
153
+
154
+ for (const node of program.body) {
155
+ if (
156
+ node.type !== 'ImportDeclaration' ||
157
+ node.source.value !== 'zyzz' ||
158
+ node.importKind === 'type'
159
+ )
160
+ continue
161
+
162
+ for (const specifier of node.specifiers)
163
+ if (
164
+ specifier.type === 'ImportSpecifier' &&
165
+ specifier.importKind !== 'type' &&
166
+ (specifier.imported.type === 'Identifier'
167
+ ? specifier.imported.name
168
+ : specifier.imported.value) === 'Theme'
169
+ )
170
+ imports.add(specifier.start)
171
+ else if (
172
+ specifier.type === 'ImportSpecifier' &&
173
+ specifier.importKind !== 'type' &&
174
+ (specifier.imported.type === 'Identifier'
175
+ ? specifier.imported.name
176
+ : specifier.imported.value) === 'Config'
177
+ )
178
+ configImports.add(specifier.start)
179
+ }
180
+
181
+ if (
182
+ !imports.size &&
183
+ !configImports.size &&
184
+ !Object.keys(options.links ?? {}).length
185
+ )
186
+ return undefined
187
+
188
+ const names = new Map<string, Call>()
189
+ const aliasNames = new Map<string, Alias>()
190
+ const exports: Record<string, Link> = Object.create(null)
191
+
192
+ for (const node of program.body) {
193
+ if (node.type !== 'ImportDeclaration' || node.importKind === 'type')
194
+ continue
195
+
196
+ for (const specifier of node.specifiers) {
197
+ const link = options.links?.[specifier.local.name]
198
+ if (
199
+ !link ||
200
+ link.kind === 'style-reference' ||
201
+ link.kind === 'animation' ||
202
+ link.kind === 'rule-reference' ||
203
+ link.kind === 'variables'
204
+ )
205
+ continue
206
+
207
+ const call = { ...link.call, start: -1, end: -1 }
208
+
209
+ themes[call.name] = link.definition
210
+
211
+ if (link.kind === 'config') {
212
+ const imported = {
213
+ ...link,
214
+ call,
215
+ members: Object.fromEntries(
216
+ Object.entries(link.members ?? {}).map(([key, member]) => [
217
+ key,
218
+ { ...member, call: { ...member.call, start: -1, end: -1 } },
219
+ ]),
220
+ ),
221
+ }
222
+
223
+ configs.set(specifier.local.name, imported)
224
+ configBindings.set(specifier.start, imported)
225
+
226
+ for (const member of Object.values(link.members ?? {}))
227
+ themes[member.call.name] = member.definition
228
+ } else if (link.kind === 'theme') {
229
+ definitions.set(specifier.start, call)
230
+ names.set(specifier.local.name, call)
231
+ } else {
232
+ const alias = { ...call, destructured: false }
233
+
234
+ aliasBindings.set(specifier.start, alias)
235
+ aliasNames.set(specifier.local.name, alias)
236
+ }
237
+ }
238
+ }
239
+
240
+ const namespaces = new Set<string>()
241
+ const configNamespaces = new Set<string>()
242
+
243
+ for (const node of program.body)
244
+ if (node.type === 'ImportDeclaration')
245
+ for (const specifier of node.specifiers)
246
+ if (imports.has(specifier.start)) namespaces.add(specifier.local.name)
247
+ else if (configImports.has(specifier.start))
248
+ configNamespaces.add(specifier.local.name)
249
+
250
+ function resolve(node: Ast.Node): Link | undefined {
251
+ if (node.type === 'Identifier') {
252
+ const config = configs.get(node.name)
253
+ if (config) return config
254
+
255
+ const call = names.get(node.name)
256
+ if (call)
257
+ return {
258
+ binding: call.name,
259
+ call,
260
+ definition: themes[call.name]!,
261
+ kind: 'theme',
262
+ }
263
+
264
+ return undefined
265
+ }
266
+
267
+ if (node.type !== 'MemberExpression' || node.optional) return undefined
268
+
269
+ const path: string[] = []
270
+ let root: Ast.Node = node
271
+
272
+ while (root.type === 'MemberExpression') {
273
+ const key = (() => {
274
+ if (root.property.type === 'Identifier' && !root.computed) {
275
+ return root.property.name
276
+ }
277
+
278
+ if (
279
+ root.property.type === 'Literal' &&
280
+ root.computed &&
281
+ (typeof root.property.value === 'string' ||
282
+ typeof root.property.value === 'number')
283
+ ) {
284
+ return String(root.property.value)
285
+ }
286
+
287
+ return undefined
288
+ })()
289
+ if (root.optional || key === undefined) return undefined
290
+
291
+ path.unshift(key)
292
+ root = root.object
293
+ }
294
+
295
+ const config =
296
+ root.type === 'Identifier' ? configs.get(root.name) : undefined
297
+
298
+ if (
299
+ config &&
300
+ !config.call.selection &&
301
+ !config.call.initialization &&
302
+ !config.call.root &&
303
+ path.length === 1 &&
304
+ ['themes', 'script', 'appearance'].includes(path[0]!)
305
+ ) {
306
+ const key = path[0]!
307
+
308
+ if (key === 'script') scripts.add(config.call.name)
309
+ if (key === 'appearance') appearances.add(config.call.name)
310
+
311
+ if (key === 'themes' && !config.call.options?.themes) return undefined
312
+ if (key === 'themes') selections.add(config.call.name)
313
+
314
+ if (key === 'script' && !config.call.script)
315
+ fail(
316
+ 'This packed configuration does not provide script(); rebuild its library with initialization support.',
317
+ node,
318
+ )
319
+
320
+ if (key === 'appearance' && !config.call.appearance)
321
+ fail(
322
+ 'This packed configuration does not provide appearance; rebuild its library with root control support.',
323
+ node,
324
+ )
325
+
326
+ const members = Object.fromEntries(
327
+ Object.entries(config.members ?? {}).flatMap(([name, member]) => {
328
+ const parts = JSON.parse(name) as string[]
329
+
330
+ return key === 'themes' && parts[0] === 'themes'
331
+ ? [[JSON.stringify(parts.slice(1)), member]]
332
+ : []
333
+ }),
334
+ )
335
+
336
+ return {
337
+ ...config,
338
+ members,
339
+ binding: `${config.binding}:${key}`,
340
+ call: {
341
+ ...config.call,
342
+ members: Object.fromEntries(
343
+ Object.entries(members).map(([name, member]) => [
344
+ name,
345
+ member.call.name,
346
+ ]),
347
+ ),
348
+ ...helper(key),
349
+ type: `${config.call.type}['${key}']`,
350
+ },
351
+ }
352
+ }
353
+
354
+ return config?.members?.[JSON.stringify(path)]
355
+ }
356
+
357
+ /** Marks which configuration helper a destructured or member binding represents. */
358
+ function helper(key: string) {
359
+ if (key === 'script') return { initialization: true }
360
+ if (key === 'appearance') return { root: true }
361
+ return { selection: true }
362
+ }
363
+
364
+ function data(node: Ast.Node): unknown {
365
+ if (node.type === 'TSAsExpression' || node.type === 'TSSatisfiesExpression')
366
+ return data(node.expression)
367
+
368
+ if (
369
+ node.type === 'Literal' &&
370
+ (typeof node.value === 'string' || typeof node.value === 'number')
371
+ )
372
+ return node.value
373
+
374
+ if (
375
+ node.type === 'UnaryExpression' &&
376
+ (node.operator === '+' || node.operator === '-') &&
377
+ node.argument.type === 'Literal' &&
378
+ typeof node.argument.value === 'number'
379
+ )
380
+ return node.operator === '-' ? -node.argument.value : node.argument.value
381
+
382
+ if (node.type === 'ArrayExpression')
383
+ return node.elements.map((element) => {
384
+ if (!element || element.type === 'SpreadElement')
385
+ return fail('Theme arrays require dense literal elements.', node)
386
+
387
+ return data(element)
388
+ })
389
+
390
+ if (node.type !== 'ObjectExpression')
391
+ return fail(
392
+ 'Theme values must be literal data; expressions are not evaluated.',
393
+ node,
394
+ )
395
+
396
+ const result: Record<string, unknown> = Object.create(null)
397
+
398
+ for (const property of node.properties) {
399
+ if (
400
+ property.type !== 'Property' ||
401
+ property.computed ||
402
+ property.method ||
403
+ property.shorthand ||
404
+ property.kind !== 'init'
405
+ )
406
+ return fail(
407
+ 'Theme data requires explicit properties without spreads, methods, or computed keys.',
408
+ property,
409
+ )
410
+
411
+ const key = (() => {
412
+ if (property.key.type === 'Identifier') {
413
+ return property.key.name
414
+ }
415
+
416
+ if (
417
+ property.key.type === 'Literal' &&
418
+ (typeof property.key.value === 'string' ||
419
+ typeof property.key.value === 'number')
420
+ ) {
421
+ return String(property.key.value)
422
+ }
423
+
424
+ return undefined
425
+ })()
426
+ if (key === undefined || Object.hasOwn(result, key))
427
+ return fail('Theme data requires unique literal keys.', property)
428
+
429
+ result[key] = data(property.value)
430
+ }
431
+
432
+ return result
433
+ }
434
+
435
+ function fail(message: string, node: Pick<Ast.Node, 'end' | 'start'>): never {
436
+ throw new InvalidError(message, node)
437
+ }
438
+
439
+ function type(node: Ast.Node): string {
440
+ if (node.type === 'TSAsExpression' || node.type === 'TSSatisfiesExpression')
441
+ return type(node.expression)
442
+
443
+ if (node.type !== 'ObjectExpression') return JSON.stringify(data(node))
444
+
445
+ return `{${node.properties
446
+ .map((property) => {
447
+ if (property.type !== 'Property')
448
+ return fail('Expected validated theme properties.', property)
449
+
450
+ const key = (() => {
451
+ if (property.key.type === 'Identifier') {
452
+ return JSON.stringify(property.key.name)
453
+ }
454
+
455
+ if (property.key.type === 'Literal') {
456
+ return JSON.stringify(property.key.value)
457
+ }
458
+
459
+ return fail('Expected a literal theme key.', property.key)
460
+ })()
461
+
462
+ return `readonly ${key}:${type(property.value)}`
463
+ })
464
+ .join(';')}}`
465
+ }
466
+
467
+ for (const statement of program.body) {
468
+ const declaration =
469
+ statement.type === 'ExportNamedDeclaration'
470
+ ? statement.declaration
471
+ : statement
472
+ if (declaration?.type !== 'VariableDeclaration') continue
473
+
474
+ for (const variable of declaration.declarations) {
475
+ registerAlias({ declaration, statement, variable })
476
+
477
+ const expression = variable.init
478
+ if (
479
+ expression?.type !== 'CallExpression' ||
480
+ expression.callee.type !== 'MemberExpression' ||
481
+ expression.callee.object.type !== 'Identifier' ||
482
+ (!namespaces.has(expression.callee.object.name) &&
483
+ !configNamespaces.has(expression.callee.object.name))
484
+ )
485
+ continue
486
+
487
+ const member = expression.callee
488
+ if (
489
+ member.computed ||
490
+ member.optional ||
491
+ expression.optional ||
492
+ member.property.type !== 'Identifier' ||
493
+ !(
494
+ configNamespaces.has(expression.callee.object.name)
495
+ ? ['create']
496
+ : ['define', 'extend']
497
+ ).includes(member.property.name)
498
+ )
499
+ continue
500
+
501
+ if (
502
+ (statement.type === 'ExportNamedDeclaration' && !options.linked) ||
503
+ declaration.kind !== 'const' ||
504
+ (variable.id.type !== 'Identifier' &&
505
+ !(
506
+ configNamespaces.has(expression.callee.object.name) &&
507
+ variable.id.type === 'ObjectPattern'
508
+ ))
509
+ )
510
+ fail(
511
+ 'Define local themes with a module-level const; exported themes require source linking.',
512
+ variable,
513
+ )
514
+
515
+ const bindings = (() => {
516
+ if (variable.id.type !== 'ObjectPattern') return []
517
+
518
+ return variable.id.properties.map((property) => {
519
+ if (
520
+ property.type !== 'Property' ||
521
+ property.computed ||
522
+ property.key.type !== 'Identifier' ||
523
+ property.value.type !== 'Identifier'
524
+ )
525
+ fail(
526
+ 'Configuration destructuring requires named bindings without defaults, rest, or nested patterns.',
527
+ property,
528
+ )
529
+
530
+ return { key: property.key.name, id: property.value }
531
+ })
532
+ })()
533
+
534
+ const binding =
535
+ variable.id.type === 'Identifier'
536
+ ? variable.id.name
537
+ : bindings[0]?.id.name
538
+
539
+ if (!binding)
540
+ fail('Configuration destructuring requires a binding.', variable)
541
+
542
+ let name = `${options.namespace}-${binding}`
543
+ if (
544
+ !configNamespaces.has(expression.callee.object.name) &&
545
+ member.property.name === 'define'
546
+ ) {
547
+ const id = Identifiers.explicit(expression)
548
+ if (id !== undefined) name = Identity.requireId(id, 'Theme.define')
549
+ }
550
+
551
+ if (configNamespaces.has(expression.callee.object.name)) {
552
+ try {
553
+ const link = Configurations.collect({
554
+ data,
555
+ expression,
556
+ name,
557
+ resolve: (node) => {
558
+ const link = resolve(node)
559
+
560
+ if (link) factoryReferences.add(node.start)
561
+
562
+ return link
563
+ },
564
+ })
565
+
566
+ if (variable.id.type === 'Identifier') {
567
+ configs.set(variable.id.name, link)
568
+ configBindings.set(variable.id.start, link)
569
+
570
+ if (statement.type === 'ExportNamedDeclaration')
571
+ exports[variable.id.name] = link
572
+ }
573
+
574
+ calls.push(link.call)
575
+ factories.add(expression.start)
576
+
577
+ for (const member of Object.values(link.members ?? {}))
578
+ themes[member.call.name] = member.definition
579
+
580
+ themes[link.call.name] = link.definition
581
+
582
+ for (const { key, id } of bindings) {
583
+ if (
584
+ (key === 'style' || key === 'variants') &&
585
+ !link.call.selection &&
586
+ !link.call.initialization
587
+ ) {
588
+ const alias = {
589
+ ...link.call,
590
+ recipe: key === 'variants',
591
+ destructured: false,
592
+ }
593
+
594
+ aliasBindings.set(id.start, alias)
595
+ aliasNames.set(id.name, alias)
596
+
597
+ if (statement.type === 'ExportNamedDeclaration')
598
+ exports[id.name] = {
599
+ ...link,
600
+ binding: `${options.namespace}-${id.name}`,
601
+ call: alias,
602
+ kind: 'style',
603
+ }
604
+
605
+ continue
606
+ }
607
+
608
+ if (
609
+ !link.call.selection &&
610
+ !link.call.initialization &&
611
+ !link.call.root &&
612
+ (key === 'script' ||
613
+ key === 'appearance' ||
614
+ (key === 'themes' && link.call.options?.themes))
615
+ ) {
616
+ if (
617
+ (key === 'script' && !link.call.script) ||
618
+ (key === 'appearance' && !link.call.appearance) ||
619
+ link.call.selection ||
620
+ link.call.initialization
621
+ )
622
+ fail(
623
+ 'This configuration helper is not available on the linked contract.',
624
+ id,
625
+ )
626
+
627
+ if (key === 'script') scripts.add(link.call.name)
628
+ if (key === 'appearance') appearances.add(link.call.name)
629
+ if (key === 'themes') selections.add(link.call.name)
630
+
631
+ const members = Object.fromEntries(
632
+ Object.entries(link.members ?? {}).flatMap(
633
+ ([pathKey, member]) => {
634
+ const path = JSON.parse(pathKey) as string[]
635
+
636
+ return key === 'themes' && path[0] === 'themes'
637
+ ? [[JSON.stringify(path.slice(1)), member]]
638
+ : []
639
+ },
640
+ ),
641
+ )
642
+
643
+ const selection = {
644
+ ...link,
645
+ members,
646
+ call: {
647
+ ...link.call,
648
+ members: Object.fromEntries(
649
+ Object.entries(members).map(([key, member]) => [
650
+ key,
651
+ member.call.name,
652
+ ]),
653
+ ),
654
+ ...helper(key),
655
+ type: `${link.call.type}['${key}']`,
656
+ },
657
+ }
658
+
659
+ configs.set(id.name, selection)
660
+ configBindings.set(id.start, selection)
661
+
662
+ if (statement.type === 'ExportNamedDeclaration')
663
+ exports[id.name] = selection
664
+
665
+ continue
666
+ }
667
+
668
+ const member = link.members?.[JSON.stringify([key])]
669
+
670
+ if (!member)
671
+ fail(
672
+ 'Destructure only style and the configured single theme; other helpers remain unsupported.',
673
+ id,
674
+ )
675
+
676
+ definitions.set(id.start, member.call)
677
+ names.set(id.name, member.call)
678
+
679
+ if (statement.type === 'ExportNamedDeclaration')
680
+ exports[id.name] = member
681
+ }
682
+ } catch (error) {
683
+ if (!(error instanceof Config.InvalidError)) throw error
684
+
685
+ fail(error.message, expression)
686
+ }
687
+
688
+ continue
689
+ }
690
+
691
+ let definition: Theme.Definition
692
+ let tokenType: string
693
+ let output: Call['output']
694
+
695
+ try {
696
+ if (member.property.name === 'define') {
697
+ if (
698
+ expression.arguments.length < 1 ||
699
+ expression.arguments.length > 2
700
+ )
701
+ fail('Theme.define requires one literal token object.', expression)
702
+
703
+ const input = data(expression.arguments[0]!)
704
+
705
+ tokenType = type(expression.arguments[0]!)
706
+
707
+ const original = Theme.define(input as Theme.Tokens)
708
+
709
+ definition = Token.bind(
710
+ original,
711
+ Object.freeze({ [Token.identity]: name }),
712
+ )
713
+ } else {
714
+ const base = expression.arguments[0]
715
+ const parent = base ? resolve(base)?.call : undefined
716
+
717
+ if (expression.arguments.length !== 2 || !parent)
718
+ fail(
719
+ 'Theme.extend requires a preceding local theme and literal overrides.',
720
+ expression,
721
+ )
722
+
723
+ factoryReferences.add(base!.start)
724
+ definition = Theme.extend(
725
+ themes[parent.name]!,
726
+ data(expression.arguments[1]!) as Theme.Overrides<Theme.Tokens>,
727
+ )
728
+ if (
729
+ definition[Token.definition].contract[Token.identity]?.startsWith(
730
+ 'id-',
731
+ )
732
+ )
733
+ name = definition.className.slice('z_theme-'.length)
734
+ tokenType = parent.tokenType
735
+ output = parent.output
736
+ }
737
+ } catch (error) {
738
+ if (error instanceof InvalidError) throw error
739
+ if (!(error instanceof Theme.InvalidError)) throw error
740
+
741
+ fail(error.message, expression)
742
+ }
743
+
744
+ const call = Object.freeze({
745
+ ...(output ? { output } : {}),
746
+ end: expression.end,
747
+ name,
748
+ start: expression.start,
749
+ tokenType,
750
+ ...(definition[Token.definition].contract.shorthands ||
751
+ output === 'html'
752
+ ? {
753
+ type: `import('zyzz').Config.create.ReturnType<{theme:${tokenType};${output === 'html' ? "output:'html';" : ''}shorthands:${Configurations.type(definition[Token.definition].contract.shorthands ?? {})}}>['theme']`,
754
+ }
755
+ : {}),
756
+ })
757
+
758
+ calls.push(call)
759
+ definitions.set(variable.id.start, call)
760
+ factories.add(expression.start)
761
+ names.set(binding, call)
762
+ themes[name] = definition
763
+
764
+ if (statement.type === 'ExportNamedDeclaration')
765
+ exports[binding] = {
766
+ binding: name,
767
+ call,
768
+ definition,
769
+ kind: 'theme',
770
+ }
771
+ }
772
+ }
773
+
774
+ function registerAlias(input: {
775
+ declaration: Ast.VariableDeclaration
776
+ statement: Ast.Node
777
+ variable: Ast.VariableDeclarator
778
+ }) {
779
+ const { declaration, statement, variable } = input
780
+ const expression = variable.init
781
+ if (!expression) return
782
+
783
+ const linked = resolve(expression)
784
+
785
+ if (linked?.kind === 'config' && variable.id.type === 'ObjectPattern') {
786
+ if (statement.type === 'ExportNamedDeclaration' && !options.linked)
787
+ fail(
788
+ 'Exported configuration destructuring requires source linking.',
789
+ variable,
790
+ )
791
+
792
+ if (declaration.kind !== 'const')
793
+ fail('Configuration destructuring requires const bindings.', variable)
794
+
795
+ const link = linked
796
+
797
+ const bindings = variable.id.properties.map((property) => {
798
+ if (
799
+ property.type !== 'Property' ||
800
+ property.computed ||
801
+ property.key.type !== 'Identifier' ||
802
+ property.value.type !== 'Identifier'
803
+ )
804
+ return fail(
805
+ 'Configuration destructuring requires named bindings without defaults or rest.',
806
+ property,
807
+ )
808
+
809
+ return { key: property.key.name, id: property.value }
810
+ })
811
+
812
+ aliasReferences.add(expression.start)
813
+ aliases.push({
814
+ ...link.call,
815
+ start: expression.start,
816
+ end: expression.end,
817
+ destructured: false,
818
+ retained: true,
819
+ })
820
+
821
+ for (const { key, id } of bindings) {
822
+ if (
823
+ (key === 'style' || key === 'variants') &&
824
+ !link.call.selection &&
825
+ !link.call.initialization
826
+ ) {
827
+ const alias = {
828
+ ...link.call,
829
+ recipe: key === 'variants',
830
+ destructured: false,
831
+ }
832
+
833
+ aliasBindings.set(id.start, alias)
834
+ aliasNames.set(id.name, alias)
835
+
836
+ if (statement.type === 'ExportNamedDeclaration')
837
+ exports[id.name] = {
838
+ ...link,
839
+ binding: `${options.namespace}-${id.name}`,
840
+ call: alias,
841
+ kind: 'style',
842
+ }
843
+
844
+ continue
845
+ }
846
+
847
+ if (
848
+ !link.call.selection &&
849
+ !link.call.initialization &&
850
+ !link.call.root &&
851
+ (key === 'script' ||
852
+ key === 'appearance' ||
853
+ (key === 'themes' && link.call.options?.themes))
854
+ ) {
855
+ if (
856
+ (key === 'script' && !link.call.script) ||
857
+ (key === 'appearance' && !link.call.appearance) ||
858
+ link.call.selection ||
859
+ link.call.initialization
860
+ )
861
+ fail(
862
+ 'This configuration helper is not available on the linked contract.',
863
+ id,
864
+ )
865
+
866
+ if (key === 'script') scripts.add(link.call.name)
867
+ if (key === 'appearance') appearances.add(link.call.name)
868
+ if (key === 'themes') selections.add(link.call.name)
869
+
870
+ const members = Object.fromEntries(
871
+ Object.entries(link.members ?? {}).flatMap(([pathKey, member]) => {
872
+ const path = JSON.parse(pathKey) as string[]
873
+
874
+ return key === 'themes' && path[0] === 'themes'
875
+ ? [[JSON.stringify(path.slice(1)), member]]
876
+ : []
877
+ }),
878
+ )
879
+
880
+ const selection = {
881
+ ...link,
882
+ members,
883
+ call: {
884
+ ...link.call,
885
+ members: Object.fromEntries(
886
+ Object.entries(members).map(([key, member]) => [
887
+ key,
888
+ member.call.name,
889
+ ]),
890
+ ),
891
+ ...helper(key),
892
+ type: `${link.call.type}['${key}']`,
893
+ },
894
+ }
895
+
896
+ configs.set(id.name, selection)
897
+ configBindings.set(id.start, selection)
898
+
899
+ if (statement.type === 'ExportNamedDeclaration')
900
+ exports[id.name] = selection
901
+
902
+ continue
903
+ }
904
+
905
+ const member = link.members?.[JSON.stringify([key])]
906
+
907
+ if (!member)
908
+ fail(
909
+ 'Destructure only style and the configured single theme; other helpers remain unsupported.',
910
+ id,
911
+ )
912
+
913
+ definitions.set(id.start, member.call)
914
+ names.set(id.name, member.call)
915
+
916
+ if (statement.type === 'ExportNamedDeclaration')
917
+ exports[id.name] = member
918
+ }
919
+
920
+ return
921
+ }
922
+
923
+ if (linked && variable.id.type === 'Identifier') {
924
+ if (expression.start < linked.call.end)
925
+ fail('Authoring aliases must follow their definition.', expression)
926
+
927
+ if (
928
+ declaration.kind !== 'const' ||
929
+ (statement.type === 'ExportNamedDeclaration' && !options.linked)
930
+ )
931
+ fail('Authoring aliases require module-level const bindings.', variable)
932
+
933
+ if (linked.kind === 'config') {
934
+ configs.set(variable.id.name, linked)
935
+ configBindings.set(variable.id.start, linked)
936
+ } else {
937
+ names.set(variable.id.name, linked.call)
938
+ definitions.set(variable.id.start, linked.call)
939
+ }
940
+
941
+ aliases.push({
942
+ ...linked.call,
943
+ start: expression.start,
944
+ end: expression.end,
945
+ destructured: false,
946
+ retained: true,
947
+ })
948
+ aliasReferences.add(expression.start)
949
+
950
+ if (statement.type === 'ExportNamedDeclaration')
951
+ exports[variable.id.name] = linked
952
+
953
+ return
954
+ }
955
+
956
+ const member = (() => {
957
+ if (
958
+ expression.type === 'MemberExpression' &&
959
+ !expression.computed &&
960
+ !expression.optional &&
961
+ expression.property.type === 'Identifier' &&
962
+ ['style', 'variants'].includes(expression.property.name)
963
+ ) {
964
+ return expression.object
965
+ }
966
+
967
+ return undefined
968
+ })()
969
+
970
+ const destructured =
971
+ variable.id.type === 'ObjectPattern' && expression.type === 'Identifier'
972
+ const source =
973
+ member ?? (expression.type === 'Identifier' ? expression : undefined)
974
+ if (!source) return
975
+
976
+ const theme = (() => {
977
+ if (member || destructured) {
978
+ return resolve(source)?.call
979
+ }
980
+
981
+ if (source.type === 'Identifier') {
982
+ return aliasNames.get(source.name)
983
+ }
984
+
985
+ return undefined
986
+ })()
987
+ if (!theme) return
988
+
989
+ const bindings = (() => {
990
+ if (destructured && variable.id.type === 'ObjectPattern') {
991
+ if (!variable.id.properties.length)
992
+ fail(
993
+ 'Theme destructuring requires an authoring binding.',
994
+ variable.id,
995
+ )
996
+
997
+ return variable.id.properties.map((property) => {
998
+ if (
999
+ property.type !== 'Property' ||
1000
+ property.computed ||
1001
+ property.key.type !== 'Identifier' ||
1002
+ (property.key.name !== 'style' &&
1003
+ property.key.name !== 'variants') ||
1004
+ property.value.type !== 'Identifier'
1005
+ )
1006
+ fail(
1007
+ 'Destructure only style or variants into const bindings without defaults or rest properties.',
1008
+ property,
1009
+ )
1010
+
1011
+ return { id: property.value, member: property.key.name } as const
1012
+ })
1013
+ }
1014
+
1015
+ if (variable.id.type !== 'Identifier')
1016
+ fail('Theme authoring aliases require named const bindings.', variable)
1017
+
1018
+ const recipe =
1019
+ expression.type === 'MemberExpression' &&
1020
+ expression.property.type === 'Identifier'
1021
+ ? expression.property.name === 'variants'
1022
+ : theme.recipe
1023
+ return [
1024
+ {
1025
+ id: variable.id,
1026
+ member: recipe ? ('variants' as const) : ('style' as const),
1027
+ },
1028
+ ]
1029
+ })()
1030
+
1031
+ if (
1032
+ declaration.kind !== 'const' ||
1033
+ (statement.type === 'ExportNamedDeclaration' && !options.linked)
1034
+ )
1035
+ fail(
1036
+ 'Theme style aliases require a local module-level const binding.',
1037
+ variable,
1038
+ )
1039
+
1040
+ if (expression.start < theme.end)
1041
+ fail('Theme style aliases must follow their definition.', expression)
1042
+
1043
+ for (const [index, { id, member }] of bindings.entries()) {
1044
+ const alias = Object.freeze({
1045
+ recipe: member === 'variants',
1046
+ destructured,
1047
+ end: expression.end,
1048
+ name: theme.name,
1049
+ start: expression.start,
1050
+ tokenType: theme.tokenType,
1051
+ type: theme.type,
1052
+ options: theme.options,
1053
+ output: theme.output,
1054
+ })
1055
+
1056
+ // Each local/exported name keeps its own callable identity, while the
1057
+ // shared initializer is rewritten once with every destructured member.
1058
+ if (index === 0)
1059
+ aliases.push({
1060
+ ...alias,
1061
+ bindings: bindings.map(({ member }) => member),
1062
+ })
1063
+ aliasBindings.set(id.start, alias)
1064
+ aliasNames.set(id.name, alias)
1065
+
1066
+ if (statement.type === 'ExportNamedDeclaration')
1067
+ exports[id.name] = {
1068
+ binding: `${options.namespace}-${id.name}`,
1069
+ call: alias,
1070
+ definition: themes[alias.name]!,
1071
+ kind: 'style',
1072
+ }
1073
+ }
1074
+ aliasReferences.add(source.start)
1075
+ }
1076
+
1077
+ const exportReferences = new Set<number>()
1078
+
1079
+ if (options.linked)
1080
+ for (const statement of program.body) {
1081
+ if (
1082
+ statement.type !== 'ExportNamedDeclaration' ||
1083
+ statement.source ||
1084
+ statement.exportKind === 'type'
1085
+ )
1086
+ continue
1087
+
1088
+ for (const specifier of statement.specifiers) {
1089
+ if (specifier.exportKind === 'type') continue
1090
+
1091
+ const name =
1092
+ specifier.local.type === 'Identifier'
1093
+ ? specifier.local.name
1094
+ : specifier.local.value
1095
+ const call =
1096
+ configs.get(name)?.call ?? names.get(name) ?? aliasNames.get(name)
1097
+ if (!call) continue
1098
+
1099
+ const exported =
1100
+ specifier.exported.type === 'Identifier'
1101
+ ? specifier.exported.name
1102
+ : specifier.exported.value
1103
+
1104
+ exports[exported] = configs.get(name) ??
1105
+ options.links?.[name] ?? {
1106
+ binding: `${options.namespace}-${name}`,
1107
+ call,
1108
+ definition: themes[call.name]!,
1109
+ kind: names.has(name) ? 'theme' : 'style',
1110
+ }
1111
+ exportReferences.add(specifier.local.start)
1112
+ }
1113
+ }
1114
+
1115
+ function reference(
1116
+ node: Extract<Ast.Node, { type: 'Identifier' | 'JSXIdentifier' }>,
1117
+ parent: Ast.Node,
1118
+ ancestors: readonly Ast.Node[],
1119
+ binding: Walker.ScopeTrackerNode | null,
1120
+ ): boolean {
1121
+ const grandparent = ancestors.at(-3)
1122
+
1123
+ if (
1124
+ binding?.type === 'Import' &&
1125
+ (imports.has(binding.node.start) || configImports.has(binding.node.start))
1126
+ ) {
1127
+ if (
1128
+ parent.type === 'MemberExpression' &&
1129
+ grandparent?.type === 'CallExpression' &&
1130
+ factories.has(grandparent.start)
1131
+ )
1132
+ return true
1133
+
1134
+ fail(
1135
+ 'Theme factories require direct module-level const declarations; aliases and indirect references require source linking.',
1136
+ node,
1137
+ )
1138
+ }
1139
+
1140
+ const alias =
1141
+ binding?.type === 'Variable' || binding?.type === 'Import'
1142
+ ? aliasBindings.get(binding.node.start)
1143
+ : undefined
1144
+
1145
+ if (alias) {
1146
+ if (
1147
+ node.start === binding!.node.start ||
1148
+ exportReferences.has(node.start)
1149
+ )
1150
+ return true
1151
+
1152
+ if (node.start < alias.end)
1153
+ fail('Theme style alias references must follow their definition.', node)
1154
+
1155
+ if (aliasReferences.has(node.start)) return true
1156
+
1157
+ if (
1158
+ parent.type !== 'CallExpression' ||
1159
+ parent.callee !== node ||
1160
+ parent.optional
1161
+ )
1162
+ fail(
1163
+ 'Theme style aliases support direct calls only; exporting or escaping them requires source linking.',
1164
+ node,
1165
+ )
1166
+
1167
+ styles.set(parent.start, {
1168
+ call: parent,
1169
+ recipe: alias.recipe,
1170
+ theme: themes[alias.name]!,
1171
+ output:
1172
+ alias.output ??
1173
+ (alias.options?.output === 'html' ? 'html' : undefined),
1174
+ })
1175
+
1176
+ return true
1177
+ }
1178
+
1179
+ const config =
1180
+ binding?.type === 'Variable' || binding?.type === 'Import'
1181
+ ? configBindings.get(binding.node.start)
1182
+ : undefined
1183
+
1184
+ if (config) {
1185
+ if (node.start === binding!.node.start) return true
1186
+
1187
+ if (exportReferences.has(node.start) || aliasReferences.has(node.start))
1188
+ return true
1189
+
1190
+ if (
1191
+ node.start < config.call.end &&
1192
+ config.call.start >= 0 &&
1193
+ binding?.type !== 'Import'
1194
+ )
1195
+ fail('Configuration references must follow their definition.', node)
1196
+
1197
+ // Root controls are an ordinary runtime object; any read or call is valid.
1198
+ if (config.call.root) {
1199
+ appearances.add(config.call.name)
1200
+
1201
+ return true
1202
+ }
1203
+
1204
+ if (
1205
+ (config.call.selection || config.call.initialization) &&
1206
+ parent.type === 'CallExpression' &&
1207
+ parent.callee === node &&
1208
+ !parent.optional
1209
+ ) {
1210
+ if (config.call.selection && config.call.catalogOnly)
1211
+ fail(
1212
+ 'This legacy catalog is not callable; rebuild its library.',
1213
+ node,
1214
+ )
1215
+
1216
+ if (config.call.selection) selections.add(config.call.name)
1217
+ if (config.call.initialization) scripts.add(config.call.name)
1218
+
1219
+ return true
1220
+ }
1221
+
1222
+ let target: Ast.Node = node
1223
+ const path: string[] = []
1224
+
1225
+ for (let index = ancestors.length - 2; index >= 0; index--) {
1226
+ const member = ancestors[index]!
1227
+
1228
+ if (
1229
+ member.type !== 'MemberExpression' ||
1230
+ member.object !== target ||
1231
+ member.optional
1232
+ )
1233
+ break
1234
+
1235
+ const key = (() => {
1236
+ if (member.property.type === 'Identifier' && !member.computed) {
1237
+ return member.property.name
1238
+ }
1239
+
1240
+ if (
1241
+ member.property.type === 'Literal' &&
1242
+ member.computed &&
1243
+ (typeof member.property.value === 'string' ||
1244
+ typeof member.property.value === 'number')
1245
+ ) {
1246
+ return String(member.property.value)
1247
+ }
1248
+
1249
+ return undefined
1250
+ })()
1251
+
1252
+ if (key === undefined) break
1253
+
1254
+ path.push(key)
1255
+ target = member
1256
+
1257
+ if (
1258
+ aliasReferences.has(target.start) ||
1259
+ factoryReferences.has(target.start)
1260
+ )
1261
+ return true
1262
+
1263
+ if (
1264
+ path.length === 1 &&
1265
+ path[0] === 'appearance' &&
1266
+ !config.call.selection &&
1267
+ !config.call.initialization
1268
+ ) {
1269
+ if (!config.call.appearance)
1270
+ fail(
1271
+ 'This packed configuration does not provide appearance; rebuild its library with root control support.',
1272
+ target,
1273
+ )
1274
+
1275
+ appearances.add(config.call.name)
1276
+
1277
+ return true
1278
+ }
1279
+
1280
+ if (
1281
+ path.length === 1 &&
1282
+ !config.call.selection &&
1283
+ !config.call.initialization &&
1284
+ ['script', 'themes'].includes(path[0]!) &&
1285
+ ancestors[index - 1]?.type === 'CallExpression' &&
1286
+ (ancestors[index - 1] as Ast.CallExpression).callee === target &&
1287
+ !(ancestors[index - 1] as Ast.CallExpression).optional
1288
+ ) {
1289
+ if (path[0] === 'themes' && !config.call.options?.themes)
1290
+ fail('Theme selection requires a named catalog.', target)
1291
+
1292
+ if (path[0] === 'themes' && config.call.catalogOnly)
1293
+ fail(
1294
+ 'This legacy catalog is not callable; rebuild its library.',
1295
+ target,
1296
+ )
1297
+
1298
+ if (path[0] === 'script') {
1299
+ if (!config.call.script)
1300
+ fail(
1301
+ 'This packed configuration does not provide script(); rebuild its library with initialization support.',
1302
+ target,
1303
+ )
1304
+
1305
+ scripts.add(config.call.name)
1306
+ }
1307
+
1308
+ if (path[0] === 'themes') selections.add(config.call.name)
1309
+
1310
+ return true
1311
+ }
1312
+
1313
+ if (
1314
+ path.length === 1 &&
1315
+ (path[0] === 'style' || path[0] === 'variants')
1316
+ ) {
1317
+ const call = ancestors[index - 1]
1318
+
1319
+ if (
1320
+ call?.type !== 'CallExpression' ||
1321
+ call.callee !== target ||
1322
+ call.optional
1323
+ )
1324
+ break
1325
+
1326
+ styles.set(call.start, {
1327
+ call,
1328
+ recipe: path[0] === 'variants',
1329
+ theme: config.definition,
1330
+ output: config.call.options?.output === 'html' ? 'html' : undefined,
1331
+ })
1332
+
1333
+ return true
1334
+ }
1335
+
1336
+ const linked = config.members?.[JSON.stringify(path)]
1337
+ if (linked)
1338
+ return themeReference(
1339
+ target,
1340
+ ancestors[index - 1]!,
1341
+ ancestors.slice(0, index + 1),
1342
+ linked.call,
1343
+ )
1344
+ }
1345
+
1346
+ // A compiled selector is an ordinary runtime function, so passing or storing it is safe.
1347
+ if (config.call.selection && !config.call.catalogOnly && !path.length) {
1348
+ selections.add(config.call.name)
1349
+
1350
+ return true
1351
+ }
1352
+
1353
+ fail(
1354
+ 'Use direct configuration style calls or static theme members; configurations cannot escape or be mutated.',
1355
+ node,
1356
+ )
1357
+ }
1358
+
1359
+ const theme =
1360
+ binding?.type === 'Variable' || binding?.type === 'Import'
1361
+ ? definitions.get(binding.node.start)
1362
+ : undefined
1363
+ if (!theme) return false
1364
+ if (node.start === binding!.node.start) return true
1365
+
1366
+ return themeReference(node, parent, ancestors, theme)
1367
+ }
1368
+
1369
+ function themeReference(
1370
+ node: Ast.Node,
1371
+ parent: Ast.Node,
1372
+ ancestors: readonly Ast.Node[],
1373
+ theme: Call,
1374
+ ): boolean {
1375
+ const grandparent = ancestors.at(-3)
1376
+ if (factoryReferences.has(node.start)) return true
1377
+ if (exportReferences.has(node.start)) return true
1378
+ if (aliasReferences.has(node.start)) return true
1379
+
1380
+ if (node.start < theme.end)
1381
+ fail('Theme references must follow their local definition.', node)
1382
+
1383
+ if (
1384
+ parent.type === 'CallExpression' &&
1385
+ factories.has(parent.start) &&
1386
+ parent.arguments[0] === node
1387
+ )
1388
+ return true
1389
+
1390
+ if (
1391
+ parent.type === 'MemberExpression' &&
1392
+ parent.object === node &&
1393
+ ((parent.property.type === 'Identifier' &&
1394
+ !parent.computed &&
1395
+ ['tokens', 'vars'].includes(parent.property.name)) ||
1396
+ (parent.property.type === 'Literal' &&
1397
+ parent.computed &&
1398
+ ['tokens', 'vars'].includes(String(parent.property.value))))
1399
+ ) {
1400
+ if (parent.optional)
1401
+ fail('Token references cannot use optional access.', parent)
1402
+
1403
+ const variable =
1404
+ parent.property.type === 'Identifier'
1405
+ ? parent.property.name === 'vars'
1406
+ : parent.property.type === 'Literal' &&
1407
+ parent.property.value === 'vars'
1408
+
1409
+ let value: unknown = variable
1410
+ ? themes[theme.name]!.vars
1411
+ : themes[theme.name]!.tokens
1412
+ let target: Ast.Node = parent
1413
+ let index = ancestors.length - 3
1414
+
1415
+ for (; index >= 0; index--) {
1416
+ const ancestor = ancestors[index]!
1417
+
1418
+ if (ancestor.type !== 'MemberExpression' || ancestor.object !== target)
1419
+ break
1420
+
1421
+ const key = (() => {
1422
+ if (ancestor.property.type === 'Identifier' && !ancestor.computed) {
1423
+ return ancestor.property.name
1424
+ }
1425
+
1426
+ if (
1427
+ ancestor.property.type === 'Literal' &&
1428
+ ancestor.computed &&
1429
+ (typeof ancestor.property.value === 'string' ||
1430
+ typeof ancestor.property.value === 'number')
1431
+ ) {
1432
+ return String(ancestor.property.value)
1433
+ }
1434
+
1435
+ return undefined
1436
+ })()
1437
+
1438
+ if (ancestor.optional || key === undefined)
1439
+ fail(
1440
+ 'Token paths require static property names without optional access.',
1441
+ ancestor,
1442
+ )
1443
+
1444
+ value =
1445
+ value && typeof value === 'object' && !Token.is(value)
1446
+ ? Object.getOwnPropertyDescriptor(value, key)?.value
1447
+ : undefined
1448
+
1449
+ if (value === undefined) fail('Unknown theme token path.', ancestor)
1450
+
1451
+ target = ancestor
1452
+ }
1453
+
1454
+ if (!Token.is(value))
1455
+ fail('Expected a scalar theme token reference.', target)
1456
+
1457
+ const reference = value
1458
+
1459
+ for (; index >= 0; index--) {
1460
+ const ancestor = ancestors[index]!
1461
+
1462
+ if (
1463
+ (ancestor.type === 'TSAsExpression' ||
1464
+ ancestor.type === 'TSSatisfiesExpression' ||
1465
+ ancestor.type === 'TSNonNullExpression' ||
1466
+ ancestor.type === 'TSTypeAssertion') &&
1467
+ ancestor.expression === target
1468
+ )
1469
+ target = ancestor
1470
+ else break
1471
+ }
1472
+
1473
+ const valueTarget = target
1474
+
1475
+ if (variable) {
1476
+ while (index >= 0) {
1477
+ const ancestor = ancestors[index]!
1478
+
1479
+ if (
1480
+ !(
1481
+ (ancestor.type === 'TemplateLiteral' &&
1482
+ ancestor.expressions.includes(target as Ast.Expression)) ||
1483
+ ((ancestor.type === 'TSAsExpression' ||
1484
+ ancestor.type === 'TSSatisfiesExpression' ||
1485
+ ancestor.type === 'TSNonNullExpression' ||
1486
+ ancestor.type === 'TSTypeAssertion') &&
1487
+ ancestor.expression === target)
1488
+ )
1489
+ )
1490
+ break
1491
+
1492
+ target = ancestor
1493
+ index--
1494
+ }
1495
+ }
1496
+
1497
+ const array = ancestors[index]
1498
+
1499
+ if (
1500
+ array?.type === 'ArrayExpression' &&
1501
+ array.elements.includes(target as Ast.Expression)
1502
+ ) {
1503
+ target = array
1504
+ index--
1505
+
1506
+ for (; index >= 0; index--) {
1507
+ const ancestor = ancestors[index]!
1508
+
1509
+ if (
1510
+ (ancestor.type === 'TSAsExpression' ||
1511
+ ancestor.type === 'TSSatisfiesExpression' ||
1512
+ ancestor.type === 'TSNonNullExpression' ||
1513
+ ancestor.type === 'TSTypeAssertion') &&
1514
+ ancestor.expression === target
1515
+ )
1516
+ target = ancestor
1517
+ else break
1518
+ }
1519
+ }
1520
+
1521
+ const property = ancestors[index]
1522
+ const object = ancestors[index - 1]
1523
+ let argument: Ast.Node | undefined = object
1524
+ let callIndex = index - 2
1525
+
1526
+ for (; callIndex >= 0; callIndex--) {
1527
+ const ancestor = ancestors[callIndex]!
1528
+
1529
+ if (
1530
+ ancestor.type === 'Property' &&
1531
+ ancestor.value === argument &&
1532
+ ancestors[callIndex - 1]?.type === 'ObjectExpression'
1533
+ ) {
1534
+ argument = ancestors[--callIndex]
1535
+ continue
1536
+ }
1537
+
1538
+ if (
1539
+ (ancestor.type === 'TSAsExpression' ||
1540
+ ancestor.type === 'TSSatisfiesExpression' ||
1541
+ ancestor.type === 'TSNonNullExpression' ||
1542
+ ancestor.type === 'TSTypeAssertion') &&
1543
+ ancestor.expression === argument
1544
+ )
1545
+ argument = ancestor
1546
+ else break
1547
+ }
1548
+
1549
+ if (
1550
+ ancestors[callIndex]?.type === 'ArrowFunctionExpression' &&
1551
+ (ancestors[callIndex] as Ast.ArrowFunctionExpression).body === argument
1552
+ ) {
1553
+ argument = ancestors[callIndex]
1554
+ callIndex--
1555
+ }
1556
+
1557
+ while (callIndex >= 0) {
1558
+ const wrapper = ancestors[callIndex]!
1559
+
1560
+ if (
1561
+ (wrapper.type === 'TSAsExpression' ||
1562
+ wrapper.type === 'TSSatisfiesExpression' ||
1563
+ wrapper.type === 'TSNonNullExpression' ||
1564
+ wrapper.type === 'TSTypeAssertion') &&
1565
+ wrapper.expression === argument
1566
+ ) {
1567
+ argument = wrapper
1568
+ callIndex--
1569
+ } else break
1570
+ }
1571
+
1572
+ const call = ancestors[callIndex]
1573
+
1574
+ if (
1575
+ property?.type !== 'Property' ||
1576
+ property.value !== target ||
1577
+ object?.type !== 'ObjectExpression' ||
1578
+ call?.type !== 'CallExpression' ||
1579
+ call.arguments[0] !== argument ||
1580
+ (!styles.has(call.start) && !options.contributionCalls?.has(call.start))
1581
+ ) {
1582
+ if (
1583
+ ancestors.some(
1584
+ (node) =>
1585
+ node.type === 'VariableDeclarator' &&
1586
+ options.staticBindings?.has(node.start),
1587
+ )
1588
+ )
1589
+ staticTokens.push(valueTarget)
1590
+ else
1591
+ fail(
1592
+ 'Token references must be direct property values in bound theme style calls.',
1593
+ target,
1594
+ )
1595
+ }
1596
+
1597
+ tokens.set(valueTarget.start, { end: valueTarget.end, reference })
1598
+
1599
+ const unwrapped = Expression.unwrap(valueTarget)
1600
+
1601
+ tokens.set(unwrapped.start, { end: unwrapped.end, reference })
1602
+
1603
+ return true
1604
+ }
1605
+
1606
+ if (
1607
+ parent.type !== 'MemberExpression' ||
1608
+ parent.object !== node ||
1609
+ parent.computed ||
1610
+ parent.optional ||
1611
+ parent.property.type !== 'Identifier'
1612
+ )
1613
+ fail(
1614
+ 'Use local theme.style calls, theme.className reads, or Theme.extend; other theme references require source linking.',
1615
+ node,
1616
+ )
1617
+
1618
+ if (
1619
+ ['style', 'variants'].includes(parent.property.name) &&
1620
+ grandparent?.type === 'CallExpression' &&
1621
+ grandparent.callee === parent &&
1622
+ !grandparent.optional
1623
+ ) {
1624
+ styles.set(grandparent.start, {
1625
+ call: grandparent,
1626
+ recipe: parent.property.name === 'variants',
1627
+ theme: themes[theme.name]!,
1628
+ output: theme.output,
1629
+ })
1630
+
1631
+ return true
1632
+ }
1633
+
1634
+ if (parent.property.name !== 'className')
1635
+ fail(
1636
+ 'Only direct theme.style calls and theme.className reads are supported here.',
1637
+ parent,
1638
+ )
1639
+
1640
+ let target: Ast.Node = parent
1641
+
1642
+ for (let index = ancestors.length - 3; index >= 0; index--) {
1643
+ const ancestor = ancestors[index]!
1644
+
1645
+ if (
1646
+ (ancestor.type === 'AssignmentExpression' &&
1647
+ ancestor.left === target) ||
1648
+ (ancestor.type === 'UpdateExpression' &&
1649
+ ancestor.argument === target) ||
1650
+ (ancestor.type === 'UnaryExpression' &&
1651
+ ancestor.operator === 'delete') ||
1652
+ ((ancestor.type === 'ForInStatement' ||
1653
+ ancestor.type === 'ForOfStatement') &&
1654
+ ancestor.left === target)
1655
+ )
1656
+ fail('Theme scope properties cannot be reassigned.', ancestor)
1657
+
1658
+ if (
1659
+ ((ancestor.type === 'TSAsExpression' ||
1660
+ ancestor.type === 'TSNonNullExpression' ||
1661
+ ancestor.type === 'TSSatisfiesExpression' ||
1662
+ ancestor.type === 'TSTypeAssertion') &&
1663
+ ancestor.expression === target) ||
1664
+ (ancestor.type === 'Property' && ancestor.value === target) ||
1665
+ ancestor.type === 'ObjectPattern' ||
1666
+ ancestor.type === 'ArrayPattern' ||
1667
+ (ancestor.type === 'RestElement' && ancestor.argument === target) ||
1668
+ (ancestor.type === 'AssignmentPattern' && ancestor.left === target)
1669
+ )
1670
+ target = ancestor
1671
+ else break
1672
+ }
1673
+
1674
+ references.push(
1675
+ Object.freeze({ end: parent.end, name: theme.name, start: parent.start }),
1676
+ )
1677
+
1678
+ return true
1679
+ }
1680
+
1681
+ for (const link of Object.values(exports))
1682
+ if (
1683
+ link.kind === 'config' &&
1684
+ !link.call.selection &&
1685
+ !link.call.initialization &&
1686
+ !link.call.root
1687
+ ) {
1688
+ if (link.call.script) scripts.add(link.call.name)
1689
+ if (link.call.appearance) appearances.add(link.call.name)
1690
+ }
1691
+
1692
+ const nativeContexts = new Map<
1693
+ Token.Contract,
1694
+ NonNullable<Source.Call['nativeContext']>
1695
+ >()
1696
+ return {
1697
+ nativeContext(start: number, end: number) {
1698
+ const theme = styles.get(start)?.theme
1699
+ const contract =
1700
+ theme?.[Token.definition].contract ??
1701
+ [...tokens].find(([offset]) => offset >= start && offset < end)?.[1]
1702
+ .reference.contract
1703
+ if (!contract) return undefined
1704
+ const cached = nativeContexts.get(contract)
1705
+ if (cached) return cached
1706
+ const config = [...configs.values()].find(
1707
+ (value) => value.definition[Token.definition].contract === contract,
1708
+ )
1709
+ if (!config?.call.options?.themes) {
1710
+ const alias = [...aliasNames.values()].find(
1711
+ (value) =>
1712
+ themes[value.name]?.[Token.definition].contract === contract &&
1713
+ value.options?.themes,
1714
+ )
1715
+ if (!alias?.options?.themes) return undefined
1716
+ const context = {
1717
+ defaultTheme: String(alias.options.defaultTheme),
1718
+ themes: Object.fromEntries(
1719
+ Object.entries(
1720
+ alias.options.themes as Record<
1721
+ string,
1722
+ Parameters<typeof Theme.define>[0]
1723
+ >,
1724
+ ).map(([name, values]) => [
1725
+ name,
1726
+ Token.bind(Theme.define(values), contract),
1727
+ ]),
1728
+ ),
1729
+ }
1730
+ Object.freeze(context.themes)
1731
+ nativeContexts.set(contract, Object.freeze(context))
1732
+ return context
1733
+ }
1734
+ const entries = Object.entries(config.members ?? {}).flatMap(
1735
+ ([key, value]) => {
1736
+ const path = JSON.parse(key) as string[]
1737
+ return path[0] === 'themes' && path.length === 2
1738
+ ? [[path[1]!, value.definition] as const]
1739
+ : []
1740
+ },
1741
+ )
1742
+ const context = Object.freeze({
1743
+ defaultTheme: String(config.call.options.defaultTheme),
1744
+ themes: Object.freeze(Object.fromEntries(entries)),
1745
+ })
1746
+ nativeContexts.set(contract, context)
1747
+ return context
1748
+ },
1749
+ aliases,
1750
+ appearances,
1751
+ calls,
1752
+ exports: Object.freeze(exports),
1753
+ reference,
1754
+ references,
1755
+ scripts,
1756
+ selections,
1757
+ staticTokens,
1758
+ styles,
1759
+ themes: Object.freeze(themes),
1760
+ tokens,
1761
+ }
1762
+ }
1763
+
1764
+ /** Inputs supplied by the source adapter. */
1765
+ export declare namespace collect {
1766
+ /** Stable module namespace, independent of token values and call offsets. */
1767
+ type Options = {
1768
+ /** Encoded package/module identity from the source adapter. */
1769
+ readonly staticBindings?: ReadonlySet<number> | undefined
1770
+ readonly contributionCalls?: ReadonlySet<number> | undefined
1771
+ readonly namespace: string
1772
+ readonly linked?: boolean | undefined
1773
+ readonly links?: Readonly<Record<string, Link>> | undefined
1774
+ }
1775
+ }
1776
+
1777
+ /** Located failure from unsupported or invalid local theme syntax. */
1778
+ export class InvalidError extends Error {
1779
+ /** Retains a source span for the public extractor diagnostic. */
1780
+ constructor(message: string, node: Pick<Ast.Node, 'end' | 'start'>) {
1781
+ super(message)
1782
+ this.end = node.end
1783
+ this.start = node.start
1784
+ }
1785
+ /** Exclusive source offset. */
1786
+ readonly end: number
1787
+ /** Namespaced diagnostic identity. */
1788
+ override name = 'Source.ThemeInvalidError'
1789
+ /** Inclusive source offset. */
1790
+ readonly start: number
1791
+ }
1792
+
1793
+ /** Scope property read replaced with a compiled constant. */
1794
+ export type Reference = Pick<Call, 'end' | 'name' | 'start'>