@astryxdesign/cli 0.7.16 → 0.7.17-canary.g16fe6a8

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 (380) 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 +28 -2
  29. package/api/docs/_adapter.mjs +249 -10
  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 +132 -1
  79. package/api/theme/build/build.mjs +482 -157
  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 +44 -5
  83. package/api/theme/build/font-warning.mjs +118 -10
  84. package/api/theme/build/icon-imports.mjs +51 -9
  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 +115 -4
  88. package/api/theme-edit/_adapter.mjs +997 -83
  89. package/api/theme-edit/_catalog.d.mts +20 -2
  90. package/api/theme-edit/_catalog.mjs +50 -10
  91. package/api/theme-edit/_check.d.mts +75 -24
  92. package/api/theme-edit/_check.mjs +2672 -422
  93. package/api/theme-edit/_color.d.mts +10 -0
  94. package/api/theme-edit/_color.mjs +54 -1
  95. package/api/theme-edit/_compiler.d.mts +1 -0
  96. package/api/theme-edit/_compiler.mjs +133 -15
  97. package/api/theme-edit/_context.d.mts +14 -3
  98. package/api/theme-edit/_context.mjs +225 -65
  99. package/api/theme-edit/_css.d.mts +14 -0
  100. package/api/theme-edit/_css.mjs +46 -1
  101. package/api/theme-edit/_edit.d.mts +54 -4
  102. package/api/theme-edit/_edit.mjs +2966 -286
  103. package/api/theme-edit/_how-commands.d.mts +72 -1
  104. package/api/theme-edit/_how-commands.mjs +770 -9
  105. package/api/theme-edit/_how-question.d.mts +82 -5
  106. package/api/theme-edit/_how-question.mjs +6983 -701
  107. package/api/theme-edit/_how.d.mts +2 -1
  108. package/api/theme-edit/_how.mjs +237 -41
  109. package/api/theme-edit/_importers.d.mts +38 -0
  110. package/api/theme-edit/_importers.mjs +188 -0
  111. package/api/theme-edit/_marks.d.mts +31 -5
  112. package/api/theme-edit/_marks.mjs +57 -5
  113. package/api/theme-edit/_name-rule.d.mts +11 -0
  114. package/api/theme-edit/_name-rule.mjs +12 -0
  115. package/api/theme-edit/_normal.d.mts +303 -0
  116. package/api/theme-edit/_normal.mjs +1517 -0
  117. package/api/theme-edit/_palette.d.mts +12 -0
  118. package/api/theme-edit/_palette.mjs +37 -4
  119. package/api/theme-edit/_part-words.d.mts +31 -0
  120. package/api/theme-edit/_part-words.mjs +126 -0
  121. package/api/theme-edit/_parts.d.mts +28 -2
  122. package/api/theme-edit/_parts.mjs +267 -31
  123. package/api/theme-edit/_preview-app.d.mts +7 -13
  124. package/api/theme-edit/_preview-app.mjs +814 -406
  125. package/api/theme-edit/_preview.d.mts +116 -16
  126. package/api/theme-edit/_preview.mjs +649 -152
  127. package/api/theme-edit/_project.d.mts +22 -1
  128. package/api/theme-edit/_project.mjs +83 -3
  129. package/api/theme-edit/_settings.d.mts +467 -42
  130. package/api/theme-edit/_settings.mjs +3527 -468
  131. package/api/theme-edit/_tables.d.mts +21 -0
  132. package/api/theme-edit/_tables.mjs +97 -3
  133. package/api/theme-edit/_vet.d.mts +31 -0
  134. package/api/theme-edit/_vet.mjs +114 -8
  135. package/api/theme-edit/theme-edit.type.d.mts +16 -2
  136. package/api/theme-edit/theme-edit.type.mjs +6 -3
  137. package/api/theme-edit/themeEditHow.doc.mjs +1 -1
  138. package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
  139. package/api/theme-edit/themeEditNew.doc.mjs +7 -4
  140. package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
  141. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
  142. package/api/upgrade/run/run.mjs +4 -3
  143. package/assets/codemods/integration-discovery.mjs +2 -1
  144. package/assets/codemods/run-codemod.mjs +87 -7
  145. package/assets/codemods/transforms/next/index.mjs +11 -1
  146. package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
  147. package/assets/component-list.generated.json +1 -0
  148. package/assets/docs/author-a-theme.doc.mjs +1 -0
  149. package/assets/docs/theme.doc.dense.mjs +2 -2
  150. package/assets/docs/theme.doc.mjs +1 -1
  151. package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
  152. package/assets/docs/tree/checks.doc.mjs +1 -1
  153. package/assets/docs/tree/cli-command.doc.mjs +2 -3
  154. package/assets/docs/tree/render-pages.doc.mjs +44 -3
  155. package/assets/docs/tree/share-a-page.doc.mjs +157 -0
  156. package/assets/docs/tree/single-component.doc.mjs +4 -0
  157. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  158. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  159. package/assets/docs/use-a-theme.doc.mjs +1 -1
  160. package/assets/docs.generated.json +2 -2
  161. package/assets/search-catalog.generated.json +2 -0
  162. package/assets/self-audit.generated.json +1 -1
  163. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
  164. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
  165. package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
  166. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
  167. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
  168. package/assets/templates/components.generated.json +1 -1
  169. package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
  170. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +5 -1
  171. package/assets/templates/pages/blank/template.doc.mjs +1 -1
  172. package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
  173. package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
  174. package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
  175. package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
  176. package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
  177. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
  178. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
  179. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
  180. package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
  181. package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
  182. package/assets/templates/pages/documentation/template.doc.mjs +4 -1
  183. package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
  184. package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
  185. package/assets/templates/pages/editor/template.doc.mjs +2 -8
  186. package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
  187. package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
  188. package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
  189. package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
  190. package/assets/templates/pages/ide/page.tsx +24 -2
  191. package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
  192. package/assets/templates/pages/library/template.doc.mjs +4 -1
  193. package/assets/templates/pages/login/template.doc.mjs +2 -1
  194. package/assets/templates/pages/login-card/template.doc.mjs +2 -1
  195. package/assets/templates/pages/login-split/template.doc.mjs +2 -1
  196. package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
  197. package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
  198. package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
  199. package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
  200. package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
  201. package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
  202. package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
  203. package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
  204. package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
  205. package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
  206. package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
  207. package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
  208. package/assets/templates/pages/table-page/template.doc.mjs +5 -4
  209. package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
  210. package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
  211. package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
  212. package/assets/theme.template.ts +6 -0
  213. package/authoring/debug/parse.d.mts +3 -3
  214. package/authoring/doctypes/_schema.d.mts +3 -3
  215. package/authoring/doctypes/command/command.doc.mjs +1 -1
  216. package/authoring/doctypes/component/categories.d.mts +37 -0
  217. package/authoring/doctypes/component/categories.mjs +54 -0
  218. package/authoring/doctypes/template/template.doc.mjs +1 -1
  219. package/authoring/doctypes/template/type.ts +9 -0
  220. package/authoring/example/example.doc.d.mts +12 -0
  221. package/authoring/example/example.doc.mjs +69 -0
  222. package/authoring/example/preview.d.mts +92 -0
  223. package/authoring/example/preview.mjs +994 -0
  224. package/authoring/example/type.ts +102 -0
  225. package/authoring/index.d.mts +1 -0
  226. package/authoring/index.d.ts +12 -0
  227. package/authoring/index.mjs +3 -1
  228. package/clients/cli/bin/astryx.mjs +6 -9
  229. package/clients/cli/build-id.generated.json +1 -1
  230. package/clients/cli/commands/component.doc.mjs +1 -1
  231. package/clients/cli/commands/component.mjs +22 -3
  232. package/clients/cli/commands/docs.doc.mjs +7 -1
  233. package/clients/cli/commands/docs.mjs +3 -1
  234. package/clients/cli/commands/doctor.mjs +32 -14
  235. package/clients/cli/commands/experimental/render.mjs +42 -1
  236. package/clients/cli/commands/experimental/theme.mjs +573 -119
  237. package/clients/cli/commands/experimental-render.doc.mjs +2 -2
  238. package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
  239. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
  240. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
  241. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  242. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
  243. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  244. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  245. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  246. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
  247. package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
  248. package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
  249. package/clients/cli/commands/search.doc.mjs +2 -1
  250. package/clients/cli/commands/search.mjs +6 -1
  251. package/clients/cli/commands/template.mjs +4 -2
  252. package/clients/cli/commands/theme-build.doc.mjs +5 -1
  253. package/clients/cli/commands/theme.doc.mjs +1 -1
  254. package/clients/cli/commands/theme.mjs +718 -438
  255. package/clients/cli/commands/upgrade.mjs +42 -7
  256. package/clients/cli/index.mjs +1 -1
  257. package/clients/cli/lib/cli-error.mjs +2 -1
  258. package/clients/cli/lib/component-format.mjs +205 -98
  259. package/clients/cli/lib/hook-format.mjs +9 -19
  260. package/clients/cli/lib/json-shim.mjs +132 -24
  261. package/clients/cli/lib/manifest.mjs +3 -2
  262. package/clients/cli/manifest.generated.json +1 -1
  263. package/foundation/agent-docs/agent-docs.mjs +1 -1
  264. package/foundation/config/theme-state.d.mts +13 -1
  265. package/foundation/config/theme-state.mjs +47 -7
  266. package/foundation/discovery/authoring-self-docs.mjs +1 -0
  267. package/foundation/discovery/component-discovery.d.mts +11 -0
  268. package/foundation/discovery/component-discovery.mjs +56 -8
  269. package/foundation/discovery/component-replacement.mjs +130 -1
  270. package/foundation/discovery/copied-passages.mjs +2 -1
  271. package/foundation/discovery/core-component-docs.d.mts +29 -0
  272. package/foundation/discovery/core-component-docs.mjs +83 -0
  273. package/foundation/discovery/doc-types.mjs +4 -3
  274. package/foundation/discovery/entry-name-files.d.mts +43 -0
  275. package/foundation/discovery/entry-name-files.mjs +264 -0
  276. package/foundation/discovery/hook-discovery.d.mts +8 -2
  277. package/foundation/discovery/hook-discovery.mjs +22 -8
  278. package/foundation/discovery/icon-definition-discovery.mjs +2 -1
  279. package/foundation/discovery/icon-set-checks.mjs +2 -1
  280. package/foundation/discovery/icon-set-discovery.mjs +2 -1
  281. package/foundation/discovery/integration-doc-files.mjs +2 -1
  282. package/foundation/discovery/package-exports.d.mts +10 -0
  283. package/foundation/discovery/package-exports.mjs +56 -3
  284. package/foundation/discovery/prop-drift.mjs +9 -9
  285. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  286. package/foundation/discovery/runner-allowlist.mjs +2 -0
  287. package/foundation/discovery/stored-component-list.d.mts +43 -0
  288. package/foundation/discovery/stored-component-list.mjs +90 -0
  289. package/foundation/discovery/stored-search-catalog.d.mts +115 -0
  290. package/foundation/discovery/stored-search-catalog.mjs +297 -0
  291. package/foundation/discovery/stored-self-audit.d.mts +26 -10
  292. package/foundation/discovery/stored-self-audit.mjs +38 -18
  293. package/foundation/discovery/template-adapter.d.mts +53 -1
  294. package/foundation/discovery/template-adapter.mjs +176 -12
  295. package/foundation/discovery/template-icons.mjs +2 -1
  296. package/foundation/discovery/theme-discovery.mjs +31 -4
  297. package/foundation/discovery/theme-imports.d.mts +14 -0
  298. package/foundation/discovery/theme-imports.mjs +43 -1
  299. package/foundation/discovery/theming-targets.d.mts +6 -5
  300. package/foundation/discovery/theming-targets.mjs +31 -47
  301. package/foundation/doc-compiler/import.mjs +7 -1
  302. package/foundation/doc-compiler/inputs.mjs +3 -2
  303. package/foundation/doc-compiler/parse-readable.mjs +4 -1
  304. package/foundation/doc-compiler/stored-docs.d.mts +22 -0
  305. package/foundation/doc-compiler/stored-docs.mjs +49 -0
  306. package/foundation/env/semver.mjs +3 -1
  307. package/foundation/fonts/font-stylesheet.d.mts +38 -0
  308. package/foundation/fonts/font-stylesheet.mjs +141 -0
  309. package/foundation/fs/cache-eviction.d.mts +21 -0
  310. package/foundation/fs/cache-eviction.mjs +73 -0
  311. package/foundation/fs/exact-codec.d.mts +12 -2
  312. package/foundation/fs/exact-codec.mjs +23 -6
  313. package/foundation/fs/file-protection.mjs +4 -3
  314. package/foundation/fs/gather-cache.d.mts +62 -4
  315. package/foundation/fs/gather-cache.mjs +517 -91
  316. package/foundation/fs/jiti-cache.d.mts +19 -1
  317. package/foundation/fs/jiti-cache.mjs +130 -6
  318. package/foundation/fs/kept-tree.d.mts +60 -0
  319. package/foundation/fs/kept-tree.mjs +154 -0
  320. package/foundation/fs/listing-cache.d.mts +7 -0
  321. package/foundation/fs/listing-cache.mjs +10 -0
  322. package/foundation/fs/module-loader.d.mts +24 -2
  323. package/foundation/fs/module-loader.mjs +94 -21
  324. package/foundation/fs/paths.d.mts +18 -0
  325. package/foundation/fs/paths.mjs +15 -2
  326. package/foundation/fs/read-record.d.mts +9 -0
  327. package/foundation/fs/read-record.mjs +19 -11
  328. package/foundation/fs/stop-cleanup.d.mts +12 -0
  329. package/foundation/fs/stop-cleanup.mjs +66 -0
  330. package/foundation/identity/provider-identity.d.mts +6 -0
  331. package/foundation/identity/provider-identity.mjs +10 -1
  332. package/foundation/integrations/contribution-inventory.mjs +4 -3
  333. package/foundation/integrations/example-code.d.mts +63 -0
  334. package/foundation/integrations/example-code.mjs +416 -0
  335. package/foundation/integrations/public-imports.d.mts +9 -0
  336. package/foundation/integrations/public-imports.mjs +3 -2
  337. package/foundation/integrations/validate-contributions.mjs +17 -45
  338. package/foundation/render/embedded-files.d.mts +6 -0
  339. package/foundation/render/embedded-files.mjs +25 -5
  340. package/foundation/render/embedded-imports.d.mts +39 -7
  341. package/foundation/render/embedded-imports.mjs +66 -27
  342. package/foundation/render/file-header.d.mts +66 -0
  343. package/foundation/render/file-header.mjs +118 -0
  344. package/foundation/render/host-answer.d.mts +18 -0
  345. package/foundation/render/host-answer.mjs +46 -0
  346. package/foundation/render/host-exit.d.mts +1 -0
  347. package/foundation/render/host-exit.mjs +6 -1
  348. package/foundation/render/html-reader.d.mts +55 -2
  349. package/foundation/render/html-reader.mjs +145 -26
  350. package/foundation/render/markup-edits.d.mts +57 -0
  351. package/foundation/render/markup-edits.mjs +182 -0
  352. package/foundation/render/page-host.mjs +29 -12
  353. package/foundation/render/page-worker.mjs +121 -13
  354. package/foundation/render/picture-chrome.d.mts +4 -0
  355. package/foundation/render/picture-chrome.mjs +185 -0
  356. package/foundation/render/picture-playwright.d.mts +4 -0
  357. package/foundation/render/picture-playwright.mjs +34 -0
  358. package/foundation/render/rebuild.mjs +2 -1
  359. package/foundation/render/render-page.d.mts +35 -3
  360. package/foundation/render/render-page.mjs +641 -96
  361. package/foundation/render/source-block.d.mts +85 -6
  362. package/foundation/render/source-block.mjs +211 -20
  363. package/foundation/render/ts-paths.d.mts +69 -6
  364. package/foundation/render/ts-paths.mjs +326 -40
  365. package/foundation/response/error-codes.d.mts +3 -1
  366. package/foundation/response/error-codes.d.ts +1 -0
  367. package/foundation/response/error-codes.doc.mjs +12 -1
  368. package/foundation/response/error-codes.mjs +11 -1
  369. package/foundation/response/response-types.doc.mjs +2 -2
  370. package/foundation/text/compare-text.d.mts +14 -0
  371. package/foundation/text/compare-text.mjs +68 -0
  372. package/foundation/text/css-escape.d.mts +18 -0
  373. package/foundation/text/css-escape.mjs +35 -0
  374. package/foundation/text/string-utils.d.mts +3 -2
  375. package/foundation/text/string-utils.mjs +18 -4
  376. package/foundation/text/suggest-order.d.mts +9 -0
  377. package/foundation/text/suggest-order.mjs +15 -1
  378. package/foundation/xle/expand.mjs +2 -1
  379. package/host/index.mjs +8 -6
  380. package/package.json +7 -6
@@ -63,7 +63,7 @@ import * as path from 'node:path';
63
63
  import {createRequire, isBuiltin} from 'node:module';
64
64
  import {fileURLToPath, pathToFileURL} from 'node:url';
65
65
  import {babelParse as parse} from '../../../foundation/runtime/lazy-dependencies.mjs';
66
- import {createJiti} from 'jiti';
66
+ import {jitiCacheOptions} from '../../../foundation/fs/jiti-cache.mjs';
67
67
  import {
68
68
  formatCliCommand,
69
69
  getCliInvocation,
@@ -90,8 +90,12 @@ import {validatePrivateVars} from '../../../foundation/config/theme-private-vars
90
90
  import {AstryxError} from '../../error.mjs';
91
91
  import {applyWrites} from '../../integration/add-helpers.mjs';
92
92
  import {logger} from '../../logger.mjs';
93
- import {loadComponentDoc} from '../../../foundation/discovery/component-loader.mjs';
93
+ import {coreComponentDocs} from '../../../foundation/discovery/core-component-docs.mjs';
94
94
  import {THEME_SOURCE_EXTENSIONS} from '../../../foundation/discovery/theme-module-extensions.mjs';
95
+ import {
96
+ createJiti,
97
+ withEmptyStylesheets,
98
+ } from '../../../foundation/fs/module-loader.mjs';
95
99
  import {
96
100
  collectThemingTargets,
97
101
  targetsByKey,
@@ -108,6 +112,7 @@ import {
108
112
  } from '../../../foundation/discovery/template-needs.mjs';
109
113
  import {generateFamilyCSS, resolveThemeFamily} from './family.mjs';
110
114
  import {resolveIconImports} from './icon-imports.mjs';
115
+ import {generatedMark} from '../../theme-edit/_marks.mjs';
111
116
 
112
117
  // Import shared theme processing from core. `astryx theme build` MUST produce the
113
118
  // exact same CSS as the `<Theme>` runtime, so it has exactly one generation
@@ -324,7 +329,9 @@ function importTarget(dir, subpath) {
324
329
  /** @param {string} file @returns {string} its real path, or itself */
325
330
  function realOrSelf(file) {
326
331
  try {
327
- return fs.realpathSync(file);
332
+ // The native form spells a path as the disk does (its own case on a
333
+ // case-insensitive disk), so two spellings of one file compare equal.
334
+ return fs.realpathSync.native(file);
328
335
  } catch {
329
336
  return file;
330
337
  }
@@ -333,10 +340,12 @@ function realOrSelf(file) {
333
340
  /**
334
341
  * `target` spelled through real directories: the deepest ancestor that exists
335
342
  * is resolved through its symlinks, and the missing rest is appended as given.
343
+ * The build confines its outputs by it, and the theme editor's compile guard
344
+ * reads paths through it too, so both read a path the same way.
336
345
  * @param {string} target absolute path
337
346
  * @returns {string}
338
347
  */
339
- function realLocation(target) {
348
+ export function realLocation(target) {
340
349
  /** @type {string[]} */
341
350
  const missing = [];
342
351
  let existing = target;
@@ -818,7 +827,7 @@ function confineOutputs(writes, root, remedy) {
818
827
  }
819
828
 
820
829
  /** @param {string} dest absolute output path @param {string} root @returns {boolean} whether a build at `root` refuses to write `dest` */
821
- function refusedOutput(dest, root) {
830
+ export function refusedOutput(dest, root) {
822
831
  try {
823
832
  confineOutput(dest, root, '');
824
833
  return false;
@@ -925,6 +934,82 @@ function isDirectorySync(file) {
925
934
  }
926
935
  }
927
936
 
937
+ /**
938
+ * The marks a file's leading comment carries (see `generatedMark`): a theme
939
+ * build's output, or a file the theme editor writes, with the command it
940
+ * names. The one reader build and doctor share.
941
+ * @param {string} source the start of the file
942
+ * @param {string} [file] its path, for a mark that names no exact command
943
+ */
944
+ export function fileMark(source, file) {
945
+ return generatedMark(source, GENERATED_MARKER, file);
946
+ }
947
+
948
+ /**
949
+ * The command a file's leading comment says writes it, when another CLI
950
+ * command generates it (the theme editor's settings module or app copy):
951
+ * the exact command its mark names. Null for a theme build's own output and
952
+ * a file without a mark, such as a theme source of one's own.
953
+ * @param {string} file
954
+ * @returns {string | null}
955
+ */
956
+ export function generatedFileCommand(file) {
957
+ const mark = fileMark(fileHead(file), file);
958
+ return mark?.kind === 'editor' ? mark.command : null;
959
+ }
960
+
961
+ /**
962
+ * The command that writes a missing `file`: a file beside it carries
963
+ * another command's mark, and a file there names `file` (a build output's
964
+ * header names its source), so it is one that command writes. Null for any
965
+ * other name, such as a typo.
966
+ * @param {string} file
967
+ * @returns {string | null}
968
+ */
969
+ function missingGeneratedCommand(file) {
970
+ const dir = path.dirname(file);
971
+ const base = path.basename(file);
972
+ let names;
973
+ try {
974
+ names = fs.readdirSync(dir).sort();
975
+ } catch {
976
+ return null;
977
+ }
978
+ /** @type {string | null} */
979
+ let by = null;
980
+ let named = false;
981
+ for (const n of names) {
982
+ const f = path.join(dir, n);
983
+ try {
984
+ if (!fs.statSync(f).isFile()) continue;
985
+ } catch {
986
+ continue;
987
+ }
988
+ by ??= generatedFileCommand(f);
989
+ if (!named)
990
+ try {
991
+ named = fs.readFileSync(f, 'utf8').slice(0, 4000).includes(base);
992
+ } catch {
993
+ // A file that does not read names nothing.
994
+ }
995
+ if (by && named) return by;
996
+ }
997
+ return null;
998
+ }
999
+
1000
+ /**
1001
+ * The command that writes `file`: from its own mark, or, when it is
1002
+ * missing, from the files beside it (see `missingGeneratedCommand`); null
1003
+ * otherwise.
1004
+ * @param {string} file
1005
+ * @returns {string | null}
1006
+ */
1007
+ export function generatedSourceCommand(file) {
1008
+ return fs.existsSync(file)
1009
+ ? generatedFileCommand(file)
1010
+ : missingGeneratedCommand(file);
1011
+ }
1012
+
928
1013
  /** @param {string} file @returns {string} the start of a file, or '' when it cannot be read */
929
1014
  function fileHead(file) {
930
1015
  try {
@@ -1121,7 +1206,16 @@ function assertThemeSourceFile(filePath, cwd, mode = {}) {
1121
1206
  * output must stay inside, for a scratch build; `commandWords` names the
1122
1207
  * command in the rebuild hint; `prepareFamily`, `familyLoader`, and
1123
1208
  * `familyInterception` make the build a family member's plan.
1124
- * @typedef {{prepareFamily?: boolean, familyLoader?: any, familyInterception?: any, writeRoot?: string, claimedOutputs?: Map<string, string>, deferredWrites?: Array<Array<{dest: string, content: string}>>, commandWords?: {group: string, build: string}}} ThemeBuildHandOff
1209
+ * `colorModes` is the one color mode a calling command knows the theme has
1210
+ * (the theme editor, from its settings), written into the built module.
1211
+ * @typedef {{prepareFamily?: boolean, familyLoader?: any, familyInterception?: any, writeRoot?: string, claimedOutputs?: Map<string, string>, deferredWrites?: Array<Array<{dest: string, content: string}>>, commandWords?: {group: string, build: string}, colorModes?: ['light'] | ['dark'] | null, fontHelp?: FontHelp | null, loadedFonts?: ((family: string) => boolean) | null, install?: string | null}} ThemeBuildHandOff
1212
+ */
1213
+
1214
+ /**
1215
+ * How a caller that loads a theme's fonts itself (the editor's app copy)
1216
+ * says to load a family: the notice per family and the recipe in place of
1217
+ * the generic one.
1218
+ * @typedef {{notice: (family: string) => string, recipe: (families: string[]) => string}} FontHelp
1125
1219
  */
1126
1220
 
1127
1221
  /**
@@ -1157,6 +1251,45 @@ export function setEditorFolderListener(listener) {
1157
1251
  * @typedef {{glob?: boolean, family?: boolean, familyKey?: string}} SuggestionShape
1158
1252
  */
1159
1253
 
1254
+ /**
1255
+ * The refusal a build gives the file it is given before it reads it, or
1256
+ * null: a file that is not there, and a folder. The build throws it, and a
1257
+ * suggested build is checked by it before it is offered.
1258
+ * @param {string} file as typed, from cwd
1259
+ * @param {BuildMode} options
1260
+ * @param {string} cwd
1261
+ * @returns {AstryxError | null}
1262
+ */
1263
+ export function buildInputProblem(file, options, cwd) {
1264
+ const filePath = path.resolve(cwd, file);
1265
+ if (!fs.existsSync(filePath))
1266
+ return new AstryxError(
1267
+ `File not found: ${filePath}`,
1268
+ themeSourceGuesses(file, cwd).map(guess => ({
1269
+ name: buildSuggestion(guess, options, cwd),
1270
+ reason: 'a theme source that exists',
1271
+ })),
1272
+ ERROR_CODES.ERR_FILE_NOT_FOUND,
1273
+ );
1274
+ if (fs.statSync(filePath).isDirectory())
1275
+ return new AstryxError(
1276
+ `${path.relative(cwd, filePath) || '.'} is a folder. Pass the theme file inside it.`,
1277
+ themeFilesIn(filePath).map(name => ({
1278
+ name: buildSuggestion(
1279
+ path
1280
+ .relative(cwd, path.join(filePath, name))
1281
+ .split(path.sep)
1282
+ .join('/'),
1283
+ options,
1284
+ cwd,
1285
+ ),
1286
+ reason: 'a theme source in that folder',
1287
+ })),
1288
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
1289
+ );
1290
+ return null;
1291
+ }
1292
+
1160
1293
  /**
1161
1294
  * The `theme build` command for `source` with the caller's mode flags, so a
1162
1295
  * suggestion never turns a check into a write or moves the outputs.
@@ -1212,11 +1345,12 @@ export function buildSuggestion(source, mode, cwd, words, shape = {}) {
1212
1345
  * @param {Array<{dest: string}>} writes
1213
1346
  * @param {string} filePath the theme source
1214
1347
  * @param {string} cwd
1215
- * @param {{claimed?: Map<string, string>, rerun?: (out: string | null) => string, refuseUnmarked?: boolean, elsewhere?: string, onEditorFolder?: (warning: string) => void}} [options]
1348
+ * @param {{claimed?: Map<string, string>, rerun?: (out: string | null) => string, refuseUnmarked?: boolean, elsewhere?: string, onEditorFolder?: (warning: string) => void, onWarning?: (message: string) => void}} [options]
1216
1349
  * `claimed`: outputs written earlier in this run, by the source that wrote
1217
1350
  * them; `rerun`: this build's command with another --out, or without one;
1218
1351
  * `elsewhere`: the option that moves the outputs; `onEditorFolder`: takes
1219
- * the editor-folder warning instead of the logger (a watcher prints it once)
1352
+ * the editor-folder warning instead of the logger (a watcher prints it
1353
+ * once); `onWarning`: each warning's message too, for the result
1220
1354
  */
1221
1355
  function assertOutputsReplaceable(
1222
1356
  writes,
@@ -1228,6 +1362,7 @@ function assertOutputsReplaceable(
1228
1362
  refuseUnmarked = false,
1229
1363
  elsewhere = '--out',
1230
1364
  onEditorFolder,
1365
+ onWarning,
1231
1366
  } = {},
1232
1367
  ) {
1233
1368
  const rel = (/** @type {string} */ file) => path.relative(cwd, file);
@@ -1309,7 +1444,7 @@ function assertOutputsReplaceable(
1309
1444
  // It is printed after every output passes, so it names a replacement
1310
1445
  // that happens.
1311
1446
  if (warnedOtherSource) continue;
1312
- warnedOtherSource = `Warning: ${rel(write.dest)} was built from ${otherSource}; this build of ${rel(filePath)} replaces it.`;
1447
+ warnedOtherSource = `${rel(write.dest)} was built from ${otherSource}; this build of ${rel(filePath)} replaces it.`;
1313
1448
  } else if (otherSource) {
1314
1449
  throw new AstryxError(
1315
1450
  `${rel(write.dest)} is the build output of another theme source, ${otherSource}, so this build does not replace it. Pick another ${elsewhere}.`,
@@ -1346,12 +1481,16 @@ function assertOutputsReplaceable(
1346
1481
  }
1347
1482
  // Warned only once nothing refuses the build, so it names a write that
1348
1483
  // happens.
1349
- if (warnedOtherSource) logger.warn(warnedOtherSource);
1484
+ if (warnedOtherSource) {
1485
+ logger.warn(`Warning: ${warnedOtherSource}`);
1486
+ onWarning?.(warnedOtherSource);
1487
+ }
1350
1488
  if (editorFolder) {
1351
1489
  const dir = path.dirname(writes[0].dest);
1352
- const warning = `Warning: ${rel(dir) || '.'} is a folder the theme editor made, and ${rel(filePath)} is outside it; the build writes there anyway. Build beside the source, or pick another ${elsewhere}, to keep the editor's folder to its own theme.`;
1353
- if (onEditorFolder) onEditorFolder(warning);
1354
- else logger.warn(warning);
1490
+ const message = `${rel(dir) || '.'} is a folder the theme editor made, and ${rel(filePath)} is outside it; the build writes there anyway. Build beside the source, or pick another ${elsewhere}, to keep the editor's folder to its own theme.`;
1491
+ if (onEditorFolder) onEditorFolder(`Warning: ${message}`);
1492
+ else logger.warn(`Warning: ${message}`);
1493
+ onWarning?.(message);
1355
1494
  }
1356
1495
  }
1357
1496
 
@@ -1443,7 +1582,31 @@ function writeBuildOutputs(writes) {
1443
1582
  })),
1444
1583
  );
1445
1584
  } catch (error) {
1446
- const message = `Failed to write theme outputs: ${/** @type {Error} */ (error).message}`;
1585
+ const e = /** @type {NodeJS.ErrnoException} */ (error);
1586
+ // A place the outputs cannot be written: name it and its fix (the
1587
+ // writes go through temporary files beside each output, whose names
1588
+ // help nobody).
1589
+ if (e.code === 'EACCES' || e.code === 'EPERM' || e.code === 'EROFS') {
1590
+ const failed = e.path ? path.resolve(e.path) : null;
1591
+ const output = writes.find(w => path.resolve(w.dest) === failed);
1592
+ const place = output
1593
+ ? output.dest
1594
+ : failed
1595
+ ? path.dirname(failed)
1596
+ : path.dirname(writes[0].dest);
1597
+ const shownPlace = path.relative(process.cwd(), place) || place;
1598
+ throw new AstryxError(
1599
+ `Could not write the theme's outputs: ${shownPlace} is not writable (${e.code}). Give yourself write permission on it (chmod u+w ${shellWord(shownPlace)}), then build again. Nothing was changed.`,
1600
+ [
1601
+ {
1602
+ name: `ls -ld ${shellWord(shownPlace)}`,
1603
+ reason: 'see its permissions',
1604
+ },
1605
+ ],
1606
+ ERROR_CODES.ERR_WRITE_FAILED,
1607
+ );
1608
+ }
1609
+ const message = `Failed to write theme outputs: ${e.message}`;
1447
1610
  throw new AstryxError(message, undefined, ERROR_CODES.ERR_WRITE_FAILED);
1448
1611
  }
1449
1612
  }
@@ -1534,27 +1697,10 @@ async function loadKnownValuesIndex() {
1534
1697
  const coreSrc = coreRoot ? path.join(coreRoot, 'src') : null;
1535
1698
  if (!coreSrc || !fs.existsSync(coreSrc)) return {};
1536
1699
 
1537
- /** @type {any[]} */
1538
- const docs = [];
1539
- /** @param {string} dir */
1540
- async function scan(dir) {
1541
- for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
1542
- const full = path.join(dir, entry.name);
1543
- if (entry.isDirectory()) {
1544
- if (entry.name !== 'node_modules' && entry.name !== '__tests__') {
1545
- await scan(full);
1546
- }
1547
- continue;
1548
- }
1549
- if (!entry.name.endsWith('.doc.mjs')) continue;
1550
- try {
1551
- docs.push(await loadComponentDoc(full));
1552
- } catch {
1553
- // One malformed or optional doc must not erase validation for the rest.
1554
- }
1555
- }
1556
- }
1557
- await scan(coreSrc);
1700
+ // One malformed or optional doc must not erase validation for the rest.
1701
+ const docs = (await coreComponentDocs(coreSrc)).flatMap(read =>
1702
+ 'error' in read ? [] : [read.doc],
1703
+ );
1558
1704
 
1559
1705
  /** @param {string} value */
1560
1706
  const targetName = value =>
@@ -1778,55 +1924,34 @@ async function resolveAugmentationTargetCandidates(componentName) {
1778
1924
  matches.push({moduleName, interfacePrefix});
1779
1925
  }
1780
1926
 
1781
- /** @param {string} dir */
1782
- async function scan(dir) {
1783
- const entries = fs.readdirSync(dir, {withFileTypes: true});
1784
- for (const entry of entries) {
1785
- const full = path.join(dir, entry.name);
1786
- if (entry.isDirectory()) {
1787
- if (entry.name === 'node_modules' || entry.name === '__tests__')
1788
- continue;
1789
- await scan(full);
1790
- continue;
1791
- }
1792
- if (!entry.name.endsWith('.doc.mjs')) continue;
1793
-
1794
- /** @type {any} */
1795
- let doc;
1796
- try {
1797
- doc = await loadComponentDoc(full);
1798
- } catch {
1799
- continue;
1800
- }
1801
-
1802
- const matchesTarget = (doc?.theming?.targets || []).some(
1803
- (/** @type {any} */ target) =>
1804
- typeof target?.className === 'string' &&
1805
- target.className.replace(/^astryx-/, '') === componentName,
1806
- );
1807
- if (!matchesTarget) continue;
1808
-
1809
- const moduleName =
1810
- typeof doc?.name === 'string' && doc.name
1811
- ? doc.name
1812
- : path.basename(path.dirname(full));
1813
-
1814
- // Try the exact rendered token first for documented subtargets such as
1815
- // avatar-status-dot → AvatarStatusDotVariantMap, then the owning public
1816
- // component name (for example, ProgressBar for progress-bar-fill).
1817
- addCandidate(moduleName, toPascalCase(componentName));
1818
- addCandidate(moduleName, moduleName);
1819
- if (Array.isArray(doc?.components)) {
1820
- for (const comp of doc.components) {
1821
- if (typeof comp?.name === 'string') {
1822
- addCandidate(moduleName, comp.name);
1823
- }
1927
+ for (const read of await coreComponentDocs(coreSrc)) {
1928
+ if ('error' in read) continue;
1929
+ const {file, doc} = read;
1930
+ const matchesTarget = (doc?.theming?.targets || []).some(
1931
+ (/** @type {any} */ target) =>
1932
+ typeof target?.className === 'string' &&
1933
+ target.className.replace(/^astryx-/, '') === componentName,
1934
+ );
1935
+ if (!matchesTarget) continue;
1936
+
1937
+ const moduleName =
1938
+ typeof doc?.name === 'string' && doc.name
1939
+ ? doc.name
1940
+ : path.basename(path.dirname(file));
1941
+
1942
+ // Try the exact rendered token first for documented subtargets such as
1943
+ // avatar-status-dot → AvatarStatusDotVariantMap, then the owning public
1944
+ // component name (for example, ProgressBar for progress-bar-fill).
1945
+ addCandidate(moduleName, toPascalCase(componentName));
1946
+ addCandidate(moduleName, moduleName);
1947
+ if (Array.isArray(doc?.components)) {
1948
+ for (const comp of doc.components) {
1949
+ if (typeof comp?.name === 'string') {
1950
+ addCandidate(moduleName, comp.name);
1824
1951
  }
1825
1952
  }
1826
1953
  }
1827
1954
  }
1828
-
1829
- await scan(coreSrc);
1830
1955
  // A target documented by a parent component may also have its own public
1831
1956
  // subpath and augmentation interface (Heading is documented under Text but
1832
1957
  // owns @astryxdesign/core/Heading). Keep the direct-name candidate after
@@ -2630,19 +2755,23 @@ function isSyncLoaderLimitation(error) {
2630
2755
  * source export and old-Core adaptation checks keep treating that path as
2631
2756
  * degraded/fail-closed.
2632
2757
  *
2758
+ * On Node 22.15 and later, on every path, a stylesheet that a module in the
2759
+ * theme's graph imports loads as an empty module (`withEmptyStylesheets`): a
2760
+ * base theme's module can import its own stylesheet for the app's bundler.
2761
+ *
2633
2762
  * @param {string} filePath
2634
2763
  * @param {import('./core-interception.mjs').CoreInterception} [interception]
2635
- * @returns {Promise<{theme: any, exportName: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
2764
+ * @returns {Promise<{theme: any, exportName: string, degraded: {topLevelAwait: boolean, commonJs: boolean}, colorModes: ["light"] | ["dark"] | null}>}
2636
2765
  */
2637
2766
  // prettier-ignore
2638
- async function importThemeModule(filePath, interception, /** @type {any} */ loader = undefined) {
2767
+ async function importThemeModule(filePath, interception, /** @type {any} */ loader = undefined, /** @type {string | undefined} */ pick = undefined) {
2639
2768
  const jiti =
2640
2769
  loader ??
2641
2770
  createJiti(import.meta.url, {
2642
2771
  moduleCache: false,
2643
- // No transpile cache: it is written to the system temp folder, named
2644
- // for the theme, and never removed, so every edit added files there.
2645
- fsCache: false,
2772
+ // The per-user transpile cache: an edited theme is transpiled again,
2773
+ // and the folder stays within its size limit.
2774
+ ...jitiCacheOptions(),
2646
2775
  jsx: true,
2647
2776
  extensions: THEME_MODULE_EXTENSIONS,
2648
2777
  ...(interception ? {virtualModules: interception.modules} : {}),
@@ -2659,7 +2788,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
2659
2788
  const commonJsPatch = interception.patchCommonJs(filePath);
2660
2789
  try {
2661
2790
  try {
2662
- mod = jiti(filePath);
2791
+ mod = await withEmptyStylesheets(async () => jiti(filePath));
2663
2792
  } catch (error) {
2664
2793
  // Only a sync-loader limitation may fall back. Anything else is the
2665
2794
  // theme's own failure and belongs to the caller unchanged.
@@ -2668,14 +2797,16 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
2668
2797
  // Force asynchronous transformation instead of native import: this
2669
2798
  // keeps virtual Core interception active even when the module uses
2670
2799
  // top-level await.
2671
- mod = await jiti.evalModule(fs.readFileSync(filePath, 'utf8'), {
2672
- id: filePath,
2673
- filename: filePath,
2674
- ext: path.extname(filePath),
2675
- cache: jiti.cache,
2676
- async: true,
2677
- forceTranspile: true,
2678
- });
2800
+ mod = await withEmptyStylesheets(() =>
2801
+ jiti.evalModule(fs.readFileSync(filePath, 'utf8'), {
2802
+ id: filePath,
2803
+ filename: filePath,
2804
+ ext: path.extname(filePath),
2805
+ cache: jiti.cache,
2806
+ async: true,
2807
+ forceTranspile: true,
2808
+ }),
2809
+ );
2679
2810
  }
2680
2811
  } finally {
2681
2812
  // Read after the load: the root is wrapped when the load requires it.
@@ -2683,7 +2814,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
2683
2814
  commonJsPatch.undo();
2684
2815
  }
2685
2816
  } else {
2686
- mod = await jiti.import(filePath);
2817
+ mod = await withEmptyStylesheets(() => jiti.import(filePath));
2687
2818
  }
2688
2819
 
2689
2820
  // Both loads hand back the module. The theme is read from the module's own
@@ -2692,15 +2823,28 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
2692
2823
  // `default` with the module), so the module can pass for the theme while
2693
2824
  // its own keys hide the theme's fields.
2694
2825
  const isModule = mod != null && typeof mod === 'object';
2826
+ // A theme with one color mode says so with a `colorModes` export beside
2827
+ // the theme (`['light']` or `['dark']`); the build carries it into the
2828
+ // built module.
2829
+ const colorModes = oneColorMode(
2830
+ isModule && Object.hasOwn(mod, 'colorModes') ? mod.colorModes : undefined,
2831
+ );
2695
2832
  const hasDefault = isModule && Object.hasOwn(mod, 'default');
2696
2833
  const defaultExport = hasDefault ? mod.default : undefined;
2834
+ // A caller that already knows which export a build reads (from a load
2835
+ // as the build loads it) reads that one.
2836
+ if (pick !== undefined && isModule && Object.hasOwn(mod, pick)) {
2837
+ if (isThemeObject(mod[pick]))
2838
+ return {theme: mod[pick], exportName: pick, degraded, colorModes};
2839
+ }
2697
2840
  if (isThemeObject(defaultExport)) {
2698
- return {theme: defaultExport, exportName: 'default', degraded};
2841
+ return {theme: defaultExport, exportName: 'default', degraded, colorModes};
2699
2842
  }
2700
2843
  if (isModule) {
2701
2844
  for (const [exportName, value] of Object.entries(mod)) {
2702
2845
  if (exportName === 'default' || exportName === 'module.exports') continue;
2703
- if (isThemeObject(value)) return {theme: value, exportName, degraded};
2846
+ if (isThemeObject(value))
2847
+ return {theme: value, exportName, degraded, colorModes};
2704
2848
  }
2705
2849
  }
2706
2850
  // The loader's interop answers a null default with the module itself, so
@@ -2722,7 +2866,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
2722
2866
  // be all it defines), or no name: the build's validation says what it
2723
2867
  // lacks.
2724
2868
  if (isPlainObject(defaultExport)) {
2725
- return {theme: defaultExport, exportName: 'default', degraded};
2869
+ return {theme: defaultExport, exportName: 'default', degraded, colorModes};
2726
2870
  }
2727
2871
  // A CommonJS module whose exports are the theme (`module.exports =
2728
2872
  // theme`) has no default of its own: interop answers `default` with
@@ -2731,7 +2875,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
2731
2875
  if (isModule && !hasDefault) {
2732
2876
  const exportsObject = mod.default ?? mod;
2733
2877
  if (isThemeObject(exportsObject)) {
2734
- return {theme: exportsObject, exportName: 'default', degraded};
2878
+ return {theme: exportsObject, exportName: 'default', degraded, colorModes};
2735
2879
  }
2736
2880
  }
2737
2881
 
@@ -2800,12 +2944,12 @@ function isThemeObject(value) {
2800
2944
  *
2801
2945
  * @param {string} filePath
2802
2946
  * @param {import('./core-interception.mjs').CoreInterception} [interception]
2803
- * @returns {Promise<{theme: any, exportName?: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
2947
+ * @returns {Promise<{theme: any, exportName?: string, degraded: {topLevelAwait: boolean, commonJs: boolean}, colorModes?: ['light'] | ['dark'] | null}>}
2804
2948
  */
2805
2949
  // prettier-ignore
2806
- async function extractThemeDefinition(filePath, interception, /** @type {any} */ loader = undefined) {
2950
+ async function extractThemeDefinition(filePath, interception, /** @type {any} */ loader = undefined, /** @type {string | undefined} */ pick = undefined) {
2807
2951
  try {
2808
- return await importThemeModule(filePath, interception, loader);
2952
+ return await importThemeModule(filePath, interception, loader, pick);
2809
2953
  } catch (jitiError) {
2810
2954
  const je = /** @type {Error} */ (jitiError);
2811
2955
  throw new Error(
@@ -2815,6 +2959,143 @@ async function extractThemeDefinition(filePath, interception, /** @type {any} */
2815
2959
  }
2816
2960
  }
2817
2961
 
2962
+ /**
2963
+ * The Core interception a standalone build loads a theme module with: none
2964
+ * when the selected Core generates adaptations itself and the theme's folder
2965
+ * resolves a Core of its own; else imports of Core are handed the selected
2966
+ * Core.
2967
+ * @param {string} filePath
2968
+ */
2969
+ function standaloneInterception(filePath) {
2970
+ return _generateAdaptationCSS && themeFolderResolvesCore(filePath)
2971
+ ? undefined
2972
+ : interceptCore(_coreThemeModule, _coreRootModule);
2973
+ }
2974
+
2975
+ /**
2976
+ * Load a theme module as a standalone build of it loads it (the Core the
2977
+ * build selects, the same loader and interception) and name the export the
2978
+ * build reads. Callers that must agree with the build on which theme a
2979
+ * module defines read it here, never from the module's text.
2980
+ *
2981
+ * With `base`, also whether the theme extends that module's export, by
2982
+ * identity, anywhere up its `extends` chain (`extendsBase`): the module is
2983
+ * loaded once, and the theme module's imports of it (by any of
2984
+ * `base.specifiers`) are handed that one load, so the answer is about the
2985
+ * very object, not one that only looks like it.
2986
+ * @param {string} file
2987
+ * @param {{cwd?: string, base?: {file: string, exportName: string, specifiers: string[]}}} [ctx]
2988
+ * @returns {Promise<{theme: any, exportName: string, extendsBase?: boolean}>}
2989
+ */
2990
+ export async function loadThemeExport(file, {cwd = process.cwd(), base} = {}) {
2991
+ const filePath = path.resolve(cwd, file);
2992
+ await selectCore(cwd, {projectOnly: false});
2993
+ const {theme, exportName = 'default'} = await extractThemeDefinition(
2994
+ filePath,
2995
+ standaloneInterception(filePath),
2996
+ );
2997
+ if (!base) return {theme, exportName};
2998
+ const recorder = interceptCore(_coreThemeModule, _coreRootModule);
2999
+ const shared = (
3000
+ await extractThemeDefinition(
3001
+ path.resolve(cwd, base.file),
3002
+ recorder,
3003
+ undefined,
3004
+ base.exportName,
3005
+ )
3006
+ ).theme;
3007
+ const withBase = {
3008
+ ...recorder,
3009
+ modules: {
3010
+ ...recorder.modules,
3011
+ ...Object.fromEntries(
3012
+ base.specifiers.map(s => [s, {[base.exportName]: shared}]),
3013
+ ),
3014
+ },
3015
+ };
3016
+ const again = await extractThemeDefinition(
3017
+ filePath,
3018
+ withBase,
3019
+ undefined,
3020
+ exportName,
3021
+ );
3022
+ let extendsBase = false;
3023
+ for (
3024
+ let at = recorder.parentOf(again.theme), depth = 0;
3025
+ at && depth < 64;
3026
+ at = recorder.parentOf(at), depth++
3027
+ )
3028
+ if (at === shared) {
3029
+ extendsBase = true;
3030
+ break;
3031
+ }
3032
+ return {theme, exportName, extendsBase};
3033
+ }
3034
+
3035
+ /**
3036
+ * The input a theme module gives `defineTheme()` for the theme a build of
3037
+ * it reads, evaluated as the build evaluates the module (an import, an
3038
+ * expression, a spread or a computed key is its value), with the theme Core
3039
+ * made of it. When Core refuses the input, the input the module gave for
3040
+ * the named theme (else its last) and Core's error; null when the module
3041
+ * does not load at all.
3042
+ * `chain` holds the inputs of the themes it extends, nearest first, as far
3043
+ * as each was made by a `defineTheme()` call this load saw.
3044
+ * @param {string} file
3045
+ * @param {{cwd?: string, name?: string}} [ctx]
3046
+ * @returns {Promise<{input: any, theme: any, error: Error | null, chain: any[]} | null>}
3047
+ */
3048
+ export async function loadThemeInput(file, {cwd = process.cwd(), name} = {}) {
3049
+ const filePath = path.resolve(cwd, file);
3050
+ await selectCore(cwd, {projectOnly: false});
3051
+ const interception = interceptCore(_coreThemeModule, _coreRootModule);
3052
+ /** @param {any} input */
3053
+ const chainOf = input => {
3054
+ const chain = [];
3055
+ /** @type {Set<any>} */
3056
+ const seen = new Set([input]);
3057
+ let parent = interception.inputOf(input?.extends);
3058
+ while (parent && typeof parent === 'object' && !seen.has(parent)) {
3059
+ seen.add(parent);
3060
+ chain.push(parent);
3061
+ parent = interception.inputOf(parent.extends);
3062
+ }
3063
+ return chain;
3064
+ };
3065
+ try {
3066
+ const {theme} = await extractThemeDefinition(filePath, interception);
3067
+ const input = interception.inputOf(theme) ?? null;
3068
+ return {input, theme, error: null, chain: chainOf(input)};
3069
+ } catch (e) {
3070
+ const given = interception.inputs;
3071
+ const input =
3072
+ given.filter(x => x && typeof x === 'object' && x.name === name).at(-1) ??
3073
+ given.at(-1);
3074
+ return input
3075
+ ? {
3076
+ input,
3077
+ theme: null,
3078
+ error: /** @type {Error} */ (e),
3079
+ chain: chainOf(input),
3080
+ }
3081
+ : null;
3082
+ }
3083
+ }
3084
+
3085
+ /**
3086
+ * A one-mode `colorModes` value (`['light']` or `['dark']`), or null for
3087
+ * anything else: a theme with both modes needs no export.
3088
+ * @param {unknown} value
3089
+ * @returns {['light'] | ['dark'] | null}
3090
+ */
3091
+ export function oneColorMode(value) {
3092
+ return Array.isArray(value) &&
3093
+ value.length === 1 &&
3094
+ (value[0] === 'light' || value[0] === 'dark')
3095
+ ? /** @type {['light'] | ['dark']} */ ([value[0]])
3096
+ : null;
3097
+ }
3098
+
2818
3099
  /** Names a theme module's exports must take; ends a shape failure. */
2819
3100
  const THEME_EXPORT_FIX =
2820
3101
  "Export the theme object: `export default defineTheme({name: 'my-theme', tokens: {...}})`, or a plain `export default {name: 'my-theme', tokens: {...}}`.";
@@ -3739,21 +4020,32 @@ async function themeBuildInternal(
3739
4020
  report = {},
3740
4021
  handOff = {},
3741
4022
  ) {
4023
+ // A blank --out names no file: the build would write files named by the
4024
+ // spaces alone.
4025
+ if (
4026
+ typeof options.out === 'string' &&
4027
+ options.out !== '' &&
4028
+ !options.out.trim()
4029
+ )
4030
+ throw new AstryxError(
4031
+ '--out is blank; name a file or folder, or leave out --out to write beside the source.',
4032
+ [
4033
+ {
4034
+ name: buildSuggestion(file, {...options, out: undefined}, cwd),
4035
+ reason: 'do this instead',
4036
+ },
4037
+ ],
4038
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
4039
+ );
3742
4040
  // A backslash in --out separates folders on every platform, as it does in
3743
4041
  // the other theme paths (a Windows path copied into a POSIX shell).
3744
4042
  if (typeof options.out === 'string' && options.out.includes('\\'))
3745
4043
  options = {...options, out: options.out.replace(/\\/g, '/')};
3746
4044
  const filePath = path.resolve(cwd, file);
3747
4045
 
3748
- if (!fs.existsSync(filePath)) {
3749
- throw new AstryxError(
3750
- `File not found: ${filePath}`,
3751
- themeSourceGuesses(file, cwd).map(guess => ({
3752
- name: buildSuggestion(guess, options, cwd),
3753
- reason: 'a theme source that exists',
3754
- })),
3755
- ERROR_CODES.ERR_FILE_NOT_FOUND,
3756
- );
4046
+ {
4047
+ const problem = buildInputProblem(file, options, cwd);
4048
+ if (problem) throw problem;
3757
4049
  }
3758
4050
 
3759
4051
  // A theme the theme editor made is built from its settings by the editor;
@@ -3772,24 +4064,6 @@ async function themeBuildInternal(
3772
4064
  );
3773
4065
  }
3774
4066
 
3775
- if (fs.statSync(filePath).isDirectory()) {
3776
- throw new AstryxError(
3777
- `${path.relative(cwd, filePath) || '.'} is a folder. Pass the theme file inside it.`,
3778
- themeFilesIn(filePath).map(name => ({
3779
- name: buildSuggestion(
3780
- path
3781
- .relative(cwd, path.join(filePath, name))
3782
- .split(path.sep)
3783
- .join('/'),
3784
- options,
3785
- cwd,
3786
- ),
3787
- reason: 'a theme source in that folder',
3788
- })),
3789
- ERROR_CODES.ERR_INVALID_ARGUMENT,
3790
- );
3791
- }
3792
-
3793
4067
  assertThemeSourceFile(filePath, cwd, options);
3794
4068
 
3795
4069
  if (!report.compact) {
@@ -3814,10 +4088,7 @@ async function themeBuildInternal(
3814
4088
  // shared loader so exact authored parent identity stays CLI-private instead
3815
4089
  // of becoming a public DefinedTheme field.
3816
4090
  const interception =
3817
- handOff.familyInterception ??
3818
- (_generateAdaptationCSS && themeFolderResolvesCore(filePath)
3819
- ? undefined
3820
- : interceptCore(_coreThemeModule, _coreRootModule));
4091
+ handOff.familyInterception ?? standaloneInterception(filePath);
3821
4092
 
3822
4093
  // Extract theme definition
3823
4094
  let themeDef;
@@ -3825,6 +4096,9 @@ async function themeBuildInternal(
3825
4096
  let themeExportName;
3826
4097
  /** Paths through the load that interception could not fully observe. */
3827
4098
  let loadDegradation;
4099
+ /** The one color mode the theme module exports, or null for both. */
4100
+ /** @type {['light'] | ['dark'] | null} */
4101
+ let colorModes;
3828
4102
  /**
3829
4103
  * The theme file's bytes as loaded: read before and after the load, and the
3830
4104
  * registry scan below reads these rather than the file again. An editor's
@@ -3851,6 +4125,7 @@ async function themeBuildInternal(
3851
4125
  themeDef = loaded.theme;
3852
4126
  themeExportName = loaded.exportName;
3853
4127
  loadDegradation = loaded.degraded;
4128
+ colorModes = handOff.colorModes ?? loaded.colorModes ?? null;
3854
4129
  } catch (e) {
3855
4130
  const err = /** @type {Error} */ (e);
3856
4131
  const shown = path.relative(cwd, filePath) || filePath;
@@ -4403,9 +4678,10 @@ async function themeBuildInternal(
4403
4678
  .join(path.dirname(options.out), `${stem}.css`)
4404
4679
  .split(path.sep)
4405
4680
  .join('/');
4406
- logger.warn(
4407
- `Warning: --out names the stylesheet, which is CSS; give it a .css name such as ${fixed}.`,
4408
- );
4681
+ // The result's warnings say it too, as text does.
4682
+ const w = `--out names the stylesheet, which is CSS; give it a .css name such as ${fixed}.`;
4683
+ warningMessages.push(w);
4684
+ logger.warn(`Warning: ${w}`);
4409
4685
  }
4410
4686
  // A build keeps the explicit output inside the write root, relative or
4411
4687
  // absolute. Check mode writes nothing, so it refuses only a relative path
@@ -4482,19 +4758,30 @@ async function themeBuildInternal(
4482
4758
  ? {}
4483
4759
  : {cssFileName: path.basename(outPath)}),
4484
4760
  },
4485
- );
4761
+ ) +
4762
+ // The one color mode, beside the theme export (a two-mode theme
4763
+ // exports none, so its module is unchanged).
4764
+ (colorModes
4765
+ ? `export const colorModes = [${JSON.stringify(colorModes[0])}];\n`
4766
+ : '');
4486
4767
  const dtsContent =
4487
4768
  generatedHeader(headerSource, 'ts', buildCommand, versions) +
4488
- generateBuiltTypes(resolvedTheme || themeDef, iconInfo, variantsFileName);
4769
+ generateBuiltTypes(resolvedTheme || themeDef, iconInfo, variantsFileName) +
4770
+ (colorModes
4771
+ ? `export declare const colorModes: readonly [${JSON.stringify(colorModes[0])}];\n`
4772
+ : '');
4489
4773
 
4774
+ // A family the caller knows the app loads (a font stylesheet it writes
4775
+ // for the theme) is not named as unloaded.
4490
4776
  const unloadedFonts = [
4491
4777
  ...new Set([
4492
4778
  ...collectUnloadedFonts(resolvedTheme),
4493
4779
  ...adaptationRuleValues(resolvedTheme).flatMap(
4494
- (/** @type {any} */ value) => collectUnloadedFonts(value),
4780
+ (/** @type {any} */ value) =>
4781
+ collectUnloadedFonts(value, resolvedTheme),
4495
4782
  ),
4496
4783
  ]),
4497
- ];
4784
+ ].filter(family => !handOff.loadedFonts?.(family));
4498
4785
 
4499
4786
  if (handOff.prepareFamily) {
4500
4787
  return {
@@ -4547,6 +4834,8 @@ async function themeBuildInternal(
4547
4834
  rerun,
4548
4835
  refuseUnmarked: Boolean(options.out),
4549
4836
  onEditorFolder: editorFolderListener ?? undefined,
4837
+ // The result's warnings carry what text prints.
4838
+ onWarning: message => warningMessages.push(message),
4550
4839
  });
4551
4840
  }
4552
4841
 
@@ -4637,12 +4926,19 @@ async function themeBuildInternal(
4637
4926
  // permanently in violation of its own "compiles with no warnings" guard).
4638
4927
  // Adaptation rules are resolved theme writes in their own right, so a family
4639
4928
  // named only inside one needs the same notice as one named at the root.
4929
+ // The result names the recipe's command bare, as every machine-read
4930
+ // command is; the printed note starts it the way this project runs the CLI.
4931
+ /** @param {string} family @param {string} recipe */
4932
+ const fontNotice = (family, recipe) =>
4933
+ handOff.fontHelp?.notice(family) ??
4934
+ `Font "${family}" is named by this theme but not loaded; add a <link> or @font-face in your app (recipe: ${recipe})`;
4640
4935
  /** @type {string[]} */
4641
4936
  const fontNotices = [];
4642
4937
  for (const family of unloadedFonts) {
4643
- const msg = `Font "${family}" is named by this theme but not loaded; add a <link> or @font-face in your app (recipe: astryx docs typography)`;
4644
- noticeMessages.push(msg);
4645
- fontNotices.push(msg);
4938
+ noticeMessages.push(fontNotice(family, 'astryx docs typography'));
4939
+ fontNotices.push(
4940
+ fontNotice(family, formatCliCommand('docs typography', cwd)),
4941
+ );
4646
4942
  }
4647
4943
 
4648
4944
  /** @type {ThemeBuildTrailer} */
@@ -4653,6 +4949,8 @@ async function themeBuildInternal(
4653
4949
  cssImport,
4654
4950
  unloadedFonts,
4655
4951
  fontNotices,
4952
+ fontHelp: handOff.fontHelp ?? null,
4953
+ install: handOff.install ?? null,
4656
4954
  };
4657
4955
  // A batch or compact report prints this once for the whole run instead.
4658
4956
  if (report.trailers) report.trailers.push(trailer);
@@ -4689,7 +4987,11 @@ async function themeBuildInternal(
4689
4987
  * @property {string} jsImport Import specifier of the built JS module.
4690
4988
  * @property {string} cssImport Import specifier of the built CSS.
4691
4989
  * @property {string[]} unloadedFonts Font families the theme names but does not load.
4692
- * @property {string[]} fontNotices One notice per unloaded font family.
4990
+ * @property {string[]} fontNotices One notice per unloaded font family, as printed.
4991
+ * @property {FontHelp | null} [fontHelp] How the caller loads fonts, when it does.
4992
+ * @property {string | null} [install] How the app takes the theme, when the
4993
+ * caller wires it another way than importing these outputs (the editor's
4994
+ * app copy).
4693
4995
  */
4694
4996
 
4695
4997
  /**
@@ -4697,7 +4999,9 @@ async function themeBuildInternal(
4697
4999
  * @param {ThemeBuildTrailer} trailer
4698
5000
  */
4699
5001
  function printBuildTrailer(trailer) {
4700
- logger.log(`
5002
+ if (trailer.install) logger.log(`\n${trailer.install}\n`);
5003
+ else
5004
+ logger.log(`
4701
5005
  Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
4702
5006
 
4703
5007
  import { Theme } from '@astryxdesign/core/theme';
@@ -4720,7 +5024,13 @@ Or with a <link> tag:
4720
5024
  `);
4721
5025
  for (const msg of trailer.fontNotices) logger.log(` note: ${msg}`);
4722
5026
  if (trailer.unloadedFonts.length > 0) {
4723
- logger.log(formatFontLoadingHelp(trailer.themeName, trailer.unloadedFonts));
5027
+ logger.log(
5028
+ formatFontLoadingHelp(
5029
+ trailer.themeName,
5030
+ trailer.unloadedFonts,
5031
+ trailer.fontHelp?.recipe,
5032
+ ),
5033
+ );
4724
5034
  }
4725
5035
  }
4726
5036
 
@@ -4732,8 +5042,13 @@ Or with a <link> tag:
4732
5042
  */
4733
5043
  export function printBatchTrailer(trailers) {
4734
5044
  if (trailers.length === 0) return;
4735
- const [first] = trailers;
4736
- logger.log(`
5045
+ // A theme the caller wires another way says how, once each.
5046
+ for (const trailer of trailers)
5047
+ if (trailer.install) logger.log(`\n${trailer.install}\n`);
5048
+ const imported = trailers.filter(trailer => !trailer.install);
5049
+ const [first] = imported;
5050
+ if (first)
5051
+ logger.log(`
4737
5052
  Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
4738
5053
 
4739
5054
  import { Theme } from '@astryxdesign/core/theme';
@@ -4754,16 +5069,19 @@ Or with a <link> tag:
4754
5069
  <App />
4755
5070
  </Theme>
4756
5071
  `);
4757
- if (trailers.length > 1) {
5072
+ if (imported.length > 1) {
4758
5073
  logger.log('Each built theme imports the same way:');
4759
- for (const trailer of trailers) {
5074
+ for (const trailer of imported) {
4760
5075
  logger.log(
4761
5076
  ` import { ${trailer.exportName} } from '${trailer.jsImport}'; import '${trailer.cssImport}';`,
4762
5077
  );
4763
5078
  }
4764
5079
  }
4765
5080
  const fonts = groupUnloadedFonts(trailers);
4766
- if (fonts.length > 0) logger.log(formatBatchFontLoadingHelp(fonts));
5081
+ // One caller's recipe serves the batch only when every theme takes it.
5082
+ const help = trailers.every(t => t.fontHelp) ? trailers[0].fontHelp : null;
5083
+ if (fonts.length > 0)
5084
+ logger.log(formatBatchFontLoadingHelp(fonts, help?.recipe));
4767
5085
  }
4768
5086
 
4769
5087
  /**
@@ -4998,7 +5316,7 @@ function planFamilySources(files, cwd) {
4998
5316
  // prettier-ignore
4999
5317
  async function preloadFamilySource(filePath, loader, interception) {
5000
5318
  const patch = interception.patchCommonJs(filePath);
5001
- try { try { loader(filePath); } catch (error) { if (!isSyncLoaderLimitation(error)) throw error; await loader.evalModule(fs.readFileSync(filePath, 'utf8'), {id: filePath, filename: filePath, ext: path.extname(filePath), cache: loader.cache, async: true, forceTranspile: true}); } }
5319
+ try { try { await withEmptyStylesheets(async () => loader(filePath)); } catch (error) { if (!isSyncLoaderLimitation(error)) throw error; await withEmptyStylesheets(() => loader.evalModule(fs.readFileSync(filePath, 'utf8'), {id: filePath, filename: filePath, ext: path.extname(filePath), cache: loader.cache, async: true, forceTranspile: true})); } }
5002
5320
  finally { patch.undo(); }
5003
5321
  }
5004
5322
 
@@ -5026,7 +5344,7 @@ export async function themeBuildFamily(
5026
5344
  await selectCore(cwd);
5027
5345
  const familyInterception = interceptCore(_coreThemeModule, _coreRootModule);
5028
5346
  // prettier-ignore
5029
- const familyLoader = createJiti(import.meta.url, {moduleCache: true, fsCache: false, interopDefault: false, jsx: true, extensions: THEME_MODULE_EXTENSIONS, virtualModules: familyInterception.modules});
5347
+ const familyLoader = createJiti(import.meta.url, {moduleCache: true, ...jitiCacheOptions(), interopDefault: false, jsx: true, extensions: THEME_MODULE_EXTENSIONS, virtualModules: familyInterception.modules});
5030
5348
  /** @type {any[]} */
5031
5349
  const prepared = [];
5032
5350
  for (const source of planFamilySources(files, cwd)) {
@@ -5318,11 +5636,18 @@ Or load the same stylesheet natively:
5318
5636
  const unloadedFonts = [
5319
5637
  ...new Set(members.flatMap(member => member.unloadedFonts)),
5320
5638
  ];
5321
- const notices = unloadedFonts.map(
5322
- family =>
5323
- `Font "${family}" is named by this theme family but not loaded; add a <link> or @font-face in your app (recipe: astryx docs typography)`,
5639
+ /** @param {string} family @param {string} recipe */
5640
+ const familyNotice = (family, recipe) =>
5641
+ `Font "${family}" is named by this theme family but not loaded; add a <link> or @font-face in your app (recipe: ${recipe})`;
5642
+ // The result names the command bare; the printed note as this project
5643
+ // runs the CLI.
5644
+ const notices = unloadedFonts.map(family =>
5645
+ familyNotice(family, 'astryx docs typography'),
5324
5646
  );
5325
- for (const notice of notices) logger.log(` note: ${notice}`);
5647
+ for (const family of unloadedFonts)
5648
+ logger.log(
5649
+ ` note: ${familyNotice(family, formatCliCommand('docs typography', cwd))}`,
5650
+ );
5326
5651
  return {
5327
5652
  type: 'theme.build',
5328
5653
  data: {