@astryxdesign/cli 0.7.16 → 0.7.17-canary.g0404a74
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 +17 -0
- package/api/build/_adapter.mjs +53 -34
- package/api/build/blocks/blocks.d.mts +7 -5
- package/api/build/blocks/blocks.mjs +113 -26
- package/api/build/blocks/blocks.weights.json +1 -1
- 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 +6 -4
- package/api/build/kit/rank.mjs +132 -28
- package/api/build/kit/signals.d.mts +7 -1
- package/api/build/kit/signals.mjs +21 -10
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +14 -9
- package/api/build/kit/weights.d.mts +39 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +351 -46
- 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 +86 -0
- package/api/build/kit/words.mjs +241 -1
- package/api/build/tree.mjs +1 -1
- package/api/component/__fixtures__/resolutions/modules.txt +5 -6
- package/api/component/_adapter.d.mts +26 -2
- package/api/component/_adapter.mjs +135 -8
- package/api/component/component.mjs +14 -1
- package/api/component/list/list.d.mts +1 -1
- package/api/component/list/list.mjs +48 -6
- package/api/discover/_adapter.d.mts +11 -1
- package/api/discover/_adapter.mjs +95 -1
- package/api/discover/detail/item/item.mjs +5 -0
- package/api/discover/discover.mjs +12 -3
- package/api/discover/discover.type.d.mts +16 -3
- package/api/discover/discover.type.mjs +13 -3
- package/api/discover/search/search.mjs +3 -2
- package/api/docs/_adapter.d.mts +57 -2
- package/api/docs/_adapter.mjs +266 -33
- package/api/docs/_entry-names-lazily.d.mts +22 -0
- package/api/docs/_entry-names-lazily.mjs +25 -0
- package/api/docs/_entry-names.d.mts +23 -0
- package/api/docs/_entry-names.mjs +105 -0
- 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 +54 -5
- package/api/doctor/_adapter.mjs +162 -11
- package/api/doctor/built-checks.mjs +40 -14
- package/api/doctor/doctor.d.mts +15 -3
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.mjs +31 -7
- package/api/doctor/theme-checks.d.mts +35 -3
- package/api/doctor/theme-checks.mjs +377 -29
- package/api/hook/_adapter.d.mts +10 -4
- package/api/hook/_adapter.mjs +41 -5
- package/api/hook/detail/detail.mjs +5 -2
- package/api/hook/detail/params/params.mjs +10 -3
- 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/add-helpers.mjs +10 -0
- package/api/integration/authoring-checks.mjs +11 -8
- 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/pack-check.mjs +16 -1
- package/api/integration/validate-integration.d.mts +18 -6
- package/api/integration/validate-integration.mjs +129 -15
- package/api/integration/validate-integration.type.d.mts +22 -0
- package/api/integration/validate-integration.type.mjs +2 -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 +53 -1
- package/api/render/render.type.mjs +32 -2
- package/api/search/ORDERING.md +2 -2
- package/api/search/_adapter.d.mts +9 -0
- package/api/search/_adapter.mjs +85 -0
- package/api/search/_candidate-score.d.mts +9 -4
- package/api/search/_candidate-score.mjs +133 -46
- 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 +14 -0
- package/api/search/_lexical.mjs +93 -11
- 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/template/_adapter.d.mts +16 -0
- package/api/template/_adapter.mjs +39 -2
- package/api/template/cdn/cdn.mjs +37 -8
- package/api/template/copy/copy.d.mts +6 -3
- package/api/template/copy/copy.mjs +40 -8
- package/api/template/template.doc.mjs +3 -3
- package/api/template/template.mjs +63 -11
- package/api/template/template.type.d.mts +1 -0
- package/api/template/template.type.mjs +1 -0
- package/api/theme/_adapter.d.mts +12 -1
- package/api/theme/_adapter.mjs +132 -13
- package/api/theme/_app-provider.d.mts +31 -0
- package/api/theme/_app-provider.mjs +135 -0
- package/api/theme/add/add.mjs +3 -1
- package/api/theme/build/build.d.mts +142 -1
- package/api/theme/build/build.mjs +692 -284
- 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 +80 -5
- package/api/theme/build/font-warning.mjs +323 -55
- package/api/theme/build/icon-imports.mjs +51 -9
- package/api/theme/build/null-values.d.mts +28 -0
- package/api/theme/build/null-values.mjs +191 -0
- package/api/theme/list/list.mjs +17 -1
- package/api/theme/remove/remove.d.mts +2 -1
- package/api/theme/remove/remove.mjs +7 -3
- package/api/theme/theme.type.d.mts +78 -1
- package/api/theme/theme.type.mjs +38 -2
- package/api/theme/themeAdd.doc.mjs +1 -1
- package/api/theme/themeListAvailable.doc.mjs +1 -1
- package/api/theme/themeRemove.doc.mjs +8 -5
- package/api/theme-edit/_adapter.d.mts +116 -4
- package/api/theme-edit/_adapter.mjs +1058 -93
- package/api/theme-edit/_catalog.d.mts +46 -2
- package/api/theme-edit/_catalog.mjs +115 -14
- package/api/theme-edit/_check.d.mts +133 -24
- package/api/theme-edit/_check.mjs +3392 -531
- package/api/theme-edit/_color.d.mts +26 -0
- package/api/theme-edit/_color.mjs +92 -2
- package/api/theme-edit/_compiler.d.mts +5 -1
- package/api/theme-edit/_compiler.mjs +141 -17
- package/api/theme-edit/_context.d.mts +74 -6
- package/api/theme-edit/_context.mjs +468 -76
- package/api/theme-edit/_css.d.mts +21 -0
- package/api/theme-edit/_css.mjs +87 -14
- package/api/theme-edit/_edit.d.mts +74 -7
- package/api/theme-edit/_edit.mjs +4426 -319
- package/api/theme-edit/_how-commands.d.mts +76 -1
- package/api/theme-edit/_how-commands.mjs +793 -9
- package/api/theme-edit/_how-question.d.mts +97 -6
- package/api/theme-edit/_how-question.mjs +9184 -747
- package/api/theme-edit/_how.d.mts +5 -2
- package/api/theme-edit/_how.mjs +255 -46
- 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 +322 -0
- package/api/theme-edit/_normal.mjs +1630 -0
- package/api/theme-edit/_palette.d.mts +49 -0
- package/api/theme-edit/_palette.mjs +180 -38
- package/api/theme-edit/_part-words.d.mts +39 -0
- package/api/theme-edit/_part-words.mjs +152 -0
- package/api/theme-edit/_parts.d.mts +55 -3
- package/api/theme-edit/_parts.mjs +421 -36
- package/api/theme-edit/_preview-app.d.mts +7 -13
- package/api/theme-edit/_preview-app.mjs +1108 -599
- package/api/theme-edit/_preview.d.mts +156 -19
- package/api/theme-edit/_preview.mjs +809 -180
- package/api/theme-edit/_project.d.mts +61 -1
- package/api/theme-edit/_project.mjs +177 -6
- package/api/theme-edit/_settings.d.mts +619 -48
- package/api/theme-edit/_settings.mjs +4910 -617
- package/api/theme-edit/_tables.d.mts +41 -0
- package/api/theme-edit/_tables.mjs +261 -41
- 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 +34 -2
- package/api/theme-edit/theme-edit.type.mjs +18 -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/api/upgrade/upgrade.mjs +16 -1
- package/assets/codemods/integration-discovery.mjs +2 -1
- package/assets/codemods/integration-runner.mjs +1 -1
- package/assets/codemods/jscodeshift.d.ts +1 -1
- package/assets/codemods/run-codemod.mjs +151 -18
- package/assets/codemods/runner.mjs +1 -4
- 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 +2 -0
- package/assets/docs/theme.doc.dense.mjs +76 -7
- package/assets/docs/theme.doc.mjs +66 -2
- package/assets/docs/theme.doc.zh.mjs +51 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
- package/assets/docs/tree/checks.doc.mjs +2 -2
- package/assets/docs/tree/cli-command.doc.mjs +2 -3
- package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/font-setup.doc.mjs +1 -1
- package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
- package/assets/docs/tree/render-pages.doc.mjs +46 -5
- 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/tree/write-good-templates.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +2 -2
- package/assets/docs-routes.generated.json +1 -0
- 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/ChatComposerInput/useSpeechRecognitionHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.tsx +43 -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/page.tsx +31 -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/page.tsx +1 -1
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/page.tsx +1 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-comparison/page.tsx +2 -2
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/page.tsx +1 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- package/assets/templates/pages/detail-page/page.tsx +60 -7
- 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/page.tsx +13 -13
- package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/page.tsx +14 -2
- package/assets/templates/pages/editor/template.doc.mjs +2 -8
- package/assets/templates/pages/file-explorer/page.tsx +9 -0
- 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/form-wizard-vertical/page.tsx +23 -3
- package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +33 -2
- package/assets/templates/pages/kanban-board/page.tsx +12 -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/page.tsx +16 -0
- package/assets/templates/pages/login-card/template.doc.mjs +2 -1
- package/assets/templates/pages/login-split/page.tsx +19 -6
- 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/messaging-shell/template.doc.mjs +6 -0
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/payment-form/page.tsx +30 -4
- package/assets/templates/pages/product-detail/page.tsx +26 -2
- 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/page.tsx +162 -12
- 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/page.tsx +11 -3
- 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/page.tsx +9 -0
- package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/page.tsx +161 -133
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- package/assets/templates/pages/table-page/page.tsx +14 -1
- 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/page.tsx +47 -7
- package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
- package/assets/theme.template.ts +9 -2
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +9 -9
- 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/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +24 -1
- package/authoring/integration/schema.mjs +126 -4
- package/authoring/integration/type.ts +14 -0
- 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/discover.mjs +70 -3
- package/clients/cli/commands/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +44 -6
- package/clients/cli/commands/doctor.mjs +84 -16
- package/clients/cli/commands/experimental/render.mjs +42 -1
- package/clients/cli/commands/experimental/theme.mjs +1032 -134
- 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 +2 -2
- 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 +2 -2
- 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-remove.doc.mjs +4 -4
- 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.doc.mjs +1 -1
- package/clients/cli/commands/template.mjs +15 -2
- package/clients/cli/commands/theme-add.doc.mjs +1 -1
- package/clients/cli/commands/theme-build.doc.mjs +5 -1
- package/clients/cli/commands/theme-list.doc.mjs +1 -1
- package/clients/cli/commands/theme-remove.doc.mjs +13 -5
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +849 -441
- package/clients/cli/commands/upgrade.mjs +46 -8
- package/clients/cli/index.mjs +9 -19
- 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 +265 -29
- package/clients/cli/lib/manifest.mjs +3 -2
- package/clients/cli/lib/stray-option.mjs +478 -0
- package/clients/cli/lib/unknown-command.mjs +353 -0
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/project.d.mts +8 -0
- package/foundation/config/project.mjs +26 -29
- package/foundation/config/theme-state.d.mts +31 -2
- package/foundation/config/theme-state.mjs +140 -8
- package/foundation/discovery/authoring-self-docs.mjs +1 -0
- package/foundation/discovery/cli-self-doc-names.d.mts +13 -0
- package/foundation/discovery/cli-self-doc-names.mjs +51 -0
- package/foundation/discovery/cli-self-docs.d.mts +0 -2
- package/foundation/discovery/cli-self-docs.mjs +2 -15
- package/foundation/discovery/component-discovery.d.mts +11 -0
- package/foundation/discovery/component-discovery.mjs +59 -10
- 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/core-theme-facts.d.mts +70 -0
- package/foundation/discovery/core-theme-facts.mjs +384 -0
- package/foundation/discovery/doc-types.mjs +4 -3
- package/foundation/discovery/docs-discovery.d.mts +66 -9
- package/foundation/discovery/docs-discovery.mjs +126 -60
- package/foundation/discovery/entry-name-files.d.mts +106 -0
- package/foundation/discovery/entry-name-files.mjs +354 -0
- package/foundation/discovery/hook-discovery.d.mts +18 -2
- package/foundation/discovery/hook-discovery.mjs +93 -42
- 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-component-views.d.mts +15 -0
- package/foundation/discovery/integration-component-views.mjs +91 -0
- package/foundation/discovery/integration-doc-files.mjs +2 -1
- package/foundation/discovery/module-exports.d.mts +26 -1
- package/foundation/discovery/module-exports.mjs +114 -40
- package/foundation/discovery/name-roots.d.mts +38 -0
- package/foundation/discovery/name-roots.mjs +108 -0
- package/foundation/discovery/next-routes.d.mts +48 -0
- package/foundation/discovery/next-routes.mjs +181 -0
- 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 +40 -18
- package/foundation/discovery/template-adapter.d.mts +49 -29
- package/foundation/discovery/template-adapter.mjs +89 -99
- package/foundation/discovery/template-destination.d.mts +28 -0
- package/foundation/discovery/template-destination.mjs +104 -0
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/template-ids.d.mts +69 -0
- package/foundation/discovery/template-ids.mjs +199 -0
- package/foundation/discovery/theme-discovery.d.mts +12 -0
- package/foundation/discovery/theme-discovery.mjs +34 -4
- package/foundation/discovery/theme-imports.d.mts +24 -0
- package/foundation/discovery/theme-imports.mjs +61 -4
- package/foundation/discovery/theming-targets.d.mts +13 -5
- package/foundation/discovery/theming-targets.mjs +41 -47
- package/foundation/doc-compiler/generated-levels.d.mts +43 -0
- package/foundation/doc-compiler/generated-levels.mjs +72 -0
- package/foundation/doc-compiler/import.mjs +7 -1
- package/foundation/doc-compiler/inputs.mjs +3 -2
- package/foundation/doc-compiler/literal-doc.d.mts +12 -0
- package/foundation/doc-compiler/literal-doc.mjs +322 -0
- package/foundation/doc-compiler/parse-readable.mjs +4 -1
- package/foundation/doc-compiler/stored-docs.d.mts +29 -0
- package/foundation/doc-compiler/stored-docs.mjs +63 -1
- package/foundation/doc-compiler/tree.d.mts +4 -84
- package/foundation/doc-compiler/tree.mjs +4 -62
- package/foundation/env/semver.mjs +3 -1
- package/foundation/fonts/font-stylesheet.d.mts +46 -0
- package/foundation/fonts/font-stylesheet.mjs +173 -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 +16 -5
- package/foundation/fs/gather-cache.d.mts +94 -4
- package/foundation/fs/gather-cache.mjs +671 -106
- package/foundation/fs/glob.d.mts +16 -0
- package/foundation/fs/glob.mjs +105 -0
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +80 -0
- package/foundation/fs/kept-tree.mjs +240 -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/path-safety.d.mts +11 -2
- package/foundation/fs/path-safety.mjs +108 -18
- package/foundation/fs/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/fs/read-record.d.mts +56 -7
- package/foundation/fs/read-record.mjs +280 -56
- package/foundation/fs/regular-file.d.mts +29 -0
- package/foundation/fs/regular-file.mjs +77 -0
- 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/integrations.d.mts +23 -1
- package/foundation/integrations/integrations.mjs +18 -1
- package/foundation/integrations/pack-state.d.mts +75 -0
- package/foundation/integrations/pack-state.mjs +314 -0
- package/foundation/integrations/public-imports.d.mts +9 -0
- package/foundation/integrations/public-imports.mjs +3 -2
- package/foundation/integrations/shipped-imports.d.mts +122 -0
- package/foundation/integrations/shipped-imports.mjs +497 -0
- package/foundation/integrations/validate-contributions.d.mts +0 -17
- package/foundation/integrations/validate-contributions.mjs +59 -333
- package/foundation/render/assets.mjs +52 -7
- package/foundation/render/charts.d.mts +78 -27
- package/foundation/render/charts.mjs +266 -90
- package/foundation/render/embedded-files.d.mts +6 -0
- package/foundation/render/embedded-files.mjs +25 -5
- package/foundation/render/embedded-imports.d.mts +70 -7
- package/foundation/render/embedded-imports.mjs +132 -41
- 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/layers.d.mts +30 -0
- package/foundation/render/layers.mjs +158 -0
- package/foundation/render/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/offline.d.mts +32 -0
- package/foundation/render/offline.mjs +56 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +354 -21
- package/foundation/render/picture-chrome.d.mts +4 -0
- package/foundation/render/picture-chrome.mjs +192 -0
- package/foundation/render/picture-playwright.d.mts +4 -0
- package/foundation/render/picture-playwright.mjs +46 -0
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.d.mts +79 -5
- package/foundation/render/render-page.mjs +735 -109
- 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 +6 -6
- package/foundation/suggest/name-index.d.mts +148 -0
- package/foundation/suggest/name-index.mjs +317 -0
- package/foundation/suggest/other-command.d.mts +140 -0
- package/foundation/suggest/other-command.mjs +756 -0
- 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/entry-names.d.mts +14 -0
- package/foundation/text/entry-names.mjs +14 -0
- package/foundation/text/string-utils.d.mts +46 -6
- package/foundation/text/string-utils.mjs +118 -20
- package/foundation/text/suggest-order.d.mts +47 -4
- package/foundation/text/suggest-order.mjs +174 -5
- package/foundation/xle/browser.d.mts +2 -2
- package/foundation/xle/expand.mjs +2 -1
- package/host/index.mjs +8 -6
- package/package.json +7 -6
package/api/build/_adapter.d.mts
CHANGED
|
@@ -12,12 +12,16 @@
|
|
|
12
12
|
* @property {string} category The template's own `Family - Variant` label; empty when it declares none.
|
|
13
13
|
* @property {string[]} keywords The ideas the page serves, as its own descriptor names them; empty when it declares none.
|
|
14
14
|
* @property {string} filePath Absolute path to the template source file on disk.
|
|
15
|
+
* @property {string[]} components The components its page composes, read from its source on first use; empty when the source cannot be read.
|
|
16
|
+
* @property {boolean} hidden The template's own `isHiddenFromOverview`: kept off the gallery, so never taken as the app shell.
|
|
15
17
|
*/
|
|
16
18
|
/**
|
|
17
19
|
* A component the project can use, as the ranker reads it.
|
|
18
20
|
* @typedef {object} ComponentWords
|
|
19
21
|
* @property {string} name The component's name, e.g. `DateRangeInput`.
|
|
20
22
|
* @property {string[]} keywords The keywords its own doc declares.
|
|
23
|
+
* @property {string} [category] The category its own doc files it under,
|
|
24
|
+
* e.g. `Table & List`.
|
|
21
25
|
*/
|
|
22
26
|
/**
|
|
23
27
|
* Every ready page template the project can scaffold, in discovery order. This
|
|
@@ -158,6 +162,14 @@ export type PageTemplate = {
|
|
|
158
162
|
* Absolute path to the template source file on disk.
|
|
159
163
|
*/
|
|
160
164
|
filePath: string;
|
|
165
|
+
/**
|
|
166
|
+
* The components its page composes, read from its source on first use; empty when the source cannot be read.
|
|
167
|
+
*/
|
|
168
|
+
components: string[];
|
|
169
|
+
/**
|
|
170
|
+
* The template's own `isHiddenFromOverview`: kept off the gallery, so never taken as the app shell.
|
|
171
|
+
*/
|
|
172
|
+
hidden: boolean;
|
|
161
173
|
};
|
|
162
174
|
/**
|
|
163
175
|
* A component the project can use, as the ranker reads it.
|
|
@@ -171,6 +183,11 @@ export type ComponentWords = {
|
|
|
171
183
|
* The keywords its own doc declares.
|
|
172
184
|
*/
|
|
173
185
|
keywords: string[];
|
|
186
|
+
/**
|
|
187
|
+
* The category its own doc files it under,
|
|
188
|
+
* e.g. `Table & List`.
|
|
189
|
+
*/
|
|
190
|
+
category?: string | undefined;
|
|
174
191
|
};
|
|
175
192
|
/**
|
|
176
193
|
* A block the kit can name, as search names a block result.
|
package/api/build/_adapter.mjs
CHANGED
|
@@ -28,6 +28,8 @@ import {componentKeywords} from '../search/search.mjs';
|
|
|
28
28
|
import {findCoreDir, requireCoreDir} from '../../foundation/fs/paths.mjs';
|
|
29
29
|
import {persistedDerived} from '../../foundation/fs/gather-cache.mjs';
|
|
30
30
|
import {analyzeTemplateNeeds} from '../../foundation/discovery/template-needs.mjs';
|
|
31
|
+
import {extractComponents} from '../../foundation/discovery/template-adapter.mjs';
|
|
32
|
+
import {isWordModel} from './kit/word-model.mjs';
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* Runs one build with a single directory listing per path: the kit resolves
|
|
@@ -47,6 +49,8 @@ export {withListingCache} from '../../foundation/fs/listing-cache.mjs';
|
|
|
47
49
|
* @property {string} category The template's own `Family - Variant` label; empty when it declares none.
|
|
48
50
|
* @property {string[]} keywords The ideas the page serves, as its own descriptor names them; empty when it declares none.
|
|
49
51
|
* @property {string} filePath Absolute path to the template source file on disk.
|
|
52
|
+
* @property {string[]} components The components its page composes, read from its source on first use; empty when the source cannot be read.
|
|
53
|
+
* @property {boolean} hidden The template's own `isHiddenFromOverview`: kept off the gallery, so never taken as the app shell.
|
|
50
54
|
*/
|
|
51
55
|
|
|
52
56
|
/**
|
|
@@ -54,6 +58,8 @@ export {withListingCache} from '../../foundation/fs/listing-cache.mjs';
|
|
|
54
58
|
* @typedef {object} ComponentWords
|
|
55
59
|
* @property {string} name The component's name, e.g. `DateRangeInput`.
|
|
56
60
|
* @property {string[]} keywords The keywords its own doc declares.
|
|
61
|
+
* @property {string} [category] The category its own doc files it under,
|
|
62
|
+
* e.g. `Table & List`.
|
|
57
63
|
*/
|
|
58
64
|
|
|
59
65
|
/**
|
|
@@ -99,18 +105,24 @@ export async function loadTemplates(cwd) {
|
|
|
99
105
|
}
|
|
100
106
|
const pages = templates
|
|
101
107
|
.filter(t => t.type === 'page' && t.isReady !== false)
|
|
102
|
-
.map(t =>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
.map(t =>
|
|
109
|
+
withComponents(
|
|
110
|
+
{
|
|
111
|
+
name: t.dirName,
|
|
112
|
+
displayName: t.displayName || t.name,
|
|
113
|
+
description: t.description || '',
|
|
114
|
+
package: t.package ?? '@astryxdesign/core',
|
|
115
|
+
category: t.category || '',
|
|
116
|
+
keywords: t.keywords ?? [],
|
|
117
|
+
hidden: t.hidden === true,
|
|
118
|
+
filePath: t.filePath,
|
|
119
|
+
// The id `template()` resolves back to this entry: an active
|
|
120
|
+
// replacement owns the Core id it names, so that id selects it.
|
|
121
|
+
command: `astryx template ${t.replaces ?? t.dirName} --type page`,
|
|
122
|
+
},
|
|
123
|
+
t.filePath,
|
|
124
|
+
),
|
|
125
|
+
);
|
|
114
126
|
const blocks = templates
|
|
115
127
|
.filter(t => t.type === 'block')
|
|
116
128
|
.map(t => ({
|
|
@@ -261,28 +273,7 @@ export function loadBlockPicker() {
|
|
|
261
273
|
*/
|
|
262
274
|
export function isWeightsFile(file) {
|
|
263
275
|
const n = Array.isArray(file?.candidates) ? file.candidates.length : 0;
|
|
264
|
-
return (
|
|
265
|
-
n > 0 &&
|
|
266
|
-
Array.isArray(file.tables) &&
|
|
267
|
-
file.tables.length > 0 &&
|
|
268
|
-
file.tables.every(
|
|
269
|
-
(/** @type {any} */ t) =>
|
|
270
|
-
Array.isArray(t?.words) &&
|
|
271
|
-
Array.isArray(t.rows) &&
|
|
272
|
-
t.rows.length === t.words.length &&
|
|
273
|
-
t.rows.every(
|
|
274
|
-
(/** @type {any} */ r) => typeof r === 'string' && r.length === n,
|
|
275
|
-
) &&
|
|
276
|
-
Array.isArray(t.bias) &&
|
|
277
|
-
t.bias.length === n &&
|
|
278
|
-
t.bias.every((/** @type {any} */ b) => Number.isFinite(b)) &&
|
|
279
|
-
Number.isFinite(t.clip) &&
|
|
280
|
-
Number.isFinite(t.step),
|
|
281
|
-
) &&
|
|
282
|
-
Array.isArray(file.blend) &&
|
|
283
|
-
file.blend.length === 3 * (file.tables.length + 1) + 1 &&
|
|
284
|
-
file.blend.every((/** @type {any} */ x) => Number.isFinite(x))
|
|
285
|
-
);
|
|
276
|
+
return isWordModel(file, n);
|
|
286
277
|
}
|
|
287
278
|
|
|
288
279
|
/** The ranking coefficients the picker reads. */
|
|
@@ -362,3 +353,31 @@ export function templateSetupNotes(template, cwd) {
|
|
|
362
353
|
export function requireBuildCoreDir(cwd) {
|
|
363
354
|
return requireCoreDir(cwd);
|
|
364
355
|
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Adds a lazy, non-enumerable `components` getter to a page entry: the page's
|
|
359
|
+
* source is read and parsed only when a caller reads it, once, so loading the
|
|
360
|
+
* catalog stays cheap and the entry's own fields are unchanged.
|
|
361
|
+
* @template {object} T
|
|
362
|
+
* @param {T} entry
|
|
363
|
+
* @param {string | undefined} filePath
|
|
364
|
+
* @returns {T & {readonly components: string[]}}
|
|
365
|
+
*/
|
|
366
|
+
function withComponents(entry, filePath) {
|
|
367
|
+
/** @type {string[] | undefined} */
|
|
368
|
+
let components;
|
|
369
|
+
return /** @type {T & {readonly components: string[]}} */ (
|
|
370
|
+
Object.defineProperty(entry, 'components', {
|
|
371
|
+
get() {
|
|
372
|
+
if (components === undefined) {
|
|
373
|
+
try {
|
|
374
|
+
components = filePath ? extractComponents(filePath) : [];
|
|
375
|
+
} catch {
|
|
376
|
+
components = [];
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return components;
|
|
380
|
+
},
|
|
381
|
+
})
|
|
382
|
+
);
|
|
383
|
+
}
|
|
@@ -47,17 +47,19 @@ export function requestSideOf(request: string, weights: BlockPickerWeights): {
|
|
|
47
47
|
/**
|
|
48
48
|
* The picker's match of a request to a docs text: their projections' dot
|
|
49
49
|
* product plus the lexical weight times their plain overlap (the cosine of
|
|
50
|
-
* their word vectors).
|
|
51
|
-
*
|
|
52
|
-
*
|
|
50
|
+
* their word vectors). The vectors are keyed by vocabulary index (search's
|
|
51
|
+
* fit) or by word (the block picker's overlap, which also counts single
|
|
52
|
+
* words outside the vocabulary).
|
|
53
|
+
* @param {{vector: Map<number | string, number>, projected: Float64Array}} request
|
|
54
|
+
* @param {{vector: Map<number | string, number>, projected: Float64Array}} doc
|
|
53
55
|
* @param {BlockPickerWeights} weights
|
|
54
56
|
* @returns {{match: number, overlap: number}}
|
|
55
57
|
*/
|
|
56
58
|
export function matchOf(request: {
|
|
57
|
-
vector: Map<number, number>;
|
|
59
|
+
vector: Map<number | string, number>;
|
|
58
60
|
projected: Float64Array;
|
|
59
61
|
}, doc: {
|
|
60
|
-
vector: Map<number, number>;
|
|
62
|
+
vector: Map<number | string, number>;
|
|
61
63
|
projected: Float64Array;
|
|
62
64
|
}, weights: BlockPickerWeights): {
|
|
63
65
|
match: number;
|
|
@@ -27,7 +27,11 @@
|
|
|
27
27
|
* request's vector through the request matrix, against the docs' vector
|
|
28
28
|
* through the doc matrix, plus the lexical weight times their plain overlap
|
|
29
29
|
* (cosine), so a block the weights were never fitted with, such as a new one,
|
|
30
|
-
* is scored from its docs the same way. The
|
|
30
|
+
* is scored from its docs the same way. The plain overlap also counts single
|
|
31
|
+
* words outside the vocabulary the matrices were fitted with (such a word
|
|
32
|
+
* weighs as much as the vocabulary's rarest word), so a newer block's own
|
|
33
|
+
* words still tie it to a request that uses them. The
|
|
34
|
+
* candidates are the best matches,
|
|
31
35
|
* build's own blocks, search's first results, and the best plain overlaps.
|
|
32
36
|
* Each candidate's final score adds the ranking coefficients times: its match
|
|
33
37
|
* relative to the best, its place among the matches, its lead over the
|
|
@@ -197,10 +201,42 @@ function vectorOf(terms, d) {
|
|
|
197
201
|
return v;
|
|
198
202
|
}
|
|
199
203
|
|
|
204
|
+
/**
|
|
205
|
+
* A text's sparse unit vector over its words, for the plain overlap:
|
|
206
|
+
* (1 + ln count) x idf. A single word outside the vocabulary weighs as much
|
|
207
|
+
* as the vocabulary's rarest word (no fitted text used it often enough to
|
|
208
|
+
* keep). It counts only when `known` has it: a request word no block's docs
|
|
209
|
+
* use cannot tie the request to any block. A word pair counts only when the
|
|
210
|
+
* vocabulary has it.
|
|
211
|
+
* @param {string[]} terms
|
|
212
|
+
* @param {{index: Map<string, number>, idf: Float64Array, rarest: number}} d
|
|
213
|
+
* @param {Set<string>} [known] the words outside the vocabulary that count; all when absent
|
|
214
|
+
* @returns {Map<string, number>}
|
|
215
|
+
*/
|
|
216
|
+
function wordVectorOf(terms, d, known) {
|
|
217
|
+
/** @type {Map<string, number>} */
|
|
218
|
+
const counts = new Map();
|
|
219
|
+
for (const t of terms) counts.set(t, (counts.get(t) ?? 0) + 1);
|
|
220
|
+
/** @type {Map<string, number>} */
|
|
221
|
+
const v = new Map();
|
|
222
|
+
let sq = 0;
|
|
223
|
+
for (const [t, c] of counts) {
|
|
224
|
+
const i = d.index.get(t);
|
|
225
|
+
if (i === undefined && (t.includes('_') || (known && !known.has(t))))
|
|
226
|
+
continue;
|
|
227
|
+
const x = (1 + Math.log(c)) * (i === undefined ? d.rarest : d.idf[i]);
|
|
228
|
+
v.set(t, x);
|
|
229
|
+
sq += x * x;
|
|
230
|
+
}
|
|
231
|
+
const norm = Math.sqrt(sq) || 1;
|
|
232
|
+
for (const [t, x] of v) v.set(t, x / norm);
|
|
233
|
+
return v;
|
|
234
|
+
}
|
|
235
|
+
|
|
200
236
|
/**
|
|
201
237
|
* The vocabulary index and idf, read once per weights object, and each matrix
|
|
202
238
|
* row decoded when a side first uses it.
|
|
203
|
-
* @type {WeakMap<BlockPickerWeights, {index: Map<string, number>, idf: Float64Array, rows: Map<string, Int8Array>}>}
|
|
239
|
+
* @type {WeakMap<BlockPickerWeights, {index: Map<string, number>, idf: Float64Array, rarest: number, rows: Map<string, Int8Array>}>}
|
|
204
240
|
*/
|
|
205
241
|
const vocabularies = new WeakMap();
|
|
206
242
|
|
|
@@ -208,9 +244,11 @@ const vocabularies = new WeakMap();
|
|
|
208
244
|
function vocabularyOf(weights) {
|
|
209
245
|
let v = vocabularies.get(weights);
|
|
210
246
|
if (!v) {
|
|
247
|
+
const idf = Float64Array.from(weights.idf, x => x / 1024);
|
|
211
248
|
v = {
|
|
212
249
|
index: new Map(weights.vocab.map((w, i) => [w, i])),
|
|
213
|
-
idf
|
|
250
|
+
idf,
|
|
251
|
+
rarest: idf.reduce((a, x) => Math.max(a, x), 0),
|
|
214
252
|
rows: new Map(),
|
|
215
253
|
};
|
|
216
254
|
vocabularies.set(weights, v);
|
|
@@ -292,9 +330,11 @@ export function requestSideOf(request, weights) {
|
|
|
292
330
|
/**
|
|
293
331
|
* The picker's match of a request to a docs text: their projections' dot
|
|
294
332
|
* product plus the lexical weight times their plain overlap (the cosine of
|
|
295
|
-
* their word vectors).
|
|
296
|
-
*
|
|
297
|
-
*
|
|
333
|
+
* their word vectors). The vectors are keyed by vocabulary index (search's
|
|
334
|
+
* fit) or by word (the block picker's overlap, which also counts single
|
|
335
|
+
* words outside the vocabulary).
|
|
336
|
+
* @param {{vector: Map<number | string, number>, projected: Float64Array}} request
|
|
337
|
+
* @param {{vector: Map<number | string, number>, projected: Float64Array}} doc
|
|
298
338
|
* @param {BlockPickerWeights} weights
|
|
299
339
|
* @returns {{match: number, overlap: number}}
|
|
300
340
|
*/
|
|
@@ -325,7 +365,7 @@ function componentOf(block, componentNames) {
|
|
|
325
365
|
/**
|
|
326
366
|
* The catalog, read once per weights and catalog contents: each block's
|
|
327
367
|
* component, docs vector and projection, and each component's name phrases.
|
|
328
|
-
* @type {WeakMap<BlockPickerWeights, {key: string, blocks: Map<string, {component: string, vector: Map<number, number>, projected: Float64Array}>, phrases: Map<string, [string[], number][]>}>}
|
|
368
|
+
* @type {WeakMap<BlockPickerWeights, {key: string, blocks: Map<string, {component: string, vector: Map<number, number>, projected: Float64Array, words: Map<string, number>}>, phrases: Map<string, [string[], number][]>}>}
|
|
329
369
|
*/
|
|
330
370
|
const catalogs = new WeakMap();
|
|
331
371
|
|
|
@@ -357,19 +397,41 @@ function readCatalog(catalog, components, weights, keep) {
|
|
|
357
397
|
return read;
|
|
358
398
|
}
|
|
359
399
|
|
|
400
|
+
/**
|
|
401
|
+
* Every word the catalog's block docs use, per read catalog.
|
|
402
|
+
* @type {WeakMap<object, Set<string>>}
|
|
403
|
+
*/
|
|
404
|
+
const docWords = new WeakMap();
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* @param {{blocks: Map<string, {words: Map<string, number>}>}} cat
|
|
408
|
+
* @returns {Set<string>}
|
|
409
|
+
*/
|
|
410
|
+
function docWordsOf(cat) {
|
|
411
|
+
let words = docWords.get(cat);
|
|
412
|
+
if (!words) {
|
|
413
|
+
words = new Set();
|
|
414
|
+
for (const b of cat.blocks.values())
|
|
415
|
+
for (const t of b.words.keys()) words.add(t);
|
|
416
|
+
docWords.set(cat, words);
|
|
417
|
+
}
|
|
418
|
+
return words;
|
|
419
|
+
}
|
|
420
|
+
|
|
360
421
|
/**
|
|
361
422
|
* readCatalog's value, worked out.
|
|
362
423
|
* @param {string} key
|
|
363
424
|
* @param {CatalogBlock[]} catalog
|
|
364
425
|
* @param {CatalogComponent[]} components
|
|
365
426
|
* @param {BlockPickerWeights} weights
|
|
366
|
-
* @returns {{key: string, blocks: Map<string, {component: string, vector: Map<number, number>, projected: Float64Array}>, phrases: Map<string, [string[], number][]>}}
|
|
427
|
+
* @returns {{key: string, blocks: Map<string, {component: string, vector: Map<number, number>, projected: Float64Array, words: Map<string, number>}>, phrases: Map<string, [string[], number][]>}}
|
|
367
428
|
*/
|
|
368
429
|
function computeCatalog(key, catalog, components, weights) {
|
|
369
430
|
const names = components.map(c => c.name).sort((a, b) => b.length - a.length);
|
|
370
431
|
const keywords = new Map(components.map(c => [c.name, c.keywords ?? []]));
|
|
371
|
-
/** @type {Map<string, {component: string, vector: Map<number, number>, projected: Float64Array}>} */
|
|
432
|
+
/** @type {Map<string, {component: string, vector: Map<number, number>, projected: Float64Array, words: Map<string, number>}>} */
|
|
372
433
|
const blocks = new Map();
|
|
434
|
+
const vocabulary = vocabularyOf(weights);
|
|
373
435
|
for (const b of catalog) {
|
|
374
436
|
if (blocks.has(b.name)) continue;
|
|
375
437
|
const component = componentOf(b, names);
|
|
@@ -380,7 +442,11 @@ function computeCatalog(key, catalog, components, weights) {
|
|
|
380
442
|
wordsOf(component).join(' '),
|
|
381
443
|
(keywords.get(component) ?? []).join(' '),
|
|
382
444
|
].join(' ');
|
|
383
|
-
blocks.set(b.name, {
|
|
445
|
+
blocks.set(b.name, {
|
|
446
|
+
component,
|
|
447
|
+
...docSideOf(text, weights),
|
|
448
|
+
words: wordVectorOf(termsOf(text), vocabulary),
|
|
449
|
+
});
|
|
384
450
|
}
|
|
385
451
|
// A component is named by its own words, or by a keyword at most three
|
|
386
452
|
// components share (weighted by how few share it).
|
|
@@ -412,7 +478,8 @@ function computeCatalog(key, catalog, components, weights) {
|
|
|
412
478
|
const CATALOG_CODEC = {
|
|
413
479
|
/**
|
|
414
480
|
* What decode can get wrong in a read-back catalog: its key, each block's
|
|
415
|
-
* component, and projections of one width with finite
|
|
481
|
+
* component and word vector, and projections of one width with finite
|
|
482
|
+
* numbers.
|
|
416
483
|
* @param {any} read
|
|
417
484
|
*/
|
|
418
485
|
valid: read => {
|
|
@@ -422,6 +489,7 @@ const CATALOG_CODEC = {
|
|
|
422
489
|
return blocks.every(
|
|
423
490
|
(/** @type {any} */ b) =>
|
|
424
491
|
typeof b.component === 'string' &&
|
|
492
|
+
b.words instanceof Map &&
|
|
425
493
|
b.projected.length > 0 &&
|
|
426
494
|
b.projected.length === width &&
|
|
427
495
|
[...b.projected].every(Number.isFinite),
|
|
@@ -435,6 +503,7 @@ const CATALOG_CODEC = {
|
|
|
435
503
|
b.component,
|
|
436
504
|
[...b.vector],
|
|
437
505
|
[...b.projected],
|
|
506
|
+
[...b.words],
|
|
438
507
|
]),
|
|
439
508
|
phrases: [...read.phrases],
|
|
440
509
|
}),
|
|
@@ -447,11 +516,12 @@ const CATALOG_CODEC = {
|
|
|
447
516
|
blocks: new Map(
|
|
448
517
|
stored.blocks.map(
|
|
449
518
|
(
|
|
450
|
-
/** @type {[string, string, [number, number][], number[]]} */ [
|
|
519
|
+
/** @type {[string, string, [number, number][], number[], [string, number][]]} */ [
|
|
451
520
|
name,
|
|
452
521
|
component,
|
|
453
522
|
vector,
|
|
454
523
|
projected,
|
|
524
|
+
words,
|
|
455
525
|
],
|
|
456
526
|
) => [
|
|
457
527
|
name,
|
|
@@ -459,6 +529,7 @@ const CATALOG_CODEC = {
|
|
|
459
529
|
component,
|
|
460
530
|
vector: new Map(vector),
|
|
461
531
|
projected: Float64Array.from(projected),
|
|
532
|
+
words: new Map(words),
|
|
462
533
|
},
|
|
463
534
|
],
|
|
464
535
|
),
|
|
@@ -540,10 +611,22 @@ export function pickBlocks(request, signals, weights, keep) {
|
|
|
540
611
|
if (own.length === 0) return {names: [], entries};
|
|
541
612
|
const cat = readCatalog(signals.catalog, signals.components, weights, keep);
|
|
542
613
|
const side = requestSideOf(request, weights);
|
|
614
|
+
const words = wordVectorOf(
|
|
615
|
+
termsOf(request),
|
|
616
|
+
vocabularyOf(weights),
|
|
617
|
+
docWordsOf(cat),
|
|
618
|
+
);
|
|
543
619
|
/** @type {Map<string, {match: number, overlap: number}>} */
|
|
544
620
|
const scored = new Map();
|
|
545
621
|
for (const [name, b] of cat.blocks)
|
|
546
|
-
scored.set(
|
|
622
|
+
scored.set(
|
|
623
|
+
name,
|
|
624
|
+
matchOf(
|
|
625
|
+
{vector: words, projected: side.projected},
|
|
626
|
+
{vector: b.words, projected: b.projected},
|
|
627
|
+
weights,
|
|
628
|
+
),
|
|
629
|
+
);
|
|
547
630
|
const get = (/** @type {string} */ b) =>
|
|
548
631
|
scored.get(b) ?? {match: -Infinity, overlap: 0};
|
|
549
632
|
const ranked = [...scored.keys()].sort((a, b) => get(b).match - get(a).match);
|
|
@@ -593,8 +676,8 @@ export function pickBlocks(request, signals, weights, keep) {
|
|
|
593
676
|
});
|
|
594
677
|
final.sort((a, b) => b.score - a.score || a.pos - b.pos);
|
|
595
678
|
const foreign = new Set(signals.foreign);
|
|
596
|
-
const
|
|
597
|
-
const keeps = own.map(b => foreign.has(b) || writesName(
|
|
679
|
+
const requestWords = wordsOf(request);
|
|
680
|
+
const keeps = own.map(b => foreign.has(b) || writesName(requestWords, b));
|
|
598
681
|
const kept = new Set(own.filter((_, k) => keeps[k]));
|
|
599
682
|
const order = [
|
|
600
683
|
...final.map(x => x.b).filter(b => !kept.has(b) && !foreign.has(b)),
|
|
@@ -626,7 +709,7 @@ export function pickBlocks(request, signals, weights, keep) {
|
|
|
626
709
|
name,
|
|
627
710
|
package: block.package ?? '',
|
|
628
711
|
score: Math.max(1, Math.round(100 * Math.exp(x.score - max))),
|
|
629
|
-
reason: reasonFor(request, side, cat.blocks.get(name), weights),
|
|
712
|
+
reason: reasonFor(request, side, words, cat.blocks.get(name), weights),
|
|
630
713
|
description: block.description ?? '',
|
|
631
714
|
displayName: block.displayName,
|
|
632
715
|
kind: 'block',
|
|
@@ -640,10 +723,11 @@ export function pickBlocks(request, signals, weights, keep) {
|
|
|
640
723
|
* Why a block fits: the request words that tie it to its docs most.
|
|
641
724
|
* @param {string} request
|
|
642
725
|
* @param {{vector: Map<number, number>, projected: Float64Array}} side the request's side
|
|
643
|
-
* @param {
|
|
726
|
+
* @param {Map<string, number>} words the request's word vector for the plain overlap
|
|
727
|
+
* @param {{projected: Float64Array, words: Map<string, number>} | undefined} block
|
|
644
728
|
* @param {BlockPickerWeights} weights
|
|
645
729
|
*/
|
|
646
|
-
function reasonFor(request, side, block, weights) {
|
|
730
|
+
function reasonFor(request, side, words, block, weights) {
|
|
647
731
|
if (!block) return 'fits by meaning';
|
|
648
732
|
const raw =
|
|
649
733
|
String(request)
|
|
@@ -653,17 +737,20 @@ function reasonFor(request, side, block, weights) {
|
|
|
653
737
|
const wordOf = new Map();
|
|
654
738
|
for (const w of raw)
|
|
655
739
|
if (!STOP.has(w) && !wordOf.has(stemOf(w))) wordOf.set(stemOf(w), w);
|
|
740
|
+
const {index} = vocabularyOf(weights);
|
|
656
741
|
/** @type {[string, number][]} */
|
|
657
742
|
const parts = [];
|
|
658
|
-
for (const [
|
|
659
|
-
const term = weights.vocab[i];
|
|
743
|
+
for (const [term, x] of words) {
|
|
660
744
|
if (term.includes('_')) continue;
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
745
|
+
let s = weights.lexical * x * (block.words.get(term) ?? 0);
|
|
746
|
+
const i = index.get(term);
|
|
747
|
+
const v = i === undefined ? undefined : side.vector.get(i);
|
|
748
|
+
if (i !== undefined && v !== undefined) {
|
|
749
|
+
const row = rowOf(weights, 'request', i);
|
|
750
|
+
let dot = 0;
|
|
751
|
+
for (let k = 0; k < weights.dims; k++) dot += row[k] * block.projected[k];
|
|
752
|
+
s += v * dot * weights.requestScale;
|
|
753
|
+
}
|
|
667
754
|
if (s > 0) parts.push([wordOf.get(term) ?? term, s]);
|
|
668
755
|
}
|
|
669
756
|
parts.sort((a, b) => b[1] - a[1]);
|