@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
|
@@ -16,7 +16,7 @@ export const doc = {
|
|
|
16
16
|
summary:
|
|
17
17
|
'Render a page to one self-contained HTML file, or turn a rendered file back into a page.',
|
|
18
18
|
description:
|
|
19
|
-
"Renders the page module's default export on the server with the project's own React and Astryx components (outside a project, with the Astryx, React and StyleX the CLI runs with), and writes ONE static HTML file that needs nothing beside it: the page's own StyleX styles are compiled, Core's stylesheets are cut to the rules the markup uses (layer order, custom properties and keyframes kept), local images become data: URIs, and the page's source is embedded so it can be given back exactly. The file runs no script and loads nothing from the network, so it works inside a sandboxed frame with a strict content security policy, and its colors follow the viewer's light or dark scheme. Warnings name anything that may differ from what the author meant, such as a component that did not render the text it was given. With `reverse
|
|
19
|
+
"Renders the page module's default export on the server with the project's own React and Astryx components (outside a project, with the Astryx, React and StyleX the CLI runs with), and writes ONE static HTML file that needs nothing beside it: the page's own StyleX styles are compiled, Core's stylesheets are cut to the rules the markup uses (layer order, custom properties and keyframes kept), local images become data: URIs, and the page's source is embedded so it can be given back exactly. The file runs no script and loads nothing from the network, so it works inside a sandboxed frame with a strict content security policy, and its colors follow the viewer's light or dark scheme. Warnings name anything that may differ from what the author meant, such as a component that did not render the text it was given. The file opens with a plain note for its next reader, a person or an agent: the CLI version and render format that made it, the page's path, the files it carries, the packages and versions it rendered with, and the exact commands that give the page back and render it again; the embedded source records the same facts and the markup as rendered. With `reverse` (the way back, or unrender), it writes the embedded source back byte for byte, and only the files a render embeds: the page and the local modules, stylesheets, JSON files and images it imports, into a new folder; it also reports the render format, the CLI version and packages that rendered the file, and whether someone changed the markup after the render, naming each run of text that changed and where the old text sits in the restored source (the restored files stay the page as rendered); a file with Astryx markup but no embedded source is rebuilt from its component class names and data attributes (text and layout only); any other file is refused. Experimental: it may change or be removed in a patch release.",
|
|
20
20
|
importPath: '@astryxdesign/cli/api/experimental',
|
|
21
21
|
signature:
|
|
22
22
|
'render(file: string, options?: RenderOptions): Promise<RenderPageResponse | RenderReverseResponse>',
|
|
@@ -29,6 +29,9 @@ export const doc = {
|
|
|
29
29
|
'snapshot',
|
|
30
30
|
'self-contained',
|
|
31
31
|
'reverse',
|
|
32
|
+
'unrender',
|
|
33
|
+
'restore',
|
|
34
|
+
'round trip',
|
|
32
35
|
],
|
|
33
36
|
params: [
|
|
34
37
|
{
|
|
@@ -77,7 +80,7 @@ export const doc = {
|
|
|
77
80
|
{
|
|
78
81
|
type: 'render.reverse',
|
|
79
82
|
description:
|
|
80
|
-
"How the page came back (`embedded`, exact; or `rebuilt`, text and layout only), the files written, and for a rebuilt page the components it uses and what could not be rebuilt.",
|
|
83
|
+
"How the page came back (`embedded`, exact; or `rebuilt`, text and layout only), the files written; for an embedded page the path-alias imports no alias here names (`aliased`), the render format, the CLI version and packages that rendered it, and whether its markup changed after the render, with each text change; for a rebuilt page the components it uses and what could not be rebuilt.",
|
|
81
84
|
},
|
|
82
85
|
],
|
|
83
86
|
throws: [
|
|
@@ -87,6 +90,7 @@ export const doc = {
|
|
|
87
90
|
when: 'the file or `out` has the wrong kind of extension, `out` is the input itself, `title` is given with `reverse`, or `overwrite` without it; with `reverse`, the page would land under a configuration name (`vite.config.ts`) or where a test, story or benchmark runner would run it (judged from the repository root)',
|
|
88
91
|
},
|
|
89
92
|
{code: 'ERR_FILE_NOT_FOUND', when: 'the file, or a local file the page imports, does not exist'},
|
|
93
|
+
{code: 'ERR_READ_FAILED', when: 'the file is there but cannot be read: no read permission, a folder or a pipe given as the file, or another file-system error; the message names the reason'},
|
|
90
94
|
{code: 'ERR_FILE_EXISTS', when: 'rendering would replace an existing file a render did not write, reversing would replace an existing file and `overwrite` is not set, or an existing file the project protects (generated, vendored or ignored) would be replaced, which `overwrite` never does'},
|
|
91
95
|
{code: 'ERR_WRITE_FAILED', when: 'a file cannot be written, such as when `out` names a folder; with `reverse`, every file is written or none is'},
|
|
92
96
|
{code: 'ERR_RENDER_COMPILE', when: 'the page does not compile, or a stylesheet it imports is not valid CSS (the message names the file)'},
|
|
@@ -101,7 +105,11 @@ export const doc = {
|
|
|
101
105
|
code: 'ERR_RENDER_NOT_ASTRYX',
|
|
102
106
|
when: 'reversing a file a render did not write, with no embedded source and no Astryx markup; the suggestion is `astryx build "<what the page is>"`',
|
|
103
107
|
},
|
|
104
|
-
{code: 'ERR_RENDER_SOURCE_DAMAGED', when: 'reversing a file a render wrote whose embedded source was removed (and that has no Astryx components to rebuild from), a file whose embedded source is damaged, lists a path twice, carries a module, stylesheet or JSON file the page does not reach through its imports, or an image, font or media file whose bytes are not one, or carries a file a render never embeds (a dotfile or dot-folder, `node_modules`, a package manifest, lockfile or tool configuration, or any kind but a
|
|
108
|
+
{code: 'ERR_RENDER_SOURCE_DAMAGED', when: 'reversing a file a render wrote whose embedded source was removed (and that has no Astryx components to rebuild from), a file a render wrote that ends before its embedded source, a file that holds merge conflict markers, a file whose embedded source is cut short or damaged (or names a CLI version that is not a release version), lists a path twice, carries a module, stylesheet or JSON file the page does not reach through its imports, or an image, font or media file whose bytes are not one, or carries a file a render never embeds (a dotfile or dot-folder, `node_modules`, a package manifest, lockfile or tool configuration, or any kind but a module, stylesheet, JSON or image)'},
|
|
109
|
+
{
|
|
110
|
+
code: 'ERR_RENDER_NEWER_FORMAT',
|
|
111
|
+
when: 'reversing a file in a newer render format than this CLI reads; the message and the suggestion name the CLI version that wrote it',
|
|
112
|
+
},
|
|
105
113
|
{code: 'ERR_PATH_TRAVERSAL', when: 'a file would be written outside the current folder (symlinks followed), or through a symbolic link: `out`, or with `reverse` the page or an embedded file; or, with `reverse`, a file other than the page would go into a folder that already exists'},
|
|
106
114
|
],
|
|
107
115
|
examples: [
|
|
@@ -37,6 +37,28 @@ export type RenderWarning = {
|
|
|
37
37
|
*/
|
|
38
38
|
message: string;
|
|
39
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* A run of text in a rendered file that differs from the text the render
|
|
42
|
+
* wrote: someone edited the HTML after the render.
|
|
43
|
+
*/
|
|
44
|
+
export type RenderEdit = {
|
|
45
|
+
/**
|
|
46
|
+
* - The text as rendered; null for text added after the render.
|
|
47
|
+
*/
|
|
48
|
+
was: string | null;
|
|
49
|
+
/**
|
|
50
|
+
* - The text the file holds now; null for text removed after the render.
|
|
51
|
+
*/
|
|
52
|
+
now: string | null;
|
|
53
|
+
/**
|
|
54
|
+
* - The restored module or JSON file that holds the text as rendered, when it appears exactly once across them.
|
|
55
|
+
*/
|
|
56
|
+
file?: string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* - The line of `file` where that text starts.
|
|
59
|
+
*/
|
|
60
|
+
line?: number | undefined;
|
|
61
|
+
};
|
|
40
62
|
/**
|
|
41
63
|
* `astryx --json experimental render <page>`.
|
|
42
64
|
*/
|
|
@@ -54,6 +76,27 @@ export type RenderPageResponse = {
|
|
|
54
76
|
warnings: RenderWarning[];
|
|
55
77
|
};
|
|
56
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* The imports a restored page makes through a path alias that no alias in
|
|
81
|
+
* the receiving project names, and the `paths` entries that let them build.
|
|
82
|
+
*/
|
|
83
|
+
export type RenderAliased = {
|
|
84
|
+
/**
|
|
85
|
+
* - The tsconfig.json or jsconfig.json the entries belong in, from the current folder: the one TypeScript reads for the page, else a new one at the project's root (or the current folder outside a project).
|
|
86
|
+
*/
|
|
87
|
+
config: string;
|
|
88
|
+
/**
|
|
89
|
+
* - The whole `paths` it needs, relative to its `baseUrl`, else to its folder: the entries it has now, its own or inherited (a `paths` of its own replaces inherited ones), with every target the imports need (`{"@/*": ["./report-restored/*"]}`), and an entry of its own for each import through a pattern with more than one target, which TypeScript reads first.
|
|
90
|
+
*/
|
|
91
|
+
paths: Record<string, string[]>;
|
|
92
|
+
/**
|
|
93
|
+
* - Each import as the page writes it (`@/components/Header`), with the file it came back as, from the current folder.
|
|
94
|
+
*/
|
|
95
|
+
imports: {
|
|
96
|
+
import: string;
|
|
97
|
+
file: string;
|
|
98
|
+
}[];
|
|
99
|
+
};
|
|
57
100
|
/**
|
|
58
101
|
* `astryx --json experimental render --reverse <file.html>`.
|
|
59
102
|
*/
|
|
@@ -66,9 +109,18 @@ export type RenderReverseResponse = {
|
|
|
66
109
|
files: string[];
|
|
67
110
|
exact: boolean;
|
|
68
111
|
missing?: string[] | undefined;
|
|
112
|
+
aliased?: RenderAliased | undefined;
|
|
69
113
|
components?: string[] | undefined;
|
|
70
114
|
elements?: number | undefined;
|
|
71
115
|
unknown?: string[] | undefined;
|
|
72
116
|
omitted?: string[] | undefined;
|
|
117
|
+
format?: number | undefined;
|
|
118
|
+
renderedBy?: string | undefined;
|
|
119
|
+
packages?: string[] | undefined;
|
|
120
|
+
title?: string | undefined;
|
|
121
|
+
edited?: boolean | undefined;
|
|
122
|
+
stylesEdited?: boolean | undefined;
|
|
123
|
+
edits?: RenderEdit[] | undefined;
|
|
124
|
+
moreEdits?: number | undefined;
|
|
73
125
|
};
|
|
74
126
|
};
|
|
@@ -26,6 +26,17 @@
|
|
|
26
26
|
* @property {string} message - What happened and what to do, in one sentence.
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* A run of text in a rendered file that differs from the text the render
|
|
31
|
+
* wrote: someone edited the HTML after the render.
|
|
32
|
+
* @experimental May change or be removed in a patch release.
|
|
33
|
+
* @typedef {object} RenderEdit
|
|
34
|
+
* @property {string | null} was - The text as rendered; null for text added after the render.
|
|
35
|
+
* @property {string | null} now - The text the file holds now; null for text removed after the render.
|
|
36
|
+
* @property {string} [file] - The restored module or JSON file that holds the text as rendered, when it appears exactly once across them.
|
|
37
|
+
* @property {number} [line] - The line of `file` where that text starts.
|
|
38
|
+
*/
|
|
39
|
+
|
|
29
40
|
/**
|
|
30
41
|
* `astryx --json experimental render <page>`.
|
|
31
42
|
* @experimental May change or be removed in a patch release.
|
|
@@ -35,7 +46,7 @@
|
|
|
35
46
|
* @property {string} data.input - The page module, relative to cwd when inside it.
|
|
36
47
|
* @property {string} data.output - The HTML file written.
|
|
37
48
|
* @property {number} data.bytes - Size of the HTML file.
|
|
38
|
-
* @property {string[]} data.files - Local files the
|
|
49
|
+
* @property {string[]} data.files - Local files the file carries, relative to the folder that holds them all (the page's folder unless it imports from above it), page first: the modules, stylesheets, images and JSON the page loaded, and the images, fonts and media a carried module or stylesheet names by a relative path inside that folder; each is embedded so --reverse can give it back.
|
|
39
50
|
* @property {string[]} data.stylesheets - Package stylesheets that were cut to the rules the page uses and inlined.
|
|
40
51
|
* @property {number} data.classes - Distinct class names in the markup.
|
|
41
52
|
* @property {number} data.cssBytes - Size of the inlined CSS.
|
|
@@ -43,6 +54,16 @@
|
|
|
43
54
|
* @property {RenderWarning[]} data.warnings - Empty when nothing looked wrong.
|
|
44
55
|
*/
|
|
45
56
|
|
|
57
|
+
/**
|
|
58
|
+
* The imports a restored page makes through a path alias that no alias in
|
|
59
|
+
* the receiving project names, and the `paths` entries that let them build.
|
|
60
|
+
* @experimental May change or be removed in a patch release.
|
|
61
|
+
* @typedef {object} RenderAliased
|
|
62
|
+
* @property {string} config - The tsconfig.json or jsconfig.json the entries belong in, from the current folder: the one TypeScript reads for the page, else a new one at the project's root (or the current folder outside a project).
|
|
63
|
+
* @property {Record<string, string[]>} paths - The whole `paths` it needs, relative to its `baseUrl`, else to its folder: the entries it has now, its own or inherited (a `paths` of its own replaces inherited ones), with every target the imports need (`{"@/*": ["./report-restored/*"]}`), and an entry of its own for each import through a pattern with more than one target, which TypeScript reads first.
|
|
64
|
+
* @property {{import: string, file: string}[]} imports - Each import as the page writes it (`@/components/Header`), with the file it came back as, from the current folder.
|
|
65
|
+
*/
|
|
66
|
+
|
|
46
67
|
/**
|
|
47
68
|
* `astryx --json experimental render --reverse <file.html>`.
|
|
48
69
|
* @experimental May change or be removed in a patch release.
|
|
@@ -55,10 +76,19 @@
|
|
|
55
76
|
* @property {string[]} data.files - Every file written, page first.
|
|
56
77
|
* @property {boolean} data.exact - Whether the page and every file it imports came back exactly as rendered.
|
|
57
78
|
* @property {string[]} [data.missing] - Embedded only: relative imports the file did not carry (files a render never embeds), so the restored page needs them before it renders.
|
|
79
|
+
* @property {RenderAliased} [data.aliased] - Embedded only: the imports the page makes through a path alias that no alias here names. Their files come back in the page's own layout inside the new folder, and the page needs the alias to build or render again: `config` names the tsconfig.json or jsconfig.json TypeScript reads for the page (or the new one to create), `paths` the whole `paths` it needs, and `imports` each import with the file it came back as.
|
|
58
80
|
* @property {string[]} [data.components] - Rebuilt only: the components the page uses.
|
|
59
81
|
* @property {number} [data.elements] - Rebuilt only: how many component elements were rebuilt.
|
|
60
82
|
* @property {string[]} [data.unknown] - Rebuilt only: Astryx class names no installed component claims; their content is kept as plain elements.
|
|
61
83
|
* @property {string[]} [data.omitted] - Rebuilt only: component kinds left out because the markup cannot give them back (such as icons).
|
|
84
|
+
* @property {number} [data.format] - Embedded only: the render format of the file's embedded source.
|
|
85
|
+
* @property {string} [data.renderedBy] - Embedded only: the version of the CLI that rendered the file, when the file names it.
|
|
86
|
+
* @property {string[]} [data.packages] - Embedded only, when the file records them: the packages the page rendered with, as `name@version`.
|
|
87
|
+
* @property {string} [data.title] - Embedded only: the title given with --title when the page was rendered, which a render again needs too.
|
|
88
|
+
* @property {boolean} [data.edited] - Embedded only, when the file records the page as rendered: whether someone changed its markup, title or styles after the render. The restored files are always the page as rendered, without those changes.
|
|
89
|
+
* @property {boolean} [data.stylesEdited] - With `edited`: whether the styles (the <style> element) changed after the render.
|
|
90
|
+
* @property {RenderEdit[]} [data.edits] - When `edited`: each run of text that changed after the render (at most 50, the title first), so the change can be made in the source. Empty when only styles, attributes, elements or formatting changed.
|
|
91
|
+
* @property {number} [data.moreEdits] - When `edits` stops at 50: how many more changes there are.
|
|
62
92
|
*/
|
|
63
93
|
|
|
64
94
|
export {};
|
package/api/search/ORDERING.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
`spec:AST-083` owns search's result order; this file describes the data that implements it. Inside one score band, a searcher's static weights decide the order. Matches with the same score move together as one block, placed by the learned position of the block's first match: moving each one on its own breaks search's existing rules for tied matches. Inside a block, the lexical ranker's order holds, except below the first result: there a block of one domain puts a part of the first result first (its name words start with the first result's; at most two parts lead across an answer), then the match whose matched words are rarer in the catalog. Matches never cross bands or kinds. There is no model runtime: every number is a plain static value read at load time.
|
|
8
8
|
|
|
9
|
-
After that order, one fit pass reads the first ten results (`_fit-order.mjs`). The first result stays. The others split into runs of one band and kind. Inside a run, each match gets a fit to the whole query from
|
|
9
|
+
After that order, one fit pass reads the first ten results (`_fit-order.mjs`). The first result stays. The others split into runs of one band and kind. Inside a run, each match gets a fit to the whole query from the block picker's `matchOf` (`../build/blocks/blocks.mjs` with `blocks.weights.json`, over the weights' vocabulary) over the match's own docs: its name words, display name or title, description, and keywords. A match whose fit is under 1.7 times the run's median fit moves, in order, after the others in its run, unless its name spells two or more of the query's words. Such a match never moves down; it can still move up when others move after it. A run whose median fit is zero or less keeps its order. A query that is an entry's whole name skips the pass, as it skips the learned order. The pass always reads ten places before the limit cuts the answer. At the default limit, and at any limit of 10 or more, the set of results stays the same. A smaller limit shows the top of the new order, so it can show a different result. Build's loader (`loadBlockPicker` in `../build/_adapter.mjs`) reads and checks the block-picker weights for both commands. When the file is missing, unreadable, or not the picker's shape, the loader returns null and the pass keeps the order. The pass reads the weights only when a run holds two or more matches, and it decodes only the matrix rows that the query's words and those matches' docs use, so a search does not pay for the whole catalog.
|
|
10
10
|
|
|
11
11
|
## Files
|
|
12
12
|
|
|
@@ -49,6 +49,15 @@ export function resolveSearchCore(type: string | undefined, lookup: (cwd: string
|
|
|
49
49
|
coreSkippedCode: string | null;
|
|
50
50
|
wants: (domain: string) => boolean;
|
|
51
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* A full gathered catalog (every domain) in the plain form the catalog stored
|
|
54
|
+
* at publish holds (scripts/generate-search-catalog.mjs): the kept gather's
|
|
55
|
+
* form, with each page template's derived component names read now, so the
|
|
56
|
+
* store names no file.
|
|
57
|
+
* @param {Awaited<ReturnType<typeof gatherCandidates>>} gathered
|
|
58
|
+
* @returns {unknown}
|
|
59
|
+
*/
|
|
60
|
+
export function encodeStoredCatalog(gathered: Awaited<ReturnType<typeof gatherCandidates>>): unknown;
|
|
52
61
|
/**
|
|
53
62
|
* gatherCandidates, reused within one process: a later search in the same
|
|
54
63
|
* folder, for the same `type`, ranks the candidates an earlier search
|
package/api/search/_adapter.mjs
CHANGED
|
@@ -28,6 +28,10 @@ import {
|
|
|
28
28
|
gatherThemes,
|
|
29
29
|
} from './_gather-templates.mjs';
|
|
30
30
|
import {componentsInSource} from '../../foundation/discovery/template-adapter.mjs';
|
|
31
|
+
import {
|
|
32
|
+
keptStoredCatalog,
|
|
33
|
+
storedSearchCatalog,
|
|
34
|
+
} from '../../foundation/discovery/stored-search-catalog.mjs';
|
|
31
35
|
|
|
32
36
|
export {componentKeywords} from './_gather-components.mjs';
|
|
33
37
|
|
|
@@ -106,6 +110,20 @@ async function gatherDomains(options) {
|
|
|
106
110
|
requireSearchCoreDir,
|
|
107
111
|
cwd,
|
|
108
112
|
);
|
|
113
|
+
const found = coreDir == null ? null : storedSearchCatalog(coreDir, cwd);
|
|
114
|
+
const stored = found && storedCatalog(found.value, DOMAINS.filter(wants));
|
|
115
|
+
if (found && stored) {
|
|
116
|
+
const result = {
|
|
117
|
+
...stored,
|
|
118
|
+
searchedComponents: wants('component'),
|
|
119
|
+
outside:
|
|
120
|
+
stored.all.some(c => c.domain === 'theme') && isOutsideProject(cwd),
|
|
121
|
+
coreSkipped,
|
|
122
|
+
coreSkippedCode,
|
|
123
|
+
};
|
|
124
|
+
fromStore.set(result, {pm: found.pm, domains: DOMAINS.filter(wants)});
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
109
127
|
const [components, hooks, docTopics, templates, themes] = await Promise.all([
|
|
110
128
|
wants('component')
|
|
111
129
|
? gatherComponents(/** @type {string} */ (coreDir), cwd)
|
|
@@ -154,6 +172,14 @@ const GATHER_CODEC = {
|
|
|
154
172
|
* @returns {any}
|
|
155
173
|
*/
|
|
156
174
|
encode(gathered) {
|
|
175
|
+
// A catalog read from the store written at publish is kept as a
|
|
176
|
+
// reference to it: the run's stamps hold every file the store's check
|
|
177
|
+
// read, so a run that finds them unchanged reads the store as it is.
|
|
178
|
+
const reference = fromStore.get(gathered);
|
|
179
|
+
if (reference) {
|
|
180
|
+
const {all: _all, components: _components, ...rest} = gathered;
|
|
181
|
+
return {...rest, [FROM_STORE]: reference};
|
|
182
|
+
}
|
|
157
183
|
const position = new Map(
|
|
158
184
|
gathered.all.map((/** @type {any} */ c, /** @type {number} */ i) => [
|
|
159
185
|
c,
|
|
@@ -189,6 +215,15 @@ const GATHER_CODEC = {
|
|
|
189
215
|
* @returns {any}
|
|
190
216
|
*/
|
|
191
217
|
decode(stored) {
|
|
218
|
+
const reference = stored[FROM_STORE];
|
|
219
|
+
if (reference) {
|
|
220
|
+
const {[FROM_STORE]: _, ...rest} = stored;
|
|
221
|
+
const value = storedCatalog(
|
|
222
|
+
keptStoredCatalog(reference.pm),
|
|
223
|
+
reference.domains,
|
|
224
|
+
);
|
|
225
|
+
return value && {...rest, ...value};
|
|
226
|
+
}
|
|
192
227
|
const all = stored.all.map((/** @type {any} */ c) => {
|
|
193
228
|
const stored = c.weakKeywords?.[DERIVED];
|
|
194
229
|
if (stored === undefined) return c;
|
|
@@ -232,6 +267,56 @@ const GATHER_CODEC = {
|
|
|
232
267
|
},
|
|
233
268
|
};
|
|
234
269
|
|
|
270
|
+
/** Every domain a catalog gathers, as candidates name them. */
|
|
271
|
+
const DOMAINS = ['component', 'hook', 'doc', 'template', 'theme'];
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Gathered catalogs read from the catalog stored at publish, each with the
|
|
275
|
+
* package manager its docs spell commands for and the domains it holds.
|
|
276
|
+
* @type {WeakMap<object, {pm: string, domains: string[]}>}
|
|
277
|
+
*/
|
|
278
|
+
const fromStore = new WeakMap();
|
|
279
|
+
|
|
280
|
+
/** The key a kept gather's reference to the stored catalog sits under. */
|
|
281
|
+
const FROM_STORE = '\0fromStore';
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* The catalog stored at publish, decoded, with only the candidates of
|
|
285
|
+
* `domains`; null when there is none or it does not decode to a catalog's
|
|
286
|
+
* shape.
|
|
287
|
+
* @param {unknown} encoded
|
|
288
|
+
* @param {string[]} domains
|
|
289
|
+
* @returns {{all: Candidate[], components: Candidate[]} | null}
|
|
290
|
+
*/
|
|
291
|
+
function storedCatalog(encoded, domains) {
|
|
292
|
+
if (encoded == null) return null;
|
|
293
|
+
try {
|
|
294
|
+
const value = GATHER_CODEC.decode(encoded);
|
|
295
|
+
if (!GATHER_CODEC.valid(value)) return null;
|
|
296
|
+
return {
|
|
297
|
+
all: value.all.filter((/** @type {Candidate} */ c) =>
|
|
298
|
+
domains.includes(c.domain),
|
|
299
|
+
),
|
|
300
|
+
components: domains.includes('component') ? value.components : [],
|
|
301
|
+
};
|
|
302
|
+
} catch {
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* A full gathered catalog (every domain) in the plain form the catalog stored
|
|
309
|
+
* at publish holds (scripts/generate-search-catalog.mjs): the kept gather's
|
|
310
|
+
* form, with each page template's derived component names read now, so the
|
|
311
|
+
* store names no file.
|
|
312
|
+
* @param {Awaited<ReturnType<typeof gatherCandidates>>} gathered
|
|
313
|
+
* @returns {unknown}
|
|
314
|
+
*/
|
|
315
|
+
export function encodeStoredCatalog(gathered) {
|
|
316
|
+
for (const c of gathered.all) void c.weakKeywords;
|
|
317
|
+
return GATHER_CODEC.encode(gathered);
|
|
318
|
+
}
|
|
319
|
+
|
|
235
320
|
/** The key a stored template's derived component names sit under. */
|
|
236
321
|
const DERIVED = '\0derived';
|
|
237
322
|
|
|
@@ -130,25 +130,50 @@ function mentionPattern(term, t) {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
|
-
* Each
|
|
134
|
-
*
|
|
135
|
-
*
|
|
133
|
+
* Each candidate's names and keywords lowercased once, and its description,
|
|
134
|
+
* prose and guidance lowercased on first use: a search scores every candidate
|
|
135
|
+
* for every term and synonym. Keyed by the candidate object, so it goes when
|
|
136
|
+
* the catalog does. A candidate's name, aliases, keywords, description, prose
|
|
137
|
+
* and guidance must not change after its first score, as no catalog changes
|
|
138
|
+
* them: an edited candidate, including one in a stored index passed to
|
|
139
|
+
* `rankSearchIndex()` again, would still be scored on its first text.
|
|
140
|
+
* @type {WeakMap<object, {names: {name: string, lower: string, leaf: string}[], keywords: {kw: string, text: string, lower: string}[], description?: string, prose: (string | undefined)[], guidance: (string | undefined)[]}>}
|
|
136
141
|
*/
|
|
137
|
-
const
|
|
142
|
+
const prepared = new WeakMap();
|
|
138
143
|
|
|
139
|
-
/**
|
|
140
|
-
|
|
144
|
+
/** @param {any} candidate */
|
|
145
|
+
function prepare(candidate) {
|
|
146
|
+
let p = prepared.get(candidate);
|
|
147
|
+
if (p === undefined) {
|
|
148
|
+
const {name, aliases = [], keywords = []} = candidate;
|
|
149
|
+
p = {
|
|
150
|
+
names: [name, ...aliases.filter(Boolean)].map(n => {
|
|
151
|
+
const l = n.toLowerCase();
|
|
152
|
+
return {name: n, lower: l, leaf: l.slice(l.lastIndexOf('/') + 1)};
|
|
153
|
+
}),
|
|
154
|
+
keywords: keywords.map((/** @type {string} */ kw) => {
|
|
155
|
+
const text = String(kw);
|
|
156
|
+
return {kw, text, lower: text.toLowerCase()};
|
|
157
|
+
}),
|
|
158
|
+
description: undefined,
|
|
159
|
+
prose: [],
|
|
160
|
+
guidance: [],
|
|
161
|
+
};
|
|
162
|
+
prepared.set(candidate, p);
|
|
163
|
+
}
|
|
164
|
+
return p;
|
|
165
|
+
}
|
|
141
166
|
|
|
142
167
|
/**
|
|
143
|
-
* @param {string}
|
|
144
|
-
* @
|
|
168
|
+
* @param {(string | undefined)[]} memo
|
|
169
|
+
* @param {unknown[]} blobs
|
|
170
|
+
* @param {number} i
|
|
145
171
|
*/
|
|
146
|
-
function
|
|
147
|
-
let out =
|
|
172
|
+
function loweredAt(memo, blobs, i) {
|
|
173
|
+
let out = memo[i];
|
|
148
174
|
if (out === undefined) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
lowered.set(text, out);
|
|
175
|
+
out = String(blobs[i]).toLowerCase();
|
|
176
|
+
memo[i] = out;
|
|
152
177
|
}
|
|
153
178
|
return out;
|
|
154
179
|
}
|
|
@@ -196,10 +221,7 @@ export function scoreCandidate(
|
|
|
196
221
|
{fuzzy = true, joins = true, part = false, synonym = false} = {},
|
|
197
222
|
) {
|
|
198
223
|
const {
|
|
199
|
-
name,
|
|
200
|
-
aliases = [],
|
|
201
224
|
domain,
|
|
202
|
-
keywords = [],
|
|
203
225
|
description = '',
|
|
204
226
|
prose = [],
|
|
205
227
|
guidance = [],
|
|
@@ -208,6 +230,7 @@ export function scoreCandidate(
|
|
|
208
230
|
} = candidate;
|
|
209
231
|
// The term's forms, worked out once for every word below.
|
|
210
232
|
const t = termWords(term);
|
|
233
|
+
const p = prepare(candidate);
|
|
211
234
|
let best = 0;
|
|
212
235
|
let reason = '';
|
|
213
236
|
/** @type {'partial' | 'keyword' | false} */
|
|
@@ -229,11 +252,13 @@ export function scoreCandidate(
|
|
|
229
252
|
// ── Name signals ────────────────────────────────────────────────
|
|
230
253
|
// An alias is a name too: a theme answers to its display name as well as
|
|
231
254
|
// its slug.
|
|
232
|
-
for (const
|
|
233
|
-
|
|
255
|
+
for (const {
|
|
256
|
+
name: candidateName,
|
|
257
|
+
lower: nameLower,
|
|
258
|
+
leaf: leafLower,
|
|
259
|
+
} of p.names) {
|
|
234
260
|
// A placed guide's name is its route, and the route's last segment is its
|
|
235
261
|
// name too, as a flat topic's is: `codemods` is authoring/building-blocks/codemods.
|
|
236
|
-
const leafLower = nameLower.slice(nameLower.lastIndexOf('/') + 1);
|
|
237
262
|
|
|
238
263
|
// A plural of the name is the name: `integration` is the `integrations`
|
|
239
264
|
// guides, `tab` the `tabs` doc.
|
|
@@ -315,8 +340,7 @@ export function scoreCandidate(
|
|
|
315
340
|
|
|
316
341
|
// ── Keyword signals ─────────────────────────────────────────────
|
|
317
342
|
const termJoined = joined(term);
|
|
318
|
-
for (const kw of keywords) {
|
|
319
|
-
const kwLower = String(kw).toLowerCase();
|
|
343
|
+
for (const {kw, text: kwText, lower: kwLower} of p.keywords) {
|
|
320
344
|
// A one-word keyword typed as separate words is the keyword: `number
|
|
321
345
|
// field` is `numberfield`. Only a
|
|
322
346
|
// lowercase keyword, one an author declares for a reader to type: a
|
|
@@ -326,12 +350,7 @@ export function scoreCandidate(
|
|
|
326
350
|
consider(90, `keyword "${kw}"`);
|
|
327
351
|
continue;
|
|
328
352
|
}
|
|
329
|
-
if (
|
|
330
|
-
joins &&
|
|
331
|
-
domain !== 'doc' &&
|
|
332
|
-
/\s/.test(term) &&
|
|
333
|
-
String(kw) === termJoined
|
|
334
|
-
) {
|
|
353
|
+
if (joins && domain !== 'doc' && /\s/.test(term) && kwText === termJoined) {
|
|
335
354
|
consider(90, `keyword "${kw}"`, 'keyword');
|
|
336
355
|
continue;
|
|
337
356
|
}
|
|
@@ -368,12 +387,12 @@ export function scoreCandidate(
|
|
|
368
387
|
// so "chart" matches "charts" and "filter" matches "filtering".
|
|
369
388
|
if (term.length >= 3) {
|
|
370
389
|
const re = mentionPattern(term, t);
|
|
371
|
-
if (description && re.test(
|
|
390
|
+
if (description && re.test((p.description ??= description.toLowerCase()))) {
|
|
372
391
|
consider(50, `description mentions "${term}"`);
|
|
373
392
|
} else {
|
|
374
393
|
let matchedProse = false;
|
|
375
|
-
for (
|
|
376
|
-
if (
|
|
394
|
+
for (let i = 0; i < prose.length; i++) {
|
|
395
|
+
if (prose[i] && re.test(loweredAt(p.prose, prose, i))) {
|
|
377
396
|
consider(50, `docs mention "${term}"`);
|
|
378
397
|
matchedProse = true;
|
|
379
398
|
break;
|
|
@@ -383,8 +402,8 @@ export function scoreCandidate(
|
|
|
383
402
|
// so the term appearing there is weaker evidence than the component's own
|
|
384
403
|
// summary. Only consulted when nothing stronger matched.
|
|
385
404
|
if (!matchedProse) {
|
|
386
|
-
for (
|
|
387
|
-
if (
|
|
405
|
+
for (let i = 0; i < guidance.length; i++) {
|
|
406
|
+
if (guidance[i] && re.test(loweredAt(p.guidance, guidance, i))) {
|
|
388
407
|
consider(45, `guidance mentions "${term}"`);
|
|
389
408
|
break;
|
|
390
409
|
}
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* @output the same response with the same results, maybe in a new order
|
|
9
9
|
* @position api/search; rankWith (_main-searcher.mjs) runs it after
|
|
10
10
|
* orderMatches, with the weights the adapter loads (loadSearchData) through
|
|
11
|
-
* build's own loader. The fit is
|
|
12
|
-
* (build/blocks/blocks.mjs)
|
|
13
|
-
* never saw is scored from its own docs the same way. Without readable
|
|
11
|
+
* build's own loader. The fit is the block picker's `matchOf`
|
|
12
|
+
* (build/blocks/blocks.mjs) over the shipped weights' vocabulary, so an entry
|
|
13
|
+
* the weights never saw is scored from its own docs the same way. Without readable
|
|
14
14
|
* weights the order stays.
|
|
15
15
|
*/
|
|
16
16
|
|
|
@@ -11,16 +11,17 @@
|
|
|
11
11
|
export function gatherComponents(coreDir: string, cwd: string): Promise<Candidate[]>;
|
|
12
12
|
/**
|
|
13
13
|
* Every component the project can use, Core's and its integrations', with the
|
|
14
|
-
* keywords its own doc declares: the discovery and doc reads search's own
|
|
14
|
+
* keywords and category its own doc declares: the discovery and doc reads search's own
|
|
15
15
|
* candidates use, without the import paths and prose a result carries. `build`
|
|
16
16
|
* reads it to tell a part of a page from a page when its search was narrowed
|
|
17
17
|
* away from components.
|
|
18
18
|
* @param {string} coreDir
|
|
19
19
|
* @param {string} cwd
|
|
20
|
-
* @returns {Promise<{name: string, keywords: string[]}[]>}
|
|
20
|
+
* @returns {Promise<{name: string, keywords: string[], category: string}[]>}
|
|
21
21
|
*/
|
|
22
22
|
export function componentKeywords(coreDir: string, cwd: string): Promise<{
|
|
23
23
|
name: string;
|
|
24
24
|
keywords: string[];
|
|
25
|
+
category: string;
|
|
25
26
|
}[]>;
|
|
26
27
|
export type Candidate = import("./_lexical.mjs").Candidate;
|
|
@@ -76,6 +76,7 @@ async function gatherCoreComponents(coreDir) {
|
|
|
76
76
|
let guidance = [];
|
|
77
77
|
/** @type {import('@astryxdesign/cli/authoring').ComponentDeprecation | undefined} */
|
|
78
78
|
let deprecated;
|
|
79
|
+
let category = '';
|
|
79
80
|
if (readme && readme.endsWith('.doc.mjs')) {
|
|
80
81
|
const loaded = await loadModuleDoc(readme);
|
|
81
82
|
// A member documented in its family's doc (VStack in Stack's doc) is
|
|
@@ -87,6 +88,7 @@ async function gatherCoreComponents(coreDir) {
|
|
|
87
88
|
description = doc.usage?.description || doc.description || '';
|
|
88
89
|
guidance = guidanceFrom(doc);
|
|
89
90
|
deprecated = doc.deprecated;
|
|
91
|
+
category = typeof doc.category === 'string' ? doc.category : '';
|
|
90
92
|
}
|
|
91
93
|
for (const [n, place] of familyPlaces(loaded)) places.set(n, place);
|
|
92
94
|
}
|
|
@@ -97,6 +99,7 @@ async function gatherCoreComponents(coreDir) {
|
|
|
97
99
|
description,
|
|
98
100
|
guidance,
|
|
99
101
|
...(deprecated ? {_deprecated: deprecated} : {}),
|
|
102
|
+
_category: category,
|
|
100
103
|
_package: CORE_PACKAGE,
|
|
101
104
|
_import: resolveImportPath(coreDir, comp),
|
|
102
105
|
});
|
|
@@ -184,6 +187,7 @@ async function gatherIntegrationComponents(loadedIntegrations) {
|
|
|
184
187
|
description: doc ? doc.usage?.description || doc.description || '' : '',
|
|
185
188
|
guidance: guidanceFrom(doc),
|
|
186
189
|
...(doc?.deprecated ? {_deprecated: doc.deprecated} : {}),
|
|
190
|
+
_category: typeof doc?.category === 'string' ? doc.category : '',
|
|
187
191
|
...places.get(rec.name),
|
|
188
192
|
_package: rec.package ?? integration.name,
|
|
189
193
|
// Exactly what `component` reports: a doc may state its own specifier
|
|
@@ -290,17 +294,20 @@ export async function gatherComponents(coreDir, cwd) {
|
|
|
290
294
|
|
|
291
295
|
/**
|
|
292
296
|
* Every component the project can use, Core's and its integrations', with the
|
|
293
|
-
* keywords its own doc declares: the discovery and doc reads search's own
|
|
297
|
+
* keywords and category its own doc declares: the discovery and doc reads search's own
|
|
294
298
|
* candidates use, without the import paths and prose a result carries. `build`
|
|
295
299
|
* reads it to tell a part of a page from a page when its search was narrowed
|
|
296
300
|
* away from components.
|
|
297
301
|
* @param {string} coreDir
|
|
298
302
|
* @param {string} cwd
|
|
299
|
-
* @returns {Promise<{name: string, keywords: string[]}[]>}
|
|
303
|
+
* @returns {Promise<{name: string, keywords: string[], category: string}[]>}
|
|
300
304
|
*/
|
|
301
305
|
export async function componentKeywords(coreDir, cwd) {
|
|
302
306
|
/** @param {any} doc */
|
|
303
307
|
const keywordsOf = doc => (Array.isArray(doc?.keywords) ? doc.keywords : []);
|
|
308
|
+
/** @param {any} doc */
|
|
309
|
+
const categoryOf = doc =>
|
|
310
|
+
typeof doc?.category === 'string' ? doc.category : '';
|
|
304
311
|
const core = Object.values(discoverComponents(coreDir))
|
|
305
312
|
.flat()
|
|
306
313
|
.map(async name => {
|
|
@@ -309,7 +316,8 @@ export async function componentKeywords(coreDir, cwd) {
|
|
|
309
316
|
readme && readme.endsWith('.doc.mjs')
|
|
310
317
|
? await loadModuleDoc(readme)
|
|
311
318
|
: null;
|
|
312
|
-
|
|
319
|
+
const doc = familyMember(loaded, name) ?? loaded;
|
|
320
|
+
return {name, keywords: keywordsOf(doc), category: categoryOf(doc)};
|
|
313
321
|
});
|
|
314
322
|
const loadedIntegrations = await loadIntegrationsSafely(cwd);
|
|
315
323
|
const replacements = await loadComponentReplacements(
|
|
@@ -324,6 +332,7 @@ export async function componentKeywords(coreDir, cwd) {
|
|
|
324
332
|
return {
|
|
325
333
|
name: rec.name,
|
|
326
334
|
keywords: keywordsOf(integrationMemberEntry(loaded, rec) ?? loaded),
|
|
335
|
+
category: categoryOf(integrationMemberEntry(loaded, rec) ?? loaded),
|
|
327
336
|
};
|
|
328
337
|
}),
|
|
329
338
|
);
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
* @property {string} [_command] - The command that reads exactly this doc part.
|
|
30
30
|
* @property {string} [_parent] - The command that opens the level above a doc
|
|
31
31
|
* part: its topic's section list, or the docs-tree namespace it sits in.
|
|
32
|
+
* @property {string} [_category] - The category its own doc files it under.
|
|
32
33
|
* @property {string} [_package] - The npm package that owns the candidate:
|
|
33
34
|
* Core's package for its components, hooks, and templates, the integration's
|
|
34
35
|
* for what it contributed, and for a doc part the package that wrote it.
|
|
@@ -125,6 +126,10 @@ export type Candidate = {
|
|
|
125
126
|
* part: its topic's section list, or the docs-tree namespace it sits in.
|
|
126
127
|
*/
|
|
127
128
|
_parent?: string | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* - The category its own doc files it under.
|
|
131
|
+
*/
|
|
132
|
+
_category?: string | undefined;
|
|
128
133
|
/**
|
|
129
134
|
* - The npm package that owns the candidate:
|
|
130
135
|
* Core's package for its components, hooks, and templates, the integration's
|