@astryxdesign/cli 0.7.16 → 0.7.17-canary.g335a172

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 (339) 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.mjs +69 -16
  13. package/api/build/kit/start.d.mts +5 -4
  14. package/api/build/kit/start.mjs +12 -8
  15. package/api/build/kit/weights.d.mts +16 -3
  16. package/api/build/kit/weights.json +1 -1
  17. package/api/build/kit/weights.mjs +251 -35
  18. package/api/build/kit/word-model.d.mts +23 -0
  19. package/api/build/kit/word-model.mjs +46 -0
  20. package/api/build/kit/words.d.mts +48 -0
  21. package/api/build/kit/words.mjs +90 -1
  22. package/api/component/__fixtures__/resolutions/modules.txt +4 -5
  23. package/api/component/list/list.d.mts +1 -1
  24. package/api/component/list/list.mjs +48 -6
  25. package/api/discover/_adapter.d.mts +1 -1
  26. package/api/discover/search/search.mjs +3 -2
  27. package/api/docs/_adapter.d.mts +26 -2
  28. package/api/docs/_adapter.mjs +219 -6
  29. package/api/docs/docs.d.mts +3 -0
  30. package/api/docs/docs.doc.mjs +7 -1
  31. package/api/docs/docs.mjs +12 -0
  32. package/api/docs/docs.type.d.mts +5 -0
  33. package/api/docs/docs.type.mjs +2 -0
  34. package/api/docs/node/node.mjs +1 -1
  35. package/api/doctor/_adapter.d.mts +27 -5
  36. package/api/doctor/_adapter.mjs +83 -10
  37. package/api/doctor/built-checks.mjs +40 -14
  38. package/api/doctor/doctor.d.mts +4 -3
  39. package/api/doctor/doctor.mjs +14 -7
  40. package/api/doctor/theme-checks.mjs +121 -17
  41. package/api/icon/_records.mjs +2 -1
  42. package/api/index.d.mts +2 -0
  43. package/api/index.mjs +2 -0
  44. package/api/integration/_adapter.d.mts +44 -0
  45. package/api/integration/_adapter.mjs +77 -1
  46. package/api/integration/authoring-checks.mjs +6 -6
  47. package/api/integration/example-scope.d.mts +14 -0
  48. package/api/integration/example-scope.mjs +44 -0
  49. package/api/integration/example-scope.type.d.mts +29 -0
  50. package/api/integration/example-scope.type.mjs +25 -0
  51. package/api/integration/integrationExampleScope.doc.d.mts +11 -0
  52. package/api/integration/integrationExampleScope.doc.mjs +59 -0
  53. package/api/integration/validate-integration.mjs +19 -1
  54. package/api/integration/validate-integration.type.d.mts +9 -0
  55. package/api/integration/validate-integration.type.mjs +1 -1
  56. package/api/integration/validateIntegration.doc.mjs +1 -1
  57. package/api/render/_adapter.mjs +591 -195
  58. package/api/render/render.doc.mjs +11 -3
  59. package/api/render/render.type.d.mts +52 -0
  60. package/api/render/render.type.mjs +31 -1
  61. package/api/search/ORDERING.md +1 -1
  62. package/api/search/_candidate-score.mjs +51 -32
  63. package/api/search/_fit-order.mjs +3 -3
  64. package/api/search/_gather-components.d.mts +3 -2
  65. package/api/search/_gather-components.mjs +12 -3
  66. package/api/search/_lexical.d.mts +5 -0
  67. package/api/search/_lexical.mjs +8 -2
  68. package/api/search/_result.d.mts +11 -9
  69. package/api/search/_result.mjs +4 -4
  70. package/api/search/_score.d.mts +6 -1
  71. package/api/search/_score.mjs +15 -3
  72. package/api/search/search-index.mjs +7 -1
  73. package/api/search/search.d.mts +1 -1
  74. package/api/theme/_adapter.mjs +12 -1
  75. package/api/theme/build/build.d.mts +60 -0
  76. package/api/theme/build/build.mjs +210 -54
  77. package/api/theme/build/font-warning.d.mts +8 -0
  78. package/api/theme/build/font-warning.mjs +19 -0
  79. package/api/theme/theme.type.d.mts +10 -0
  80. package/api/theme/theme.type.mjs +7 -1
  81. package/api/theme-edit/_adapter.d.mts +55 -0
  82. package/api/theme-edit/_adapter.mjs +673 -42
  83. package/api/theme-edit/_check.d.mts +28 -22
  84. package/api/theme-edit/_check.mjs +1858 -312
  85. package/api/theme-edit/_color.d.mts +10 -0
  86. package/api/theme-edit/_color.mjs +49 -1
  87. package/api/theme-edit/_compiler.mjs +9 -0
  88. package/api/theme-edit/_context.mjs +60 -3
  89. package/api/theme-edit/_css.mjs +21 -1
  90. package/api/theme-edit/_edit.d.mts +22 -0
  91. package/api/theme-edit/_edit.mjs +1533 -92
  92. package/api/theme-edit/_how-commands.d.mts +57 -0
  93. package/api/theme-edit/_how-commands.mjs +587 -1
  94. package/api/theme-edit/_how-question.d.mts +78 -0
  95. package/api/theme-edit/_how-question.mjs +4716 -235
  96. package/api/theme-edit/_how.mjs +134 -8
  97. package/api/theme-edit/_marks.d.mts +31 -5
  98. package/api/theme-edit/_marks.mjs +57 -5
  99. package/api/theme-edit/_normal.d.mts +219 -0
  100. package/api/theme-edit/_normal.mjs +1041 -0
  101. package/api/theme-edit/_palette.mjs +10 -4
  102. package/api/theme-edit/_parts.d.mts +8 -0
  103. package/api/theme-edit/_parts.mjs +103 -2
  104. package/api/theme-edit/_playwright-picture.d.mts +4 -0
  105. package/api/theme-edit/_playwright-picture.mjs +34 -0
  106. package/api/theme-edit/_preview-app.d.mts +7 -1
  107. package/api/theme-edit/_preview-app.mjs +394 -74
  108. package/api/theme-edit/_preview.d.mts +69 -8
  109. package/api/theme-edit/_preview.mjs +531 -108
  110. package/api/theme-edit/_settings.d.mts +243 -6
  111. package/api/theme-edit/_settings.mjs +2415 -147
  112. package/api/theme-edit/_tables.d.mts +6 -0
  113. package/api/theme-edit/_tables.mjs +44 -1
  114. package/api/theme-edit/_vet.d.mts +18 -0
  115. package/api/theme-edit/_vet.mjs +32 -0
  116. package/api/theme-edit/theme-edit.type.d.mts +10 -1
  117. package/api/theme-edit/theme-edit.type.mjs +4 -1
  118. package/api/theme-edit/themeEditHow.doc.mjs +1 -1
  119. package/api/theme-edit/themeEditNew.doc.mjs +1 -1
  120. package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
  121. package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
  122. package/api/upgrade/run/run.mjs +4 -3
  123. package/assets/codemods/integration-discovery.mjs +2 -1
  124. package/assets/codemods/run-codemod.mjs +87 -7
  125. package/assets/codemods/transforms/next/index.mjs +11 -1
  126. package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
  127. package/assets/component-list.generated.json +1 -0
  128. package/assets/docs/author-a-theme.doc.mjs +1 -0
  129. package/assets/docs/theme.doc.dense.mjs +2 -2
  130. package/assets/docs/theme.doc.mjs +1 -1
  131. package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
  132. package/assets/docs/tree/checks.doc.mjs +1 -1
  133. package/assets/docs/tree/cli-command.doc.mjs +2 -3
  134. package/assets/docs/tree/render-pages.doc.mjs +44 -3
  135. package/assets/docs/tree/single-component.doc.mjs +4 -0
  136. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  137. package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
  138. package/assets/docs/use-a-theme.doc.mjs +1 -1
  139. package/assets/docs.generated.json +2 -2
  140. package/assets/self-audit.generated.json +1 -1
  141. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
  142. package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
  143. package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
  144. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
  145. package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
  146. package/assets/templates/components.generated.json +1 -1
  147. package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
  148. package/assets/templates/pages/ai-chat-landing/template.doc.mjs +2 -1
  149. package/assets/templates/pages/blank/template.doc.mjs +1 -1
  150. package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
  151. package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
  152. package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
  153. package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
  154. package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
  155. package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
  156. package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
  157. package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
  158. package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
  159. package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
  160. package/assets/templates/pages/documentation/template.doc.mjs +4 -1
  161. package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
  162. package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
  163. package/assets/templates/pages/editor/template.doc.mjs +2 -8
  164. package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
  165. package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
  166. package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
  167. package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
  168. package/assets/templates/pages/ide/page.tsx +24 -2
  169. package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
  170. package/assets/templates/pages/library/template.doc.mjs +4 -1
  171. package/assets/templates/pages/login/template.doc.mjs +2 -1
  172. package/assets/templates/pages/login-card/template.doc.mjs +2 -1
  173. package/assets/templates/pages/login-split/template.doc.mjs +2 -1
  174. package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
  175. package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
  176. package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
  177. package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
  178. package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
  179. package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
  180. package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
  181. package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
  182. package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
  183. package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
  184. package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
  185. package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
  186. package/assets/templates/pages/table-page/template.doc.mjs +5 -4
  187. package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
  188. package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
  189. package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
  190. package/assets/theme.template.ts +6 -0
  191. package/authoring/debug/parse.d.mts +3 -3
  192. package/authoring/doctypes/_schema.d.mts +3 -3
  193. package/authoring/doctypes/command/command.doc.mjs +1 -1
  194. package/authoring/doctypes/component/categories.d.mts +37 -0
  195. package/authoring/doctypes/component/categories.mjs +54 -0
  196. package/authoring/doctypes/template/template.doc.mjs +1 -1
  197. package/authoring/doctypes/template/type.ts +9 -0
  198. package/authoring/example/example.doc.d.mts +12 -0
  199. package/authoring/example/example.doc.mjs +69 -0
  200. package/authoring/example/preview.d.mts +92 -0
  201. package/authoring/example/preview.mjs +994 -0
  202. package/authoring/example/type.ts +102 -0
  203. package/authoring/index.d.mts +1 -0
  204. package/authoring/index.d.ts +12 -0
  205. package/authoring/index.mjs +3 -1
  206. package/clients/cli/bin/astryx.mjs +6 -9
  207. package/clients/cli/build-id.generated.json +1 -1
  208. package/clients/cli/commands/component.doc.mjs +1 -1
  209. package/clients/cli/commands/component.mjs +22 -3
  210. package/clients/cli/commands/docs.doc.mjs +7 -1
  211. package/clients/cli/commands/docs.mjs +3 -1
  212. package/clients/cli/commands/doctor.mjs +32 -14
  213. package/clients/cli/commands/experimental/render.mjs +42 -1
  214. package/clients/cli/commands/experimental/theme.mjs +145 -16
  215. package/clients/cli/commands/experimental-render.doc.mjs +2 -2
  216. package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
  217. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
  218. package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
  219. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
  220. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
  221. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
  222. package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
  223. package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
  224. package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
  225. package/clients/cli/commands/search.doc.mjs +2 -1
  226. package/clients/cli/commands/search.mjs +6 -1
  227. package/clients/cli/commands/template.mjs +4 -2
  228. package/clients/cli/commands/theme-build.doc.mjs +5 -1
  229. package/clients/cli/commands/theme.doc.mjs +1 -1
  230. package/clients/cli/commands/theme.mjs +183 -6
  231. package/clients/cli/commands/upgrade.mjs +42 -7
  232. package/clients/cli/index.mjs +1 -1
  233. package/clients/cli/lib/cli-error.mjs +2 -1
  234. package/clients/cli/lib/component-format.mjs +205 -98
  235. package/clients/cli/lib/hook-format.mjs +9 -19
  236. package/clients/cli/lib/json-shim.mjs +77 -21
  237. package/clients/cli/lib/manifest.mjs +3 -2
  238. package/clients/cli/manifest.generated.json +1 -1
  239. package/foundation/agent-docs/agent-docs.mjs +1 -1
  240. package/foundation/config/theme-state.d.mts +13 -1
  241. package/foundation/config/theme-state.mjs +47 -7
  242. package/foundation/discovery/authoring-self-docs.mjs +1 -0
  243. package/foundation/discovery/component-discovery.d.mts +11 -0
  244. package/foundation/discovery/component-discovery.mjs +56 -8
  245. package/foundation/discovery/component-replacement.mjs +130 -1
  246. package/foundation/discovery/copied-passages.mjs +2 -1
  247. package/foundation/discovery/doc-types.mjs +4 -3
  248. package/foundation/discovery/entry-name-files.d.mts +43 -0
  249. package/foundation/discovery/entry-name-files.mjs +264 -0
  250. package/foundation/discovery/hook-discovery.d.mts +8 -2
  251. package/foundation/discovery/hook-discovery.mjs +22 -8
  252. package/foundation/discovery/icon-definition-discovery.mjs +2 -1
  253. package/foundation/discovery/icon-set-checks.mjs +2 -1
  254. package/foundation/discovery/icon-set-discovery.mjs +2 -1
  255. package/foundation/discovery/integration-doc-files.mjs +2 -1
  256. package/foundation/discovery/package-exports.d.mts +10 -0
  257. package/foundation/discovery/package-exports.mjs +56 -3
  258. package/foundation/discovery/prop-drift.mjs +9 -9
  259. package/foundation/discovery/runner-allowlist.d.mts +1 -0
  260. package/foundation/discovery/runner-allowlist.mjs +2 -0
  261. package/foundation/discovery/stored-component-list.d.mts +43 -0
  262. package/foundation/discovery/stored-component-list.mjs +90 -0
  263. package/foundation/discovery/stored-self-audit.d.mts +26 -10
  264. package/foundation/discovery/stored-self-audit.mjs +38 -18
  265. package/foundation/discovery/template-adapter.d.mts +52 -0
  266. package/foundation/discovery/template-adapter.mjs +176 -12
  267. package/foundation/discovery/template-icons.mjs +2 -1
  268. package/foundation/discovery/theme-discovery.mjs +3 -2
  269. package/foundation/discovery/theme-imports.d.mts +14 -0
  270. package/foundation/discovery/theme-imports.mjs +43 -1
  271. package/foundation/discovery/theming-targets.mjs +3 -2
  272. package/foundation/doc-compiler/import.mjs +7 -1
  273. package/foundation/doc-compiler/inputs.mjs +3 -2
  274. package/foundation/doc-compiler/parse-readable.mjs +4 -1
  275. package/foundation/doc-compiler/stored-docs.d.mts +22 -0
  276. package/foundation/doc-compiler/stored-docs.mjs +49 -0
  277. package/foundation/env/semver.mjs +3 -1
  278. package/foundation/fonts/font-stylesheet.d.mts +31 -0
  279. package/foundation/fonts/font-stylesheet.mjs +115 -0
  280. package/foundation/fs/cache-eviction.d.mts +21 -0
  281. package/foundation/fs/cache-eviction.mjs +73 -0
  282. package/foundation/fs/file-protection.mjs +4 -3
  283. package/foundation/fs/gather-cache.d.mts +25 -4
  284. package/foundation/fs/gather-cache.mjs +164 -55
  285. package/foundation/fs/jiti-cache.d.mts +19 -1
  286. package/foundation/fs/jiti-cache.mjs +130 -6
  287. package/foundation/fs/kept-tree.d.mts +60 -0
  288. package/foundation/fs/kept-tree.mjs +154 -0
  289. package/foundation/fs/listing-cache.d.mts +7 -0
  290. package/foundation/fs/listing-cache.mjs +10 -0
  291. package/foundation/fs/module-loader.d.mts +24 -2
  292. package/foundation/fs/module-loader.mjs +94 -21
  293. package/foundation/fs/paths.d.mts +18 -0
  294. package/foundation/fs/paths.mjs +15 -2
  295. package/foundation/identity/provider-identity.d.mts +6 -0
  296. package/foundation/identity/provider-identity.mjs +10 -1
  297. package/foundation/integrations/contribution-inventory.mjs +4 -3
  298. package/foundation/integrations/example-code.d.mts +63 -0
  299. package/foundation/integrations/example-code.mjs +416 -0
  300. package/foundation/integrations/public-imports.d.mts +9 -0
  301. package/foundation/integrations/public-imports.mjs +3 -2
  302. package/foundation/integrations/validate-contributions.mjs +17 -45
  303. package/foundation/render/embedded-files.d.mts +6 -0
  304. package/foundation/render/embedded-files.mjs +25 -5
  305. package/foundation/render/embedded-imports.d.mts +39 -7
  306. package/foundation/render/embedded-imports.mjs +66 -27
  307. package/foundation/render/file-header.d.mts +66 -0
  308. package/foundation/render/file-header.mjs +118 -0
  309. package/foundation/render/host-answer.d.mts +18 -0
  310. package/foundation/render/host-answer.mjs +46 -0
  311. package/foundation/render/host-exit.d.mts +1 -0
  312. package/foundation/render/host-exit.mjs +6 -1
  313. package/foundation/render/html-reader.d.mts +55 -2
  314. package/foundation/render/html-reader.mjs +145 -26
  315. package/foundation/render/markup-edits.d.mts +57 -0
  316. package/foundation/render/markup-edits.mjs +182 -0
  317. package/foundation/render/page-host.mjs +29 -12
  318. package/foundation/render/page-worker.mjs +121 -13
  319. package/foundation/render/rebuild.mjs +2 -1
  320. package/foundation/render/render-page.d.mts +35 -3
  321. package/foundation/render/render-page.mjs +316 -42
  322. package/foundation/render/source-block.d.mts +85 -6
  323. package/foundation/render/source-block.mjs +211 -20
  324. package/foundation/render/ts-paths.d.mts +69 -6
  325. package/foundation/render/ts-paths.mjs +326 -40
  326. package/foundation/response/error-codes.d.mts +3 -1
  327. package/foundation/response/error-codes.d.ts +1 -0
  328. package/foundation/response/error-codes.doc.mjs +12 -1
  329. package/foundation/response/error-codes.mjs +11 -1
  330. package/foundation/response/response-types.doc.mjs +2 -2
  331. package/foundation/text/compare-text.d.mts +14 -0
  332. package/foundation/text/compare-text.mjs +68 -0
  333. package/foundation/text/string-utils.d.mts +3 -2
  334. package/foundation/text/string-utils.mjs +18 -4
  335. package/foundation/text/suggest-order.d.mts +9 -0
  336. package/foundation/text/suggest-order.mjs +15 -1
  337. package/foundation/xle/expand.mjs +2 -1
  338. package/host/index.mjs +8 -6
  339. 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,20 @@ async function extractThemeDefinition(filePath, interception, /** @type {any} */
2815
2952
  }
2816
2953
  }
2817
2954
 
2955
+ /**
2956
+ * A one-mode `colorModes` value (`['light']` or `['dark']`), or null for
2957
+ * anything else: a theme with both modes needs no export.
2958
+ * @param {unknown} value
2959
+ * @returns {['light'] | ['dark'] | null}
2960
+ */
2961
+ export function oneColorMode(value) {
2962
+ return Array.isArray(value) &&
2963
+ value.length === 1 &&
2964
+ (value[0] === 'light' || value[0] === 'dark')
2965
+ ? /** @type {['light'] | ['dark']} */ ([value[0]])
2966
+ : null;
2967
+ }
2968
+
2818
2969
  /** Names a theme module's exports must take; ends a shape failure. */
2819
2970
  const THEME_EXPORT_FIX =
2820
2971
  "Export the theme object: `export default defineTheme({name: 'my-theme', tokens: {...}})`, or a plain `export default {name: 'my-theme', tokens: {...}}`.";
@@ -3739,21 +3890,32 @@ async function themeBuildInternal(
3739
3890
  report = {},
3740
3891
  handOff = {},
3741
3892
  ) {
3893
+ // A blank --out names no file: the build would write files named by the
3894
+ // spaces alone.
3895
+ if (
3896
+ typeof options.out === 'string' &&
3897
+ options.out !== '' &&
3898
+ !options.out.trim()
3899
+ )
3900
+ throw new AstryxError(
3901
+ '--out is blank; name a file or folder, or leave out --out to write beside the source.',
3902
+ [
3903
+ {
3904
+ name: buildSuggestion(file, {...options, out: undefined}, cwd),
3905
+ reason: 'do this instead',
3906
+ },
3907
+ ],
3908
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
3909
+ );
3742
3910
  // A backslash in --out separates folders on every platform, as it does in
3743
3911
  // the other theme paths (a Windows path copied into a POSIX shell).
3744
3912
  if (typeof options.out === 'string' && options.out.includes('\\'))
3745
3913
  options = {...options, out: options.out.replace(/\\/g, '/')};
3746
3914
  const filePath = path.resolve(cwd, file);
3747
3915
 
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
- );
3916
+ {
3917
+ const problem = buildInputProblem(file, options, cwd);
3918
+ if (problem) throw problem;
3757
3919
  }
3758
3920
 
3759
3921
  // A theme the theme editor made is built from its settings by the editor;
@@ -3772,24 +3934,6 @@ async function themeBuildInternal(
3772
3934
  );
3773
3935
  }
3774
3936
 
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
3937
  assertThemeSourceFile(filePath, cwd, options);
3794
3938
 
3795
3939
  if (!report.compact) {
@@ -3825,6 +3969,9 @@ async function themeBuildInternal(
3825
3969
  let themeExportName;
3826
3970
  /** Paths through the load that interception could not fully observe. */
3827
3971
  let loadDegradation;
3972
+ /** The one color mode the theme module exports, or null for both. */
3973
+ /** @type {['light'] | ['dark'] | null} */
3974
+ let colorModes;
3828
3975
  /**
3829
3976
  * The theme file's bytes as loaded: read before and after the load, and the
3830
3977
  * registry scan below reads these rather than the file again. An editor's
@@ -3851,6 +3998,7 @@ async function themeBuildInternal(
3851
3998
  themeDef = loaded.theme;
3852
3999
  themeExportName = loaded.exportName;
3853
4000
  loadDegradation = loaded.degraded;
4001
+ colorModes = handOff.colorModes ?? loaded.colorModes ?? null;
3854
4002
  } catch (e) {
3855
4003
  const err = /** @type {Error} */ (e);
3856
4004
  const shown = path.relative(cwd, filePath) || filePath;
@@ -4482,10 +4630,18 @@ async function themeBuildInternal(
4482
4630
  ? {}
4483
4631
  : {cssFileName: path.basename(outPath)}),
4484
4632
  },
4485
- );
4633
+ ) +
4634
+ // The one color mode, beside the theme export (a two-mode theme
4635
+ // exports none, so its module is unchanged).
4636
+ (colorModes
4637
+ ? `export const colorModes = [${JSON.stringify(colorModes[0])}];\n`
4638
+ : '');
4486
4639
  const dtsContent =
4487
4640
  generatedHeader(headerSource, 'ts', buildCommand, versions) +
4488
- generateBuiltTypes(resolvedTheme || themeDef, iconInfo, variantsFileName);
4641
+ generateBuiltTypes(resolvedTheme || themeDef, iconInfo, variantsFileName) +
4642
+ (colorModes
4643
+ ? `export declare const colorModes: readonly [${JSON.stringify(colorModes[0])}];\n`
4644
+ : '');
4489
4645
 
4490
4646
  const unloadedFonts = [
4491
4647
  ...new Set([
@@ -4998,7 +5154,7 @@ function planFamilySources(files, cwd) {
4998
5154
  // prettier-ignore
4999
5155
  async function preloadFamilySource(filePath, loader, interception) {
5000
5156
  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}); } }
5157
+ 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
5158
  finally { patch.undo(); }
5003
5159
  }
5004
5160
 
@@ -5026,7 +5182,7 @@ export async function themeBuildFamily(
5026
5182
  await selectCore(cwd);
5027
5183
  const familyInterception = interceptCore(_coreThemeModule, _coreRootModule);
5028
5184
  // prettier-ignore
5029
- const familyLoader = createJiti(import.meta.url, {moduleCache: true, fsCache: false, interopDefault: false, jsx: true, extensions: THEME_MODULE_EXTENSIONS, virtualModules: familyInterception.modules});
5185
+ const familyLoader = createJiti(import.meta.url, {moduleCache: true, ...jitiCacheOptions(), interopDefault: false, jsx: true, extensions: THEME_MODULE_EXTENSIONS, virtualModules: familyInterception.modules});
5030
5186
  /** @type {any[]} */
5031
5187
  const prepared = [];
5032
5188
  for (const source of planFamilySources(files, cwd)) {
@@ -1,6 +1,14 @@
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 that something has to
6
+ * load: its names without generics, CSS-wide keywords, `var()` references
7
+ * or known system families.
8
+ * @param {string} value
9
+ * @returns {string[]}
10
+ */
11
+ export function loadableFontFamilies(value: string): string[];
4
12
  /**
5
13
  * Collect the font families a resolved theme names but does not load —
6
14
  * 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,20 @@ function splitFamilies(value) {
129
134
  return families;
130
135
  }
131
136
 
137
+ /**
138
+ * The font families a CSS font-family value names that something has to
139
+ * load: its names without generics, CSS-wide keywords, `var()` references
140
+ * or known system families.
141
+ * @param {string} value
142
+ * @returns {string[]}
143
+ */
144
+ export function loadableFontFamilies(value) {
145
+ return splitFamilies(value).filter(family => {
146
+ const key = family.toLowerCase();
147
+ return !GENERIC_KEYWORDS.has(key) && !SYSTEM_FAMILIES.has(key);
148
+ });
149
+ }
150
+
132
151
  /**
133
152
  * Collect the font families a resolved theme names but does not load —
134
153
  * 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
  /**
@@ -30,6 +30,25 @@ export function projectRoot(cwd: string): string;
30
30
  * @returns {AstryxError | null}
31
31
  */
32
32
  export function editorThemeRefusal(err: AstryxError, cwd: string): AstryxError | null;
33
+ /**
34
+ * The editor themes of the app the folder `cwd` is in, by name; none when
35
+ * the folder is in no app or its themes cannot be read.
36
+ * @param {string} cwd
37
+ * @returns {string[]}
38
+ */
39
+ export function editorThemesAt(cwd: string): string[];
40
+ /**
41
+ * A refused compile whose first suggestion is another compile: that compile
42
+ * is run through compile's own checks before it is offered (in memory,
43
+ * nothing built), and each repair a refusal of it offers is folded into the
44
+ * one line. An --out outside the working folder is dropped, and the reason
45
+ * says why; when the rest cannot be repaired, the reason says so. A line
46
+ * that starts with `cd` runs elsewhere, so it is not checked from here.
47
+ * @param {AstryxError} err
48
+ * @param {string} cwd
49
+ * @returns {Promise<AstryxError>}
50
+ */
51
+ export function editorFollowCompile(err: AstryxError, cwd: string): Promise<AstryxError>;
33
52
  /**
34
53
  * A refusal before `compile` runs on an editor theme's files, or null: the
35
54
  * editor's generated settings are not a theme source, `--family` does not
@@ -59,6 +78,42 @@ export function editorCompileProblem(files: string[], { cwd, check, family, icon
59
78
  export function editorThemeHold(files: string[], { cwd }: {
60
79
  cwd: string;
61
80
  }): Promise<() => Promise<void>>;
81
+ /**
82
+ * For `compile` of an editor theme: `appCopyStale` for its result data when
83
+ * the app copy is behind (the same line set and show give); null for any
84
+ * other file or a current copy.
85
+ * @param {string} file the path as given
86
+ * @param {string} cwd
87
+ * @param {{check: boolean, upToDate?: boolean}} opts `upToDate`: the
88
+ * check's own verdict on the theme's outputs
89
+ * @returns {Promise<Record<string, unknown> | null>}
90
+ */
91
+ export function editorBuildExtra(file: string, cwd: string, opts: {
92
+ check: boolean;
93
+ upToDate?: boolean;
94
+ }): Promise<Record<string, unknown> | null>;
95
+ /**
96
+ * For `compile` of an editor theme's own source (themes/<t>/<t>.theme.ts):
97
+ * the one color mode a light-only or dark-only theme has, which its source
98
+ * cannot say, for the build to write into the built module. Null for any
99
+ * other file (the app copy's source re-exports it from its build).
100
+ * @param {string} file the path as given
101
+ * @param {string} cwd
102
+ * @returns {['light'] | ['dark'] | null}
103
+ */
104
+ export function editorColorModes(file: string, cwd: string): ["light"] | ["dark"] | null;
105
+ /**
106
+ * For `compile` of an editor theme (themes/<t>/ or its app copy's source):
107
+ * whether a font family is loaded by the app copy's font stylesheet as
108
+ * this compile writes it (src/themes/<t>/<t>.fonts.css, from the fonts the
109
+ * theme loads now: an @fontsource package by its name, a stylesheet by the
110
+ * `family=` it requests), so the build's "named but not loaded" notice
111
+ * leaves it out. Null for any other file.
112
+ * @param {string} file the path as given
113
+ * @param {string} cwd
114
+ * @returns {Promise<((family: string) => boolean) | null>}
115
+ */
116
+ export function editorLoadedFonts(file: string, cwd: string): Promise<((family: string) => boolean) | null>;
62
117
  /**
63
118
  * For `compile` of a file that is not there: when it is an editor theme's
64
119
  * own source (`themes/<t>/<t>.theme.ts` beside its settings), the command