@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
@@ -158,6 +158,31 @@ export function listTemplates(): string[];
158
158
  * @returns {string | null}
159
159
  */
160
160
  export function findPageDocFile(dirPath: string): string | null;
161
+ /**
162
+ * The ids of Core's templates that `keep` accepts, read from file names: each
163
+ * page folder, and each block doc that has its same-stem source. Discovery
164
+ * gives Core's templates exactly these ids. Only a kept block's source is
165
+ * looked for.
166
+ * @param {(id: string) => boolean} [keep]
167
+ * @returns {string[]}
168
+ */
169
+ export function coreTemplateIds(keep?: (id: string) => boolean): string[];
170
+ /**
171
+ * Which template files can give an id that folds to `wanted`, read from a
172
+ * kept summary of file names: `blocks` false means {@link coreTemplateIds}
173
+ * gives no block id that folds to it, and `listed` says whether any of the
174
+ * integrations ships a template doc whose id ({@link integrationTemplateIds})
175
+ * folds to it.
176
+ * @param {Array<{templates?: string}>} integrations
177
+ * @param {string} wanted a folded name
178
+ * @returns {{blocks: boolean, listed: boolean}}
179
+ */
180
+ export function templateFilesNaming(integrations: Array<{
181
+ templates?: string;
182
+ }>, wanted: string): {
183
+ blocks: boolean;
184
+ listed: boolean;
185
+ };
161
186
  /**
162
187
  * Discover only the templates built into @astryxdesign/core. Integration
163
188
  * authoring checks use this narrower surface so a broken project config or a
@@ -214,6 +239,33 @@ export function discoverAllWithErrors(cwd?: string): Promise<{
214
239
  templates: DiscoveredTemplate[];
215
240
  errors: Array<TemplateDiscoveryError | TemplateReplacementError>;
216
241
  }>;
242
+ /**
243
+ * The id of each template doc an integration ships, valid or not, read from
244
+ * file names alone.
245
+ * @param {{templates?: string}} integration
246
+ * @returns {string[]}
247
+ */
248
+ export function integrationTemplateIds(integration: {
249
+ templates?: string;
250
+ }): string[];
251
+ /**
252
+ * Whether any template doc an integration ships can declare a replacement,
253
+ * read from its text without loading it.
254
+ * @param {{templates?: string}} integration
255
+ * @returns {boolean}
256
+ */
257
+ export function integrationMayReplaceTemplate(integration: {
258
+ templates?: string;
259
+ }): boolean;
260
+ /**
261
+ * Whether any template doc any of the integrations ships can declare a
262
+ * replacement, read from a kept summary of the docs' text.
263
+ * @param {Array<{templates?: string}>} integrations
264
+ * @returns {boolean}
265
+ */
266
+ export function integrationsMayReplaceTemplate(integrations: Array<{
267
+ templates?: string;
268
+ }>): boolean;
217
269
  /**
218
270
  * Discover the templates contributed by a SINGLE integration. Same per-template
219
271
  * rules as {@link discoverIntegrationTemplates} (same-stem source required,
@@ -24,6 +24,7 @@
24
24
 
25
25
  import * as fs from 'node:fs';
26
26
  import * as path from 'node:path';
27
+ import {fileURLToPath} from 'node:url';
27
28
  import {readDocView} from '../doc-compiler/read.mjs';
28
29
  import {importDocModule} from '../doc-compiler/import.mjs';
29
30
  import {readStore, storedKey} from '../doc-compiler/stored-docs.mjs';
@@ -40,9 +41,11 @@ import {
40
41
  TEMPLATE_COMPONENTS_FILE,
41
42
  } from './template-source-tree.mjs';
42
43
  import {persistedGather} from '../fs/gather-cache.mjs';
44
+ import {hasNameLine, keptTreeSummary, nameLines} from '../fs/kept-tree.mjs';
45
+ import {foldEntryName} from './entry-name-files.mjs';
43
46
  import {EXACT_CODEC} from '../fs/exact-codec.mjs';
44
- import {hostedRun} from '../runtime/package-root.mjs';
45
47
  import {babelParser} from '../runtime/lazy-dependencies.mjs';
48
+ import {compareText} from '../text/compare-text.mjs';
46
49
 
47
50
  /** Identity used for core (built-in) templates in package-scoped listings. */
48
51
  const CORE_PACKAGE = CORE_PROVIDER_ID;
@@ -1251,6 +1254,99 @@ async function discoverBlocks() {
1251
1254
  return blocks;
1252
1255
  }
1253
1256
 
1257
+ /**
1258
+ * The ids of Core's templates that `keep` accepts, read from file names: each
1259
+ * page folder, and each block doc that has its same-stem source. Discovery
1260
+ * gives Core's templates exactly these ids. Only a kept block's source is
1261
+ * looked for.
1262
+ * @param {(id: string) => boolean} [keep]
1263
+ * @returns {string[]}
1264
+ */
1265
+ export function coreTemplateIds(keep = () => true) {
1266
+ const ids = listTemplates().filter(keep);
1267
+ /** @param {string} dir */
1268
+ const walk = dir => {
1269
+ let entries;
1270
+ try {
1271
+ entries = fs.readdirSync(dir, {withFileTypes: true});
1272
+ } catch {
1273
+ return;
1274
+ }
1275
+ for (const entry of entries) {
1276
+ const full = path.join(dir, entry.name);
1277
+ if (entry.isDirectory()) {
1278
+ walk(full);
1279
+ continue;
1280
+ }
1281
+ if (!TEMPLATE_SUFFIX_RE.test(entry.name)) continue;
1282
+ const suffix = matchedTemplateSuffix(entry.name);
1283
+ if (!suffix) continue;
1284
+ const basename = entry.name.slice(0, -suffix.length);
1285
+ if (keep(basename) && fs.existsSync(path.join(dir, basename + '.tsx'))) {
1286
+ ids.push(basename);
1287
+ }
1288
+ }
1289
+ };
1290
+ walk(BLOCKS_DIR);
1291
+ return ids;
1292
+ }
1293
+
1294
+ /** This module's own file: its code decides the kept summaries' shape. */
1295
+ const OWN_FILE = fileURLToPath(import.meta.url);
1296
+
1297
+ /** The file of foldEntryName, which decides the template-ids summary too. */
1298
+ const FOLD_FILE = fileURLToPath(
1299
+ new URL('./entry-name-files.mjs', import.meta.url),
1300
+ );
1301
+
1302
+ /**
1303
+ * Which template files can give an id that folds to `wanted`, read from a
1304
+ * kept summary of file names: `blocks` false means {@link coreTemplateIds}
1305
+ * gives no block id that folds to it, and `listed` says whether any of the
1306
+ * integrations ships a template doc whose id ({@link integrationTemplateIds})
1307
+ * folds to it.
1308
+ * @param {Array<{templates?: string}>} integrations
1309
+ * @param {string} wanted a folded name
1310
+ * @returns {{blocks: boolean, listed: boolean}}
1311
+ */
1312
+ export function templateFilesNaming(integrations, wanted) {
1313
+ const roots = integrations.flatMap(integration =>
1314
+ typeof integration?.templates === 'string' && integration.templates !== ''
1315
+ ? [integration.templates]
1316
+ : [],
1317
+ );
1318
+ /** @type {Array<string | string[]>} */
1319
+ const [blocks, ...listed] = keptTreeSummary(
1320
+ {
1321
+ kind: 'template-ids',
1322
+ roots: [BLOCKS_DIR, ...roots],
1323
+ code: [OWN_FILE, FOLD_FILE],
1324
+ },
1325
+ trees =>
1326
+ trees.map(({folders}, at) => {
1327
+ const folded = new Set();
1328
+ for (const {rel, entries} of folders) {
1329
+ for (const {name, isDir} of entries) {
1330
+ if (isDir) continue;
1331
+ const suffix = matchedTemplateSuffix(name);
1332
+ if (!suffix) continue;
1333
+ // Core's block ids are stems; an integration's are paths.
1334
+ const id =
1335
+ at === 0
1336
+ ? name.slice(0, -suffix.length)
1337
+ : path.join(rel, name).slice(0, -suffix.length);
1338
+ folded.add(foldEntryName(id.split(path.sep).join('/')));
1339
+ }
1340
+ }
1341
+ return nameLines(folded);
1342
+ }),
1343
+ );
1344
+ return {
1345
+ blocks: hasNameLine(blocks, wanted),
1346
+ listed: listed.some(ids => hasNameLine(ids, wanted)),
1347
+ };
1348
+ }
1349
+
1254
1350
  /**
1255
1351
  * Discover blocks from external packages that declare `astryx.blocks` in
1256
1352
  * their package.json. Same shape as discoverBlocks() output.
@@ -1522,7 +1618,7 @@ export function applyTemplateReplacements(templates, declarationErrors = []) {
1522
1618
  });
1523
1619
 
1524
1620
  return {
1525
- templates: effective.sort((a, b) => a.name.localeCompare(b.name)),
1621
+ templates: effective.sort((a, b) => compareText(a.name, b.name)),
1526
1622
  errors,
1527
1623
  };
1528
1624
  }
@@ -1553,7 +1649,7 @@ async function discoverAllSources(cwd = process.cwd()) {
1553
1649
  */
1554
1650
  export async function discoverAllUnresolved(cwd = process.cwd()) {
1555
1651
  return (await discoverAllSources(cwd)).templates.sort((a, b) =>
1556
- a.name.localeCompare(b.name),
1652
+ compareText(a.name, b.name),
1557
1653
  );
1558
1654
  }
1559
1655
 
@@ -1580,15 +1676,10 @@ async function resolveAllSources(cwd = process.cwd()) {
1580
1676
  // a later run with every one unchanged reads the records back.
1581
1677
  return /** @type {Awaited<ReturnType<typeof resolveAllSourcesNow>>} */ (
1582
1678
  await persistedGather(
1583
- // The folder, and the copy of the CLI that answers with the
1584
- // integrations a host approves: outside a project the integrations
1585
- // beside the answering copy load too.
1586
- [
1587
- 'template-sources',
1588
- realDir(cwd),
1589
- CLI_ROOT,
1590
- hostedRun()?.integrations ?? [],
1591
- ],
1679
+ // The folder, and the copy of the CLI that answers: outside a project
1680
+ // the integrations beside the answering copy load too. A host's inputs
1681
+ // are in every entry's key (gather-cache.mjs).
1682
+ ['template-sources', realDir(cwd), CLI_ROOT],
1592
1683
  () => resolveAllSourcesNow(cwd),
1593
1684
  TEMPLATE_SOURCES_CODEC,
1594
1685
  )
@@ -1681,6 +1772,79 @@ function findIntegrationDocFiles(root) {
1681
1772
  return results;
1682
1773
  }
1683
1774
 
1775
+ /**
1776
+ * Code that lets a template doc declare a replacement: the field itself, or an
1777
+ * import, a require or a spread that can bring it in. Comments do not count.
1778
+ */
1779
+ const MAY_REPLACE_RE =
1780
+ /\breplaces\b|^\s*import\b|\bimport\s*\(|\brequire\s*\(|\.\.\.\s*[A-Za-z_$]/m;
1781
+
1782
+ /**
1783
+ * The id of each template doc an integration ships, valid or not, read from
1784
+ * file names alone.
1785
+ * @param {{templates?: string}} integration
1786
+ * @returns {string[]}
1787
+ */
1788
+ export function integrationTemplateIds(integration) {
1789
+ const root = integration?.templates;
1790
+ if (!root) return [];
1791
+ return findIntegrationDocFiles(root).flatMap(docPath => {
1792
+ const suffix = matchedTemplateSuffix(docPath);
1793
+ if (!suffix) return [];
1794
+ return [
1795
+ path
1796
+ .relative(root, docPath)
1797
+ .slice(0, -suffix.length)
1798
+ .split(path.sep)
1799
+ .join('/'),
1800
+ ];
1801
+ });
1802
+ }
1803
+
1804
+ /**
1805
+ * Whether any template doc an integration ships can declare a replacement,
1806
+ * read from its text without loading it.
1807
+ * @param {{templates?: string}} integration
1808
+ * @returns {boolean}
1809
+ */
1810
+ export function integrationMayReplaceTemplate(integration) {
1811
+ return integrationsMayReplaceTemplate([integration]);
1812
+ }
1813
+
1814
+ /**
1815
+ * Whether any template doc any of the integrations ships can declare a
1816
+ * replacement, read from a kept summary of the docs' text.
1817
+ * @param {Array<{templates?: string}>} integrations
1818
+ * @returns {boolean}
1819
+ */
1820
+ export function integrationsMayReplaceTemplate(integrations) {
1821
+ const roots = integrations.flatMap(integration =>
1822
+ typeof integration?.templates === 'string' && integration.templates !== ''
1823
+ ? [integration.templates]
1824
+ : [],
1825
+ );
1826
+ if (roots.length === 0) return false;
1827
+ return keptTreeSummary(
1828
+ {kind: 'integration-template-replaces', roots, code: [OWN_FILE]},
1829
+ trees =>
1830
+ trees.some(({folders, readText}) =>
1831
+ folders.some(({rel, entries}) =>
1832
+ entries.some(({name, isDir}) => {
1833
+ if (isDir || !matchedTemplateSuffix(name)) return false;
1834
+ try {
1835
+ const code = readText(rel === '' ? name : path.join(rel, name))
1836
+ .replace(/\/\*[\s\S]*?\*\//g, '')
1837
+ .replace(/^\s*\/\/.*$/gm, '');
1838
+ return MAY_REPLACE_RE.test(code);
1839
+ } catch {
1840
+ return true;
1841
+ }
1842
+ }),
1843
+ ),
1844
+ ),
1845
+ );
1846
+ }
1847
+
1684
1848
  /**
1685
1849
  * Discover templates contributed by configured integrations.
1686
1850
  *
@@ -61,6 +61,7 @@ import {
61
61
  import {definitionsByIcon, iconUseCommand} from './icon-set-discovery.mjs';
62
62
  import {astryxDefinitionsByName} from './icon-definition-discovery.mjs';
63
63
  import {generatedOrigins} from './icon-set-writer.mjs';
64
+ import {compareText} from '../text/compare-text.mjs';
64
65
 
65
66
  /** @typedef {import('./icon-set-discovery.mjs').DiscoveredIconSet} DiscoveredIconSet */
66
67
  /** @typedef {import('./icon-set-discovery.mjs').IconSetChoice} IconSetChoice */
@@ -665,7 +666,7 @@ export function sharedTemplateMeanings(declared) {
665
666
  return [...byDefinition]
666
667
  .filter(([, icons]) => icons.size > 1)
667
668
  .map(([definition, icons]) => ({definition, keys: [...icons.values()]}))
668
- .sort((a, b) => a.definition.localeCompare(b.definition));
669
+ .sort((a, b) => compareText(a.definition, b.definition));
669
670
  }
670
671
 
671
672
  /**
@@ -34,6 +34,7 @@ import {
34
34
  storedKey,
35
35
  STORED_DOCS_FILE,
36
36
  } from '../doc-compiler/stored-docs.mjs';
37
+ import {compareText} from '../text/compare-text.mjs';
37
38
 
38
39
  export const BUNDLED_THEME_PACKAGE = '@astryxdesign/cli';
39
40
  export const THEMES_DIR = path.join(CLI_ROOT, 'assets', 'templates', 'themes');
@@ -1328,7 +1329,7 @@ export function discoverUnmigratedThemeCopies(
1328
1329
  .filter(entry => entry.isDirectory() && !isIgnoredThemeEntry(entry.name))
1329
1330
  .map(entry => unmigratedThemeCopy(path.join(root, entry.name)))
1330
1331
  .filter(copy => copy !== null)
1331
- .sort((a, b) => a.slug.localeCompare(b.slug));
1332
+ .sort((a, b) => compareText(a.slug, b.slug));
1332
1333
  }
1333
1334
 
1334
1335
  /** @param {string[]} files */
@@ -1434,7 +1435,7 @@ export function discoverThemeDirectory(
1434
1435
  }
1435
1436
  const directories = rootEntries
1436
1437
  .filter(entry => entry.isDirectory())
1437
- .sort((a, b) => a.name.localeCompare(b.name));
1438
+ .sort((a, b) => compareText(a.name, b.name));
1438
1439
 
1439
1440
  for (const directory of directories) {
1440
1441
  const slug = directory.name;
@@ -1,6 +1,20 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * `{mode}` for a built theme module that exports one color mode
6
+ * (`export const colorModes = ["light"];`, which `theme build` writes beside
7
+ * the theme export), read without running it; nothing for a module with
8
+ * both modes, which exports none.
9
+ * @param {string | null | undefined} moduleFile
10
+ * @param {string} [exportName] the theme's export: a module that re-exports
11
+ * only the theme by name (`export {oceanTheme} from './ocean.js'`) is
12
+ * read where the theme is declared
13
+ * @returns {{mode?: 'light' | 'dark'}}
14
+ */
15
+ export function builtColorMode(moduleFile: string | null | undefined, exportName?: string): {
16
+ mode?: "light" | "dark";
17
+ };
4
18
  /**
5
19
  * Resolve a discovered theme to app imports.
6
20
  * @param {import('./theme-discovery.mjs').DiscoveredTheme} theme
@@ -15,7 +15,7 @@
15
15
  import * as fs from 'node:fs';
16
16
  import * as path from 'node:path';
17
17
  import {findInstalledPackage} from '../fs/paths.mjs';
18
- import {moduleExportsName} from './module-exports.mjs';
18
+ import {moduleExportSource, moduleExportsName} from './module-exports.mjs';
19
19
  import {inspectPackageExport} from './package-exports.mjs';
20
20
  import {themeImportPackage} from './theme-discovery.mjs';
21
21
  import {isLocalThemeOwner, projectPath} from '../config/theme-state.mjs';
@@ -101,6 +101,7 @@ function resolveLocalTheme(theme, cwd) {
101
101
  stylesheetFile,
102
102
  ...(fs.existsSync(fontStylesheetFile) ? {fontStylesheetFile} : {}),
103
103
  source: /** @type {const} */ ('local'),
104
+ ...builtColorMode(moduleFile, theme.exportName),
104
105
  };
105
106
  }
106
107
 
@@ -228,9 +229,50 @@ function resolvePackageTheme(theme, cwd, ownerThemeCount) {
228
229
  /** @type {any} */ (theme).source === 'bundled' || theme.bundled
229
230
  ? /** @type {const} */ ('bundled')
230
231
  : /** @type {const} */ ('package'),
232
+ ...builtColorMode(selected.module.target, theme.exportName),
231
233
  };
232
234
  }
233
235
 
236
+ /**
237
+ * `{mode}` for a built theme module that exports one color mode
238
+ * (`export const colorModes = ["light"];`, which `theme build` writes beside
239
+ * the theme export), read without running it; nothing for a module with
240
+ * both modes, which exports none.
241
+ * @param {string | null | undefined} moduleFile
242
+ * @param {string} [exportName] the theme's export: a module that re-exports
243
+ * only the theme by name (`export {oceanTheme} from './ocean.js'`) is
244
+ * read where the theme is declared
245
+ * @returns {{mode?: 'light' | 'dark'}}
246
+ */
247
+ export function builtColorMode(moduleFile, exportName) {
248
+ if (!moduleFile) return {};
249
+ // The file that declares it: the module, or the built module it re-exports
250
+ // (`export * from './ocean.js'`); else the built module that declares the
251
+ // theme the module re-exports by name.
252
+ const declaring =
253
+ moduleExportSource(moduleFile, 'colorModes') ??
254
+ (exportName
255
+ ? (() => {
256
+ const theme = moduleExportSource(moduleFile, exportName);
257
+ return theme && theme !== moduleFile
258
+ ? moduleExportSource(theme, 'colorModes')
259
+ : null;
260
+ })()
261
+ : null);
262
+ if (!declaring) return {};
263
+ let text;
264
+ try {
265
+ text = fs.readFileSync(declaring, 'utf8');
266
+ } catch {
267
+ return {};
268
+ }
269
+ const m =
270
+ /^export const colorModes = \[\s*["'](light|dark)["']\s*\];?\s*$/m.exec(
271
+ text,
272
+ );
273
+ return m ? {mode: /** @type {'light' | 'dark'} */ (m[1])} : {};
274
+ }
275
+
234
276
  /**
235
277
  * Resolve a discovered theme to app imports.
236
278
  * @param {import('./theme-discovery.mjs').DiscoveredTheme} theme
@@ -20,6 +20,7 @@ import * as fs from 'node:fs';
20
20
  import * as path from 'node:path';
21
21
  import {reusedWhileUnchanged} from '../fs/read-record.mjs';
22
22
  import {loadComponentDoc} from './component-loader.mjs';
23
+ import {compareText} from '../text/compare-text.mjs';
23
24
 
24
25
  const SKIP_DIRS = new Set(['node_modules', '__tests__']);
25
26
 
@@ -142,7 +143,7 @@ async function scanThemingTargets(coreSrc) {
142
143
  const canonical = canonicalizeParentTargets(targets);
143
144
  canonical.sort(
144
145
  (a, b) =>
145
- a.key.localeCompare(b.key) || a.component.localeCompare(b.component),
146
+ compareText(a.key, b.key) || compareText(a.component, b.component),
146
147
  );
147
148
  return canonical;
148
149
  }
@@ -254,7 +255,7 @@ export async function collectThemingVars(coreSrc) {
254
255
 
255
256
  await scan(coreSrc);
256
257
 
257
- return [...vars.values()].sort((a, b) => a.name.localeCompare(b.name));
258
+ return [...vars.values()].sort((a, b) => compareText(a.name, b.name));
258
259
  }
259
260
 
260
261
  /**
@@ -35,7 +35,12 @@ import {
35
35
  readInTurn,
36
36
  } from '../fs/module-loader.mjs';
37
37
  import {fileStamp, recordContentRead} from '../fs/read-record.mjs';
38
- import {readStore, storedKey, STORED_DOCS_FILE} from './stored-docs.mjs';
38
+ import {
39
+ noteStoredExport,
40
+ readStore,
41
+ storedKey,
42
+ STORED_DOCS_FILE,
43
+ } from './stored-docs.mjs';
39
44
 
40
45
  const requireFromHere = createRequire(import.meta.url);
41
46
 
@@ -132,6 +137,7 @@ function storedModule(file) {
132
137
  enumerable: true,
133
138
  writable: true,
134
139
  });
140
+ noteStoredExport(exports[name], key, name);
135
141
  }
136
142
  Object.defineProperty(module, Symbol.toStringTag, {value: 'Module'});
137
143
  Object.preventExtensions(module);
@@ -27,6 +27,7 @@ import {astryxIconDefinitions} from '../discovery/icon-definition-discovery.mjs'
27
27
  import {CLI_ROOT, findCoreDir} from '../fs/paths.mjs';
28
28
  import {packageSource} from './source.mjs';
29
29
  import {treeDocFiles} from './tree.mjs';
30
+ import {compareText} from '../text/compare-text.mjs';
30
31
 
31
32
  export {packageSource};
32
33
 
@@ -203,7 +204,7 @@ function unlistedCoreComponentDocs(coreDir, list) {
203
204
  const walk = dir => {
204
205
  const entries = fs
205
206
  .readdirSync(dir, {withFileTypes: true})
206
- .sort((a, b) => a.name.localeCompare(b.name));
207
+ .sort((a, b) => compareText(a.name, b.name));
207
208
  for (const entry of entries) {
208
209
  const full = path.join(dir, entry.name);
209
210
  if (entry.isDirectory()) {
@@ -235,7 +236,7 @@ export function selfDocFiles() {
235
236
  const walk = dir => {
236
237
  const entries = fs
237
238
  .readdirSync(dir, {withFileTypes: true})
238
- .sort((a, b) => a.name.localeCompare(b.name));
239
+ .sort((a, b) => compareText(a.name, b.name));
239
240
  for (const entry of entries) {
240
241
  const full = path.join(dir, entry.name);
241
242
  if (entry.isDirectory()) {
@@ -11,6 +11,7 @@
11
11
  */
12
12
 
13
13
  import {parseDoc} from '../../authoring/doctypes/parse.mjs';
14
+ import {storedParse} from './stored-docs.mjs';
14
15
 
15
16
  /**
16
17
  * @param {unknown} input
@@ -25,5 +26,7 @@ export function parseReadableDoc(input, label = 'doc') {
25
26
  if (type === 'theme') {
26
27
  throw new Error(`${label} has unsupported type ${JSON.stringify(type)}.`);
27
28
  }
28
- return parseDoc(input, label);
29
+ // A doc Astryx ships was parsed at publish (scripts/generate-stored-docs.mjs):
30
+ // its stored parse is what parsing it gives.
31
+ return storedParse(input) ?? parseDoc(input, label);
29
32
  }
@@ -21,6 +21,28 @@ export function storedKey(text: string | Buffer): string;
21
21
  export function readStore(file: string): {
22
22
  get: (key: string) => any;
23
23
  };
24
+ /**
25
+ * Note that `value` is the `name` export of the stored doc `key`.
26
+ * @param {unknown} value
27
+ * @param {string} key
28
+ * @param {string} name
29
+ */
30
+ export function noteStoredExport(value: unknown, key: string, name: string): void;
31
+ /**
32
+ * Where a stored doc's export, as the readers parse it, is stored at publish.
33
+ * @param {string} key the doc's key
34
+ * @param {string} name the export's name
35
+ * @returns {string}
36
+ */
37
+ export function storedParseKey(key: string, name: string): string;
38
+ /**
39
+ * The parse of `value`, read from the store, when `value` is a stored doc's
40
+ * export whose parse was stored at publish: a fresh value, as a parse gives.
41
+ * Undefined otherwise, or when the store cannot be read.
42
+ * @param {unknown} value
43
+ * @returns {any}
44
+ */
45
+ export function storedParse(value: unknown): any;
24
46
  /**
25
47
  * Where the exports of the doc files Astryx ships (the CLI's and Core's) are
26
48
  * stored: each doc that imports nothing, reads nothing of where it sits, and
@@ -96,3 +96,52 @@ function openStore(file) {
96
96
  return new Map();
97
97
  }
98
98
  }
99
+
100
+ /**
101
+ * Each export value of a stored doc's module (./import.mjs), with the doc's
102
+ * key and the export's name, so its parse can be answered from the store
103
+ * ({@link storedParse}).
104
+ * @type {WeakMap<object, {key: string, name: string}>}
105
+ */
106
+ const storedExports = new WeakMap();
107
+
108
+ /**
109
+ * Note that `value` is the `name` export of the stored doc `key`.
110
+ * @param {unknown} value
111
+ * @param {string} key
112
+ * @param {string} name
113
+ */
114
+ export function noteStoredExport(value, key, name) {
115
+ if (value && typeof value === 'object') storedExports.set(value, {key, name});
116
+ }
117
+
118
+ /**
119
+ * Where a stored doc's export, as the readers parse it, is stored at publish.
120
+ * @param {string} key the doc's key
121
+ * @param {string} name the export's name
122
+ * @returns {string}
123
+ */
124
+ export function storedParseKey(key, name) {
125
+ return `parsed:${name}:${key}`;
126
+ }
127
+
128
+ /**
129
+ * The parse of `value`, read from the store, when `value` is a stored doc's
130
+ * export whose parse was stored at publish: a fresh value, as a parse gives.
131
+ * Undefined otherwise, or when the store cannot be read.
132
+ * @param {unknown} value
133
+ * @returns {any}
134
+ */
135
+ export function storedParse(value) {
136
+ if (!value || typeof value !== 'object') return undefined;
137
+ const at = storedExports.get(value);
138
+ if (!at) return undefined;
139
+ try {
140
+ const parsed = readStore(STORED_DOCS_FILE).get(
141
+ storedParseKey(at.key, at.name),
142
+ );
143
+ return parsed != null && typeof parsed === 'object' ? parsed : undefined;
144
+ } catch {
145
+ return undefined;
146
+ }
147
+ }
@@ -8,6 +8,8 @@
8
8
  * sandboxes where a smaller dependency surface is preferred.
9
9
  */
10
10
 
11
+ import {compareText} from '../text/compare-text.mjs';
12
+
11
13
  const SEMVER_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
12
14
 
13
15
  /**
@@ -42,7 +44,7 @@ export function semverCompare(a, b) {
42
44
  if (Number.isNaN(na) || Number.isNaN(nb)) {
43
45
  // Fall back to lexicographic compare on garbage input rather than
44
46
  // returning NaN, which would silently break sort/filter callers.
45
- return String(a).localeCompare(String(b));
47
+ return compareText(String(a), String(b));
46
48
  }
47
49
  if (na !== nb) return na - nb;
48
50
  }
@@ -0,0 +1,31 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * The families a stylesheet `@import` specifier loads, read from `fromDir`:
6
+ * an `@fontsource` package by its name, a font service URL by the
7
+ * `family=` it requests, a local stylesheet by its `@font-face` rules and
8
+ * its own imports.
9
+ * @param {string} spec
10
+ * @param {string} fromDir
11
+ * @param {Set<string>} [seen]
12
+ * @returns {Set<string>}
13
+ */
14
+ export function importedFontFamilies(spec: string, fromDir: string, seen?: Set<string>): Set<string>;
15
+ /**
16
+ * The families a stylesheet file loads: its `@font-face` rules, and what
17
+ * each of its `@import`s loads.
18
+ * @param {string} file
19
+ * @param {Set<string>} [seen]
20
+ * @returns {Set<string>}
21
+ */
22
+ export function stylesheetFontFamilies(file: string, seen?: Set<string>): Set<string>;
23
+ /**
24
+ * The values of the declarations in a stylesheet's text whose property
25
+ * matches `property` (custom properties included), in source order.
26
+ * @param {string} css
27
+ * @param {RegExp} property
28
+ * @returns {string[]}
29
+ */
30
+ export function declarationValues(css: string, property: RegExp): string[];
31
+ export function fontKey(family: string): string;