@astryxdesign/cli 0.6.5 → 0.6.6-canary.408ad59

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 (433) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +58 -55
  3. package/api/build/_adapter.d.mts +55 -2
  4. package/api/build/_adapter.mjs +100 -10
  5. package/api/build/build.doc.mjs +2 -2
  6. package/api/build/build.test.mjs +111 -2
  7. package/api/build/build.type.d.mts +8 -0
  8. package/api/build/build.type.mjs +2 -0
  9. package/api/build/kit/kit.mjs +99 -22
  10. package/api/build/kit/rank.d.mts +32 -8
  11. package/api/build/kit/rank.mjs +291 -97
  12. package/api/build/kit/rank.test.mjs +231 -48
  13. package/api/build/kit/weights.d.mts +82 -0
  14. package/api/build/kit/weights.json +1 -0
  15. package/api/build/kit/weights.mjs +305 -0
  16. package/api/build/kit/weights.test.mjs +190 -0
  17. package/api/component/_adapter.d.mts +19 -0
  18. package/api/component/_adapter.mjs +33 -0
  19. package/api/component/component-replacement.test.mjs +603 -0
  20. package/api/component/component.mjs +49 -15
  21. package/api/component/component.test.mjs +32 -0
  22. package/api/component/component.type.d.mts +33 -3
  23. package/api/component/component.type.mjs +10 -3
  24. package/api/component/detail/blocks/blocks.d.mts +2 -1
  25. package/api/component/detail/blocks/blocks.mjs +5 -2
  26. package/api/component/detail/detail.mjs +5 -1
  27. package/api/component/detail/props/props.d.mts +2 -1
  28. package/api/component/detail/props/props.mjs +3 -2
  29. package/api/component/detail/showcase/showcase.d.mts +3 -1
  30. package/api/component/detail/showcase/showcase.mjs +3 -1
  31. package/api/component/detail/source/source.d.mts +3 -2
  32. package/api/component/detail/source/source.mjs +7 -3
  33. package/api/component/list/list.mjs +128 -10
  34. package/api/docs/_adapter.d.mts +11 -0
  35. package/api/docs/_adapter.mjs +25 -0
  36. package/api/docs/detail/detail.mjs +19 -3
  37. package/api/docs/detail/section/section.mjs +7 -1
  38. package/api/docs/docOverlays.test.mjs +10 -6
  39. package/api/docs/docs.d.mts +6 -0
  40. package/api/docs/docs.depth.test.mjs +134 -0
  41. package/api/docs/docs.doc.mjs +31 -2
  42. package/api/docs/docs.mjs +46 -1
  43. package/api/docs/docs.test.mjs +279 -0
  44. package/api/docs/docs.type.d.mts +81 -4
  45. package/api/docs/docs.type.mjs +41 -4
  46. package/api/docs/index/index.mjs +11 -2
  47. package/api/docs/index/index.test.mjs +7 -2
  48. package/api/docs/integration-tree.test.mjs +572 -0
  49. package/api/docs/integrationDocs.test.mjs +337 -0
  50. package/api/docs/node/node.d.mts +28 -3
  51. package/api/docs/node/node.mjs +149 -23
  52. package/api/doctor/_adapter.d.mts +43 -0
  53. package/api/doctor/_adapter.mjs +142 -0
  54. package/api/doctor/doctor.d.mts +0 -10
  55. package/api/doctor/doctor.doc.mjs +1 -3
  56. package/api/doctor/doctor.mjs +6 -123
  57. package/api/doctor/theme-checks.d.mts +12 -0
  58. package/api/doctor/theme-checks.mjs +1117 -0
  59. package/api/doctor/theme-checks.test.mjs +526 -0
  60. package/api/error.d.mts +22 -0
  61. package/api/error.mjs +42 -0
  62. package/api/gap-report/gap-report.d.mts +3 -1
  63. package/api/gap-report/gap-report.mjs +27 -3
  64. package/api/gap-report/gap-report.test.mjs +106 -0
  65. package/api/hook/_adapter.d.mts +1 -0
  66. package/api/hook/_adapter.mjs +3 -0
  67. package/api/hook/detail/detail.mjs +2 -2
  68. package/api/hook/detail/params/params.mjs +2 -2
  69. package/api/hook/hook.type.d.mts +12 -0
  70. package/api/hook/hook.type.mjs +3 -0
  71. package/api/hook/list/list.d.mts +1 -1
  72. package/api/hook/list/list.mjs +8 -8
  73. package/api/index.d.mts +1 -1
  74. package/api/index.mjs +4 -0
  75. package/api/init/run/run.d.mts +3 -5
  76. package/api/init/run/run.mjs +10 -11
  77. package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
  78. package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
  79. package/api/integration/add-contribution.d.mts +2 -1
  80. package/api/integration/add-contribution.mjs +7 -3
  81. package/api/integration/add-contribution.test.mjs +3 -3
  82. package/api/integration/add-helpers.d.mts +26 -5
  83. package/api/integration/add-helpers.mjs +50 -5
  84. package/api/integration/add-theme.mjs +354 -28
  85. package/api/integration/add-theme.test.mjs +380 -16
  86. package/api/integration/authoring-checks.mjs +31 -8
  87. package/api/integration/authoring-checks.type.d.mts +8 -0
  88. package/api/integration/authoring-checks.type.mjs +7 -3
  89. package/api/integration/integration-authoring.type.d.mts +4 -1
  90. package/api/integration/integration-authoring.type.mjs +6 -1
  91. package/api/integration/integrationAdd.doc.mjs +6 -0
  92. package/api/integration/integrationAddTheme.doc.mjs +10 -0
  93. package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
  94. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  95. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
  96. package/api/integration/pack-check.component-replaces.test.mjs +126 -0
  97. package/api/integration/pack-check.d.mts +10 -0
  98. package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
  99. package/api/integration/pack-check.mjs +495 -4
  100. package/api/integration/pack-check.test.mjs +619 -10
  101. package/api/integration/validate-integration.d.mts +4 -2
  102. package/api/integration/validate-integration.mjs +7 -2
  103. package/api/integration/validate-integration.test.mjs +55 -0
  104. package/api/integration/validate-integration.type.d.mts +5 -0
  105. package/api/integration/validate-integration.type.mjs +5 -1
  106. package/api/integration/validateIntegration.doc.mjs +1 -1
  107. package/api/layout/expand/expand.mjs +12 -7
  108. package/api/layout/expand/expand.receipt.test.mjs +74 -0
  109. package/api/layout/layout.type.d.mts +1 -0
  110. package/api/layout/layout.type.mjs +1 -0
  111. package/api/layout/layoutExpand.doc.mjs +1 -1
  112. package/api/search/search.d.mts +39 -8
  113. package/api/search/search.doc.mjs +4 -4
  114. package/api/search/search.mjs +248 -66
  115. package/api/search/search.test.mjs +829 -0
  116. package/api/search/search.type.d.mts +6 -6
  117. package/api/search/search.type.mjs +5 -5
  118. package/api/swizzle/_adapter.d.mts +10 -0
  119. package/api/swizzle/_adapter.mjs +23 -0
  120. package/api/swizzle/copy/copy.d.mts +5 -6
  121. package/api/swizzle/copy/copy.mjs +95 -13
  122. package/api/swizzle/list/list.mjs +2 -2
  123. package/api/swizzle/swizzle.doc.mjs +4 -0
  124. package/api/swizzle/swizzle.test.mjs +55 -5
  125. package/api/swizzle/swizzle.type.d.mts +8 -0
  126. package/api/swizzle/swizzle.type.mjs +2 -0
  127. package/api/template/copy/copy.mjs +15 -8
  128. package/api/template/copy/copy.receipt.test.mjs +77 -0
  129. package/api/template/show/show.mjs +17 -4
  130. package/api/template/show/show.test.mjs +76 -0
  131. package/api/template/skeleton/skeleton.mjs +2 -1
  132. package/api/template/template-integration.test.mjs +14 -0
  133. package/api/template/template.d.mts +1 -1
  134. package/api/template/template.doc.mjs +6 -2
  135. package/api/template/template.mjs +2 -0
  136. package/api/template/template.type.d.mts +14 -0
  137. package/api/template/template.type.mjs +5 -0
  138. package/api/theme/_adapter.d.mts +106 -6
  139. package/api/theme/_adapter.mjs +687 -18
  140. package/api/theme/add/add.binary.test.mjs +76 -3
  141. package/api/theme/add/add.d.mts +5 -9
  142. package/api/theme/add/add.mjs +87 -64
  143. package/api/theme/add/add.rollback.test.mjs +9 -9
  144. package/api/theme/add/add.staging.test.mjs +9 -9
  145. package/api/theme/add/add.test.mjs +461 -55
  146. package/api/theme/add/add.types.test.mjs +151 -0
  147. package/api/theme/build/build.d.mts +50 -2
  148. package/api/theme/build/build.family.test.mjs +13 -4
  149. package/api/theme/build/build.icon-lineage.test.mjs +117 -0
  150. package/api/theme/build/build.icon-preservation.test.mjs +639 -0
  151. package/api/theme/build/build.mjs +463 -155
  152. package/api/theme/build/build.project-core.test.mjs +165 -0
  153. package/api/theme/build/build.test.mjs +220 -1
  154. package/api/theme/build/icon-imports.d.mts +47 -0
  155. package/api/theme/build/icon-imports.mjs +691 -0
  156. package/api/theme/eject/eject.binary.test.mjs +90 -0
  157. package/api/theme/eject/eject.d.mts +17 -0
  158. package/api/theme/eject/eject.mjs +65 -0
  159. package/api/theme/eject/eject.rollback.test.mjs +158 -0
  160. package/api/theme/eject/eject.staging.test.mjs +83 -0
  161. package/api/theme/eject/eject.test.mjs +160 -0
  162. package/api/theme/integration-themes.test.mjs +30 -6
  163. package/api/theme/list/list.d.mts +10 -0
  164. package/api/theme/list/list.mjs +75 -7
  165. package/api/theme/list/list.test.mjs +155 -4
  166. package/api/theme/remove/remove.d.mts +12 -0
  167. package/api/theme/remove/remove.mjs +15 -0
  168. package/api/theme/remove/remove.test.mjs +94 -0
  169. package/api/theme/template/template.mjs +3 -4
  170. package/api/theme/theme.d.mts +5 -2
  171. package/api/theme/theme.mjs +13 -8
  172. package/api/theme/theme.type.d.mts +106 -2
  173. package/api/theme/theme.type.mjs +54 -5
  174. package/api/theme/themeAdd.doc.d.mts +1 -3
  175. package/api/theme/themeAdd.doc.mjs +35 -22
  176. package/api/theme/themeBuild.doc.d.mts +4 -1
  177. package/api/theme/themeBuild.doc.mjs +15 -4
  178. package/api/theme/themeEject.doc.d.mts +8 -0
  179. package/api/theme/themeEject.doc.mjs +89 -0
  180. package/api/theme/themeListAvailable.doc.mjs +4 -4
  181. package/api/theme/themeListCopySources.doc.d.mts +8 -0
  182. package/api/theme/themeListCopySources.doc.mjs +60 -0
  183. package/api/theme/themeRemove.doc.d.mts +6 -0
  184. package/api/theme/themeRemove.doc.mjs +50 -0
  185. package/api/theme/themeTemplate.doc.mjs +4 -3
  186. package/api/theme/themeUse.doc.d.mts +6 -0
  187. package/api/theme/themeUse.doc.mjs +47 -0
  188. package/api/theme/use/use.d.mts +12 -0
  189. package/api/theme/use/use.mjs +15 -0
  190. package/api/theme/use/use.test.mjs +98 -0
  191. package/api/upgrade/_adapter.d.mts +1 -0
  192. package/api/upgrade/_adapter.mjs +3 -0
  193. package/api/upgrade/list/list.mjs +9 -3
  194. package/api/upgrade/run/run.mjs +20 -3
  195. package/api/upgrade/run/run.test.mjs +45 -1
  196. package/api/upgrade/upgrade.doc.mjs +1 -1
  197. package/api/upgrade/upgrade.type.d.mts +5 -0
  198. package/api/upgrade/upgrade.type.mjs +2 -0
  199. package/assets/codemods/integration-discovery.mjs +1 -1
  200. package/assets/codemods/integration-discovery.test.mjs +64 -0
  201. package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
  202. package/assets/codemods/transforms/next/index.mjs +14 -1
  203. package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
  204. package/assets/docs/author-a-theme.doc.mjs +161 -0
  205. package/assets/docs/getting-started.doc.mjs +59 -15
  206. package/assets/docs/icons.doc.mjs +1 -0
  207. package/assets/docs/principles.doc.dense.mjs +2 -2
  208. package/assets/docs/principles.doc.mjs +2 -2
  209. package/assets/docs/principles.doc.zh.mjs +2 -2
  210. package/assets/docs/styling-libraries.doc.mjs +1 -1
  211. package/assets/docs/styling.doc.mjs +2 -2
  212. package/assets/docs/theme.doc.dense.mjs +10 -198
  213. package/assets/docs/theme.doc.mjs +13 -770
  214. package/assets/docs/theme.doc.zh.mjs +31 -12
  215. package/assets/docs/tokens.doc.mjs +4 -4
  216. package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
  217. package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
  218. package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
  219. package/assets/docs/tree/checks.doc.mjs +6 -5
  220. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
  221. package/assets/docs/tree/define-the-theme.doc.mjs +2 -2
  222. package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
  223. package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
  224. package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
  225. package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
  226. package/assets/docs/tree/layout.doc.mjs +32 -0
  227. package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
  228. package/assets/docs/tree/responsive.doc.mjs +102 -0
  229. package/assets/docs/tree/scaffold.doc.mjs +145 -0
  230. package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
  231. package/assets/docs/tree/side-panels.doc.mjs +82 -0
  232. package/assets/docs/tree/structure.doc.mjs +144 -0
  233. package/assets/docs/tree/template-doc-overview.doc.mjs +13 -1
  234. package/assets/docs/tree/themes.doc.mjs +2 -2
  235. package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
  236. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
  237. package/assets/docs/tree/versioning.doc.mjs +11 -7
  238. package/assets/docs/use-a-theme.doc.mjs +97 -0
  239. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
  240. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
  241. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
  242. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
  243. package/assets/templates/pages/ai-chat/template.doc.mjs +16 -1
  244. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +9 -1
  245. package/assets/templates/pages/blank/template.doc.mjs +3 -1
  246. package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -1
  247. package/assets/templates/pages/centered-hero/template.doc.mjs +3 -1
  248. package/assets/templates/pages/checkout-wizard/template.doc.mjs +1 -0
  249. package/assets/templates/pages/classic-gallery/template.doc.mjs +3 -1
  250. package/assets/templates/pages/contact-form/template.doc.mjs +16 -1
  251. package/assets/templates/pages/dashboard/template.doc.mjs +15 -1
  252. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +23 -1
  253. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +10 -1
  254. package/assets/templates/pages/dashboard-comparison/template.doc.mjs +9 -1
  255. package/assets/templates/pages/dashboard-composition/template.doc.mjs +10 -1
  256. package/assets/templates/pages/dashboard-progress/template.doc.mjs +17 -1
  257. package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -1
  258. package/assets/templates/pages/detail-page/template.doc.mjs +8 -0
  259. package/assets/templates/pages/documentation/template.doc.mjs +10 -1
  260. package/assets/templates/pages/documentation-design/template.doc.mjs +10 -1
  261. package/assets/templates/pages/documentation-technical/template.doc.mjs +10 -1
  262. package/assets/templates/pages/editor/template.doc.mjs +9 -1
  263. package/assets/templates/pages/file-explorer/template.doc.mjs +3 -1
  264. package/assets/templates/pages/form-two-column/template.doc.mjs +17 -1
  265. package/assets/templates/pages/form-wizard/template.doc.mjs +14 -1
  266. package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +1 -0
  267. package/assets/templates/pages/gallery-hero/template.doc.mjs +10 -1
  268. package/assets/templates/pages/ide/template.doc.mjs +9 -1
  269. package/assets/templates/pages/incident-console/template.doc.mjs +10 -1
  270. package/assets/templates/pages/kanban-board/template.doc.mjs +11 -1
  271. package/assets/templates/pages/library/template.doc.mjs +15 -1
  272. package/assets/templates/pages/login/template.doc.mjs +10 -1
  273. package/assets/templates/pages/login-card/template.doc.mjs +11 -1
  274. package/assets/templates/pages/login-split/template.doc.mjs +10 -1
  275. package/assets/templates/pages/login-sso/template.doc.mjs +10 -1
  276. package/assets/templates/pages/messaging-shell/template.doc.mjs +11 -1
  277. package/assets/templates/pages/mixed-gallery/template.doc.mjs +10 -1
  278. package/assets/templates/pages/payment-form/template.doc.mjs +3 -1
  279. package/assets/templates/pages/product-detail/template.doc.mjs +9 -1
  280. package/assets/templates/pages/product-gallery/template.doc.mjs +10 -1
  281. package/assets/templates/pages/settings/template.doc.mjs +3 -1
  282. package/assets/templates/pages/settings-dialog/template.doc.mjs +9 -1
  283. package/assets/templates/pages/settings-sidebar/template.doc.mjs +9 -1
  284. package/assets/templates/pages/shell-nav/template.doc.mjs +10 -1
  285. package/assets/templates/pages/shell-side-nav/template.doc.mjs +14 -1
  286. package/assets/templates/pages/shell-top-nav/template.doc.mjs +11 -1
  287. package/assets/templates/pages/side-gallery/template.doc.mjs +3 -1
  288. package/assets/templates/pages/table/template.doc.mjs +11 -1
  289. package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
  290. package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
  291. package/assets/templates/pages/table-comparison/page.tsx +1449 -0
  292. package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
  293. package/assets/templates/pages/table-filter/template.doc.mjs +21 -1
  294. package/assets/templates/pages/table-grouped/template.doc.mjs +15 -1
  295. package/assets/templates/pages/table-inbox/template.doc.mjs +18 -6
  296. package/assets/templates/pages/table-page/template.doc.mjs +20 -1
  297. package/assets/templates/pages/table-tree/template.doc.mjs +14 -1
  298. package/assets/templates/pages/theme-showcase/template.doc.mjs +10 -1
  299. package/assets/templates/pages/work-item-detail/template.doc.mjs +10 -0
  300. package/assets/templates/themes/butter/icons.tsx +2 -0
  301. package/assets/templates/themes/chocolate/icons.tsx +2 -0
  302. package/assets/templates/themes/gothic/icons.tsx +2 -0
  303. package/assets/templates/themes/matcha/icons.tsx +2 -0
  304. package/assets/templates/themes/neutral/icons.tsx +2 -0
  305. package/assets/templates/themes/stone/icons.tsx +2 -0
  306. package/assets/templates/themes/y2k/icons.tsx +2 -0
  307. package/authoring/doctypes/command/command.doc.mjs +5 -0
  308. package/authoring/doctypes/command/type.ts +2 -0
  309. package/authoring/doctypes/component/component.doc.mjs +1 -1
  310. package/authoring/doctypes/component/type.ts +8 -4
  311. package/authoring/doctypes/template/parse.d.mts +2 -0
  312. package/authoring/doctypes/template/parse.mjs +1 -0
  313. package/authoring/doctypes/template/parse.test.mjs +21 -0
  314. package/authoring/doctypes/template/template.doc.mjs +6 -0
  315. package/authoring/doctypes/template/type.ts +10 -0
  316. package/authoring/integration/integration.doc.mjs +1 -1
  317. package/clients/cli/commands/build-theme.mjs +279 -30
  318. package/clients/cli/commands/build.mjs +7 -6
  319. package/clients/cli/commands/build.text-fields.test.mjs +1 -1
  320. package/clients/cli/commands/component/index.mjs +88 -12
  321. package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
  322. package/clients/cli/commands/component.doc.mjs +9 -2
  323. package/clients/cli/commands/discover.mjs +29 -1
  324. package/clients/cli/commands/discover.no-source.test.mjs +75 -0
  325. package/clients/cli/commands/docs.depth.test.mjs +219 -0
  326. package/clients/cli/commands/docs.doc.mjs +15 -2
  327. package/clients/cli/commands/docs.mjs +273 -16
  328. package/clients/cli/commands/docs.test.mjs +382 -0
  329. package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
  330. package/clients/cli/commands/doctor.doc.mjs +1 -1
  331. package/clients/cli/commands/doctor.mjs +4 -4
  332. package/clients/cli/commands/doctor.test.mjs +9 -51
  333. package/clients/cli/commands/gap-report.doc.mjs +2 -2
  334. package/clients/cli/commands/gap-report.mjs +12 -0
  335. package/clients/cli/commands/gap-report.test.mjs +63 -0
  336. package/clients/cli/commands/hook/index.mjs +7 -2
  337. package/clients/cli/commands/import-hint-correctness.test.mjs +5 -5
  338. package/clients/cli/commands/init.next-steps.test.mjs +18 -23
  339. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  340. package/clients/cli/commands/integration-authoring.test.mjs +12 -2
  341. package/clients/cli/commands/integration-real-world.test.mjs +61 -12
  342. package/clients/cli/commands/integration.mjs +3 -1
  343. package/clients/cli/commands/layout-check.doc.mjs +1 -0
  344. package/clients/cli/commands/layout-expand.doc.mjs +4 -1
  345. package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
  346. package/clients/cli/commands/layout.doc.mjs +1 -0
  347. package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
  348. package/clients/cli/commands/layout.mjs +61 -4
  349. package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
  350. package/clients/cli/commands/search.doc.mjs +5 -4
  351. package/clients/cli/commands/search.mjs +30 -6
  352. package/clients/cli/commands/search.test.mjs +63 -17
  353. package/clients/cli/commands/swizzle.doc.mjs +12 -3
  354. package/clients/cli/commands/swizzle.mjs +2 -1
  355. package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
  356. package/clients/cli/commands/template.mjs +70 -6
  357. package/clients/cli/commands/template.show-media.test.mjs +62 -0
  358. package/clients/cli/commands/text-json-parity.test.mjs +40 -0
  359. package/clients/cli/commands/theme-add-lifecycle.test.mjs +132 -0
  360. package/clients/cli/commands/theme-add.doc.mjs +19 -19
  361. package/clients/cli/commands/theme-eject.doc.mjs +47 -0
  362. package/clients/cli/commands/theme-list.behavior.test.mjs +44 -0
  363. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  364. package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
  365. package/clients/cli/commands/theme-remove.doc.mjs +22 -0
  366. package/clients/cli/commands/theme-template.doc.mjs +4 -3
  367. package/clients/cli/commands/theme-use.doc.mjs +22 -0
  368. package/clients/cli/commands/theme.doc.mjs +21 -16
  369. package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
  370. package/clients/cli/commands/upgrade.mjs +1 -1
  371. package/clients/cli/commands/write-failure.test.mjs +175 -0
  372. package/clients/cli/index.mjs +4 -1
  373. package/clients/cli/lib/component-format.mjs +19 -2
  374. package/clients/cli/lib/manifest.mjs +44 -165
  375. package/clients/cli/lib/manifest.test.mjs +98 -7
  376. package/clients/cli/lib/resolve-theme.mjs +80 -78
  377. package/clients/cli/lib/resolve-theme.test.mjs +523 -27
  378. package/foundation/agent-docs/agent-docs.mjs +31 -28
  379. package/foundation/agent-docs/agent-docs.test.mjs +1163 -0
  380. package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
  381. package/foundation/config/project.d.mts +20 -5
  382. package/foundation/config/project.mjs +43 -6
  383. package/foundation/config/theme-private-vars.d.mts +12 -0
  384. package/foundation/config/theme-private-vars.mjs +107 -0
  385. package/foundation/config/theme-private-vars.test.mjs +55 -0
  386. package/foundation/config/theme-state.d.mts +145 -0
  387. package/foundation/config/theme-state.mjs +417 -0
  388. package/foundation/config/theme-state.test.mjs +182 -0
  389. package/foundation/discovery/component-discovery.d.mts +5 -2
  390. package/foundation/discovery/component-discovery.mjs +12 -6
  391. package/foundation/discovery/component-replacement.d.mts +91 -0
  392. package/foundation/discovery/component-replacement.mjs +417 -0
  393. package/foundation/discovery/component-replacement.test.mjs +480 -0
  394. package/foundation/discovery/docs-output-budget.d.mts +6 -2
  395. package/foundation/discovery/docs-output-budget.mjs +2 -1
  396. package/foundation/discovery/docs-section-key.d.mts +4 -2
  397. package/foundation/discovery/docs-section-key.mjs +1 -1
  398. package/foundation/discovery/module-exports.d.mts +10 -0
  399. package/foundation/discovery/module-exports.mjs +146 -0
  400. package/foundation/discovery/package-exports.d.mts +29 -0
  401. package/foundation/discovery/package-exports.mjs +200 -0
  402. package/foundation/discovery/template-adapter.d.mts +14 -0
  403. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
  404. package/foundation/discovery/template-adapter.mjs +21 -1
  405. package/foundation/discovery/theme-discovery.d.mts +78 -5
  406. package/foundation/discovery/theme-discovery.mjs +143 -18
  407. package/foundation/discovery/theme-discovery.test.mjs +9 -3
  408. package/foundation/discovery/theme-imports.d.mts +15 -0
  409. package/foundation/discovery/theme-imports.mjs +217 -0
  410. package/foundation/discovery/theme-imports.test.mjs +173 -0
  411. package/foundation/doc-compiler/doc-loads.test.mjs +18 -8
  412. package/foundation/doc-compiler/inputs.mjs +2 -1
  413. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  414. package/foundation/doc-compiler/lenses.d.mts +4 -2
  415. package/foundation/doc-compiler/lenses.mjs +1 -1
  416. package/foundation/doc-compiler/tree.test.mjs +649 -0
  417. package/foundation/fs/module-loader.d.mts +9 -0
  418. package/foundation/fs/module-loader.mjs +71 -2
  419. package/foundation/integrations/cli-requirement.d.mts +79 -13
  420. package/foundation/integrations/cli-requirement.mjs +115 -22
  421. package/foundation/integrations/cli-requirement.test.mjs +205 -8
  422. package/foundation/integrations/contribution-inventory.mjs +3 -3
  423. package/foundation/response/base.d.ts +9 -3
  424. package/foundation/response/json.d.mts +7 -4
  425. package/foundation/response/json.mjs +10 -6
  426. package/foundation/response/response-types.doc.d.mts +5 -5
  427. package/foundation/response/response-types.doc.mjs +50 -35
  428. package/foundation/response/response.doc.mjs +18 -4
  429. package/foundation/text/copyright-header.mjs +1 -1
  430. package/foundation/text/copyright-header.test.mjs +1 -1
  431. package/package.json +9 -9
  432. package/assets/docs/layout.doc.dense.mjs +0 -388
  433. package/assets/docs/layout.doc.mjs +0 -550
@@ -2,21 +2,28 @@
2
2
 
3
3
  /**
4
4
  * @file theme build API — compile standalone themes or one selected family.
5
+ * @input JS/TS theme modules, build/check options, and the installed Core.
6
+ * @output Generated artifacts preserving imported and inherited icon registries.
7
+ * @position CLI theme compiler; standalone icon provenance is icon-imports.mjs.
5
8
  *
6
9
  * `themeBuild` and `themeBuildFamily` share the same loader, compiler,
7
10
  * serializers, check, and writer. They read defineTheme() sources and, via
8
11
  * @astryxdesign/core's shared generator (the SINGLE source of truth so the
9
12
  * build emits the exact CSS the `<Theme>` runtime does), writes:
10
13
  * - A CSS file with token overrides and component styles
14
+ * - A CSS declaration module for strict side-effect imports
11
15
  * - A JS module that re-exports the built theme (+ icon registry)
12
16
  * - A .d.ts (plus an optional .variants.d.ts for custom prop values)
13
17
  *
14
18
  * It performs the writes and returns a `theme.build` receipt — its `warnings`
15
- * carry override problems, every declaration core's generator dropped because
16
- * its value could not stay one CSS declaration, and any fonts the theme names
17
- * but does not load (font-warning.mjs) — or `null` when the theme produced no
18
- * CSS (nothing to build). Errors throw AstryxError (with
19
- * a stable code). Human progress is emitted through the shared `logger`
19
+ * carry override problems and every declaration core's generator dropped
20
+ * because its value could not stay one CSS declaration; `notices` carry fonts
21
+ * the theme names but does not load (font-warning.mjs) — or `null` when the
22
+ * theme produced no CSS (nothing to build). Standalone icon imports come from
23
+ * the selected theme's parsed bindings and inheritance, never from comment or
24
+ * string contents. A registry that cannot be preserved fails before output
25
+ * generation, including in check mode. Errors throw AstryxError (with a stable
26
+ * code). Human progress is emitted through the shared `logger`
20
27
  * (silent by default), so the CLI keeps its exact output while a programmatic
21
28
  * caller stays quiet.
22
29
  *
@@ -35,7 +42,9 @@
35
42
  * `theme.build.check` receipt listing any stale or missing outputs. This is
36
43
  * the CI guard for committed, generated theme CSS: the source of truth is
37
44
  * `<theme>.ts`, and `theme build --check` fails when the committed
38
- * `<theme>.css`/`.js`/`.d.ts` no longer match it.
45
+ * `<theme>.css`/`.js`/`.d.ts` no longer match it. Builds also write a
46
+ * `<theme>.css.d.ts` import stub; check mode tolerates that one file being absent
47
+ * so output sets from the released CLI stay valid after an upgrade.
39
48
  */
40
49
 
41
50
  import * as fs from 'node:fs';
@@ -45,13 +54,18 @@ import {fileURLToPath, pathToFileURL} from 'node:url';
45
54
  import {parse} from '@babel/parser';
46
55
  import {createJiti} from 'jiti';
47
56
  import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
48
- import {CLI_ROOT, findCoreDir} from '../../../foundation/fs/paths.mjs';
57
+ import {
58
+ CLI_ROOT,
59
+ findCoreDir,
60
+ findInstalledPackage,
61
+ } from '../../../foundation/fs/paths.mjs';
49
62
  import {
50
63
  assertWithin,
51
64
  sanitizeName,
52
65
  PathSafetyError,
53
66
  } from '../../../foundation/fs/path-safety.mjs';
54
67
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
68
+ import {validatePrivateVars} from '../../../foundation/config/theme-private-vars.mjs';
55
69
  import {AstryxError} from '../../error.mjs';
56
70
  import {applyWrites} from '../../integration/add-helpers.mjs';
57
71
  import {logger} from '../../logger.mjs';
@@ -63,6 +77,7 @@ import {
63
77
  import {collectUnloadedFonts, formatFontLoadingHelp} from './font-warning.mjs';
64
78
  import {interceptCore} from './core-interception.mjs';
65
79
  import {generateFamilyCSS, resolveThemeFamily} from './family.mjs';
80
+ import {resolveIconImports} from './icon-imports.mjs';
66
81
 
67
82
  // Import shared theme processing from core. `astryx theme build` MUST produce the
68
83
  // exact same CSS as the `<Theme>` runtime, so it has exactly one generation
@@ -125,6 +140,232 @@ try {
125
140
  _coreImportError = e;
126
141
  }
127
142
 
143
+ /**
144
+ * The bindings one Core provides: the namespaces interception spreads, the
145
+ * functions the build calls, and why the import failed, if it did.
146
+ * @typedef {{
147
+ * themeModule: any,
148
+ * rootModule: any,
149
+ * importError: any,
150
+ * defineTheme: any,
151
+ * generateThemeRulesSplit: any,
152
+ * generateOnMediaCSS: any,
153
+ * generateAdaptationCSS: any,
154
+ * dataTokenDefaults: any,
155
+ * }} CoreBindings
156
+ */
157
+
158
+ /**
159
+ * The bindings exactly as the CLI's own import left them, kept so each build
160
+ * can choose between them and the project's installed Core.
161
+ * @type {CoreBindings}
162
+ */
163
+ const _cliCore = {
164
+ themeModule: _coreThemeModule,
165
+ rootModule: _coreRootModule,
166
+ importError: _coreImportError,
167
+ defineTheme: _defineTheme,
168
+ generateThemeRulesSplit: _generateThemeRulesSplit,
169
+ generateOnMediaCSS: _generateOnMediaCSS,
170
+ generateAdaptationCSS: _generateAdaptationCSS,
171
+ dataTokenDefaults: _dataTokenDefaults,
172
+ };
173
+
174
+ /**
175
+ * Point the build at one Core: the module-level bindings every step reads.
176
+ * @param {CoreBindings} core
177
+ */
178
+ function setCore(core) {
179
+ _coreThemeModule = core.themeModule;
180
+ _coreRootModule = core.rootModule;
181
+ _coreImportError = core.importError;
182
+ _defineTheme = core.defineTheme;
183
+ _generateThemeRulesSplit = core.generateThemeRulesSplit;
184
+ _generateOnMediaCSS = core.generateOnMediaCSS;
185
+ _generateAdaptationCSS = core.generateAdaptationCSS;
186
+ _dataTokenDefaults = core.dataTokenDefaults;
187
+ }
188
+
189
+ /**
190
+ * The file an `import` of `subpath` reaches through a package's `exports` map,
191
+ * or null when the map has no entry for it. Conditions are taken in the map's
192
+ * own order, as Node does, accepting the ones an import matches here: `node`,
193
+ * `import`, and `default` (so `source` and `types` are skipped).
194
+ *
195
+ * @param {string} dir - The package directory.
196
+ * @param {string} subpath - `'.'` or a subpath such as `'./theme'`.
197
+ * @returns {string|null}
198
+ */
199
+ function importTarget(dir, subpath) {
200
+ let pkg;
201
+ try {
202
+ pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'));
203
+ } catch {
204
+ return null;
205
+ }
206
+ const map = pkg?.exports;
207
+ const bySubpath =
208
+ map &&
209
+ typeof map === 'object' &&
210
+ !Array.isArray(map) &&
211
+ Object.keys(map).some(key => key.startsWith('.'));
212
+ const entry = bySubpath ? map[subpath] : subpath === '.' ? map : undefined;
213
+ /** @param {any} value @returns {string|null} */
214
+ const pick = value => {
215
+ if (typeof value === 'string') return value;
216
+ if (!value || typeof value !== 'object' || Array.isArray(value))
217
+ return null;
218
+ for (const [condition, target] of Object.entries(value)) {
219
+ if (
220
+ condition !== 'node' &&
221
+ condition !== 'import' &&
222
+ condition !== 'default'
223
+ )
224
+ continue;
225
+ const picked = pick(target);
226
+ if (picked) return picked;
227
+ }
228
+ return null;
229
+ };
230
+ const target = pick(entry);
231
+ return target ? path.resolve(dir, target) : null;
232
+ }
233
+
234
+ /** @param {string} file @returns {string} its real path, or itself */
235
+ function realOrSelf(file) {
236
+ try {
237
+ return fs.realpathSync(file);
238
+ } catch {
239
+ return file;
240
+ }
241
+ }
242
+
243
+ /**
244
+ * The Core the project at `cwd` installed, when it differs from the one the
245
+ * CLI's own import found and loads. The app's `<Theme>` runs on the app's
246
+ * Core, so building with it keeps the CSS identical; and a CLI run one-off
247
+ * (`npx @astryxdesign/cli`) has no Core beside it at all. Null when there is
248
+ * nothing better than the CLI's own import: no installed Core (the Astryx
249
+ * repository, a bare directory), the same Core, or one that does not load.
250
+ *
251
+ * @param {string} cwd
252
+ * @returns {Promise<CoreBindings | null>}
253
+ */
254
+ async function loadProjectCore(cwd) {
255
+ const dir = findInstalledPackage(cwd, '@astryxdesign/core');
256
+ const themeFile = dir ? importTarget(dir, './theme') : null;
257
+ if (!dir || !themeFile) return null;
258
+ if (_cliCore.themeModule) {
259
+ try {
260
+ const own = fileURLToPath(
261
+ import.meta.resolve('@astryxdesign/core/theme'),
262
+ );
263
+ if (realOrSelf(own) === realOrSelf(themeFile)) return null;
264
+ } catch {
265
+ // The CLI's own Core cannot be located; load the project's.
266
+ }
267
+ }
268
+ let themeModule;
269
+ try {
270
+ themeModule = await import(pathToFileURL(themeFile).href);
271
+ } catch {
272
+ return null;
273
+ }
274
+ if (!themeModule.defineTheme || !themeModule.generateThemeRulesSplit)
275
+ return null;
276
+ let rootModule = null;
277
+ const rootFile = importTarget(dir, '.');
278
+ if (rootFile) {
279
+ try {
280
+ rootModule = await import(pathToFileURL(rootFile).href);
281
+ } catch {
282
+ // As with the CLI's own import, the theme namespace stands in for it.
283
+ }
284
+ }
285
+ return {
286
+ themeModule,
287
+ rootModule,
288
+ importError: null,
289
+ defineTheme: themeModule.defineTheme,
290
+ generateThemeRulesSplit: themeModule.generateThemeRulesSplit,
291
+ generateOnMediaCSS: themeModule.generateOnMediaCSS,
292
+ generateAdaptationCSS: themeModule.generateAdaptationCSS,
293
+ dataTokenDefaults: themeModule.dataTokenDefaults,
294
+ };
295
+ }
296
+
297
+ /** @type {Map<string, Awaited<ReturnType<typeof loadProjectCore>>>} */
298
+ const _projectCores = new Map();
299
+
300
+ /**
301
+ * Choose the Core this build generates with: the project's installed one when
302
+ * {@link loadProjectCore} finds it, else the CLI's own.
303
+ * @param {string} cwd
304
+ */
305
+ async function selectCore(cwd) {
306
+ if (!_projectCores.has(cwd))
307
+ _projectCores.set(cwd, await loadProjectCore(cwd));
308
+ setCore(_projectCores.get(cwd) ?? _cliCore);
309
+ }
310
+
311
+ /**
312
+ * Whether `cwd` sits in the Astryx repository, where Core is built from
313
+ * source rather than installed.
314
+ * @param {string} cwd
315
+ */
316
+ function inAstryxRepository(cwd) {
317
+ let dir = cwd;
318
+ for (let i = 0; i < 6; i++) {
319
+ try {
320
+ const pkg = JSON.parse(
321
+ fs.readFileSync(
322
+ path.join(dir, 'packages', 'core', 'package.json'),
323
+ 'utf-8',
324
+ ),
325
+ );
326
+ if (pkg?.name === '@astryxdesign/core') return true;
327
+ } catch {
328
+ // Not here; keep walking up.
329
+ }
330
+ const parent = path.dirname(dir);
331
+ if (parent === dir) break;
332
+ dir = parent;
333
+ }
334
+ return false;
335
+ }
336
+
337
+ /**
338
+ * Why `theme build` has no Core to generate with, and the fix for where it
339
+ * ran: the Astryx repository builds Core, an app installs it, and an installed
340
+ * Core that will not load is named.
341
+ *
342
+ * @param {string} cwd
343
+ * @param {any} importError - Why the import failed, when it threw.
344
+ * @returns {string}
345
+ */
346
+ export function coreUnavailableMessage(cwd, importError) {
347
+ const why =
348
+ '`astryx theme build` generates CSS with @astryxdesign/core, the same code the runtime <Theme> uses';
349
+ const detail = importError ? `\n Import error: ${importError.message}` : '';
350
+ if (inAstryxRepository(cwd)) {
351
+ return (
352
+ `Could not load @astryxdesign/core/theme: ${why}. Build @astryxdesign/core ` +
353
+ `first (e.g. \`pnpm -F @astryxdesign/core build\`).${detail}`
354
+ );
355
+ }
356
+ const installed = findInstalledPackage(cwd, '@astryxdesign/core');
357
+ if (installed) {
358
+ return (
359
+ `Could not load the @astryxdesign/core installed at ` +
360
+ `${path.relative(cwd, installed) || '.'}: ${why}. Reinstall it.${detail}`
361
+ );
362
+ }
363
+ return (
364
+ `This project does not have @astryxdesign/core installed: ${why}. Install ` +
365
+ `it: \`npm install @astryxdesign/core\` (or yarn/pnpm/bun).${detail}`
366
+ );
367
+ }
368
+
128
369
  /**
129
370
  * Read a package's `version` from a resolved directory. Returns `'unknown'`
130
371
  * when it can't be read so the header always has a value.
@@ -194,7 +435,7 @@ function generatedHeader(sourceFile, lang = 'js', command, versions) {
194
435
  * @param {string} content
195
436
  * @returns {string}
196
437
  */
197
- function normalizeForCompare(content) {
438
+ export function normalizeThemeBuildForCompare(content) {
198
439
  return content
199
440
  .split('\n')
200
441
  .filter(line => {
@@ -204,24 +445,36 @@ function normalizeForCompare(content) {
204
445
  .join('\n');
205
446
  }
206
447
 
207
- /** @param {Array<{dest: string, content: string}>} writes @param {string} cwd @returns {Array<{path: string, reason: 'missing' | 'outdated'}>} */
448
+ /** @param {Array<{dest: string, content: string, allowMissingInCheck?: boolean}>} writes @param {string} cwd @returns {Array<{path: string, reason: 'missing' | 'outdated'}>} */
208
449
  function staleBuildOutputs(writes, cwd) {
209
450
  /** @type {Array<{path: string, reason: 'missing' | 'outdated'}>} */
210
451
  const stale = [];
211
452
  for (const write of writes) {
212
453
  const rel = path.relative(cwd, write.dest);
213
454
  if (!fs.existsSync(write.dest)) {
214
- stale.push({path: rel, reason: 'missing'});
455
+ if (!write.allowMissingInCheck) {
456
+ stale.push({path: rel, reason: 'missing'});
457
+ }
215
458
  continue;
216
459
  }
217
460
  const onDisk = fs.readFileSync(write.dest, 'utf8');
218
- if (normalizeForCompare(onDisk) !== normalizeForCompare(write.content)) {
461
+ if (
462
+ normalizeThemeBuildForCompare(onDisk) !==
463
+ normalizeThemeBuildForCompare(write.content)
464
+ ) {
219
465
  stale.push({path: rel, reason: 'outdated'});
220
466
  }
221
467
  }
222
468
  return stale;
223
469
  }
224
470
 
471
+ /** @param {Array<{dest: string, allowMissingInCheck?: boolean}>} writes @param {string} cwd */
472
+ function checkedBuildOutputs(writes, cwd) {
473
+ return writes
474
+ .filter(write => !write.allowMissingInCheck || fs.existsSync(write.dest))
475
+ .map(write => path.relative(cwd, write.dest));
476
+ }
477
+
225
478
  /** @param {Array<{dest: string, content: string}>} writes */
226
479
  function writeBuildOutputs(writes) {
227
480
  if (writes.length === 0) return;
@@ -278,8 +531,6 @@ function toIdentifier(name) {
278
531
  * from the cwd-relative dir (most consumers import from a file under src/) but
279
532
  * keeps the rest of the path (e.g. `themes/gothic`). Callers note the path is
280
533
  * relative to the consumer's file.
281
- * Exported (not just used by `themeBuild`'s install instructions) because the
282
- * thin CLI's `theme add` action reuses it for its own scaffold instructions.
283
534
  * @param {string} relDir
284
535
  * @param {string} base
285
536
  * @returns {string}
@@ -869,30 +1120,6 @@ function assertAdaptationCapability(
869
1120
  );
870
1121
  }
871
1122
 
872
- /**
873
- * Every `[component, rules]` pair a theme may emit, including ordered
874
- * adaptation rules. Validators, private-variable checks, and notices must see
875
- * rule-only values even though variant augmentation is root-owned.
876
- *
877
- * @param {Record<string, any>} themeDef
878
- * @returns {[string, Record<string, any>][]}
879
- */
880
- function themedComponentEntries(themeDef) {
881
- const maps = [
882
- themeDef.components,
883
- ...adaptationRuleValues(themeDef).map(
884
- (/** @type {any} */ value) => value.components,
885
- ),
886
- ];
887
-
888
- /** @type {[string, Record<string, any>][]} */
889
- const entries = [];
890
- for (const map of maps) {
891
- if (map) entries.push(...Object.entries(map));
892
- }
893
- return entries;
894
- }
895
-
896
1123
  /**
897
1124
  * Root component entries are the only surface allowed to introduce variants.
898
1125
  * @param {Record<string, any>} themeDef
@@ -1276,6 +1503,19 @@ async function validateRegistryGraphs(/** @type {Array<{specifier: string, expor
1276
1503
  if (!(root.exportName in exports)) throw registryGraphError(`Family registry ${root.file} does not export "${root.exportName}".`);
1277
1504
  }
1278
1505
  }
1506
+ /**
1507
+ * Resolve inherited source with exactly the loader's extension precedence.
1508
+ * This reads module locations only; icon discovery never executes a second load.
1509
+ * @param {string} specifier
1510
+ * @param {string} fromFile
1511
+ * @returns {string}
1512
+ */
1513
+ function resolveThemeModule(specifier, fromFile) {
1514
+ return createJiti(fromFile, {extensions: THEME_MODULE_EXTENSIONS}).resolve(
1515
+ specifier,
1516
+ );
1517
+ }
1518
+
1279
1519
  /**
1280
1520
  * Errors that mean "the synchronous loader cannot evaluate this module", as
1281
1521
  * opposed to "this module is broken". Only the former may fall back to the
@@ -1323,7 +1563,7 @@ function isSyncLoaderLimitation(error) {
1323
1563
  *
1324
1564
  * @param {string} filePath
1325
1565
  * @param {import('./core-interception.mjs').CoreInterception} [interception]
1326
- * @returns {Promise<{theme: any, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
1566
+ * @returns {Promise<{theme: any, exportName: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
1327
1567
  */
1328
1568
  // prettier-ignore
1329
1569
  async function importThemeModule(filePath, interception, /** @type {any} */ loader = undefined) {
@@ -1373,12 +1613,14 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
1373
1613
  mod = await jiti.import(filePath, {default: true});
1374
1614
  }
1375
1615
 
1376
- if (isThemeObject(mod)) return {theme: mod, degraded};
1616
+ if (isThemeObject(mod)) return {theme: mod, exportName: 'default', degraded};
1377
1617
 
1378
1618
  if (mod && typeof mod === 'object') {
1379
- if (isThemeObject(mod.default)) return {theme: mod.default, degraded};
1380
- for (const value of Object.values(mod)) {
1381
- if (isThemeObject(value)) return {theme: value, degraded};
1619
+ if (isThemeObject(mod.default)) {
1620
+ return {theme: mod.default, exportName: 'default', degraded};
1621
+ }
1622
+ for (const [exportName, value] of Object.entries(mod)) {
1623
+ if (isThemeObject(value)) return {theme: value, exportName, degraded};
1382
1624
  }
1383
1625
  }
1384
1626
 
@@ -1412,7 +1654,7 @@ function isThemeObject(value) {
1412
1654
  *
1413
1655
  * @param {string} filePath
1414
1656
  * @param {import('./core-interception.mjs').CoreInterception} [interception]
1415
- * @returns {Promise<{theme: any, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
1657
+ * @returns {Promise<{theme: any, exportName?: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
1416
1658
  */
1417
1659
  // prettier-ignore
1418
1660
  async function extractThemeDefinition(filePath, interception, /** @type {any} */ loader = undefined) {
@@ -1434,9 +1676,51 @@ async function extractThemeDefinition(filePath, interception, /** @type {any} */
1434
1676
  }
1435
1677
  }
1436
1678
 
1679
+ /**
1680
+ * Load one theme through the build's real module loader and validate the raw
1681
+ * input captured from its defineTheme lineage. Used by doctor so it applies the
1682
+ * same direct-input rule as theme build without mistaking compiler output for
1683
+ * authored input.
1684
+ *
1685
+ * @param {string} file
1686
+ * @param {{cwd?: string}} [ctx]
1687
+ * @returns {Promise<string[]>}
1688
+ */
1689
+ export async function validateThemePrivateInputs(
1690
+ file,
1691
+ {cwd = process.cwd()} = {},
1692
+ ) {
1693
+ const filePath = path.resolve(cwd, file);
1694
+ if (!fs.existsSync(filePath)) {
1695
+ throw new AstryxError(
1696
+ `File not found: ${filePath}`,
1697
+ undefined,
1698
+ ERROR_CODES.ERR_FILE_NOT_FOUND,
1699
+ );
1700
+ }
1701
+
1702
+ const interception = interceptCore(_coreThemeModule, _coreRootModule);
1703
+ let theme;
1704
+ try {
1705
+ theme = (await extractThemeDefinition(filePath, interception)).theme;
1706
+ } catch (error) {
1707
+ const message = error instanceof Error ? error.message : String(error);
1708
+ throw new AstryxError(message, undefined, ERROR_CODES.ERR_THEME_LOAD);
1709
+ }
1710
+
1711
+ const inputs = interception.lineageOf(theme);
1712
+ try {
1713
+ return [...new Set(inputs.flatMap(input => validatePrivateVars(input)))];
1714
+ } finally {
1715
+ interception.strip(theme);
1716
+ }
1717
+ }
1718
+
1437
1719
  /**
1438
1720
  * Fallback extraction via regex + eval.
1439
1721
  * Only works for plain object literals — can't follow imports or variables.
1722
+ * Never erase icon references: an unresolved registry must preserve the loader
1723
+ * error instead of turning an incomplete theme into a successful build.
1440
1724
  * @param {string} filePath
1441
1725
  * @returns {any}
1442
1726
  */
@@ -1458,10 +1742,6 @@ function extractThemeDefinitionLegacy(filePath) {
1458
1742
 
1459
1743
  let objStr = defineMatch[1];
1460
1744
  objStr = objStr.replace(/\s+as\s+const/g, '');
1461
- objStr = objStr.replace(
1462
- /icons:\s*[a-zA-Z_][a-zA-Z0-9_]*/g,
1463
- 'icons: undefined',
1464
- );
1465
1745
 
1466
1746
  try {
1467
1747
  return eval(`(${objStr})`);
@@ -1476,30 +1756,19 @@ function extractThemeDefinitionLegacy(filePath) {
1476
1756
  }
1477
1757
 
1478
1758
  /**
1479
- * Extract icon import info from a theme source file.
1480
- * Returns { importPath, exportName } or null if no icons.
1759
+ * Extract a family member's named registry import from its source file.
1760
+ * Returns { importPath, exportName } or null when the theme names none.
1761
+ * Standalone builds resolve icons through `resolveIconImports` instead.
1481
1762
  *
1482
1763
  * Looks for patterns like:
1483
1764
  * import { defaultIconRegistry } from './icons';
1484
1765
  * icons: defaultIconRegistry,
1485
1766
  * @param {string} filePath
1767
+ * @param {'icons' | 'indicators'} field
1486
1768
  * @returns {{exportName: string, importPath: string} | null}
1487
1769
  */
1488
- function extractRegistryInfo(filePath, field = 'icons', familyMode = false) {
1770
+ function extractRegistryInfo(filePath, field) {
1489
1771
  const content = fs.readFileSync(filePath, 'utf8');
1490
- if (!familyMode) {
1491
- const fieldMatch = content.match(
1492
- new RegExp(`${field}:\\s*([a-zA-Z_][a-zA-Z0-9_]*)`),
1493
- );
1494
- if (!fieldMatch) return null;
1495
- const varName = fieldMatch[1];
1496
- const match = content.match(
1497
- new RegExp(
1498
- `import\\s*{[^}]*\\b${varName}\\b[^}]*}\\s*from\\s*['"]([^'"]+)['"]`,
1499
- ),
1500
- );
1501
- return match ? {exportName: varName, importPath: match[1]} : null;
1502
- }
1503
1772
  const defineIndex = content.indexOf('defineTheme(');
1504
1773
  if (defineIndex < 0) return null;
1505
1774
  const themeSource = content.slice(defineIndex);
@@ -1539,17 +1808,18 @@ function extractRegistryInfo(filePath, field = 'icons', familyMode = false) {
1539
1808
  * override it had.
1540
1809
  *
1541
1810
  * The icon registry is imported rather than inlined because it holds React
1542
- * elements, which cannot be serialized. `extractIconInfo` lifts the specifier
1543
- * out of the TypeScript source, where an extensionless `./icons` is resolved by
1811
+ * elements, which cannot be serialized. `resolveIconImports` reads actual
1812
+ * imports from the selected theme's source, where extensionless `./icons` uses
1544
1813
  * the TypeScript resolver — but the artifact here is ESM JavaScript, which
1545
1814
  * requires a fully specified path. Only the caller knows what its own build
1546
1815
  * will emit and under what name, so `iconsSpecifier` lets it say. When it is
1547
- * not given, the scraped specifier is emitted unchanged.
1816
+ * not given, direct registry specifiers are preserved, and inherited relative
1817
+ * imports are rebased from the base module to the theme entry's directory.
1548
1818
  *
1549
1819
  * @param {any} themeDef
1550
- * @param {{exportName: string, importPath: string} | null} iconInfo
1551
- * @param {string} [iconsSpecifier] - Overrides the scraped icon import specifier.
1552
- * @param {{themeBinding?: string, iconBinding?: string, iconsExpression?: string, indicatorsExpression?: string, artifactBaseName?: string, exportIcons?: boolean}} [moduleOptions]
1820
+ * @param {import('./icon-imports.mjs').IconImports | null} iconInfo
1821
+ * @param {string} [iconsSpecifier] - Overrides the selected registry specifier.
1822
+ * @param {{themeBinding?: string, iconsExpression?: string, indicatorsExpression?: string, artifactBaseName?: string, exportIcons?: boolean}} [moduleOptions]
1553
1823
  * @returns {string}
1554
1824
  */
1555
1825
  function generateBuiltModule(
@@ -1560,29 +1830,46 @@ function generateBuiltModule(
1560
1830
  ) {
1561
1831
  const themeBinding =
1562
1832
  moduleOptions.themeBinding ?? `${toIdentifier(themeDef.name)}Theme`;
1563
- const iconBinding = moduleOptions.iconBinding ?? iconInfo?.exportName;
1564
1833
  const artifactBaseName = moduleOptions.artifactBaseName ?? themeDef.name;
1565
1834
  const exportIcons = moduleOptions.exportIcons ?? true;
1566
- // Preserve the historical generated bytes when no override is supplied.
1567
- // User-provided specifiers need string-literal encoding so quotes and
1568
- // backslashes cannot produce invalid JavaScript.
1569
- const renderedSpecifier =
1570
- iconsSpecifier === undefined
1571
- ? `'${iconInfo?.importPath}'`
1572
- : JSON.stringify(iconsSpecifier);
1573
- const iconImport = iconInfo
1574
- ? `import { ${iconInfo.exportName}${iconBinding === iconInfo.exportName ? '' : ` as ${iconBinding}`} } from ${renderedSpecifier};\n`
1575
- : '';
1576
- const iconsExpression =
1577
- moduleOptions.iconsExpression ?? (iconInfo ? iconBinding : undefined);
1835
+ // Keep ordinary direct named imports byte-compatible, while encoding paths
1836
+ // with quotes/escapes and retaining default, namespace, and aliased bindings.
1837
+ const iconImport = (iconInfo?.imports ?? [])
1838
+ .map(({importPath, importedName, localName}) => {
1839
+ const overridden =
1840
+ iconsSpecifier !== undefined &&
1841
+ importPath === iconInfo?.iconsSpecifierImportPath &&
1842
+ localName === iconInfo?.iconsSpecifierLocalName;
1843
+ const specifier = overridden
1844
+ ? JSON.stringify(iconsSpecifier)
1845
+ : /['\\\r\n]/u.test(importPath)
1846
+ ? JSON.stringify(importPath)
1847
+ : `'${importPath}'`;
1848
+ const imported = /^[$\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u.test(
1849
+ importedName,
1850
+ )
1851
+ ? importedName
1852
+ : JSON.stringify(importedName);
1853
+ const binding =
1854
+ importedName === 'default'
1855
+ ? localName
1856
+ : importedName === '*'
1857
+ ? `* as ${localName}`
1858
+ : `{ ${imported}${importedName === localName ? '' : ` as ${localName}`} }`;
1859
+ return `import ${binding} from ${specifier};\n`;
1860
+ })
1861
+ .join('');
1862
+ const iconDeclaration =
1863
+ iconInfo && iconInfo.expression !== iconInfo.exportName
1864
+ ? `const ${iconInfo.exportName} = ${iconInfo.expression};\n`
1865
+ : '';
1866
+ const iconsExpression = moduleOptions.iconsExpression ?? iconInfo?.exportName;
1578
1867
  const iconsField = iconsExpression ? ` icons: ${iconsExpression},` : '';
1579
1868
  const indicatorsField = moduleOptions.indicatorsExpression
1580
1869
  ? `\n indicators: ${moduleOptions.indicatorsExpression},`
1581
1870
  : '';
1582
1871
  const iconReExport =
1583
- iconInfo && exportIcons
1584
- ? `\nexport { ${iconBinding}${iconBinding === iconInfo.exportName ? '' : ` as ${iconInfo.exportName}`} };\n`
1585
- : '';
1872
+ iconInfo && exportIcons ? `\nexport { ${iconInfo.exportName} };\n` : '';
1586
1873
 
1587
1874
  // Resolve token values — tuples become light-dark() strings
1588
1875
  /** @type {Record<string, unknown>} */
@@ -1641,7 +1928,7 @@ function generateBuiltModule(
1641
1928
  serializeField('__adaptations', themeDef.__adaptations) +
1642
1929
  serializeField('__axes', themeDef.__axes ?? {}, true);
1643
1930
 
1644
- return `${iconImport}/**
1931
+ return `${iconImport}${iconDeclaration}/**
1645
1932
  * ${themeDef.name} theme — built by \`${getCliInvocation()} theme build\`
1646
1933
  * Import the CSS file alongside this module:
1647
1934
  *
@@ -1660,7 +1947,7 @@ ${iconReExport}`;
1660
1947
  /**
1661
1948
  * Generate TypeScript declarations for a built theme module.
1662
1949
  * @param {any} themeDef
1663
- * @param {{exportName: string, importPath: string} | null} iconInfo
1950
+ * @param {{exportName: string} | null} iconInfo - The re-exported registry, if any.
1664
1951
  * @param {string | null} variantsFileName
1665
1952
  * @param {{themeBinding?: string, includeIconExport?: boolean, includeThemeImport?: boolean}} [typeOptions]
1666
1953
  * @returns {string}
@@ -1835,48 +2122,6 @@ async function validateComponentOverrides(themeDef) {
1835
2122
  : validateComponentOverridesAgainstRegistry(themeDef, knownComponents);
1836
2123
  }
1837
2124
 
1838
- /**
1839
- * Validate that themes don't set private (--_*) CSS custom properties directly.
1840
- * Private vars are internal implementation details managed by the derived var
1841
- * expansion pipeline. Theme authors should write standard CSS properties
1842
- * (e.g. borderRadius, padding) instead.
1843
- *
1844
- * Returns array of error strings.
1845
- * @param {{components?: Record<string, Record<string, Record<string, unknown>>>}} themeDef
1846
- * @returns {string[]}
1847
- */
1848
- function validatePrivateVars(themeDef) {
1849
- /** @type {string[]} */
1850
- const errors = [];
1851
-
1852
- for (const [component, rules] of themedComponentEntries(themeDef)) {
1853
- for (const [key, styles] of Object.entries(rules)) {
1854
- /**
1855
- * @param {unknown} value
1856
- * @param {string[]} [path]
1857
- */
1858
- const visit = (value, path = []) => {
1859
- if (!value || typeof value !== 'object' || Array.isArray(value)) return;
1860
- for (const [prop, nested] of Object.entries(value)) {
1861
- if (prop.startsWith('--_')) {
1862
- errors.push(
1863
- `Component "${component}" (${[key, ...path].join(' ')}) sets private var "${prop}". ` +
1864
- `Private vars (--_*) are internal; use standard CSS properties ` +
1865
- `(e.g. borderRadius, padding) instead. The pipeline expands them automatically.`,
1866
- );
1867
- }
1868
- visit(nested, [...path, prop]);
1869
- }
1870
- };
1871
- visit(styles);
1872
- }
1873
- }
1874
-
1875
- // One entry per distinct message: a component declared both at the root and
1876
- // in one or more adaptations would otherwise report the same problem twice.
1877
- return [...new Set(errors)];
1878
- }
1879
-
1880
2125
  const BUILTIN_HEADING_TYPES = new Set(['display-1', 'display-2', 'display-3']);
1881
2126
 
1882
2127
  /**
@@ -2075,8 +2320,8 @@ function validateHeadingTypeAugmentationSupport(themeDef) {
2075
2320
  }
2076
2321
 
2077
2322
  /**
2078
- * Compile a defineTheme file to CSS + JS + .d.ts (and an optional
2079
- * `.variants.d.ts`). Performs the writes and returns a `theme.build` receipt,
2323
+ * Compile a defineTheme file to CSS + CSS .d.ts + JS + JS .d.ts (and an
2324
+ * optional `.variants.d.ts`). Performs the writes and returns a `theme.build` receipt,
2080
2325
  * or `null` when the theme produced no CSS (nothing to build). Throws
2081
2326
  * AstryxError (stable code) on failure. Progress is emitted through the shared
2082
2327
  * `logger` (silent by default).
@@ -2086,7 +2331,7 @@ function validateHeadingTypeAugmentationSupport(themeDef) {
2086
2331
  * `out` overrides the output CSS path; `check` compares against on-disk outputs
2087
2332
  * instead of writing. `iconsSpecifier` overrides the icon registry import
2088
2333
  * specifier in the generated module (e.g. `./icons.mjs`); when omitted, the
2089
- * specifier scraped from the theme source is emitted unchanged.
2334
+ * direct registry specifiers from the theme source are emitted unchanged.
2090
2335
  * @param {{cwd?: string}} [ctx]
2091
2336
  * @returns {Promise<any>}
2092
2337
  */
@@ -2107,6 +2352,8 @@ async function themeBuildInternal(
2107
2352
 
2108
2353
  logger.log(`\nBuilding theme from ${path.relative(cwd, filePath)}...`);
2109
2354
 
2355
+ await selectCore(cwd);
2356
+
2110
2357
  // Standalone builds only need interception when an older Core could erase
2111
2358
  // adaptations. Family preparation always supplies the same recorder as its
2112
2359
  // shared loader so exact authored parent identity stays CLI-private instead
@@ -2119,6 +2366,8 @@ async function themeBuildInternal(
2119
2366
 
2120
2367
  // Extract theme definition
2121
2368
  let themeDef;
2369
+ /** The export actually selected by the loader, not the first AST match. */
2370
+ let themeExportName;
2122
2371
  /** Paths through the load that interception could not fully observe. */
2123
2372
  let loadDegradation;
2124
2373
  try {
@@ -2128,6 +2377,7 @@ async function themeBuildInternal(
2128
2377
  options.__familyLoader,
2129
2378
  );
2130
2379
  themeDef = loaded.theme;
2380
+ themeExportName = loaded.exportName;
2131
2381
  loadDegradation = loaded.degraded;
2132
2382
  } catch (e) {
2133
2383
  const err = /** @type {Error} */ (e);
@@ -2193,6 +2443,25 @@ async function themeBuildInternal(
2193
2443
  throw err;
2194
2444
  }
2195
2445
 
2446
+ // A generated module must preserve the registry through an import: it may
2447
+ // contain React elements, which cannot be serialized. Validate before CSS
2448
+ // generation so neither the no-CSS return nor --check can bypass the error.
2449
+ // Family preparation keeps its own named-import registry contract, which
2450
+ // themeBuildFamily checks against the selected members' graph.
2451
+ const standaloneIcons = !options.__prepareFamily;
2452
+ const iconResolution = {
2453
+ readSource: (/** @type {string} */ file) => fs.readFileSync(file, 'utf8'),
2454
+ resolveModule: resolveThemeModule,
2455
+ reservedNames: [`${toIdentifier(themeDef.name)}Theme`],
2456
+ rawInput: 'extends' in themeDef,
2457
+ hasIcons:
2458
+ Object.keys(themeDef.icons ?? {}).length > 0 ||
2459
+ Object.keys(themeDef.extends?.icons ?? {}).length > 0,
2460
+ };
2461
+ let iconInfo = standaloneIcons
2462
+ ? await resolveIconImports(filePath, themeExportName, iconResolution)
2463
+ : null;
2464
+
2196
2465
  // Validate component overrides
2197
2466
  const warnings = await validateComponentOverrides(themeDef);
2198
2467
  const warningMessages = [];
@@ -2233,13 +2502,7 @@ async function themeBuildInternal(
2233
2502
  // capability exports are checked against what the theme actually asks for.
2234
2503
  if (!_defineTheme || !_generateThemeRulesSplit) {
2235
2504
  throw new AstryxError(
2236
- 'Could not load @astryxdesign/core/theme: `astryx theme build` requires a ' +
2237
- 'built, resolvable @astryxdesign/core so it emits the same CSS as the ' +
2238
- 'runtime <Theme>. Build @astryxdesign/core first (e.g. `pnpm -F @astryxdesign/core ' +
2239
- 'build`)' +
2240
- (_coreImportError
2241
- ? `.\n Import error: ${_coreImportError.message}`
2242
- : '.'),
2505
+ coreUnavailableMessage(cwd, _coreImportError),
2243
2506
  undefined,
2244
2507
  ERROR_CODES.ERR_CORE_NOT_FOUND,
2245
2508
  );
@@ -2305,6 +2568,40 @@ async function themeBuildInternal(
2305
2568
  resolvedTheme = themeDef;
2306
2569
  }
2307
2570
 
2571
+ // Raw object exports can acquire icons only when Core resolves `extends`.
2572
+ // Recheck an unresolved provenance result before any generator runs.
2573
+ if (
2574
+ standaloneIcons &&
2575
+ !iconInfo &&
2576
+ Object.keys(resolvedTheme.icons ?? {}).length > 0
2577
+ ) {
2578
+ iconInfo = await resolveIconImports(filePath, themeExportName, {
2579
+ ...iconResolution,
2580
+ hasIcons: true,
2581
+ });
2582
+ }
2583
+ // An opaque package base can legitimately have no icons. Its .icons
2584
+ // reference is unnecessary; direct empty registry imports remain intact.
2585
+ if (
2586
+ iconInfo &&
2587
+ iconInfo.iconsSpecifierLocalName === undefined &&
2588
+ Object.keys(resolvedTheme.icons ?? {}).length === 0
2589
+ ) {
2590
+ iconInfo = null;
2591
+ }
2592
+ if (
2593
+ iconInfo &&
2594
+ options.iconsSpecifier !== undefined &&
2595
+ iconInfo.iconsSpecifierImportPath === undefined
2596
+ ) {
2597
+ throw new AstryxError(
2598
+ 'The icon registry is inherited through a theme import. ' +
2599
+ 'To use --icons-specifier, import the registry directly and set icons to that binding.',
2600
+ undefined,
2601
+ ERROR_CODES.ERR_THEME_INVALID,
2602
+ );
2603
+ }
2604
+
2308
2605
  // Cores that predate adaptations can still resolve typography, color,
2309
2606
  // radius, and motion into root tokens, but they do not retain the raw axis
2310
2607
  // inputs. Keep the effective metadata captured from the same defineTheme
@@ -2527,18 +2824,10 @@ async function themeBuildInternal(
2527
2824
  // was left as orphaned half-built output. Stage-then-commit avoids
2528
2825
  // that.
2529
2826
  const outDir = path.dirname(outPath);
2827
+ const cssDtsPath = `${outPath}.d.ts`;
2530
2828
  const jsPath = path.join(outDir, `${baseName}.js`);
2531
2829
  const dtsPath = path.join(outDir, `${baseName}.d.ts`);
2532
2830
 
2533
- const iconInfo = extractRegistryInfo(
2534
- filePath,
2535
- 'icons',
2536
- options.__prepareFamily,
2537
- );
2538
- const indicatorInfo = options.__prepareFamily
2539
- ? extractRegistryInfo(filePath, 'indicators', true)
2540
- : null;
2541
-
2542
2831
  // Type augmentation .d.ts if theme has custom prop values. Computed
2543
2832
  // before the main .d.ts so the latter can reference it (see below).
2544
2833
  const augmentationSource = resolvedTheme || themeDef;
@@ -2559,6 +2848,9 @@ async function themeBuildInternal(
2559
2848
  // importing the theme also loads the custom-variant augmentations.
2560
2849
  const cssContent =
2561
2850
  generatedHeader(sourceRelative, 'css', buildCommand, versions) + css;
2851
+ const cssDtsContent =
2852
+ generatedHeader(sourceRelative, 'ts', buildCommand, versions) +
2853
+ 'export {};\n';
2562
2854
  const jsContent =
2563
2855
  generatedHeader(sourceRelative, 'js', buildCommand, versions) +
2564
2856
  generateBuiltModule(
@@ -2586,8 +2878,8 @@ async function themeBuildInternal(
2586
2878
  theme: displayTheme,
2587
2879
  sourceTheme: themeDef,
2588
2880
  sourceParent,
2589
- iconInfo,
2590
- indicatorInfo,
2881
+ iconInfo: extractRegistryInfo(filePath, 'icons'),
2882
+ indicatorInfo: extractRegistryInfo(filePath, 'indicators'),
2591
2883
  variantDecl,
2592
2884
  css: cssPlan,
2593
2885
  versions,
@@ -2600,6 +2892,7 @@ async function themeBuildInternal(
2600
2892
 
2601
2893
  const writes = [
2602
2894
  {dest: outPath, content: cssContent},
2895
+ {dest: cssDtsPath, content: cssDtsContent, allowMissingInCheck: true},
2603
2896
  {dest: jsPath, content: jsContent},
2604
2897
  {dest: dtsPath, content: dtsContent},
2605
2898
  ];
@@ -2633,7 +2926,7 @@ async function themeBuildInternal(
2633
2926
  name: themeDef.name,
2634
2927
  upToDate,
2635
2928
  stale,
2636
- checked: writes.map(w => path.relative(cwd, w.dest)),
2929
+ checked: checkedBuildOutputs(writes, cwd),
2637
2930
  },
2638
2931
  };
2639
2932
  }
@@ -2641,6 +2934,7 @@ async function themeBuildInternal(
2641
2934
  writeBuildOutputs(writes);
2642
2935
 
2643
2936
  logger.log(`\n[ok] ${path.relative(cwd, outPath)}`);
2937
+ logger.log(`[ok] ${path.relative(cwd, cssDtsPath)}`);
2644
2938
  logger.log(
2645
2939
  ` ${tokenCount} token overrides, ${componentCount} component overrides`,
2646
2940
  );
@@ -2709,6 +3003,7 @@ Or with a <link> tag:
2709
3003
  sizeKB: parseFloat(size),
2710
3004
  outputs: {
2711
3005
  css: path.relative(cwd, outPath),
3006
+ cssDts: path.relative(cwd, cssDtsPath),
2712
3007
  js: path.relative(cwd, jsPath),
2713
3008
  dts: path.relative(cwd, dtsPath),
2714
3009
  ...(variantDecl && variantDtsPath
@@ -2807,6 +3102,7 @@ export async function themeBuildFamily(
2807
3102
  error instanceof Error ? error.message : 'Invalid family key.';
2808
3103
  throw new AstryxError(message, undefined, ERROR_CODES.ERR_THEME_INVALID);
2809
3104
  }
3105
+ await selectCore(cwd);
2810
3106
  const familyInterception = interceptCore(_coreThemeModule, _coreRootModule);
2811
3107
  // prettier-ignore
2812
3108
  const familyLoader = createJiti(import.meta.url, {moduleCache: true, interopDefault: false, jsx: true, extensions: THEME_MODULE_EXTENSIONS, virtualModules: familyInterception.modules});
@@ -2873,6 +3169,7 @@ export async function themeBuildFamily(
2873
3169
  const root = members[0];
2874
3170
  const outDir = path.dirname(root.filePath);
2875
3171
  const outPath = path.join(outDir, `${baseName}.css`);
3172
+ const cssDtsPath = `${outPath}.d.ts`;
2876
3173
  const jsPath = path.join(outDir, `${baseName}.js`);
2877
3174
  const dtsPath = path.join(outDir, `${baseName}.d.ts`);
2878
3175
  const sources = new Set(
@@ -2882,7 +3179,7 @@ export async function themeBuildFamily(
2882
3179
  ),
2883
3180
  ),
2884
3181
  );
2885
- const collision = [outPath, jsPath, dtsPath].find(output => {
3182
+ const collision = [outPath, cssDtsPath, jsPath, dtsPath].find(output => {
2886
3183
  const candidates = [path.resolve(output)];
2887
3184
  if (fs.existsSync(output)) candidates.push(fs.realpathSync(output));
2888
3185
  return candidates.some(value => sources.has(value.toLowerCase()));
@@ -2930,11 +3227,14 @@ export async function themeBuildFamily(
2930
3227
  const indicatorImport = indicator.info
2931
3228
  ? `import { ${indicator.info.exportName} as ${ownIndicators} } from ${JSON.stringify(indicator.specifier ?? indicator.info.importPath)};\n`
2932
3229
  : '';
3230
+ // The member's own registry import, bound to its family-unique name; a
3231
+ // rebased or overridden specifier replaces the scraped one.
3232
+ // prettier-ignore
3233
+ const iconImports = icon.info && ownIcons ? {imports: [{importPath: icon.info.importPath, importedName: icon.info.exportName, localName: ownIcons}], expression: ownIcons, exportName: ownIcons, iconsSpecifierImportPath: icon.info.importPath, iconsSpecifierLocalName: ownIcons} : null;
2933
3234
  return (
2934
3235
  indicatorImport +
2935
- generateBuiltModule(member.theme, icon.info, icon.specifier, {
3236
+ generateBuiltModule(member.theme, iconImports, icon.specifier, {
2936
3237
  themeBinding,
2937
- iconBinding: ownIcons ?? undefined,
2938
3238
  iconsExpression: expression(ownIcons, inheritedIcons),
2939
3239
  indicatorsExpression: expression(ownIndicators, inheritedIndicators),
2940
3240
  artifactBaseName: baseName,
@@ -2963,6 +3263,13 @@ export async function themeBuildFamily(
2963
3263
  generatedHeader(sourceRelative, 'css', buildCommand, root.versions) +
2964
3264
  css,
2965
3265
  },
3266
+ {
3267
+ dest: cssDtsPath,
3268
+ allowMissingInCheck: true,
3269
+ content:
3270
+ generatedHeader(sourceRelative, 'ts', buildCommand, root.versions) +
3271
+ 'export {};\n',
3272
+ },
2966
3273
  {
2967
3274
  dest: jsPath,
2968
3275
  content:
@@ -2978,6 +3285,7 @@ export async function themeBuildFamily(
2978
3285
  ];
2979
3286
  const outputs = {
2980
3287
  css: path.relative(cwd, outPath),
3288
+ cssDts: path.relative(cwd, cssDtsPath),
2981
3289
  js: path.relative(cwd, jsPath),
2982
3290
  dts: path.relative(cwd, dtsPath),
2983
3291
  };
@@ -3005,7 +3313,7 @@ export async function themeBuildFamily(
3005
3313
  name: root.theme.name,
3006
3314
  upToDate,
3007
3315
  stale,
3008
- checked: writes.map(write => path.relative(cwd, write.dest)),
3316
+ checked: checkedBuildOutputs(writes, cwd),
3009
3317
  },
3010
3318
  };
3011
3319
  }