@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
@@ -47,6 +47,14 @@ export const SHELL_FAMILY = 'Shell';
47
47
  export const CONTAINER_PHRASE =
48
48
  /\b(?:in|inside|within)\s+(?:a|an|the)\s+([a-z-]+)(?:\s+([a-z-]+))?/gi;
49
49
 
50
+ /**
51
+ * A place phrase: a preposition of place, then a determiner ("above the
52
+ * table", "into my dashboard"). CONTAINER_PHRASE is the narrower class of
53
+ * frames a page lives in ("in a modal"); this one names where a piece goes.
54
+ */
55
+ export const PLACE_PHRASE =
56
+ /\b(?:to|into|onto|in|inside|within|on|above|below|beside|under|next to)\s+(?:the|a|an|my|our|this|each|every|existing)\b/i;
57
+
50
58
  /**
51
59
  * Where a phrase ends, for finding the word that heads it: punctuation and
52
60
  * the words that join phrases.
@@ -130,6 +138,87 @@ export function containersOf(query) {
130
138
  return found;
131
139
  }
132
140
 
141
+ /**
142
+ * A template's keywords as the units a request can match, each read with the
143
+ * caller's own word reader. A one-word keyword is that word. A longer keyword
144
+ * is one phrase unit, its words joined by single spaces: a request matches it
145
+ * only when it names those words in that order (`phrasesIn`), and its words
146
+ * never count alone. So "table of contents" on a docs page adds no "table" to
147
+ * that page, and a table request still reads as a table.
148
+ * @param {readonly string[]} keywords
149
+ * @param {(text: string) => string[]} read the caller's word reader
150
+ * @returns {string[]}
151
+ */
152
+ export function keywordUnits(keywords, read) {
153
+ return keywords.map(keyword => read(keyword).join(' ')).filter(Boolean);
154
+ }
155
+
156
+ /**
157
+ * The phrase units (two or more words) a request names: the unit's words
158
+ * appear next to each other, in order, in the request's words as the same
159
+ * reader reads them.
160
+ * @param {readonly string[]} words the request's words, in order
161
+ * @param {Iterable<string>} units
162
+ * @returns {Set<string>}
163
+ */
164
+ export function phrasesIn(words, units) {
165
+ const text = ` ${words.join(' ')} `;
166
+ const found = new Set();
167
+ for (const unit of units) {
168
+ if (unit.includes(' ') && text.includes(` ${unit} `)) found.add(unit);
169
+ }
170
+ return found;
171
+ }
172
+
173
+ /**
174
+ * The words a template's keyword units give an idea: each one-word keyword,
175
+ * and every word of each phrase keyword the idea names (`phrasesIn`). A named
176
+ * phrase carries all of its words, as the same words listed one by one would;
177
+ * a phrase the idea does not name gives none of them.
178
+ * @param {readonly string[]} units the template's keyword units (`keywordUnits`)
179
+ * @param {readonly string[]} words the idea's words, in order, read the same way
180
+ * @returns {string[]}
181
+ */
182
+ export function keywordWordsFor(units, words) {
183
+ const named = phrasesIn(words, units);
184
+ return units.flatMap(unit =>
185
+ !unit.includes(' ') ? [unit] : named.has(unit) ? unit.split(' ') : [],
186
+ );
187
+ }
188
+
189
+ /**
190
+ * What each frame of an idea holds: for every container phrase ("settings in
191
+ * a modal", "in a settings modal"), the frame's terms with the words that
192
+ * name what sits in it: the head of the phrase right before the container
193
+ * phrase, and the container phrase's own other words. In "a toggle in a modal
194
+ * on the settings page" the modal holds the toggle, not the settings page.
195
+ * @param {string} query
196
+ * @returns {Map<string, Set<string>>} frame term -> terms it holds
197
+ */
198
+ export function framesOf(query) {
199
+ const text = String(query);
200
+ /** @type {Map<string, Set<string>>} */
201
+ const held = new Map();
202
+ for (const m of text.matchAll(CONTAINER_PHRASE)) {
203
+ const frames = terms(`${m[1]} ${m[2] ?? ''}`).filter(t =>
204
+ OVERLAY_FRAMES.has(t),
205
+ );
206
+ if (frames.length === 0) continue;
207
+ const before = text.slice(0, m.index).toLowerCase().split(PHRASE_END);
208
+ const lead = terms(before[before.length - 1] ?? '');
209
+ const holds = new Set([
210
+ ...lead.slice(-1),
211
+ ...terms(`${m[1]} ${m[2] ?? ''}`).filter(t => !OVERLAY_FRAMES.has(t)),
212
+ ]);
213
+ for (const f of frames) {
214
+ const set = held.get(f) ?? new Set();
215
+ for (const t of holds) set.add(t);
216
+ held.set(f, set);
217
+ }
218
+ }
219
+ return held;
220
+ }
221
+
133
222
  /** @param {string} text */
134
223
  export const normalized = text =>
135
224
  (
@@ -163,7 +252,7 @@ export const SYNONYMS_OF = (() => {
163
252
  /**
164
253
  * @typedef {import('../_adapter.mjs').PageTemplate} PageTemplate
165
254
  * @typedef {import('../_adapter.mjs').ComponentWords} ComponentWords
166
- * @typedef {{name: string, score: number, hits: number, familyNamed: boolean, headNamed: boolean, containerMatched: boolean, family: string, base: boolean, matched: Set<string>}} RankedPage
255
+ * @typedef {{name: string, score: number, hits: number, familyNamed: boolean, headNamed: boolean, containerMatched: boolean, family: string, base: boolean, matched: Set<string>, typical: number}} RankedPage
167
256
  * @typedef {'page' | 'part' | 'edit'} IdeaKind
168
257
  */
169
258
 
@@ -27,7 +27,6 @@ InputGroupInternalContext InputGroupInternalContext InputGroup/InputGroup.doc.mj
27
27
  InternationalizationContext InternationalizationContext i18n/InternationalizationProvider.doc.mjs i18n/InternationalizationContext.ts
28
28
  ItemDescriptionContext ItemDescriptionContext Item/Item.doc.mjs Item/ItemDescriptionContext.tsx
29
29
  ItemMarkerColumnsContext ItemMarkerColumnsContext Item/Item.doc.mjs Item/ItemMarkerColumnsContext.tsx
30
- ItemSwipeLayer ItemSwipeLayer Item/Item.doc.mjs Item/ItemSwipeLayer.tsx
31
30
  LayerContext LayerContext Layer/Layer.doc.mjs Layer/LayerContext.ts
32
31
  LayerDepthContext LayerDepthContext Layer/Layer.doc.mjs Layer/LayerDepthContext.tsx
33
32
  LayerProvider LayerProvider Layer/Layer.doc.mjs Layer/LayerProvider.tsx
@@ -111,7 +110,7 @@ dataTokens dataTokens theme/MediaTheme.doc.mjs theme/domainTokens/dataTokens.ts
111
110
  dayCellUtils dayCellUtils Calendar/Calendar.doc.mjs Calendar/dayCellUtils.ts
112
111
  declarationBoundary declarationBoundary theme/MediaTheme.doc.mjs theme/declarationBoundary.ts
113
112
  defaultIcons defaultIcons Icon/Icon.doc.mjs Icon/defaultIcons.tsx
114
- defineSyntaxTheme defineSyntaxTheme theme/MediaTheme.doc.mjs theme/syntax/defineSyntaxTheme.ts
113
+ defineSyntaxTheme defineSyntaxTheme theme/syntax/useSyntaxTheme.doc.mjs theme/syntax/defineSyntaxTheme.ts
115
114
  defineTheme defineTheme theme/MediaTheme.doc.mjs theme/defineTheme.ts
116
115
  derivedVarRegistry derivedVarRegistry theme/MediaTheme.doc.mjs theme/derivedVarRegistry.ts
117
116
  dockerfile dockerfile CodeBlock/CodeBlock.doc.mjs CodeBlock/languages/dockerfile.ts
@@ -191,7 +190,7 @@ popoverOperations popoverOperations Layer/Layer.doc.mjs Layer/popoverOperations.
191
190
  powerSearchSheetUtils powerSearchSheetUtils PowerSearch/PowerSearch.doc.mjs PowerSearch/powerSearchSheetUtils.ts
192
191
  powershell powershell CodeBlock/CodeBlock.doc.mjs CodeBlock/languages/powershell.ts
193
192
  preserveAnimations preserveAnimations Layer/Layer.doc.mjs Layer/preserveAnimations.ts
194
- presets presets theme/MediaTheme.doc.mjs theme/syntax/presets.ts
193
+ presets presets theme/syntax/useSyntaxTheme.doc.mjs theme/syntax/presets.ts
195
194
  pressGroupContext pressGroupContext hooks/useAnimatedLayout.doc.mjs hooks/pressGroupContext.ts
196
195
  protocol protocol Markdown/Markdown.doc.mjs Markdown/plugins/protocol.ts
197
196
  publicContext publicContext i18n/InternationalizationProvider.doc.mjs i18n/publicContext.ts
@@ -251,7 +250,7 @@ useCalendarConstraints useCalendarConstraints Calendar/useCalendarConstraints.do
251
250
  useCalendarDays useCalendarDays Calendar/useCalendarDays.doc.mjs Calendar/hooks/useCalendarDays.ts
252
251
  useCalendarNavigation useCalendarNavigation Calendar/useCalendarNavigation.doc.mjs Calendar/hooks/useCalendarNavigation.ts
253
252
  useChatComposerTokens useChatComposerTokens Chat/Chat.doc.mjs Chat/useChatComposerTokens.ts
254
- useChatDictation useChatDictation Chat/Chat.doc.mjs Chat/useChatDictation.ts
253
+ useChatDictation useChatDictation Chat/useChatDictation.doc.mjs Chat/useChatDictation.ts
255
254
  useChatNewMessages useChatNewMessages Chat/Chat.doc.mjs Chat/useChatNewMessages.ts
256
255
  useChatPasteAsToken useChatPasteAsToken Chat/Chat.doc.mjs Chat/useChatPasteAsToken.ts
257
256
  useChatStreamScroll useChatStreamScroll Chat/Chat.doc.mjs Chat/useChatStreamScroll.ts
@@ -295,7 +294,7 @@ useSettledOpen useSettledOpen hooks/useAnimatedLayout.doc.mjs hooks/useSettledOp
295
294
  useSheetGestures useSheetGestures BottomSheet/BottomSheet.doc.mjs BottomSheet/useSheetGestures.ts
296
295
  useSliderTouch useSliderTouch Slider/Slider.doc.mjs Slider/useSliderTouch.ts
297
296
  useSpeechRecognition useSpeechRecognition Chat/Chat.doc.mjs Chat/useSpeechRecognition.ts
298
- useSwipeAction useSwipeAction Item/Item.doc.mjs Item/useSwipeAction.ts
297
+ useSwipeAction useSwipeAction Swipe/createSwipe.doc.mjs Swipe/useSwipeAction.ts
299
298
  useSwitchTouch useSwitchTouch Switch/Switch.doc.mjs Switch/useSwitchTouch.ts
300
299
  useTableCellStyles useTableCellStyles Table/Table.doc.mjs Table/useTableCellStyles.ts
301
300
  useTableColumnSettingsState useTableColumnSettingsState Table/plugins/columnSettings/useTableColumnSettingsState.doc.mjs Table/plugins/columnSettings/useTableColumnSettingsState.tsx
@@ -15,7 +15,7 @@
15
15
  * @param {string|null} opts.lang
16
16
  * @returns {Promise<ComponentListResponse>}
17
17
  */
18
- export function componentList(coreDir: string, { cwd, category, detail, zh, dense, lang }: {
18
+ export function componentList(coreDir: string, opts: {
19
19
  cwd: string;
20
20
  category?: string | undefined;
21
21
  detail: "full" | "compact" | "brief";
@@ -22,7 +22,9 @@ import {
22
22
  resolveImportPath,
23
23
  resolveIntegrationImportPath,
24
24
  } from '../../../foundation/discovery/component-discovery.mjs';
25
- import {discoverExternalPackages} from '../../../foundation/fs/paths.mjs';
25
+ import {EXACT_CODEC} from '../../../foundation/fs/exact-codec.mjs';
26
+ import {persistedGather} from '../../../foundation/fs/gather-cache.mjs';
27
+ import {CLI_ROOT, discoverExternalPackages, realDir} from '../../../foundation/fs/paths.mjs';
26
28
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
27
29
  import {AstryxError} from '../../error.mjs';
28
30
  import {
@@ -31,6 +33,7 @@ import {
31
33
  loadIntegrationsSafely,
32
34
  withOwnership,
33
35
  } from '../_adapter.mjs';
36
+ import {compareText} from '../../../foundation/text/compare-text.mjs';
34
37
 
35
38
  /**
36
39
  * @typedef {import('../component.type.mjs').ComponentListResponse} ComponentListResponse
@@ -162,10 +165,49 @@ async function replacementEntry(replacement, detail, {zh, dense, lang}) {
162
165
  * @param {string|null} opts.lang
163
166
  * @returns {Promise<ComponentListResponse>}
164
167
  */
165
- export async function componentList(
166
- coreDir,
167
- {cwd, category, detail, zh, dense, lang},
168
- ) {
168
+ export async function componentList(coreDir, opts) {
169
+ const {cwd, category, detail, zh, dense, lang} = opts;
170
+ // A function of the files it reads (Core's component folders and docs, the
171
+ // integrations and their docs), which the kept gather stamps: a later run
172
+ // with every one unchanged reads the list back.
173
+ return /** @type {ComponentListResponse} */ (
174
+ await persistedGather(
175
+ [
176
+ 'component-list',
177
+ realDir(cwd),
178
+ coreDir,
179
+ CLI_ROOT,
180
+ category ?? null,
181
+ detail,
182
+ zh,
183
+ dense,
184
+ lang,
185
+ ],
186
+ () => componentListNow(coreDir, opts),
187
+ COMPONENT_LIST_CODEC,
188
+ )
189
+ );
190
+ }
191
+
192
+ /** The component list, kept exactly, with the envelope's shape. */
193
+ const COMPONENT_LIST_CODEC = {
194
+ ...EXACT_CODEC,
195
+ valid: (/** @type {any} */ value) =>
196
+ value != null &&
197
+ value.type === 'component.list' &&
198
+ value.data != null &&
199
+ typeof value.data.detail === 'string' &&
200
+ value.data.components != null &&
201
+ typeof value.data.components === 'object',
202
+ };
203
+
204
+ /**
205
+ * componentList, worked out now.
206
+ * @param {string} coreDir
207
+ * @param {Parameters<typeof componentList>[1]} options
208
+ * @returns {Promise<ComponentListResponse>}
209
+ */
210
+ async function componentListNow(coreDir, {cwd, category, detail, zh, dense, lang}) {
169
211
  const components = discoverComponents(coreDir);
170
212
  // An active integration replacement takes its Core component's slot in
171
213
  // every list view (spec:AST-035 FR11); the Core original stays reachable
@@ -429,7 +471,7 @@ export async function componentList(
429
471
  });
430
472
  }
431
473
  for (const [key, members] of byGroup) {
432
- members.sort((a, b) => a.name.localeCompare(b.name));
474
+ members.sort((a, b) => compareText(a.name, b.name));
433
475
  listData[key] = members;
434
476
  }
435
477
  }
@@ -216,7 +216,7 @@ export const OFFICIAL_LIST_FILE: string;
216
216
  */
217
217
  export const EXPERIMENTAL_KINDS: readonly ["icon-set"];
218
218
  /** The item kinds every project reads: the catalog kinds, less experimental ones. */
219
- export const STABLE_KINDS: ("template" | "component" | "doc" | "theme" | "codemod" | "agent-doc" | "icon-set")[];
219
+ export const STABLE_KINDS: ("component" | "template" | "doc" | "theme" | "codemod" | "agent-doc" | "icon-set")[];
220
220
  /** The list and detail entry fields for each item kind, in display order. */
221
221
  export const KIND_FIELDS: readonly [readonly ["component", "components"], readonly ["template", "templates"], readonly ["doc", "docs"], readonly ["theme", "themes"], readonly ["codemod", "codemods"], readonly ["agent-doc", "agentDocs"], readonly ["icon-set", "iconSets"]];
222
222
  export type ScannedPackage = import("./_package-scanner.mjs").ScannedPackage;
@@ -24,6 +24,7 @@ import {levenshteinDistance} from '../../../foundation/text/string-utils.mjs';
24
24
  import {AstryxError} from '../../error.mjs';
25
25
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
26
26
  import {DISCOVER_KINDS} from '../../../authoring/discover/parse.mjs';
27
+ import {compareText} from '../../../foundation/text/compare-text.mjs';
27
28
 
28
29
  /**
29
30
  * @typedef {import('../_package-scanner.mjs').ScannedPackage} ScannedPackage
@@ -131,8 +132,8 @@ export async function search(packages, query, opts) {
131
132
  a.score - b.score ||
132
133
  Number(b.item.installed) - Number(a.item.installed) ||
133
134
  KIND_ORDER.indexOf(a.item.kind) - KIND_ORDER.indexOf(b.item.kind) ||
134
- a.item.package.localeCompare(b.item.package) ||
135
- a.item.name.localeCompare(b.item.name),
135
+ compareText(a.item.package, b.item.package) ||
136
+ compareText(a.item.name, b.item.name),
136
137
  );
137
138
 
138
139
  if (ranked.length > 0) {
@@ -366,12 +366,36 @@ export function routeOwner(tree: DocsTree, entry: import("../../foundation/disco
366
366
  * Otherwise it suggests the docs the argument names in another spelling, or
367
367
  * failing that the topics and top-level namespaces, closest first and cut
368
368
  * where the matches get weaker (every one of them when none shares a word
369
- * with the argument).
369
+ * with the argument). When the argument is the name of a component, hook or
370
+ * template, the command that reads that entry comes first and takes the last
371
+ * suggestion's place, so the list keeps its length; when no suggested doc
372
+ * shares a word with the argument, that command is the only suggestion.
370
373
  * @param {unknown} topic
371
374
  * @param {DocsCatalog} catalog
375
+ * @param {{cwd?: string}} [options]
372
376
  * @returns {Promise<AstryxError>}
373
377
  */
374
- export function unknownTopicError(topic: unknown, catalog: DocsCatalog): Promise<AstryxError>;
378
+ export function unknownTopicError(topic: unknown, catalog: DocsCatalog, { cwd }?: {
379
+ cwd?: string;
380
+ }): Promise<AstryxError>;
381
+ /**
382
+ * The command that reads the component, hook or template a docs argument
383
+ * names, or null. Only an exact name counts, in any case and with or without
384
+ * spaces and hyphens; a hook also answers to its name without `use`. A
385
+ * component wins over a hook, and a hook over a template. A route never names
386
+ * one of them.
387
+ * @param {string} topic
388
+ * @param {{components?: string[], hooks?: string[], templates?: string[]}} names
389
+ * @returns {{name: string, reason: string} | null}
390
+ */
391
+ export function entryCommand(topic: string, { components, hooks, templates }: {
392
+ components?: string[];
393
+ hooks?: string[];
394
+ templates?: string[];
395
+ }): {
396
+ name: string;
397
+ reason: string;
398
+ } | null;
375
399
  /**
376
400
  * A sentence naming the packages whose docs did not load, or nothing: a doc
377
401
  * that fails to load withdraws its package's docs, so a reader who cannot
@@ -68,23 +68,46 @@ import {
68
68
  import {CLI_PROVIDER_ID} from '../../foundation/identity/providers.mjs';
69
69
  import {
70
70
  CORE_PACKAGE,
71
+ discoverComponentNamesWhere,
72
+ discoverIntegrationComponents,
71
73
  discoverOwnedComponents,
72
74
  discoverValidIntegrationComponents,
73
75
  } from '../../foundation/discovery/component-discovery.mjs';
74
76
  import {loadComponentDoc} from '../../foundation/discovery/component-loader.mjs';
75
77
  import {
78
+ coreFilesNaming,
79
+ foldEntryName,
80
+ integrationsFilesNaming,
81
+ } from '../../foundation/discovery/entry-name-files.mjs';
82
+ import {getAllHookNames} from '../../foundation/discovery/hook-discovery.mjs';
83
+ import {
84
+ coreTemplateIds,
76
85
  discoverCoreTemplates,
77
86
  discoverIntegrationTemplatesForOne,
87
+ integrationsMayReplaceTemplate,
88
+ listTemplates,
89
+ templateFilesNaming,
78
90
  } from '../../foundation/discovery/template-adapter.mjs';
79
91
  import {findCoreDir} from '../../foundation/fs/paths.mjs';
80
92
  import {reusedWhileUnchanged} from '../../foundation/fs/read-record.mjs';
81
93
  import {AstryxError} from '../error.mjs';
82
94
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
83
- import {orderRouteSuggestions} from '../../foundation/text/suggest-order.mjs';
95
+ import {
96
+ carriesTypedWord,
97
+ orderRouteSuggestions,
98
+ } from '../../foundation/text/suggest-order.mjs';
84
99
  import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
100
+ import {compareText} from '../../foundation/text/compare-text.mjs';
85
101
 
86
102
  export {OVERLAY_LANGUAGES, overlayLanguages};
87
103
 
104
+ /**
105
+ * The project each loaded catalog came from, so a later step of the same read
106
+ * does not load the project again.
107
+ * @type {WeakMap<DocsCatalog, Project>}
108
+ */
109
+ const projectOfCatalog = new WeakMap();
110
+
88
111
  /**
89
112
  * The project's topics: the built-in ones plus whatever the configured
90
113
  * integrations contribute.
@@ -101,7 +124,9 @@ export {OVERLAY_LANGUAGES, overlayLanguages};
101
124
  export async function loadDocsCatalog(cwd = process.cwd()) {
102
125
  try {
103
126
  const project = await Project.load(cwd);
104
- return await project.docs();
127
+ const catalog = await project.docs();
128
+ projectOfCatalog.set(catalog, project);
129
+ return catalog;
105
130
  } catch {
106
131
  return DocsCatalog.fromBuiltins();
107
132
  }
@@ -1932,12 +1957,16 @@ function movedRoute(topic, tree) {
1932
1957
  * Otherwise it suggests the docs the argument names in another spelling, or
1933
1958
  * failing that the topics and top-level namespaces, closest first and cut
1934
1959
  * where the matches get weaker (every one of them when none shares a word
1935
- * with the argument).
1960
+ * with the argument). When the argument is the name of a component, hook or
1961
+ * template, the command that reads that entry comes first and takes the last
1962
+ * suggestion's place, so the list keeps its length; when no suggested doc
1963
+ * shares a word with the argument, that command is the only suggestion.
1936
1964
  * @param {unknown} topic
1937
1965
  * @param {DocsCatalog} catalog
1966
+ * @param {{cwd?: string}} [options]
1938
1967
  * @returns {Promise<AstryxError>}
1939
1968
  */
1940
- export async function unknownTopicError(topic, catalog) {
1969
+ export async function unknownTopicError(topic, catalog, {cwd} = {}) {
1941
1970
  const tree = await projectTree(catalog);
1942
1971
  /** @type {Array<{name: string, reason: string}>} */
1943
1972
  let suggestions = [];
@@ -1975,7 +2004,10 @@ export async function unknownTopicError(topic, catalog) {
1975
2004
  )
1976
2005
  .map(node => ({name: node.route, reason: node.summary}));
1977
2006
  }
2007
+ // Every topic and namespace: the list a name no doc shares a word with gets.
2008
+ let everyDoc = false;
1978
2009
  if (suggestions.length === 0) {
2010
+ everyDoc = true;
1979
2011
  suggestions = [
1980
2012
  ...tree
1981
2013
  .roots()
@@ -2001,6 +2033,16 @@ export async function unknownTopicError(topic, catalog) {
2001
2033
  ERROR_CODES.ERR_UNKNOWN_TOPIC,
2002
2034
  );
2003
2035
  }
2036
+ const elsewhere =
2037
+ suggestions.length > 0 ? await entryElsewhere(topic, catalog, cwd) : null;
2038
+ if (elsewhere) {
2039
+ const sharesAWord =
2040
+ !everyDoc ||
2041
+ suggestions.some(entry => carriesTypedWord(String(topic), entry.name));
2042
+ suggestions = sharesAWord
2043
+ ? [elsewhere, ...suggestions.slice(0, -1)]
2044
+ : [elsewhere];
2045
+ }
2004
2046
  return new AstryxError(
2005
2047
  `Unknown topic "${String(topic)}"${notLoaded(catalog)}`,
2006
2048
  suggestions,
@@ -2008,6 +2050,177 @@ export async function unknownTopicError(topic, catalog) {
2008
2050
  );
2009
2051
  }
2010
2052
 
2053
+ /**
2054
+ * The command that reads the component, hook or template a docs argument
2055
+ * names, or null. Only an exact name counts, in any case and with or without
2056
+ * spaces and hyphens; a hook also answers to its name without `use`. A
2057
+ * component wins over a hook, and a hook over a template. A route never names
2058
+ * one of them.
2059
+ * @param {string} topic
2060
+ * @param {{components?: string[], hooks?: string[], templates?: string[]}} names
2061
+ * @returns {{name: string, reason: string} | null}
2062
+ */
2063
+ export function entryCommand(
2064
+ topic,
2065
+ {components = [], hooks = [], templates = []},
2066
+ ) {
2067
+ if (topic.includes('/')) return null;
2068
+ const wanted = foldEntryName(topic);
2069
+ if (wanted === '') return null;
2070
+ const component = components.find(name => foldEntryName(name) === wanted);
2071
+ if (component) {
2072
+ return {
2073
+ name: `astryx component ${component}`,
2074
+ reason: 'a component, not a docs topic',
2075
+ };
2076
+ }
2077
+ const hook = hooks.find(name => {
2078
+ const folded = foldEntryName(name);
2079
+ return folded === wanted || folded === `use${wanted}`;
2080
+ });
2081
+ if (hook) {
2082
+ return {name: `astryx hook ${hook}`, reason: 'a hook, not a docs topic'};
2083
+ }
2084
+ const template = templates.find(name => foldEntryName(name) === wanted);
2085
+ if (template) {
2086
+ return {
2087
+ name: `astryx template ${template}`,
2088
+ reason: 'a template, not a docs topic',
2089
+ };
2090
+ }
2091
+ return null;
2092
+ }
2093
+
2094
+ /**
2095
+ * {@link entryCommand} over the names the project's catalogs hold. File names
2096
+ * and doc text say first which catalogs can hold the argument; a catalog is
2097
+ * asked only then, only for the names that fold to the argument, and only
2098
+ * when the one before it has no match. So a name no file carries reads no doc.
2099
+ * A check that fails gives no hint.
2100
+ * @param {unknown} topic
2101
+ * @param {DocsCatalog} catalog the catalog the read used; its project is
2102
+ * reused
2103
+ * @param {string} [cwd]
2104
+ * @returns {Promise<{name: string, reason: string} | null>}
2105
+ */
2106
+ async function entryElsewhere(topic, catalog, cwd = process.cwd()) {
2107
+ if (typeof topic !== 'string' || topic.includes('/')) return null;
2108
+ const wanted = foldEntryName(topic);
2109
+ if (wanted === '') return null;
2110
+ let project = projectOfCatalog.get(catalog);
2111
+ try {
2112
+ project ??= await Project.load(cwd);
2113
+ } catch {
2114
+ return null;
2115
+ }
2116
+ const coreDir = project.coreDir();
2117
+ const integrations = project.loadedIntegrations;
2118
+ /** @param {string} name */
2119
+ const isWanted = name => foldEntryName(name) === wanted;
2120
+ /** @param {string} name */
2121
+ const isWantedHook = name =>
2122
+ isWanted(name) || foldEntryName(name) === `use${wanted}`;
2123
+ /** @type {{component: boolean, hook: boolean, componentTops?: Set<string>, hookTops?: Set<string>}} */
2124
+ let inCore = {component: false, hook: false};
2125
+ try {
2126
+ if (coreDir) inCore = coreFilesNaming(coreDir, wanted);
2127
+ } catch {
2128
+ inCore = {component: true, hook: true};
2129
+ }
2130
+ /** @type {Array<() => Promise<{components?: string[], hooks?: string[], templates?: string[]}>>} */
2131
+ const catalogs = [
2132
+ async () => ({
2133
+ components:
2134
+ coreDir && inCore.component
2135
+ ? discoverComponentNamesWhere(coreDir, isWanted, inCore.componentTops)
2136
+ : [],
2137
+ }),
2138
+ async () => ({
2139
+ components: await integrationComponentNames(
2140
+ integrations,
2141
+ wanted,
2142
+ isWanted,
2143
+ ),
2144
+ }),
2145
+ async () => ({
2146
+ hooks:
2147
+ coreDir && inCore.hook
2148
+ ? getAllHookNames(coreDir, isWantedHook, inCore.hookTops)
2149
+ : [],
2150
+ }),
2151
+ async () => ({
2152
+ templates: await templateNames(project, integrations, wanted),
2153
+ }),
2154
+ ];
2155
+ for (const load of catalogs) {
2156
+ let names;
2157
+ try {
2158
+ names = await load();
2159
+ } catch {
2160
+ continue;
2161
+ }
2162
+ const found = entryCommand(topic, names);
2163
+ if (found) return found;
2164
+ }
2165
+ return null;
2166
+ }
2167
+
2168
+ /**
2169
+ * The names `isWanted` accepts among the valid components of the loaded
2170
+ * integrations, in project order. Only an integration whose files can carry
2171
+ * the name is read, and it loads its docs only when it lists such a name.
2172
+ * @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} integrations
2173
+ * @param {string} wanted the folded name
2174
+ * @param {(name: string) => boolean} isWanted
2175
+ * @returns {Promise<string[]>}
2176
+ */
2177
+ async function integrationComponentNames(integrations, wanted, isWanted) {
2178
+ const naming = integrationsFilesNaming(
2179
+ integrations.map(integration => integration.components),
2180
+ wanted,
2181
+ );
2182
+ for (const [at, integration] of integrations.entries()) {
2183
+ if (!naming[at]) continue;
2184
+ if (!discoverIntegrationComponents(integration).some(r => isWanted(r.name)))
2185
+ continue;
2186
+ const {components} = await discoverValidIntegrationComponents(integration);
2187
+ const names = components.map(r => r.name).filter(isWanted);
2188
+ if (names.length > 0) return names;
2189
+ }
2190
+ return [];
2191
+ }
2192
+
2193
+ /**
2194
+ * The template ids that fold to `wanted`, as the project's template list
2195
+ * holds them. Core's ids come from file names. The whole list loads only when
2196
+ * an integration ships a template doc with such an id, when more than one
2197
+ * Core id folds to it (the list decides their order), or when one does and
2198
+ * an integration template may replace it.
2199
+ * @param {Project} project
2200
+ * @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} integrations
2201
+ * @param {string} wanted the folded name
2202
+ * @returns {Promise<string[]>}
2203
+ */
2204
+ async function templateNames(project, integrations, wanted) {
2205
+ /** @param {string} name */
2206
+ const isWanted = name => foldEntryName(name) === wanted;
2207
+ const {blocks, listed} = templateFilesNaming(integrations, wanted);
2208
+ const core = blocks
2209
+ ? coreTemplateIds(isWanted)
2210
+ : listTemplates().filter(isWanted);
2211
+ if (
2212
+ !listed &&
2213
+ core.length < 2 &&
2214
+ (core.length === 0 || !integrationsMayReplaceTemplate(integrations))
2215
+ ) {
2216
+ return core;
2217
+ }
2218
+ return /** @type {Array<{dirName?: unknown}>} */ (await project.templates())
2219
+ .map(record => record.dirName)
2220
+ .filter(name => typeof name === 'string')
2221
+ .filter(isWanted);
2222
+ }
2223
+
2011
2224
  /**
2012
2225
  * A sentence naming the packages whose docs did not load, or nothing: a doc
2013
2226
  * that fails to load withdraws its package's docs, so a reader who cannot
@@ -2041,7 +2254,7 @@ export async function resolveTopicDocs(topic, options = {}, loaded) {
2041
2254
  undefined,
2042
2255
  ERROR_CODES.ERR_UNKNOWN_TOPIC,
2043
2256
  )
2044
- : await unknownTopicError(topic, found.catalog);
2257
+ : await unknownTopicError(topic, found.catalog, {cwd});
2045
2258
  }
2046
2259
  const {catalog, entry} = found;
2047
2260
  const node = await lowerTopic(catalog, entry, effectiveLang);
@@ -2081,6 +2294,6 @@ export async function integrationDocTypes(integration, cwd) {
2081
2294
  unchecked: [
2082
2295
  ...report.unchecked,
2083
2296
  ...unread.map(entry => ({doc: rel(entry.path), reason: entry.reason})),
2084
- ].sort((a, b) => a.doc.localeCompare(b.doc)),
2297
+ ].sort((a, b) => compareText(a.doc, b.doc)),
2085
2298
  };
2086
2299
  }
@@ -8,6 +8,8 @@
8
8
  * @param {string} [options.lang]
9
9
  * @param {boolean} [options.zh]
10
10
  * @param {boolean} [options.dense]
11
+ * @param {boolean} [options.list] return the topic list, the same as giving
12
+ * no topic; docs() refuses a topic or section beside it
11
13
  * @param {boolean} [options.index] return the topic's section index instead of
12
14
  * the whole doc
13
15
  * @param {number | 'all'} [options.depth] how many levels below a docs-tree
@@ -27,6 +29,7 @@ export function docs(topic?: string, section?: string, options?: {
27
29
  lang?: string | undefined;
28
30
  zh?: boolean | undefined;
29
31
  dense?: boolean | undefined;
32
+ list?: boolean | undefined;
30
33
  index?: boolean | undefined;
31
34
  depth?: number | "all" | undefined;
32
35
  detail?: "compact" | "full" | "brief" | undefined;
@@ -78,6 +78,12 @@ export const doc = {
78
78
  description:
79
79
  'Return the token-efficient dense doc variant. It is written to be read whole, so it returns the whole doc.',
80
80
  },
81
+ {
82
+ name: 'options.list',
83
+ type: 'boolean',
84
+ description:
85
+ 'Return the topic list, the same as giving no topic. It takes no topic or section.',
86
+ },
81
87
  {
82
88
  name: 'options.index',
83
89
  type: 'boolean',
@@ -133,7 +139,7 @@ export const doc = {
133
139
  throws: [
134
140
  {
135
141
  code: 'ERR_INVALID_ARGUMENT',
136
- when: "depth is not a whole number of levels or 'all'",
142
+ when: "depth is not a whole number of levels or 'all', or list is set with a topic or section",
137
143
  },
138
144
  {
139
145
  code: 'ERR_INVALID_DETAIL',