@astryxdesign/cli 0.6.6 → 0.6.7-canary.796bcc2
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/CHANGELOG.md +129 -0
- package/README.md +84 -82
- package/api/build/_adapter.d.mts +20 -0
- package/api/build/_adapter.mjs +24 -0
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.test.mjs +1 -1
- package/api/build/build.type.d.mts +12 -0
- package/api/build/build.type.mjs +3 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +13 -1
- package/api/component/_adapter.d.mts +19 -0
- package/api/component/_adapter.mjs +33 -0
- package/api/component/component-replacement.test.mjs +615 -0
- package/api/component/component.doc.mjs +5 -2
- package/api/component/component.mjs +49 -15
- package/api/component/component.test.mjs +32 -0
- package/api/component/component.type.d.mts +33 -3
- package/api/component/component.type.mjs +10 -3
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +5 -2
- package/api/component/detail/detail.mjs +5 -1
- package/api/component/detail/props/props.d.mts +2 -1
- package/api/component/detail/props/props.mjs +3 -2
- package/api/component/detail/showcase/showcase.d.mts +3 -1
- package/api/component/detail/showcase/showcase.mjs +3 -1
- package/api/component/detail/source/source.d.mts +3 -2
- package/api/component/detail/source/source.mjs +7 -3
- package/api/component/list/list.mjs +128 -10
- package/api/docs/_adapter.d.mts +11 -0
- package/api/docs/_adapter.mjs +73 -1
- package/api/docs/compiled-topics.test.mjs +1 -1
- package/api/docs/detail/detail.mjs +19 -3
- package/api/docs/detail/section/section.d.mts +44 -0
- package/api/docs/detail/section/section.mjs +171 -14
- package/api/docs/detail/section/section.test.mjs +4 -4
- package/api/docs/docOverlays.test.mjs +38 -23
- package/api/docs/docs.depth.test.mjs +2 -0
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.mjs +13 -16
- package/api/docs/docs.test.mjs +9 -10
- package/api/docs/docs.type.d.mts +43 -3
- package/api/docs/docs.type.mjs +23 -3
- package/api/docs/index/index.mjs +11 -2
- package/api/docs/index/index.test.mjs +7 -2
- package/api/docs/integration-tree.test.mjs +26 -26
- package/api/docs/integrationDocs.test.mjs +8 -7
- package/api/docs/namespace-section.test.mjs +260 -0
- package/api/docs/node/node.mjs +3 -0
- package/api/docs/token-tables.test.mjs +93 -0
- package/api/doctor/_adapter.d.mts +50 -0
- package/api/doctor/_adapter.mjs +190 -0
- package/api/doctor/doctor.d.mts +6 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +144 -150
- package/api/doctor/doctor.test.mjs +104 -0
- package/api/doctor/theme-checks.d.mts +24 -0
- package/api/doctor/theme-checks.mjs +1231 -0
- package/api/doctor/theme-checks.test.mjs +667 -0
- package/api/gap-report/gap-report.doc.mjs +2 -1
- package/api/gap-report/gap-report.mjs +15 -1
- package/api/hook/_adapter.d.mts +1 -0
- package/api/hook/_adapter.mjs +3 -0
- package/api/hook/detail/detail.mjs +2 -2
- package/api/hook/detail/params/params.mjs +2 -2
- package/api/hook/hook.type.d.mts +12 -0
- package/api/hook/hook.type.mjs +3 -0
- package/api/hook/list/list.mjs +8 -8
- package/api/index.d.mts +1 -1
- package/api/index.mjs +4 -0
- package/api/init/run/run.d.mts +3 -5
- package/api/init/run/run.mjs +11 -11
- package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
- package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
- package/api/integration/add-helpers.d.mts +26 -5
- package/api/integration/add-helpers.mjs +50 -5
- package/api/integration/add-theme.mjs +16 -2
- package/api/integration/add-theme.test.mjs +66 -15
- package/api/integration/authoring-checks.mjs +21 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
- package/api/integration/pack-check.component-replaces.test.mjs +126 -0
- package/api/integration/pack-check.d.mts +10 -0
- package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
- package/api/integration/pack-check.mjs +485 -3
- package/api/integration/pack-check.test.mjs +578 -10
- package/api/integration/validate-integration.mjs +20 -4
- package/api/integration/validate-integration.test.mjs +73 -0
- package/api/layout/check/check.d.mts +1 -0
- package/api/layout/check/check.mjs +1 -0
- package/api/layout/expand/expand.d.mts +1 -0
- package/api/layout/expand/expand.mjs +1 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -1
- package/api/search/search.d.mts +47 -3
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.domain-priority.test.mjs +261 -0
- package/api/search/search.mjs +247 -43
- package/api/search/search.test.mjs +5 -1
- package/api/search/search.type.d.mts +3 -3
- package/api/search/search.type.mjs +2 -2
- package/api/swizzle/_adapter.d.mts +10 -0
- package/api/swizzle/_adapter.mjs +23 -0
- package/api/swizzle/copy/copy.d.mts +5 -6
- package/api/swizzle/copy/copy.mjs +29 -10
- package/api/swizzle/list/list.mjs +2 -2
- package/api/swizzle/swizzle.doc.mjs +5 -2
- package/api/swizzle/swizzle.test.mjs +55 -5
- package/api/swizzle/swizzle.type.d.mts +8 -0
- package/api/swizzle/swizzle.type.mjs +2 -0
- package/api/template/copy/copy.mjs +14 -1
- package/api/template/show/show.mjs +2 -0
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.mjs +1 -0
- package/api/template/template.type.d.mts +15 -0
- package/api/template/template.type.mjs +6 -0
- package/api/theme/_adapter.d.mts +106 -6
- package/api/theme/_adapter.mjs +687 -18
- package/api/theme/add/add.binary.test.mjs +76 -3
- package/api/theme/add/add.d.mts +5 -9
- package/api/theme/add/add.mjs +87 -64
- package/api/theme/add/add.rollback.test.mjs +9 -9
- package/api/theme/add/add.staging.test.mjs +9 -9
- package/api/theme/add/add.test.mjs +461 -55
- package/api/theme/add/add.types.test.mjs +151 -0
- package/api/theme/build/build.d.mts +96 -2
- package/api/theme/build/build.family.test.mjs +13 -4
- package/api/theme/build/build.mjs +286 -118
- package/api/theme/build/build.test.mjs +30 -0
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- package/api/theme/eject/eject.binary.test.mjs +90 -0
- package/api/theme/eject/eject.d.mts +17 -0
- package/api/theme/eject/eject.mjs +65 -0
- package/api/theme/eject/eject.rollback.test.mjs +158 -0
- package/api/theme/eject/eject.staging.test.mjs +83 -0
- package/api/theme/eject/eject.test.mjs +160 -0
- package/api/theme/integration-themes.test.mjs +30 -6
- package/api/theme/list/list.d.mts +10 -0
- package/api/theme/list/list.mjs +75 -7
- package/api/theme/list/list.test.mjs +155 -4
- package/api/theme/remove/remove.d.mts +12 -0
- package/api/theme/remove/remove.mjs +15 -0
- package/api/theme/remove/remove.test.mjs +94 -0
- package/api/theme/template/template.mjs +3 -4
- package/api/theme/theme.d.mts +5 -2
- package/api/theme/theme.mjs +13 -8
- package/api/theme/theme.type.d.mts +106 -2
- package/api/theme/theme.type.mjs +54 -5
- package/api/theme/themeAdd.doc.d.mts +1 -3
- package/api/theme/themeAdd.doc.mjs +35 -22
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themeEject.doc.d.mts +8 -0
- package/api/theme/themeEject.doc.mjs +89 -0
- package/api/theme/themeListAvailable.doc.mjs +4 -4
- package/api/theme/themeListCopySources.doc.d.mts +8 -0
- package/api/theme/themeListCopySources.doc.mjs +60 -0
- package/api/theme/themeRemove.doc.d.mts +6 -0
- package/api/theme/themeRemove.doc.mjs +50 -0
- package/api/theme/themeTemplate.doc.mjs +4 -3
- package/api/theme/themeUse.doc.d.mts +6 -0
- package/api/theme/themeUse.doc.mjs +47 -0
- package/api/theme/use/use.d.mts +12 -0
- package/api/theme/use/use.mjs +15 -0
- package/api/theme/use/use.test.mjs +98 -0
- package/api/upgrade/_adapter.d.mts +1 -0
- package/api/upgrade/_adapter.mjs +3 -0
- package/api/upgrade/list/list.mjs +9 -3
- package/api/upgrade/upgrade.type.d.mts +4 -0
- package/api/upgrade/upgrade.type.mjs +1 -0
- package/assets/codemods/__tests__/registry.test.mjs +1 -0
- package/assets/codemods/integration-discovery.mjs +1 -1
- package/assets/codemods/integration-discovery.test.mjs +64 -0
- package/assets/codemods/registry.mjs +1 -0
- package/assets/codemods/transforms/v0.6.7/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
- package/assets/codemods/transforms/v0.6.7/index.mjs +23 -0
- package/assets/codemods/transforms/v0.6.7/migrate-copied-themes-to-descriptors.mjs +54 -0
- package/assets/docs/author-a-theme.doc.mjs +166 -0
- package/assets/docs/getting-started.doc.mjs +61 -17
- package/assets/docs/principles.doc.dense.mjs +4 -4
- package/assets/docs/principles.doc.mjs +6 -6
- package/assets/docs/principles.doc.zh.mjs +4 -4
- package/assets/docs/styling-overview.doc.mjs +211 -0
- package/assets/docs/theme.doc.dense.mjs +10 -198
- package/assets/docs/theme.doc.mjs +13 -771
- package/assets/docs/theme.doc.zh.mjs +31 -12
- package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +6 -5
- package/assets/docs/tree/component-migration.doc.mjs +107 -0
- package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
- package/assets/docs/tree/font-setup.doc.mjs +122 -0
- package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
- package/assets/docs/tree/headers-and-footers.doc.mjs +67 -0
- package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
- package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
- package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
- package/assets/docs/tree/internationalization.doc.mjs +29 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
- package/assets/docs/tree/layout.doc.mjs +55 -0
- package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
- package/assets/docs/tree/migration-verification.doc.mjs +67 -0
- package/assets/docs/tree/migration.doc.mjs +28 -0
- package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
- package/assets/docs/tree/other-libraries.doc.mjs +218 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
- package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
- package/assets/docs/tree/responsive.doc.mjs +98 -0
- package/assets/docs/tree/scaffold.doc.mjs +140 -0
- package/assets/docs/tree/side-panels.doc.mjs +81 -0
- package/assets/docs/tree/structure.doc.mjs +140 -0
- package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
- package/assets/docs/tree/styling-basics.doc.mjs +181 -0
- package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
- package/assets/docs/tree/styling.doc.mjs +29 -0
- package/assets/docs/tree/tailwind.doc.mjs +65 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/themes.doc.mjs +2 -2
- package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
- package/assets/docs/tree/tokens-border.doc.mjs +46 -0
- package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-color.doc.mjs +438 -0
- package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-data.doc.mjs +323 -0
- package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
- package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
- package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
- package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
- package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
- package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
- package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.mjs +54 -0
- package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
- package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
- package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
- package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
- package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
- package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
- package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens.doc.mjs +28 -0
- package/assets/docs/tree/troubleshooting.doc.mjs +7 -3
- package/assets/docs/tree/type-scale.doc.mjs +147 -0
- package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
- package/assets/docs/tree/typography.doc.mjs +29 -0
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
- package/assets/docs/tree/versioning.doc.mjs +6 -3
- package/assets/docs/use-a-theme.doc.mjs +212 -0
- package/assets/templates/pages/incident-console/page.tsx +1 -1
- package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
- package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
- package/assets/templates/pages/table-comparison/page.tsx +1449 -0
- package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
- package/assets/theme.template.ts +4 -3
- package/authoring/doctypes/command/command.doc.mjs +5 -0
- package/authoring/doctypes/command/type.ts +2 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -4
- package/authoring/doctypes/template/template.doc.mjs +2 -2
- package/authoring/doctypes/template/type.ts +5 -3
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +338 -45
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +8 -6
- package/clients/cli/commands/build.text-fields.test.mjs +1 -1
- package/clients/cli/commands/component/index.mjs +91 -12
- package/clients/cli/commands/component-replacement.text.test.mjs +316 -0
- package/clients/cli/commands/component.doc.mjs +9 -2
- package/clients/cli/commands/docs.doc.mjs +2 -1
- package/clients/cli/commands/docs.mjs +63 -23
- package/clients/cli/commands/docs.test.mjs +17 -15
- package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +59 -52
- package/clients/cli/commands/gap-report.doc.mjs +2 -2
- package/clients/cli/commands/hook/index.mjs +7 -2
- package/clients/cli/commands/import-hint-correctness.test.mjs +28 -5
- package/clients/cli/commands/init.next-steps.test.mjs +18 -23
- package/clients/cli/commands/integration-real-world.test.mjs +61 -12
- package/clients/cli/commands/layout-check.doc.mjs +2 -0
- package/clients/cli/commands/layout-expand.doc.mjs +2 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +2 -0
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
- package/clients/cli/commands/layout.doc.mjs +2 -0
- package/clients/cli/commands/layout.mjs +40 -4
- package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
- package/clients/cli/commands/search.test.mjs +10 -4
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
- package/clients/cli/commands/template.mjs +56 -5
- package/clients/cli/commands/text-json-parity.test.mjs +40 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +135 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- package/clients/cli/commands/theme-eject.doc.mjs +47 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +5 -2
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
- package/clients/cli/commands/theme-remove.doc.mjs +22 -0
- package/clients/cli/commands/theme-template.doc.mjs +4 -3
- package/clients/cli/commands/theme-use.doc.mjs +22 -0
- package/clients/cli/commands/theme.doc.mjs +21 -16
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/index.mjs +5 -2
- package/clients/cli/lib/component-format.mjs +29 -2
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- package/clients/cli/lib/resolve-theme.mjs +80 -78
- package/clients/cli/lib/resolve-theme.test.mjs +523 -27
- package/foundation/agent-docs/agent-docs.mjs +48 -30
- package/foundation/agent-docs/agent-docs.test.mjs +47 -34
- package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
- package/foundation/config/project.d.mts +20 -5
- package/foundation/config/project.mjs +43 -6
- package/foundation/config/project.test.mjs +1 -1
- package/foundation/config/theme-private-vars.d.mts +12 -0
- package/foundation/config/theme-private-vars.mjs +107 -0
- package/foundation/config/theme-private-vars.test.mjs +55 -0
- package/foundation/config/theme-state.d.mts +145 -0
- package/foundation/config/theme-state.mjs +417 -0
- package/foundation/config/theme-state.test.mjs +182 -0
- package/foundation/discovery/component-discovery.d.mts +5 -2
- package/foundation/discovery/component-discovery.mjs +12 -6
- package/foundation/discovery/component-replacement.d.mts +91 -0
- package/foundation/discovery/component-replacement.mjs +417 -0
- package/foundation/discovery/component-replacement.test.mjs +480 -0
- package/foundation/discovery/docs-discovery.test.mjs +1 -1
- package/foundation/discovery/docs-output-budget.d.mts +6 -2
- package/foundation/discovery/docs-output-budget.mjs +2 -1
- package/foundation/discovery/docs-section-key.d.mts +4 -2
- package/foundation/discovery/docs-section-key.mjs +1 -1
- package/foundation/discovery/module-exports.d.mts +10 -0
- package/foundation/discovery/module-exports.mjs +146 -0
- package/foundation/discovery/package-exports.d.mts +29 -0
- package/foundation/discovery/package-exports.mjs +200 -0
- package/foundation/discovery/template-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- package/foundation/discovery/theme-discovery.d.mts +72 -5
- package/foundation/discovery/theme-discovery.mjs +134 -18
- package/foundation/discovery/theme-discovery.test.mjs +9 -3
- package/foundation/discovery/theme-imports.d.mts +15 -0
- package/foundation/discovery/theme-imports.mjs +217 -0
- package/foundation/discovery/theme-imports.test.mjs +173 -0
- package/foundation/doc-compiler/bundle.mjs +52 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +15 -5
- package/foundation/doc-compiler/inputs.mjs +2 -1
- package/foundation/doc-compiler/lenses.d.mts +4 -2
- package/foundation/doc-compiler/lenses.mjs +1 -1
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
- package/foundation/doc-compiler/tree.d.mts +10 -0
- package/foundation/doc-compiler/tree.mjs +22 -0
- package/foundation/doc-compiler/tree.test.mjs +3 -2
- package/foundation/env/package-manager.d.mts +31 -8
- package/foundation/env/package-manager.mjs +120 -13
- package/foundation/env/package-manager.test.mjs +174 -1
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +43 -10
- package/foundation/integrations/cli-requirement.mjs +56 -13
- package/foundation/integrations/cli-requirement.test.mjs +160 -23
- package/foundation/integrations/contribution-inventory.mjs +3 -3
- package/foundation/integrations/validate-contributions.d.mts +16 -0
- package/foundation/integrations/validate-contributions.mjs +56 -8
- package/foundation/response/base.d.ts +9 -3
- package/foundation/response/json.d.mts +7 -4
- package/foundation/response/json.mjs +10 -6
- package/foundation/response/response-types.doc.mjs +41 -26
- package/foundation/response/response.doc.mjs +18 -4
- package/foundation/text/copyright-header.mjs +1 -1
- package/foundation/text/copyright-header.test.mjs +1 -1
- package/package.json +9 -9
- package/assets/docs/layout.doc.dense.mjs +0 -388
- package/assets/docs/layout.doc.mjs +0 -550
- package/assets/docs/styling-libraries.doc.mjs +0 -469
- package/assets/docs/styling.doc.mjs +0 -412
- package/assets/docs/tokens.doc.dense.mjs +0 -15
- package/assets/docs/tokens.doc.mjs +0 -1491
- package/assets/docs/tokens.doc.zh.mjs +0 -15
- package/assets/docs/typography.doc.mjs +0 -286
package/api/search/search.mjs
CHANGED
|
@@ -54,6 +54,13 @@
|
|
|
54
54
|
* description hold both words of `troubleshoot integration` answers it better
|
|
55
55
|
* than a doc named `integration`.
|
|
56
56
|
*
|
|
57
|
+
* Between domains, ranking adds one rule ahead of the score: domain priority
|
|
58
|
+
* (see {@link domainPriority}). A component, hook, template, or theme whose
|
|
59
|
+
* name or keyword a query word hits ranks ahead of every doc the reader did not
|
|
60
|
+
* ask for by name or title, so `font size` finds `Text` before a typography
|
|
61
|
+
* topic that declares the phrase. A doc the query names, or whose title the
|
|
62
|
+
* query holds, keeps its place.
|
|
63
|
+
*
|
|
57
64
|
* Description and guidance are separate tiers on purpose. A component's own
|
|
58
65
|
* one-line description saying "notification" is a claim about what it IS; the
|
|
59
66
|
* same word inside another component's best-practice advice is a passing
|
|
@@ -80,12 +87,16 @@ import {
|
|
|
80
87
|
findComponentReadme,
|
|
81
88
|
resolveImportPath,
|
|
82
89
|
resolveIntegrationImportPath,
|
|
90
|
+
CORE_PACKAGE,
|
|
83
91
|
} from '../../foundation/discovery/component-discovery.mjs';
|
|
84
92
|
import {
|
|
85
93
|
discoverHooks,
|
|
86
94
|
findHookDoc,
|
|
87
95
|
} from '../../foundation/discovery/hook-discovery.mjs';
|
|
88
|
-
import {
|
|
96
|
+
import {
|
|
97
|
+
loadComponentReplacements,
|
|
98
|
+
loadIntegrationsSafely,
|
|
99
|
+
} from '../component/_adapter.mjs';
|
|
89
100
|
import {levenshteinDistance} from '../../foundation/text/string-utils.mjs';
|
|
90
101
|
import {discoverTemplates, extractComponents} from '../template/template.mjs';
|
|
91
102
|
import {templateLookupIds} from '../../foundation/discovery/template-adapter.mjs';
|
|
@@ -130,9 +141,9 @@ import {setResultCoverage} from './coverage.mjs';
|
|
|
130
141
|
* @property {string} [_command] - The command that reads exactly this doc part.
|
|
131
142
|
* @property {string} [_parent] - The command that opens the level above a doc
|
|
132
143
|
* part: its topic's section list, or the docs-tree namespace it sits in.
|
|
133
|
-
* @property {string} [_package] - The npm package that
|
|
134
|
-
*
|
|
135
|
-
*
|
|
144
|
+
* @property {string} [_package] - The npm package that owns the candidate:
|
|
145
|
+
* Core's package for its components, hooks, and templates, the integration's
|
|
146
|
+
* for what it contributed, and for a doc part the package that wrote it.
|
|
136
147
|
* @property {string} [_displayName]
|
|
137
148
|
* @property {'page'|'block'} [_kind]
|
|
138
149
|
* @property {string} [_resultName]
|
|
@@ -472,13 +483,110 @@ const FULL_COVERAGE_SCORE = 151;
|
|
|
472
483
|
*/
|
|
473
484
|
const STRONG_TOKEN_SCORE = 70;
|
|
474
485
|
|
|
486
|
+
/**
|
|
487
|
+
* A match's domain priority: 0 (none), 1, or 2 (a doc the whole query names).
|
|
488
|
+
* A component, hook, template, or theme with priority ranks ahead of any doc
|
|
489
|
+
* without it, whatever the two scores are. Docs among themselves rank by
|
|
490
|
+
* priority, then score; everything else ranks among itself by score.
|
|
491
|
+
*
|
|
492
|
+
* A component, hook, template, or theme has priority (1) when one of the
|
|
493
|
+
* query's words, or the whole query, hits its name or an authored keyword at
|
|
494
|
+
* {@link STRONG_TOKEN_SCORE} or above, or when it matches every word.
|
|
495
|
+
*
|
|
496
|
+
* A doc has priority when the reader asked for that doc:
|
|
497
|
+
* - 2: the whole query is the topic's name, its last route segment, or its
|
|
498
|
+
* own title, as words and whatever the plural (`font setup` is
|
|
499
|
+
* typography/font-setup, `side panel` is "Side panels");
|
|
500
|
+
* - 1: a word of the query is the topic's name (`illustration` in a longer
|
|
501
|
+
* question is the illustrations guide);
|
|
502
|
+
* - 1: the query holds one of the doc's titles whole (`resizable side panels`
|
|
503
|
+
* names "Side panels"; `light dark mode button` names "Light/Dark Mode");
|
|
504
|
+
* - 1: the doc matches every word of the query and one of them is a word of
|
|
505
|
+
* its title (`switch to a dark theme` and "Use a theme").
|
|
506
|
+
* A section answers to its topic's name.
|
|
507
|
+
*
|
|
508
|
+
* A doc that matched only by keyword, by a heading holding the query, or by
|
|
509
|
+
* words spread through its text has no priority. Docs are split into many
|
|
510
|
+
* small topics, and each declares its own keywords and headings, so a common
|
|
511
|
+
* phrase such as `font size` hits a guide's keyword or heading exactly
|
|
512
|
+
* (170-190) while the component the reader is after matches one word by
|
|
513
|
+
* keyword (`Text`, 98). Ranked on text alone, every split adds another doc
|
|
514
|
+
* above the component. Broad reference pages match every word of many queries
|
|
515
|
+
* in their text the same way. The score stays the text-match strength the
|
|
516
|
+
* result reports, so callers that gate on it (`build`) see the same numbers.
|
|
517
|
+
*
|
|
518
|
+
* @param {string} term - Lowercased search term.
|
|
519
|
+
* @param {string[]} tokens - Content tokens from tokenizeQuery(term).
|
|
520
|
+
* @param {Candidate} candidate
|
|
521
|
+
* @param {{score: number, matched: number, total: number}} hit - The
|
|
522
|
+
* candidate's scoreQuery result.
|
|
523
|
+
* @returns {0 | 1 | 2}
|
|
524
|
+
*/
|
|
525
|
+
export function domainPriority(term, tokens, candidate, hit) {
|
|
526
|
+
const words = [term, ...tokens];
|
|
527
|
+
if (candidate.domain === 'doc') {
|
|
528
|
+
const topic = String(candidate._topic ?? candidate.name).toLowerCase();
|
|
529
|
+
// The whole query, read as words, is the topic's route, its last
|
|
530
|
+
// segment, or its own title, whatever the plural: `side panel` is
|
|
531
|
+
// layout/side-panels, and `header and footer` is "Headers and footers".
|
|
532
|
+
// A section's title is a heading inside a topic, not the topic's name.
|
|
533
|
+
const named = [topic, topic.slice(topic.lastIndexOf('/') + 1)];
|
|
534
|
+
if (candidate._section == null && candidate.titles?.[0]) {
|
|
535
|
+
named.push(candidate.titles[0]);
|
|
536
|
+
}
|
|
537
|
+
if (named.some(n => samePhrase(term, n))) {
|
|
538
|
+
return 2;
|
|
539
|
+
}
|
|
540
|
+
if (
|
|
541
|
+
words.some(
|
|
542
|
+
w =>
|
|
543
|
+
(scoreCandidate(w, {name: topic}, {fuzzy: false})?.score ?? 0) >= 95,
|
|
544
|
+
)
|
|
545
|
+
) {
|
|
546
|
+
return 1;
|
|
547
|
+
}
|
|
548
|
+
// A whole title inside the query is the only path to 160-169.
|
|
549
|
+
if (hit.score >= TITLE_IN_QUERY_SCORE && hit.score < TITLE_PHRASE_SCORE) {
|
|
550
|
+
return 1;
|
|
551
|
+
}
|
|
552
|
+
// Every word matched, and one of them names the doc in its title.
|
|
553
|
+
if (
|
|
554
|
+
hit.score >= FULL_COVERAGE_SCORE &&
|
|
555
|
+
hit.score < TITLE_IN_QUERY_SCORE &&
|
|
556
|
+
hit.matched === hit.total
|
|
557
|
+
) {
|
|
558
|
+
const titleWords = phraseWords(candidate.titles?.[0] ?? '');
|
|
559
|
+
if (
|
|
560
|
+
(tokens.length ? tokens : [term]).some(t =>
|
|
561
|
+
titleWords.some(w => samePhraseWord(t, w) || sameWord(t, w)),
|
|
562
|
+
)
|
|
563
|
+
) {
|
|
564
|
+
return 1;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
return 0;
|
|
568
|
+
}
|
|
569
|
+
if (hit.score >= FULL_COVERAGE_SCORE) return 1;
|
|
570
|
+
const fuzzy = tokens.length <= 1;
|
|
571
|
+
return words.some(
|
|
572
|
+
w =>
|
|
573
|
+
(bestForToken(w, candidate, {fuzzy})?.score ?? 0) >= STRONG_TOKEN_SCORE,
|
|
574
|
+
)
|
|
575
|
+
? 1
|
|
576
|
+
: 0;
|
|
577
|
+
}
|
|
578
|
+
|
|
475
579
|
/**
|
|
476
580
|
* The words of a title or query, lowercased, without punctuation or code ticks.
|
|
477
581
|
* @param {string} text
|
|
478
582
|
* @returns {string[]}
|
|
479
583
|
*/
|
|
480
584
|
function phraseWords(text) {
|
|
481
|
-
return
|
|
585
|
+
return (
|
|
586
|
+
unlinkText(text)
|
|
587
|
+
.toLowerCase()
|
|
588
|
+
.match(/[a-z0-9]+/g) ?? []
|
|
589
|
+
);
|
|
482
590
|
}
|
|
483
591
|
|
|
484
592
|
/**
|
|
@@ -497,6 +605,24 @@ function samePhraseWord(a, b) {
|
|
|
497
605
|
);
|
|
498
606
|
}
|
|
499
607
|
|
|
608
|
+
/**
|
|
609
|
+
* Whether two phrases are the same words, in order, ignoring case,
|
|
610
|
+
* punctuation, and a plural on any word: `side panel` is "Side panels", and
|
|
611
|
+
* `headers and footers` is `header-and-footer`.
|
|
612
|
+
* @param {string} a
|
|
613
|
+
* @param {string} b
|
|
614
|
+
* @returns {boolean}
|
|
615
|
+
*/
|
|
616
|
+
function samePhrase(a, b) {
|
|
617
|
+
const x = phraseWords(a);
|
|
618
|
+
const y = phraseWords(b);
|
|
619
|
+
return (
|
|
620
|
+
x.length > 0 &&
|
|
621
|
+
x.length === y.length &&
|
|
622
|
+
x.every((w, k) => samePhraseWord(w, y[k]) || sameWord(w, y[k]))
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
|
|
500
626
|
/**
|
|
501
627
|
* Whether `plural` is the plural of `word`: `integrations` of `integration`,
|
|
502
628
|
* `boxes` of `box`. `es` only follows s, x, z, ch, or sh, so `notes` is not a
|
|
@@ -675,9 +801,7 @@ export function scoreQuery(term, tokens, candidate) {
|
|
|
675
801
|
score:
|
|
676
802
|
FULL_COVERAGE_SCORE +
|
|
677
803
|
Math.min(
|
|
678
|
-
Math.floor(
|
|
679
|
-
(tokenSum - matched * MIN_TOKEN_SCORE) / (matched * 5),
|
|
680
|
-
),
|
|
804
|
+
Math.floor((tokenSum - matched * MIN_TOKEN_SCORE) / (matched * 5)),
|
|
681
805
|
8,
|
|
682
806
|
),
|
|
683
807
|
reason,
|
|
@@ -967,6 +1091,7 @@ async function gatherCoreComponents(coreDir) {
|
|
|
967
1091
|
keywords,
|
|
968
1092
|
description,
|
|
969
1093
|
guidance,
|
|
1094
|
+
_package: CORE_PACKAGE,
|
|
970
1095
|
_import: resolveImportPath(coreDir, comp),
|
|
971
1096
|
});
|
|
972
1097
|
}
|
|
@@ -980,11 +1105,10 @@ async function gatherCoreComponents(coreDir) {
|
|
|
980
1105
|
* this, an integration component is invisible to `search`/`build` even
|
|
981
1106
|
* though `component --list`/`component <Name>` already resolve it — the two
|
|
982
1107
|
* discovery paths silently disagreed.
|
|
983
|
-
* @param {
|
|
1108
|
+
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
984
1109
|
* @returns {Promise<Candidate[]>}
|
|
985
1110
|
*/
|
|
986
|
-
async function gatherIntegrationComponents(
|
|
987
|
-
const loadedIntegrations = await loadIntegrationsSafely(cwd);
|
|
1111
|
+
async function gatherIntegrationComponents(loadedIntegrations) {
|
|
988
1112
|
/** @type {Candidate[]} */
|
|
989
1113
|
const candidates = [];
|
|
990
1114
|
for (const integration of loadedIntegrations) {
|
|
@@ -997,6 +1121,7 @@ async function gatherIntegrationComponents(cwd) {
|
|
|
997
1121
|
keywords: doc && Array.isArray(doc.keywords) ? doc.keywords : [],
|
|
998
1122
|
description: doc ? doc.usage?.description || doc.description || '' : '',
|
|
999
1123
|
guidance: guidanceFrom(doc),
|
|
1124
|
+
_package: rec.package ?? integration.name,
|
|
1000
1125
|
// Exactly what `component` reports: a doc may state its own specifier
|
|
1001
1126
|
// (one entry point exporting several components), and only when it
|
|
1002
1127
|
// does not do we resolve the subpath against the owning package's
|
|
@@ -1028,11 +1153,40 @@ async function gatherIntegrationComponents(cwd) {
|
|
|
1028
1153
|
* @returns {Promise<Candidate[]>}
|
|
1029
1154
|
*/
|
|
1030
1155
|
async function gatherComponents(coreDir, cwd) {
|
|
1031
|
-
const
|
|
1156
|
+
const loadedIntegrations = await loadIntegrationsSafely(cwd);
|
|
1157
|
+
const [core, integrations, replacements] = await Promise.all([
|
|
1032
1158
|
gatherCoreComponents(coreDir),
|
|
1033
|
-
gatherIntegrationComponents(
|
|
1159
|
+
gatherIntegrationComponents(loadedIntegrations),
|
|
1160
|
+
loadComponentReplacements(coreDir, loadedIntegrations),
|
|
1034
1161
|
]);
|
|
1035
|
-
|
|
1162
|
+
// An active replacement answers to the Core name it replaces, so a search
|
|
1163
|
+
// for that name finds the replacement and not the Core original
|
|
1164
|
+
// (spec:AST-035 FR11).
|
|
1165
|
+
/** @type {Map<string, string>} */
|
|
1166
|
+
const targetOf = new Map(
|
|
1167
|
+
replacements.active.map(active => [
|
|
1168
|
+
`${active.package}\0${active.name}`,
|
|
1169
|
+
active.target,
|
|
1170
|
+
]),
|
|
1171
|
+
);
|
|
1172
|
+
return [
|
|
1173
|
+
...core.filter(candidate => !replacements.forTarget(candidate.name)),
|
|
1174
|
+
...integrations.map(candidate => {
|
|
1175
|
+
const target = targetOf.get(`${candidate._package}\0${candidate.name}`);
|
|
1176
|
+
if (target != null) {
|
|
1177
|
+
return {...candidate, aliases: [...(candidate.aliases ?? []), target]};
|
|
1178
|
+
}
|
|
1179
|
+
// Another package's component named after a replaced Core component is
|
|
1180
|
+
// shadowed for the bare name (FR14): its command names its package.
|
|
1181
|
+
const shadowedBy = replacements.forTarget(candidate.name);
|
|
1182
|
+
return shadowedBy && shadowedBy.package !== candidate._package
|
|
1183
|
+
? {
|
|
1184
|
+
...candidate,
|
|
1185
|
+
_command: `astryx component ${candidate.name} --package ${candidate._package}`,
|
|
1186
|
+
}
|
|
1187
|
+
: candidate;
|
|
1188
|
+
}),
|
|
1189
|
+
];
|
|
1036
1190
|
}
|
|
1037
1191
|
|
|
1038
1192
|
/**
|
|
@@ -1076,19 +1230,24 @@ export async function componentKeywords(coreDir, cwd) {
|
|
|
1076
1230
|
: null;
|
|
1077
1231
|
return {name, keywords: keywordsOf(doc)};
|
|
1078
1232
|
});
|
|
1079
|
-
const
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
components.map(async rec => ({
|
|
1084
|
-
name: rec.name,
|
|
1085
|
-
keywords: keywordsOf(await loadModuleDoc(rec.docPath)),
|
|
1086
|
-
})),
|
|
1087
|
-
);
|
|
1088
|
-
},
|
|
1233
|
+
const loadedIntegrations = await loadIntegrationsSafely(cwd);
|
|
1234
|
+
const replacements = await loadComponentReplacements(
|
|
1235
|
+
coreDir,
|
|
1236
|
+
loadedIntegrations,
|
|
1089
1237
|
);
|
|
1238
|
+
const integrations = loadedIntegrations.map(async integration => {
|
|
1239
|
+
const {components} = await discoverValidIntegrationComponents(integration);
|
|
1240
|
+
return Promise.all(
|
|
1241
|
+
components.map(async rec => ({
|
|
1242
|
+
name: rec.name,
|
|
1243
|
+
keywords: keywordsOf(await loadModuleDoc(rec.docPath)),
|
|
1244
|
+
})),
|
|
1245
|
+
);
|
|
1246
|
+
});
|
|
1090
1247
|
return [
|
|
1091
|
-
...(await Promise.all(core))
|
|
1248
|
+
...(await Promise.all(core)).filter(
|
|
1249
|
+
component => !replacements.forTarget(component.name),
|
|
1250
|
+
),
|
|
1092
1251
|
...(await Promise.all(integrations)).flat(),
|
|
1093
1252
|
];
|
|
1094
1253
|
}
|
|
@@ -1123,6 +1282,7 @@ async function gatherHooks(coreDir) {
|
|
|
1123
1282
|
name: hookName,
|
|
1124
1283
|
keywords,
|
|
1125
1284
|
description,
|
|
1285
|
+
_package: CORE_PACKAGE,
|
|
1126
1286
|
_import: importPath,
|
|
1127
1287
|
});
|
|
1128
1288
|
}
|
|
@@ -1179,7 +1339,11 @@ async function gatherDocs(cwd) {
|
|
|
1179
1339
|
const packages = new Map([
|
|
1180
1340
|
[entry.providerId ?? entry.package, entry.package],
|
|
1181
1341
|
...entry.extensions.map(
|
|
1182
|
-
ext =>
|
|
1342
|
+
ext =>
|
|
1343
|
+
/** @type {[string, string]} */ ([
|
|
1344
|
+
ext.providerId ?? ext.package,
|
|
1345
|
+
ext.package,
|
|
1346
|
+
]),
|
|
1183
1347
|
),
|
|
1184
1348
|
]);
|
|
1185
1349
|
candidates.push(
|
|
@@ -1257,7 +1421,8 @@ async function gatherDocs(cwd) {
|
|
|
1257
1421
|
_topic: node.route,
|
|
1258
1422
|
_title: path.join(' › '),
|
|
1259
1423
|
_command: `astryx docs ${node.route}`,
|
|
1260
|
-
_parent:
|
|
1424
|
+
_parent:
|
|
1425
|
+
node.parent == null ? 'astryx docs' : `astryx docs ${node.parent}`,
|
|
1261
1426
|
_package: node.provider,
|
|
1262
1427
|
});
|
|
1263
1428
|
}
|
|
@@ -1421,7 +1586,9 @@ function topicCandidates(
|
|
|
1421
1586
|
_title: `${docTitle} › ${section.title}`,
|
|
1422
1587
|
_command: `astryx docs ${name} ${key}`,
|
|
1423
1588
|
_parent: `astryx docs ${name} --index`,
|
|
1424
|
-
...((sectionPackage?.(key) ?? pkg)
|
|
1589
|
+
...((sectionPackage?.(key) ?? pkg)
|
|
1590
|
+
? {_package: sectionPackage?.(key) ?? pkg}
|
|
1591
|
+
: {}),
|
|
1425
1592
|
});
|
|
1426
1593
|
}
|
|
1427
1594
|
return out;
|
|
@@ -1484,6 +1651,7 @@ async function gatherTemplates(cwd) {
|
|
|
1484
1651
|
// short idea is not a direct match.
|
|
1485
1652
|
prose: t.keywords ?? [],
|
|
1486
1653
|
_displayName: t.name,
|
|
1654
|
+
_package: t.package ?? CORE_PACKAGE,
|
|
1487
1655
|
_kind: t.type, // 'page' | 'block'
|
|
1488
1656
|
_resultName: t.dirName,
|
|
1489
1657
|
_commandName: commandName,
|
|
@@ -1536,6 +1704,7 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
|
|
|
1536
1704
|
const base = {
|
|
1537
1705
|
domain: c.domain,
|
|
1538
1706
|
name: c._resultName ?? c.name,
|
|
1707
|
+
package: c._package,
|
|
1539
1708
|
score,
|
|
1540
1709
|
reason,
|
|
1541
1710
|
description: c.description || '',
|
|
@@ -1546,7 +1715,7 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
|
|
|
1546
1715
|
result = {
|
|
1547
1716
|
...base,
|
|
1548
1717
|
import: c._import,
|
|
1549
|
-
command: `astryx component ${c.name}`,
|
|
1718
|
+
command: c._command ?? `astryx component ${c.name}`,
|
|
1550
1719
|
};
|
|
1551
1720
|
break;
|
|
1552
1721
|
case 'hook':
|
|
@@ -1566,7 +1735,6 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
|
|
|
1566
1735
|
title: c._title,
|
|
1567
1736
|
command: c._command ?? `astryx docs ${c.name}`,
|
|
1568
1737
|
...(c._parent ? {parent: c._parent} : {}),
|
|
1569
|
-
...(c._package ? {package: c._package} : {}),
|
|
1570
1738
|
};
|
|
1571
1739
|
break;
|
|
1572
1740
|
case 'template':
|
|
@@ -1581,8 +1749,7 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
|
|
|
1581
1749
|
result = {
|
|
1582
1750
|
...base,
|
|
1583
1751
|
displayName: c._displayName,
|
|
1584
|
-
command: `astryx theme add ${c.name}`,
|
|
1585
|
-
...(c._package ? {package: c._package} : {}),
|
|
1752
|
+
command: `astryx theme add --import ${c.name}`,
|
|
1586
1753
|
};
|
|
1587
1754
|
break;
|
|
1588
1755
|
default:
|
|
@@ -1669,24 +1836,61 @@ export async function search(query, options = {}) {
|
|
|
1669
1836
|
// role (page / block / component) and takes the top of each, so there's no
|
|
1670
1837
|
// cross-role competition to engineer — a target page only needs to be the
|
|
1671
1838
|
// strongest PAGE, not outrank every component.
|
|
1672
|
-
|
|
1839
|
+
/** @type {{result: any, priority: 0 | 1 | 2}[]} */
|
|
1840
|
+
const ranked = [];
|
|
1673
1841
|
for (const candidate of all) {
|
|
1674
1842
|
const hit = scoreQuery(term, tokens, candidate);
|
|
1675
1843
|
if (hit)
|
|
1676
|
-
|
|
1677
|
-
toResult(
|
|
1678
|
-
|
|
1844
|
+
ranked.push({
|
|
1845
|
+
result: toResult(
|
|
1846
|
+
candidate,
|
|
1847
|
+
hit.score,
|
|
1848
|
+
hit.reason,
|
|
1849
|
+
hit.matched,
|
|
1850
|
+
hit.total,
|
|
1851
|
+
),
|
|
1852
|
+
priority: domainPriority(term, tokens, candidate, hit),
|
|
1853
|
+
});
|
|
1679
1854
|
}
|
|
1680
1855
|
|
|
1681
|
-
//
|
|
1856
|
+
// Docs and everything else are each sorted by score desc, then domain
|
|
1857
|
+
// (stable order), then name. The two are merged: at each step the stronger
|
|
1858
|
+
// head goes next, except that a head with domain priority goes ahead of a
|
|
1859
|
+
// doc head without it (see domainPriority). Each side keeps its own order.
|
|
1682
1860
|
/** @type {Record<string, number>} */
|
|
1683
1861
|
const domainOrder = {component: 0, hook: 1, doc: 2, template: 3, theme: 4};
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1862
|
+
/**
|
|
1863
|
+
* @param {{result: any}} x
|
|
1864
|
+
* @param {{result: any}} y
|
|
1865
|
+
*/
|
|
1866
|
+
const byScore = ({result: a}, {result: b}) =>
|
|
1867
|
+
b.score - a.score ||
|
|
1868
|
+
(domainOrder[a.domain] ?? 9) - (domainOrder[b.domain] ?? 9) ||
|
|
1869
|
+
a.name.localeCompare(b.name);
|
|
1870
|
+
const others = ranked.filter(r => r.result.domain !== 'doc').sort(byScore);
|
|
1871
|
+
// Against other domains, a doc the reader asked for competes ahead of docs
|
|
1872
|
+
// they did not, so it is not held behind a broad page that outscores it.
|
|
1873
|
+
// Docs alone keep their text-match order, with a doc the whole query names
|
|
1874
|
+
// first.
|
|
1875
|
+
const docs = ranked
|
|
1876
|
+
.filter(r => r.result.domain === 'doc')
|
|
1877
|
+
.sort((x, y) =>
|
|
1878
|
+
others.length > 0
|
|
1879
|
+
? y.priority - x.priority || byScore(x, y)
|
|
1880
|
+
: Number(y.priority === 2) - Number(x.priority === 2) || byScore(x, y),
|
|
1881
|
+
);
|
|
1882
|
+
const scored = [];
|
|
1883
|
+
let i = 0;
|
|
1884
|
+
let j = 0;
|
|
1885
|
+
while (i < others.length || j < docs.length) {
|
|
1886
|
+
const other = others[i];
|
|
1887
|
+
const doc = docs[j];
|
|
1888
|
+
const otherFirst =
|
|
1889
|
+
!doc ||
|
|
1890
|
+
(other != null &&
|
|
1891
|
+
((other.priority && !doc.priority) || byScore(other, doc) < 0));
|
|
1892
|
+
scored.push(otherFirst ? others[i++].result : docs[j++].result);
|
|
1893
|
+
}
|
|
1690
1894
|
|
|
1691
1895
|
// `results` is bounded by `limit` so a caller (and the recorded run that
|
|
1692
1896
|
// quotes it) never carries an unbounded payload. `matchCount` is the number
|
|
@@ -367,7 +367,11 @@ describe('search leaf — a whole-query phrase in a title or heading is top tier
|
|
|
367
367
|
it('puts the dark mode section first for a docs search', async () => {
|
|
368
368
|
for (const query of ['dark mode', 'how do I add dark mode']) {
|
|
369
369
|
const r = await search(query, {cwd, type: 'doc'});
|
|
370
|
-
|
|
370
|
+
// The topic-level hit and the section can tie; either is correct.
|
|
371
|
+
const top = r.data.results[0];
|
|
372
|
+
const hasDarkMode = top.section === 'light-dark-mode' ||
|
|
373
|
+
top.name === 'use-a-theme' || top.name === 'theme';
|
|
374
|
+
expect(hasDarkMode).toBe(true);
|
|
371
375
|
}
|
|
372
376
|
}, SLOW);
|
|
373
377
|
});
|
|
@@ -30,7 +30,7 @@ export type SearchResultEntry = {
|
|
|
30
30
|
*/
|
|
31
31
|
description: string;
|
|
32
32
|
/**
|
|
33
|
-
* - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add neutral` for a theme).
|
|
33
|
+
* - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add --import neutral` for a theme).
|
|
34
34
|
*/
|
|
35
35
|
command: string;
|
|
36
36
|
/**
|
|
@@ -46,9 +46,9 @@ export type SearchResultEntry = {
|
|
|
46
46
|
*/
|
|
47
47
|
section?: string | undefined;
|
|
48
48
|
/**
|
|
49
|
-
* - The npm package that
|
|
49
|
+
* - The npm package that owns the result: `@astryxdesign/core` for a Core component, hook, or template, `@astryxdesign/cli` for a doc the CLI ships, or the integration package that contributed it. For a doc section, the package whose file the section came from.
|
|
50
50
|
*/
|
|
51
|
-
package
|
|
51
|
+
package: string;
|
|
52
52
|
/**
|
|
53
53
|
* - Command that opens the level above a doc result — its topic's section list for a section, the docs-tree namespace it sits in for a tree node — so a reader can see the siblings and open another.
|
|
54
54
|
*/
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
* @property {number} score - Relevance score (higher is better).
|
|
21
21
|
* @property {string} reason - Human-readable reason the candidate matched (e.g. `keyword "button"`).
|
|
22
22
|
* @property {string} description - One-line description, when available.
|
|
23
|
-
* @property {string} command - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add neutral` for a theme).
|
|
23
|
+
* @property {string} command - Follow-up command to act on this result (e.g. `astryx component Button`, or `astryx theme add --import neutral` for a theme).
|
|
24
24
|
* @property {string} [import] - Import path — present for component and hook results.
|
|
25
25
|
* @property {string} [title] - Doc title — present for doc results.
|
|
26
26
|
* @property {string} [section] - Section key — present when a doc result is one section of a topic; `command` reads only that section.
|
|
27
|
-
* @property {string}
|
|
27
|
+
* @property {string} package - The npm package that owns the result: `@astryxdesign/core` for a Core component, hook, or template, `@astryxdesign/cli` for a doc the CLI ships, or the integration package that contributed it. For a doc section, the package whose file the section came from.
|
|
28
28
|
* @property {string} [parent] - Command that opens the level above a doc result — its topic's section list for a section, the docs-tree namespace it sits in for a tree node — so a reader can see the siblings and open another.
|
|
29
29
|
* @property {string} [displayName] - Friendly display name — present for template and theme results.
|
|
30
30
|
* @property {'page' | 'block'} [kind] - Template kind (`page` | `block`) — present for template results.
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The integration component that replaces the Core component `name`
|
|
6
|
+
* (spec:AST-035 FR11), or undefined when none does.
|
|
7
|
+
* @param {string} coreDir
|
|
8
|
+
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
9
|
+
* @param {string} name
|
|
10
|
+
* @returns {Promise<import('../../foundation/discovery/component-replacement.mjs').ActiveComponentReplacement | undefined>}
|
|
11
|
+
*/
|
|
12
|
+
export function resolveComponentReplacement(coreDir: string, loadedIntegrations: import("../../foundation/integrations/integrations.mjs").LoadedIntegration[], name: string): Promise<import("../../foundation/discovery/component-replacement.mjs").ActiveComponentReplacement | undefined>;
|
|
4
13
|
/**
|
|
5
14
|
* Locate @astryxdesign/core for `cwd` and list its swizzlable components.
|
|
6
15
|
* @param {string} cwd
|
|
@@ -10,3 +19,4 @@ export function resolveCore(cwd: string): {
|
|
|
10
19
|
coreDir: string;
|
|
11
20
|
components: string[];
|
|
12
21
|
};
|
|
22
|
+
export { CORE_PROVIDER_ID as CORE_PACKAGE } from "../../foundation/identity/providers.mjs";
|
package/api/swizzle/_adapter.mjs
CHANGED
|
@@ -12,9 +12,32 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import {findCoreDir, listComponents} from '../../foundation/fs/paths.mjs';
|
|
15
|
+
import {resolveComponentReplacements} from '../../foundation/discovery/component-replacement.mjs';
|
|
15
16
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
16
17
|
import {AstryxError} from '../error.mjs';
|
|
17
18
|
|
|
19
|
+
/** The package that owns Core's components, hooks, and codemods. */
|
|
20
|
+
export {CORE_PROVIDER_ID as CORE_PACKAGE} from '../../foundation/identity/providers.mjs';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The integration component that replaces the Core component `name`
|
|
24
|
+
* (spec:AST-035 FR11), or undefined when none does.
|
|
25
|
+
* @param {string} coreDir
|
|
26
|
+
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
27
|
+
* @param {string} name
|
|
28
|
+
* @returns {Promise<import('../../foundation/discovery/component-replacement.mjs').ActiveComponentReplacement | undefined>}
|
|
29
|
+
*/
|
|
30
|
+
export async function resolveComponentReplacement(
|
|
31
|
+
coreDir,
|
|
32
|
+
loadedIntegrations,
|
|
33
|
+
name,
|
|
34
|
+
) {
|
|
35
|
+
if (loadedIntegrations.length === 0) return undefined;
|
|
36
|
+
return (
|
|
37
|
+
await resolveComponentReplacements(coreDir, loadedIntegrations)
|
|
38
|
+
).forTarget(name);
|
|
39
|
+
}
|
|
40
|
+
|
|
18
41
|
/**
|
|
19
42
|
* Locate @astryxdesign/core for `cwd` and list its swizzlable components.
|
|
20
43
|
* @param {string} cwd
|
|
@@ -17,12 +17,11 @@
|
|
|
17
17
|
* - Asset files (`.json`, `.css`): exported by full subpath (e.g.
|
|
18
18
|
* `./locales/*.json`, `./reset.css`), and collapsing a two-levels-up
|
|
19
19
|
* `../../locales/x.json` would emit the invalid `<pkg>/..`.
|
|
20
|
-
* -
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* keep the barrel collapse.
|
|
20
|
+
* - StyleX modules (`*.stylex`): the StyleX compiler needs the real module
|
|
21
|
+
* path so it can resolve the styles at compile time. The barrel re-export
|
|
22
|
+
* loses the module identity. Core exports every `.stylex` file by its
|
|
23
|
+
* deep subpath (e.g. `./utils/focusOutline.stylex`,
|
|
24
|
+
* `./theme/tokens.stylex`).
|
|
26
25
|
*
|
|
27
26
|
* @param {string} content
|
|
28
27
|
* @param {string} [ownerPackage]
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import * as fs from 'node:fs';
|
|
17
17
|
import * as path from 'node:path';
|
|
18
|
-
import {resolveCore} from '../_adapter.mjs';
|
|
18
|
+
import {resolveComponentReplacement, resolveCore} from '../_adapter.mjs';
|
|
19
19
|
import {assertWithin, sanitizeName, PathSafetyError} from '../../../foundation/fs/path-safety.mjs';
|
|
20
20
|
import {checkGhCli} from '../_github.mjs';
|
|
21
21
|
import {Project} from '../../../foundation/config/project.mjs';
|
|
@@ -46,12 +46,11 @@ const DEFAULT_ISSUES_URL = 'https://github.com/facebook/astryx/issues/new';
|
|
|
46
46
|
* - Asset files (`.json`, `.css`): exported by full subpath (e.g.
|
|
47
47
|
* `./locales/*.json`, `./reset.css`), and collapsing a two-levels-up
|
|
48
48
|
* `../../locales/x.json` would emit the invalid `<pkg>/..`.
|
|
49
|
-
* -
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* keep the barrel collapse.
|
|
49
|
+
* - StyleX modules (`*.stylex`): the StyleX compiler needs the real module
|
|
50
|
+
* path so it can resolve the styles at compile time. The barrel re-export
|
|
51
|
+
* loses the module identity. Core exports every `.stylex` file by its
|
|
52
|
+
* deep subpath (e.g. `./utils/focusOutline.stylex`,
|
|
53
|
+
* `./theme/tokens.stylex`).
|
|
55
54
|
*
|
|
56
55
|
* @param {string} content
|
|
57
56
|
* @param {string} [ownerPackage]
|
|
@@ -67,8 +66,8 @@ export function rewriteImports(content, ownerPackage = CORE_PACKAGE) {
|
|
|
67
66
|
if (/\.(?:json|css)$/.test(last)) {
|
|
68
67
|
return `${ownerPackage}/${rest}`;
|
|
69
68
|
}
|
|
70
|
-
//
|
|
71
|
-
if (
|
|
69
|
+
// StyleX modules need the deep path so the compiler can resolve them.
|
|
70
|
+
if (/\.stylex(?:\.[cm]?[jt]sx?)?$/.test(last)) {
|
|
72
71
|
return `${ownerPackage}/${rest}`;
|
|
73
72
|
}
|
|
74
73
|
return `${ownerPackage}/${parts[0]}`;
|
|
@@ -221,6 +220,26 @@ export async function swizzleCopy(component, options = {}) {
|
|
|
221
220
|
const coreIssuesUrl = project
|
|
222
221
|
? project.issuesUrl({package: CORE_PACKAGE})
|
|
223
222
|
: undefined;
|
|
223
|
+
// An active integration replacement answers to the Core name it replaces,
|
|
224
|
+
// bare or qualified by its own package (spec:AST-035 FR11): copy it under its
|
|
225
|
+
// own name. `--package @astryxdesign/core` still copies the Core original.
|
|
226
|
+
if (pkg !== CORE_PACKAGE) {
|
|
227
|
+
const replacement = await resolveComponentReplacement(
|
|
228
|
+
coreDir,
|
|
229
|
+
loadedIntegrations,
|
|
230
|
+
dirName,
|
|
231
|
+
);
|
|
232
|
+
if (
|
|
233
|
+
replacement &&
|
|
234
|
+
(!pkg || (pkg === replacement.package && replacement.name !== dirName))
|
|
235
|
+
) {
|
|
236
|
+
return swizzleCopy(replacement.name, {
|
|
237
|
+
...options,
|
|
238
|
+
package: replacement.package,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
224
243
|
const allOwners = resolveOwners(coreDir, loadedIntegrations, dirName, coreIssuesUrl);
|
|
225
244
|
|
|
226
245
|
if (allOwners.length === 0) {
|
|
@@ -359,7 +378,7 @@ export async function swizzleCopy(component, options = {}) {
|
|
|
359
378
|
usesStyleX,
|
|
360
379
|
};
|
|
361
380
|
if (feedback) data.feedback = feedback;
|
|
362
|
-
return {type: 'swizzle.copy', data};
|
|
381
|
+
return {type: 'swizzle.copy', package: data.package, data};
|
|
363
382
|
}
|
|
364
383
|
|
|
365
384
|
/**
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* shared seam. All human prose / usage hints live in the CLI renderer.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {resolveCore} from '../_adapter.mjs';
|
|
11
|
+
import {CORE_PACKAGE, resolveCore} from '../_adapter.mjs';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* List swizzlable components discoverable from `cwd`'s @astryxdesign/core.
|
|
@@ -17,5 +17,5 @@ import {resolveCore} from '../_adapter.mjs';
|
|
|
17
17
|
*/
|
|
18
18
|
export function swizzleList(cwd = process.cwd()) {
|
|
19
19
|
const {components} = resolveCore(cwd);
|
|
20
|
-
return {type: 'swizzle.list', data: components};
|
|
20
|
+
return {type: 'swizzle.list', package: CORE_PACKAGE, data: components};
|
|
21
21
|
}
|