@astryxdesign/cli 0.6.5 → 0.6.6-canary.1f4eb3c
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 +87 -0
- package/README.md +58 -55
- package/api/build/_adapter.d.mts +55 -2
- package/api/build/_adapter.mjs +100 -10
- package/api/build/build.doc.mjs +2 -2
- package/api/build/build.test.mjs +111 -2
- package/api/build/build.type.d.mts +8 -0
- package/api/build/build.type.mjs +2 -0
- package/api/build/kit/kit.mjs +99 -22
- package/api/build/kit/rank.d.mts +32 -8
- package/api/build/kit/rank.mjs +291 -97
- package/api/build/kit/rank.test.mjs +231 -48
- package/api/build/kit/weights.d.mts +82 -0
- package/api/build/kit/weights.json +1 -0
- package/api/build/kit/weights.mjs +305 -0
- package/api/build/kit/weights.test.mjs +190 -0
- package/api/component/_adapter.d.mts +19 -0
- package/api/component/_adapter.mjs +33 -0
- package/api/component/component-replacement.test.mjs +603 -0
- 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 +25 -0
- package/api/docs/detail/detail.mjs +19 -3
- package/api/docs/detail/section/section.mjs +7 -1
- package/api/docs/docOverlays.test.mjs +10 -6
- package/api/docs/docs.d.mts +6 -0
- package/api/docs/docs.depth.test.mjs +134 -0
- package/api/docs/docs.doc.mjs +31 -2
- package/api/docs/docs.mjs +46 -1
- package/api/docs/docs.test.mjs +279 -0
- package/api/docs/docs.type.d.mts +81 -4
- package/api/docs/docs.type.mjs +41 -4
- package/api/docs/index/index.mjs +11 -2
- package/api/docs/index/index.test.mjs +7 -2
- package/api/docs/integration-tree.test.mjs +572 -0
- package/api/docs/integrationDocs.test.mjs +337 -0
- package/api/docs/node/node.d.mts +28 -3
- package/api/docs/node/node.mjs +149 -23
- package/api/doctor/_adapter.d.mts +43 -0
- package/api/doctor/_adapter.mjs +142 -0
- package/api/doctor/doctor.d.mts +0 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +6 -123
- package/api/doctor/theme-checks.d.mts +12 -0
- package/api/doctor/theme-checks.mjs +1117 -0
- package/api/doctor/theme-checks.test.mjs +526 -0
- package/api/error.d.mts +22 -0
- package/api/error.mjs +42 -0
- package/api/gap-report/gap-report.d.mts +3 -1
- package/api/gap-report/gap-report.mjs +27 -3
- package/api/gap-report/gap-report.test.mjs +106 -0
- 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.d.mts +1 -1
- 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 +10 -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-contribution.d.mts +2 -1
- package/api/integration/add-contribution.mjs +7 -3
- package/api/integration/add-contribution.test.mjs +3 -3
- package/api/integration/add-helpers.d.mts +26 -5
- package/api/integration/add-helpers.mjs +50 -5
- package/api/integration/add-theme.mjs +354 -28
- package/api/integration/add-theme.test.mjs +380 -16
- package/api/integration/authoring-checks.mjs +31 -8
- package/api/integration/authoring-checks.type.d.mts +8 -0
- package/api/integration/authoring-checks.type.mjs +7 -3
- package/api/integration/integration-authoring.type.d.mts +4 -1
- package/api/integration/integration-authoring.type.mjs +6 -1
- package/api/integration/integrationAdd.doc.mjs +6 -0
- package/api/integration/integrationAddTheme.doc.mjs +10 -0
- package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
- 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 +495 -4
- package/api/integration/pack-check.test.mjs +619 -10
- package/api/integration/validate-integration.d.mts +4 -2
- package/api/integration/validate-integration.mjs +7 -2
- package/api/integration/validate-integration.test.mjs +55 -0
- package/api/integration/validate-integration.type.d.mts +5 -0
- package/api/integration/validate-integration.type.mjs +5 -1
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/layout/expand/expand.mjs +12 -7
- package/api/layout/expand/expand.receipt.test.mjs +74 -0
- package/api/layout/layout.type.d.mts +1 -0
- package/api/layout/layout.type.mjs +1 -0
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/search/search.d.mts +39 -8
- package/api/search/search.doc.mjs +4 -4
- package/api/search/search.mjs +248 -66
- package/api/search/search.test.mjs +829 -0
- package/api/search/search.type.d.mts +6 -6
- package/api/search/search.type.mjs +5 -5
- 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 +95 -13
- package/api/swizzle/list/list.mjs +2 -2
- package/api/swizzle/swizzle.doc.mjs +4 -0
- 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 +15 -8
- package/api/template/copy/copy.receipt.test.mjs +77 -0
- package/api/template/show/show.mjs +17 -4
- package/api/template/show/show.test.mjs +76 -0
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template-integration.test.mjs +14 -0
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +6 -2
- package/api/template/template.mjs +2 -0
- package/api/template/template.type.d.mts +14 -0
- package/api/template/template.type.mjs +5 -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 +50 -2
- package/api/theme/build/build.family.test.mjs +13 -4
- package/api/theme/build/build.icon-lineage.test.mjs +117 -0
- package/api/theme/build/build.icon-preservation.test.mjs +639 -0
- package/api/theme/build/build.mjs +463 -155
- package/api/theme/build/build.project-core.test.mjs +165 -0
- package/api/theme/build/build.test.mjs +220 -1
- package/api/theme/build/icon-imports.d.mts +47 -0
- package/api/theme/build/icon-imports.mjs +691 -0
- 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.d.mts +4 -1
- package/api/theme/themeBuild.doc.mjs +15 -4
- 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/run/run.mjs +20 -3
- package/api/upgrade/run/run.test.mjs +45 -1
- package/api/upgrade/upgrade.doc.mjs +1 -1
- package/api/upgrade/upgrade.type.d.mts +5 -0
- package/api/upgrade/upgrade.type.mjs +2 -0
- package/assets/codemods/integration-discovery.mjs +1 -1
- package/assets/codemods/integration-discovery.test.mjs +64 -0
- package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
- package/assets/codemods/transforms/next/index.mjs +14 -1
- package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
- package/assets/docs/author-a-theme.doc.mjs +161 -0
- package/assets/docs/getting-started.doc.mjs +59 -15
- package/assets/docs/icons.doc.mjs +1 -0
- package/assets/docs/principles.doc.dense.mjs +2 -2
- package/assets/docs/principles.doc.mjs +2 -2
- package/assets/docs/principles.doc.zh.mjs +2 -2
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/styling.doc.mjs +2 -2
- package/assets/docs/theme.doc.dense.mjs +10 -198
- package/assets/docs/theme.doc.mjs +13 -770
- package/assets/docs/theme.doc.zh.mjs +31 -12
- package/assets/docs/tokens.doc.mjs +4 -4
- package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
- package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +6 -5
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +2 -2
- package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
- package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
- package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
- package/assets/docs/tree/layout.doc.mjs +32 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
- package/assets/docs/tree/responsive.doc.mjs +102 -0
- package/assets/docs/tree/scaffold.doc.mjs +145 -0
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/side-panels.doc.mjs +82 -0
- package/assets/docs/tree/structure.doc.mjs +144 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +13 -1
- package/assets/docs/tree/themes.doc.mjs +2 -2
- package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
- package/assets/docs/tree/versioning.doc.mjs +11 -7
- package/assets/docs/use-a-theme.doc.mjs +97 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
- package/assets/templates/pages/ai-chat/template.doc.mjs +16 -1
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +9 -1
- package/assets/templates/pages/blank/template.doc.mjs +3 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +9 -1
- package/assets/templates/pages/centered-hero/template.doc.mjs +3 -1
- package/assets/templates/pages/checkout-wizard/template.doc.mjs +1 -0
- package/assets/templates/pages/classic-gallery/template.doc.mjs +3 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +16 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +15 -1
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +23 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +10 -1
- package/assets/templates/pages/dashboard-comparison/template.doc.mjs +9 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +10 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +17 -1
- package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -1
- package/assets/templates/pages/detail-page/template.doc.mjs +8 -0
- package/assets/templates/pages/documentation/template.doc.mjs +10 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +10 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +10 -1
- package/assets/templates/pages/editor/template.doc.mjs +9 -1
- package/assets/templates/pages/file-explorer/template.doc.mjs +3 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +17 -1
- package/assets/templates/pages/form-wizard/template.doc.mjs +14 -1
- package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +1 -0
- package/assets/templates/pages/gallery-hero/template.doc.mjs +10 -1
- package/assets/templates/pages/ide/template.doc.mjs +9 -1
- package/assets/templates/pages/incident-console/template.doc.mjs +10 -1
- package/assets/templates/pages/kanban-board/template.doc.mjs +11 -1
- package/assets/templates/pages/library/template.doc.mjs +15 -1
- package/assets/templates/pages/login/template.doc.mjs +10 -1
- package/assets/templates/pages/login-card/template.doc.mjs +11 -1
- package/assets/templates/pages/login-split/template.doc.mjs +10 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +10 -1
- package/assets/templates/pages/messaging-shell/template.doc.mjs +11 -1
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +10 -1
- package/assets/templates/pages/payment-form/template.doc.mjs +3 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +9 -1
- package/assets/templates/pages/product-gallery/template.doc.mjs +10 -1
- package/assets/templates/pages/settings/template.doc.mjs +3 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +9 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +9 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +10 -1
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +14 -1
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +11 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +3 -1
- package/assets/templates/pages/table/template.doc.mjs +11 -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/templates/pages/table-filter/template.doc.mjs +21 -1
- package/assets/templates/pages/table-grouped/template.doc.mjs +15 -1
- package/assets/templates/pages/table-inbox/template.doc.mjs +18 -6
- package/assets/templates/pages/table-page/template.doc.mjs +20 -1
- package/assets/templates/pages/table-tree/template.doc.mjs +14 -1
- package/assets/templates/pages/theme-showcase/template.doc.mjs +10 -1
- package/assets/templates/pages/work-item-detail/template.doc.mjs +10 -0
- package/assets/templates/themes/butter/icons.tsx +2 -0
- package/assets/templates/themes/chocolate/icons.tsx +2 -0
- package/assets/templates/themes/gothic/icons.tsx +2 -0
- package/assets/templates/themes/matcha/icons.tsx +2 -0
- package/assets/templates/themes/neutral/icons.tsx +2 -0
- package/assets/templates/themes/stone/icons.tsx +2 -0
- package/assets/templates/themes/y2k/icons.tsx +2 -0
- 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/parse.d.mts +2 -0
- package/authoring/doctypes/template/parse.mjs +1 -0
- package/authoring/doctypes/template/parse.test.mjs +21 -0
- package/authoring/doctypes/template/template.doc.mjs +6 -0
- package/authoring/doctypes/template/type.ts +10 -0
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/build-theme.mjs +279 -30
- package/clients/cli/commands/build.mjs +7 -6
- package/clients/cli/commands/build.text-fields.test.mjs +1 -1
- package/clients/cli/commands/component/index.mjs +88 -12
- package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
- package/clients/cli/commands/component.doc.mjs +9 -2
- package/clients/cli/commands/discover.mjs +29 -1
- package/clients/cli/commands/discover.no-source.test.mjs +75 -0
- package/clients/cli/commands/docs.depth.test.mjs +219 -0
- package/clients/cli/commands/docs.doc.mjs +15 -2
- package/clients/cli/commands/docs.mjs +273 -16
- package/clients/cli/commands/docs.test.mjs +382 -0
- 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.mjs +4 -4
- package/clients/cli/commands/doctor.test.mjs +9 -51
- package/clients/cli/commands/gap-report.doc.mjs +2 -2
- package/clients/cli/commands/gap-report.mjs +12 -0
- package/clients/cli/commands/gap-report.test.mjs +63 -0
- package/clients/cli/commands/hook/index.mjs +7 -2
- package/clients/cli/commands/import-hint-correctness.test.mjs +5 -5
- package/clients/cli/commands/init.next-steps.test.mjs +18 -23
- package/clients/cli/commands/integration-add.doc.mjs +10 -0
- package/clients/cli/commands/integration-authoring.test.mjs +12 -2
- package/clients/cli/commands/integration-real-world.test.mjs +61 -12
- package/clients/cli/commands/integration.mjs +3 -1
- package/clients/cli/commands/layout-check.doc.mjs +1 -0
- package/clients/cli/commands/layout-expand.doc.mjs +4 -1
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
- package/clients/cli/commands/layout.doc.mjs +1 -0
- package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
- package/clients/cli/commands/layout.mjs +61 -4
- package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
- package/clients/cli/commands/search.doc.mjs +5 -4
- package/clients/cli/commands/search.mjs +30 -6
- package/clients/cli/commands/search.test.mjs +63 -17
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
- package/clients/cli/commands/template.mjs +70 -6
- package/clients/cli/commands/template.show-media.test.mjs +62 -0
- package/clients/cli/commands/text-json-parity.test.mjs +40 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +132 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-eject.doc.mjs +47 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +44 -0
- 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.ascii-output.test.mjs +14 -0
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/commands/write-failure.test.mjs +175 -0
- package/clients/cli/index.mjs +4 -1
- package/clients/cli/lib/component-format.mjs +19 -2
- package/clients/cli/lib/manifest.mjs +44 -165
- package/clients/cli/lib/manifest.test.mjs +98 -7
- 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 +31 -28
- package/foundation/agent-docs/agent-docs.test.mjs +1163 -0
- 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/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-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-adapter.d.mts +14 -0
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
- package/foundation/discovery/template-adapter.mjs +21 -1
- package/foundation/discovery/theme-discovery.d.mts +78 -5
- package/foundation/discovery/theme-discovery.mjs +143 -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/doc-loads.test.mjs +18 -8
- package/foundation/doc-compiler/inputs.mjs +2 -1
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/lenses.d.mts +4 -2
- package/foundation/doc-compiler/lenses.mjs +1 -1
- package/foundation/doc-compiler/tree.test.mjs +649 -0
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +79 -13
- package/foundation/integrations/cli-requirement.mjs +115 -22
- package/foundation/integrations/cli-requirement.test.mjs +205 -8
- package/foundation/integrations/contribution-inventory.mjs +3 -3
- 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.d.mts +5 -5
- package/foundation/response/response-types.doc.mjs +50 -35
- 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
|
@@ -24,7 +24,12 @@ import {
|
|
|
24
24
|
import {discoverExternalPackages} from '../../../foundation/fs/paths.mjs';
|
|
25
25
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
26
26
|
import {AstryxError} from '../../error.mjs';
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
loadComponentDoc,
|
|
29
|
+
loadComponentReplacements,
|
|
30
|
+
loadIntegrationsSafely,
|
|
31
|
+
withOwnership,
|
|
32
|
+
} from '../_adapter.mjs';
|
|
28
33
|
|
|
29
34
|
/**
|
|
30
35
|
* @typedef {import('../component.type.mjs').ComponentListResponse} ComponentListResponse
|
|
@@ -55,6 +60,66 @@ async function legacyImport(ext, name, coreDir, docOpts) {
|
|
|
55
60
|
return withOwnership(docs, {package: ext.name, sourcePath: null}, name, coreDir).import;
|
|
56
61
|
}
|
|
57
62
|
|
|
63
|
+
/**
|
|
64
|
+
* A full Core ComponentDoc list entry, naming the package that owns it.
|
|
65
|
+
* @param {any} doc
|
|
66
|
+
*/
|
|
67
|
+
const coreEntry = doc => ({name: doc.name, package: CORE_PACKAGE, ...doc});
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The entry for a Core slot an integration component replaces
|
|
71
|
+
* (spec:AST-035 FR11), at the list's detail level: the replacement's own name,
|
|
72
|
+
* its package, and the import `component <Name>` reports for it.
|
|
73
|
+
* @param {import('../../../foundation/discovery/component-replacement.mjs').ActiveComponentReplacement} replacement
|
|
74
|
+
* @param {'names'|'compact'|'full'} detail
|
|
75
|
+
* @param {{zh: boolean, dense: boolean, lang: string|null}} docOpts
|
|
76
|
+
* @returns {Promise<any>}
|
|
77
|
+
*/
|
|
78
|
+
async function replacementEntry(replacement, detail, {zh, dense, lang}) {
|
|
79
|
+
const {integration} = replacement;
|
|
80
|
+
/** @type {any} */
|
|
81
|
+
let docs = null;
|
|
82
|
+
try {
|
|
83
|
+
docs = await loadComponentDoc(
|
|
84
|
+
replacement.docPath,
|
|
85
|
+
detail === 'full' ? {zh, lang, dense} : {zh, lang},
|
|
86
|
+
);
|
|
87
|
+
} catch {
|
|
88
|
+
// Keep list resilient; validation owns malformed integration docs.
|
|
89
|
+
}
|
|
90
|
+
const importPath = resolveIntegrationImportPath(
|
|
91
|
+
{
|
|
92
|
+
exportsMap: integration.__packageExports,
|
|
93
|
+
packageDir: integration.__packageDir,
|
|
94
|
+
docPath: replacement.docPath,
|
|
95
|
+
packageName: replacement.package,
|
|
96
|
+
},
|
|
97
|
+
replacement.name,
|
|
98
|
+
docs?.import,
|
|
99
|
+
);
|
|
100
|
+
if (detail === 'names') {
|
|
101
|
+
return {name: replacement.name, package: replacement.package, import: importPath};
|
|
102
|
+
}
|
|
103
|
+
if (detail === 'compact') {
|
|
104
|
+
return {
|
|
105
|
+
name: replacement.name,
|
|
106
|
+
package: replacement.package,
|
|
107
|
+
description: docs?.usage?.description || docs?.description || '',
|
|
108
|
+
import: importPath,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (docs == null) {
|
|
112
|
+
return {name: replacement.name, package: replacement.package, description: ''};
|
|
113
|
+
}
|
|
114
|
+
const {package: _owner, ...doc} = docs;
|
|
115
|
+
return {
|
|
116
|
+
name: doc.name ?? replacement.name,
|
|
117
|
+
package: replacement.package,
|
|
118
|
+
...doc,
|
|
119
|
+
import: importPath,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
58
123
|
/**
|
|
59
124
|
* Build the `component.list` envelope. The list taxonomy is collapsed: all
|
|
60
125
|
* three detail levels emit ONE `component.list` type; the depth rides in
|
|
@@ -74,6 +139,15 @@ export async function componentList(
|
|
|
74
139
|
{cwd, category, detail, zh, dense, lang},
|
|
75
140
|
) {
|
|
76
141
|
const components = discoverComponents(coreDir);
|
|
142
|
+
// An active integration replacement takes its Core component's slot in
|
|
143
|
+
// every list view (spec:AST-035 FR11); the Core original stays reachable
|
|
144
|
+
// with `component <Name> --package @astryxdesign/core`.
|
|
145
|
+
const loadedIntegrations = await loadIntegrationsSafely(cwd);
|
|
146
|
+
const replacements = await loadComponentReplacements(
|
|
147
|
+
coreDir,
|
|
148
|
+
loadedIntegrations,
|
|
149
|
+
);
|
|
150
|
+
const docOpts = {zh, dense, lang};
|
|
77
151
|
|
|
78
152
|
if (category) {
|
|
79
153
|
const match = Object.entries(components).find(
|
|
@@ -91,18 +165,25 @@ export async function componentList(
|
|
|
91
165
|
/** @type {ComponentBriefEntry[]} */
|
|
92
166
|
const entries = [];
|
|
93
167
|
for (const comp of match[1]) {
|
|
168
|
+
const replacement = replacements.forTarget(comp);
|
|
169
|
+
if (replacement) {
|
|
170
|
+
entries.push(await replacementEntry(replacement, 'compact', docOpts));
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
94
173
|
const readme = findComponentReadme(coreDir, comp);
|
|
95
174
|
if (readme && readme.endsWith('.doc.mjs')) {
|
|
96
175
|
try {
|
|
97
176
|
const docs = await loadComponentDoc(readme, {zh, lang});
|
|
98
177
|
entries.push({
|
|
99
178
|
name: comp,
|
|
179
|
+
package: CORE_PACKAGE,
|
|
100
180
|
description: docs.usage?.description || docs.description || '',
|
|
101
181
|
import: resolveImportPath(coreDir, comp),
|
|
102
182
|
});
|
|
103
183
|
} catch {
|
|
104
184
|
entries.push({
|
|
105
185
|
name: comp,
|
|
186
|
+
package: CORE_PACKAGE,
|
|
106
187
|
description: '',
|
|
107
188
|
import: resolveImportPath(coreDir, comp),
|
|
108
189
|
});
|
|
@@ -110,6 +191,7 @@ export async function componentList(
|
|
|
110
191
|
} else {
|
|
111
192
|
entries.push({
|
|
112
193
|
name: comp,
|
|
194
|
+
package: CORE_PACKAGE,
|
|
113
195
|
description: '',
|
|
114
196
|
import: resolveImportPath(coreDir, comp),
|
|
115
197
|
});
|
|
@@ -125,15 +207,20 @@ export async function componentList(
|
|
|
125
207
|
/** @type {any[]} */
|
|
126
208
|
const entries = [];
|
|
127
209
|
for (const comp of match[1]) {
|
|
210
|
+
const replacement = replacements.forTarget(comp);
|
|
211
|
+
if (replacement) {
|
|
212
|
+
entries.push(await replacementEntry(replacement, 'full', docOpts));
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
128
215
|
const readme = findComponentReadme(coreDir, comp);
|
|
129
216
|
if (readme && readme.endsWith('.doc.mjs')) {
|
|
130
217
|
try {
|
|
131
|
-
entries.push(await loadComponentDoc(readme, {zh, lang, dense}));
|
|
218
|
+
entries.push(coreEntry(await loadComponentDoc(readme, {zh, lang, dense})));
|
|
132
219
|
} catch {
|
|
133
|
-
entries.push({name: `XDS${comp}`, description: ''});
|
|
220
|
+
entries.push({name: `XDS${comp}`, package: CORE_PACKAGE, description: ''});
|
|
134
221
|
}
|
|
135
222
|
} else {
|
|
136
|
-
entries.push({name: `XDS${comp}`, description: ''});
|
|
223
|
+
entries.push({name: `XDS${comp}`, package: CORE_PACKAGE, description: ''});
|
|
137
224
|
}
|
|
138
225
|
}
|
|
139
226
|
return {
|
|
@@ -150,7 +237,14 @@ export async function componentList(
|
|
|
150
237
|
data: {
|
|
151
238
|
detail: 'names',
|
|
152
239
|
components: {
|
|
153
|
-
[match[0]]:
|
|
240
|
+
[match[0]]: await Promise.all(
|
|
241
|
+
match[1].map(n => {
|
|
242
|
+
const replacement = replacements.forTarget(n);
|
|
243
|
+
return replacement
|
|
244
|
+
? replacementEntry(replacement, 'names', docOpts)
|
|
245
|
+
: {name: n, package: CORE_PACKAGE};
|
|
246
|
+
}),
|
|
247
|
+
),
|
|
154
248
|
},
|
|
155
249
|
},
|
|
156
250
|
};
|
|
@@ -163,18 +257,25 @@ export async function componentList(
|
|
|
163
257
|
for (const [cat, comps] of Object.entries(components)) {
|
|
164
258
|
result[cat] = [];
|
|
165
259
|
for (const comp of comps) {
|
|
260
|
+
const replacement = replacements.forTarget(comp);
|
|
261
|
+
if (replacement) {
|
|
262
|
+
result[cat].push(await replacementEntry(replacement, 'compact', docOpts));
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
166
265
|
const readme = findComponentReadme(coreDir, comp);
|
|
167
266
|
if (readme && readme.endsWith('.doc.mjs')) {
|
|
168
267
|
try {
|
|
169
268
|
const docs = await loadComponentDoc(readme, {zh, lang});
|
|
170
269
|
result[cat].push({
|
|
171
270
|
name: comp,
|
|
271
|
+
package: CORE_PACKAGE,
|
|
172
272
|
description: docs.usage?.description || docs.description || '',
|
|
173
273
|
import: resolveImportPath(coreDir, comp),
|
|
174
274
|
});
|
|
175
275
|
} catch {
|
|
176
276
|
result[cat].push({
|
|
177
277
|
name: comp,
|
|
278
|
+
package: CORE_PACKAGE,
|
|
178
279
|
description: '',
|
|
179
280
|
import: resolveImportPath(coreDir, comp),
|
|
180
281
|
});
|
|
@@ -182,6 +283,7 @@ export async function componentList(
|
|
|
182
283
|
} else {
|
|
183
284
|
result[cat].push({
|
|
184
285
|
name: comp,
|
|
286
|
+
package: CORE_PACKAGE,
|
|
185
287
|
description: '',
|
|
186
288
|
import: resolveImportPath(coreDir, comp),
|
|
187
289
|
});
|
|
@@ -200,15 +302,20 @@ export async function componentList(
|
|
|
200
302
|
for (const [cat, comps] of Object.entries(components)) {
|
|
201
303
|
result[cat] = [];
|
|
202
304
|
for (const comp of comps) {
|
|
305
|
+
const replacement = replacements.forTarget(comp);
|
|
306
|
+
if (replacement) {
|
|
307
|
+
result[cat].push(await replacementEntry(replacement, 'full', docOpts));
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
203
310
|
const readme = findComponentReadme(coreDir, comp);
|
|
204
311
|
if (readme && readme.endsWith('.doc.mjs')) {
|
|
205
312
|
try {
|
|
206
|
-
result[cat].push(await loadComponentDoc(readme, {zh, lang, dense}));
|
|
313
|
+
result[cat].push(coreEntry(await loadComponentDoc(readme, {zh, lang, dense})));
|
|
207
314
|
} catch {
|
|
208
|
-
result[cat].push({name: `XDS${comp}`, description: ''});
|
|
315
|
+
result[cat].push({name: `XDS${comp}`, package: CORE_PACKAGE, description: ''});
|
|
209
316
|
}
|
|
210
317
|
} else {
|
|
211
|
-
result[cat].push({name: `XDS${comp}`, description: ''});
|
|
318
|
+
result[cat].push({name: `XDS${comp}`, package: CORE_PACKAGE, description: ''});
|
|
212
319
|
}
|
|
213
320
|
}
|
|
214
321
|
}
|
|
@@ -220,11 +327,21 @@ export async function componentList(
|
|
|
220
327
|
/** @type {Record<string, ComponentListEntry[]>} */
|
|
221
328
|
const listData = {};
|
|
222
329
|
for (const [cat, comps] of Object.entries(components)) {
|
|
223
|
-
listData[cat] =
|
|
330
|
+
listData[cat] = await Promise.all(
|
|
331
|
+
comps.map(n => {
|
|
332
|
+
const replacement = replacements.forTarget(n);
|
|
333
|
+
return replacement
|
|
334
|
+
? replacementEntry(replacement, 'names', docOpts)
|
|
335
|
+
: {name: n, package: CORE_PACKAGE};
|
|
336
|
+
}),
|
|
337
|
+
);
|
|
224
338
|
}
|
|
339
|
+
// A replacement is listed once, in the Core slot it took.
|
|
340
|
+
const listedReplacements = new Set(
|
|
341
|
+
replacements.active.map(active => `${active.package}\0${active.name}`),
|
|
342
|
+
);
|
|
225
343
|
|
|
226
344
|
// Integration components (authoritative source: loadedIntegrations).
|
|
227
|
-
const loadedIntegrations = await loadIntegrationsSafely(cwd);
|
|
228
345
|
const seenIntegration = new Set();
|
|
229
346
|
for (const integration of loadedIntegrations) {
|
|
230
347
|
seenIntegration.add(integration.name);
|
|
@@ -236,6 +353,7 @@ export async function componentList(
|
|
|
236
353
|
/** @type {Map<string, Array<{name: string, package: string, import?: string}>>} */
|
|
237
354
|
const byGroup = new Map();
|
|
238
355
|
for (const rec of owned) {
|
|
356
|
+
if (listedReplacements.has(`${integration.name}\0${rec.name}`)) continue;
|
|
239
357
|
const groupLabel = rec.group ?? integration.name;
|
|
240
358
|
const key = `${groupLabel} (${integration.name})`;
|
|
241
359
|
if (!byGroup.has(key)) byGroup.set(key, []);
|
package/api/docs/_adapter.d.mts
CHANGED
|
@@ -20,6 +20,17 @@ export function loadDocsCatalog(cwd?: string): Promise<DocsCatalog>;
|
|
|
20
20
|
* @returns {DocsCatalog}
|
|
21
21
|
*/
|
|
22
22
|
export function builtinCatalog(): DocsCatalog;
|
|
23
|
+
/**
|
|
24
|
+
* The npm package that wrote each section of a lowered topic: the topic's own
|
|
25
|
+
* package, or the package of the extension that contributed the section
|
|
26
|
+
* (spec cli-surface INV28).
|
|
27
|
+
* @param {DocsTopicEntry} entry
|
|
28
|
+
* @param {{sectionProviders?: Record<string, string>}} node the lowered topic
|
|
29
|
+
* @returns {(sectionId: string | undefined) => string}
|
|
30
|
+
*/
|
|
31
|
+
export function sectionPackageOf(entry: DocsTopicEntry, node: {
|
|
32
|
+
sectionProviders?: Record<string, string>;
|
|
33
|
+
}): (sectionId: string | undefined) => string;
|
|
23
34
|
/**
|
|
24
35
|
* One topic, lowered for `lang` with every link between docs resolved
|
|
25
36
|
* (spec:AST-047 FR9): an inline `{@link <target>}` reads as the command that
|
package/api/docs/_adapter.mjs
CHANGED
|
@@ -150,6 +150,31 @@ function providerOf(entry) {
|
|
|
150
150
|
return normalizeProviderId(entry.providerId ?? entry.package);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
/**
|
|
154
|
+
* The npm package that wrote each section of a lowered topic: the topic's own
|
|
155
|
+
* package, or the package of the extension that contributed the section
|
|
156
|
+
* (spec cli-surface INV28).
|
|
157
|
+
* @param {DocsTopicEntry} entry
|
|
158
|
+
* @param {{sectionProviders?: Record<string, string>}} node the lowered topic
|
|
159
|
+
* @returns {(sectionId: string | undefined) => string}
|
|
160
|
+
*/
|
|
161
|
+
export function sectionPackageOf(entry, node) {
|
|
162
|
+
/** @type {Map<string, string>} */
|
|
163
|
+
const byProvider = new Map([[providerOf(entry), entry.package]]);
|
|
164
|
+
for (const extension of entry.extensions ?? []) {
|
|
165
|
+
byProvider.set(providerOf(extension), extension.package);
|
|
166
|
+
}
|
|
167
|
+
return sectionId => {
|
|
168
|
+
const provider =
|
|
169
|
+
sectionId == null ? undefined : node.sectionProviders?.[sectionId];
|
|
170
|
+
return (
|
|
171
|
+
(provider == null
|
|
172
|
+
? undefined
|
|
173
|
+
: byProvider.get(normalizeProviderId(provider))) ?? entry.package
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
153
178
|
/**
|
|
154
179
|
* One topic, lowered for `lang` with every link between docs resolved
|
|
155
180
|
* (spec:AST-047 FR9): an inline `{@link <target>}` reads as the command that
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @input A topic name plus optional {lang, zh, dense, cwd}. Resolves the topic
|
|
7
7
|
* via the shared adapter and compiles it with its token references linked.
|
|
8
|
-
* @output { type: 'docs.detail', data: ReferenceDoc } — the full doc with
|
|
8
|
+
* @output { type: 'docs.detail', package, data: ReferenceDoc } — the full doc with
|
|
9
9
|
* token-refs inlined, matching `astryx --json docs <topic>`.
|
|
10
10
|
* @position Leaf under api/docs. Reads the compiled node through the detail
|
|
11
11
|
* lens; resolution, overlays and extensions happen in the compiler.
|
|
@@ -13,7 +13,12 @@
|
|
|
13
13
|
|
|
14
14
|
import {linkReferenceTopic} from '../../../foundation/doc-compiler/compile.mjs';
|
|
15
15
|
import {detailView} from '../../../foundation/doc-compiler/lenses.mjs';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
referenceTargets,
|
|
18
|
+
resolveTopicDocs,
|
|
19
|
+
sectionPackageOf,
|
|
20
|
+
topicLinks,
|
|
21
|
+
} from '../_adapter.mjs';
|
|
17
22
|
|
|
18
23
|
/**
|
|
19
24
|
* @param {string} topic
|
|
@@ -30,10 +35,21 @@ export async function detail(topic, options = {}) {
|
|
|
30
35
|
node,
|
|
31
36
|
referenceTargets(catalog, lang),
|
|
32
37
|
);
|
|
38
|
+
const view = detailView(linked);
|
|
39
|
+
const sectionPackage = sectionPackageOf(entry, node);
|
|
33
40
|
return {
|
|
34
41
|
type: 'docs.detail',
|
|
42
|
+
package: entry.package,
|
|
35
43
|
data: {
|
|
36
|
-
...
|
|
44
|
+
...view,
|
|
45
|
+
// Each section names the package that wrote it: the topic's own, or an
|
|
46
|
+
// extension's.
|
|
47
|
+
sections: view.sections.map(
|
|
48
|
+
(/** @type {import('../docs.type.mjs').DocsReadSection} */ section) => {
|
|
49
|
+
const {id, title, ...rest} = section;
|
|
50
|
+
return {id, title, package: sectionPackage(id), ...rest};
|
|
51
|
+
},
|
|
52
|
+
),
|
|
37
53
|
// A guide the docs tree places is read by its route, not its doc name.
|
|
38
54
|
...(entry.tree ? {name: entry.name} : {}),
|
|
39
55
|
links: await topicLinks(catalog, entry),
|
|
@@ -26,7 +26,11 @@ import {
|
|
|
26
26
|
readerSections,
|
|
27
27
|
sectionView,
|
|
28
28
|
} from '../../../../foundation/doc-compiler/lenses.mjs';
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
referenceTargets,
|
|
31
|
+
resolveTopicDocs,
|
|
32
|
+
sectionPackageOf,
|
|
33
|
+
} from '../../_adapter.mjs';
|
|
30
34
|
|
|
31
35
|
/**
|
|
32
36
|
* @param {string} topic
|
|
@@ -84,6 +88,8 @@ export async function section(topic, sectionName, options = {}) {
|
|
|
84
88
|
}
|
|
85
89
|
return {
|
|
86
90
|
type: 'docs.detail.section',
|
|
91
|
+
// The package that wrote this section: the topic's own, or an extension's.
|
|
92
|
+
package: sectionPackageOf(entry, node)(match.id),
|
|
87
93
|
data: {...sectionView(node, linked), links},
|
|
88
94
|
};
|
|
89
95
|
}
|
|
@@ -136,17 +136,21 @@ describe('the reported defect: docs tokens --dense (#2182)', () => {
|
|
|
136
136
|
expect(dense.data.sections.length).toBe(full.data.sections.length);
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
-
it('does not lose
|
|
139
|
+
it('does not lose a section from docs theme --dense', async () => {
|
|
140
|
+
const full = await docs('theme');
|
|
140
141
|
const dense = await docs('theme', null, {dense: true});
|
|
141
142
|
const titles = dense.data.sections.map(s => s.title);
|
|
142
|
-
|
|
143
|
+
// The dense overlay keeps every base section.
|
|
144
|
+
expect(titles.length).toBe(full.data.sections.length);
|
|
143
145
|
});
|
|
144
146
|
|
|
145
|
-
it('does not emit a duplicate
|
|
147
|
+
it('does not emit a duplicate heading in docs theme --dense', async () => {
|
|
146
148
|
const dense = await docs('theme', null, {dense: true});
|
|
147
149
|
const titles = dense.data.sections.map(s => s.title.toLowerCase());
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
+
const counts = new Map();
|
|
151
|
+
for (const t of titles) counts.set(t, (counts.get(t) ?? 0) + 1);
|
|
152
|
+
const dupes = [...counts.entries()].filter(([, c]) => c > 1);
|
|
153
|
+
expect(dupes).toEqual([]);
|
|
150
154
|
});
|
|
151
155
|
|
|
152
156
|
it('does not leak English headings into docs theme --zh', async () => {
|
|
@@ -154,6 +158,6 @@ describe('the reported defect: docs tokens --dense (#2182)', () => {
|
|
|
154
158
|
const titles = zh.data.sections.map(s => s.title);
|
|
155
159
|
// Every section the overlay translates must appear once, in Chinese only.
|
|
156
160
|
expect(titles).not.toContain('Dark mode');
|
|
157
|
-
expect(titles).toContain('
|
|
161
|
+
expect(titles).toContain('深色模式');
|
|
158
162
|
});
|
|
159
163
|
});
|
package/api/docs/docs.d.mts
CHANGED
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
* @param {boolean} [options.dense]
|
|
11
11
|
* @param {boolean} [options.index] return the topic's section index instead of
|
|
12
12
|
* the whole doc
|
|
13
|
+
* @param {number | 'all'} [options.depth] how many levels below a docs-tree
|
|
14
|
+
* namespace to read; a doc with nothing below it reads the same at any depth
|
|
15
|
+
* @param {'brief' | 'compact' | 'full'} [options.detail] how much of each doc
|
|
16
|
+
* below the named one a depth read returns (brief by default)
|
|
13
17
|
* @param {string} [options.cwd]
|
|
14
18
|
* @returns {Promise<
|
|
15
19
|
* import('./docs.type.mjs').DocsListResponse |
|
|
@@ -24,6 +28,8 @@ export function docs(topic?: string, section?: string, options?: {
|
|
|
24
28
|
zh?: boolean | undefined;
|
|
25
29
|
dense?: boolean | undefined;
|
|
26
30
|
index?: boolean | undefined;
|
|
31
|
+
depth?: number | "all" | undefined;
|
|
32
|
+
detail?: "compact" | "full" | "brief" | undefined;
|
|
27
33
|
cwd?: string | undefined;
|
|
28
34
|
}): Promise<import("./docs.type.mjs").DocsListResponse | import("./docs.type.mjs").DocsIndexResponse | import("./docs.type.mjs").DocsDetailResponse | import("./docs.type.mjs").DocsDetailSectionResponse | import("./docs.type.mjs").DocsNodeResponse>;
|
|
29
35
|
import { list } from './list/list.mjs';
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {describe, expect, it} from 'vitest';
|
|
4
|
+
import {docs} from './docs.mjs';
|
|
5
|
+
|
|
6
|
+
const SLOW = 60_000;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {any} node
|
|
10
|
+
* @param {string} route
|
|
11
|
+
* @returns {any}
|
|
12
|
+
*/
|
|
13
|
+
function findRoute(node, route) {
|
|
14
|
+
if (node.route === route) return node;
|
|
15
|
+
for (const slot of node.slots ?? []) {
|
|
16
|
+
for (const child of slot.children) {
|
|
17
|
+
const found = findRoute(child, route);
|
|
18
|
+
if (found) return found;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {any} node
|
|
26
|
+
* @returns {any[]}
|
|
27
|
+
*/
|
|
28
|
+
function children(node) {
|
|
29
|
+
return (node.slots ?? []).flatMap((/** @type {any} */ slot) => slot.children);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('docs() depth', () => {
|
|
33
|
+
it(
|
|
34
|
+
'reads one level down, as it always has, without a depth',
|
|
35
|
+
async () => {
|
|
36
|
+
const plain = await docs('cli/api');
|
|
37
|
+
expect(plain.type).toBe('docs.node');
|
|
38
|
+
if (plain.type !== 'docs.node') return;
|
|
39
|
+
expect(plain.data).not.toHaveProperty('childCount');
|
|
40
|
+
for (const child of children(plain.data)) {
|
|
41
|
+
expect(Object.keys(child).sort()).toEqual([
|
|
42
|
+
'kind',
|
|
43
|
+
'name',
|
|
44
|
+
'package',
|
|
45
|
+
'route',
|
|
46
|
+
'summary',
|
|
47
|
+
'title',
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
SLOW,
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
it(
|
|
55
|
+
'goes as many levels down as asked, each doc below as its identity',
|
|
56
|
+
async () => {
|
|
57
|
+
const result = await docs('cli/api', undefined, {depth: 2});
|
|
58
|
+
if (result.type !== 'docs.node') throw new Error(result.type);
|
|
59
|
+
const functions = findRoute(result.data, 'cli/api/functions');
|
|
60
|
+
expect(functions).not.toHaveProperty('childCount');
|
|
61
|
+
expect(findRoute(result.data, 'cli/api/functions/search')).toEqual({
|
|
62
|
+
route: 'cli/api/functions/search',
|
|
63
|
+
name: 'search',
|
|
64
|
+
package: '@astryxdesign/cli',
|
|
65
|
+
kind: 'function',
|
|
66
|
+
title: 'search()',
|
|
67
|
+
summary: expect.any(String),
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
SLOW,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
it(
|
|
74
|
+
'says how many docs sit below where the read stops',
|
|
75
|
+
async () => {
|
|
76
|
+
const one = await docs('cli/api', undefined, {depth: 1});
|
|
77
|
+
if (one.type !== 'docs.node') throw new Error(one.type);
|
|
78
|
+
const functions = findRoute(one.data, 'cli/api/functions');
|
|
79
|
+
expect(functions).not.toHaveProperty('slots');
|
|
80
|
+
expect(functions.childCount).toBeGreaterThan(1);
|
|
81
|
+
|
|
82
|
+
const zero = await docs('cli/api', undefined, {depth: 0});
|
|
83
|
+
if (zero.type !== 'docs.node') throw new Error(zero.type);
|
|
84
|
+
expect(zero.data.slots).toEqual([]);
|
|
85
|
+
expect(zero.data.childCount).toBe(children(one.data).length);
|
|
86
|
+
},
|
|
87
|
+
SLOW,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
it(
|
|
91
|
+
"reads every level with 'all', and each doc's text at full detail",
|
|
92
|
+
async () => {
|
|
93
|
+
const result = await docs('cli/api', undefined, {
|
|
94
|
+
depth: 'all',
|
|
95
|
+
detail: 'full',
|
|
96
|
+
});
|
|
97
|
+
if (result.type !== 'docs.node') throw new Error(result.type);
|
|
98
|
+
expect(JSON.stringify(result.data)).not.toContain('"childCount"');
|
|
99
|
+
const search = findRoute(result.data, 'cli/api/functions/search');
|
|
100
|
+
expect(JSON.stringify(search.content)).toContain(
|
|
101
|
+
'`astryx search` runs it. Read it with `astryx docs cli/commands/search`.',
|
|
102
|
+
);
|
|
103
|
+
},
|
|
104
|
+
SLOW,
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
it(
|
|
108
|
+
'reads a doc with nothing below it the same at any depth',
|
|
109
|
+
async () => {
|
|
110
|
+
expect(
|
|
111
|
+
await docs('cli/api/functions/search', undefined, {depth: 3}),
|
|
112
|
+
).toEqual(await docs('cli/api/functions/search'));
|
|
113
|
+
},
|
|
114
|
+
SLOW,
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
it(
|
|
118
|
+
'refuses a depth that is not a number of levels, and an unknown detail',
|
|
119
|
+
async () => {
|
|
120
|
+
for (const depth of [-1, 1.5, 'deep', '2']) {
|
|
121
|
+
await expect(
|
|
122
|
+
docs('cli/api', undefined, {depth: /** @type {any} */ (depth)}),
|
|
123
|
+
).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
|
|
124
|
+
}
|
|
125
|
+
await expect(
|
|
126
|
+
docs('cli/api', undefined, {
|
|
127
|
+
depth: 1,
|
|
128
|
+
detail: /** @type {any} */ ('huge'),
|
|
129
|
+
}),
|
|
130
|
+
).rejects.toMatchObject({code: 'ERR_INVALID_DETAIL'});
|
|
131
|
+
},
|
|
132
|
+
SLOW,
|
|
133
|
+
);
|
|
134
|
+
});
|
package/api/docs/docs.doc.mjs
CHANGED
|
@@ -25,7 +25,8 @@ export const doc = {
|
|
|
25
25
|
'ones the project\'s configured integrations contribute, including any ' +
|
|
26
26
|
'topic an integration replaces or extends, so it depends on the cwd. ' +
|
|
27
27
|
'A route opens a node of the docs tree instead: a namespace such as ' +
|
|
28
|
-
|
|
28
|
+
'`cli/api` returns its children one level down (`depth` reads as many ' +
|
|
29
|
+
'levels as asked, and `detail` how much of each doc below), a typed doc such as ' +
|
|
29
30
|
"`cli/api/functions/search` returns its content, and a guide the tree " +
|
|
30
31
|
'places (`cli/integrations/quick-start`) reads like any topic. ' +
|
|
31
32
|
'Every read but the list carries `links`, the commands that move from it: ' +
|
|
@@ -82,6 +83,18 @@ export const doc = {
|
|
|
82
83
|
description:
|
|
83
84
|
"Return the topic's section index (each section's key, title, and summary), even for a topic with one section.",
|
|
84
85
|
},
|
|
86
|
+
{
|
|
87
|
+
name: 'options.depth',
|
|
88
|
+
type: "number | 'all'",
|
|
89
|
+
description:
|
|
90
|
+
"How many levels below a docs-tree namespace to read: 0 for the namespace alone, 1 for its children (the default), 'all' for every level. Where a read stops, a child with docs below it carries childCount. A doc with nothing below it reads the same at any depth.",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'options.detail',
|
|
94
|
+
type: "'brief' | 'compact' | 'full'",
|
|
95
|
+
description:
|
|
96
|
+
"How much of each doc below the named one a depth read returns: brief (the default) is its identity; compact and full add its text (a guide's sections, a namespace's or typed doc's content). Given alone, it reads one level down.",
|
|
97
|
+
},
|
|
85
98
|
{
|
|
86
99
|
name: 'options.cwd',
|
|
87
100
|
type: 'string',
|
|
@@ -113,10 +126,18 @@ export const doc = {
|
|
|
113
126
|
{
|
|
114
127
|
type: 'docs.node',
|
|
115
128
|
description:
|
|
116
|
-
"A namespace or typed doc in the docs tree, read by its route: {id, route, kind, package, title, summary, breadcrumb, slots, content}. A namespace lists each slot's children one level down; a typed doc carries its content.",
|
|
129
|
+
"A namespace or typed doc in the docs tree, read by its route: {id, route, kind, package, title, summary, breadcrumb, slots, content}. A namespace lists each slot's children one level down, or as deep as depth asks, each child carrying its own slots, childCount where the read stops, and its text at compact or full detail; a typed doc carries its content.",
|
|
117
130
|
},
|
|
118
131
|
],
|
|
119
132
|
throws: [
|
|
133
|
+
{
|
|
134
|
+
code: 'ERR_INVALID_ARGUMENT',
|
|
135
|
+
when: "depth is not a whole number of levels or 'all'",
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
code: 'ERR_INVALID_DETAIL',
|
|
139
|
+
when: 'detail is not brief, compact, or full',
|
|
140
|
+
},
|
|
120
141
|
{
|
|
121
142
|
code: 'ERR_UNKNOWN_TOPIC',
|
|
122
143
|
when: 'the topic is not a string, or matches no topic and no docs-tree route',
|
|
@@ -134,6 +155,14 @@ export const doc = {
|
|
|
134
155
|
code: "await docs('principles', undefined, {index: true});",
|
|
135
156
|
},
|
|
136
157
|
{label: 'A docs-tree namespace', code: "await docs('cli/api');"},
|
|
158
|
+
{
|
|
159
|
+
label: 'Every doc below a namespace, one entry each',
|
|
160
|
+
code: "await docs('cli', undefined, {depth: 'all'});",
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
label: 'A namespace and everything below it, in full',
|
|
164
|
+
code: "await docs('cli/integrations', undefined, {depth: 'all', detail: 'full'});",
|
|
165
|
+
},
|
|
137
166
|
{label: 'One API function', code: "await docs('cli/api/functions/search');"},
|
|
138
167
|
{
|
|
139
168
|
label: 'A whole guide from the docs tree',
|