@astryxdesign/cli 0.7.16 → 0.7.17-canary.g49a475f

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 (354) 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 +75 -0
  79. package/api/theme/build/build.mjs +243 -58
  80. package/api/theme/build/font-warning.d.mts +7 -0
  81. package/api/theme/build/font-warning.mjs +17 -0
  82. package/api/theme/theme.type.d.mts +10 -0
  83. package/api/theme/theme.type.mjs +7 -1
  84. package/api/theme-edit/_adapter.d.mts +63 -2
  85. package/api/theme-edit/_adapter.mjs +771 -57
  86. package/api/theme-edit/_check.d.mts +40 -22
  87. package/api/theme-edit/_check.mjs +2029 -336
  88. package/api/theme-edit/_color.d.mts +10 -0
  89. package/api/theme-edit/_color.mjs +49 -1
  90. package/api/theme-edit/_compiler.mjs +9 -0
  91. package/api/theme-edit/_context.d.mts +3 -3
  92. package/api/theme-edit/_context.mjs +111 -48
  93. package/api/theme-edit/_css.d.mts +14 -0
  94. package/api/theme-edit/_css.mjs +46 -1
  95. package/api/theme-edit/_edit.d.mts +18 -4
  96. package/api/theme-edit/_edit.mjs +1685 -155
  97. package/api/theme-edit/_how-commands.d.mts +65 -0
  98. package/api/theme-edit/_how-commands.mjs +633 -1
  99. package/api/theme-edit/_how-question.d.mts +84 -0
  100. package/api/theme-edit/_how-question.mjs +5124 -281
  101. package/api/theme-edit/_how.mjs +140 -29
  102. package/api/theme-edit/_marks.d.mts +31 -5
  103. package/api/theme-edit/_marks.mjs +57 -5
  104. package/api/theme-edit/_name-rule.d.mts +11 -0
  105. package/api/theme-edit/_name-rule.mjs +12 -0
  106. package/api/theme-edit/_normal.d.mts +257 -0
  107. package/api/theme-edit/_normal.mjs +1252 -0
  108. package/api/theme-edit/_palette.mjs +10 -4
  109. package/api/theme-edit/_parts.d.mts +10 -1
  110. package/api/theme-edit/_parts.mjs +179 -3
  111. package/api/theme-edit/_preview-app.d.mts +7 -1
  112. package/api/theme-edit/_preview-app.mjs +515 -148
  113. package/api/theme-edit/_preview.d.mts +100 -14
  114. package/api/theme-edit/_preview.mjs +549 -137
  115. package/api/theme-edit/_settings.d.mts +347 -30
  116. package/api/theme-edit/_settings.mjs +2971 -327
  117. package/api/theme-edit/_tables.d.mts +6 -0
  118. package/api/theme-edit/_tables.mjs +44 -1
  119. package/api/theme-edit/_vet.d.mts +18 -0
  120. package/api/theme-edit/_vet.mjs +32 -0
  121. package/api/theme-edit/theme-edit.type.d.mts +10 -1
  122. package/api/theme-edit/theme-edit.type.mjs +4 -1
  123. package/api/theme-edit/themeEditHow.doc.mjs +1 -1
  124. package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
  125. package/api/theme-edit/themeEditNew.doc.mjs +7 -4
  126. package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
  127. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
  128. package/api/upgrade/run/run.mjs +4 -3
  129. package/assets/codemods/integration-discovery.mjs +2 -1
  130. package/assets/codemods/run-codemod.mjs +87 -7
  131. package/assets/codemods/transforms/next/index.mjs +11 -1
  132. package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
  133. package/assets/component-list.generated.json +1 -0
  134. package/assets/docs/author-a-theme.doc.mjs +1 -0
  135. package/assets/docs/theme.doc.dense.mjs +2 -2
  136. package/assets/docs/theme.doc.mjs +1 -1
  137. package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
  138. package/assets/docs/tree/checks.doc.mjs +1 -1
  139. package/assets/docs/tree/cli-command.doc.mjs +2 -3
  140. package/assets/docs/tree/render-pages.doc.mjs +44 -3
  141. package/assets/docs/tree/single-component.doc.mjs +4 -0
  142. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  143. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  144. package/assets/docs/use-a-theme.doc.mjs +1 -1
  145. package/assets/docs.generated.json +2 -2
  146. package/assets/search-catalog.generated.json +2 -0
  147. package/assets/self-audit.generated.json +1 -1
  148. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
  149. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
  150. package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
  151. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
  152. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
  153. package/assets/templates/components.generated.json +1 -1
  154. package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
  155. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +2 -1
  156. package/assets/templates/pages/blank/template.doc.mjs +1 -1
  157. package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
  158. package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
  159. package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
  160. package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
  161. package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
  162. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
  163. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
  164. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
  165. package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
  166. package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
  167. package/assets/templates/pages/documentation/template.doc.mjs +4 -1
  168. package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
  169. package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
  170. package/assets/templates/pages/editor/template.doc.mjs +2 -8
  171. package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
  172. package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
  173. package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
  174. package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
  175. package/assets/templates/pages/ide/page.tsx +24 -2
  176. package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
  177. package/assets/templates/pages/library/template.doc.mjs +4 -1
  178. package/assets/templates/pages/login/template.doc.mjs +2 -1
  179. package/assets/templates/pages/login-card/template.doc.mjs +2 -1
  180. package/assets/templates/pages/login-split/template.doc.mjs +2 -1
  181. package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
  182. package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
  183. package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
  184. package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
  185. package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
  186. package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
  187. package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
  188. package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
  189. package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
  190. package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
  191. package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
  192. package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
  193. package/assets/templates/pages/table-page/template.doc.mjs +5 -4
  194. package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
  195. package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
  196. package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
  197. package/assets/theme.template.ts +6 -0
  198. package/authoring/debug/parse.d.mts +3 -3
  199. package/authoring/doctypes/_schema.d.mts +3 -3
  200. package/authoring/doctypes/command/command.doc.mjs +1 -1
  201. package/authoring/doctypes/component/categories.d.mts +37 -0
  202. package/authoring/doctypes/component/categories.mjs +54 -0
  203. package/authoring/doctypes/template/template.doc.mjs +1 -1
  204. package/authoring/doctypes/template/type.ts +9 -0
  205. package/authoring/example/example.doc.d.mts +12 -0
  206. package/authoring/example/example.doc.mjs +69 -0
  207. package/authoring/example/preview.d.mts +92 -0
  208. package/authoring/example/preview.mjs +994 -0
  209. package/authoring/example/type.ts +102 -0
  210. package/authoring/index.d.mts +1 -0
  211. package/authoring/index.d.ts +12 -0
  212. package/authoring/index.mjs +3 -1
  213. package/clients/cli/bin/astryx.mjs +6 -9
  214. package/clients/cli/build-id.generated.json +1 -1
  215. package/clients/cli/commands/component.doc.mjs +1 -1
  216. package/clients/cli/commands/component.mjs +22 -3
  217. package/clients/cli/commands/docs.doc.mjs +7 -1
  218. package/clients/cli/commands/docs.mjs +3 -1
  219. package/clients/cli/commands/doctor.mjs +32 -14
  220. package/clients/cli/commands/experimental/render.mjs +42 -1
  221. package/clients/cli/commands/experimental/theme.mjs +163 -28
  222. package/clients/cli/commands/experimental-render.doc.mjs +2 -2
  223. package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
  224. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
  225. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
  226. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  227. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  228. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  229. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  230. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  231. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
  232. package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
  233. package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
  234. package/clients/cli/commands/search.doc.mjs +2 -1
  235. package/clients/cli/commands/search.mjs +6 -1
  236. package/clients/cli/commands/template.mjs +4 -2
  237. package/clients/cli/commands/theme-build.doc.mjs +5 -1
  238. package/clients/cli/commands/theme.doc.mjs +1 -1
  239. package/clients/cli/commands/theme.mjs +209 -8
  240. package/clients/cli/commands/upgrade.mjs +42 -7
  241. package/clients/cli/index.mjs +1 -1
  242. package/clients/cli/lib/cli-error.mjs +2 -1
  243. package/clients/cli/lib/component-format.mjs +205 -98
  244. package/clients/cli/lib/hook-format.mjs +9 -19
  245. package/clients/cli/lib/json-shim.mjs +77 -21
  246. package/clients/cli/lib/manifest.mjs +3 -2
  247. package/clients/cli/manifest.generated.json +1 -1
  248. package/foundation/agent-docs/agent-docs.mjs +1 -1
  249. package/foundation/config/theme-state.d.mts +13 -1
  250. package/foundation/config/theme-state.mjs +47 -7
  251. package/foundation/discovery/authoring-self-docs.mjs +1 -0
  252. package/foundation/discovery/component-discovery.d.mts +11 -0
  253. package/foundation/discovery/component-discovery.mjs +56 -8
  254. package/foundation/discovery/component-replacement.mjs +130 -1
  255. package/foundation/discovery/copied-passages.mjs +2 -1
  256. package/foundation/discovery/doc-types.mjs +4 -3
  257. package/foundation/discovery/entry-name-files.d.mts +43 -0
  258. package/foundation/discovery/entry-name-files.mjs +264 -0
  259. package/foundation/discovery/hook-discovery.d.mts +8 -2
  260. package/foundation/discovery/hook-discovery.mjs +22 -8
  261. package/foundation/discovery/icon-definition-discovery.mjs +2 -1
  262. package/foundation/discovery/icon-set-checks.mjs +2 -1
  263. package/foundation/discovery/icon-set-discovery.mjs +2 -1
  264. package/foundation/discovery/integration-doc-files.mjs +2 -1
  265. package/foundation/discovery/package-exports.d.mts +10 -0
  266. package/foundation/discovery/package-exports.mjs +56 -3
  267. package/foundation/discovery/prop-drift.mjs +9 -9
  268. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  269. package/foundation/discovery/runner-allowlist.mjs +2 -0
  270. package/foundation/discovery/stored-component-list.d.mts +43 -0
  271. package/foundation/discovery/stored-component-list.mjs +90 -0
  272. package/foundation/discovery/stored-search-catalog.d.mts +115 -0
  273. package/foundation/discovery/stored-search-catalog.mjs +297 -0
  274. package/foundation/discovery/stored-self-audit.d.mts +26 -10
  275. package/foundation/discovery/stored-self-audit.mjs +38 -18
  276. package/foundation/discovery/template-adapter.d.mts +52 -0
  277. package/foundation/discovery/template-adapter.mjs +176 -12
  278. package/foundation/discovery/template-icons.mjs +2 -1
  279. package/foundation/discovery/theme-discovery.mjs +3 -2
  280. package/foundation/discovery/theme-imports.d.mts +14 -0
  281. package/foundation/discovery/theme-imports.mjs +43 -1
  282. package/foundation/discovery/theming-targets.mjs +3 -2
  283. package/foundation/doc-compiler/import.mjs +7 -1
  284. package/foundation/doc-compiler/inputs.mjs +3 -2
  285. package/foundation/doc-compiler/parse-readable.mjs +4 -1
  286. package/foundation/doc-compiler/stored-docs.d.mts +22 -0
  287. package/foundation/doc-compiler/stored-docs.mjs +49 -0
  288. package/foundation/env/semver.mjs +3 -1
  289. package/foundation/fonts/font-stylesheet.d.mts +31 -0
  290. package/foundation/fonts/font-stylesheet.mjs +115 -0
  291. package/foundation/fs/cache-eviction.d.mts +21 -0
  292. package/foundation/fs/cache-eviction.mjs +73 -0
  293. package/foundation/fs/file-protection.mjs +4 -3
  294. package/foundation/fs/gather-cache.d.mts +25 -4
  295. package/foundation/fs/gather-cache.mjs +164 -55
  296. package/foundation/fs/jiti-cache.d.mts +19 -1
  297. package/foundation/fs/jiti-cache.mjs +130 -6
  298. package/foundation/fs/kept-tree.d.mts +60 -0
  299. package/foundation/fs/kept-tree.mjs +154 -0
  300. package/foundation/fs/listing-cache.d.mts +7 -0
  301. package/foundation/fs/listing-cache.mjs +10 -0
  302. package/foundation/fs/module-loader.d.mts +24 -2
  303. package/foundation/fs/module-loader.mjs +94 -21
  304. package/foundation/fs/paths.d.mts +18 -0
  305. package/foundation/fs/paths.mjs +15 -2
  306. package/foundation/identity/provider-identity.d.mts +6 -0
  307. package/foundation/identity/provider-identity.mjs +10 -1
  308. package/foundation/integrations/contribution-inventory.mjs +4 -3
  309. package/foundation/integrations/example-code.d.mts +63 -0
  310. package/foundation/integrations/example-code.mjs +416 -0
  311. package/foundation/integrations/public-imports.d.mts +9 -0
  312. package/foundation/integrations/public-imports.mjs +3 -2
  313. package/foundation/integrations/validate-contributions.mjs +17 -45
  314. package/foundation/render/embedded-files.d.mts +6 -0
  315. package/foundation/render/embedded-files.mjs +25 -5
  316. package/foundation/render/embedded-imports.d.mts +39 -7
  317. package/foundation/render/embedded-imports.mjs +66 -27
  318. package/foundation/render/file-header.d.mts +66 -0
  319. package/foundation/render/file-header.mjs +118 -0
  320. package/foundation/render/host-answer.d.mts +18 -0
  321. package/foundation/render/host-answer.mjs +46 -0
  322. package/foundation/render/host-exit.d.mts +1 -0
  323. package/foundation/render/host-exit.mjs +6 -1
  324. package/foundation/render/html-reader.d.mts +55 -2
  325. package/foundation/render/html-reader.mjs +145 -26
  326. package/foundation/render/markup-edits.d.mts +57 -0
  327. package/foundation/render/markup-edits.mjs +182 -0
  328. package/foundation/render/page-host.mjs +29 -12
  329. package/foundation/render/page-worker.mjs +121 -13
  330. package/foundation/render/picture-chrome.d.mts +4 -0
  331. package/foundation/render/picture-chrome.mjs +185 -0
  332. package/foundation/render/picture-playwright.d.mts +4 -0
  333. package/foundation/render/picture-playwright.mjs +34 -0
  334. package/foundation/render/rebuild.mjs +2 -1
  335. package/foundation/render/render-page.d.mts +35 -3
  336. package/foundation/render/render-page.mjs +316 -42
  337. package/foundation/render/source-block.d.mts +85 -6
  338. package/foundation/render/source-block.mjs +211 -20
  339. package/foundation/render/ts-paths.d.mts +69 -6
  340. package/foundation/render/ts-paths.mjs +326 -40
  341. package/foundation/response/error-codes.d.mts +3 -1
  342. package/foundation/response/error-codes.d.ts +1 -0
  343. package/foundation/response/error-codes.doc.mjs +12 -1
  344. package/foundation/response/error-codes.mjs +11 -1
  345. package/foundation/response/response-types.doc.mjs +2 -2
  346. package/foundation/text/compare-text.d.mts +14 -0
  347. package/foundation/text/compare-text.mjs +68 -0
  348. package/foundation/text/string-utils.d.mts +3 -2
  349. package/foundation/text/string-utils.mjs +18 -4
  350. package/foundation/text/suggest-order.d.mts +9 -0
  351. package/foundation/text/suggest-order.mjs +15 -1
  352. package/foundation/xle/expand.mjs +2 -1
  353. package/host/index.mjs +8 -6
  354. 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,
@@ -92,6 +92,10 @@ import {applyWrites} from '../../integration/add-helpers.mjs';
92
92
  import {logger} from '../../logger.mjs';
93
93
  import {loadComponentDoc} from '../../../foundation/discovery/component-loader.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
@@ -333,10 +338,12 @@ function realOrSelf(file) {
333
338
  /**
334
339
  * `target` spelled through real directories: the deepest ancestor that exists
335
340
  * is resolved through its symlinks, and the missing rest is appended as given.
341
+ * The build confines its outputs by it, and the theme editor's compile guard
342
+ * reads paths through it too, so both read a path the same way.
336
343
  * @param {string} target absolute path
337
344
  * @returns {string}
338
345
  */
339
- function realLocation(target) {
346
+ export function realLocation(target) {
340
347
  /** @type {string[]} */
341
348
  const missing = [];
342
349
  let existing = target;
@@ -818,7 +825,7 @@ function confineOutputs(writes, root, remedy) {
818
825
  }
819
826
 
820
827
  /** @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) {
828
+ export function refusedOutput(dest, root) {
822
829
  try {
823
830
  confineOutput(dest, root, '');
824
831
  return false;
@@ -925,6 +932,82 @@ function isDirectorySync(file) {
925
932
  }
926
933
  }
927
934
 
935
+ /**
936
+ * The marks a file's leading comment carries (see `generatedMark`): a theme
937
+ * build's output, or a file the theme editor writes, with the command it
938
+ * names. The one reader build and doctor share.
939
+ * @param {string} source the start of the file
940
+ * @param {string} [file] its path, for a mark that names no exact command
941
+ */
942
+ export function fileMark(source, file) {
943
+ return generatedMark(source, GENERATED_MARKER, file);
944
+ }
945
+
946
+ /**
947
+ * The command a file's leading comment says writes it, when another CLI
948
+ * command generates it (the theme editor's settings module or app copy):
949
+ * the exact command its mark names. Null for a theme build's own output and
950
+ * a file without a mark, such as a theme source of one's own.
951
+ * @param {string} file
952
+ * @returns {string | null}
953
+ */
954
+ export function generatedFileCommand(file) {
955
+ const mark = fileMark(fileHead(file), file);
956
+ return mark?.kind === 'editor' ? mark.command : null;
957
+ }
958
+
959
+ /**
960
+ * The command that writes a missing `file`: a file beside it carries
961
+ * another command's mark, and a file there names `file` (a build output's
962
+ * header names its source), so it is one that command writes. Null for any
963
+ * other name, such as a typo.
964
+ * @param {string} file
965
+ * @returns {string | null}
966
+ */
967
+ function missingGeneratedCommand(file) {
968
+ const dir = path.dirname(file);
969
+ const base = path.basename(file);
970
+ let names;
971
+ try {
972
+ names = fs.readdirSync(dir).sort();
973
+ } catch {
974
+ return null;
975
+ }
976
+ /** @type {string | null} */
977
+ let by = null;
978
+ let named = false;
979
+ for (const n of names) {
980
+ const f = path.join(dir, n);
981
+ try {
982
+ if (!fs.statSync(f).isFile()) continue;
983
+ } catch {
984
+ continue;
985
+ }
986
+ by ??= generatedFileCommand(f);
987
+ if (!named)
988
+ try {
989
+ named = fs.readFileSync(f, 'utf8').slice(0, 4000).includes(base);
990
+ } catch {
991
+ // A file that does not read names nothing.
992
+ }
993
+ if (by && named) return by;
994
+ }
995
+ return null;
996
+ }
997
+
998
+ /**
999
+ * The command that writes `file`: from its own mark, or, when it is
1000
+ * missing, from the files beside it (see `missingGeneratedCommand`); null
1001
+ * otherwise.
1002
+ * @param {string} file
1003
+ * @returns {string | null}
1004
+ */
1005
+ export function generatedSourceCommand(file) {
1006
+ return fs.existsSync(file)
1007
+ ? generatedFileCommand(file)
1008
+ : missingGeneratedCommand(file);
1009
+ }
1010
+
928
1011
  /** @param {string} file @returns {string} the start of a file, or '' when it cannot be read */
929
1012
  function fileHead(file) {
930
1013
  try {
@@ -1121,7 +1204,9 @@ function assertThemeSourceFile(filePath, cwd, mode = {}) {
1121
1204
  * output must stay inside, for a scratch build; `commandWords` names the
1122
1205
  * command in the rebuild hint; `prepareFamily`, `familyLoader`, and
1123
1206
  * `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
1207
+ * `colorModes` is the one color mode a calling command knows the theme has
1208
+ * (the theme editor, from its settings), written into the built module.
1209
+ * @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}} ThemeBuildHandOff
1125
1210
  */
1126
1211
 
1127
1212
  /**
@@ -1157,6 +1242,45 @@ export function setEditorFolderListener(listener) {
1157
1242
  * @typedef {{glob?: boolean, family?: boolean, familyKey?: string}} SuggestionShape
1158
1243
  */
1159
1244
 
1245
+ /**
1246
+ * The refusal a build gives the file it is given before it reads it, or
1247
+ * null: a file that is not there, and a folder. The build throws it, and a
1248
+ * suggested build is checked by it before it is offered.
1249
+ * @param {string} file as typed, from cwd
1250
+ * @param {BuildMode} options
1251
+ * @param {string} cwd
1252
+ * @returns {AstryxError | null}
1253
+ */
1254
+ export function buildInputProblem(file, options, cwd) {
1255
+ const filePath = path.resolve(cwd, file);
1256
+ if (!fs.existsSync(filePath))
1257
+ return new AstryxError(
1258
+ `File not found: ${filePath}`,
1259
+ themeSourceGuesses(file, cwd).map(guess => ({
1260
+ name: buildSuggestion(guess, options, cwd),
1261
+ reason: 'a theme source that exists',
1262
+ })),
1263
+ ERROR_CODES.ERR_FILE_NOT_FOUND,
1264
+ );
1265
+ if (fs.statSync(filePath).isDirectory())
1266
+ return new AstryxError(
1267
+ `${path.relative(cwd, filePath) || '.'} is a folder. Pass the theme file inside it.`,
1268
+ themeFilesIn(filePath).map(name => ({
1269
+ name: buildSuggestion(
1270
+ path
1271
+ .relative(cwd, path.join(filePath, name))
1272
+ .split(path.sep)
1273
+ .join('/'),
1274
+ options,
1275
+ cwd,
1276
+ ),
1277
+ reason: 'a theme source in that folder',
1278
+ })),
1279
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
1280
+ );
1281
+ return null;
1282
+ }
1283
+
1160
1284
  /**
1161
1285
  * The `theme build` command for `source` with the caller's mode flags, so a
1162
1286
  * suggestion never turns a check into a write or moves the outputs.
@@ -2630,9 +2754,13 @@ function isSyncLoaderLimitation(error) {
2630
2754
  * source export and old-Core adaptation checks keep treating that path as
2631
2755
  * degraded/fail-closed.
2632
2756
  *
2757
+ * On Node 22.15 and later, on every path, a stylesheet that a module in the
2758
+ * theme's graph imports loads as an empty module (`withEmptyStylesheets`): a
2759
+ * base theme's module can import its own stylesheet for the app's bundler.
2760
+ *
2633
2761
  * @param {string} filePath
2634
2762
  * @param {import('./core-interception.mjs').CoreInterception} [interception]
2635
- * @returns {Promise<{theme: any, exportName: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
2763
+ * @returns {Promise<{theme: any, exportName: string, degraded: {topLevelAwait: boolean, commonJs: boolean}, colorModes: ["light"] | ["dark"] | null}>}
2636
2764
  */
2637
2765
  // prettier-ignore
2638
2766
  async function importThemeModule(filePath, interception, /** @type {any} */ loader = undefined) {
@@ -2640,9 +2768,9 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
2640
2768
  loader ??
2641
2769
  createJiti(import.meta.url, {
2642
2770
  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,
2771
+ // The per-user transpile cache: an edited theme is transpiled again,
2772
+ // and the folder stays within its size limit.
2773
+ ...jitiCacheOptions(),
2646
2774
  jsx: true,
2647
2775
  extensions: THEME_MODULE_EXTENSIONS,
2648
2776
  ...(interception ? {virtualModules: interception.modules} : {}),
@@ -2659,7 +2787,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
2659
2787
  const commonJsPatch = interception.patchCommonJs(filePath);
2660
2788
  try {
2661
2789
  try {
2662
- mod = jiti(filePath);
2790
+ mod = await withEmptyStylesheets(async () => jiti(filePath));
2663
2791
  } catch (error) {
2664
2792
  // Only a sync-loader limitation may fall back. Anything else is the
2665
2793
  // theme's own failure and belongs to the caller unchanged.
@@ -2668,14 +2796,16 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
2668
2796
  // Force asynchronous transformation instead of native import: this
2669
2797
  // keeps virtual Core interception active even when the module uses
2670
2798
  // 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
- });
2799
+ mod = await withEmptyStylesheets(() =>
2800
+ jiti.evalModule(fs.readFileSync(filePath, 'utf8'), {
2801
+ id: filePath,
2802
+ filename: filePath,
2803
+ ext: path.extname(filePath),
2804
+ cache: jiti.cache,
2805
+ async: true,
2806
+ forceTranspile: true,
2807
+ }),
2808
+ );
2679
2809
  }
2680
2810
  } finally {
2681
2811
  // Read after the load: the root is wrapped when the load requires it.
@@ -2683,7 +2813,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
2683
2813
  commonJsPatch.undo();
2684
2814
  }
2685
2815
  } else {
2686
- mod = await jiti.import(filePath);
2816
+ mod = await withEmptyStylesheets(() => jiti.import(filePath));
2687
2817
  }
2688
2818
 
2689
2819
  // Both loads hand back the module. The theme is read from the module's own
@@ -2692,15 +2822,22 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
2692
2822
  // `default` with the module), so the module can pass for the theme while
2693
2823
  // its own keys hide the theme's fields.
2694
2824
  const isModule = mod != null && typeof mod === 'object';
2825
+ // A theme with one color mode says so with a `colorModes` export beside
2826
+ // the theme (`['light']` or `['dark']`); the build carries it into the
2827
+ // built module.
2828
+ const colorModes = oneColorMode(
2829
+ isModule && Object.hasOwn(mod, 'colorModes') ? mod.colorModes : undefined,
2830
+ );
2695
2831
  const hasDefault = isModule && Object.hasOwn(mod, 'default');
2696
2832
  const defaultExport = hasDefault ? mod.default : undefined;
2697
2833
  if (isThemeObject(defaultExport)) {
2698
- return {theme: defaultExport, exportName: 'default', degraded};
2834
+ return {theme: defaultExport, exportName: 'default', degraded, colorModes};
2699
2835
  }
2700
2836
  if (isModule) {
2701
2837
  for (const [exportName, value] of Object.entries(mod)) {
2702
2838
  if (exportName === 'default' || exportName === 'module.exports') continue;
2703
- if (isThemeObject(value)) return {theme: value, exportName, degraded};
2839
+ if (isThemeObject(value))
2840
+ return {theme: value, exportName, degraded, colorModes};
2704
2841
  }
2705
2842
  }
2706
2843
  // The loader's interop answers a null default with the module itself, so
@@ -2722,7 +2859,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
2722
2859
  // be all it defines), or no name: the build's validation says what it
2723
2860
  // lacks.
2724
2861
  if (isPlainObject(defaultExport)) {
2725
- return {theme: defaultExport, exportName: 'default', degraded};
2862
+ return {theme: defaultExport, exportName: 'default', degraded, colorModes};
2726
2863
  }
2727
2864
  // A CommonJS module whose exports are the theme (`module.exports =
2728
2865
  // theme`) has no default of its own: interop answers `default` with
@@ -2731,7 +2868,7 @@ async function importThemeModule(filePath, interception, /** @type {any} */ load
2731
2868
  if (isModule && !hasDefault) {
2732
2869
  const exportsObject = mod.default ?? mod;
2733
2870
  if (isThemeObject(exportsObject)) {
2734
- return {theme: exportsObject, exportName: 'default', degraded};
2871
+ return {theme: exportsObject, exportName: 'default', degraded, colorModes};
2735
2872
  }
2736
2873
  }
2737
2874
 
@@ -2800,7 +2937,7 @@ function isThemeObject(value) {
2800
2937
  *
2801
2938
  * @param {string} filePath
2802
2939
  * @param {import('./core-interception.mjs').CoreInterception} [interception]
2803
- * @returns {Promise<{theme: any, exportName?: string, degraded: {topLevelAwait: boolean, commonJs: boolean}}>}
2940
+ * @returns {Promise<{theme: any, exportName?: string, degraded: {topLevelAwait: boolean, commonJs: boolean}, colorModes?: ['light'] | ['dark'] | null}>}
2804
2941
  */
2805
2942
  // prettier-ignore
2806
2943
  async function extractThemeDefinition(filePath, interception, /** @type {any} */ loader = undefined) {
@@ -2815,6 +2952,52 @@ async function extractThemeDefinition(filePath, interception, /** @type {any} */
2815
2952
  }
2816
2953
  }
2817
2954
 
2955
+ /**
2956
+ * The Core interception a standalone build loads a theme module with: none
2957
+ * when the selected Core generates adaptations itself and the theme's folder
2958
+ * resolves a Core of its own; else imports of Core are handed the selected
2959
+ * Core.
2960
+ * @param {string} filePath
2961
+ */
2962
+ function standaloneInterception(filePath) {
2963
+ return _generateAdaptationCSS && themeFolderResolvesCore(filePath)
2964
+ ? undefined
2965
+ : interceptCore(_coreThemeModule, _coreRootModule);
2966
+ }
2967
+
2968
+ /**
2969
+ * Load a theme module as a standalone build of it loads it (the Core the
2970
+ * build selects, the same loader and interception) and name the export the
2971
+ * build reads. Callers that must agree with the build on which theme a
2972
+ * module defines read it here, never from the module's text.
2973
+ * @param {string} file
2974
+ * @param {{cwd?: string}} [ctx]
2975
+ * @returns {Promise<{theme: any, exportName: string}>}
2976
+ */
2977
+ export async function loadThemeExport(file, {cwd = process.cwd()} = {}) {
2978
+ const filePath = path.resolve(cwd, file);
2979
+ await selectCore(cwd, {projectOnly: false});
2980
+ const {theme, exportName} = await extractThemeDefinition(
2981
+ filePath,
2982
+ standaloneInterception(filePath),
2983
+ );
2984
+ return {theme, exportName: exportName ?? 'default'};
2985
+ }
2986
+
2987
+ /**
2988
+ * A one-mode `colorModes` value (`['light']` or `['dark']`), or null for
2989
+ * anything else: a theme with both modes needs no export.
2990
+ * @param {unknown} value
2991
+ * @returns {['light'] | ['dark'] | null}
2992
+ */
2993
+ export function oneColorMode(value) {
2994
+ return Array.isArray(value) &&
2995
+ value.length === 1 &&
2996
+ (value[0] === 'light' || value[0] === 'dark')
2997
+ ? /** @type {['light'] | ['dark']} */ ([value[0]])
2998
+ : null;
2999
+ }
3000
+
2818
3001
  /** Names a theme module's exports must take; ends a shape failure. */
2819
3002
  const THEME_EXPORT_FIX =
2820
3003
  "Export the theme object: `export default defineTheme({name: 'my-theme', tokens: {...}})`, or a plain `export default {name: 'my-theme', tokens: {...}}`.";
@@ -3739,21 +3922,32 @@ async function themeBuildInternal(
3739
3922
  report = {},
3740
3923
  handOff = {},
3741
3924
  ) {
3925
+ // A blank --out names no file: the build would write files named by the
3926
+ // spaces alone.
3927
+ if (
3928
+ typeof options.out === 'string' &&
3929
+ options.out !== '' &&
3930
+ !options.out.trim()
3931
+ )
3932
+ throw new AstryxError(
3933
+ '--out is blank; name a file or folder, or leave out --out to write beside the source.',
3934
+ [
3935
+ {
3936
+ name: buildSuggestion(file, {...options, out: undefined}, cwd),
3937
+ reason: 'do this instead',
3938
+ },
3939
+ ],
3940
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
3941
+ );
3742
3942
  // A backslash in --out separates folders on every platform, as it does in
3743
3943
  // the other theme paths (a Windows path copied into a POSIX shell).
3744
3944
  if (typeof options.out === 'string' && options.out.includes('\\'))
3745
3945
  options = {...options, out: options.out.replace(/\\/g, '/')};
3746
3946
  const filePath = path.resolve(cwd, file);
3747
3947
 
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
- );
3948
+ {
3949
+ const problem = buildInputProblem(file, options, cwd);
3950
+ if (problem) throw problem;
3757
3951
  }
3758
3952
 
3759
3953
  // A theme the theme editor made is built from its settings by the editor;
@@ -3772,24 +3966,6 @@ async function themeBuildInternal(
3772
3966
  );
3773
3967
  }
3774
3968
 
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
3969
  assertThemeSourceFile(filePath, cwd, options);
3794
3970
 
3795
3971
  if (!report.compact) {
@@ -3814,10 +3990,7 @@ async function themeBuildInternal(
3814
3990
  // shared loader so exact authored parent identity stays CLI-private instead
3815
3991
  // of becoming a public DefinedTheme field.
3816
3992
  const interception =
3817
- handOff.familyInterception ??
3818
- (_generateAdaptationCSS && themeFolderResolvesCore(filePath)
3819
- ? undefined
3820
- : interceptCore(_coreThemeModule, _coreRootModule));
3993
+ handOff.familyInterception ?? standaloneInterception(filePath);
3821
3994
 
3822
3995
  // Extract theme definition
3823
3996
  let themeDef;
@@ -3825,6 +3998,9 @@ async function themeBuildInternal(
3825
3998
  let themeExportName;
3826
3999
  /** Paths through the load that interception could not fully observe. */
3827
4000
  let loadDegradation;
4001
+ /** The one color mode the theme module exports, or null for both. */
4002
+ /** @type {['light'] | ['dark'] | null} */
4003
+ let colorModes;
3828
4004
  /**
3829
4005
  * The theme file's bytes as loaded: read before and after the load, and the
3830
4006
  * registry scan below reads these rather than the file again. An editor's
@@ -3851,6 +4027,7 @@ async function themeBuildInternal(
3851
4027
  themeDef = loaded.theme;
3852
4028
  themeExportName = loaded.exportName;
3853
4029
  loadDegradation = loaded.degraded;
4030
+ colorModes = handOff.colorModes ?? loaded.colorModes ?? null;
3854
4031
  } catch (e) {
3855
4032
  const err = /** @type {Error} */ (e);
3856
4033
  const shown = path.relative(cwd, filePath) || filePath;
@@ -4482,10 +4659,18 @@ async function themeBuildInternal(
4482
4659
  ? {}
4483
4660
  : {cssFileName: path.basename(outPath)}),
4484
4661
  },
4485
- );
4662
+ ) +
4663
+ // The one color mode, beside the theme export (a two-mode theme
4664
+ // exports none, so its module is unchanged).
4665
+ (colorModes
4666
+ ? `export const colorModes = [${JSON.stringify(colorModes[0])}];\n`
4667
+ : '');
4486
4668
  const dtsContent =
4487
4669
  generatedHeader(headerSource, 'ts', buildCommand, versions) +
4488
- generateBuiltTypes(resolvedTheme || themeDef, iconInfo, variantsFileName);
4670
+ generateBuiltTypes(resolvedTheme || themeDef, iconInfo, variantsFileName) +
4671
+ (colorModes
4672
+ ? `export declare const colorModes: readonly [${JSON.stringify(colorModes[0])}];\n`
4673
+ : '');
4489
4674
 
4490
4675
  const unloadedFonts = [
4491
4676
  ...new Set([
@@ -4998,7 +5183,7 @@ function planFamilySources(files, cwd) {
4998
5183
  // prettier-ignore
4999
5184
  async function preloadFamilySource(filePath, loader, interception) {
5000
5185
  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}); } }
5186
+ 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
5187
  finally { patch.undo(); }
5003
5188
  }
5004
5189
 
@@ -5026,7 +5211,7 @@ export async function themeBuildFamily(
5026
5211
  await selectCore(cwd);
5027
5212
  const familyInterception = interceptCore(_coreThemeModule, _coreRootModule);
5028
5213
  // prettier-ignore
5029
- const familyLoader = createJiti(import.meta.url, {moduleCache: true, fsCache: false, interopDefault: false, jsx: true, extensions: THEME_MODULE_EXTENSIONS, virtualModules: familyInterception.modules});
5214
+ const familyLoader = createJiti(import.meta.url, {moduleCache: true, ...jitiCacheOptions(), interopDefault: false, jsx: true, extensions: THEME_MODULE_EXTENSIONS, virtualModules: familyInterception.modules});
5030
5215
  /** @type {any[]} */
5031
5216
  const prepared = [];
5032
5217
  for (const source of planFamilySources(files, cwd)) {
@@ -1,6 +1,13 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * The font families a CSS font-family value names, without generics,
6
+ * CSS-wide keywords or `var()` references (system families included).
7
+ * @param {string} value
8
+ * @returns {string[]}
9
+ */
10
+ export function namedFontFamilies(value: string): string[];
4
11
  /**
5
12
  * Collect the font families a resolved theme names but does not load —
6
13
  * every `--font-family-*` token plus every component-override `fontFamily`,
@@ -60,6 +60,11 @@ const SYSTEM_FAMILIES = new Set([
60
60
  'segoe ui',
61
61
  'segoe ui emoji',
62
62
  'segoe ui symbol',
63
+ // The weights Windows ships as families of their own.
64
+ 'segoe ui light',
65
+ 'segoe ui semilight',
66
+ 'segoe ui semibold',
67
+ 'segoe ui black',
63
68
  'roboto',
64
69
  'helvetica',
65
70
  'helvetica neue',
@@ -129,6 +134,18 @@ function splitFamilies(value) {
129
134
  return families;
130
135
  }
131
136
 
137
+ /**
138
+ * The font families a CSS font-family value names, without generics,
139
+ * CSS-wide keywords or `var()` references (system families included).
140
+ * @param {string} value
141
+ * @returns {string[]}
142
+ */
143
+ export function namedFontFamilies(value) {
144
+ return splitFamilies(value).filter(
145
+ family => !GENERIC_KEYWORDS.has(family.toLowerCase()),
146
+ );
147
+ }
148
+
132
149
  /**
133
150
  * Collect the font families a resolved theme names but does not load —
134
151
  * every `--font-family-*` token plus every component-override `fontFamily`,
@@ -137,6 +137,12 @@ export type ThemeAppEntry = {
137
137
  */
138
138
  fontStylesheet?: string | undefined;
139
139
  source: "bundled" | "package" | "local";
140
+ /**
141
+ * the one color mode the theme has, when its
142
+ * built module exports one (`colorModes`); the generated module then lists
143
+ * it in `themeModes`. Absent for a theme with both modes.
144
+ */
145
+ mode?: "light" | "dark" | undefined;
140
146
  };
141
147
  /**
142
148
  * astryx --json theme add <slug> [--import] / remove / use
@@ -149,6 +155,9 @@ export type ThemeAppResponse = {
149
155
  * `notes` is present only when the command did more than its change says:
150
156
  * it chose between a local and a package theme with one slug, replaced a
151
157
  * recorded owner, or dropped a recorded theme whose source is gone.
158
+ * `change.wireModes` is present when the module lists a theme's one color
159
+ * mode (`themeModes`) for the first time after the app was wired: the app's
160
+ * `Theme` then takes `mode={themeModes[defaultThemeSlug] ?? 'system'}`.
152
161
  */
153
162
  package?: string | undefined;
154
163
  data: {
@@ -160,6 +169,7 @@ export type ThemeAppResponse = {
160
169
  slug: string;
161
170
  changed: boolean;
162
171
  firstAdd: boolean;
172
+ wireModes?: true;
163
173
  };
164
174
  notes?: string[];
165
175
  };
@@ -92,6 +92,9 @@
92
92
  * @property {string} stylesheet production stylesheet import
93
93
  * @property {string} [fontStylesheet] package-owned font stylesheet import
94
94
  * @property {'bundled'|'package'|'local'} source
95
+ * @property {'light'|'dark'} [mode] the one color mode the theme has, when its
96
+ * built module exports one (`colorModes`); the generated module then lists
97
+ * it in `themeModes`. Absent for a theme with both modes.
95
98
  */
96
99
 
97
100
  /**
@@ -103,7 +106,10 @@
103
106
  * `notes` is present only when the command did more than its change says:
104
107
  * it chose between a local and a package theme with one slug, replaced a
105
108
  * recorded owner, or dropped a recorded theme whose source is gone.
106
- * @property {{themes: ThemeAppEntry[], default: string, modulePath: string, change: {action: 'add'|'remove'|'use', slug: string, changed: boolean, firstAdd: boolean}, notes?: string[]}} data
109
+ * `change.wireModes` is present when the module lists a theme's one color
110
+ * mode (`themeModes`) for the first time after the app was wired: the app's
111
+ * `Theme` then takes `mode={themeModes[defaultThemeSlug] ?? 'system'}`.
112
+ * @property {{themes: ThemeAppEntry[], default: string, modulePath: string, change: {action: 'add'|'remove'|'use', slug: string, changed: boolean, firstAdd: boolean, wireModes?: true}, notes?: string[]}} data
107
113
  */
108
114
 
109
115
  /**