@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
@@ -30,7 +30,10 @@ import {
30
30
  text,
31
31
  } from '../../formatters/index.mjs';
32
32
  import {cliError} from '../../lib/cli-error.mjs';
33
- import {editorMissingArgument} from '../../lib/json-shim.mjs';
33
+ import {
34
+ editorMissingArgument,
35
+ setEditorThemeList,
36
+ } from '../../lib/json-shim.mjs';
34
37
  import {AstryxError} from '../../../../api/error.mjs';
35
38
  import {defineCommand} from '../../lib/define-command.mjs';
36
39
  import {
@@ -48,7 +51,19 @@ import {
48
51
  builtInThemes,
49
52
  dialValueFits,
50
53
  newFlagList,
54
+ editorCheckedLine,
55
+ booleanWord,
51
56
  editorCompileProblem,
57
+ editorFollowCompile,
58
+ editorThemesAt,
59
+ typoNear,
60
+ typoOf,
61
+ editorAfterBuild,
62
+ editorFontHelp,
63
+ editorSourcePath,
64
+ editorBuildExtra,
65
+ editorLoadedFonts,
66
+ editorColorModes,
52
67
  editorThemeHold,
53
68
  editorThemeRefusal,
54
69
  editorMissingSource,
@@ -106,7 +121,6 @@ const cmd = line => {
106
121
  .join(stem);
107
122
  };
108
123
  /** The project's invocation of a command line (cmd, under a name an action's own `cmd` parameter does not hide). */
109
- const cliLine = (/** @type {string} */ line) => cmd(line);
110
124
 
111
125
  /**
112
126
  * Print blocks, a blank line between them, with this project's run prefix
@@ -484,7 +498,16 @@ function flagValues(name) {
484
498
  */
485
499
  function changeBlocks(r) {
486
500
  const d = r.data;
487
- const s = d.setting;
501
+ // The status line names the value as saved, with a quote or space mark
502
+ // the text output would fold written as its CSS escape (\201C), so the
503
+ // text and the JSON name the same value.
504
+ const s = {
505
+ ...d.setting,
506
+ value: String(d.setting.value).replace(
507
+ /[\u00A0\u00AB\u00BB\u2000-\u200B\u2018-\u201F\u2039\u203A\u202F\u3000\u300C-\u300F]/g,
508
+ c => `\\${c.codePointAt(0)?.toString(16).toUpperCase()} `,
509
+ ),
510
+ };
488
511
  const status =
489
512
  d.was != null
490
513
  ? `[ok] ${d.theme}: ${s.thing} ${d.was} -> ${s.value}`
@@ -639,10 +662,17 @@ function strayOption(command, rest) {
639
662
  },
640
663
  );
641
664
  }
642
- const word = rest.find(w => typeof w === 'string' && w.startsWith('--'));
665
+ // A value pasted with a token's label (`'--color-accent: #e11d48'`) is
666
+ // a value, read by the label reader, not an option.
667
+ const word = rest.find(
668
+ w =>
669
+ typeof w === 'string' &&
670
+ w.startsWith('--') &&
671
+ !/^--[a-z0-9-]+\s*:\s*\S/i.test(w),
672
+ );
643
673
  if (word == null) return null;
644
674
  return cliError(
645
- `unknown option '${word}': only the thing a change names may start with -- (a design token such as --color-accent).`,
675
+ `unknown option '${word}': ${command} takes no such option, and a design token (such as --color-accent) is the thing a change names, before its value.`,
646
676
  {
647
677
  suggestions: [
648
678
  {
@@ -655,6 +685,168 @@ function strayOption(command, rest) {
655
685
  );
656
686
  }
657
687
 
688
+ /**
689
+ * Read the options of an editor command as written, the one reading every
690
+ * editor command gives them: an option in other letters, with one dash or
691
+ * a typed dash (`--On`, `-only`, `\u2014only`) or within the one typo limit
692
+ * of an option the command takes (`--olny`) is that option; a boolean
693
+ * option written with a value (`--png=false`, `--only true`) takes none,
694
+ * and its value is read by the one yes/no reader (booleanWord). Null when
695
+ * every option is written as the command takes it; else the reason, and
696
+ * the command as meant (the option as the command takes it; a boolean as
697
+ * itself for yes, left out for no), or no command when a boolean's value
698
+ * reads as neither.
699
+ * @param {string} command the subcommand (`set`, `undo`, `new`, `show`, how's word)
700
+ * @param {import('@astryxdesign/cli/authoring').CommandDoc} doc the command's doc, which lists its options
701
+ * @returns {{why: string, line: string | null} | null}
702
+ */
703
+ function optionsAsWritten(command, doc) {
704
+ const flags = (doc.options ?? []).map(opt => String(opt.flag));
705
+ const names = (/** @type {(f: string) => boolean} */ keep) =>
706
+ flags
707
+ .filter(keep)
708
+ .flatMap(f => f.split(/[\s,]+/).filter(w => w.startsWith('--')));
709
+ const booleans = ['--json', ...names(f => !/[<[]/.test(f))];
710
+ const all = [...booleans, ...names(f => /[<[]/.test(f))];
711
+ /** The option a word names, as the command takes it, or null. @param {string} word */
712
+ const meant = word => {
713
+ const w = word.toLowerCase();
714
+ if (all.includes(`--${w}`)) return `--${w}`;
715
+ const near = all.filter(o => typoNear(w, o.slice(2)));
716
+ return near.length === 1 ? near[0] : null;
717
+ };
718
+ const argv = process.argv;
719
+ const at = argv.indexOf(command, argv.indexOf('editor') + 1);
720
+ if (at < 0) return null;
721
+ /** @type {string[]} */
722
+ const words = [];
723
+ /** @type {string | null} */
724
+ let why = null;
725
+ let unread = false;
726
+ for (let i = at + 1; i < argv.length; i += 1) {
727
+ const a = argv[i];
728
+ if (a === '--') {
729
+ words.push(...argv.slice(i));
730
+ break;
731
+ }
732
+ const m = /^(--?|[\u2013\u2014]-?)([A-Za-z][A-Za-z-]*)(?:=(.*))?$/.exec(a);
733
+ const flag = m ? meant(m[2]) : null;
734
+ if (!m || !flag) {
735
+ if (a !== '--json') words.push(a);
736
+ continue;
737
+ }
738
+ const written = m[3] == null ? `${m[1]}${m[2]}` : a.split('=')[0];
739
+ if (written !== flag)
740
+ why ??= `unknown option '${written}' (did you mean ${flag}?)`;
741
+ const next = argv[i + 1];
742
+ if (booleans.includes(flag)) {
743
+ // A value after a boolean option, joined by `=` or as the next word
744
+ // when that word is a yes or a no.
745
+ const value = m[3] ?? (booleanWord(next) != null ? String(next) : null);
746
+ if (value != null) {
747
+ if (m[3] == null) i += 1;
748
+ const read = booleanWord(value);
749
+ const shown = m[3] == null ? `${a} ${value}` : a;
750
+ if (read == null) unread = true;
751
+ why ??=
752
+ read == null
753
+ ? `${flag} takes no value ("${shown}"), and "${value}" reads as neither yes nor no: give ${flag} alone for yes, or leave it out`
754
+ : `${flag} takes no value ("${shown}"): give it alone for yes, or leave it out`;
755
+ if (read === true && flag !== '--json') words.push(flag);
756
+ continue;
757
+ }
758
+ if (flag !== '--json') words.push(flag);
759
+ continue;
760
+ }
761
+ // An option that takes a value, given none, is left out of the line.
762
+ if (m[3] == null && (next == null || /^-/.test(next))) continue;
763
+ words.push(flag);
764
+ if (m[3] != null) words.push(m[3]);
765
+ }
766
+ if (!why) return null;
767
+ return {
768
+ why,
769
+ line: unread
770
+ ? null
771
+ : `${EDITOR} ${command} ${words.map(w => (/^--[a-z]/.test(w) && all.includes(w) ? w : quoteCommandArgument(w))).join(' ')}`.trim(),
772
+ };
773
+ }
774
+
775
+ /**
776
+ * The refusal of options not written as the command takes them, with the
777
+ * command as meant when there is one.
778
+ * @param {string} command
779
+ * @param {{why: string, line: string | null}} read
780
+ */
781
+ function optionsRefusal(command, read) {
782
+ return cliError(`${read.why}.`, {
783
+ suggestions: [
784
+ ...(read.line ? [{name: cmd(read.line), reason: 'do this instead'}] : []),
785
+ {
786
+ name: cmd(`${EDITOR} ${command} --help`),
787
+ reason: 'every option it takes',
788
+ },
789
+ ],
790
+ code: ERROR_CODES.ERR_INVALID_OPTION,
791
+ });
792
+ }
793
+
794
+ /**
795
+ * {@link optionsAsWritten} as a refusal, or null.
796
+ * @param {string} command
797
+ * @param {import('@astryxdesign/cli/authoring').CommandDoc} doc
798
+ */
799
+ function readOptions(command, doc) {
800
+ const read = optionsAsWritten(command, doc);
801
+ return read ? optionsRefusal(command, read) : null;
802
+ }
803
+
804
+ /**
805
+ * {@link readOptions} for `set` and `undo`, whose line is checked as every
806
+ * offered line is (the command's own check, a repair it offers folded in):
807
+ * a line set or undo refuses with no repair is not offered.
808
+ * @param {'set' | 'undo'} command
809
+ * @param {import('@astryxdesign/cli/authoring').CommandDoc} doc
810
+ */
811
+ async function readOptionsChecked(command, doc) {
812
+ const read = optionsAsWritten(command, doc);
813
+ if (!read) return null;
814
+ const line = read.line
815
+ ? await editorCheckedLine(command, read.line, process.cwd())
816
+ : null;
817
+ return optionsRefusal(command, {...read, line});
818
+ }
819
+
820
+ /**
821
+ * Refuse an option `show` does not take with a show that works: the same
822
+ * show without it, the nearest option it takes, and its help (an option it
823
+ * takes written with a value is read by {@link readOptions}). Null
824
+ * when there is none.
825
+ * @param {string} name
826
+ * @param {unknown[]} rest the words after the theme
827
+ * @param {{png?: boolean, section?: string}} o the options read
828
+ */
829
+ function showStray(name, rest, o) {
830
+ const stray = rest.map(String).find(w => w.startsWith('-'));
831
+ if (stray == null) return null;
832
+ const [flag] = stray.split('=');
833
+ const near = ['--png', '--section', '--json']
834
+ .map(t => ({t, d: levenshteinDistance(flag.toLowerCase(), t)}))
835
+ .filter(x => x.d <= 2)
836
+ .sort((a, b) => a.d - b.d)[0]?.t;
837
+ const line = `${EDITOR} show ${name}${o.section ? ` --section ${o.section}` : ''}${o.png ? ' --png' : ''}`;
838
+ return cliError(
839
+ `unknown option '${stray}'${near && near !== flag ? ` (did you mean ${near}?)` : ''}.`,
840
+ {
841
+ suggestions: [
842
+ {name: cmd(line), reason: 'do this instead'},
843
+ {name: cmd(`${EDITOR} show --help`), reason: 'every option it takes'},
844
+ ],
845
+ code: ERROR_CODES.ERR_INVALID_OPTION,
846
+ },
847
+ );
848
+ }
849
+
658
850
  /**
659
851
  * A refusal for words after what a command takes, which would otherwise be
660
852
  * dropped without a word; null when there are none.
@@ -727,18 +919,24 @@ function defineGroup(parent, doc) {
727
919
  if (extras.length > 0) {
728
920
  const word = String(extras[0]).toLowerCase();
729
921
  const group = doc.name.split(' ').at(-1) ?? '';
730
- const moved =
731
- MOVED[group]?.[word] ??
732
- // `preview <theme>`: the pages for a theme.
733
- (group === 'preview' && /^[a-z][a-z0-9-]*$/.test(word)
734
- ? `add --theme ${word}`
735
- : null);
736
922
  const ranked = (cmd.commands ?? [])
737
923
  .map(command => command.name())
738
924
  .sort(
739
925
  (a, b) =>
740
926
  levenshteinDistance(word, a) - levenshteinDistance(word, b),
741
927
  );
928
+ // A typo of a subcommand (lst, remve) is that subcommand; any
929
+ // other word after `preview` that names an editor theme here asks
930
+ // for that theme's pages.
931
+ const typo = typoOf(word, ranked[0] ?? '') ? ranked[0] : null;
932
+ const moved =
933
+ MOVED[group]?.[word] ??
934
+ (typo
935
+ ? null
936
+ : group === 'preview' &&
937
+ editorThemesAt(process.cwd()).includes(word)
938
+ ? `add --theme ${word}`
939
+ : null);
742
940
  return cliError(
743
941
  `unknown subcommand '${doc.name} ${String(extras[0])}'${moved ? `; it is ${here} ${moved}` : ''}`,
744
942
  {
@@ -777,12 +975,32 @@ function defineGroup(parent, doc) {
777
975
  return cmd;
778
976
  }
779
977
 
978
+ /**
979
+ * A preview command's result, once it is in: this client owns its process,
980
+ * so a stop that lands while the result is printed is held, and a printed
981
+ * ok never ends with exit 130. The API itself leaves no listener behind.
982
+ * @template T
983
+ * @param {Promise<T>} result
984
+ * @returns {Promise<T>}
985
+ */
986
+ async function resultStands(result) {
987
+ const r = await result;
988
+ for (const sig of /** @type {const} */ (['SIGINT', 'SIGTERM']))
989
+ if (!process.listeners(sig).includes(heldStop)) process.on(sig, heldStop);
990
+ return r;
991
+ }
992
+
993
+ /** A stop after a preview command finished: its result stands. */
994
+ function heldStop() {}
995
+
780
996
  /**
781
997
  * Register `theme` and its subcommands under the `experimental` group.
782
998
  * @param {import('commander').Command} group the `experimental` command
783
999
  * @param {import('commander').Command} program the root program
784
1000
  */
785
1001
  export function registerExperimentalTheme(group, program) {
1002
+ // A command run with no theme names the app's only theme.
1003
+ setEditorThemeList(editorThemesAt);
786
1004
  const theme = defineGroup(group, groupDoc);
787
1005
  explained(theme, groupDoc);
788
1006
  theme.addHelpText(
@@ -807,6 +1025,8 @@ export function registerExperimentalTheme(group, program) {
807
1025
  run(
808
1026
  program,
809
1027
  () => {
1028
+ const valued = readOptions('new', newDoc);
1029
+ if (valued) return valued;
810
1030
  // An option new does not take (--force, --dry-run, -t) is refused
811
1031
  // with new's help, as every editor command's unknown option is.
812
1032
  const takes = new Set(
@@ -824,16 +1044,45 @@ export function registerExperimentalTheme(group, program) {
824
1044
  (/** @type {string} */ w) =>
825
1045
  /^-/.test(w) && !takes.has(w.split('=')[0]),
826
1046
  );
1047
+ // `--base` is the dial new takes as --like.
1048
+ if (stray && stray.split('=')[0] === '--base') {
1049
+ const args = (cmd?.args ?? []).slice(1).map(String);
1050
+ const at = args.indexOf(stray);
1051
+ const value = stray.includes('=')
1052
+ ? stray.slice(stray.indexOf('=') + 1)
1053
+ : args[at + 1];
1054
+ // Thrown, as every refusal inside run is: run prints it once
1055
+ // (a refusal printed here and then caught again by run would
1056
+ // print twice where exit does not end the process).
1057
+ throw new AstryxError(
1058
+ `new takes the base theme as --like, not --base.`,
1059
+ value
1060
+ ? [
1061
+ {
1062
+ name: `${EDITOR} new ${quoteCommandArgument(name)}${newFlagLine({...o, like: value})}`,
1063
+ reason: 'do this instead',
1064
+ },
1065
+ ]
1066
+ : [
1067
+ {
1068
+ name: `${EDITOR} new --help`,
1069
+ reason: 'every option it takes',
1070
+ },
1071
+ ],
1072
+ ERROR_CODES.ERR_INVALID_OPTION,
1073
+ );
1074
+ }
827
1075
  if (stray)
828
- return cliError(`unknown option '${stray}'.`, {
829
- suggestions: [
1076
+ throw new AstryxError(
1077
+ `unknown option '${stray}'.`,
1078
+ [
830
1079
  {
831
- name: cliLine(`${EDITOR} new --help`),
1080
+ name: `${EDITOR} new --help`,
832
1081
  reason: 'every option it takes',
833
1082
  },
834
1083
  ],
835
- code: ERROR_CODES.ERR_INVALID_OPTION,
836
- });
1084
+ ERROR_CODES.ERR_INVALID_OPTION,
1085
+ );
837
1086
  // A word after the name is never dropped without a word.
838
1087
  const extra = (cmd?.args ?? []).slice(1);
839
1088
  if (extra.length) {
@@ -856,15 +1105,26 @@ export function registerExperimentalTheme(group, program) {
856
1105
  }
857
1106
  words.push(w);
858
1107
  }
859
- const builtIn =
860
- words.length && builtInThemes().includes(words[0]);
861
- if (builtIn && given.like == null) given.like = words[0];
862
- const fixed = builtIn
863
- ? name
864
- : [name, ...words]
865
- .join('-')
866
- .toLowerCase()
867
- .replace(/[^a-z0-9-]+/g, '-');
1108
+ // A built-in theme among the words (after a `like` word, or
1109
+ // typed as the name with the real name after it) is the base,
1110
+ // as --like; every other word is part of the name.
1111
+ const all = [String(name), ...words];
1112
+ const baseAt = all.findIndex(
1113
+ (w, i) =>
1114
+ builtInThemes().includes(w.toLowerCase()) &&
1115
+ (i > 0 || all.length > 1),
1116
+ );
1117
+ if (baseAt >= 0 && given.like == null)
1118
+ given.like = all[baseAt].toLowerCase();
1119
+ const nameWords = all.filter(
1120
+ (w, i) =>
1121
+ i !== baseAt &&
1122
+ !(baseAt >= 0 && /^like$/i.test(w) && i === baseAt - 1),
1123
+ );
1124
+ const fixed = nameWords
1125
+ .join('-')
1126
+ .toLowerCase()
1127
+ .replace(/[^a-z0-9-]+/g, '-');
868
1128
  throw new AstryxError(
869
1129
  `new takes one theme name; "${extra.join(' ')}" is extra. For a base theme, use --like. Nothing was changed.`,
870
1130
  [
@@ -908,10 +1168,17 @@ export function registerExperimentalTheme(group, program) {
908
1168
  // A declaration pasted as one argument (`--color-accent: #e11d48`,
909
1169
  // or `--color-accent:#e11d48`) is the token and its value; with no
910
1170
  // value otherwise, the missing-argument error the parser gives.
1171
+ // A pasted JSON object of settings goes to the editor whole, which
1172
+ // gives one set line per entry.
1173
+ if (!value.length && /^\s*\{/.test(thing)) value = [''];
911
1174
  if (!value.length) {
912
1175
  // Any thing, a token or a dial, with `:` or `=` (`accent: red`,
913
1176
  // `--color-accent=#e11d48`).
914
- const pasted = /^(\S+?)\s*[:=]\s*(.+?);?\s*$/.exec(thing);
1177
+ // A thing and its value in one word (`'corners pill'`) are the
1178
+ // same as given apart.
1179
+ const pasted =
1180
+ /^(\S+?)\s*[:=]\s*(.+?);?\s*$/.exec(thing) ??
1181
+ /^\s*(\S+)\s+(.+?)\s*$/.exec(thing);
915
1182
  if (!pasted)
916
1183
  return missingSetValue(
917
1184
  editor.commands.find(c => c.name() === 'set'),
@@ -919,14 +1186,20 @@ export function registerExperimentalTheme(group, program) {
919
1186
  thing = pasted[1];
920
1187
  value = [pasted[2]];
921
1188
  }
922
- return (
923
- strayOption('set', value) ??
1189
+ return (async () =>
1190
+ (await readOptionsChecked('set', setDoc)) ??
1191
+ // A token typed after its value (`set t 4px --radius-element`)
1192
+ // is no option: the set reads the two in the other order.
1193
+ (value.length === 1 &&
1194
+ /^--[a-z0-9-]+$/i.test(value[0]) &&
1195
+ !thing.startsWith('-')
1196
+ ? null
1197
+ : strayOption('set', value)) ??
924
1198
  run(
925
1199
  program,
926
1200
  () => themeEditSet(name, thing, value.join(' '), changeOptions(o)),
927
1201
  changeBlocks,
928
- )
929
- );
1202
+ ))();
930
1203
  },
931
1204
  }),
932
1205
  setDoc,
@@ -941,6 +1214,8 @@ export function registerExperimentalTheme(group, program) {
941
1214
  /** @type {any} */ o,
942
1215
  /** @type {any} */ c,
943
1216
  ) =>
1217
+ readOptions('show', showDoc) ??
1218
+ showStray(name, (c?.args ?? []).slice(1), o) ??
944
1219
  extraWords('show', (c?.args ?? []).slice(1)) ??
945
1220
  // The sheet is limited to one section (the docs say so): a second
946
1221
  // --section is refused, never kept over the first in silence.
@@ -974,6 +1249,8 @@ export function registerExperimentalTheme(group, program) {
974
1249
  ),
975
1250
  }),
976
1251
  showDoc,
1252
+ // An unknown option reaches the action, which names a show that works.
1253
+ {tokens: true},
977
1254
  );
978
1255
 
979
1256
  explained(
@@ -986,27 +1263,29 @@ export function registerExperimentalTheme(group, program) {
986
1263
  /** @type {any} */ o,
987
1264
  /** @type {import('commander').Command} */ c,
988
1265
  ) =>
989
- strayOption('undo', [which, ...(c?.args ?? []).slice(3)]) ??
990
- extraWords('undo', (c?.args ?? []).slice(3)) ??
991
- run(
992
- program,
993
- () =>
994
- themeEditUndo(name, {
995
- ...changeOptions(o),
996
- ...(thing == null ? {} : {thing, value: which}),
997
- }),
998
- r =>
999
- r.data.action === 'step'
1000
- ? [
1001
- `[ok] ${r.data.theme}: undid the last change`,
1002
- ...project(/** @type {any} */ (r.data)),
1003
- ]
1004
- : changeBlocks(
1005
- /** @type {import('../../../../api/theme-edit/theme-edit.type.mjs').ThemeEditChangeResponse} */ (
1006
- r
1266
+ (async () =>
1267
+ (await readOptionsChecked('undo', undoDoc)) ??
1268
+ strayOption('undo', [which, ...(c?.args ?? []).slice(3)]) ??
1269
+ extraWords('undo', (c?.args ?? []).slice(3)) ??
1270
+ run(
1271
+ program,
1272
+ () =>
1273
+ themeEditUndo(name, {
1274
+ ...changeOptions(o),
1275
+ ...(thing == null ? {} : {thing, value: which}),
1276
+ }),
1277
+ r =>
1278
+ r.data.action === 'step'
1279
+ ? [
1280
+ `[ok] ${r.data.theme}: undid the last change`,
1281
+ ...project(/** @type {any} */ (r.data)),
1282
+ ]
1283
+ : changeBlocks(
1284
+ /** @type {import('../../../../api/theme-edit/theme-edit.type.mjs').ThemeEditChangeResponse} */ (
1285
+ r
1286
+ ),
1007
1287
  ),
1008
- ),
1009
- ),
1288
+ ))(),
1010
1289
  }),
1011
1290
  undoDoc,
1012
1291
  {tokens: true},
@@ -1026,13 +1305,15 @@ export function registerExperimentalTheme(group, program) {
1026
1305
  program,
1027
1306
  () =>
1028
1307
  previewFlagsOnce('add', ['theme', 'template', 'top', 'path']) ??
1029
- themeEditPreviewAdd([words ?? []].flat().join(' ') || undefined, {
1030
- cwd: process.cwd(),
1031
- theme: o.theme,
1032
- template: o.template,
1033
- top: o.top,
1034
- path: o.path,
1035
- }),
1308
+ resultStands(
1309
+ themeEditPreviewAdd([words ?? []].flat().join(' ') || undefined, {
1310
+ cwd: process.cwd(),
1311
+ theme: o.theme,
1312
+ template: o.template,
1313
+ top: o.top,
1314
+ path: o.path,
1315
+ }),
1316
+ ),
1036
1317
  r => {
1037
1318
  const {matched, skipped, ...rest} = r.data;
1038
1319
  return [
@@ -1073,10 +1354,12 @@ export function registerExperimentalTheme(group, program) {
1073
1354
  program,
1074
1355
  () =>
1075
1356
  previewFlagsOnce('app', ['theme']) ??
1076
- themeEditPreviewApp(dir, {
1077
- cwd: process.cwd(),
1078
- theme: o.theme,
1079
- }),
1357
+ resultStands(
1358
+ themeEditPreviewApp(dir, {
1359
+ cwd: process.cwd(),
1360
+ theme: o.theme,
1361
+ }),
1362
+ ),
1080
1363
  r => [
1081
1364
  `[ok] new app in ${r.data.folder} with the theme preview`,
1082
1365
  ...project(/** @type {any} */ (r.data)),
@@ -1157,7 +1440,9 @@ export function registerExperimentalTheme(group, program) {
1157
1440
  program,
1158
1441
  () =>
1159
1442
  previewFlagsOnce('remove', ['path']) ??
1160
- themeEditPreviewRemove(page, {cwd: process.cwd(), path: o.path}),
1443
+ resultStands(
1444
+ themeEditPreviewRemove(page, {cwd: process.cwd(), path: o.path}),
1445
+ ),
1161
1446
  r => [
1162
1447
  r.data.pages.length
1163
1448
  ? `[ok] removed ${page} from the theme preview`
@@ -1256,7 +1541,10 @@ export function registerExperimentalTheme(group, program) {
1256
1541
  // question); a picture is told by its extension here only to keep
1257
1542
  // option words after it for the count.
1258
1543
  const picture = /\.png$/i.test(rest[0] ?? '');
1259
- const stray = picture ? null : strayOption('how', rest.slice(1));
1544
+ const stray = picture
1545
+ ? null
1546
+ : (readOptions(howDoc.name.split(' ').pop() ?? 'how', howDoc) ??
1547
+ strayOption('how', rest.slice(1)));
1260
1548
  if (stray) return stray;
1261
1549
  return run(
1262
1550
  program,
@@ -1303,9 +1591,16 @@ export function registerExperimentalTheme(group, program) {
1303
1591
  build: 'compile',
1304
1592
  explain: editorThemeRefusal,
1305
1593
  preflight: editorCompileProblem,
1594
+ follow: editorFollowCompile,
1306
1595
  missingSource: editorMissingSource,
1307
1596
  template: editorThemeTemplate,
1308
1597
  hold: editorThemeHold,
1598
+ loadedFonts: editorLoadedFonts,
1599
+ extraData: editorBuildExtra,
1600
+ afterBuild: editorAfterBuild,
1601
+ sourcePath: editorSourcePath,
1602
+ fontHelp: editorFontHelp,
1603
+ colorModes: editorColorModes,
1309
1604
  },
1310
1605
  );
1311
1606
  }
@@ -16,7 +16,7 @@ export const doc = {
16
16
  summary:
17
17
  'Render a page to one self-contained HTML file, or turn one back into a page',
18
18
  description:
19
- "Renders the page's default export with the project's own Astryx components and writes ONE static HTML file that needs nothing beside it: no script runs and nothing loads from the network, so it opens anywhere, including a sandboxed frame with a strict content security policy, and follows the viewer's light or dark scheme. The page's own StyleX compiles, only the Core CSS rules the page uses are inlined, local images become data: URIs, and the page's source is embedded. Warnings name anything that may not look as meant, such as a component that did not render the text it was given (ListItem takes label=, not children). --reverse writes the embedded source back byte for byte; a file with Astryx markup but no embedded source is rebuilt from its components (text and layout only, as a starting point); any other HTML is refused. Experimental: it may change or be removed in a patch release.",
19
+ "Renders the page's default export with the project's own Astryx components and writes ONE static HTML file that needs nothing beside it: no script runs and nothing loads from the network, so it opens anywhere, including a sandboxed frame with a strict content security policy, and follows the viewer's light or dark scheme. The page's own StyleX compiles, only the Core CSS rules the page uses are inlined, local images become data: URIs, and the page's source is embedded. Warnings name anything that may not look as meant, such as a component that did not render the text it was given (ListItem takes label=, not children). The file opens with a plain note for whoever opens it next: the CLI version and render format that made it, the page's path, the files it carries, the packages it rendered with, and the exact commands that give the page back and render it again. --reverse (the way back, or unrender) writes the embedded source back byte for byte and names any text someone changed in the HTML after the render, with the file and line that hold the old text; a file with Astryx markup but no embedded source is rebuilt from its components (text and layout only, as a starting point); any other HTML is refused. Experimental: it may change or be removed in a patch release.",
20
20
  fn: 'render',
21
21
  args: [{name: 'file', param: 'file', required: false}],
22
22
  options: [
@@ -53,7 +53,7 @@ export const doc = {
53
53
  {code: 0, when: 'the file was written (warnings included)'},
54
54
  {
55
55
  code: 1,
56
- when: 'no file, a wrong extension, a missing file, a page that does not compile, has no default export, imports a package that is not installed, reads a browser API while rendering, throws, crashes Node, or takes over 60 seconds; a file to write outside the current folder; with --reverse, an existing output without --overwrite, a damaged embedded source, or HTML that is not an Astryx page',
56
+ when: 'no file, a wrong extension, a missing file, a page that does not compile, has no default export, imports a package that is not installed, reads a browser API while rendering, throws, crashes Node, or takes over 60 seconds; a file to write outside the current folder; with --reverse, an existing output without --overwrite, a damaged embedded source, a file in a newer render format than this CLI reads, or HTML that is not an Astryx page',
57
57
  },
58
58
  ],
59
59
  related: ['template', 'build'],
@@ -14,7 +14,7 @@ export const doc = {
14
14
  stability: 'experimental',
15
15
  summary: 'Compile standalone themes or one keyed theme family',
16
16
  description:
17
- 'Compiles defineTheme() sources through the same theme pipeline into scoped CSS, standard ESM, and type declarations. Ordinary mode writes one complete set per theme. --family combines one selected extension tree into the three files named by the required --family-key, ready for one CSS load and identity-only switching. With --check it writes nothing and reports source drift. --icons-specifier keeps its existing generated-module behavior. It prints one line per built theme and one line naming fonts the themes do not load; --detail full adds the install example and the font recipe, once for a batch.',
17
+ "Compiles defineTheme() sources through the same theme pipeline into scoped CSS, standard ESM, and type declarations. Compiling a theme made by experimental theme editor (themes/<theme>/<theme>.theme.ts) takes that theme's lock and also writes its app copy in src/themes/<theme>/ again; --check fails while that copy is behind or gone. The app copy's own files (src/themes/<theme>/<theme>Theme.ts and the rest) are not compiled: compile the theme itself. With --out somewhere else, compile builds and --check checks only the files --out names: themes/<theme>/ and the app copy are not written or checked, and the result says so (appCopySkipped). The result also says what the copy write did: appCopy names the files of its first write, and appCopyStale says what kept it back. An --out in the theme's own folder, other than its default stylesheet, is refused, as one in the app copy is. Ordinary mode writes one complete set per theme. --family combines one selected extension tree into the three files named by the required --family-key, ready for one CSS load and identity-only switching. With --check it writes nothing and reports source drift. --icons-specifier keeps its existing generated-module behavior. It prints one line per built theme and one line naming fonts the themes do not load; --detail full adds the install example and the font recipe, once for a batch.",
18
18
  fn: 'themeBuild',
19
19
  args: [
20
20
  {
@@ -39,7 +39,7 @@ export const doc = {
39
39
  flag: '-o, --out <path>',
40
40
  param: 'options.out',
41
41
  description:
42
- 'Output CSS file path, relative or absolute; the .js and .d.ts are written beside it (default: <theme name>.css next to the source). A folder, or a path ending in /, writes <theme name>.css into it. The path should end in .css; another name still builds, with a warning. A build never replaces the theme source (ERR_THEME_INVALID). At a path --out names, it replaces its own earlier outputs, and the output of another theme source with a warning that names both sources; any other existing file fails with ERR_FILE_EXISTS and nothing is written. Into a folder the theme editor made (folder <slug>/ holds <slug>.settings.json), a source outside that folder builds there too, with a warning; to keep the editor folder to its own theme, build beside the source, or pass an --out outside it. A build writes only inside the working directory, the defaults beside the source too (ERR_PATH_TRAVERSAL); --check writes nothing, so it compares outputs anywhere and refuses only a relative path that escapes the working directory. Single theme only: refused with more than one file or with --family (ERR_THEME_INVALID)',
42
+ "Output CSS file path, relative or absolute; the .js and .d.ts are written beside it (default: <theme name>.css next to the source). A folder, or a path ending in /, writes <theme name>.css into it. The path should end in .css; another name still builds, with a warning. A build never replaces the theme source (ERR_THEME_INVALID). At a path --out names, it replaces its own earlier outputs, and the output of another theme source with a warning that names both sources; any other existing file fails with ERR_FILE_EXISTS and nothing is written. Into a folder the theme editor made (folder <slug>/ holds <slug>.settings.json), a source outside that folder builds there too, with a warning; to keep the editor folder to its own theme, build beside the source, or pass an --out outside it. A build writes only inside the working directory, the defaults beside the source too (ERR_PATH_TRAVERSAL); --check writes nothing, so it compares outputs anywhere and refuses only a relative path that escapes the working directory. Single theme only: refused with more than one file or with --family (ERR_THEME_INVALID) An --out in an editor theme's app copy folder (src/themes/<theme>/, the folder itself too) is refused (ERR_INVALID_ARGUMENT): the editor writes that folder after every build",
43
43
  },
44
44
  {
45
45
  flag: '--icons-specifier <specifier>',
@@ -89,7 +89,7 @@ export const doc = {
89
89
  },
90
90
  {
91
91
  code: 1,
92
- when: 'a build or validation error (an error envelope), or --check finds stale or missing outputs (the check result, with upToDate false, the stale files and code ERR_THEME_STALE, is still printed: it is a result, not an error). One exception: an editor theme whose settings changed after its build is refused (ERR_THEME_INVALID, an error envelope) before any file is checked, with `editor show <theme>` to build it again. An editor theme run from a folder other than its app root is refused (ERR_INVALID_ARGUMENT) with the `cd` to the root and the same command; `--family` does not take an editor theme (ERR_INVALID_ARGUMENT); its damaged or unbuildable settings are refused (ERR_THEME_INVALID)',
92
+ when: "a build or validation error (an error envelope), or --check finds stale or missing outputs (the check result, with upToDate false, the stale files and code ERR_THEME_STALE, is still printed: it is a result, not an error). One exception: an editor theme whose settings changed after its build is refused (ERR_THEME_INVALID, an error envelope) before any file is checked, with `editor show <theme>` to build it again. An editor theme run from a folder other than its app root is refused (ERR_INVALID_ARGUMENT) with the `cd` to the root and the same command; `--family` does not take an editor theme (ERR_INVALID_ARGUMENT); its damaged or unbuildable settings are refused (ERR_THEME_INVALID). An editor theme's compile also writes its app copy in src/themes/<theme>/ from what it just built (its font stylesheet from the fonts the theme loads now), and --check also compares that copy once the theme's outputs are current: a copy that is kept back, missing a file or not the current build fails the check with the same check result (upToDate false, code ERR_THEME_STALE) and appCopyStale naming why. The copy's own files, its source included, are not compile targets (ERR_INVALID_ARGUMENT, naming the theme to compile). With --out outside the theme's folder neither themes/<theme>/ nor the copy is written or checked, and the result says so in appCopySkipped; an --out in the theme's own folder, other than its default stylesheet, is refused (ERR_INVALID_ARGUMENT)",
93
93
  },
94
94
  ],
95
95
  related: ['experimental theme add', 'experimental theme list'],