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,1169 @@
1
+ import * as Identity from '../../internal/Identity.js';
2
+ import * as Identifiers from './Identifiers.js';
3
+ import * as Config from '../../Config.js';
4
+ import * as Expression from './Expression.js';
5
+ import * as Configurations from './Configurations.js';
6
+ import * as Token from '../../internal/Token.js';
7
+ import * as Theme from '../../Theme.js';
8
+ /** Internal context passed between graph extraction and module rewriting. */
9
+ export const context = Symbol('zyzz.source.graph');
10
+ /** Collects immutable module-level themes without evaluating source. */
11
+ export function collect(program, options) {
12
+ const staticTokens = [];
13
+ const aliases = [];
14
+ const aliasBindings = new Map();
15
+ const aliasReferences = new Set();
16
+ const appearances = new Set();
17
+ const selections = new Set();
18
+ const calls = [];
19
+ const scripts = new Set();
20
+ const definitions = new Map();
21
+ const factories = new Set();
22
+ const imports = new Set();
23
+ const configImports = new Set();
24
+ const configs = new Map();
25
+ const configBindings = new Map();
26
+ const factoryReferences = new Set();
27
+ const references = [];
28
+ const styles = new Map();
29
+ const themes = Object.create(null);
30
+ const tokens = new Map();
31
+ for (const node of program.body) {
32
+ if (node.type !== 'ImportDeclaration' ||
33
+ node.source.value !== 'zyzz' ||
34
+ node.importKind === 'type')
35
+ continue;
36
+ for (const specifier of node.specifiers)
37
+ if (specifier.type === 'ImportSpecifier' &&
38
+ specifier.importKind !== 'type' &&
39
+ (specifier.imported.type === 'Identifier'
40
+ ? specifier.imported.name
41
+ : specifier.imported.value) === 'Theme')
42
+ imports.add(specifier.start);
43
+ else if (specifier.type === 'ImportSpecifier' &&
44
+ specifier.importKind !== 'type' &&
45
+ (specifier.imported.type === 'Identifier'
46
+ ? specifier.imported.name
47
+ : specifier.imported.value) === 'Config')
48
+ configImports.add(specifier.start);
49
+ }
50
+ if (!imports.size &&
51
+ !configImports.size &&
52
+ !Object.keys(options.links ?? {}).length)
53
+ return undefined;
54
+ const names = new Map();
55
+ const aliasNames = new Map();
56
+ const exports = Object.create(null);
57
+ for (const node of program.body) {
58
+ if (node.type !== 'ImportDeclaration' || node.importKind === 'type')
59
+ continue;
60
+ for (const specifier of node.specifiers) {
61
+ const link = options.links?.[specifier.local.name];
62
+ if (!link ||
63
+ link.kind === 'style-reference' ||
64
+ link.kind === 'animation' ||
65
+ link.kind === 'rule-reference' ||
66
+ link.kind === 'variables')
67
+ continue;
68
+ const call = { ...link.call, start: -1, end: -1 };
69
+ themes[call.name] = link.definition;
70
+ if (link.kind === 'config') {
71
+ const imported = {
72
+ ...link,
73
+ call,
74
+ members: Object.fromEntries(Object.entries(link.members ?? {}).map(([key, member]) => [
75
+ key,
76
+ { ...member, call: { ...member.call, start: -1, end: -1 } },
77
+ ])),
78
+ };
79
+ configs.set(specifier.local.name, imported);
80
+ configBindings.set(specifier.start, imported);
81
+ for (const member of Object.values(link.members ?? {}))
82
+ themes[member.call.name] = member.definition;
83
+ }
84
+ else if (link.kind === 'theme') {
85
+ definitions.set(specifier.start, call);
86
+ names.set(specifier.local.name, call);
87
+ }
88
+ else {
89
+ const alias = { ...call, destructured: false };
90
+ aliasBindings.set(specifier.start, alias);
91
+ aliasNames.set(specifier.local.name, alias);
92
+ }
93
+ }
94
+ }
95
+ const namespaces = new Set();
96
+ const configNamespaces = new Set();
97
+ for (const node of program.body)
98
+ if (node.type === 'ImportDeclaration')
99
+ for (const specifier of node.specifiers)
100
+ if (imports.has(specifier.start))
101
+ namespaces.add(specifier.local.name);
102
+ else if (configImports.has(specifier.start))
103
+ configNamespaces.add(specifier.local.name);
104
+ function resolve(node) {
105
+ if (node.type === 'Identifier') {
106
+ const config = configs.get(node.name);
107
+ if (config)
108
+ return config;
109
+ const call = names.get(node.name);
110
+ if (call)
111
+ return {
112
+ binding: call.name,
113
+ call,
114
+ definition: themes[call.name],
115
+ kind: 'theme',
116
+ };
117
+ return undefined;
118
+ }
119
+ if (node.type !== 'MemberExpression' || node.optional)
120
+ return undefined;
121
+ const path = [];
122
+ let root = node;
123
+ while (root.type === 'MemberExpression') {
124
+ const key = (() => {
125
+ if (root.property.type === 'Identifier' && !root.computed) {
126
+ return root.property.name;
127
+ }
128
+ if (root.property.type === 'Literal' &&
129
+ root.computed &&
130
+ (typeof root.property.value === 'string' ||
131
+ typeof root.property.value === 'number')) {
132
+ return String(root.property.value);
133
+ }
134
+ return undefined;
135
+ })();
136
+ if (root.optional || key === undefined)
137
+ return undefined;
138
+ path.unshift(key);
139
+ root = root.object;
140
+ }
141
+ const config = root.type === 'Identifier' ? configs.get(root.name) : undefined;
142
+ if (config &&
143
+ !config.call.selection &&
144
+ !config.call.initialization &&
145
+ !config.call.root &&
146
+ path.length === 1 &&
147
+ ['themes', 'script', 'appearance'].includes(path[0])) {
148
+ const key = path[0];
149
+ if (key === 'script')
150
+ scripts.add(config.call.name);
151
+ if (key === 'appearance')
152
+ appearances.add(config.call.name);
153
+ if (key === 'themes' && !config.call.options?.themes)
154
+ return undefined;
155
+ if (key === 'themes')
156
+ selections.add(config.call.name);
157
+ if (key === 'script' && !config.call.script)
158
+ fail('This packed configuration does not provide script(); rebuild its library with initialization support.', node);
159
+ if (key === 'appearance' && !config.call.appearance)
160
+ fail('This packed configuration does not provide appearance; rebuild its library with root control support.', node);
161
+ const members = Object.fromEntries(Object.entries(config.members ?? {}).flatMap(([name, member]) => {
162
+ const parts = JSON.parse(name);
163
+ return key === 'themes' && parts[0] === 'themes'
164
+ ? [[JSON.stringify(parts.slice(1)), member]]
165
+ : [];
166
+ }));
167
+ return {
168
+ ...config,
169
+ members,
170
+ binding: `${config.binding}:${key}`,
171
+ call: {
172
+ ...config.call,
173
+ members: Object.fromEntries(Object.entries(members).map(([name, member]) => [
174
+ name,
175
+ member.call.name,
176
+ ])),
177
+ ...helper(key),
178
+ type: `${config.call.type}['${key}']`,
179
+ },
180
+ };
181
+ }
182
+ return config?.members?.[JSON.stringify(path)];
183
+ }
184
+ /** Marks which configuration helper a destructured or member binding represents. */
185
+ function helper(key) {
186
+ if (key === 'script')
187
+ return { initialization: true };
188
+ if (key === 'appearance')
189
+ return { root: true };
190
+ return { selection: true };
191
+ }
192
+ function data(node) {
193
+ if (node.type === 'TSAsExpression' || node.type === 'TSSatisfiesExpression')
194
+ return data(node.expression);
195
+ if (node.type === 'Literal' &&
196
+ (typeof node.value === 'string' || typeof node.value === 'number'))
197
+ return node.value;
198
+ if (node.type === 'UnaryExpression' &&
199
+ (node.operator === '+' || node.operator === '-') &&
200
+ node.argument.type === 'Literal' &&
201
+ typeof node.argument.value === 'number')
202
+ return node.operator === '-' ? -node.argument.value : node.argument.value;
203
+ if (node.type === 'ArrayExpression')
204
+ return node.elements.map((element) => {
205
+ if (!element || element.type === 'SpreadElement')
206
+ return fail('Theme arrays require dense literal elements.', node);
207
+ return data(element);
208
+ });
209
+ if (node.type !== 'ObjectExpression')
210
+ return fail('Theme values must be literal data; expressions are not evaluated.', node);
211
+ const result = Object.create(null);
212
+ for (const property of node.properties) {
213
+ if (property.type !== 'Property' ||
214
+ property.computed ||
215
+ property.method ||
216
+ property.shorthand ||
217
+ property.kind !== 'init')
218
+ return fail('Theme data requires explicit properties without spreads, methods, or computed keys.', property);
219
+ const key = (() => {
220
+ if (property.key.type === 'Identifier') {
221
+ return property.key.name;
222
+ }
223
+ if (property.key.type === 'Literal' &&
224
+ (typeof property.key.value === 'string' ||
225
+ typeof property.key.value === 'number')) {
226
+ return String(property.key.value);
227
+ }
228
+ return undefined;
229
+ })();
230
+ if (key === undefined || Object.hasOwn(result, key))
231
+ return fail('Theme data requires unique literal keys.', property);
232
+ result[key] = data(property.value);
233
+ }
234
+ return result;
235
+ }
236
+ function fail(message, node) {
237
+ throw new InvalidError(message, node);
238
+ }
239
+ function type(node) {
240
+ if (node.type === 'TSAsExpression' || node.type === 'TSSatisfiesExpression')
241
+ return type(node.expression);
242
+ if (node.type !== 'ObjectExpression')
243
+ return JSON.stringify(data(node));
244
+ return `{${node.properties
245
+ .map((property) => {
246
+ if (property.type !== 'Property')
247
+ return fail('Expected validated theme properties.', property);
248
+ const key = (() => {
249
+ if (property.key.type === 'Identifier') {
250
+ return JSON.stringify(property.key.name);
251
+ }
252
+ if (property.key.type === 'Literal') {
253
+ return JSON.stringify(property.key.value);
254
+ }
255
+ return fail('Expected a literal theme key.', property.key);
256
+ })();
257
+ return `readonly ${key}:${type(property.value)}`;
258
+ })
259
+ .join(';')}}`;
260
+ }
261
+ for (const statement of program.body) {
262
+ const declaration = statement.type === 'ExportNamedDeclaration'
263
+ ? statement.declaration
264
+ : statement;
265
+ if (declaration?.type !== 'VariableDeclaration')
266
+ continue;
267
+ for (const variable of declaration.declarations) {
268
+ registerAlias({ declaration, statement, variable });
269
+ const expression = variable.init;
270
+ if (expression?.type !== 'CallExpression' ||
271
+ expression.callee.type !== 'MemberExpression' ||
272
+ expression.callee.object.type !== 'Identifier' ||
273
+ (!namespaces.has(expression.callee.object.name) &&
274
+ !configNamespaces.has(expression.callee.object.name)))
275
+ continue;
276
+ const member = expression.callee;
277
+ if (member.computed ||
278
+ member.optional ||
279
+ expression.optional ||
280
+ member.property.type !== 'Identifier' ||
281
+ !(configNamespaces.has(expression.callee.object.name)
282
+ ? ['create']
283
+ : ['define', 'extend']).includes(member.property.name))
284
+ continue;
285
+ if ((statement.type === 'ExportNamedDeclaration' && !options.linked) ||
286
+ declaration.kind !== 'const' ||
287
+ (variable.id.type !== 'Identifier' &&
288
+ !(configNamespaces.has(expression.callee.object.name) &&
289
+ variable.id.type === 'ObjectPattern')))
290
+ fail('Define local themes with a module-level const; exported themes require source linking.', variable);
291
+ const bindings = (() => {
292
+ if (variable.id.type !== 'ObjectPattern')
293
+ return [];
294
+ return variable.id.properties.map((property) => {
295
+ if (property.type !== 'Property' ||
296
+ property.computed ||
297
+ property.key.type !== 'Identifier' ||
298
+ property.value.type !== 'Identifier')
299
+ fail('Configuration destructuring requires named bindings without defaults, rest, or nested patterns.', property);
300
+ return { key: property.key.name, id: property.value };
301
+ });
302
+ })();
303
+ const binding = variable.id.type === 'Identifier'
304
+ ? variable.id.name
305
+ : bindings[0]?.id.name;
306
+ if (!binding)
307
+ fail('Configuration destructuring requires a binding.', variable);
308
+ let name = `${options.namespace}-${binding}`;
309
+ if (!configNamespaces.has(expression.callee.object.name) &&
310
+ member.property.name === 'define') {
311
+ const id = Identifiers.explicit(expression);
312
+ if (id !== undefined)
313
+ name = Identity.requireId(id, 'Theme.define');
314
+ }
315
+ if (configNamespaces.has(expression.callee.object.name)) {
316
+ try {
317
+ const link = Configurations.collect({
318
+ data,
319
+ expression,
320
+ name,
321
+ resolve: (node) => {
322
+ const link = resolve(node);
323
+ if (link)
324
+ factoryReferences.add(node.start);
325
+ return link;
326
+ },
327
+ });
328
+ if (variable.id.type === 'Identifier') {
329
+ configs.set(variable.id.name, link);
330
+ configBindings.set(variable.id.start, link);
331
+ if (statement.type === 'ExportNamedDeclaration')
332
+ exports[variable.id.name] = link;
333
+ }
334
+ calls.push(link.call);
335
+ factories.add(expression.start);
336
+ for (const member of Object.values(link.members ?? {}))
337
+ themes[member.call.name] = member.definition;
338
+ themes[link.call.name] = link.definition;
339
+ for (const { key, id } of bindings) {
340
+ if ((key === 'style' || key === 'variants') &&
341
+ !link.call.selection &&
342
+ !link.call.initialization) {
343
+ const alias = {
344
+ ...link.call,
345
+ recipe: key === 'variants',
346
+ destructured: false,
347
+ };
348
+ aliasBindings.set(id.start, alias);
349
+ aliasNames.set(id.name, alias);
350
+ if (statement.type === 'ExportNamedDeclaration')
351
+ exports[id.name] = {
352
+ ...link,
353
+ binding: `${options.namespace}-${id.name}`,
354
+ call: alias,
355
+ kind: 'style',
356
+ };
357
+ continue;
358
+ }
359
+ if (!link.call.selection &&
360
+ !link.call.initialization &&
361
+ !link.call.root &&
362
+ (key === 'script' ||
363
+ key === 'appearance' ||
364
+ (key === 'themes' && link.call.options?.themes))) {
365
+ if ((key === 'script' && !link.call.script) ||
366
+ (key === 'appearance' && !link.call.appearance) ||
367
+ link.call.selection ||
368
+ link.call.initialization)
369
+ fail('This configuration helper is not available on the linked contract.', id);
370
+ if (key === 'script')
371
+ scripts.add(link.call.name);
372
+ if (key === 'appearance')
373
+ appearances.add(link.call.name);
374
+ if (key === 'themes')
375
+ selections.add(link.call.name);
376
+ const members = Object.fromEntries(Object.entries(link.members ?? {}).flatMap(([pathKey, member]) => {
377
+ const path = JSON.parse(pathKey);
378
+ return key === 'themes' && path[0] === 'themes'
379
+ ? [[JSON.stringify(path.slice(1)), member]]
380
+ : [];
381
+ }));
382
+ const selection = {
383
+ ...link,
384
+ members,
385
+ call: {
386
+ ...link.call,
387
+ members: Object.fromEntries(Object.entries(members).map(([key, member]) => [
388
+ key,
389
+ member.call.name,
390
+ ])),
391
+ ...helper(key),
392
+ type: `${link.call.type}['${key}']`,
393
+ },
394
+ };
395
+ configs.set(id.name, selection);
396
+ configBindings.set(id.start, selection);
397
+ if (statement.type === 'ExportNamedDeclaration')
398
+ exports[id.name] = selection;
399
+ continue;
400
+ }
401
+ const member = link.members?.[JSON.stringify([key])];
402
+ if (!member)
403
+ fail('Destructure only style and the configured single theme; other helpers remain unsupported.', id);
404
+ definitions.set(id.start, member.call);
405
+ names.set(id.name, member.call);
406
+ if (statement.type === 'ExportNamedDeclaration')
407
+ exports[id.name] = member;
408
+ }
409
+ }
410
+ catch (error) {
411
+ if (!(error instanceof Config.InvalidError))
412
+ throw error;
413
+ fail(error.message, expression);
414
+ }
415
+ continue;
416
+ }
417
+ let definition;
418
+ let tokenType;
419
+ let output;
420
+ try {
421
+ if (member.property.name === 'define') {
422
+ if (expression.arguments.length < 1 ||
423
+ expression.arguments.length > 2)
424
+ fail('Theme.define requires one literal token object.', expression);
425
+ const input = data(expression.arguments[0]);
426
+ tokenType = type(expression.arguments[0]);
427
+ const original = Theme.define(input);
428
+ definition = Token.bind(original, Object.freeze({ [Token.identity]: name }));
429
+ }
430
+ else {
431
+ const base = expression.arguments[0];
432
+ const parent = base ? resolve(base)?.call : undefined;
433
+ if (expression.arguments.length !== 2 || !parent)
434
+ fail('Theme.extend requires a preceding local theme and literal overrides.', expression);
435
+ factoryReferences.add(base.start);
436
+ definition = Theme.extend(themes[parent.name], data(expression.arguments[1]));
437
+ if (definition[Token.definition].contract[Token.identity]?.startsWith('id-'))
438
+ name = definition.className.slice('z_theme-'.length);
439
+ tokenType = parent.tokenType;
440
+ output = parent.output;
441
+ }
442
+ }
443
+ catch (error) {
444
+ if (error instanceof InvalidError)
445
+ throw error;
446
+ if (!(error instanceof Theme.InvalidError))
447
+ throw error;
448
+ fail(error.message, expression);
449
+ }
450
+ const call = Object.freeze({
451
+ ...(output ? { output } : {}),
452
+ end: expression.end,
453
+ name,
454
+ start: expression.start,
455
+ tokenType,
456
+ ...(definition[Token.definition].contract.shorthands ||
457
+ output === 'html'
458
+ ? {
459
+ type: `import('zyzz').Config.create.ReturnType<{theme:${tokenType};${output === 'html' ? "output:'html';" : ''}shorthands:${Configurations.type(definition[Token.definition].contract.shorthands ?? {})}}>['theme']`,
460
+ }
461
+ : {}),
462
+ });
463
+ calls.push(call);
464
+ definitions.set(variable.id.start, call);
465
+ factories.add(expression.start);
466
+ names.set(binding, call);
467
+ themes[name] = definition;
468
+ if (statement.type === 'ExportNamedDeclaration')
469
+ exports[binding] = {
470
+ binding: name,
471
+ call,
472
+ definition,
473
+ kind: 'theme',
474
+ };
475
+ }
476
+ }
477
+ function registerAlias(input) {
478
+ const { declaration, statement, variable } = input;
479
+ const expression = variable.init;
480
+ if (!expression)
481
+ return;
482
+ const linked = resolve(expression);
483
+ if (linked?.kind === 'config' && variable.id.type === 'ObjectPattern') {
484
+ if (statement.type === 'ExportNamedDeclaration' && !options.linked)
485
+ fail('Exported configuration destructuring requires source linking.', variable);
486
+ if (declaration.kind !== 'const')
487
+ fail('Configuration destructuring requires const bindings.', variable);
488
+ const link = linked;
489
+ const bindings = variable.id.properties.map((property) => {
490
+ if (property.type !== 'Property' ||
491
+ property.computed ||
492
+ property.key.type !== 'Identifier' ||
493
+ property.value.type !== 'Identifier')
494
+ return fail('Configuration destructuring requires named bindings without defaults or rest.', property);
495
+ return { key: property.key.name, id: property.value };
496
+ });
497
+ aliasReferences.add(expression.start);
498
+ aliases.push({
499
+ ...link.call,
500
+ start: expression.start,
501
+ end: expression.end,
502
+ destructured: false,
503
+ retained: true,
504
+ });
505
+ for (const { key, id } of bindings) {
506
+ if ((key === 'style' || key === 'variants') &&
507
+ !link.call.selection &&
508
+ !link.call.initialization) {
509
+ const alias = {
510
+ ...link.call,
511
+ recipe: key === 'variants',
512
+ destructured: false,
513
+ };
514
+ aliasBindings.set(id.start, alias);
515
+ aliasNames.set(id.name, alias);
516
+ if (statement.type === 'ExportNamedDeclaration')
517
+ exports[id.name] = {
518
+ ...link,
519
+ binding: `${options.namespace}-${id.name}`,
520
+ call: alias,
521
+ kind: 'style',
522
+ };
523
+ continue;
524
+ }
525
+ if (!link.call.selection &&
526
+ !link.call.initialization &&
527
+ !link.call.root &&
528
+ (key === 'script' ||
529
+ key === 'appearance' ||
530
+ (key === 'themes' && link.call.options?.themes))) {
531
+ if ((key === 'script' && !link.call.script) ||
532
+ (key === 'appearance' && !link.call.appearance) ||
533
+ link.call.selection ||
534
+ link.call.initialization)
535
+ fail('This configuration helper is not available on the linked contract.', id);
536
+ if (key === 'script')
537
+ scripts.add(link.call.name);
538
+ if (key === 'appearance')
539
+ appearances.add(link.call.name);
540
+ if (key === 'themes')
541
+ selections.add(link.call.name);
542
+ const members = Object.fromEntries(Object.entries(link.members ?? {}).flatMap(([pathKey, member]) => {
543
+ const path = JSON.parse(pathKey);
544
+ return key === 'themes' && path[0] === 'themes'
545
+ ? [[JSON.stringify(path.slice(1)), member]]
546
+ : [];
547
+ }));
548
+ const selection = {
549
+ ...link,
550
+ members,
551
+ call: {
552
+ ...link.call,
553
+ members: Object.fromEntries(Object.entries(members).map(([key, member]) => [
554
+ key,
555
+ member.call.name,
556
+ ])),
557
+ ...helper(key),
558
+ type: `${link.call.type}['${key}']`,
559
+ },
560
+ };
561
+ configs.set(id.name, selection);
562
+ configBindings.set(id.start, selection);
563
+ if (statement.type === 'ExportNamedDeclaration')
564
+ exports[id.name] = selection;
565
+ continue;
566
+ }
567
+ const member = link.members?.[JSON.stringify([key])];
568
+ if (!member)
569
+ fail('Destructure only style and the configured single theme; other helpers remain unsupported.', id);
570
+ definitions.set(id.start, member.call);
571
+ names.set(id.name, member.call);
572
+ if (statement.type === 'ExportNamedDeclaration')
573
+ exports[id.name] = member;
574
+ }
575
+ return;
576
+ }
577
+ if (linked && variable.id.type === 'Identifier') {
578
+ if (expression.start < linked.call.end)
579
+ fail('Authoring aliases must follow their definition.', expression);
580
+ if (declaration.kind !== 'const' ||
581
+ (statement.type === 'ExportNamedDeclaration' && !options.linked))
582
+ fail('Authoring aliases require module-level const bindings.', variable);
583
+ if (linked.kind === 'config') {
584
+ configs.set(variable.id.name, linked);
585
+ configBindings.set(variable.id.start, linked);
586
+ }
587
+ else {
588
+ names.set(variable.id.name, linked.call);
589
+ definitions.set(variable.id.start, linked.call);
590
+ }
591
+ aliases.push({
592
+ ...linked.call,
593
+ start: expression.start,
594
+ end: expression.end,
595
+ destructured: false,
596
+ retained: true,
597
+ });
598
+ aliasReferences.add(expression.start);
599
+ if (statement.type === 'ExportNamedDeclaration')
600
+ exports[variable.id.name] = linked;
601
+ return;
602
+ }
603
+ const member = (() => {
604
+ if (expression.type === 'MemberExpression' &&
605
+ !expression.computed &&
606
+ !expression.optional &&
607
+ expression.property.type === 'Identifier' &&
608
+ ['style', 'variants'].includes(expression.property.name)) {
609
+ return expression.object;
610
+ }
611
+ return undefined;
612
+ })();
613
+ const destructured = variable.id.type === 'ObjectPattern' && expression.type === 'Identifier';
614
+ const source = member ?? (expression.type === 'Identifier' ? expression : undefined);
615
+ if (!source)
616
+ return;
617
+ const theme = (() => {
618
+ if (member || destructured) {
619
+ return resolve(source)?.call;
620
+ }
621
+ if (source.type === 'Identifier') {
622
+ return aliasNames.get(source.name);
623
+ }
624
+ return undefined;
625
+ })();
626
+ if (!theme)
627
+ return;
628
+ const bindings = (() => {
629
+ if (destructured && variable.id.type === 'ObjectPattern') {
630
+ if (!variable.id.properties.length)
631
+ fail('Theme destructuring requires an authoring binding.', variable.id);
632
+ return variable.id.properties.map((property) => {
633
+ if (property.type !== 'Property' ||
634
+ property.computed ||
635
+ property.key.type !== 'Identifier' ||
636
+ (property.key.name !== 'style' &&
637
+ property.key.name !== 'variants') ||
638
+ property.value.type !== 'Identifier')
639
+ fail('Destructure only style or variants into const bindings without defaults or rest properties.', property);
640
+ return { id: property.value, member: property.key.name };
641
+ });
642
+ }
643
+ if (variable.id.type !== 'Identifier')
644
+ fail('Theme authoring aliases require named const bindings.', variable);
645
+ const recipe = expression.type === 'MemberExpression' &&
646
+ expression.property.type === 'Identifier'
647
+ ? expression.property.name === 'variants'
648
+ : theme.recipe;
649
+ return [
650
+ {
651
+ id: variable.id,
652
+ member: recipe ? 'variants' : 'style',
653
+ },
654
+ ];
655
+ })();
656
+ if (declaration.kind !== 'const' ||
657
+ (statement.type === 'ExportNamedDeclaration' && !options.linked))
658
+ fail('Theme style aliases require a local module-level const binding.', variable);
659
+ if (expression.start < theme.end)
660
+ fail('Theme style aliases must follow their definition.', expression);
661
+ for (const [index, { id, member }] of bindings.entries()) {
662
+ const alias = Object.freeze({
663
+ recipe: member === 'variants',
664
+ destructured,
665
+ end: expression.end,
666
+ name: theme.name,
667
+ start: expression.start,
668
+ tokenType: theme.tokenType,
669
+ type: theme.type,
670
+ options: theme.options,
671
+ output: theme.output,
672
+ });
673
+ // Each local/exported name keeps its own callable identity, while the
674
+ // shared initializer is rewritten once with every destructured member.
675
+ if (index === 0)
676
+ aliases.push({
677
+ ...alias,
678
+ bindings: bindings.map(({ member }) => member),
679
+ });
680
+ aliasBindings.set(id.start, alias);
681
+ aliasNames.set(id.name, alias);
682
+ if (statement.type === 'ExportNamedDeclaration')
683
+ exports[id.name] = {
684
+ binding: `${options.namespace}-${id.name}`,
685
+ call: alias,
686
+ definition: themes[alias.name],
687
+ kind: 'style',
688
+ };
689
+ }
690
+ aliasReferences.add(source.start);
691
+ }
692
+ const exportReferences = new Set();
693
+ if (options.linked)
694
+ for (const statement of program.body) {
695
+ if (statement.type !== 'ExportNamedDeclaration' ||
696
+ statement.source ||
697
+ statement.exportKind === 'type')
698
+ continue;
699
+ for (const specifier of statement.specifiers) {
700
+ if (specifier.exportKind === 'type')
701
+ continue;
702
+ const name = specifier.local.type === 'Identifier'
703
+ ? specifier.local.name
704
+ : specifier.local.value;
705
+ const call = configs.get(name)?.call ?? names.get(name) ?? aliasNames.get(name);
706
+ if (!call)
707
+ continue;
708
+ const exported = specifier.exported.type === 'Identifier'
709
+ ? specifier.exported.name
710
+ : specifier.exported.value;
711
+ exports[exported] = configs.get(name) ??
712
+ options.links?.[name] ?? {
713
+ binding: `${options.namespace}-${name}`,
714
+ call,
715
+ definition: themes[call.name],
716
+ kind: names.has(name) ? 'theme' : 'style',
717
+ };
718
+ exportReferences.add(specifier.local.start);
719
+ }
720
+ }
721
+ function reference(node, parent, ancestors, binding) {
722
+ const grandparent = ancestors.at(-3);
723
+ if (binding?.type === 'Import' &&
724
+ (imports.has(binding.node.start) || configImports.has(binding.node.start))) {
725
+ if (parent.type === 'MemberExpression' &&
726
+ grandparent?.type === 'CallExpression' &&
727
+ factories.has(grandparent.start))
728
+ return true;
729
+ fail('Theme factories require direct module-level const declarations; aliases and indirect references require source linking.', node);
730
+ }
731
+ const alias = binding?.type === 'Variable' || binding?.type === 'Import'
732
+ ? aliasBindings.get(binding.node.start)
733
+ : undefined;
734
+ if (alias) {
735
+ if (node.start === binding.node.start ||
736
+ exportReferences.has(node.start))
737
+ return true;
738
+ if (node.start < alias.end)
739
+ fail('Theme style alias references must follow their definition.', node);
740
+ if (aliasReferences.has(node.start))
741
+ return true;
742
+ if (parent.type !== 'CallExpression' ||
743
+ parent.callee !== node ||
744
+ parent.optional)
745
+ fail('Theme style aliases support direct calls only; exporting or escaping them requires source linking.', node);
746
+ styles.set(parent.start, {
747
+ call: parent,
748
+ recipe: alias.recipe,
749
+ theme: themes[alias.name],
750
+ output: alias.output ??
751
+ (alias.options?.output === 'html' ? 'html' : undefined),
752
+ });
753
+ return true;
754
+ }
755
+ const config = binding?.type === 'Variable' || binding?.type === 'Import'
756
+ ? configBindings.get(binding.node.start)
757
+ : undefined;
758
+ if (config) {
759
+ if (node.start === binding.node.start)
760
+ return true;
761
+ if (exportReferences.has(node.start) || aliasReferences.has(node.start))
762
+ return true;
763
+ if (node.start < config.call.end &&
764
+ config.call.start >= 0 &&
765
+ binding?.type !== 'Import')
766
+ fail('Configuration references must follow their definition.', node);
767
+ // Root controls are an ordinary runtime object; any read or call is valid.
768
+ if (config.call.root) {
769
+ appearances.add(config.call.name);
770
+ return true;
771
+ }
772
+ if ((config.call.selection || config.call.initialization) &&
773
+ parent.type === 'CallExpression' &&
774
+ parent.callee === node &&
775
+ !parent.optional) {
776
+ if (config.call.selection && config.call.catalogOnly)
777
+ fail('This legacy catalog is not callable; rebuild its library.', node);
778
+ if (config.call.selection)
779
+ selections.add(config.call.name);
780
+ if (config.call.initialization)
781
+ scripts.add(config.call.name);
782
+ return true;
783
+ }
784
+ let target = node;
785
+ const path = [];
786
+ for (let index = ancestors.length - 2; index >= 0; index--) {
787
+ const member = ancestors[index];
788
+ if (member.type !== 'MemberExpression' ||
789
+ member.object !== target ||
790
+ member.optional)
791
+ break;
792
+ const key = (() => {
793
+ if (member.property.type === 'Identifier' && !member.computed) {
794
+ return member.property.name;
795
+ }
796
+ if (member.property.type === 'Literal' &&
797
+ member.computed &&
798
+ (typeof member.property.value === 'string' ||
799
+ typeof member.property.value === 'number')) {
800
+ return String(member.property.value);
801
+ }
802
+ return undefined;
803
+ })();
804
+ if (key === undefined)
805
+ break;
806
+ path.push(key);
807
+ target = member;
808
+ if (aliasReferences.has(target.start) ||
809
+ factoryReferences.has(target.start))
810
+ return true;
811
+ if (path.length === 1 &&
812
+ path[0] === 'appearance' &&
813
+ !config.call.selection &&
814
+ !config.call.initialization) {
815
+ if (!config.call.appearance)
816
+ fail('This packed configuration does not provide appearance; rebuild its library with root control support.', target);
817
+ appearances.add(config.call.name);
818
+ return true;
819
+ }
820
+ if (path.length === 1 &&
821
+ !config.call.selection &&
822
+ !config.call.initialization &&
823
+ ['script', 'themes'].includes(path[0]) &&
824
+ ancestors[index - 1]?.type === 'CallExpression' &&
825
+ ancestors[index - 1].callee === target &&
826
+ !ancestors[index - 1].optional) {
827
+ if (path[0] === 'themes' && !config.call.options?.themes)
828
+ fail('Theme selection requires a named catalog.', target);
829
+ if (path[0] === 'themes' && config.call.catalogOnly)
830
+ fail('This legacy catalog is not callable; rebuild its library.', target);
831
+ if (path[0] === 'script') {
832
+ if (!config.call.script)
833
+ fail('This packed configuration does not provide script(); rebuild its library with initialization support.', target);
834
+ scripts.add(config.call.name);
835
+ }
836
+ if (path[0] === 'themes')
837
+ selections.add(config.call.name);
838
+ return true;
839
+ }
840
+ if (path.length === 1 &&
841
+ (path[0] === 'style' || path[0] === 'variants')) {
842
+ const call = ancestors[index - 1];
843
+ if (call?.type !== 'CallExpression' ||
844
+ call.callee !== target ||
845
+ call.optional)
846
+ break;
847
+ styles.set(call.start, {
848
+ call,
849
+ recipe: path[0] === 'variants',
850
+ theme: config.definition,
851
+ output: config.call.options?.output === 'html' ? 'html' : undefined,
852
+ });
853
+ return true;
854
+ }
855
+ const linked = config.members?.[JSON.stringify(path)];
856
+ if (linked)
857
+ return themeReference(target, ancestors[index - 1], ancestors.slice(0, index + 1), linked.call);
858
+ }
859
+ // A compiled selector is an ordinary runtime function, so passing or storing it is safe.
860
+ if (config.call.selection && !config.call.catalogOnly && !path.length) {
861
+ selections.add(config.call.name);
862
+ return true;
863
+ }
864
+ fail('Use direct configuration style calls or static theme members; configurations cannot escape or be mutated.', node);
865
+ }
866
+ const theme = binding?.type === 'Variable' || binding?.type === 'Import'
867
+ ? definitions.get(binding.node.start)
868
+ : undefined;
869
+ if (!theme)
870
+ return false;
871
+ if (node.start === binding.node.start)
872
+ return true;
873
+ return themeReference(node, parent, ancestors, theme);
874
+ }
875
+ function themeReference(node, parent, ancestors, theme) {
876
+ const grandparent = ancestors.at(-3);
877
+ if (factoryReferences.has(node.start))
878
+ return true;
879
+ if (exportReferences.has(node.start))
880
+ return true;
881
+ if (aliasReferences.has(node.start))
882
+ return true;
883
+ if (node.start < theme.end)
884
+ fail('Theme references must follow their local definition.', node);
885
+ if (parent.type === 'CallExpression' &&
886
+ factories.has(parent.start) &&
887
+ parent.arguments[0] === node)
888
+ return true;
889
+ if (parent.type === 'MemberExpression' &&
890
+ parent.object === node &&
891
+ ((parent.property.type === 'Identifier' &&
892
+ !parent.computed &&
893
+ ['tokens', 'vars'].includes(parent.property.name)) ||
894
+ (parent.property.type === 'Literal' &&
895
+ parent.computed &&
896
+ ['tokens', 'vars'].includes(String(parent.property.value))))) {
897
+ if (parent.optional)
898
+ fail('Token references cannot use optional access.', parent);
899
+ const variable = parent.property.type === 'Identifier'
900
+ ? parent.property.name === 'vars'
901
+ : parent.property.type === 'Literal' &&
902
+ parent.property.value === 'vars';
903
+ let value = variable
904
+ ? themes[theme.name].vars
905
+ : themes[theme.name].tokens;
906
+ let target = parent;
907
+ let index = ancestors.length - 3;
908
+ for (; index >= 0; index--) {
909
+ const ancestor = ancestors[index];
910
+ if (ancestor.type !== 'MemberExpression' || ancestor.object !== target)
911
+ break;
912
+ const key = (() => {
913
+ if (ancestor.property.type === 'Identifier' && !ancestor.computed) {
914
+ return ancestor.property.name;
915
+ }
916
+ if (ancestor.property.type === 'Literal' &&
917
+ ancestor.computed &&
918
+ (typeof ancestor.property.value === 'string' ||
919
+ typeof ancestor.property.value === 'number')) {
920
+ return String(ancestor.property.value);
921
+ }
922
+ return undefined;
923
+ })();
924
+ if (ancestor.optional || key === undefined)
925
+ fail('Token paths require static property names without optional access.', ancestor);
926
+ value =
927
+ value && typeof value === 'object' && !Token.is(value)
928
+ ? Object.getOwnPropertyDescriptor(value, key)?.value
929
+ : undefined;
930
+ if (value === undefined)
931
+ fail('Unknown theme token path.', ancestor);
932
+ target = ancestor;
933
+ }
934
+ if (!Token.is(value))
935
+ fail('Expected a scalar theme token reference.', target);
936
+ const reference = value;
937
+ for (; index >= 0; index--) {
938
+ const ancestor = ancestors[index];
939
+ if ((ancestor.type === 'TSAsExpression' ||
940
+ ancestor.type === 'TSSatisfiesExpression' ||
941
+ ancestor.type === 'TSNonNullExpression' ||
942
+ ancestor.type === 'TSTypeAssertion') &&
943
+ ancestor.expression === target)
944
+ target = ancestor;
945
+ else
946
+ break;
947
+ }
948
+ const valueTarget = target;
949
+ if (variable) {
950
+ while (index >= 0) {
951
+ const ancestor = ancestors[index];
952
+ if (!((ancestor.type === 'TemplateLiteral' &&
953
+ ancestor.expressions.includes(target)) ||
954
+ ((ancestor.type === 'TSAsExpression' ||
955
+ ancestor.type === 'TSSatisfiesExpression' ||
956
+ ancestor.type === 'TSNonNullExpression' ||
957
+ ancestor.type === 'TSTypeAssertion') &&
958
+ ancestor.expression === target)))
959
+ break;
960
+ target = ancestor;
961
+ index--;
962
+ }
963
+ }
964
+ const array = ancestors[index];
965
+ if (array?.type === 'ArrayExpression' &&
966
+ array.elements.includes(target)) {
967
+ target = array;
968
+ index--;
969
+ for (; index >= 0; index--) {
970
+ const ancestor = ancestors[index];
971
+ if ((ancestor.type === 'TSAsExpression' ||
972
+ ancestor.type === 'TSSatisfiesExpression' ||
973
+ ancestor.type === 'TSNonNullExpression' ||
974
+ ancestor.type === 'TSTypeAssertion') &&
975
+ ancestor.expression === target)
976
+ target = ancestor;
977
+ else
978
+ break;
979
+ }
980
+ }
981
+ const property = ancestors[index];
982
+ const object = ancestors[index - 1];
983
+ let argument = object;
984
+ let callIndex = index - 2;
985
+ for (; callIndex >= 0; callIndex--) {
986
+ const ancestor = ancestors[callIndex];
987
+ if (ancestor.type === 'Property' &&
988
+ ancestor.value === argument &&
989
+ ancestors[callIndex - 1]?.type === 'ObjectExpression') {
990
+ argument = ancestors[--callIndex];
991
+ continue;
992
+ }
993
+ if ((ancestor.type === 'TSAsExpression' ||
994
+ ancestor.type === 'TSSatisfiesExpression' ||
995
+ ancestor.type === 'TSNonNullExpression' ||
996
+ ancestor.type === 'TSTypeAssertion') &&
997
+ ancestor.expression === argument)
998
+ argument = ancestor;
999
+ else
1000
+ break;
1001
+ }
1002
+ if (ancestors[callIndex]?.type === 'ArrowFunctionExpression' &&
1003
+ ancestors[callIndex].body === argument) {
1004
+ argument = ancestors[callIndex];
1005
+ callIndex--;
1006
+ }
1007
+ while (callIndex >= 0) {
1008
+ const wrapper = ancestors[callIndex];
1009
+ if ((wrapper.type === 'TSAsExpression' ||
1010
+ wrapper.type === 'TSSatisfiesExpression' ||
1011
+ wrapper.type === 'TSNonNullExpression' ||
1012
+ wrapper.type === 'TSTypeAssertion') &&
1013
+ wrapper.expression === argument) {
1014
+ argument = wrapper;
1015
+ callIndex--;
1016
+ }
1017
+ else
1018
+ break;
1019
+ }
1020
+ const call = ancestors[callIndex];
1021
+ if (property?.type !== 'Property' ||
1022
+ property.value !== target ||
1023
+ object?.type !== 'ObjectExpression' ||
1024
+ call?.type !== 'CallExpression' ||
1025
+ call.arguments[0] !== argument ||
1026
+ (!styles.has(call.start) && !options.contributionCalls?.has(call.start))) {
1027
+ if (ancestors.some((node) => node.type === 'VariableDeclarator' &&
1028
+ options.staticBindings?.has(node.start)))
1029
+ staticTokens.push(valueTarget);
1030
+ else
1031
+ fail('Token references must be direct property values in bound theme style calls.', target);
1032
+ }
1033
+ tokens.set(valueTarget.start, { end: valueTarget.end, reference });
1034
+ const unwrapped = Expression.unwrap(valueTarget);
1035
+ tokens.set(unwrapped.start, { end: unwrapped.end, reference });
1036
+ return true;
1037
+ }
1038
+ if (parent.type !== 'MemberExpression' ||
1039
+ parent.object !== node ||
1040
+ parent.computed ||
1041
+ parent.optional ||
1042
+ parent.property.type !== 'Identifier')
1043
+ fail('Use local theme.style calls, theme.className reads, or Theme.extend; other theme references require source linking.', node);
1044
+ if (['style', 'variants'].includes(parent.property.name) &&
1045
+ grandparent?.type === 'CallExpression' &&
1046
+ grandparent.callee === parent &&
1047
+ !grandparent.optional) {
1048
+ styles.set(grandparent.start, {
1049
+ call: grandparent,
1050
+ recipe: parent.property.name === 'variants',
1051
+ theme: themes[theme.name],
1052
+ output: theme.output,
1053
+ });
1054
+ return true;
1055
+ }
1056
+ if (parent.property.name !== 'className')
1057
+ fail('Only direct theme.style calls and theme.className reads are supported here.', parent);
1058
+ let target = parent;
1059
+ for (let index = ancestors.length - 3; index >= 0; index--) {
1060
+ const ancestor = ancestors[index];
1061
+ if ((ancestor.type === 'AssignmentExpression' &&
1062
+ ancestor.left === target) ||
1063
+ (ancestor.type === 'UpdateExpression' &&
1064
+ ancestor.argument === target) ||
1065
+ (ancestor.type === 'UnaryExpression' &&
1066
+ ancestor.operator === 'delete') ||
1067
+ ((ancestor.type === 'ForInStatement' ||
1068
+ ancestor.type === 'ForOfStatement') &&
1069
+ ancestor.left === target))
1070
+ fail('Theme scope properties cannot be reassigned.', ancestor);
1071
+ if (((ancestor.type === 'TSAsExpression' ||
1072
+ ancestor.type === 'TSNonNullExpression' ||
1073
+ ancestor.type === 'TSSatisfiesExpression' ||
1074
+ ancestor.type === 'TSTypeAssertion') &&
1075
+ ancestor.expression === target) ||
1076
+ (ancestor.type === 'Property' && ancestor.value === target) ||
1077
+ ancestor.type === 'ObjectPattern' ||
1078
+ ancestor.type === 'ArrayPattern' ||
1079
+ (ancestor.type === 'RestElement' && ancestor.argument === target) ||
1080
+ (ancestor.type === 'AssignmentPattern' && ancestor.left === target))
1081
+ target = ancestor;
1082
+ else
1083
+ break;
1084
+ }
1085
+ references.push(Object.freeze({ end: parent.end, name: theme.name, start: parent.start }));
1086
+ return true;
1087
+ }
1088
+ for (const link of Object.values(exports))
1089
+ if (link.kind === 'config' &&
1090
+ !link.call.selection &&
1091
+ !link.call.initialization &&
1092
+ !link.call.root) {
1093
+ if (link.call.script)
1094
+ scripts.add(link.call.name);
1095
+ if (link.call.appearance)
1096
+ appearances.add(link.call.name);
1097
+ }
1098
+ const nativeContexts = new Map();
1099
+ return {
1100
+ nativeContext(start, end) {
1101
+ const theme = styles.get(start)?.theme;
1102
+ const contract = theme?.[Token.definition].contract ??
1103
+ [...tokens].find(([offset]) => offset >= start && offset < end)?.[1]
1104
+ .reference.contract;
1105
+ if (!contract)
1106
+ return undefined;
1107
+ const cached = nativeContexts.get(contract);
1108
+ if (cached)
1109
+ return cached;
1110
+ const config = [...configs.values()].find((value) => value.definition[Token.definition].contract === contract);
1111
+ if (!config?.call.options?.themes) {
1112
+ const alias = [...aliasNames.values()].find((value) => themes[value.name]?.[Token.definition].contract === contract &&
1113
+ value.options?.themes);
1114
+ if (!alias?.options?.themes)
1115
+ return undefined;
1116
+ const context = {
1117
+ defaultTheme: String(alias.options.defaultTheme),
1118
+ themes: Object.fromEntries(Object.entries(alias.options.themes).map(([name, values]) => [
1119
+ name,
1120
+ Token.bind(Theme.define(values), contract),
1121
+ ])),
1122
+ };
1123
+ Object.freeze(context.themes);
1124
+ nativeContexts.set(contract, Object.freeze(context));
1125
+ return context;
1126
+ }
1127
+ const entries = Object.entries(config.members ?? {}).flatMap(([key, value]) => {
1128
+ const path = JSON.parse(key);
1129
+ return path[0] === 'themes' && path.length === 2
1130
+ ? [[path[1], value.definition]]
1131
+ : [];
1132
+ });
1133
+ const context = Object.freeze({
1134
+ defaultTheme: String(config.call.options.defaultTheme),
1135
+ themes: Object.freeze(Object.fromEntries(entries)),
1136
+ });
1137
+ nativeContexts.set(contract, context);
1138
+ return context;
1139
+ },
1140
+ aliases,
1141
+ appearances,
1142
+ calls,
1143
+ exports: Object.freeze(exports),
1144
+ reference,
1145
+ references,
1146
+ scripts,
1147
+ selections,
1148
+ staticTokens,
1149
+ styles,
1150
+ themes: Object.freeze(themes),
1151
+ tokens,
1152
+ };
1153
+ }
1154
+ /** Located failure from unsupported or invalid local theme syntax. */
1155
+ export class InvalidError extends Error {
1156
+ /** Retains a source span for the public extractor diagnostic. */
1157
+ constructor(message, node) {
1158
+ super(message);
1159
+ this.end = node.end;
1160
+ this.start = node.start;
1161
+ }
1162
+ /** Exclusive source offset. */
1163
+ end;
1164
+ /** Namespaced diagnostic identity. */
1165
+ name = 'Source.ThemeInvalidError';
1166
+ /** Inclusive source offset. */
1167
+ start;
1168
+ }
1169
+ //# sourceMappingURL=Themes.js.map