@astryxdesign/cli 0.7.16 → 0.7.17-canary.g16fe6a8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -86
- package/api/build/_adapter.d.mts +12 -0
- package/api/build/_adapter.mjs +51 -34
- package/api/build/blocks/blocks.d.mts +7 -5
- package/api/build/blocks/blocks.mjs +113 -26
- package/api/build/build.doc.mjs +4 -3
- package/api/build/build.type.d.mts +2 -2
- package/api/build/build.type.mjs +3 -3
- package/api/build/kit/kind.d.mts +2 -1
- package/api/build/kit/kind.mjs +199 -10
- package/api/build/kit/kit.mjs +6 -4
- package/api/build/kit/rank.d.mts +4 -2
- package/api/build/kit/rank.mjs +125 -24
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +12 -8
- package/api/build/kit/weights.d.mts +39 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +340 -43
- package/api/build/kit/word-model.d.mts +23 -0
- package/api/build/kit/word-model.mjs +46 -0
- package/api/build/kit/words.d.mts +48 -0
- package/api/build/kit/words.mjs +90 -1
- package/api/component/__fixtures__/resolutions/modules.txt +4 -5
- package/api/component/list/list.d.mts +1 -1
- package/api/component/list/list.mjs +48 -6
- package/api/discover/_adapter.d.mts +1 -1
- package/api/discover/search/search.mjs +3 -2
- package/api/docs/_adapter.d.mts +28 -2
- package/api/docs/_adapter.mjs +249 -10
- package/api/docs/docs.d.mts +3 -0
- package/api/docs/docs.doc.mjs +7 -1
- package/api/docs/docs.mjs +12 -0
- package/api/docs/docs.type.d.mts +5 -0
- package/api/docs/docs.type.mjs +2 -0
- package/api/docs/node/node.mjs +1 -1
- package/api/doctor/_adapter.d.mts +27 -5
- package/api/doctor/_adapter.mjs +83 -10
- package/api/doctor/built-checks.mjs +40 -14
- package/api/doctor/doctor.d.mts +4 -3
- package/api/doctor/doctor.mjs +14 -7
- package/api/doctor/theme-checks.mjs +121 -17
- package/api/icon/_records.mjs +2 -1
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/integration/_adapter.d.mts +44 -0
- package/api/integration/_adapter.mjs +77 -1
- package/api/integration/authoring-checks.mjs +6 -6
- package/api/integration/example-scope.d.mts +14 -0
- package/api/integration/example-scope.mjs +44 -0
- package/api/integration/example-scope.type.d.mts +29 -0
- package/api/integration/example-scope.type.mjs +25 -0
- package/api/integration/integrationExampleScope.doc.d.mts +11 -0
- package/api/integration/integrationExampleScope.doc.mjs +59 -0
- package/api/integration/validate-integration.mjs +19 -1
- package/api/integration/validate-integration.type.d.mts +9 -0
- package/api/integration/validate-integration.type.mjs +1 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.mjs +591 -195
- package/api/render/render.doc.mjs +11 -3
- package/api/render/render.type.d.mts +52 -0
- package/api/render/render.type.mjs +31 -1
- package/api/search/ORDERING.md +1 -1
- package/api/search/_adapter.d.mts +9 -0
- package/api/search/_adapter.mjs +85 -0
- package/api/search/_candidate-score.mjs +51 -32
- package/api/search/_fit-order.mjs +3 -3
- package/api/search/_gather-components.d.mts +3 -2
- package/api/search/_gather-components.mjs +12 -3
- package/api/search/_lexical.d.mts +5 -0
- package/api/search/_lexical.mjs +8 -2
- package/api/search/_result.d.mts +11 -9
- package/api/search/_result.mjs +4 -4
- package/api/search/_score.d.mts +6 -1
- package/api/search/_score.mjs +15 -3
- package/api/search/search-index.mjs +7 -1
- package/api/search/search.d.mts +1 -1
- package/api/theme/_adapter.mjs +12 -1
- package/api/theme/build/build.d.mts +132 -1
- package/api/theme/build/build.mjs +482 -157
- package/api/theme/build/core-interception.d.mts +10 -0
- package/api/theme/build/core-interception.mjs +10 -0
- package/api/theme/build/font-warning.d.mts +44 -5
- package/api/theme/build/font-warning.mjs +118 -10
- package/api/theme/build/icon-imports.mjs +51 -9
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +115 -4
- package/api/theme-edit/_adapter.mjs +997 -83
- package/api/theme-edit/_catalog.d.mts +20 -2
- package/api/theme-edit/_catalog.mjs +50 -10
- package/api/theme-edit/_check.d.mts +75 -24
- package/api/theme-edit/_check.mjs +2672 -422
- package/api/theme-edit/_color.d.mts +10 -0
- package/api/theme-edit/_color.mjs +54 -1
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +133 -15
- package/api/theme-edit/_context.d.mts +14 -3
- package/api/theme-edit/_context.mjs +225 -65
- package/api/theme-edit/_css.d.mts +14 -0
- package/api/theme-edit/_css.mjs +46 -1
- package/api/theme-edit/_edit.d.mts +54 -4
- package/api/theme-edit/_edit.mjs +2966 -286
- package/api/theme-edit/_how-commands.d.mts +72 -1
- package/api/theme-edit/_how-commands.mjs +770 -9
- package/api/theme-edit/_how-question.d.mts +82 -5
- package/api/theme-edit/_how-question.mjs +6983 -701
- package/api/theme-edit/_how.d.mts +2 -1
- package/api/theme-edit/_how.mjs +237 -41
- package/api/theme-edit/_importers.d.mts +38 -0
- package/api/theme-edit/_importers.mjs +188 -0
- package/api/theme-edit/_marks.d.mts +31 -5
- package/api/theme-edit/_marks.mjs +57 -5
- package/api/theme-edit/_name-rule.d.mts +11 -0
- package/api/theme-edit/_name-rule.mjs +12 -0
- package/api/theme-edit/_normal.d.mts +303 -0
- package/api/theme-edit/_normal.mjs +1517 -0
- package/api/theme-edit/_palette.d.mts +12 -0
- package/api/theme-edit/_palette.mjs +37 -4
- package/api/theme-edit/_part-words.d.mts +31 -0
- package/api/theme-edit/_part-words.mjs +126 -0
- package/api/theme-edit/_parts.d.mts +28 -2
- package/api/theme-edit/_parts.mjs +267 -31
- package/api/theme-edit/_preview-app.d.mts +7 -13
- package/api/theme-edit/_preview-app.mjs +814 -406
- package/api/theme-edit/_preview.d.mts +116 -16
- package/api/theme-edit/_preview.mjs +649 -152
- package/api/theme-edit/_project.d.mts +22 -1
- package/api/theme-edit/_project.mjs +83 -3
- package/api/theme-edit/_settings.d.mts +467 -42
- package/api/theme-edit/_settings.mjs +3527 -468
- package/api/theme-edit/_tables.d.mts +21 -0
- package/api/theme-edit/_tables.mjs +97 -3
- package/api/theme-edit/_vet.d.mts +31 -0
- package/api/theme-edit/_vet.mjs +114 -8
- package/api/theme-edit/theme-edit.type.d.mts +16 -2
- package/api/theme-edit/theme-edit.type.mjs +6 -3
- package/api/theme-edit/themeEditHow.doc.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
- package/api/theme-edit/themeEditNew.doc.mjs +7 -4
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +3 -3
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
- package/api/upgrade/run/run.mjs +4 -3
- package/assets/codemods/integration-discovery.mjs +2 -1
- package/assets/codemods/run-codemod.mjs +87 -7
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
- package/assets/component-list.generated.json +1 -0
- package/assets/docs/author-a-theme.doc.mjs +1 -0
- package/assets/docs/theme.doc.dense.mjs +2 -2
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +2 -3
- package/assets/docs/tree/render-pages.doc.mjs +44 -3
- package/assets/docs/tree/share-a-page.doc.mjs +157 -0
- package/assets/docs/tree/single-component.doc.mjs +4 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/search-catalog.generated.json +2 -0
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
- package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/template.doc.mjs +5 -4
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +5 -1
- package/assets/templates/pages/blank/template.doc.mjs +1 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
- package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
- package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
- package/assets/templates/pages/documentation/template.doc.mjs +4 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/template.doc.mjs +2 -8
- package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
- package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
- package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +24 -2
- package/assets/templates/pages/kanban-board/template.doc.mjs +1 -9
- package/assets/templates/pages/library/template.doc.mjs +4 -1
- package/assets/templates/pages/login/template.doc.mjs +2 -1
- package/assets/templates/pages/login-card/template.doc.mjs +2 -1
- package/assets/templates/pages/login-split/template.doc.mjs +2 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
- package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
- package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- package/assets/templates/pages/table-page/template.doc.mjs +5 -4
- package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
- package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -9
- package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
- package/assets/theme.template.ts +6 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +3 -3
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/component/categories.d.mts +37 -0
- package/authoring/doctypes/component/categories.mjs +54 -0
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +9 -0
- package/authoring/example/example.doc.d.mts +12 -0
- package/authoring/example/example.doc.mjs +69 -0
- package/authoring/example/preview.d.mts +92 -0
- package/authoring/example/preview.mjs +994 -0
- package/authoring/example/type.ts +102 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +12 -0
- package/authoring/index.mjs +3 -1
- package/clients/cli/bin/astryx.mjs +6 -9
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.mjs +22 -3
- package/clients/cli/commands/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +32 -14
- package/clients/cli/commands/experimental/render.mjs +42 -1
- package/clients/cli/commands/experimental/theme.mjs +573 -119
- package/clients/cli/commands/experimental-render.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
- package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
- package/clients/cli/commands/search.doc.mjs +2 -1
- package/clients/cli/commands/search.mjs +6 -1
- package/clients/cli/commands/template.mjs +4 -2
- package/clients/cli/commands/theme-build.doc.mjs +5 -1
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +718 -438
- package/clients/cli/commands/upgrade.mjs +42 -7
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/cli-error.mjs +2 -1
- package/clients/cli/lib/component-format.mjs +205 -98
- package/clients/cli/lib/hook-format.mjs +9 -19
- package/clients/cli/lib/json-shim.mjs +132 -24
- package/clients/cli/lib/manifest.mjs +3 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/theme-state.d.mts +13 -1
- package/foundation/config/theme-state.mjs +47 -7
- package/foundation/discovery/authoring-self-docs.mjs +1 -0
- package/foundation/discovery/component-discovery.d.mts +11 -0
- package/foundation/discovery/component-discovery.mjs +56 -8
- package/foundation/discovery/component-replacement.mjs +130 -1
- package/foundation/discovery/copied-passages.mjs +2 -1
- package/foundation/discovery/core-component-docs.d.mts +29 -0
- package/foundation/discovery/core-component-docs.mjs +83 -0
- package/foundation/discovery/doc-types.mjs +4 -3
- package/foundation/discovery/entry-name-files.d.mts +43 -0
- package/foundation/discovery/entry-name-files.mjs +264 -0
- package/foundation/discovery/hook-discovery.d.mts +8 -2
- package/foundation/discovery/hook-discovery.mjs +22 -8
- package/foundation/discovery/icon-definition-discovery.mjs +2 -1
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.mjs +2 -1
- package/foundation/discovery/integration-doc-files.mjs +2 -1
- package/foundation/discovery/package-exports.d.mts +10 -0
- package/foundation/discovery/package-exports.mjs +56 -3
- package/foundation/discovery/prop-drift.mjs +9 -9
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/stored-component-list.d.mts +43 -0
- package/foundation/discovery/stored-component-list.mjs +90 -0
- package/foundation/discovery/stored-search-catalog.d.mts +115 -0
- package/foundation/discovery/stored-search-catalog.mjs +297 -0
- package/foundation/discovery/stored-self-audit.d.mts +26 -10
- package/foundation/discovery/stored-self-audit.mjs +38 -18
- package/foundation/discovery/template-adapter.d.mts +53 -1
- package/foundation/discovery/template-adapter.mjs +176 -12
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/theme-discovery.mjs +31 -4
- package/foundation/discovery/theme-imports.d.mts +14 -0
- package/foundation/discovery/theme-imports.mjs +43 -1
- package/foundation/discovery/theming-targets.d.mts +6 -5
- package/foundation/discovery/theming-targets.mjs +31 -47
- package/foundation/doc-compiler/import.mjs +7 -1
- package/foundation/doc-compiler/inputs.mjs +3 -2
- package/foundation/doc-compiler/parse-readable.mjs +4 -1
- package/foundation/doc-compiler/stored-docs.d.mts +22 -0
- package/foundation/doc-compiler/stored-docs.mjs +49 -0
- package/foundation/env/semver.mjs +3 -1
- package/foundation/fonts/font-stylesheet.d.mts +38 -0
- package/foundation/fonts/font-stylesheet.mjs +141 -0
- package/foundation/fs/cache-eviction.d.mts +21 -0
- package/foundation/fs/cache-eviction.mjs +73 -0
- package/foundation/fs/exact-codec.d.mts +12 -2
- package/foundation/fs/exact-codec.mjs +23 -6
- package/foundation/fs/file-protection.mjs +4 -3
- package/foundation/fs/gather-cache.d.mts +62 -4
- package/foundation/fs/gather-cache.mjs +517 -91
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +60 -0
- package/foundation/fs/kept-tree.mjs +154 -0
- package/foundation/fs/listing-cache.d.mts +7 -0
- package/foundation/fs/listing-cache.mjs +10 -0
- package/foundation/fs/module-loader.d.mts +24 -2
- package/foundation/fs/module-loader.mjs +94 -21
- package/foundation/fs/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/fs/read-record.d.mts +9 -0
- package/foundation/fs/read-record.mjs +19 -11
- package/foundation/fs/stop-cleanup.d.mts +12 -0
- package/foundation/fs/stop-cleanup.mjs +66 -0
- package/foundation/identity/provider-identity.d.mts +6 -0
- package/foundation/identity/provider-identity.mjs +10 -1
- package/foundation/integrations/contribution-inventory.mjs +4 -3
- package/foundation/integrations/example-code.d.mts +63 -0
- package/foundation/integrations/example-code.mjs +416 -0
- package/foundation/integrations/public-imports.d.mts +9 -0
- package/foundation/integrations/public-imports.mjs +3 -2
- package/foundation/integrations/validate-contributions.mjs +17 -45
- package/foundation/render/embedded-files.d.mts +6 -0
- package/foundation/render/embedded-files.mjs +25 -5
- package/foundation/render/embedded-imports.d.mts +39 -7
- package/foundation/render/embedded-imports.mjs +66 -27
- package/foundation/render/file-header.d.mts +66 -0
- package/foundation/render/file-header.mjs +118 -0
- package/foundation/render/host-answer.d.mts +18 -0
- package/foundation/render/host-answer.mjs +46 -0
- package/foundation/render/host-exit.d.mts +1 -0
- package/foundation/render/host-exit.mjs +6 -1
- package/foundation/render/html-reader.d.mts +55 -2
- package/foundation/render/html-reader.mjs +145 -26
- package/foundation/render/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +121 -13
- package/foundation/render/picture-chrome.d.mts +4 -0
- package/foundation/render/picture-chrome.mjs +185 -0
- package/foundation/render/picture-playwright.d.mts +4 -0
- package/foundation/render/picture-playwright.mjs +34 -0
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.d.mts +35 -3
- package/foundation/render/render-page.mjs +641 -96
- package/foundation/render/source-block.d.mts +85 -6
- package/foundation/render/source-block.mjs +211 -20
- package/foundation/render/ts-paths.d.mts +69 -6
- package/foundation/render/ts-paths.mjs +326 -40
- package/foundation/response/error-codes.d.mts +3 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +12 -1
- package/foundation/response/error-codes.mjs +11 -1
- package/foundation/response/response-types.doc.mjs +2 -2
- package/foundation/text/compare-text.d.mts +14 -0
- package/foundation/text/compare-text.mjs +68 -0
- package/foundation/text/css-escape.d.mts +18 -0
- package/foundation/text/css-escape.mjs +35 -0
- package/foundation/text/string-utils.d.mts +3 -2
- package/foundation/text/string-utils.mjs +18 -4
- package/foundation/text/suggest-order.d.mts +9 -0
- package/foundation/text/suggest-order.mjs +15 -1
- package/foundation/xle/expand.mjs +2 -1
- package/host/index.mjs +8 -6
- package/package.json +7 -6
package/api/build/kit/words.mjs
CHANGED
|
@@ -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
|
|
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/
|
|
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/
|
|
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/
|
|
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
|
|
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,
|
|
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 {
|
|
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
|
-
|
|
167
|
-
|
|
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
|
|
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: ("
|
|
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
|
|
135
|
-
a.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) {
|
package/api/docs/_adapter.d.mts
CHANGED
|
@@ -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
|
|
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
|
|
@@ -480,6 +504,7 @@ export type LinkProblem = import("../../foundation/doc-compiler/links.mjs").Link
|
|
|
480
504
|
export type LinkResolver = import("../../foundation/doc-compiler/links.mjs").LinkResolver;
|
|
481
505
|
export type DocIncluder = import("../../foundation/doc-compiler/links.mjs").DocIncluder;
|
|
482
506
|
export type DocsTopicEntry = import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry;
|
|
507
|
+
export type TreeInputs = Awaited<ReturnType<typeof loadTreeInputs>>;
|
|
483
508
|
import { DocsCatalog } from '../../foundation/discovery/docs-discovery.mjs';
|
|
484
509
|
/**
|
|
485
510
|
* The catalog one integration package's docs and links read, as doctor checks
|
|
@@ -497,4 +522,5 @@ declare function packageCatalog(integration: any, discovered: {
|
|
|
497
522
|
import { AstryxError } from '../error.mjs';
|
|
498
523
|
import { OVERLAY_LANGUAGES } from '../../foundation/doc-compiler/read.mjs';
|
|
499
524
|
import { overlayLanguages } from '../../foundation/doc-compiler/read.mjs';
|
|
525
|
+
import { loadTreeInputs } from '../../foundation/doc-compiler/tree.mjs';
|
|
500
526
|
export { OVERLAY_LANGUAGES, overlayLanguages };
|
package/api/docs/_adapter.mjs
CHANGED
|
@@ -68,23 +68,48 @@ 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
|
-
import {
|
|
91
|
+
import {persistedGather} from '../../foundation/fs/gather-cache.mjs';
|
|
92
|
+
import {EXACT_CODEC} from '../../foundation/fs/exact-codec.mjs';
|
|
93
|
+
import {CLI_ROOT, findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
80
94
|
import {reusedWhileUnchanged} from '../../foundation/fs/read-record.mjs';
|
|
81
95
|
import {AstryxError} from '../error.mjs';
|
|
82
96
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
83
|
-
import {
|
|
97
|
+
import {
|
|
98
|
+
carriesTypedWord,
|
|
99
|
+
orderRouteSuggestions,
|
|
100
|
+
} from '../../foundation/text/suggest-order.mjs';
|
|
84
101
|
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
102
|
+
import {compareText} from '../../foundation/text/compare-text.mjs';
|
|
85
103
|
|
|
86
104
|
export {OVERLAY_LANGUAGES, overlayLanguages};
|
|
87
105
|
|
|
106
|
+
/**
|
|
107
|
+
* The project each loaded catalog came from, so a later step of the same read
|
|
108
|
+
* does not load the project again.
|
|
109
|
+
* @type {WeakMap<DocsCatalog, Project>}
|
|
110
|
+
*/
|
|
111
|
+
const projectOfCatalog = new WeakMap();
|
|
112
|
+
|
|
88
113
|
/**
|
|
89
114
|
* The project's topics: the built-in ones plus whatever the configured
|
|
90
115
|
* integrations contribute.
|
|
@@ -101,7 +126,9 @@ export {OVERLAY_LANGUAGES, overlayLanguages};
|
|
|
101
126
|
export async function loadDocsCatalog(cwd = process.cwd()) {
|
|
102
127
|
try {
|
|
103
128
|
const project = await Project.load(cwd);
|
|
104
|
-
|
|
129
|
+
const catalog = await project.docs();
|
|
130
|
+
projectOfCatalog.set(catalog, project);
|
|
131
|
+
return catalog;
|
|
105
132
|
} catch {
|
|
106
133
|
return DocsCatalog.fromBuiltins();
|
|
107
134
|
}
|
|
@@ -394,8 +421,32 @@ export function projectTree(catalog, {fresh = false} = {}) {
|
|
|
394
421
|
return tree;
|
|
395
422
|
}
|
|
396
423
|
|
|
397
|
-
/**
|
|
398
|
-
|
|
424
|
+
/**
|
|
425
|
+
* The CLI's own tree files, kept between runs and loaded again after one of
|
|
426
|
+
* them changes. They are the same for every project this copy of the CLI
|
|
427
|
+
* runs in, so the copy's folder is the whole key.
|
|
428
|
+
*/
|
|
429
|
+
const keptTreeInputs = reusedWhileUnchanged(() =>
|
|
430
|
+
persistedGather(['docs-tree-inputs', CLI_ROOT], loadTreeInputs, TREE_INPUTS),
|
|
431
|
+
);
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* The CLI's own tree files, read from the files themselves, never from the
|
|
435
|
+
* kept copy: doctor checks what the files say.
|
|
436
|
+
*/
|
|
437
|
+
const readTreeInputs = reusedWhileUnchanged(() => loadTreeInputs());
|
|
438
|
+
|
|
439
|
+
/** @typedef {Awaited<ReturnType<typeof loadTreeInputs>>} TreeInputs */
|
|
440
|
+
|
|
441
|
+
/** The tree inputs, kept exactly, with the shape they need. */
|
|
442
|
+
const TREE_INPUTS = {
|
|
443
|
+
...EXACT_CODEC,
|
|
444
|
+
valid: (/** @type {any} */ value) =>
|
|
445
|
+
value != null &&
|
|
446
|
+
Array.isArray(value.namespaces) &&
|
|
447
|
+
Array.isArray(value.docs) &&
|
|
448
|
+
Array.isArray(value.diagnostics),
|
|
449
|
+
};
|
|
399
450
|
|
|
400
451
|
/**
|
|
401
452
|
* Every flat topic in the catalog, as the tree's topic levels read it.
|
|
@@ -442,7 +493,7 @@ async function flatTopicInputs(catalog) {
|
|
|
442
493
|
*/
|
|
443
494
|
async function buildProjectTree(catalog, fresh) {
|
|
444
495
|
const added = catalog.treeInputs;
|
|
445
|
-
const cli = await
|
|
496
|
+
const cli = fresh ? await readTreeInputs({fresh}) : await keptTreeInputs();
|
|
446
497
|
const result = buildDocsTree({
|
|
447
498
|
namespaces: [...cli.namespaces, ...added.flatMap(each => each.namespaces)],
|
|
448
499
|
docs: [...cli.docs, ...added.flatMap(each => each.guides)],
|
|
@@ -1932,12 +1983,16 @@ function movedRoute(topic, tree) {
|
|
|
1932
1983
|
* Otherwise it suggests the docs the argument names in another spelling, or
|
|
1933
1984
|
* failing that the topics and top-level namespaces, closest first and cut
|
|
1934
1985
|
* where the matches get weaker (every one of them when none shares a word
|
|
1935
|
-
* with the argument).
|
|
1986
|
+
* with the argument). When the argument is the name of a component, hook or
|
|
1987
|
+
* template, the command that reads that entry comes first and takes the last
|
|
1988
|
+
* suggestion's place, so the list keeps its length; when no suggested doc
|
|
1989
|
+
* shares a word with the argument, that command is the only suggestion.
|
|
1936
1990
|
* @param {unknown} topic
|
|
1937
1991
|
* @param {DocsCatalog} catalog
|
|
1992
|
+
* @param {{cwd?: string}} [options]
|
|
1938
1993
|
* @returns {Promise<AstryxError>}
|
|
1939
1994
|
*/
|
|
1940
|
-
export async function unknownTopicError(topic, catalog) {
|
|
1995
|
+
export async function unknownTopicError(topic, catalog, {cwd} = {}) {
|
|
1941
1996
|
const tree = await projectTree(catalog);
|
|
1942
1997
|
/** @type {Array<{name: string, reason: string}>} */
|
|
1943
1998
|
let suggestions = [];
|
|
@@ -1975,7 +2030,10 @@ export async function unknownTopicError(topic, catalog) {
|
|
|
1975
2030
|
)
|
|
1976
2031
|
.map(node => ({name: node.route, reason: node.summary}));
|
|
1977
2032
|
}
|
|
2033
|
+
// Every topic and namespace: the list a name no doc shares a word with gets.
|
|
2034
|
+
let everyDoc = false;
|
|
1978
2035
|
if (suggestions.length === 0) {
|
|
2036
|
+
everyDoc = true;
|
|
1979
2037
|
suggestions = [
|
|
1980
2038
|
...tree
|
|
1981
2039
|
.roots()
|
|
@@ -2001,6 +2059,16 @@ export async function unknownTopicError(topic, catalog) {
|
|
|
2001
2059
|
ERROR_CODES.ERR_UNKNOWN_TOPIC,
|
|
2002
2060
|
);
|
|
2003
2061
|
}
|
|
2062
|
+
const elsewhere =
|
|
2063
|
+
suggestions.length > 0 ? await entryElsewhere(topic, catalog, cwd) : null;
|
|
2064
|
+
if (elsewhere) {
|
|
2065
|
+
const sharesAWord =
|
|
2066
|
+
!everyDoc ||
|
|
2067
|
+
suggestions.some(entry => carriesTypedWord(String(topic), entry.name));
|
|
2068
|
+
suggestions = sharesAWord
|
|
2069
|
+
? [elsewhere, ...suggestions.slice(0, -1)]
|
|
2070
|
+
: [elsewhere];
|
|
2071
|
+
}
|
|
2004
2072
|
return new AstryxError(
|
|
2005
2073
|
`Unknown topic "${String(topic)}"${notLoaded(catalog)}`,
|
|
2006
2074
|
suggestions,
|
|
@@ -2008,6 +2076,177 @@ export async function unknownTopicError(topic, catalog) {
|
|
|
2008
2076
|
);
|
|
2009
2077
|
}
|
|
2010
2078
|
|
|
2079
|
+
/**
|
|
2080
|
+
* The command that reads the component, hook or template a docs argument
|
|
2081
|
+
* names, or null. Only an exact name counts, in any case and with or without
|
|
2082
|
+
* spaces and hyphens; a hook also answers to its name without `use`. A
|
|
2083
|
+
* component wins over a hook, and a hook over a template. A route never names
|
|
2084
|
+
* one of them.
|
|
2085
|
+
* @param {string} topic
|
|
2086
|
+
* @param {{components?: string[], hooks?: string[], templates?: string[]}} names
|
|
2087
|
+
* @returns {{name: string, reason: string} | null}
|
|
2088
|
+
*/
|
|
2089
|
+
export function entryCommand(
|
|
2090
|
+
topic,
|
|
2091
|
+
{components = [], hooks = [], templates = []},
|
|
2092
|
+
) {
|
|
2093
|
+
if (topic.includes('/')) return null;
|
|
2094
|
+
const wanted = foldEntryName(topic);
|
|
2095
|
+
if (wanted === '') return null;
|
|
2096
|
+
const component = components.find(name => foldEntryName(name) === wanted);
|
|
2097
|
+
if (component) {
|
|
2098
|
+
return {
|
|
2099
|
+
name: `astryx component ${component}`,
|
|
2100
|
+
reason: 'a component, not a docs topic',
|
|
2101
|
+
};
|
|
2102
|
+
}
|
|
2103
|
+
const hook = hooks.find(name => {
|
|
2104
|
+
const folded = foldEntryName(name);
|
|
2105
|
+
return folded === wanted || folded === `use${wanted}`;
|
|
2106
|
+
});
|
|
2107
|
+
if (hook) {
|
|
2108
|
+
return {name: `astryx hook ${hook}`, reason: 'a hook, not a docs topic'};
|
|
2109
|
+
}
|
|
2110
|
+
const template = templates.find(name => foldEntryName(name) === wanted);
|
|
2111
|
+
if (template) {
|
|
2112
|
+
return {
|
|
2113
|
+
name: `astryx template ${template}`,
|
|
2114
|
+
reason: 'a template, not a docs topic',
|
|
2115
|
+
};
|
|
2116
|
+
}
|
|
2117
|
+
return null;
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
/**
|
|
2121
|
+
* {@link entryCommand} over the names the project's catalogs hold. File names
|
|
2122
|
+
* and doc text say first which catalogs can hold the argument; a catalog is
|
|
2123
|
+
* asked only then, only for the names that fold to the argument, and only
|
|
2124
|
+
* when the one before it has no match. So a name no file carries reads no doc.
|
|
2125
|
+
* A check that fails gives no hint.
|
|
2126
|
+
* @param {unknown} topic
|
|
2127
|
+
* @param {DocsCatalog} catalog the catalog the read used; its project is
|
|
2128
|
+
* reused
|
|
2129
|
+
* @param {string} [cwd]
|
|
2130
|
+
* @returns {Promise<{name: string, reason: string} | null>}
|
|
2131
|
+
*/
|
|
2132
|
+
async function entryElsewhere(topic, catalog, cwd = process.cwd()) {
|
|
2133
|
+
if (typeof topic !== 'string' || topic.includes('/')) return null;
|
|
2134
|
+
const wanted = foldEntryName(topic);
|
|
2135
|
+
if (wanted === '') return null;
|
|
2136
|
+
let project = projectOfCatalog.get(catalog);
|
|
2137
|
+
try {
|
|
2138
|
+
project ??= await Project.load(cwd);
|
|
2139
|
+
} catch {
|
|
2140
|
+
return null;
|
|
2141
|
+
}
|
|
2142
|
+
const coreDir = project.coreDir();
|
|
2143
|
+
const integrations = project.loadedIntegrations;
|
|
2144
|
+
/** @param {string} name */
|
|
2145
|
+
const isWanted = name => foldEntryName(name) === wanted;
|
|
2146
|
+
/** @param {string} name */
|
|
2147
|
+
const isWantedHook = name =>
|
|
2148
|
+
isWanted(name) || foldEntryName(name) === `use${wanted}`;
|
|
2149
|
+
/** @type {{component: boolean, hook: boolean, componentTops?: Set<string>, hookTops?: Set<string>}} */
|
|
2150
|
+
let inCore = {component: false, hook: false};
|
|
2151
|
+
try {
|
|
2152
|
+
if (coreDir) inCore = coreFilesNaming(coreDir, wanted);
|
|
2153
|
+
} catch {
|
|
2154
|
+
inCore = {component: true, hook: true};
|
|
2155
|
+
}
|
|
2156
|
+
/** @type {Array<() => Promise<{components?: string[], hooks?: string[], templates?: string[]}>>} */
|
|
2157
|
+
const catalogs = [
|
|
2158
|
+
async () => ({
|
|
2159
|
+
components:
|
|
2160
|
+
coreDir && inCore.component
|
|
2161
|
+
? discoverComponentNamesWhere(coreDir, isWanted, inCore.componentTops)
|
|
2162
|
+
: [],
|
|
2163
|
+
}),
|
|
2164
|
+
async () => ({
|
|
2165
|
+
components: await integrationComponentNames(
|
|
2166
|
+
integrations,
|
|
2167
|
+
wanted,
|
|
2168
|
+
isWanted,
|
|
2169
|
+
),
|
|
2170
|
+
}),
|
|
2171
|
+
async () => ({
|
|
2172
|
+
hooks:
|
|
2173
|
+
coreDir && inCore.hook
|
|
2174
|
+
? getAllHookNames(coreDir, isWantedHook, inCore.hookTops)
|
|
2175
|
+
: [],
|
|
2176
|
+
}),
|
|
2177
|
+
async () => ({
|
|
2178
|
+
templates: await templateNames(project, integrations, wanted),
|
|
2179
|
+
}),
|
|
2180
|
+
];
|
|
2181
|
+
for (const load of catalogs) {
|
|
2182
|
+
let names;
|
|
2183
|
+
try {
|
|
2184
|
+
names = await load();
|
|
2185
|
+
} catch {
|
|
2186
|
+
continue;
|
|
2187
|
+
}
|
|
2188
|
+
const found = entryCommand(topic, names);
|
|
2189
|
+
if (found) return found;
|
|
2190
|
+
}
|
|
2191
|
+
return null;
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
/**
|
|
2195
|
+
* The names `isWanted` accepts among the valid components of the loaded
|
|
2196
|
+
* integrations, in project order. Only an integration whose files can carry
|
|
2197
|
+
* the name is read, and it loads its docs only when it lists such a name.
|
|
2198
|
+
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} integrations
|
|
2199
|
+
* @param {string} wanted the folded name
|
|
2200
|
+
* @param {(name: string) => boolean} isWanted
|
|
2201
|
+
* @returns {Promise<string[]>}
|
|
2202
|
+
*/
|
|
2203
|
+
async function integrationComponentNames(integrations, wanted, isWanted) {
|
|
2204
|
+
const naming = integrationsFilesNaming(
|
|
2205
|
+
integrations.map(integration => integration.components),
|
|
2206
|
+
wanted,
|
|
2207
|
+
);
|
|
2208
|
+
for (const [at, integration] of integrations.entries()) {
|
|
2209
|
+
if (!naming[at]) continue;
|
|
2210
|
+
if (!discoverIntegrationComponents(integration).some(r => isWanted(r.name)))
|
|
2211
|
+
continue;
|
|
2212
|
+
const {components} = await discoverValidIntegrationComponents(integration);
|
|
2213
|
+
const names = components.map(r => r.name).filter(isWanted);
|
|
2214
|
+
if (names.length > 0) return names;
|
|
2215
|
+
}
|
|
2216
|
+
return [];
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
/**
|
|
2220
|
+
* The template ids that fold to `wanted`, as the project's template list
|
|
2221
|
+
* holds them. Core's ids come from file names. The whole list loads only when
|
|
2222
|
+
* an integration ships a template doc with such an id, when more than one
|
|
2223
|
+
* Core id folds to it (the list decides their order), or when one does and
|
|
2224
|
+
* an integration template may replace it.
|
|
2225
|
+
* @param {Project} project
|
|
2226
|
+
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} integrations
|
|
2227
|
+
* @param {string} wanted the folded name
|
|
2228
|
+
* @returns {Promise<string[]>}
|
|
2229
|
+
*/
|
|
2230
|
+
async function templateNames(project, integrations, wanted) {
|
|
2231
|
+
/** @param {string} name */
|
|
2232
|
+
const isWanted = name => foldEntryName(name) === wanted;
|
|
2233
|
+
const {blocks, listed} = templateFilesNaming(integrations, wanted);
|
|
2234
|
+
const core = blocks
|
|
2235
|
+
? coreTemplateIds(isWanted)
|
|
2236
|
+
: listTemplates().filter(isWanted);
|
|
2237
|
+
if (
|
|
2238
|
+
!listed &&
|
|
2239
|
+
core.length < 2 &&
|
|
2240
|
+
(core.length === 0 || !integrationsMayReplaceTemplate(integrations))
|
|
2241
|
+
) {
|
|
2242
|
+
return core;
|
|
2243
|
+
}
|
|
2244
|
+
return /** @type {Array<{dirName?: unknown}>} */ (await project.templates())
|
|
2245
|
+
.map(record => record.dirName)
|
|
2246
|
+
.filter(name => typeof name === 'string')
|
|
2247
|
+
.filter(isWanted);
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2011
2250
|
/**
|
|
2012
2251
|
* A sentence naming the packages whose docs did not load, or nothing: a doc
|
|
2013
2252
|
* that fails to load withdraws its package's docs, so a reader who cannot
|
|
@@ -2041,7 +2280,7 @@ export async function resolveTopicDocs(topic, options = {}, loaded) {
|
|
|
2041
2280
|
undefined,
|
|
2042
2281
|
ERROR_CODES.ERR_UNKNOWN_TOPIC,
|
|
2043
2282
|
)
|
|
2044
|
-
: await unknownTopicError(topic, found.catalog);
|
|
2283
|
+
: await unknownTopicError(topic, found.catalog, {cwd});
|
|
2045
2284
|
}
|
|
2046
2285
|
const {catalog, entry} = found;
|
|
2047
2286
|
const node = await lowerTopic(catalog, entry, effectiveLang);
|
|
@@ -2081,6 +2320,6 @@ export async function integrationDocTypes(integration, cwd) {
|
|
|
2081
2320
|
unchecked: [
|
|
2082
2321
|
...report.unchecked,
|
|
2083
2322
|
...unread.map(entry => ({doc: rel(entry.path), reason: entry.reason})),
|
|
2084
|
-
].sort((a, b) => a.doc
|
|
2323
|
+
].sort((a, b) => compareText(a.doc, b.doc)),
|
|
2085
2324
|
};
|
|
2086
2325
|
}
|