@astryxdesign/cli 0.7.16 → 0.7.17-canary.g0135e03

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 (369) hide show
  1. package/README.md +76 -86
  2. package/api/build/_adapter.d.mts +12 -0
  3. package/api/build/_adapter.mjs +51 -34
  4. package/api/build/blocks/blocks.d.mts +7 -5
  5. package/api/build/blocks/blocks.mjs +113 -26
  6. package/api/build/build.doc.mjs +4 -3
  7. package/api/build/build.type.d.mts +2 -2
  8. package/api/build/build.type.mjs +3 -3
  9. package/api/build/kit/kind.d.mts +2 -1
  10. package/api/build/kit/kind.mjs +199 -10
  11. package/api/build/kit/kit.mjs +6 -4
  12. package/api/build/kit/rank.d.mts +4 -2
  13. package/api/build/kit/rank.mjs +125 -24
  14. package/api/build/kit/start.d.mts +5 -4
  15. package/api/build/kit/start.mjs +12 -8
  16. package/api/build/kit/weights.d.mts +39 -3
  17. package/api/build/kit/weights.json +1 -1
  18. package/api/build/kit/weights.mjs +340 -43
  19. package/api/build/kit/word-model.d.mts +23 -0
  20. package/api/build/kit/word-model.mjs +46 -0
  21. package/api/build/kit/words.d.mts +48 -0
  22. package/api/build/kit/words.mjs +90 -1
  23. package/api/component/__fixtures__/resolutions/modules.txt +4 -5
  24. package/api/component/list/list.d.mts +1 -1
  25. package/api/component/list/list.mjs +48 -6
  26. package/api/discover/_adapter.d.mts +1 -1
  27. package/api/discover/search/search.mjs +3 -2
  28. package/api/docs/_adapter.d.mts +26 -2
  29. package/api/docs/_adapter.mjs +219 -6
  30. package/api/docs/docs.d.mts +3 -0
  31. package/api/docs/docs.doc.mjs +7 -1
  32. package/api/docs/docs.mjs +12 -0
  33. package/api/docs/docs.type.d.mts +5 -0
  34. package/api/docs/docs.type.mjs +2 -0
  35. package/api/docs/node/node.mjs +1 -1
  36. package/api/doctor/_adapter.d.mts +27 -5
  37. package/api/doctor/_adapter.mjs +83 -10
  38. package/api/doctor/built-checks.mjs +40 -14
  39. package/api/doctor/doctor.d.mts +4 -3
  40. package/api/doctor/doctor.mjs +14 -7
  41. package/api/doctor/theme-checks.mjs +121 -17
  42. package/api/icon/_records.mjs +2 -1
  43. package/api/index.d.mts +2 -0
  44. package/api/index.mjs +2 -0
  45. package/api/integration/_adapter.d.mts +44 -0
  46. package/api/integration/_adapter.mjs +77 -1
  47. package/api/integration/authoring-checks.mjs +6 -6
  48. package/api/integration/example-scope.d.mts +14 -0
  49. package/api/integration/example-scope.mjs +44 -0
  50. package/api/integration/example-scope.type.d.mts +29 -0
  51. package/api/integration/example-scope.type.mjs +25 -0
  52. package/api/integration/integrationExampleScope.doc.d.mts +11 -0
  53. package/api/integration/integrationExampleScope.doc.mjs +59 -0
  54. package/api/integration/validate-integration.mjs +19 -1
  55. package/api/integration/validate-integration.type.d.mts +9 -0
  56. package/api/integration/validate-integration.type.mjs +1 -1
  57. package/api/integration/validateIntegration.doc.mjs +1 -1
  58. package/api/render/_adapter.mjs +591 -195
  59. package/api/render/render.doc.mjs +11 -3
  60. package/api/render/render.type.d.mts +52 -0
  61. package/api/render/render.type.mjs +31 -1
  62. package/api/search/ORDERING.md +1 -1
  63. package/api/search/_adapter.d.mts +9 -0
  64. package/api/search/_adapter.mjs +85 -0
  65. package/api/search/_candidate-score.mjs +51 -32
  66. package/api/search/_fit-order.mjs +3 -3
  67. package/api/search/_gather-components.d.mts +3 -2
  68. package/api/search/_gather-components.mjs +12 -3
  69. package/api/search/_lexical.d.mts +5 -0
  70. package/api/search/_lexical.mjs +8 -2
  71. package/api/search/_result.d.mts +11 -9
  72. package/api/search/_result.mjs +4 -4
  73. package/api/search/_score.d.mts +6 -1
  74. package/api/search/_score.mjs +15 -3
  75. package/api/search/search-index.mjs +7 -1
  76. package/api/search/search.d.mts +1 -1
  77. package/api/theme/_adapter.mjs +12 -1
  78. package/api/theme/build/build.d.mts +122 -1
  79. package/api/theme/build/build.mjs +412 -84
  80. package/api/theme/build/core-interception.d.mts +10 -0
  81. package/api/theme/build/core-interception.mjs +10 -0
  82. package/api/theme/build/font-warning.d.mts +23 -3
  83. package/api/theme/build/font-warning.mjs +54 -5
  84. package/api/theme/build/icon-imports.mjs +25 -2
  85. package/api/theme/theme.type.d.mts +10 -0
  86. package/api/theme/theme.type.mjs +7 -1
  87. package/api/theme-edit/_adapter.d.mts +103 -3
  88. package/api/theme-edit/_adapter.mjs +961 -82
  89. package/api/theme-edit/_catalog.mjs +19 -4
  90. package/api/theme-edit/_check.d.mts +63 -24
  91. package/api/theme-edit/_check.mjs +2467 -362
  92. package/api/theme-edit/_color.d.mts +10 -0
  93. package/api/theme-edit/_color.mjs +49 -1
  94. package/api/theme-edit/_compiler.mjs +89 -6
  95. package/api/theme-edit/_context.d.mts +3 -3
  96. package/api/theme-edit/_context.mjs +165 -54
  97. package/api/theme-edit/_css.d.mts +14 -0
  98. package/api/theme-edit/_css.mjs +46 -1
  99. package/api/theme-edit/_edit.d.mts +31 -4
  100. package/api/theme-edit/_edit.mjs +2433 -204
  101. package/api/theme-edit/_how-commands.d.mts +72 -1
  102. package/api/theme-edit/_how-commands.mjs +759 -9
  103. package/api/theme-edit/_how-question.d.mts +82 -5
  104. package/api/theme-edit/_how-question.mjs +6473 -553
  105. package/api/theme-edit/_how.d.mts +2 -1
  106. package/api/theme-edit/_how.mjs +237 -41
  107. package/api/theme-edit/_marks.d.mts +31 -5
  108. package/api/theme-edit/_marks.mjs +57 -5
  109. package/api/theme-edit/_name-rule.d.mts +11 -0
  110. package/api/theme-edit/_name-rule.mjs +12 -0
  111. package/api/theme-edit/_normal.d.mts +292 -0
  112. package/api/theme-edit/_normal.mjs +1454 -0
  113. package/api/theme-edit/_palette.mjs +10 -4
  114. package/api/theme-edit/_part-words.d.mts +31 -0
  115. package/api/theme-edit/_part-words.mjs +126 -0
  116. package/api/theme-edit/_parts.d.mts +18 -1
  117. package/api/theme-edit/_parts.mjs +246 -23
  118. package/api/theme-edit/_preview-app.d.mts +7 -1
  119. package/api/theme-edit/_preview-app.mjs +776 -187
  120. package/api/theme-edit/_preview.d.mts +100 -14
  121. package/api/theme-edit/_preview.mjs +582 -139
  122. package/api/theme-edit/_project.d.mts +4 -0
  123. package/api/theme-edit/_project.mjs +3 -1
  124. package/api/theme-edit/_settings.d.mts +417 -42
  125. package/api/theme-edit/_settings.mjs +3262 -424
  126. package/api/theme-edit/_tables.d.mts +15 -0
  127. package/api/theme-edit/_tables.mjs +63 -1
  128. package/api/theme-edit/_vet.d.mts +20 -0
  129. package/api/theme-edit/_vet.mjs +47 -2
  130. package/api/theme-edit/theme-edit.type.d.mts +10 -1
  131. package/api/theme-edit/theme-edit.type.mjs +4 -1
  132. package/api/theme-edit/themeEditHow.doc.mjs +1 -1
  133. package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
  134. package/api/theme-edit/themeEditNew.doc.mjs +7 -4
  135. package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
  136. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
  137. package/api/upgrade/run/run.mjs +4 -3
  138. package/assets/codemods/integration-discovery.mjs +2 -1
  139. package/assets/codemods/run-codemod.mjs +87 -7
  140. package/assets/codemods/transforms/next/index.mjs +11 -1
  141. package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
  142. package/assets/component-list.generated.json +1 -0
  143. package/assets/docs/author-a-theme.doc.mjs +1 -0
  144. package/assets/docs/theme.doc.dense.mjs +2 -2
  145. package/assets/docs/theme.doc.mjs +1 -1
  146. package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
  147. package/assets/docs/tree/checks.doc.mjs +1 -1
  148. package/assets/docs/tree/cli-command.doc.mjs +2 -3
  149. package/assets/docs/tree/render-pages.doc.mjs +44 -3
  150. package/assets/docs/tree/single-component.doc.mjs +4 -0
  151. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  152. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  153. package/assets/docs/use-a-theme.doc.mjs +1 -1
  154. package/assets/docs.generated.json +2 -2
  155. package/assets/search-catalog.generated.json +2 -0
  156. package/assets/self-audit.generated.json +1 -1
  157. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
  158. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
  159. package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
  160. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
  161. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
  162. package/assets/templates/components.generated.json +1 -1
  163. package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
  164. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +5 -1
  165. package/assets/templates/pages/blank/template.doc.mjs +1 -1
  166. package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
  167. package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
  168. package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
  169. package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
  170. package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
  171. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
  172. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
  173. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
  174. package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
  175. package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
  176. package/assets/templates/pages/documentation/template.doc.mjs +4 -1
  177. package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
  178. package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
  179. package/assets/templates/pages/editor/template.doc.mjs +2 -8
  180. package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
  181. package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
  182. package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
  183. package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
  184. package/assets/templates/pages/ide/page.tsx +24 -2
  185. package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
  186. package/assets/templates/pages/library/template.doc.mjs +4 -1
  187. package/assets/templates/pages/login/template.doc.mjs +2 -1
  188. package/assets/templates/pages/login-card/template.doc.mjs +2 -1
  189. package/assets/templates/pages/login-split/template.doc.mjs +2 -1
  190. package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
  191. package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
  192. package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
  193. package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
  194. package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
  195. package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
  196. package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
  197. package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
  198. package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
  199. package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
  200. package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
  201. package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
  202. package/assets/templates/pages/table-page/template.doc.mjs +5 -4
  203. package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
  204. package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
  205. package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
  206. package/assets/theme.template.ts +6 -0
  207. package/authoring/debug/parse.d.mts +3 -3
  208. package/authoring/doctypes/_schema.d.mts +3 -3
  209. package/authoring/doctypes/command/command.doc.mjs +1 -1
  210. package/authoring/doctypes/component/categories.d.mts +37 -0
  211. package/authoring/doctypes/component/categories.mjs +54 -0
  212. package/authoring/doctypes/template/template.doc.mjs +1 -1
  213. package/authoring/doctypes/template/type.ts +9 -0
  214. package/authoring/example/example.doc.d.mts +12 -0
  215. package/authoring/example/example.doc.mjs +69 -0
  216. package/authoring/example/preview.d.mts +92 -0
  217. package/authoring/example/preview.mjs +994 -0
  218. package/authoring/example/type.ts +102 -0
  219. package/authoring/index.d.mts +1 -0
  220. package/authoring/index.d.ts +12 -0
  221. package/authoring/index.mjs +3 -1
  222. package/clients/cli/bin/astryx.mjs +6 -9
  223. package/clients/cli/build-id.generated.json +1 -1
  224. package/clients/cli/commands/component.doc.mjs +1 -1
  225. package/clients/cli/commands/component.mjs +22 -3
  226. package/clients/cli/commands/docs.doc.mjs +7 -1
  227. package/clients/cli/commands/docs.mjs +3 -1
  228. package/clients/cli/commands/doctor.mjs +32 -14
  229. package/clients/cli/commands/experimental/render.mjs +42 -1
  230. package/clients/cli/commands/experimental/theme.mjs +358 -63
  231. package/clients/cli/commands/experimental-render.doc.mjs +2 -2
  232. package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
  233. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
  234. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
  235. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  236. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  237. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  238. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  239. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  240. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
  241. package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
  242. package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
  243. package/clients/cli/commands/search.doc.mjs +2 -1
  244. package/clients/cli/commands/search.mjs +6 -1
  245. package/clients/cli/commands/template.mjs +4 -2
  246. package/clients/cli/commands/theme-build.doc.mjs +5 -1
  247. package/clients/cli/commands/theme.doc.mjs +1 -1
  248. package/clients/cli/commands/theme.mjs +317 -47
  249. package/clients/cli/commands/upgrade.mjs +42 -7
  250. package/clients/cli/index.mjs +1 -1
  251. package/clients/cli/lib/cli-error.mjs +2 -1
  252. package/clients/cli/lib/component-format.mjs +205 -98
  253. package/clients/cli/lib/hook-format.mjs +9 -19
  254. package/clients/cli/lib/json-shim.mjs +92 -21
  255. package/clients/cli/lib/manifest.mjs +3 -2
  256. package/clients/cli/manifest.generated.json +1 -1
  257. package/foundation/agent-docs/agent-docs.mjs +1 -1
  258. package/foundation/config/theme-state.d.mts +13 -1
  259. package/foundation/config/theme-state.mjs +47 -7
  260. package/foundation/discovery/authoring-self-docs.mjs +1 -0
  261. package/foundation/discovery/component-discovery.d.mts +11 -0
  262. package/foundation/discovery/component-discovery.mjs +56 -8
  263. package/foundation/discovery/component-replacement.mjs +130 -1
  264. package/foundation/discovery/copied-passages.mjs +2 -1
  265. package/foundation/discovery/doc-types.mjs +4 -3
  266. package/foundation/discovery/entry-name-files.d.mts +43 -0
  267. package/foundation/discovery/entry-name-files.mjs +264 -0
  268. package/foundation/discovery/hook-discovery.d.mts +8 -2
  269. package/foundation/discovery/hook-discovery.mjs +22 -8
  270. package/foundation/discovery/icon-definition-discovery.mjs +2 -1
  271. package/foundation/discovery/icon-set-checks.mjs +2 -1
  272. package/foundation/discovery/icon-set-discovery.mjs +2 -1
  273. package/foundation/discovery/integration-doc-files.mjs +2 -1
  274. package/foundation/discovery/package-exports.d.mts +10 -0
  275. package/foundation/discovery/package-exports.mjs +56 -3
  276. package/foundation/discovery/prop-drift.mjs +9 -9
  277. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  278. package/foundation/discovery/runner-allowlist.mjs +2 -0
  279. package/foundation/discovery/stored-component-list.d.mts +43 -0
  280. package/foundation/discovery/stored-component-list.mjs +90 -0
  281. package/foundation/discovery/stored-search-catalog.d.mts +115 -0
  282. package/foundation/discovery/stored-search-catalog.mjs +297 -0
  283. package/foundation/discovery/stored-self-audit.d.mts +26 -10
  284. package/foundation/discovery/stored-self-audit.mjs +38 -18
  285. package/foundation/discovery/template-adapter.d.mts +53 -1
  286. package/foundation/discovery/template-adapter.mjs +176 -12
  287. package/foundation/discovery/template-icons.mjs +2 -1
  288. package/foundation/discovery/theme-discovery.mjs +31 -4
  289. package/foundation/discovery/theme-imports.d.mts +14 -0
  290. package/foundation/discovery/theme-imports.mjs +43 -1
  291. package/foundation/discovery/theming-targets.mjs +3 -2
  292. package/foundation/doc-compiler/import.mjs +7 -1
  293. package/foundation/doc-compiler/inputs.mjs +3 -2
  294. package/foundation/doc-compiler/parse-readable.mjs +4 -1
  295. package/foundation/doc-compiler/stored-docs.d.mts +22 -0
  296. package/foundation/doc-compiler/stored-docs.mjs +49 -0
  297. package/foundation/env/semver.mjs +3 -1
  298. package/foundation/fonts/font-stylesheet.d.mts +31 -0
  299. package/foundation/fonts/font-stylesheet.mjs +115 -0
  300. package/foundation/fs/cache-eviction.d.mts +21 -0
  301. package/foundation/fs/cache-eviction.mjs +73 -0
  302. package/foundation/fs/exact-codec.d.mts +12 -2
  303. package/foundation/fs/exact-codec.mjs +23 -6
  304. package/foundation/fs/file-protection.mjs +4 -3
  305. package/foundation/fs/gather-cache.d.mts +62 -4
  306. package/foundation/fs/gather-cache.mjs +512 -91
  307. package/foundation/fs/jiti-cache.d.mts +19 -1
  308. package/foundation/fs/jiti-cache.mjs +130 -6
  309. package/foundation/fs/kept-tree.d.mts +60 -0
  310. package/foundation/fs/kept-tree.mjs +154 -0
  311. package/foundation/fs/listing-cache.d.mts +7 -0
  312. package/foundation/fs/listing-cache.mjs +10 -0
  313. package/foundation/fs/module-loader.d.mts +24 -2
  314. package/foundation/fs/module-loader.mjs +94 -21
  315. package/foundation/fs/paths.d.mts +18 -0
  316. package/foundation/fs/paths.mjs +15 -2
  317. package/foundation/fs/read-record.d.mts +9 -0
  318. package/foundation/fs/read-record.mjs +19 -11
  319. package/foundation/fs/stop-cleanup.d.mts +12 -0
  320. package/foundation/fs/stop-cleanup.mjs +66 -0
  321. package/foundation/identity/provider-identity.d.mts +6 -0
  322. package/foundation/identity/provider-identity.mjs +10 -1
  323. package/foundation/integrations/contribution-inventory.mjs +4 -3
  324. package/foundation/integrations/example-code.d.mts +63 -0
  325. package/foundation/integrations/example-code.mjs +416 -0
  326. package/foundation/integrations/public-imports.d.mts +9 -0
  327. package/foundation/integrations/public-imports.mjs +3 -2
  328. package/foundation/integrations/validate-contributions.mjs +17 -45
  329. package/foundation/render/embedded-files.d.mts +6 -0
  330. package/foundation/render/embedded-files.mjs +25 -5
  331. package/foundation/render/embedded-imports.d.mts +39 -7
  332. package/foundation/render/embedded-imports.mjs +66 -27
  333. package/foundation/render/file-header.d.mts +66 -0
  334. package/foundation/render/file-header.mjs +118 -0
  335. package/foundation/render/host-answer.d.mts +18 -0
  336. package/foundation/render/host-answer.mjs +46 -0
  337. package/foundation/render/host-exit.d.mts +1 -0
  338. package/foundation/render/host-exit.mjs +6 -1
  339. package/foundation/render/html-reader.d.mts +55 -2
  340. package/foundation/render/html-reader.mjs +145 -26
  341. package/foundation/render/markup-edits.d.mts +57 -0
  342. package/foundation/render/markup-edits.mjs +182 -0
  343. package/foundation/render/page-host.mjs +29 -12
  344. package/foundation/render/page-worker.mjs +121 -13
  345. package/foundation/render/picture-chrome.d.mts +4 -0
  346. package/foundation/render/picture-chrome.mjs +185 -0
  347. package/foundation/render/picture-playwright.d.mts +4 -0
  348. package/foundation/render/picture-playwright.mjs +34 -0
  349. package/foundation/render/rebuild.mjs +2 -1
  350. package/foundation/render/render-page.d.mts +35 -3
  351. package/foundation/render/render-page.mjs +641 -96
  352. package/foundation/render/source-block.d.mts +85 -6
  353. package/foundation/render/source-block.mjs +211 -20
  354. package/foundation/render/ts-paths.d.mts +69 -6
  355. package/foundation/render/ts-paths.mjs +326 -40
  356. package/foundation/response/error-codes.d.mts +3 -1
  357. package/foundation/response/error-codes.d.ts +1 -0
  358. package/foundation/response/error-codes.doc.mjs +12 -1
  359. package/foundation/response/error-codes.mjs +11 -1
  360. package/foundation/response/response-types.doc.mjs +2 -2
  361. package/foundation/text/compare-text.d.mts +14 -0
  362. package/foundation/text/compare-text.mjs +68 -0
  363. package/foundation/text/string-utils.d.mts +3 -2
  364. package/foundation/text/string-utils.mjs +18 -4
  365. package/foundation/text/suggest-order.d.mts +9 -0
  366. package/foundation/text/suggest-order.mjs +15 -1
  367. package/foundation/xle/expand.mjs +2 -1
  368. package/host/index.mjs +8 -6
  369. package/package.json +7 -6
@@ -31,6 +31,10 @@
31
31
 
32
32
  import * as fs from 'node:fs';
33
33
  import * as path from 'node:path';
34
+ import {
35
+ fontKey,
36
+ stylesheetFontFamilies,
37
+ } from '../../../foundation/fonts/font-stylesheet.mjs';
34
38
  import {fileURLToPath} from 'node:url';
35
39
  import {spawn} from 'node:child_process';
36
40
  import {
@@ -85,6 +89,7 @@ import {
85
89
  themeSourceFiles,
86
90
  themeSourceGuesses,
87
91
  buildSuggestion,
92
+ generatedSourceCommand,
88
93
  writeDeferredBuildOutputs,
89
94
  } from '../../../api/theme/build/build.mjs';
90
95
  import {defineCommand} from '../lib/define-command.mjs';
@@ -119,13 +124,45 @@ import {doc as themePaletteGenerateFn} from '../../../api/theme/themePaletteGene
119
124
  * @property {string} build - The build subcommand's name: `build` or `compile`.
120
125
  * @property {(err: import('../../../api/error.mjs').AstryxError, cwd: string) => import('../../../api/error.mjs').AstryxError | null} [explain] - A clearer refusal for this group, or null.
121
126
  * @property {(files: string[], options: {cwd: string, check?: boolean, family?: boolean, iconsSpecifier?: string, out?: string}) => Promise<import('../../../api/error.mjs').AstryxError | null>} [preflight] - A refusal before a build starts, or null.
122
- * @property {(files: string[], options: {cwd: string}) => Promise<() => Promise<void>>} [hold] - Locks held while a build or check runs; resolves to their release.
127
+ * @property {(err: import('../../../api/error.mjs').AstryxError, cwd: string) => Promise<import('../../../api/error.mjs').AstryxError>} [follow] - The refusal with its first suggested build checked and repaired as the build would check it.
128
+ * @property {(file: string, cwd: string) => import('../../../api/theme/build/build.mjs').FontHelp | null} [fontHelp] - How a group says to load a theme's fonts when it loads them itself (the editor's app copy).
129
+ * @property {(file: string, cwd: string) => string | null} [sourcePath] - The path a source builds under, when not the typed one; null to keep it.
130
+ * @property {(files: string[], cwd: string) => Promise<Record<string, Record<string, unknown>>>} [afterBuild] - Writes a group makes once a build's outputs are written (the editor's app copy), with what each did, by file, for its result.
131
+ * @property {(files: string[], options: {cwd: string, check?: boolean, out?: string}) => Promise<() => Promise<void>>} [hold] - Locks held while a build or check runs; resolves to their release.
132
+ * @property {(file: string, cwd: string, opts: {check: boolean, upToDate?: boolean, out?: string, iconsSpecifier?: string}) => Record<string, unknown> | null | Promise<Record<string, unknown> | null>} [extraData] - Fields a group adds to a build's result data (the editor's `appCopyStale`); in a check, `upToDate: false` fails it.
133
+ * @property {(file: string, cwd: string) => (['light'] | ['dark'] | null)} [colorModes] - The one color mode a theme file has that the file itself cannot say, for the build to write into the built module.
134
+ * @property {(file: string, cwd: string) => ((family: string) => boolean) | null | Promise<((family: string) => boolean) | null>} [loadedFonts] - Font families the app loads for a theme file that the file itself cannot say, so the build does not name them as unloaded.
123
135
  * @property {(file: string, cwd: string) => {name: string, reason: string} | null} [missingSource] - For a source file that is not there, this group's way to write it again, or null.
124
136
  * @property {(options: {targetPath?: string, overwrite?: boolean, cwd?: string}) => import('../../../api/theme/theme.type.mjs').ThemeTemplateResponse} [template] - This group's template write, in place of `themeTemplate`.
125
137
  */
126
138
 
127
139
  /** @type {ThemeCommandWords} */
128
- const THEME_WORDS = {group: 'theme', build: 'build'};
140
+ const THEME_WORDS = {
141
+ group: 'theme',
142
+ build: 'build',
143
+ loadedFonts: fontsLoadedBeside,
144
+ };
145
+
146
+ /**
147
+ * The font families a local theme's font stylesheet loads: the
148
+ * `<slug>.fonts.css` beside its source, where the theme's folder is named
149
+ * for its slug (the one font stylesheet `theme add` imports for it), read
150
+ * with its imports (an @fontsource package by its name, a stylesheet by its
151
+ * @font-face rules or the `family=` it requests). A build of that source
152
+ * does not name those families as unloaded. Another stylesheet in the
153
+ * folder loads nothing for the app, so it counts for nothing. Null when the
154
+ * theme has no font stylesheet.
155
+ * @param {string} file the theme source, as given
156
+ * @param {string} cwd
157
+ * @returns {((family: string) => boolean) | null}
158
+ */
159
+ function fontsLoadedBeside(file, cwd) {
160
+ const dir = path.dirname(path.resolve(cwd, file));
161
+ const sheet = path.join(dir, `${path.basename(dir)}.fonts.css`);
162
+ if (!fs.existsSync(sheet)) return null;
163
+ const loaded = stylesheetFontFamilies(sheet);
164
+ return loaded.size ? family => loaded.has(fontKey(family)) : null;
165
+ }
129
166
 
130
167
  /**
131
168
  * Text as the group that ran the command words it: under `experimental
@@ -193,13 +230,16 @@ function inGroupNotes(result, words) {
193
230
  * group that works whatever went wrong.
194
231
  * @param {import('../../../api/error.mjs').AstryxError} err
195
232
  * @param {ThemeCommandWords} [words]
196
- * @param {Array<{name: string, reason: string}>} [fallback]
233
+ * @param {Array<{name: string, reason?: string}>} [fallback]
197
234
  */
198
235
  function themeError(err, words = THEME_WORDS, fallback = []) {
199
236
  err = words.explain?.(err, process.cwd()) ?? err;
200
237
  /** @param {string} text */
201
238
  const local = text => inGroupWords(text, words);
202
239
  const given = err.suggestions || [];
240
+ // Suggested commands stay bare (`astryx …`): the JSON envelope carries
241
+ // them so, and the text output starts them the way this project runs the
242
+ // CLI.
203
243
  return cliError(local(err.message), {
204
244
  suggestions: (given.length > 0 ? given : fallback).map(x => ({
205
245
  ...x,
@@ -210,6 +250,41 @@ function themeError(err, words = THEME_WORDS, fallback = []) {
210
250
  });
211
251
  }
212
252
 
253
+ /**
254
+ * Add a group's fields to a build's result data. Its warnings join the
255
+ * build's own, and are printed as the build's are (`--json` prints none).
256
+ * @param {Record<string, any>} data
257
+ * @param {Record<string, unknown>} extra
258
+ */
259
+ function mergeResultData(data, extra) {
260
+ const {warnings, ...rest} = /** @type {any} */ (extra);
261
+ Object.assign(data, rest);
262
+ if (Array.isArray(warnings) && warnings.length > 0) {
263
+ data.warnings = [...(data.warnings ?? []), ...warnings];
264
+ for (const w of warnings) logger.warn(`Warning: ${w}`);
265
+ }
266
+ }
267
+
268
+ /** Marks a suggested build with what it builds, for the group's checks. */
269
+ const BUILD_RUN = Symbol('build run');
270
+
271
+ /**
272
+ * A suggested build, marked with the files and mode it builds so the
273
+ * group's own checks can vet it before it is shown (the mark is not part of
274
+ * what is printed).
275
+ * @template {{name: string, reason: string}} S
276
+ * @param {S} suggestion
277
+ * @param {string[]} files
278
+ * @param {{check?: boolean, family?: boolean, iconsSpecifier?: string, out?: string}} mode
279
+ * @returns {S}
280
+ */
281
+ function buildRun(suggestion, files, mode) {
282
+ return Object.defineProperty(suggestion, BUILD_RUN, {
283
+ value: {files, mode},
284
+ enumerable: false,
285
+ });
286
+ }
287
+
213
288
  /**
214
289
  * A command of this CLI as this project runs it, each argument quoted for the
215
290
  * shell.
@@ -629,6 +704,7 @@ function printThemeApp(result) {
629
704
  'stylesheet',
630
705
  'fontStylesheet',
631
706
  'source',
707
+ 'mode',
632
708
  ],
633
709
  layout: 'stacked',
634
710
  }),
@@ -641,6 +717,7 @@ function printThemeApp(result) {
641
717
  slug: change.slug,
642
718
  changed: change.changed,
643
719
  firstAdd: change.firstAdd,
720
+ ...(change.wireModes ? {wireModes: true} : {}),
644
721
  },
645
722
  ],
646
723
  {
@@ -651,20 +728,40 @@ function printThemeApp(result) {
651
728
  'slug',
652
729
  'changed',
653
730
  'firstAdd',
731
+ 'wireModes',
654
732
  ],
655
733
  layout: 'stacked',
656
734
  },
657
735
  ),
658
736
  );
659
737
  for (const note of result.data.notes ?? []) emit(text(`[note] ${note}`));
660
- if (!change.firstAdd) return;
661
738
  const stem = path.basename(modulePath, path.extname(modulePath));
739
+ if (!change.firstAdd) {
740
+ // The module now lists one-mode themes' modes: the app's wiring, made
741
+ // without them, passes the selected theme's mode from now on.
742
+ if (change.wireModes)
743
+ emit(
744
+ text(
745
+ "The theme module now exports themeModes. Pass the selected theme's mode to Theme in the app root:",
746
+ ),
747
+ code(
748
+ "import {Theme} from '@astryxdesign/core/theme';\n" +
749
+ `import {themes, defaultThemeSlug, themeModes} from './${stem}';\n\n` +
750
+ "<Theme theme={themes[defaultThemeSlug]} mode={themeModes[defaultThemeSlug] ?? 'system'}>\n <App />\n</Theme>",
751
+ ),
752
+ );
753
+ return;
754
+ }
755
+ // With a theme of one color mode added, the generated module lists each
756
+ // such theme's mode in `themeModes`, and the wiring passes the selected
757
+ // theme's (none for a two-mode theme, which follows the system).
758
+ const modes = result.data.themes.some(t => t.mode);
662
759
  emit(
663
760
  text('Wire the generated module once in the app root:'),
664
761
  code(
665
762
  "import {Theme} from '@astryxdesign/core/theme';\n" +
666
- `import {themes, defaultThemeSlug} from './${stem}';\n\n` +
667
- '<Theme theme={themes[defaultThemeSlug]}>\n <App />\n</Theme>',
763
+ `import {themes, defaultThemeSlug${modes ? ', themeModes' : ''}} from './${stem}';\n\n` +
764
+ `<Theme theme={themes[defaultThemeSlug]}${modes ? " mode={themeModes[defaultThemeSlug] ?? 'system'}" : ''}>\n <App />\n</Theme>`,
668
765
  ),
669
766
  );
670
767
  }
@@ -967,9 +1064,51 @@ function registerThemeCommands(theme, program, docs, words) {
967
1064
  const buildCli = defineCommand(theme, docs.build, {
968
1065
  fn: themeBuildFn,
969
1066
  action: async (
970
- /** @type {string[]} */ files,
1067
+ /** @type {string[]} */ typedFiles,
971
1068
  /** @type {{out?: string, watch?: boolean, check?: boolean, iconsSpecifier?: string, family?: boolean, familyKey?: string}} */ options,
972
1069
  ) => {
1070
+ // A group may name the path a source builds under (an editor theme
1071
+ // reached through a link builds under its own path, which its
1072
+ // outputs' headers name).
1073
+ const files = typedFiles.map(
1074
+ file => words.sourcePath?.(file, process.cwd()) ?? file,
1075
+ );
1076
+ // Every suggested build passes the group's own checks before it is
1077
+ // shown (from a subfolder an editor theme compiles from the app
1078
+ // root): a suggestion the group refuses gives way to the group's own
1079
+ // suggestion, which does.
1080
+ /** @param {Array<{name: string, reason?: string}> | undefined} list */
1081
+ const vet = async list => {
1082
+ /** @type {Array<{name: string, reason?: string}>} */
1083
+ const out = [];
1084
+ for (const s of list ?? []) {
1085
+ const run = /** @type {any} */ (s)[BUILD_RUN];
1086
+ const refused = run
1087
+ ? await words.preflight?.(run.files, {
1088
+ cwd: process.cwd(),
1089
+ ...run.mode,
1090
+ })
1091
+ : null;
1092
+ out.push(...(refused ? (refused.suggestions ?? []) : [s]));
1093
+ }
1094
+ return out;
1095
+ };
1096
+ /** @param {string} message @param {Parameters<typeof cliError>[1]} [opts] */
1097
+ const refuse = async (message, opts = {}) =>
1098
+ cliError(message, {
1099
+ ...opts,
1100
+ suggestions: await vet(opts.suggestions),
1101
+ });
1102
+ /**
1103
+ * @param {import('../../../api/error.mjs').AstryxError} err
1104
+ * @param {ThemeCommandWords} [w]
1105
+ * @param {Array<{name: string, reason?: string}>} [fallback]
1106
+ */
1107
+ const refuseTheme = async (err, w = words, fallback = []) => {
1108
+ err.suggestions = await vet(err.suggestions);
1109
+ return themeError(err, w, await vet(fallback));
1110
+ };
1111
+
973
1112
  const json = program.opts().json || false;
974
1113
  // The report is one line per theme unless the user asks for
975
1114
  // `--detail full`, which prints the install example and the font
@@ -996,7 +1135,29 @@ function registerThemeCommands(theme, program, docs, words) {
996
1135
  const rewrite = looksGlobby
997
1136
  ? null
998
1137
  : (words.missingSource?.(entry.file, process.cwd()) ?? null);
999
- return cliError(`File not found: ${entry.filePath}`, {
1138
+ // A file another command generates, gone from a folder whose other
1139
+ // files carry that command's mark: that command writes it again; a
1140
+ // blank theme template is no way back.
1141
+ const by =
1142
+ rewrite || looksGlobby
1143
+ ? null
1144
+ : generatedSourceCommand(entry.filePath);
1145
+ if (by)
1146
+ return await refuse(
1147
+ `File not found: ${entry.filePath}. It is a generated file: the files beside it are written by ${by}, so rebuild it with the command that made it.`,
1148
+ {
1149
+ code: ERROR_CODES.ERR_FILE_NOT_FOUND,
1150
+ suggestions: /^astryx(\s|$)/.test(by)
1151
+ ? [
1152
+ {
1153
+ name: `${getCliInvocation(process.cwd())} ${by.replace(/^astryx\s*/, '')}`.trim(),
1154
+ reason: 'the command that writes these files',
1155
+ },
1156
+ ]
1157
+ : [],
1158
+ },
1159
+ );
1160
+ return await refuse(`File not found: ${entry.filePath}`, {
1000
1161
  code: ERROR_CODES.ERR_FILE_NOT_FOUND,
1001
1162
  suggestions: rewrite
1002
1163
  ? [rewrite]
@@ -1024,11 +1185,28 @@ function registerThemeCommands(theme, program, docs, words) {
1024
1185
  },
1025
1186
  ]
1026
1187
  : guesses.length > 0
1027
- ? guesses.map(guess => ({
1028
- // The same build of that source: a --check stays a check.
1029
- name: buildSuggestion(guess, options, process.cwd(), words),
1030
- reason: 'a theme source that exists',
1031
- }))
1188
+ ? guesses.map(guess =>
1189
+ buildRun(
1190
+ {
1191
+ // The same build of that source: a --check stays a
1192
+ // check.
1193
+ name: buildSuggestion(
1194
+ guess,
1195
+ options,
1196
+ process.cwd(),
1197
+ words,
1198
+ ),
1199
+ reason: 'a theme source that exists',
1200
+ },
1201
+ [guess],
1202
+ {
1203
+ check: Boolean(options.check),
1204
+ family: Boolean(options.family),
1205
+ iconsSpecifier: options.iconsSpecifier,
1206
+ out: options.out,
1207
+ },
1208
+ ),
1209
+ )
1032
1210
  : [
1033
1211
  themeCommand(
1034
1212
  words,
@@ -1048,23 +1226,37 @@ function registerThemeCommands(theme, program, docs, words) {
1048
1226
  * @param {string[]} [only] the files to build, when not all of them
1049
1227
  */
1050
1228
  const buildWithout = (drop, reason, only = files) =>
1051
- themeCommand(
1052
- words,
1053
- words.build,
1054
- [
1055
- ...(options.family && !drop.includes('family')
1056
- ? ['--family', ...only, '--family-key', String(options.familyKey)]
1057
- : only),
1058
- ...(options.out && !drop.includes('out')
1059
- ? ['--out', options.out]
1060
- : []),
1061
- ...(options.check && !drop.includes('check') ? ['--check'] : []),
1062
- ...(options.watch && !drop.includes('watch') ? ['--watch'] : []),
1063
- ...(options.iconsSpecifier
1064
- ? ['--icons-specifier', options.iconsSpecifier]
1065
- : []),
1066
- ],
1067
- reason,
1229
+ buildRun(
1230
+ themeCommand(
1231
+ words,
1232
+ words.build,
1233
+ [
1234
+ ...(options.family && !drop.includes('family')
1235
+ ? [
1236
+ '--family',
1237
+ ...only,
1238
+ '--family-key',
1239
+ String(options.familyKey),
1240
+ ]
1241
+ : only),
1242
+ ...(options.out && !drop.includes('out')
1243
+ ? ['--out', options.out]
1244
+ : []),
1245
+ ...(options.check && !drop.includes('check') ? ['--check'] : []),
1246
+ ...(options.watch && !drop.includes('watch') ? ['--watch'] : []),
1247
+ ...(options.iconsSpecifier
1248
+ ? ['--icons-specifier', options.iconsSpecifier]
1249
+ : []),
1250
+ ],
1251
+ reason,
1252
+ ),
1253
+ only,
1254
+ {
1255
+ check: Boolean(options.check) && !drop.includes('check'),
1256
+ family: Boolean(options.family) && !drop.includes('family'),
1257
+ iconsSpecifier: options.iconsSpecifier,
1258
+ out: drop.includes('out') ? undefined : options.out,
1259
+ },
1068
1260
  );
1069
1261
 
1070
1262
  // A refusal from the build that names no command: without --out the
@@ -1096,7 +1288,7 @@ function registerThemeCommands(theme, program, docs, words) {
1096
1288
  ) === index,
1097
1289
  )
1098
1290
  .map(other => other.file);
1099
- return cliError(
1291
+ return await refuse(
1100
1292
  `${entry.file} is given more than once. Select each theme file once.`,
1101
1293
  {
1102
1294
  code: ERROR_CODES.ERR_THEME_INVALID,
@@ -1111,15 +1303,15 @@ function registerThemeCommands(theme, program, docs, words) {
1111
1303
  // Its key is required exactly with --family, and options that describe one
1112
1304
  // standalone output or a long-running loop remain intentionally separate.
1113
1305
  if (Boolean(options.family) !== Boolean(options.familyKey)) {
1114
- return cliError(
1306
+ return await refuse(
1115
1307
  options.family
1116
1308
  ? '--family requires --family-key <key>'
1117
1309
  : '--family-key requires --family',
1118
1310
  {
1119
1311
  code: ERROR_CODES.ERR_THEME_INVALID,
1120
1312
  suggestions: [
1121
- {
1122
- ...themeCommand(
1313
+ buildRun(
1314
+ themeCommand(
1123
1315
  words,
1124
1316
  words.build,
1125
1317
  [
@@ -1135,13 +1327,20 @@ function registerThemeCommands(theme, program, docs, words) {
1135
1327
  ],
1136
1328
  'build each theme on its own',
1137
1329
  ),
1138
- },
1330
+ files,
1331
+ {
1332
+ check: Boolean(options.check),
1333
+ family: false,
1334
+ iconsSpecifier: options.iconsSpecifier,
1335
+ out: files.length === 1 ? options.out : undefined,
1336
+ },
1337
+ ),
1139
1338
  ],
1140
1339
  },
1141
1340
  );
1142
1341
  }
1143
1342
  if (options.family && options.out) {
1144
- return cliError('--family cannot be combined with --out', {
1343
+ return await refuse('--family cannot be combined with --out', {
1145
1344
  code: ERROR_CODES.ERR_THEME_INVALID,
1146
1345
  suggestions: [
1147
1346
  buildWithout(['out'], 'family outputs go beside the family root'),
@@ -1149,7 +1348,7 @@ function registerThemeCommands(theme, program, docs, words) {
1149
1348
  });
1150
1349
  }
1151
1350
  if (options.family && options.watch) {
1152
- return cliError('--family cannot be combined with --watch', {
1351
+ return await refuse('--family cannot be combined with --watch', {
1153
1352
  code: ERROR_CODES.ERR_THEME_INVALID,
1154
1353
  suggestions: [buildWithout(['watch'], 'build the family once')],
1155
1354
  });
@@ -1158,7 +1357,7 @@ function registerThemeCommands(theme, program, docs, words) {
1158
1357
  // --check and --watch are mutually exclusive: check is a one-shot,
1159
1358
  // exit-coded verification; watch is a long-running rebuild loop.
1160
1359
  if (options.check && options.watch) {
1161
- return cliError('--check cannot be combined with --watch', {
1360
+ return await refuse('--check cannot be combined with --watch', {
1162
1361
  code: ERROR_CODES.ERR_THEME_INVALID,
1163
1362
  suggestions: [buildWithout(['watch'], 'check once')],
1164
1363
  });
@@ -1168,7 +1367,7 @@ function registerThemeCommands(theme, program, docs, words) {
1168
1367
  // it each theme writes `<theme name>.css` beside its source, which is
1169
1368
  // what a multi-theme build wants anyway.
1170
1369
  if (options.out && entries.length > 1) {
1171
- return cliError(
1370
+ return await refuse(
1172
1371
  `--out takes a single output path and ${entries.length} theme files were given. ` +
1173
1372
  'Build them without --out (each theme writes <name>.css next to its source), ' +
1174
1373
  'or run one invocation per theme.',
@@ -1189,7 +1388,7 @@ function registerThemeCommands(theme, program, docs, words) {
1189
1388
  // supported in --json (machine) mode, which expects a single envelope.
1190
1389
  if (options.watch) {
1191
1390
  if (json) {
1192
- return cliError('--watch is not supported with --json', {
1391
+ return await refuse('--watch is not supported with --json', {
1193
1392
  code: ERROR_CODES.ERR_THEME_INVALID,
1194
1393
  suggestions: [
1195
1394
  buildWithout(['watch'], 'build once, with a JSON result'),
@@ -1229,7 +1428,12 @@ function registerThemeCommands(theme, program, docs, words) {
1229
1428
  iconsSpecifier: options.iconsSpecifier,
1230
1429
  out: options.out,
1231
1430
  });
1232
- if (refused) return themeError(refused, words, buildFallback);
1431
+ if (refused)
1432
+ return await refuseTheme(
1433
+ (await words.follow?.(refused, process.cwd())) ?? refused,
1434
+ words,
1435
+ buildFallback,
1436
+ );
1233
1437
 
1234
1438
  if (options.family) {
1235
1439
  try {
@@ -1258,7 +1462,7 @@ function registerThemeCommands(theme, program, docs, words) {
1258
1462
  } catch (e) {
1259
1463
  const err =
1260
1464
  /** @type {import('../../../api/error.mjs').AstryxError} */ (e);
1261
- return themeError(err, words, [
1465
+ return await refuseTheme(err, words, [
1262
1466
  buildWithout(['family'], 'build each theme on its own'),
1263
1467
  ]);
1264
1468
  }
@@ -1288,8 +1492,8 @@ function registerThemeCommands(theme, program, docs, words) {
1288
1492
  for (const show of theme.lines) show();
1289
1493
  }
1290
1494
  };
1291
- const writeFailed = (/** @type {unknown} */ error) =>
1292
- themeError(
1495
+ const writeFailed = async (/** @type {unknown} */ error) =>
1496
+ refuseTheme(
1293
1497
  /** @type {import('../../../api/error.mjs').AstryxError} */ (error),
1294
1498
  words,
1295
1499
  [
@@ -1308,6 +1512,21 @@ function registerThemeCommands(theme, program, docs, words) {
1308
1512
  const writes = [];
1309
1513
  const log = logger.log;
1310
1514
  const warn = logger.warn;
1515
+ // A group may know fonts the app loads that the theme file cannot
1516
+ // say (the editor's app copy stylesheet): the build leaves them out
1517
+ // of every "not loaded" note, family by family.
1518
+ const loads =
1519
+ (await words.loadedFonts?.(entry.file, process.cwd())) ?? null;
1520
+ // A check whose result a group may still fail holds its lines
1521
+ // until the group has looked.
1522
+ /** @type {Array<string | undefined> | null} */
1523
+ let held = null;
1524
+ if (options.check && words.extraData && !deferred) {
1525
+ held = [];
1526
+ logger.log = (/** @type {string | undefined} */ message) => {
1527
+ held?.push(message);
1528
+ };
1529
+ }
1311
1530
  if (deferred) {
1312
1531
  logger.log = (/** @type {string | undefined} */ message) => {
1313
1532
  lines.push(() => log.call(logger, message));
@@ -1327,6 +1546,9 @@ function registerThemeCommands(theme, program, docs, words) {
1327
1546
  claimedOutputs,
1328
1547
  deferredWrites: deferred ? writes : undefined,
1329
1548
  commandWords: words,
1549
+ colorModes: words.colorModes?.(entry.file, process.cwd()) ?? null,
1550
+ fontHelp: words.fontHelp?.(entry.file, process.cwd()) ?? null,
1551
+ loadedFonts: loads,
1330
1552
  };
1331
1553
  let result;
1332
1554
  if (report) {
@@ -1360,6 +1582,29 @@ function registerThemeCommands(theme, program, docs, words) {
1360
1582
  }
1361
1583
  logger.log = log;
1362
1584
  logger.warn = warn;
1585
+ // A group may add to a build's result (the editor's app copy:
1586
+ // what keeps it behind, and in a check whether it is current).
1587
+ const extra = await words.extraData?.(entry.file, process.cwd(), {
1588
+ check: Boolean(options.check),
1589
+ upToDate: /** @type {any} */ (result)?.data?.upToDate,
1590
+ out: options.out,
1591
+ iconsSpecifier: options.iconsSpecifier,
1592
+ });
1593
+ if (extra && result?.data) mergeResultData(result.data, extra);
1594
+ // A check the group failed says so where the check said ok.
1595
+ if (held) {
1596
+ logger.log = log;
1597
+ for (const line of held)
1598
+ log.call(
1599
+ logger,
1600
+ extra?.upToDate === false &&
1601
+ typeof line === 'string' &&
1602
+ /^\s*\[ok\]/.test(line)
1603
+ ? `[fail] ${String(extra.appCopyStale ?? 'not up to date')}`
1604
+ : line,
1605
+ );
1606
+ held = null;
1607
+ }
1363
1608
  results.push({file: entry.file, receipt: result ?? null});
1364
1609
  if (deferred) built.push({writes, lines});
1365
1610
  if (
@@ -1373,6 +1618,8 @@ function registerThemeCommands(theme, program, docs, words) {
1373
1618
  } catch (e) {
1374
1619
  logger.log = log;
1375
1620
  logger.warn = warn;
1621
+ for (const line of held ?? []) log.call(logger, line);
1622
+ held = null;
1376
1623
  const err =
1377
1624
  /** @type {import('../../../api/error.mjs').AstryxError} */ (e);
1378
1625
  // Stop at the first failure, as a shell loop under `set -e` does.
@@ -1382,7 +1629,7 @@ function registerThemeCommands(theme, program, docs, words) {
1382
1629
  if (/** @type {any} */ (err).outputCollision) {
1383
1630
  // Nothing is written, so only this theme's warnings are shown.
1384
1631
  for (const show of lines) show();
1385
- return themeError(err, words, [
1632
+ return await refuseTheme(err, words, [
1386
1633
  buildWithout([], 'build the first theme on its own', [
1387
1634
  entries[0].file,
1388
1635
  ]),
@@ -1401,7 +1648,13 @@ function registerThemeCommands(theme, program, docs, words) {
1401
1648
  if (report && compact) printCompactTrailer(trailers);
1402
1649
  else if (report) printBatchTrailer(trailers);
1403
1650
  if (entries.length > 1) err.message = `${entry.file}: ${err.message}`;
1404
- return themeError(err, words, buildFallback);
1651
+ return await refuseTheme(
1652
+ entries.length === 1
1653
+ ? ((await words.follow?.(err, process.cwd())) ?? err)
1654
+ : err,
1655
+ words,
1656
+ buildFallback,
1657
+ );
1405
1658
  }
1406
1659
  }
1407
1660
  if (deferred) {
@@ -1411,6 +1664,18 @@ function registerThemeCommands(theme, program, docs, words) {
1411
1664
  return writeFailed(e);
1412
1665
  }
1413
1666
  }
1667
+ // A group follows the written outputs with writes of its own (the
1668
+ // editor's app copy), and each result says what they did.
1669
+ if (words.afterBuild && !options.check) {
1670
+ const more = await words.afterBuild(
1671
+ results.map(r => r.file),
1672
+ process.cwd(),
1673
+ );
1674
+ for (const r of results) {
1675
+ const data = /** @type {any} */ (r.receipt)?.data;
1676
+ if (data && more[r.file]) mergeResultData(data, more[r.file]);
1677
+ }
1678
+ }
1414
1679
 
1415
1680
  if (json) {
1416
1681
  // One theme keeps the single-envelope contract it has always had; a
@@ -1461,7 +1726,12 @@ function registerThemeCommands(theme, program, docs, words) {
1461
1726
  // Under --watch each rebuild runs on its own and takes the locks
1462
1727
  // itself; holding them for the whole watch would block every one.
1463
1728
  if (cmd.opts().watch) return;
1464
- release = await words.hold?.(cmd.args, {cwd: process.cwd()});
1729
+ const o = cmd.opts();
1730
+ release = await words.hold?.(cmd.args, {
1731
+ cwd: process.cwd(),
1732
+ check: Boolean(o.check),
1733
+ out: o.out,
1734
+ });
1465
1735
  });
1466
1736
  buildCli.hook('postAction', async () => {
1467
1737
  await release?.();
@@ -22,6 +22,44 @@ import {doc as upgradeCommand} from './upgrade.doc.mjs';
22
22
  import {doc as upgradeFn} from '../../../api/upgrade/upgrade.doc.mjs';
23
23
  import {NO_RESULT_SET, resultSet} from '../../../foundation/debug/index.mjs';
24
24
 
25
+ /**
26
+ * The codemod list as text: a heading that says how many codemods there are
27
+ * and names their package when they share one, then each version with one
28
+ * line per codemod, its name and title, and `(optional)` on a codemod that
29
+ * runs only on request. When codemods come from more than one package, every
30
+ * line names its package.
31
+ * @param {import('../../../api/upgrade/upgrade.type.mjs').UpgradeListResponse['data']} codemods
32
+ * @returns {import('../formatters/index.mjs').Block[]}
33
+ */
34
+ function codemodListBlocks(codemods) {
35
+ const packages = new Set(codemods.map(c => c.package));
36
+ const shared = packages.size === 1 ? [...packages][0] : null;
37
+ /** @type {Map<string, typeof codemods>} */
38
+ const byVersion = new Map();
39
+ for (const c of codemods) {
40
+ byVersion.set(c.version, [...(byVersion.get(c.version) ?? []), c]);
41
+ }
42
+ const count = `${codemods.length} codemod${codemods.length === 1 ? '' : 's'}`;
43
+ return [
44
+ section(
45
+ 'Available codemods',
46
+ `${count}${shared ? ` from ${shared}` : ''}, oldest first`,
47
+ ),
48
+ ...[...byVersion].flatMap(([version, group]) => [
49
+ section(version),
50
+ records(
51
+ group.map(c => ({
52
+ name: c.name,
53
+ title: c.title,
54
+ optional: c.optional ? '(optional)' : undefined,
55
+ package: shared ? undefined : c.package,
56
+ })),
57
+ {fields: ['name', 'title', 'optional', 'package'], layout: 'inline'},
58
+ ),
59
+ ]),
60
+ ];
61
+ }
62
+
25
63
  /**
26
64
  * @param {import('commander').Command} program
27
65
  */
@@ -79,13 +117,10 @@ export function registerUpgrade(program) {
79
117
  if (json) jsonOut(result);
80
118
  else if (result.type === 'upgrade.list') {
81
119
  // Render the list from the result, not the API logger, so the text
82
- // carries the same fields the JSON does (name, title, version, optional).
83
- emit(
84
- section('Available codemods'),
85
- records(result.data, {
86
- fields: ['name', 'package', 'title', 'version', 'optional'],
87
- }),
88
- );
120
+ // carries the same fields the JSON does. One line per codemod under
121
+ // its version: the list gains a line per codemod each release, not a
122
+ // five-line record.
123
+ emit(...codemodListBlocks(result.data));
89
124
  }
90
125
 
91
126
  const registrySummary =
@@ -595,7 +595,7 @@ export async function createProgram({argv} = {}) {
595
595
 
596
596
  program
597
597
  .name('astryx')
598
- .description('Design system CLI — components, themes, and tooling\n\nMaking or changing a theme? Use the experimental theme editor: astryx experimental theme editor new <name> --like neutral, then editor set / editor how "<what you want>"; after each change look at it with astryx experimental theme editor show <name> --png (writes PNGs, changes nothing in the app): a theme change is not done until you have looked. No app yet: astryx experimental theme preview app <dir>.')
598
+ .description('Design system CLI — components, themes, and tooling\n\nMaking or changing a theme? Use the experimental theme editor: astryx experimental theme editor new <name> --like neutral, then editor set / editor how "<what you want>"; after each change look at it with astryx experimental theme editor show <name> --png (takes pictures of real components): a theme change is not done until you have looked. No app yet: astryx experimental theme preview app <dir>.')
599
599
  .version(pkg.version)
600
600
  // These four change only the reads named in their text; every other
601
601
  // command ignores them.