@astryxdesign/cli 0.7.17-canary.g5a3fd39 → 0.7.17-canary.g5cf5d69
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 +64 -63
- package/api/build/_adapter.d.mts +51 -0
- package/api/build/_adapter.mjs +122 -6
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.mjs +23 -14
- package/api/build/build.type.d.mts +1 -1
- package/api/build/build.type.mjs +3 -3
- package/api/build/help/help.d.mts +15 -14
- package/api/build/help/help.mjs +62 -3
- package/api/build/kit/answer.mjs +2 -3
- package/api/build/kit/signals.d.mts +10 -0
- package/api/build/kit/signals.mjs +15 -2
- package/api/component/detail/blocks/blocks.mjs +2 -1
- package/api/discover/_adapter.d.mts +57 -6
- package/api/discover/_adapter.mjs +278 -49
- package/api/discover/_catalog-view.d.mts +7 -0
- package/api/discover/_catalog-view.mjs +10 -1
- package/api/discover/detail/detail.d.mts +3 -2
- package/api/discover/detail/detail.mjs +3 -2
- package/api/discover/detail/doc/doc.mjs +1 -1
- package/api/discover/discover.d.mts +24 -0
- package/api/discover/discover.doc.mjs +1 -1
- package/api/discover/discover.mjs +146 -25
- package/api/discover/discover.type.d.mts +6 -4
- package/api/discover/discover.type.mjs +6 -4
- package/api/discover/search/search.d.mts +22 -0
- package/api/discover/search/search.mjs +290 -70
- package/api/docs/_entry-names.mjs +4 -3
- package/api/doctor/_adapter.d.mts +43 -3
- package/api/doctor/_adapter.mjs +142 -18
- package/api/doctor/built-checks.d.mts +30 -3
- package/api/doctor/built-checks.mjs +132 -5
- package/api/doctor/doctor.d.mts +93 -6
- package/api/doctor/doctor.doc.mjs +2 -2
- package/api/doctor/doctor.mjs +524 -33
- package/api/doctor/doctor.type.d.mts +2 -1
- package/api/doctor/doctor.type.mjs +2 -1
- package/api/doctor/theme-checks.d.mts +19 -0
- package/api/doctor/theme-checks.mjs +74 -6
- package/api/hook/hook.type.d.mts +1 -1
- package/api/hook/hook.type.mjs +1 -1
- package/api/hook/list/list.mjs +11 -7
- package/api/icon/_adapter.d.mts +2 -1
- package/api/icon/_adapter.mjs +10 -15
- package/api/icon/_records.d.mts +3 -1
- package/api/icon/_records.mjs +30 -3
- package/api/icon/exportIconIndex.doc.mjs +1 -1
- package/api/icon/icon.doc.mjs +3 -3
- package/api/icon/icon.type.d.mts +32 -1
- package/api/icon/icon.type.mjs +19 -3
- package/api/icon/list/list.mjs +4 -1
- package/api/icon/rankIconIndex.doc.mjs +1 -1
- package/api/icon/search/icon-index.mjs +18 -8
- package/api/icon/search/search.d.mts +26 -3
- package/api/icon/search/search.mjs +155 -9
- package/api/init/_adapter.d.mts +14 -0
- package/api/init/_adapter.mjs +26 -4
- package/api/init/init.d.mts +1 -1
- package/api/init/init.doc.mjs +2 -2
- package/api/init/init.mjs +1 -1
- package/api/init/init.type.d.mts +29 -1
- package/api/init/init.type.mjs +14 -1
- package/api/init/run/run.d.mts +11 -1
- package/api/init/run/run.mjs +84 -5
- package/api/integration/_adapter.d.mts +5 -4
- package/api/integration/_adapter.mjs +7 -5
- package/api/integration/integrationCheck.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +8 -9
- package/api/integration/validate-integration.d.mts +1 -1
- package/api/integration/validate-integration.mjs +26 -24
- package/api/integration/validate-integration.type.d.mts +5 -2
- package/api/integration/validate-integration.type.mjs +5 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/render/_adapter.d.mts +4 -2
- package/api/render/_adapter.mjs +62 -21
- package/api/render/render.doc.mjs +8 -5
- package/api/render/render.mjs +1 -1
- package/api/render/render.type.d.mts +2 -0
- package/api/render/render.type.mjs +2 -0
- package/api/search/ORDERING.md +2 -2
- package/api/search/_candidate-score.d.mts +3 -0
- package/api/search/_candidate-score.mjs +36 -3
- package/api/search/_gather-docs.mjs +29 -2
- package/api/search/_gather-templates.mjs +2 -1
- package/api/search/_main-searcher.mjs +13 -0
- package/api/search/_named-keywords.d.mts +2 -1
- package/api/search/_named-keywords.mjs +48 -6
- package/api/search/_order.d.mts +36 -1
- package/api/search/_order.mjs +141 -3
- package/api/swizzle/list/list.mjs +8 -1
- package/api/swizzle/swizzle.type.d.mts +1 -1
- package/api/swizzle/swizzle.type.mjs +1 -1
- package/api/template/copy/copy.mjs +3 -4
- package/api/template/list/list.mjs +2 -1
- package/api/template/show/show.mjs +2 -1
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.mjs +19 -1
- package/api/template/template.type.d.mts +1 -0
- package/api/template/template.type.mjs +2 -1
- package/api/theme/_adapter.d.mts +1 -0
- package/api/theme/_adapter.mjs +3 -5
- package/api/theme/_app-provider.d.mts +42 -0
- package/api/theme/_app-provider.mjs +61 -27
- package/api/theme/build/build.d.mts +4 -10
- package/api/theme/build/build.mjs +165 -116
- package/api/theme/build/input-fields.d.mts +9 -0
- package/api/theme/build/input-fields.mjs +155 -16
- package/api/theme/build/radius-values.d.mts +18 -0
- package/api/theme/build/radius-values.mjs +76 -0
- package/api/theme/build/typography-values.mjs +7 -23
- package/api/theme/build/written-values.d.mts +18 -0
- package/api/theme/build/written-values.mjs +107 -31
- package/api/theme/eject/eject.mjs +6 -1
- package/api/theme/palette/generate/generator.mjs +24 -0
- package/api/theme/theme.type.d.mts +4 -2
- package/api/theme/theme.type.mjs +3 -2
- package/api/theme/themeBuild.doc.mjs +2 -2
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme-edit/_catalog.d.mts +40 -0
- package/api/theme-edit/_catalog.mjs +100 -22
- package/api/theme-edit/_check.mjs +213 -43
- package/api/theme-edit/_color.d.mts +14 -0
- package/api/theme-edit/_color.mjs +22 -0
- package/api/theme-edit/_compiler.mjs +52 -0
- package/api/theme-edit/_context.d.mts +20 -2
- package/api/theme-edit/_context.mjs +157 -29
- package/api/theme-edit/_edit.mjs +426 -58
- package/api/theme-edit/_how-question.d.mts +14 -0
- package/api/theme-edit/_how-question.mjs +1541 -127
- package/api/theme-edit/_how.mjs +43 -0
- package/api/theme-edit/_missed.mjs +107 -27
- package/api/theme-edit/_normal.d.mts +18 -4
- package/api/theme-edit/_normal.mjs +84 -3
- package/api/theme-edit/_palette.d.mts +9 -0
- package/api/theme-edit/_palette.mjs +158 -33
- package/api/theme-edit/_part-words.mjs +16 -3
- package/api/theme-edit/_parts.d.mts +8 -0
- package/api/theme-edit/_parts.mjs +120 -36
- package/api/theme-edit/_png.d.mts +24 -0
- package/api/theme-edit/_png.mjs +99 -0
- package/api/theme-edit/_preview-app.d.mts +16 -0
- package/api/theme-edit/_preview-app.mjs +52 -18
- package/api/theme-edit/_preview.d.mts +44 -26
- package/api/theme-edit/_preview.mjs +255 -67
- package/api/theme-edit/_project.d.mts +12 -1
- package/api/theme-edit/_project.mjs +16 -1
- package/api/theme-edit/_settings.d.mts +116 -0
- package/api/theme-edit/_settings.mjs +1197 -58
- package/api/theme-edit/_tables.d.mts +16 -0
- package/api/theme-edit/_tables.mjs +34 -4
- package/api/theme-edit/theme-edit.type.d.mts +15 -2
- package/api/theme-edit/theme-edit.type.mjs +8 -6
- package/api/upgrade/_adapter.d.mts +46 -7
- package/api/upgrade/_adapter.mjs +110 -15
- package/api/upgrade/registry/registry.d.mts +6 -3
- package/api/upgrade/registry/registry.mjs +21 -6
- package/api/upgrade/run/run.mjs +23 -11
- package/api/upgrade/upgrade.doc.mjs +4 -3
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/tree/agent-guidance.doc.mjs +3 -2
- package/assets/docs/tree/checks.doc.mjs +2 -2
- package/assets/docs/tree/host-entry.doc.mjs +4 -0
- package/assets/docs/tree/icon-definitions.doc.mjs +3 -3
- package/assets/docs/tree/icon-sets.doc.mjs +6 -6
- package/assets/docs/tree/problems.doc.mjs +3 -3
- package/assets/docs/tree/render-pages.doc.mjs +17 -3
- package/assets/docs/tree/share-a-page.doc.mjs +5 -5
- package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
- package/assets/docs/tree/troubleshooting.doc.mjs +8 -0
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +40 -5
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/installed-icon-set.doc.mjs +30 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Avatar/AvatarInteractive.tsx +6 -1
- package/assets/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +1 -1
- package/assets/templates/blocks/components/LinkProvider/LinkProviderCustomLink.tsx +3 -1
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +6 -2
- package/assets/templates/pages/ai-chat-landing/page.tsx +1 -1
- package/assets/templates/pages/blank/page.tsx +4 -2
- package/assets/templates/pages/canvas-editor/page.tsx +3 -1
- package/assets/templates/pages/centered-hero/page.tsx +1 -1
- package/assets/templates/pages/checkout-wizard/page.tsx +1 -1
- package/assets/templates/pages/classic-gallery/page.tsx +1 -1
- package/assets/templates/pages/contact-form/page.tsx +2 -2
- package/assets/templates/pages/course-detail/page.tsx +1 -1
- package/assets/templates/pages/dashboard/page.tsx +24 -8
- package/assets/templates/pages/dashboard-alert-rail/page.tsx +4 -2
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +7 -3
- package/assets/templates/pages/dashboard-comparison/page.tsx +5 -2
- package/assets/templates/pages/dashboard-composition/page.tsx +10 -4
- package/assets/templates/pages/dashboard-progress/page.tsx +6 -3
- package/assets/templates/pages/dashboard-scorecard/page.tsx +17 -8
- package/assets/templates/pages/detail-page/page.tsx +22 -5
- package/assets/templates/pages/documentation/page.tsx +4 -2
- package/assets/templates/pages/documentation-design/page.tsx +5 -2
- package/assets/templates/pages/documentation-technical/page.tsx +4 -2
- package/assets/templates/pages/editor/page.tsx +28 -9
- package/assets/templates/pages/file-explorer/page.tsx +3 -1
- package/assets/templates/pages/form-two-column/page.tsx +1 -1
- package/assets/templates/pages/form-wizard/page.tsx +1 -1
- package/assets/templates/pages/form-wizard-dialog/page.tsx +3 -1
- package/assets/templates/pages/form-wizard-inline/page.tsx +1 -1
- package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
- package/assets/templates/pages/gallery-hero/page.tsx +1 -1
- package/assets/templates/pages/ide/page.tsx +7 -2
- package/assets/templates/pages/kanban-board/page.tsx +10 -4
- package/assets/templates/pages/library/page.tsx +31 -61
- package/assets/templates/pages/login/page.tsx +4 -2
- package/assets/templates/pages/login-card/page.tsx +4 -2
- package/assets/templates/pages/login-split/page.tsx +3 -2
- package/assets/templates/pages/login-sso/page.tsx +4 -4
- package/assets/templates/pages/mixed-gallery/page.tsx +1 -1
- package/assets/templates/pages/payment-form/page.tsx +1 -1
- package/assets/templates/pages/product-detail/page.tsx +16 -4
- package/assets/templates/pages/product-gallery/page.tsx +1 -1
- package/assets/templates/pages/settings/page.tsx +10 -4
- package/assets/templates/pages/settings-dialog/page.tsx +5 -6
- package/assets/templates/pages/settings-sidebar/page.tsx +39 -13
- package/assets/templates/pages/side-gallery/page.tsx +1 -1
- package/assets/templates/pages/table/page.tsx +2 -2
- package/assets/templates/pages/table-filter/page.tsx +21 -6
- package/assets/templates/pages/table-grouped/page.tsx +23 -2
- package/assets/templates/pages/table-inbox/page.tsx +82 -32
- package/assets/templates/pages/theme-showcase/page.tsx +3 -2
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +12 -12
- package/assets/templates/themes/butter/butterTheme.ts +197 -4
- package/assets/templates/themes/chocolate/chocolateTheme.ts +72 -8
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +3 -3
- package/assets/templates/themes/gothic/gothicTheme.ts +114 -4
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +8 -8
- package/assets/templates/themes/matcha/matchaTheme.ts +48 -12
- package/assets/templates/themes/neutral/neutralTheme.ts +29 -0
- package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +2 -2
- package/assets/templates/themes/stone/stoneTheme.ts +69 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +9 -9
- package/assets/templates/themes/y2k/y2kTheme.ts +249 -14
- package/authoring/codemod/parse.d.mts +0 -36
- package/authoring/codemod/parse.mjs +62 -41
- package/authoring/config/config.doc.mjs +1 -1
- package/authoring/config/parse.d.mts +0 -47
- package/authoring/config/parse.mjs +128 -103
- package/authoring/config/type.ts +4 -3
- package/authoring/debug/parse.d.mts +2 -2
- package/authoring/discover/parse.d.mts +2 -2
- package/authoring/discover/parse.mjs +52 -38
- package/authoring/discover/type.ts +2 -1
- package/authoring/doctypes/_schema.d.mts +834 -950
- package/authoring/doctypes/_schema.mjs +863 -825
- package/authoring/doctypes/command/parse.mjs +2 -2
- package/authoring/doctypes/component/parse.mjs +2 -2
- package/authoring/doctypes/enum/parse.mjs +2 -2
- package/authoring/doctypes/hook/parse.mjs +2 -2
- package/authoring/doctypes/icon-definition/icon-definition.doc.mjs +1 -1
- package/authoring/doctypes/icon-definition/parse.d.mts +0 -24
- package/authoring/doctypes/icon-definition/parse.mjs +59 -43
- package/authoring/doctypes/icon-set/parse.d.mts +0 -75
- package/authoring/doctypes/icon-set/parse.mjs +239 -210
- package/authoring/doctypes/legacy.mjs +3 -3
- package/authoring/doctypes/namespace/parse.mjs +2 -2
- package/authoring/doctypes/reference/parse.mjs +2 -2
- package/authoring/doctypes/schema/parse.mjs +2 -2
- package/authoring/doctypes/template/parse.d.mts +0 -101
- package/authoring/doctypes/template/parse.mjs +131 -106
- package/authoring/doctypes/theme/parse.d.mts +0 -23
- package/authoring/doctypes/theme/parse.mjs +52 -36
- package/authoring/gap-report/parse.d.mts +1 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +14 -3
- package/authoring/integration/schema.mjs +20 -2
- package/authoring/integration/type.ts +14 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/build.mjs +27 -13
- package/clients/cli/commands/component.mjs +14 -3
- package/clients/cli/commands/discover.doc.mjs +2 -2
- package/clients/cli/commands/discover.mjs +20 -3
- package/clients/cli/commands/docs.doc.mjs +11 -9
- package/clients/cli/commands/docs.mjs +50 -21
- package/clients/cli/commands/experimental/icon.mjs +330 -227
- package/clients/cli/commands/experimental/render.mjs +16 -1
- package/clients/cli/commands/experimental/theme.mjs +42 -17
- package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-map.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +4 -1
- package/clients/cli/commands/experimental-icon-use.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
- package/clients/cli/commands/experimental-render.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/init.doc.mjs +36 -24
- package/clients/cli/commands/integration-check.doc.mjs +1 -1
- package/clients/cli/commands/mcp.doc.mjs +53 -0
- package/clients/cli/commands/mcp.mjs +51 -0
- package/clients/cli/commands/search.mjs +46 -9
- package/clients/cli/commands/template.mjs +3 -2
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +12 -2
- package/clients/cli/commands/upgrade.doc.mjs +3 -2
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/formatters/index.mjs +52 -6
- package/clients/cli/index.mjs +23 -17
- package/clients/cli/lib/base-gate.mjs +37 -5
- package/clients/cli/lib/define-command.mjs +82 -4
- package/clients/cli/lib/json-shim.mjs +61 -4
- package/clients/cli/lib/manifest.mjs +9 -1
- package/clients/cli/lib/mcp-server.mjs +286 -0
- package/clients/cli/lib/mcp-tools.mjs +405 -0
- package/clients/cli/lib/other-cli-words.mjs +99 -0
- package/clients/cli/lib/stray-option.mjs +27 -1
- package/clients/cli/lib/unknown-command.mjs +326 -11
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +1 -1
- package/foundation/agent-docs/agent-docs.d.mts +49 -1
- package/foundation/agent-docs/agent-docs.mjs +108 -7
- package/foundation/agent-docs/computer-agent-text.mjs +1 -1
- package/foundation/bases/core.d.mts +1 -1
- package/foundation/bases/core.mjs +3 -3
- package/foundation/bases/resolve.d.mts +4 -8
- package/foundation/bases/resolve.mjs +15 -21
- package/foundation/bases/state.d.mts +15 -9
- package/foundation/bases/state.mjs +33 -6
- package/foundation/config/project.d.mts +5 -4
- package/foundation/config/project.mjs +33 -17
- package/foundation/discovery/component-discovery.mjs +15 -28
- package/foundation/discovery/icon-imports.d.mts +66 -0
- package/foundation/discovery/icon-imports.mjs +225 -0
- package/foundation/discovery/icon-ranking.d.mts +12 -2
- package/foundation/discovery/icon-ranking.mjs +197 -10
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.d.mts +28 -0
- package/foundation/discovery/icon-set-discovery.mjs +42 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -11
- package/foundation/discovery/icon-set-writer.mjs +3 -29
- package/foundation/discovery/module-exports.d.mts +1 -1
- package/foundation/discovery/module-exports.mjs +136 -33
- package/foundation/discovery/name-roots.d.mts +5 -0
- package/foundation/discovery/name-roots.mjs +11 -0
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/runner-commands.mjs +1 -0
- package/foundation/discovery/template-adapter.d.mts +1 -1
- package/foundation/discovery/template-destination.d.mts +14 -6
- package/foundation/discovery/template-destination.mjs +42 -8
- package/foundation/discovery/template-icons.d.mts +45 -2
- package/foundation/discovery/template-icons.mjs +26 -54
- package/foundation/discovery/template-needs.d.mts +28 -2
- package/foundation/discovery/template-needs.mjs +92 -11
- package/foundation/discovery/theme-discovery.d.mts +8 -0
- package/foundation/discovery/theme-discovery.mjs +23 -6
- package/foundation/discovery/theme-imports.mjs +2 -4
- package/foundation/doc-compiler/parse-readable.mjs +4 -3
- package/foundation/doc-compiler/stored-docs.d.mts +13 -0
- package/foundation/doc-compiler/stored-docs.mjs +74 -3
- package/foundation/env/cli-command.d.mts +68 -10
- package/foundation/env/cli-command.mjs +116 -22
- package/foundation/env/project-scope.d.mts +9 -0
- package/foundation/env/project-scope.mjs +28 -2
- package/foundation/fs/gather-cache.d.mts +23 -0
- package/foundation/fs/gather-cache.mjs +94 -2
- package/foundation/fs/module-loader.d.mts +3 -1
- package/foundation/fs/module-loader.mjs +85 -5
- package/foundation/fs/read-record.mjs +9 -5
- package/foundation/identity/package-names.d.mts +18 -0
- package/foundation/identity/package-names.mjs +19 -0
- package/foundation/identity/providers.mjs +3 -2
- package/foundation/integrations/icon-features.d.mts +63 -0
- package/foundation/integrations/icon-features.mjs +54 -0
- package/foundation/integrations/integrations.d.mts +13 -1
- package/foundation/integrations/integrations.mjs +47 -6
- package/foundation/integrations/pack-state.d.mts +21 -0
- package/foundation/integrations/pack-state.mjs +42 -19
- package/foundation/integrations/validate-contributions.d.mts +11 -3
- package/foundation/integrations/validate-contributions.mjs +51 -13
- package/foundation/release/cache.d.mts +13 -1
- package/foundation/release/cache.mjs +94 -14
- package/foundation/release/notices.d.mts +15 -0
- package/foundation/release/notices.mjs +111 -7
- package/foundation/release/project.d.mts +3 -4
- package/foundation/release/project.mjs +5 -6
- package/foundation/render/client-bundle.d.mts +126 -0
- package/foundation/render/client-bundle.mjs +565 -0
- package/foundation/render/cut-short.d.mts +7 -1
- package/foundation/render/cut-short.mjs +46 -6
- package/foundation/render/embedded-imports.d.mts +4 -3
- package/foundation/render/embedded-imports.mjs +13 -8
- package/foundation/render/esbuild-dependency.d.mts +14 -0
- package/foundation/render/esbuild-dependency.mjs +41 -0
- package/foundation/render/file-header.mjs +5 -4
- package/foundation/render/page-worker.mjs +562 -86
- package/foundation/render/picture-chrome.mjs +54 -29
- package/foundation/render/picture-playwright.mjs +78 -42
- package/foundation/render/picture-window.d.mts +33 -0
- package/foundation/render/picture-window.mjs +78 -0
- package/foundation/render/render-page.d.mts +55 -4
- package/foundation/render/render-page.mjs +199 -28
- package/foundation/render/restore-folder.d.mts +13 -0
- package/foundation/render/restore-folder.mjs +30 -0
- package/foundation/render/served-packages.d.mts +2 -1
- package/foundation/render/served-packages.mjs +5 -3
- package/foundation/render/ts-paths.d.mts +11 -0
- package/foundation/render/ts-paths.mjs +27 -2
- package/foundation/render/value-uses.d.mts +43 -0
- package/foundation/render/value-uses.mjs +110 -0
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.doc.mjs +7 -1
- package/foundation/response/error-codes.mjs +10 -2
- package/foundation/response/response-types.doc.mjs +12 -12
- package/foundation/runtime/package-root.d.mts +8 -0
- package/foundation/runtime/package-root.mjs +20 -0
- package/foundation/suggest/other-command.d.mts +11 -0
- package/foundation/suggest/other-command.mjs +1 -1
- package/foundation/text/icon-id.d.mts +20 -0
- package/foundation/text/icon-id.mjs +40 -0
- package/foundation/text/icon-set-next.d.mts +25 -0
- package/foundation/text/icon-set-next.mjs +29 -0
- package/foundation/xle/browser.d.mts +2 -2
- package/package.json +7 -6
package/api/render/_adapter.mjs
CHANGED
|
@@ -10,8 +10,11 @@
|
|
|
10
10
|
import * as fs from 'node:fs';
|
|
11
11
|
import * as os from 'node:os';
|
|
12
12
|
import * as path from 'node:path';
|
|
13
|
+
import {freeRestoreFolder} from '../../foundation/render/restore-folder.mjs';
|
|
13
14
|
import {randomUUID} from 'node:crypto';
|
|
14
15
|
import {createRequire} from 'node:module';
|
|
16
|
+
import {installStepFor} from '../../foundation/discovery/template-needs.mjs';
|
|
17
|
+
import {installGuidanceFor} from '../../foundation/env/cli-command.mjs';
|
|
15
18
|
import {AstryxError} from '../error.mjs';
|
|
16
19
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
17
20
|
import {
|
|
@@ -49,7 +52,7 @@ import {climbsOut, findPackageRoot, isInside as liesInside, requireCoreDir} from
|
|
|
49
52
|
import {runChoice} from '../../foundation/release/run-context.mjs';
|
|
50
53
|
import {isAlive, pidSpace} from '../../foundation/release/cache.mjs';
|
|
51
54
|
import {isServedPackage} from '../../foundation/render/served-packages.mjs';
|
|
52
|
-
import {hostedRun, recordResolved} from '../../foundation/runtime/package-root.mjs';
|
|
55
|
+
import {hostedRun, recordResolved, servingRootPackages} from '../../foundation/runtime/package-root.mjs';
|
|
53
56
|
|
|
54
57
|
export {PAGE_EXTENSIONS, embeddedPathProblem};
|
|
55
58
|
|
|
@@ -136,15 +139,16 @@ function resolvesCore(dir) {
|
|
|
136
139
|
* @param {string} file absolute
|
|
137
140
|
* @param {string} cwd
|
|
138
141
|
* @param {string} what
|
|
142
|
+
* @param {string} [fix] what to do instead
|
|
139
143
|
* @returns {string}
|
|
140
144
|
*/
|
|
141
|
-
function confined(file, cwd, what) {
|
|
145
|
+
function confined(file, cwd, what, fix = 'Write inside the folder you run the command from.') {
|
|
142
146
|
try {
|
|
143
147
|
return assertWithin(file, cwd, {allowAbsolute: true, label: what});
|
|
144
148
|
} catch (e) {
|
|
145
149
|
if (e instanceof PathSafetyError) {
|
|
146
150
|
throw new AstryxError(
|
|
147
|
-
`${what} ${shown(cwd, file)} is outside the current folder; nothing was written.
|
|
151
|
+
`${what} ${shown(cwd, file)} is outside the current folder; nothing was written. ${fix}`,
|
|
148
152
|
[],
|
|
149
153
|
ERROR_CODES.ERR_PATH_TRAVERSAL,
|
|
150
154
|
);
|
|
@@ -404,14 +408,28 @@ function writeRestore(writes, folder, cwd, overwrite) {
|
|
|
404
408
|
return true;
|
|
405
409
|
}
|
|
406
410
|
|
|
407
|
-
/** @param {unknown} e */
|
|
408
|
-
function asAstryxError(e) {
|
|
411
|
+
/** @param {unknown} e @param {string} [cwd] the project the page belongs to */
|
|
412
|
+
function asAstryxError(e, cwd = process.cwd()) {
|
|
409
413
|
if (e instanceof RenderError) {
|
|
410
414
|
const code = /** @type {import('../../foundation/response/error-codes.mjs').ErrorCode} */ (e.code);
|
|
411
415
|
/** @type {{name: string, reason: string}[]} */
|
|
412
416
|
const suggestions = [];
|
|
413
417
|
if (e.code === 'ERR_RENDER_MISSING_DEPENDENCY' && typeof e.detail?.package === 'string') {
|
|
414
|
-
|
|
418
|
+
// The integration's install guidance first, then the install command
|
|
419
|
+
// the render named in the project's package manager, else the
|
|
420
|
+
// project's install step for every package it found.
|
|
421
|
+
const packages = Array.isArray(e.detail.packages) ? e.detail.packages : [e.detail.package];
|
|
422
|
+
const guidance = installGuidanceFor(packages, cwd);
|
|
423
|
+
const needs = `install ${packages.join(', ')}, which this render needs`;
|
|
424
|
+
if (guidance) {
|
|
425
|
+
suggestions.push({name: guidance, reason: needs});
|
|
426
|
+
} else if (typeof e.detail.install === 'string') {
|
|
427
|
+
suggestions.push({name: e.detail.install, reason: needs});
|
|
428
|
+
} else {
|
|
429
|
+
const {line, note} = installStepFor(packages, cwd);
|
|
430
|
+
const what = packages.length === 1 ? 'install the package the page imports' : 'install the packages the page imports';
|
|
431
|
+
suggestions.push({name: line, reason: note ? `${what} (${note})` : what});
|
|
432
|
+
}
|
|
415
433
|
}
|
|
416
434
|
return new AstryxError(e.message, suggestions, code);
|
|
417
435
|
}
|
|
@@ -422,6 +440,16 @@ function asAstryxError(e) {
|
|
|
422
440
|
return e;
|
|
423
441
|
}
|
|
424
442
|
|
|
443
|
+
/**
|
|
444
|
+
* The packages besides Astryx, React and StyleX that a page outside a project
|
|
445
|
+
* takes from the package set: the integrations the host approves, and the
|
|
446
|
+
* other packages its set declares, such as the icon library templates import.
|
|
447
|
+
* @returns {string[]}
|
|
448
|
+
*/
|
|
449
|
+
function servedExtras() {
|
|
450
|
+
return [...(hostedRun()?.integrations ?? []), ...servingRootPackages()];
|
|
451
|
+
}
|
|
452
|
+
|
|
425
453
|
/**
|
|
426
454
|
* The package set the CLI runs from, for a page outside a project
|
|
427
455
|
* (architecture:cli-surface INV30): the Core it carries, found by the rule of
|
|
@@ -438,7 +466,7 @@ function servedSet(input) {
|
|
|
438
466
|
const dir = path.dirname(input);
|
|
439
467
|
if (runChoice(dir).inProject) return null;
|
|
440
468
|
try {
|
|
441
|
-
return {dir: requireCoreDir(dir), integrations:
|
|
469
|
+
return {dir: requireCoreDir(dir), integrations: servedExtras()};
|
|
442
470
|
} catch (e) {
|
|
443
471
|
const err = /** @type {any} */ (e);
|
|
444
472
|
return err?.code === ERROR_CODES.ERR_VERSIONS_UNAVAILABLE ? {unavailable: err} : null;
|
|
@@ -447,12 +475,17 @@ function servedSet(input) {
|
|
|
447
475
|
|
|
448
476
|
/**
|
|
449
477
|
* Render a page module to one HTML file and write it.
|
|
450
|
-
* @param {{cwd: string, input: string, output: string, title?: string}} args absolute paths
|
|
478
|
+
* @param {{cwd: string, input: string, output: string, title?: string, absolute?: boolean}} args absolute paths;
|
|
479
|
+
* `absolute`: the caller named the output by an absolute path
|
|
451
480
|
* @returns {Promise<import('./render.type.mjs').RenderPageResponse['data']>}
|
|
452
481
|
*/
|
|
453
|
-
export async function renderToFile({cwd, input, output, title}) {
|
|
482
|
+
export async function renderToFile({cwd, input, output, title, absolute = false}) {
|
|
454
483
|
readInput(input, cwd);
|
|
455
|
-
|
|
484
|
+
// An absolute --out is the caller's choice of place, also outside the
|
|
485
|
+
// current folder (cli-surface DEC-16). The file there is still never one a
|
|
486
|
+
// render did not write.
|
|
487
|
+
const elsewhere = absolute && !isInside(output, cwd);
|
|
488
|
+
if (!elsewhere) confined(output, cwd, 'The output', 'Write inside the folder you run the command from, or name an absolute path.');
|
|
456
489
|
/** @type {import('../../foundation/render/render-page.mjs').RenderedPage} */
|
|
457
490
|
let page;
|
|
458
491
|
try {
|
|
@@ -461,14 +494,17 @@ export async function renderToFile({cwd, input, output, title}) {
|
|
|
461
494
|
page = await renderPage(input, {title, version: cliVersion(), served: set && 'dir' in set ? set : null, output, cwd});
|
|
462
495
|
} catch (e) {
|
|
463
496
|
// A page that needs the Core the CLI could not obtain says why.
|
|
464
|
-
const
|
|
465
|
-
|
|
497
|
+
const detail = /** @type {any} */ (e)?.code === 'ERR_RENDER_MISSING_DEPENDENCY' ? /** @type {any} */ (e).detail : null;
|
|
498
|
+
/** @type {unknown[]} */
|
|
499
|
+
const missing = Array.isArray(detail?.packages) ? detail.packages : [detail?.package];
|
|
500
|
+
const served = servedExtras();
|
|
501
|
+
if (set && 'unavailable' in set && missing.some(name => typeof name === 'string' && isServedPackage(name, served))) {
|
|
466
502
|
throw new AstryxError(set.unavailable.message, [], ERROR_CODES.ERR_VERSIONS_UNAVAILABLE);
|
|
467
503
|
}
|
|
468
504
|
throw e;
|
|
469
505
|
}
|
|
470
506
|
} catch (e) {
|
|
471
|
-
throw asAstryxError(e);
|
|
507
|
+
throw asAstryxError(e, cwd);
|
|
472
508
|
}
|
|
473
509
|
for (const {name, dir} of page.fromSet) {
|
|
474
510
|
let version = null;
|
|
@@ -479,7 +515,16 @@ export async function renderToFile({cwd, input, output, title}) {
|
|
|
479
515
|
}
|
|
480
516
|
recordResolved(name, version, dir, 'package-set');
|
|
481
517
|
}
|
|
482
|
-
refuseProtected([output], cwd);
|
|
518
|
+
if (!elsewhere) refuseProtected([output], cwd);
|
|
519
|
+
// Elsewhere, the file named is the file written: a link there would put the
|
|
520
|
+
// render wherever the link points.
|
|
521
|
+
if (elsewhere && fs.lstatSync(output, {throwIfNoEntry: false})?.isSymbolicLink()) {
|
|
522
|
+
throw new AstryxError(
|
|
523
|
+
`${shown(cwd, output)} is a symbolic link, so it is not replaced; nothing was written. Name the file itself.`,
|
|
524
|
+
[],
|
|
525
|
+
ERROR_CODES.ERR_PATH_TRAVERSAL,
|
|
526
|
+
);
|
|
527
|
+
}
|
|
483
528
|
// An existing file is replaced only when a render wrote it.
|
|
484
529
|
if (
|
|
485
530
|
fs.existsSync(output) &&
|
|
@@ -517,6 +562,8 @@ export async function renderToFile({cwd, input, output, title}) {
|
|
|
517
562
|
cssBytes: page.cssBytes,
|
|
518
563
|
images: page.images,
|
|
519
564
|
warnings: page.warnings,
|
|
565
|
+
scriptBytes: page.scriptBytes ?? 0,
|
|
566
|
+
scriptModules: page.scriptModules ?? 0,
|
|
520
567
|
};
|
|
521
568
|
}
|
|
522
569
|
|
|
@@ -629,13 +676,7 @@ function aliasedResult(unaliased, page, cwd) {
|
|
|
629
676
|
* @param {string} input absolute
|
|
630
677
|
*/
|
|
631
678
|
function restoreFolder(input) {
|
|
632
|
-
|
|
633
|
-
let folder = path.join(path.dirname(input), `${stem}-restored`);
|
|
634
|
-
for (let n = 2; fs.existsSync(folder); n++) {
|
|
635
|
-
removeStaleTemporaries(folder);
|
|
636
|
-
folder = path.join(path.dirname(input), `${stem}-restored-${n}`);
|
|
637
|
-
}
|
|
638
|
-
return folder;
|
|
679
|
+
return freeRestoreFolder(path.dirname(input), path.basename(input), removeStaleTemporaries);
|
|
639
680
|
}
|
|
640
681
|
|
|
641
682
|
/**
|
|
@@ -16,13 +16,15 @@ 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
|
|
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, when a tool runs the CLI through its host entry, the packages the `package.json` beside that CLI lists in `dependencies` or `optionalDependencies`), and writes ONE HTML file that is the page as a live app and needs nothing beside it: the page's own StyleX styles are compiled, Core's stylesheets are cut to the rules the page can use (layer order, custom properties and keyframes kept), local images become data: URIs, the page's source is embedded so it can be given back exactly, and the page's own script follows it inline: the page's modules and the packages they use, bundled for the browser by esbuild (a dependency of the CLI that only this function loads). The file paints its markup first, then the script draws the live page over it, so state, effects and event handlers work: popovers, menus, dialogs, tabs and forms behave as in the app. It loads nothing from the network and the render adds no `eval`, so it works in a sandboxed frame that allows scripts under a policy that allows inline scripts, and its colors follow the viewer's light or dark scheme. A page whose script cannot be built for the browser (a module it loads needs Node, say) is refused. A page is refused with ERR_RENDER_COMPILE naming the file, the line, the module and the missing name, as a build refuses it, when it imports a name that one of its own modules, a StyleX variables module (`.stylex`) or an `@astryxdesign/*` package does not export, draws a member (`<Name.Member>`) such an export lacks, or imports any package subpath the package does not export (a named, default or side-effect import). A name another package does not export is refused only when the page's script is built: a page that draws or calls it as it renders fails with ERR_RENDER_FAILED first. Not checked: type imports, a name the page never uses as a value, a default import from a module that exists, a named import from one of the page's own CommonJS modules (a bundler reads those by interop), and a name the page imports through a TypeScript module that only re-exports it with a plain `export {…}` (such a page fails with ERR_RENDER_FAILED if it draws or calls the name as it renders). 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>',
|
|
23
23
|
keywords: [
|
|
24
24
|
'render',
|
|
25
25
|
'static',
|
|
26
|
+
'interactive',
|
|
27
|
+
'hydrate',
|
|
26
28
|
'html',
|
|
27
29
|
'export',
|
|
28
30
|
'artifact',
|
|
@@ -44,7 +46,7 @@ export const doc = {
|
|
|
44
46
|
name: 'options.out',
|
|
45
47
|
type: 'string',
|
|
46
48
|
description:
|
|
47
|
-
"The file to write. Rendering: an .html file (default: the page's name with .html). Reversing: a page module (default: inside a new folder beside the HTML file, named after it, such as `report-restored/`).",
|
|
49
|
+
"The file to write. Rendering: an .html file (default: the page's name with .html); a relative path stays inside the current folder, and an absolute path may name any folder (a render never replaces a file it did not write). Reversing: a page module inside the current folder (default: inside a new folder beside the HTML file, named after it, such as `report-restored/`).",
|
|
48
50
|
},
|
|
49
51
|
{
|
|
50
52
|
name: 'options.reverse',
|
|
@@ -75,7 +77,7 @@ export const doc = {
|
|
|
75
77
|
{
|
|
76
78
|
type: 'render.page',
|
|
77
79
|
description:
|
|
78
|
-
|
|
80
|
+
"The page and the HTML file written, its size, the local modules embedded, the stylesheets inlined, the class and image counts, the CSS size, the script's size and how many modules it holds, and any warnings.",
|
|
79
81
|
},
|
|
80
82
|
{
|
|
81
83
|
type: 'render.reverse',
|
|
@@ -95,7 +97,8 @@ export const doc = {
|
|
|
95
97
|
{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'},
|
|
96
98
|
{code: 'ERR_RENDER_COMPILE', when: 'the page does not compile, or a stylesheet it imports is not valid CSS (the message names the file)'},
|
|
97
99
|
{code: 'ERR_RENDER_NO_DEFAULT_EXPORT', when: 'the page has no default export'},
|
|
98
|
-
{code: 'ERR_RENDER_MISSING_DEPENDENCY', when:
|
|
100
|
+
{code: 'ERR_RENDER_MISSING_DEPENDENCY', when: "the page imports a package that is not installed (the suggestion is the install line), or the esbuild the CLI depends on is missing from its install"},
|
|
101
|
+
{code: 'ERR_RENDER_SCRIPT', when: "the page's script cannot be built for the browser: a module it loads needs Node (`fs`, `path`), or cannot be found or compiled for the browser; the message names the module"},
|
|
99
102
|
{code: 'ERR_VERSIONS_UNAVAILABLE', when: 'outside a project, the page imports an Astryx package, React or StyleX, and the Core of the release that answers cannot be downloaded'},
|
|
100
103
|
{code: 'ERR_RENDER_BROWSER_API', when: 'the page reads a browser-only API, such as window or document, while rendering'},
|
|
101
104
|
{code: 'ERR_RENDER_ASSET_TOO_LARGE', when: 'a local file the page uses is over 8 MB'},
|
|
@@ -110,7 +113,7 @@ export const doc = {
|
|
|
110
113
|
code: 'ERR_RENDER_NEWER_FORMAT',
|
|
111
114
|
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
115
|
},
|
|
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'},
|
|
116
|
+
{code: 'ERR_PATH_TRAVERSAL', when: 'a file would be written outside the current folder (symlinks followed), or through a symbolic link: a relative `out`, or with `reverse` the page or an embedded file; an absolute `out` that is a symbolic link; or, with `reverse`, a file other than the page would go into a folder that already exists'},
|
|
114
117
|
],
|
|
115
118
|
examples: [
|
|
116
119
|
{label: 'Render a page', code: "const {data} = await render('src/app/page.tsx', {out: 'page.html'});"},
|
package/api/render/render.mjs
CHANGED
|
@@ -108,6 +108,6 @@ export async function render(file, options = {}) {
|
|
|
108
108
|
const target = output ?? input.replace(/\.[^.]+$/, '.html');
|
|
109
109
|
return {
|
|
110
110
|
type: 'render.page',
|
|
111
|
-
data: await renderToFile({cwd, input, output: target, title}),
|
|
111
|
+
data: await renderToFile({cwd, input, output: target, title, absolute: Boolean(options.out) && path.isAbsolute(/** @type {string} */ (options.out))}),
|
|
112
112
|
};
|
|
113
113
|
}
|
|
@@ -52,6 +52,8 @@
|
|
|
52
52
|
* @property {number} data.cssBytes - Size of the inlined CSS.
|
|
53
53
|
* @property {number} data.images - Local files inlined as data: URIs.
|
|
54
54
|
* @property {RenderWarning[]} data.warnings - Empty when nothing looked wrong.
|
|
55
|
+
* @property {number} data.scriptBytes - Size of the page's script, which `bytes` includes.
|
|
56
|
+
* @property {number} data.scriptModules - How many modules the page's script holds (the page's own, its packages', React's).
|
|
55
57
|
*/
|
|
56
58
|
|
|
57
59
|
/**
|
package/api/search/ORDERING.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Search ordering data
|
|
2
2
|
|
|
3
|
-
`astryx search` decides **what matches**, and each match's score and reason, with the lexical ranker (`_lexical.mjs` and the files it imports). The files in this folder only decide **the order of matches inside one score band**: they never add or drop a match, change a score, or move a match past one of another band or kind (doc or not). The bands are scores 195 and up, 188–194, 170–187, 160–169, 151–159, 100–150, 55–99, and under 55. A band can be wide (55–99 holds keyword matches beside one-word description hits), so inside a band a lower score can lead a higher one.
|
|
3
|
+
`astryx search` decides **what matches**, and each match's score and reason, with the lexical ranker (`_lexical.mjs` and the files it imports). The files in this folder only decide **the order of matches inside one score band**: they never add or drop a match, change a score, or move a match past one of another band or kind (doc or not). The bands are scores 195 and up, 188–194, 170–187, 160–169, 151–159, 100–150, 55–99, and under 55. A band can be wide (55–99 holds keyword matches beside one-word description hits), so inside a band a lower score can lead a higher one. In search's own reading of the catalog (`searchView` in `_named-keywords.mjs`), a doc that opens a level (a docs-tree namespace, holding the docs under its route as `_summarizes`) does not answer a query word through its text (its prose, or a code term or table cell its keywords gather) when a doc beneath it answers that word at least as strongly (`_candidate-score.mjs`); its name, title, description and declared keywords stay its own. `searchCore`, which build reads, keeps the gathered reading.
|
|
4
4
|
|
|
5
5
|
## Rule
|
|
6
6
|
|
|
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. A one-word PascalCase query that only doc text mentions is read as its words too (`identifierReading` in `_lexical.mjs`): the lexical ranker puts the entries that mention it, and those its words name outright, before the entries its words only match, and the learned order and fit pass then apply to that order as to any other.
|
|
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. Then a family's root leads a part of its own family in their run (same band and domain) when the root answers every query word the part answers and no query word is, in any plural or stem form, a word of the part's name that does not start a word of the root's name (`rootsFirst`, with families from each member's doc): `tabs` puts TabList before its Tab, while a query holding "item" keeps ListItem before List and one holding "statuses" keeps FieldStatus before Field. The root moves just ahead of the part; nothing else moves. Then the first result's tie can go to another match (`tieByOwnName`): among matches of the first result's domain that scored the same as it and matched the same query words (the terms their reasons list), a match whose name words hold more of the query's words than the first result's name moves first. A first result whose reason lists no terms keeps its place: one that matched the whole query (a name, keyword, or title hit) or whose title the query holds (`how do i generate a palette` keeps `author-a-theme` ahead of the tied `generate-a-palette` doc); a part of the first result (in its family, or its name words start with the first result's) never takes its place this way; and an entry the query names keeps it. Without this, a tie for first place goes to the first name alphabetically. 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. A one-word PascalCase query that only doc text mentions is read as its words too (`identifierReading` in `_lexical.mjs`): the lexical ranker puts the entries that mention it, and those its words name outright, before the entries its words only match, and the learned order and fit pass then apply to that order as to any other.
|
|
8
8
|
|
|
9
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
|
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
* @param {string[]} [candidate.guidance] - Usage guidance (features, best practices) — scored a tier below description.
|
|
22
22
|
* @param {string} [candidate._family] - The family whose doc lists the entry as a member.
|
|
23
23
|
* @param {number} [candidate._familyIndex] - The entry's place among that family's members.
|
|
24
|
+
* @param {any[]} [candidate._summarizes] - The docs beneath a doc that
|
|
25
|
+
* opens a level, in search's view only (_named-keywords.mjs).
|
|
24
26
|
* @param {{fuzzy?: boolean, joins?: boolean, part?: boolean, synonym?: boolean, mentions?: boolean}} [opts] - `mentions`: also say whether the hit is only a mention (see `inText`); only the reading of a one-identifier query asks, so other searches pay nothing for it. `fuzzy`: allow edit-distance (typo) matches. Default true; multi-word queries pass false. `joins`: read a spaced query joined into a name or keyword (default true); off when the query names an entry outright. `part`: the term is one word of a longer query, so a name's head word after single letters (Stack in VStack) does not count as a keyword hit for it. `synonym`: the term stands in for a word of the query, so it names no family.
|
|
25
27
|
* @returns {{score: number, reason: string, alias?: 'partial' | 'keyword', inText?: true} | null}
|
|
26
28
|
* `alias` marks a hit that read the query's words joined; `inText`, asked
|
|
@@ -40,6 +42,7 @@ export function scoreCandidate(term: string, candidate: {
|
|
|
40
42
|
guidance?: string[] | undefined;
|
|
41
43
|
_family?: string | undefined;
|
|
42
44
|
_familyIndex?: number | undefined;
|
|
45
|
+
_summarizes?: any[] | undefined;
|
|
43
46
|
}, { fuzzy, joins, part, synonym, mentions, }?: {
|
|
44
47
|
fuzzy?: boolean;
|
|
45
48
|
joins?: boolean;
|
|
@@ -236,6 +236,8 @@ function weakKeywordScore(t, kw) {
|
|
|
236
236
|
* @param {string[]} [candidate.guidance] - Usage guidance (features, best practices) — scored a tier below description.
|
|
237
237
|
* @param {string} [candidate._family] - The family whose doc lists the entry as a member.
|
|
238
238
|
* @param {number} [candidate._familyIndex] - The entry's place among that family's members.
|
|
239
|
+
* @param {any[]} [candidate._summarizes] - The docs beneath a doc that
|
|
240
|
+
* opens a level, in search's view only (_named-keywords.mjs).
|
|
239
241
|
* @param {{fuzzy?: boolean, joins?: boolean, part?: boolean, synonym?: boolean, mentions?: boolean}} [opts] - `mentions`: also say whether the hit is only a mention (see `inText`); only the reading of a one-identifier query asks, so other searches pay nothing for it. `fuzzy`: allow edit-distance (typo) matches. Default true; multi-word queries pass false. `joins`: read a spaced query joined into a name or keyword (default true); off when the query names an entry outright. `part`: the term is one word of a longer query, so a name's head word after single letters (Stack in VStack) does not count as a keyword hit for it. `synonym`: the term stands in for a word of the query, so it names no family.
|
|
240
242
|
* @returns {{score: number, reason: string, alias?: 'partial' | 'keyword', inText?: true} | null}
|
|
241
243
|
* `alias` marks a hit that read the query's words joined; `inText`, asked
|
|
@@ -271,14 +273,37 @@ export function scoreCandidate(
|
|
|
271
273
|
let alias = false;
|
|
272
274
|
/** Whether the best hit is a mention in text, not a name or keyword. */
|
|
273
275
|
let inText = false;
|
|
276
|
+
// A doc that opens a level (search's view, _named-keywords.mjs) sums up the
|
|
277
|
+
// docs beneath it: a term its text mentions that one of them answers at
|
|
278
|
+
// least as strongly is that doc's evidence, not this page's.
|
|
279
|
+
const summarized = candidate._summarizes;
|
|
280
|
+
/** @param {number} score */
|
|
281
|
+
const answeredBelow = score =>
|
|
282
|
+
summarized != null &&
|
|
283
|
+
summarized.some(
|
|
284
|
+
doc =>
|
|
285
|
+
(scoreCandidate(term, doc, {fuzzy, joins, part, synonym})?.score ??
|
|
286
|
+
0) >= score,
|
|
287
|
+
);
|
|
274
288
|
/**
|
|
275
289
|
* @param {number} score
|
|
276
290
|
* @param {string} why
|
|
277
291
|
* @param {'partial' | 'keyword' | false} [byAlias] - the hit reads the
|
|
278
292
|
* query's words joined, into part of a name or into a keyword
|
|
279
293
|
* @param {boolean} [mention] - the hit is the term mentioned in text
|
|
294
|
+
* @param {boolean} [text] - the hit is the page's text (its prose, or a
|
|
295
|
+
* keyword that text gathers) rather than its name, title, description or
|
|
296
|
+
* declared keywords; a page that sums up the docs beneath it does not
|
|
297
|
+
* take it when one of them answers the term as strongly
|
|
280
298
|
*/
|
|
281
|
-
const consider = (
|
|
299
|
+
const consider = (
|
|
300
|
+
score,
|
|
301
|
+
why,
|
|
302
|
+
byAlias = false,
|
|
303
|
+
mention = false,
|
|
304
|
+
text = false,
|
|
305
|
+
) => {
|
|
306
|
+
if (text && score > best && answeredBelow(score)) return;
|
|
282
307
|
if (score > best) {
|
|
283
308
|
best = score;
|
|
284
309
|
reason = why;
|
|
@@ -378,6 +403,9 @@ export function scoreCandidate(
|
|
|
378
403
|
|
|
379
404
|
// ── Keyword signals ─────────────────────────────────────────────
|
|
380
405
|
const termJoined = joined(term);
|
|
406
|
+
/** Whether a keyword is one the page's text gathers (see `consider`). */
|
|
407
|
+
const byText = (/** @type {string} */ lower) =>
|
|
408
|
+
summarized != null && mentionKeyword(candidate, lower);
|
|
381
409
|
for (const {kw, text: kwText, lower: kwLower} of p.keywords) {
|
|
382
410
|
// A one-word keyword typed as separate words is the keyword: `number
|
|
383
411
|
// field` is `numberfield`. Only a
|
|
@@ -390,6 +418,7 @@ export function scoreCandidate(
|
|
|
390
418
|
`keyword "${kw}"`,
|
|
391
419
|
false,
|
|
392
420
|
mentions && mentionKeyword(candidate, kwLower),
|
|
421
|
+
byText(kwLower),
|
|
393
422
|
);
|
|
394
423
|
continue;
|
|
395
424
|
}
|
|
@@ -399,6 +428,7 @@ export function scoreCandidate(
|
|
|
399
428
|
`keyword "${kw}"`,
|
|
400
429
|
'keyword',
|
|
401
430
|
mentions && mentionKeyword(candidate, kwLower),
|
|
431
|
+
byText(kwLower),
|
|
402
432
|
);
|
|
403
433
|
continue;
|
|
404
434
|
}
|
|
@@ -408,6 +438,7 @@ export function scoreCandidate(
|
|
|
408
438
|
`keyword "${kw}"`,
|
|
409
439
|
false,
|
|
410
440
|
mentions && mentionKeyword(candidate, kwLower),
|
|
441
|
+
byText(kwLower),
|
|
411
442
|
);
|
|
412
443
|
continue;
|
|
413
444
|
}
|
|
@@ -417,6 +448,7 @@ export function scoreCandidate(
|
|
|
417
448
|
`keyword "${kw}"`,
|
|
418
449
|
false,
|
|
419
450
|
mentions && mentionKeyword(candidate, kwLower),
|
|
451
|
+
byText(kwLower),
|
|
420
452
|
);
|
|
421
453
|
if (fuzzy) {
|
|
422
454
|
const dist = typoDistance(term, kwLower);
|
|
@@ -426,6 +458,7 @@ export function scoreCandidate(
|
|
|
426
458
|
`keyword "${kw}" (distance ${dist})`,
|
|
427
459
|
false,
|
|
428
460
|
mentions && mentionKeyword(candidate, kwLower),
|
|
461
|
+
byText(kwLower),
|
|
429
462
|
);
|
|
430
463
|
}
|
|
431
464
|
}
|
|
@@ -457,7 +490,7 @@ export function scoreCandidate(
|
|
|
457
490
|
let matchedProse = false;
|
|
458
491
|
for (let i = 0; i < prose.length; i++) {
|
|
459
492
|
if (prose[i] && re.test(loweredAt(p.prose, prose, i))) {
|
|
460
|
-
consider(50, `docs mention "${term}"`, false, true);
|
|
493
|
+
consider(50, `docs mention "${term}"`, false, true, true);
|
|
461
494
|
matchedProse = true;
|
|
462
495
|
break;
|
|
463
496
|
}
|
|
@@ -468,7 +501,7 @@ export function scoreCandidate(
|
|
|
468
501
|
if (!matchedProse) {
|
|
469
502
|
for (let i = 0; i < guidance.length; i++) {
|
|
470
503
|
if (guidance[i] && re.test(loweredAt(p.guidance, guidance, i))) {
|
|
471
|
-
consider(45, `guidance mentions "${term}"`, false, true);
|
|
504
|
+
consider(45, `guidance mentions "${term}"`, false, true, true);
|
|
472
505
|
break;
|
|
473
506
|
}
|
|
474
507
|
}
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
} from '../../foundation/discovery/docs-section-key.mjs';
|
|
21
21
|
import {sectionProse, codeTerms, headings, plain} from './_doc-text.mjs';
|
|
22
22
|
import {loadAuthoringSelfDocs} from '../../foundation/discovery/authoring-self-docs.mjs';
|
|
23
|
+
import {readDocAsData} from '../../foundation/discovery/docs-discovery.mjs';
|
|
23
24
|
|
|
24
25
|
/** @typedef {import('./_lexical.mjs').Candidate} Candidate */
|
|
25
26
|
|
|
@@ -73,12 +74,16 @@ export async function gatherDocs(cwd) {
|
|
|
73
74
|
}
|
|
74
75
|
const read = lowered?.doc ?? null;
|
|
75
76
|
if (isExperimentalDoc(read)) continue;
|
|
77
|
+
const hiddenHere = new Set([
|
|
78
|
+
...hidden,
|
|
79
|
+
...(await experimentalSectionKeys(entry.extensions)),
|
|
80
|
+
]);
|
|
76
81
|
const doc =
|
|
77
|
-
read &&
|
|
82
|
+
read && hiddenHere.size > 0 && Array.isArray(read.sections)
|
|
78
83
|
? {
|
|
79
84
|
...read,
|
|
80
85
|
sections: read.sections.filter(
|
|
81
|
-
(/** @type {any} */ section) => !
|
|
86
|
+
(/** @type {any} */ section) => !hiddenHere.has(section.id),
|
|
82
87
|
),
|
|
83
88
|
}
|
|
84
89
|
: read;
|
|
@@ -194,6 +199,28 @@ export async function gatherDocs(cwd) {
|
|
|
194
199
|
return candidates;
|
|
195
200
|
}
|
|
196
201
|
|
|
202
|
+
/**
|
|
203
|
+
* The keys of the sections that experimental extensions add to a topic: like
|
|
204
|
+
* an experimental topic, they are read on their own and never searched.
|
|
205
|
+
* @param {ReadonlyArray<{path: string}>} extensions
|
|
206
|
+
* @returns {Promise<string[]>}
|
|
207
|
+
*/
|
|
208
|
+
async function experimentalSectionKeys(extensions) {
|
|
209
|
+
/** @type {string[]} */
|
|
210
|
+
const keys = [];
|
|
211
|
+
for (const extension of extensions) {
|
|
212
|
+
let doc;
|
|
213
|
+
try {
|
|
214
|
+
doc = /** @type {any} */ (await readDocAsData(extension.path));
|
|
215
|
+
} catch {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (!isExperimentalDoc(doc) || !Array.isArray(doc.sections)) continue;
|
|
219
|
+
keys.push(...doc.sections.map(sectionKey));
|
|
220
|
+
}
|
|
221
|
+
return keys;
|
|
222
|
+
}
|
|
223
|
+
|
|
197
224
|
/**
|
|
198
225
|
* Is this doc an experimental surface's (spec:AST-017 FR21)?
|
|
199
226
|
* @param {any} doc
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import fs from 'node:fs';
|
|
8
|
+
import {renderTokens} from '../../foundation/doc-compiler/links.mjs';
|
|
8
9
|
import {CORE_PACKAGE} from '../../foundation/discovery/component-discovery.mjs';
|
|
9
10
|
import {discoverTemplates} from '../template/template.mjs';
|
|
10
11
|
import {listAvailableThemes} from '../theme/_adapter.mjs';
|
|
@@ -123,7 +124,7 @@ export async function gatherTemplates(cwd) {
|
|
|
123
124
|
return derive();
|
|
124
125
|
},
|
|
125
126
|
...(weakKeywordBound ? {weakKeywordBound} : {}),
|
|
126
|
-
description: t.description || '',
|
|
127
|
+
description: renderTokens(t.description || ''),
|
|
127
128
|
// A template's own keywords name the many ideas it serves, so they score
|
|
128
129
|
// as its prose does, not as a name: one of them matching one word of a
|
|
129
130
|
// short idea is not a direct match.
|
|
@@ -70,6 +70,18 @@ function namesLoosely(candidate, loose) {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Each family member's `domain:name`, mapped to the family its doc lists it
|
|
75
|
+
* in (see rootsFirst in _order.mjs).
|
|
76
|
+
* @param {import('./_lexical.mjs').Candidate[]} all
|
|
77
|
+
* @returns {Map<string, string>}
|
|
78
|
+
*/
|
|
79
|
+
function familiesOf(all) {
|
|
80
|
+
return new Map(
|
|
81
|
+
all.flatMap(c => (c._family ? [[`${c.domain}:${c.name}`, c._family]] : [])),
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
73
85
|
/**
|
|
74
86
|
* Ranks with one searcher's weights. Shared by the main searcher and every
|
|
75
87
|
* topic searcher, which differ only in their weights.
|
|
@@ -105,6 +117,7 @@ export function rankWith(request, catalog, weights) {
|
|
|
105
117
|
lexical,
|
|
106
118
|
query,
|
|
107
119
|
Math.max(limit, FIT_PLACES),
|
|
120
|
+
familiesOf(catalog.all),
|
|
108
121
|
),
|
|
109
122
|
catalog.all,
|
|
110
123
|
query,
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
export function withoutOtherNames(all: import("./_lexical.mjs").Candidate[], named?: import("./_lexical.mjs").Candidate[]): import("./_lexical.mjs").Candidate[];
|
|
15
15
|
/**
|
|
16
16
|
* The gathered catalog as search reads it: its entries with
|
|
17
|
-
* {@link withoutOtherNames} applied
|
|
17
|
+
* {@link withoutOtherNames} applied, and each doc that opens a level read at
|
|
18
|
+
* its own grain ({@link withSummarized}). Names come from the catalog and from
|
|
18
19
|
* `others`, further gathered catalogs (a search for one `type` passes the
|
|
19
20
|
* other of components and hooks, so `type` never changes which keywords
|
|
20
21
|
* count). A reused gather, with the same others, gets the same view back.
|
|
@@ -133,6 +133,45 @@ export function withoutOtherNames(all, named = all) {
|
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* The catalog's docs, each doc that opens a level (a docs-tree namespace such
|
|
138
|
+
* as `layout`) holding the docs beneath it (`_summarizes`: the pages under its
|
|
139
|
+
* route and their sections). Such a page sums up the docs below it: a word its
|
|
140
|
+
* text shares with one of them is that doc's evidence, which the reader opens
|
|
141
|
+
* at its own grain, so the page does not answer it through that text
|
|
142
|
+
* (`scoreCandidate`, _candidate-score.mjs). Its name, title, description and
|
|
143
|
+
* declared keywords stay its own. Entries with nothing beneath them are
|
|
144
|
+
* returned as they are.
|
|
145
|
+
* @param {import('./_lexical.mjs').Candidate[]} all
|
|
146
|
+
* @returns {import('./_lexical.mjs').Candidate[]}
|
|
147
|
+
*/
|
|
148
|
+
function withSummarized(all) {
|
|
149
|
+
/** @type {Map<string, import('./_lexical.mjs').Candidate[]>} */
|
|
150
|
+
const below = new Map();
|
|
151
|
+
for (const c of all) {
|
|
152
|
+
const topic = c.domain === 'doc' ? /** @type {any} */ (c)._topic : null;
|
|
153
|
+
if (typeof topic !== 'string') continue;
|
|
154
|
+
for (let at = topic.indexOf('/'); at > 0; at = topic.indexOf('/', at + 1)) {
|
|
155
|
+
const route = topic.slice(0, at);
|
|
156
|
+
const list = below.get(route);
|
|
157
|
+
if (list) list.push(c);
|
|
158
|
+
else below.set(route, [c]);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (below.size === 0) return all;
|
|
162
|
+
return all.map(c => {
|
|
163
|
+
const topic = c.domain === 'doc' ? /** @type {any} */ (c)._topic : null;
|
|
164
|
+
const docs = typeof topic === 'string' ? below.get(topic) : undefined;
|
|
165
|
+
if (!docs) return c;
|
|
166
|
+
const view = Object.create(
|
|
167
|
+
Object.getPrototypeOf(c),
|
|
168
|
+
Object.getOwnPropertyDescriptors(c),
|
|
169
|
+
);
|
|
170
|
+
Object.defineProperty(view, '_summarizes', {value: docs});
|
|
171
|
+
return view;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
136
175
|
/**
|
|
137
176
|
* Each gathered catalog's search views, one per set of naming catalogs.
|
|
138
177
|
* @type {WeakMap<object, {others: object[], view: object}[]>}
|
|
@@ -141,7 +180,8 @@ const views = new WeakMap();
|
|
|
141
180
|
|
|
142
181
|
/**
|
|
143
182
|
* The gathered catalog as search reads it: its entries with
|
|
144
|
-
* {@link withoutOtherNames} applied
|
|
183
|
+
* {@link withoutOtherNames} applied, and each doc that opens a level read at
|
|
184
|
+
* its own grain ({@link withSummarized}). Names come from the catalog and from
|
|
145
185
|
* `others`, further gathered catalogs (a search for one `type` passes the
|
|
146
186
|
* other of components and hooks, so `type` never changes which keywords
|
|
147
187
|
* count). A reused gather, with the same others, gets the same view back.
|
|
@@ -158,11 +198,13 @@ export function searchView(catalog, others = []) {
|
|
|
158
198
|
v.others.every((o, i) => o === others[i]),
|
|
159
199
|
);
|
|
160
200
|
if (hit) return /** @type {T} */ (hit.view);
|
|
161
|
-
const all =
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
201
|
+
const all = withSummarized(
|
|
202
|
+
withoutOtherNames(
|
|
203
|
+
catalog.all,
|
|
204
|
+
others.length === 0
|
|
205
|
+
? catalog.all
|
|
206
|
+
: [catalog.all, ...others.map(o => o.all)].flat(),
|
|
207
|
+
),
|
|
166
208
|
);
|
|
167
209
|
const swap = new Map(catalog.all.map((c, i) => [c, all[i]]));
|
|
168
210
|
const view = {
|