@astryxdesign/cli 0.1.8-canary.0c4d8d7 → 0.1.8-canary.0db5dfd
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/{src/api → api/blog}/blog.mjs +42 -6
- package/{src/api → api/blog}/blog.test.mjs +2 -2
- package/api/build/build.mjs +92 -0
- package/api/build/build.test.mjs +92 -0
- package/{src/api → api/component}/component.mjs +49 -26
- package/{src/api → api/discover}/discover.mjs +55 -18
- package/{src/api → api/docs}/docs.mjs +47 -21
- package/{src/api → api/doctor}/doctor.mjs +11 -8
- package/{src/api → api/hook}/hook.mjs +11 -11
- package/{src/api → api}/index.mjs +16 -9
- package/{src/api → api/integration}/validate-integration.mjs +48 -15
- package/{src/api → api/integration}/validate-integration.test.mjs +1 -1
- package/{src/api → api/layout}/layout.mjs +66 -17
- package/{src/api → api/layout}/layout.test.mjs +1 -1
- package/{src/api → api/search}/search.mjs +71 -12
- package/api/swizzle/swizzle.mjs +283 -0
- package/{src/commands → api/swizzle}/swizzle.test.mjs +26 -1
- package/{src/api → api/template}/template-integration.test.mjs +2 -2
- package/{src/api → api/template}/template-suffix.test.mjs +3 -3
- package/{src/api → api/template}/template.mjs +96 -19
- package/{src/api → api/theme}/theme-add.mjs +35 -7
- package/{src → authoring}/codemod.mjs +6 -6
- package/{src → authoring}/config.test.mjs +1 -1
- package/{src → authoring}/doc.mjs +1 -1
- package/{src → authoring}/doc.test.mjs +1 -1
- package/{src → authoring}/template.mjs +1 -1
- package/bin/astryx.mjs +12 -10
- package/{src → cli}/commands/blog.mjs +48 -7
- package/{src → cli}/commands/build-theme.mjs +125 -46
- package/{src → cli}/commands/build.mjs +33 -57
- package/{src → cli}/commands/component/index.mjs +49 -22
- package/{src → cli}/commands/component-ownership.test.mjs +3 -3
- package/{src → cli}/commands/component-package.test.mjs +1 -1
- package/{src → cli}/commands/component-resolution.test.mjs +2 -2
- package/{src → cli}/commands/discover.mjs +17 -8
- package/{src → cli}/commands/docs.mjs +39 -7
- package/{src → cli}/commands/docs.test.mjs +1 -1
- package/{src → cli}/commands/doctor.mjs +3 -3
- package/{src → cli}/commands/doctor.test.mjs +2 -2
- package/{src → cli}/commands/ensure-core-built.mjs +3 -2
- package/{src → cli}/commands/external-showcase.test.mjs +1 -1
- package/{src → cli}/commands/hook/index.mjs +37 -14
- package/{src → cli}/commands/import-hint-correctness.test.mjs +1 -1
- package/{src → cli}/commands/init.mjs +20 -9
- package/{src → cli}/commands/layout.mjs +58 -18
- package/{src → cli}/commands/search.mjs +19 -12
- package/{src → cli}/commands/search.test.mjs +1 -1
- package/{src → cli}/commands/setup-nudge.test.mjs +1 -1
- package/cli/commands/swizzle.mjs +103 -0
- package/{src → cli}/commands/template.mjs +73 -22
- package/{src → cli}/commands/template.path-safety.test.mjs +2 -2
- package/{src → cli}/commands/upgrade.integration-policy.test.mjs +1 -1
- package/{src → cli}/commands/upgrade.mjs +160 -52
- package/{src → cli}/commands/upgrade.test.mjs +1 -1
- package/{src → cli}/commands/validate-integration.mjs +17 -37
- package/{src → cli}/index.mjs +17 -15
- package/{src/codemods → codemods}/ensure-jscodeshift.mjs +1 -1
- package/{src/codemods → codemods}/integration-discovery.mjs +6 -3
- package/{src/codemods → codemods}/integration-discovery.test.mjs +1 -1
- package/{src/codemods → codemods}/integration-runner.mjs +8 -3
- package/{src/codemods → codemods}/registry.mjs +3 -1
- package/{src/codemods → codemods}/run-codemod.mjs +17 -10
- package/{src/codemods → codemods}/runner.mjs +22 -12
- package/{src/codemods → codemods}/transforms/v0.0.10/remove-size-props.mjs +9 -4
- package/{src/codemods → codemods}/transforms/v0.0.12/add-is-icon-only.mjs +27 -22
- package/{src/codemods → codemods}/transforms/v0.0.13/icon-name-deprecations.mjs +12 -5
- package/{src/codemods → codemods}/transforms/v0.0.13/rename-attachments-to-drawer.mjs +15 -8
- package/{src/codemods → codemods}/transforms/v0.0.13/toolbar-density-to-size.mjs +10 -4
- package/{src/codemods → codemods}/transforms/v0.0.14/rename-action-props.mjs +11 -5
- package/{src/codemods → codemods}/transforms/v0.0.14/rename-section-wash-to-muted.mjs +11 -6
- package/{src/codemods → codemods}/transforms/v0.0.14/rename-status-variants.mjs +15 -10
- package/{src/codemods → codemods}/transforms/v0.0.15/migrate-item-children-to-endcontent.mjs +13 -8
- package/{src/codemods → codemods}/transforms/v0.0.15/migrate-selector-children-to-render-option.mjs +18 -13
- package/{src/codemods → codemods}/transforms/v0.0.15/migrate-theme-selectors-to-data-attrs.mjs +8 -4
- package/{src/codemods → codemods}/transforms/v0.0.15/rename-date-picker-to-input.mjs +11 -6
- package/{src/codemods → codemods}/transforms/v0.0.15/rename-imperative-ref-to-handleRef.mjs +6 -1
- package/{src/codemods → codemods}/transforms/v0.0.15/rename-isStreaming-to-isStopShown.mjs +6 -1
- package/{src/codemods → codemods}/transforms/v0.0.15/rename-stack-element-to-as.mjs +8 -3
- package/{src/codemods → codemods}/transforms/v0.0.2/migrate-badge-dot-to-statusdot.mjs +17 -10
- package/{src/codemods → codemods}/transforms/v0.0.2/migrate-gap-to-numeric.mjs +7 -1
- package/{src/codemods → codemods}/transforms/v0.0.2/migrate-isFullBleed-to-padding.mjs +9 -4
- package/{src/codemods → codemods}/transforms/v0.0.2/migrate-useXDSIcon-to-getIcon.mjs +12 -7
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-banner-endButton-to-endContent.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-form-tooltip-startIcon.mjs +8 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-isShown-to-isOpen.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-selector-items-to-options.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-sidenav-header-to-heading.mjs +11 -4
- package/{src/codemods → codemods}/transforms/v0.0.2/rename-topnav-title-to-heading.mjs +10 -4
- package/{src/codemods → codemods}/transforms/v0.0.2/unify-uncontrolled-to-defaultX.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.2/unify-visibility-to-onOpenChange.mjs +10 -5
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-badge-children-to-label.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-collapse-to-collapsible.mjs +9 -3
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-radius-tokens.mjs +11 -5
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-shadow-tokens.mjs +13 -6
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-skeleton-radius.mjs +7 -1
- package/{src/codemods → codemods}/transforms/v0.0.6/migrate-token-names.mjs +11 -5
- package/{src/codemods → codemods}/transforms/v0.0.7/rename-banner-variant-to-container.mjs +8 -3
- package/{src/codemods → codemods}/transforms/v0.0.8/migrate-token-renames.mjs +15 -8
- package/{src/codemods → codemods}/transforms/v0.0.8/rename-endslot-to-endcontent.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.1.0/drop-xds-prefix-imports.mjs +19 -14
- package/{src/codemods → codemods}/transforms/v0.1.0/migrate-xds-css-surfaces.mjs +21 -17
- package/{src/codemods → codemods}/transforms/v0.1.0/migrate-xds-declare-module.mjs +7 -2
- package/{src/codemods → codemods}/transforms/v0.1.0/migrate-xds-module-specifiers.mjs +16 -11
- package/{src/codemods → codemods}/transforms/v0.1.2/rename-text-color-active-to-accent.mjs +15 -9
- package/{src/codemods → codemods}/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs +17 -12
- package/{src/codemods → codemods}/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +15 -9
- package/{src/codemods → codemods}/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +17 -10
- package/{src/codemods → codemods}/transforms/v0.1.7/rename-table-renderprops-styles-to-xstyle.mjs +18 -13
- package/{src/codemods → codemods}/transforms/v0.1.8/rename-avatar-size-scale.mjs +15 -10
- package/docs/internationalization.doc.mjs +92 -46
- package/{src/commands → lib/agent-docs}/agent-docs.mjs +30 -11
- package/{src/commands → lib/agent-docs}/agent-docs.path-safety.test.mjs +1 -1
- package/{src/lib → lib}/component-discovery.mjs +44 -2
- package/{src/lib → lib}/component-format.mjs +65 -24
- package/{src/lib → lib}/component-loader.mjs +27 -13
- package/{src/lib → lib}/componentDocOverlay.test.mjs +0 -1
- package/{src/lib → lib}/error-codes.test.mjs +1 -1
- package/{src/lib → lib}/hook-discovery.mjs +14 -1
- package/{src/lib → lib}/hook-format.mjs +29 -5
- package/{src/lib → lib}/integration-warnings.mjs +2 -2
- package/{src/lib → lib}/integrations.mjs +20 -0
- package/{src/lib → lib}/integrations.test.mjs +1 -1
- package/{src/lib → lib}/json-contract.test.mjs +1 -1
- package/{src/lib → lib}/json-shim.mjs +10 -5
- package/{src/lib → lib}/json-shim.test.mjs +1 -1
- package/{src/lib → lib}/levenshtein.mjs +6 -0
- package/{src/lib → lib}/manifest.mjs +7 -5
- package/{src/lib → lib}/manifest.test.mjs +2 -2
- package/{src/lib → lib}/module-loader.mjs +1 -0
- package/{src/lib → lib}/package-scanner.mjs +47 -0
- package/{src/lib → lib}/project.mjs +48 -18
- package/{src/lib → lib}/project.test.mjs +1 -1
- package/{src/lib → lib}/resolve-theme.mjs +5 -0
- package/{src/lib → lib}/string-utils.mjs +15 -0
- package/{src/lib → lib}/term-log.mjs +12 -3
- package/{src/lib → lib}/xle/browser.mjs +18 -8
- package/{src/lib → lib}/xle/expand.mjs +155 -22
- package/{src/lib → lib}/xle/parse.mjs +119 -13
- package/{src/lib → lib}/xle/print.mjs +54 -14
- package/{src/lib → lib}/xle/registry-core.mjs +28 -3
- package/{src/lib → lib}/xle/registry.mjs +9 -4
- package/{src/lib → lib}/xle/splice.mjs +13 -2
- package/{src/lib → lib}/xle/validate.mjs +95 -14
- package/lib/xle/xle-ast.d.ts +214 -0
- package/package.json +33 -26
- package/scripts/postinstall.mjs +4 -4
- package/templates/blocks/components/Avatar/AvatarShowcase.tsx +1 -1
- package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.doc.mjs +19 -0
- package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +46 -0
- package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.doc.mjs +14 -0
- package/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.tsx +33 -0
- package/{src/types → types}/api.contract.assert.ts +17 -8
- package/{src/types → types}/api.d.ts +106 -0
- package/{src/types → types}/base.d.ts +17 -2
- package/types/build.d.ts +53 -0
- package/types/codemod.d.ts +166 -0
- package/{src/types → types}/component.d.ts +1 -1
- package/{src/types → types}/discover.d.ts +1 -1
- package/{src/types → types}/docs.d.ts +1 -4
- package/{src/types → types}/hook.d.ts +1 -1
- package/types/jscodeshift.d.ts +19 -0
- package/types/layout.d.ts +74 -0
- package/types/theme.d.ts +53 -0
- package/{src/types → types}/upgrade.d.ts +8 -1
- package/{src/utils → utils}/paths.mjs +4 -1
- package/src/commands/swizzle.mjs +0 -417
- package/src/types/build.d.ts +0 -23
- package/src/types/codemod.d.ts +0 -81
- package/src/types/theme.d.ts +0 -23
- /package/{src/api → api/docs}/docOverlays.test.mjs +0 -0
- /package/{src/api → api}/error.mjs +0 -0
- /package/{src/api → api/integration}/integration-block-exports.test.mjs +0 -0
- /package/{src/api → api/template}/template.test.mjs +0 -0
- /package/{src → authoring}/codemod.test.mjs +0 -0
- /package/{src → authoring}/config.mjs +0 -0
- /package/{src → authoring}/integration.mjs +0 -0
- /package/{src → authoring}/template.test.mjs +0 -0
- /package/{src → cli}/cli-exit-codes.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.color-scheme.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.import-path.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.path-safety.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.prose.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.variants.test.mjs +0 -0
- /package/{src → cli}/commands/build-theme.watch.test.mjs +0 -0
- /package/{src → cli}/commands/cli-postinstall.test.mjs +0 -0
- /package/{src → cli}/commands/component.test.mjs +0 -0
- /package/{src → cli}/commands/detail-levels.test.mjs +0 -0
- /package/{src → cli}/commands/init.next-steps.test.mjs +0 -0
- /package/{src → cli}/commands/interactive-guard.test.mjs +0 -0
- /package/{src → cli}/commands/json-contract.test.mjs +0 -0
- /package/{src → cli}/commands/swizzle.path-safety.test.mjs +0 -0
- /package/{src → cli}/commands/swizzle.routing.test.mjs +0 -0
- /package/{src → cli}/commands/template.test.mjs +0 -0
- /package/{src → cli}/commands/upgrade.config-ordering.test.mjs +0 -0
- /package/{src → cli}/commands/validate-integration.test.mjs +0 -0
- /package/{src → cli}/update-hint-commands.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/registry.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/rename-imperative-ref-to-handleRef.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/rename-isStreaming-to-isStopShown.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/rename-section-wash-to-muted.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/runner.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/toolbar-density-to-size.test.mjs +0 -0
- /package/{src/codemods → codemods}/__tests__/validation.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.10/__tests__/remove-size-props.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.10/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.12/__tests__/add-is-icon-only.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.12/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.13/__tests__/icon-name-deprecations.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.13/__tests__/rename-attachments-to-drawer.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.13/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.14/__tests__/rename-action-props.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.14/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/migrate-item-children-to-endcontent.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/migrate-selector-children-to-render-option.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/migrate-theme-selectors-to-data-attrs.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/rename-date-picker-to-input.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/__tests__/rename-stack-element-to-as.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.15/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-badge-dot-to-statusdot.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-gap-to-numeric.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-isFullBleed-to-padding.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/migrate-useXDSIcon-to-getIcon.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-banner-endButton-to-endContent.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-form-tooltip-startIcon.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-isShown-to-isOpen.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-selector-items-to-options.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-sidenav-header-to-heading.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/rename-topnav-title-to-heading.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/unify-uncontrolled-to-defaultX.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/__tests__/unify-visibility-to-onOpenChange.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.2/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-collapse-to-collapsible.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-radius-tokens.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-shadow-tokens.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-skeleton-radius.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/__tests__/migrate-token-names.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.6/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.7/__tests__/rename-banner-variant-to-container.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.7/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.8/__tests__/migrate-token-renames.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.8/__tests__/rename-endslot-to-endcontent.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.0.8/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/drop-xds-prefix-imports.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/migrate-xds-css-surfaces.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/migrate-xds-declare-module.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/migrate-xds-module-specifiers.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/__tests__/v0.1.0-ordering.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.0/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.2/__tests__/rename-text-color-active-to-accent.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.2/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.3/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.5/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.7/__tests__/rename-table-renderprops-styles-to-xstyle.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.7/index.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +0 -0
- /package/{src/codemods → codemods}/transforms/v0.1.8/index.mjs +0 -0
- /package/{src/commands → lib/agent-docs}/agent-docs.test.mjs +0 -0
- /package/{src/lib → lib}/cli-error.mjs +0 -0
- /package/{src/lib → lib}/cli-error.test.mjs +0 -0
- /package/{src/lib → lib}/component-discovery.importpath.test.mjs +0 -0
- /package/{src/lib → lib}/component-format.test.mjs +0 -0
- /package/{src/lib → lib}/component-loader.test.mjs +0 -0
- /package/{src/lib → lib}/config-cache.mjs +0 -0
- /package/{src/lib → lib}/config-cache.test.mjs +0 -0
- /package/{src/lib → lib}/config-schema.mjs +0 -0
- /package/{src/lib → lib}/error-codes.mjs +0 -0
- /package/{src/lib → lib}/integration-warnings.test.mjs +0 -0
- /package/{src/lib → lib}/json.mjs +0 -0
- /package/{src/lib → lib}/module-loader.test.mjs +0 -0
- /package/{src/lib → lib}/node-version.mjs +0 -0
- /package/{src/lib → lib}/node-version.test.mjs +0 -0
- /package/{src/lib → lib}/parse.mjs +0 -0
- /package/{src/lib → lib}/site.mjs +0 -0
- /package/{src/lib → lib}/xle/browser.d.ts +0 -0
- /package/{src/lib → lib}/xle/xle.test.mjs +0 -0
- /package/{src/schemas → schemas}/doc-schema.mjs +0 -0
- /package/{src/schemas → schemas}/template-schema.mjs +0 -0
- /package/{src/types → types}/config.d.ts +0 -0
- /package/{src/types → types}/doc.d.ts +0 -0
- /package/{src/types → types}/doctor.d.ts +0 -0
- /package/{src/types → types}/error-codes.d.ts +0 -0
- /package/{src/types → types}/index.d.ts +0 -0
- /package/{src/types → types}/integration.d.ts +0 -0
- /package/{src/types → types}/manifest.d.ts +0 -0
- /package/{src/types → types}/search.d.ts +0 -0
- /package/{src/types → types}/swizzle.d.ts +0 -0
- /package/{src/types → types}/template-api.d.ts +0 -0
- /package/{src/types → types}/template.d.ts +0 -0
- /package/{src/types → types}/validate-integration.d.ts +0 -0
- /package/{src/utils → utils}/github.mjs +0 -0
- /package/{src/utils → utils}/package-manager.mjs +0 -0
- /package/{src/utils → utils}/package-manager.test.mjs +0 -0
- /package/{src/utils → utils}/path-safety.mjs +0 -0
- /package/{src/utils → utils}/path-safety.test.mjs +0 -0
- /package/{src/utils → utils}/paths.test.mjs +0 -0
- /package/{src/utils → utils}/semver.mjs +0 -0
- /package/{src/utils → utils}/semver.test.mjs +0 -0
- /package/{src/utils → utils}/update-check.mjs +0 -0
- /package/{src/utils → utils}/update-check.test.mjs +0 -0
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* blog's structure can change freely without touching the CLI.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {AstryxError} from '
|
|
14
|
-
import {ERROR_CODES} from '
|
|
15
|
-
import {SITE_URL, SITE_ORIGIN} from '
|
|
13
|
+
import {AstryxError} from '../error.mjs';
|
|
14
|
+
import {ERROR_CODES} from '../../lib/error-codes.mjs';
|
|
15
|
+
import {SITE_URL, SITE_ORIGIN} from '../../lib/site.mjs';
|
|
16
16
|
|
|
17
17
|
/** Abort a feed/post fetch that hangs, and cap how much we'll read. */
|
|
18
18
|
const FETCH_TIMEOUT_MS = 15000;
|
|
@@ -20,6 +20,10 @@ const MAX_BYTES = 5 * 1024 * 1024; // 5 MB — a blog feed is never larger.
|
|
|
20
20
|
|
|
21
21
|
const FEED_URL = new URL('/rss.xml', SITE_URL).toString();
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} url
|
|
25
|
+
* @returns {Promise<string>}
|
|
26
|
+
*/
|
|
23
27
|
async function fetchText(url) {
|
|
24
28
|
const controller = new AbortController();
|
|
25
29
|
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
@@ -31,7 +35,12 @@ async function fetchText(url) {
|
|
|
31
35
|
});
|
|
32
36
|
} catch (e) {
|
|
33
37
|
clearTimeout(timer);
|
|
34
|
-
const reason =
|
|
38
|
+
const reason =
|
|
39
|
+
e instanceof Error
|
|
40
|
+
? e.name === 'AbortError'
|
|
41
|
+
? 'timed out'
|
|
42
|
+
: e.message
|
|
43
|
+
: String(e);
|
|
35
44
|
throw new AstryxError(
|
|
36
45
|
`Could not reach ${url}: ${reason}`,
|
|
37
46
|
[],
|
|
@@ -61,6 +70,7 @@ async function fetchText(url) {
|
|
|
61
70
|
* Defense in depth: a post's plaintext URL comes from feed content. Require it
|
|
62
71
|
* to live on the canonical origin so even a tampered feed can't redirect the
|
|
63
72
|
* CLI to another host.
|
|
73
|
+
* @param {string} target
|
|
64
74
|
*/
|
|
65
75
|
function assertCanonicalOrigin(target) {
|
|
66
76
|
let targetOrigin;
|
|
@@ -82,6 +92,10 @@ function assertCanonicalOrigin(target) {
|
|
|
82
92
|
}
|
|
83
93
|
}
|
|
84
94
|
|
|
95
|
+
/**
|
|
96
|
+
* @param {string} value
|
|
97
|
+
* @returns {string}
|
|
98
|
+
*/
|
|
85
99
|
function unescapeXml(value) {
|
|
86
100
|
return value
|
|
87
101
|
.replace(/</g, '<')
|
|
@@ -91,12 +105,23 @@ function unescapeXml(value) {
|
|
|
91
105
|
.replace(/&/g, '&');
|
|
92
106
|
}
|
|
93
107
|
|
|
108
|
+
/**
|
|
109
|
+
* @param {string} item
|
|
110
|
+
* @param {string} name
|
|
111
|
+
* @returns {string}
|
|
112
|
+
*/
|
|
94
113
|
function tag(item, name) {
|
|
95
114
|
const m = item.match(new RegExp(`<${name}[^>]*>([\\s\\S]*?)</${name}>`));
|
|
96
115
|
return m ? unescapeXml(m[1].trim()) : '';
|
|
97
116
|
}
|
|
98
117
|
|
|
118
|
+
/**
|
|
119
|
+
* @param {string} item
|
|
120
|
+
* @param {string} name
|
|
121
|
+
* @returns {string[]}
|
|
122
|
+
*/
|
|
99
123
|
function tagAll(item, name) {
|
|
124
|
+
/** @type {string[]} */
|
|
100
125
|
const out = [];
|
|
101
126
|
const re = new RegExp(`<${name}[^>]*>([\\s\\S]*?)</${name}>`, 'g');
|
|
102
127
|
let m;
|
|
@@ -104,7 +129,11 @@ function tagAll(item, name) {
|
|
|
104
129
|
return out;
|
|
105
130
|
}
|
|
106
131
|
|
|
107
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* Extract the plaintext alternate href from an <item>.
|
|
134
|
+
* @param {string} item
|
|
135
|
+
* @returns {string | null}
|
|
136
|
+
*/
|
|
108
137
|
function textHref(item) {
|
|
109
138
|
// Match the atom:link alternate regardless of attribute order/quoting; then
|
|
110
139
|
// confirm it's the text/plain alternate before trusting the href.
|
|
@@ -121,7 +150,11 @@ function textHref(item) {
|
|
|
121
150
|
return null;
|
|
122
151
|
}
|
|
123
152
|
|
|
124
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* Derive a slug from a post link (last path segment).
|
|
155
|
+
* @param {string} link
|
|
156
|
+
* @returns {string}
|
|
157
|
+
*/
|
|
125
158
|
function slugFromLink(link) {
|
|
126
159
|
try {
|
|
127
160
|
const path = new URL(link).pathname.replace(/\/$/, '');
|
|
@@ -131,6 +164,9 @@ function slugFromLink(link) {
|
|
|
131
164
|
}
|
|
132
165
|
}
|
|
133
166
|
|
|
167
|
+
/**
|
|
168
|
+
* @param {string} xml
|
|
169
|
+
*/
|
|
134
170
|
function parseFeed(xml) {
|
|
135
171
|
const items = [];
|
|
136
172
|
const re = /<item>([\s\S]*?)<\/item>/g;
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
|
|
11
11
|
import {blog} from './blog.mjs';
|
|
12
|
-
import {AstryxError} from '
|
|
13
|
-
import {SITE_URL} from '
|
|
12
|
+
import {AstryxError} from '../error.mjs';
|
|
13
|
+
import {SITE_URL} from '../../lib/site.mjs';
|
|
14
14
|
|
|
15
15
|
const FEED = `<?xml version="1.0" encoding="UTF-8"?>
|
|
16
16
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file build API — the "assemble a page" assistant, as data.
|
|
5
|
+
*
|
|
6
|
+
* `build()` with no query signals the workflow playbook (`build.help`). With a
|
|
7
|
+
* query it runs the unified search and groups the results into a composition
|
|
8
|
+
* KIT (`build.kit`): the closest page templates, the blocks that cover parts,
|
|
9
|
+
* and the domain components to fill gaps, plus the always-on frame + foundation.
|
|
10
|
+
*
|
|
11
|
+
* The kit carries RAW `SearchResultEntry` objects and static name arrays only —
|
|
12
|
+
* never pre-formatted command strings. All CLI prefixing (formatCliCommand /
|
|
13
|
+
* getCliInvocation) and the section prose live in the command renderer, so the
|
|
14
|
+
* JSON shape stays package-manager-agnostic and stable across environments.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {search} from '../search/search.mjs';
|
|
18
|
+
|
|
19
|
+
/** A page at/above this score is a confident direct match. */
|
|
20
|
+
const PAGE_DIRECT = 95;
|
|
21
|
+
/** Below this a page is too weak to offer even as a layout reference. */
|
|
22
|
+
const PAGE_FLOOR = 50;
|
|
23
|
+
/** Below this a block/domain-component match is incidental noise. */
|
|
24
|
+
const DOMAIN_FLOOR = 55;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Always-surfaced primitives. Every page needs a shell + layout/typography/
|
|
28
|
+
* action atoms, but these never keyword-match an idea ("dashboard" != "Stack"),
|
|
29
|
+
* so search alone never returns them. Kept here (not the renderer) because they
|
|
30
|
+
* are ALSO used to exclude these names from the idea-specific `domain` group.
|
|
31
|
+
*/
|
|
32
|
+
const FRAME = ['AppShell', 'TopNav', 'SideNav', 'Layout'];
|
|
33
|
+
const FOUNDATION = [
|
|
34
|
+
'VStack', 'HStack', 'Grid', 'StackItem', 'Card', 'Section',
|
|
35
|
+
'Text', 'Heading', 'Button', 'Icon', 'Badge', 'Divider',
|
|
36
|
+
];
|
|
37
|
+
const ALWAYS = new Set([...FRAME, ...FOUNDATION]);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The page-building assistant. No query → the playbook signal; a query → the
|
|
41
|
+
* grouped composition kit.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} [query] what you're building (e.g. "analytics dashboard")
|
|
44
|
+
* @param {{cwd?: string, type?: import('../../types/search').SearchDomain, limit?: number}} [options]
|
|
45
|
+
* @returns {Promise<import('../../types/build').BuildHelpResponse | import('../../types/build').BuildKitResponse>}
|
|
46
|
+
*/
|
|
47
|
+
export async function build(query, options = {}) {
|
|
48
|
+
if (!query || !String(query).trim()) {
|
|
49
|
+
return {type: 'build.help', data: {playbook: true}};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const {cwd = process.cwd(), type, limit = 60} = options;
|
|
53
|
+
// search()'s JSDoc @returns widens results to object[]; the SearchResponse
|
|
54
|
+
// shape is the contract (api.d.ts). Cast locally rather than tightening the
|
|
55
|
+
// search @returns (a separate follow-up).
|
|
56
|
+
const result = /** @type {import('../../types/search').SearchResponse} */ (
|
|
57
|
+
await search(query, {cwd, type, limit})
|
|
58
|
+
);
|
|
59
|
+
const results = result.data.results;
|
|
60
|
+
|
|
61
|
+
const pages = results
|
|
62
|
+
.filter(r => r.domain === 'template' && r.kind !== 'block' && r.score >= PAGE_FLOOR)
|
|
63
|
+
.slice(0, 3);
|
|
64
|
+
const blocks = results
|
|
65
|
+
.filter(r => r.domain === 'template' && r.kind === 'block' && r.score >= DOMAIN_FLOOR)
|
|
66
|
+
.slice(0, 5);
|
|
67
|
+
const domain = results
|
|
68
|
+
.filter(
|
|
69
|
+
r =>
|
|
70
|
+
(r.domain === 'component' || r.domain === 'hook') &&
|
|
71
|
+
r.score >= DOMAIN_FLOOR &&
|
|
72
|
+
!ALWAYS.has(r.name),
|
|
73
|
+
)
|
|
74
|
+
.slice(0, 6);
|
|
75
|
+
const directMatch = pages.length > 0 && pages[0].score >= PAGE_DIRECT;
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
type: 'build.kit',
|
|
79
|
+
data: {
|
|
80
|
+
query: result.data.query,
|
|
81
|
+
// Distinguishes "search found nothing" (renderer shows "No matches")
|
|
82
|
+
// from a weak-but-non-empty result set (renderer still shows the kit).
|
|
83
|
+
hasResults: results.length > 0,
|
|
84
|
+
directMatch,
|
|
85
|
+
pages,
|
|
86
|
+
blocks,
|
|
87
|
+
domain,
|
|
88
|
+
frame: FRAME,
|
|
89
|
+
foundation: FOUNDATION,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Tests for the build API (playbook signal + composition kit).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {describe, it, expect, vi} from 'vitest';
|
|
8
|
+
import * as path from 'node:path';
|
|
9
|
+
import {fileURLToPath} from 'node:url';
|
|
10
|
+
import {build} from './build.mjs';
|
|
11
|
+
|
|
12
|
+
// api/build/ -> up 3 = packages/cli, up 4 = repo root (has packages/core).
|
|
13
|
+
const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../..');
|
|
14
|
+
|
|
15
|
+
// build() delegates to search(), whose first (cold) call is slow under vitest.
|
|
16
|
+
vi.setConfig({testTimeout: 30000});
|
|
17
|
+
|
|
18
|
+
describe('build API', () => {
|
|
19
|
+
it('no query → build.help playbook signal', async () => {
|
|
20
|
+
const r = await build();
|
|
21
|
+
expect(r.type).toBe('build.help');
|
|
22
|
+
expect(r.data).toEqual({playbook: true});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('query → build.kit with raw entries + static frame/foundation', async () => {
|
|
26
|
+
const r = await build('dashboard', {cwd: REPO});
|
|
27
|
+
expect(r.type).toBe('build.kit');
|
|
28
|
+
if (r.type !== 'build.kit') return;
|
|
29
|
+
expect(r.data.query).toBe('dashboard');
|
|
30
|
+
expect(r.data.hasResults).toBe(true);
|
|
31
|
+
expect(r.data.frame).toContain('AppShell');
|
|
32
|
+
expect(r.data.foundation).toContain('Button');
|
|
33
|
+
expect(Array.isArray(r.data.pages)).toBe(true);
|
|
34
|
+
|
|
35
|
+
// Entries are RAW SearchResultEntry objects — never package-manager-prefixed
|
|
36
|
+
// command strings (that formatting is the CLI renderer's job).
|
|
37
|
+
for (const e of [...r.data.pages, ...r.data.blocks, ...r.data.domain]) {
|
|
38
|
+
expect(typeof e.name).toBe('string');
|
|
39
|
+
expect(typeof e.score).toBe('number');
|
|
40
|
+
expect(e.command).not.toMatch(/^(pnpm|npm|yarn|bun|npx)\b/);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('excludes always-on frame/foundation names from the domain group', async () => {
|
|
45
|
+
const r = await build('dashboard', {cwd: REPO});
|
|
46
|
+
if (r.type !== 'build.kit') throw new Error('expected build.kit');
|
|
47
|
+
const names = r.data.domain.map(d => d.name);
|
|
48
|
+
expect(names).not.toContain('Button');
|
|
49
|
+
expect(names).not.toContain('AppShell');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('applies grouping caps, score floors, and directMatch threshold', async () => {
|
|
53
|
+
const r = await build('dashboard', {cwd: REPO});
|
|
54
|
+
if (r.type !== 'build.kit') throw new Error('expected build.kit');
|
|
55
|
+
const {pages, blocks, domain, directMatch} = r.data;
|
|
56
|
+
|
|
57
|
+
// Caps: pages ≤ 3, blocks ≤ 5, domain ≤ 6.
|
|
58
|
+
expect(pages.length).toBeLessThanOrEqual(3);
|
|
59
|
+
expect(blocks.length).toBeLessThanOrEqual(5);
|
|
60
|
+
expect(domain.length).toBeLessThanOrEqual(6);
|
|
61
|
+
|
|
62
|
+
// Score floors: pages ≥ PAGE_FLOOR(50); blocks/domain ≥ DOMAIN_FLOOR(55).
|
|
63
|
+
for (const p of pages) expect(p.score).toBeGreaterThanOrEqual(50);
|
|
64
|
+
for (const b of blocks) expect(b.score).toBeGreaterThanOrEqual(55);
|
|
65
|
+
for (const d of domain) expect(d.score).toBeGreaterThanOrEqual(55);
|
|
66
|
+
|
|
67
|
+
// directMatch iff the top page is a confident match (PAGE_DIRECT = 95).
|
|
68
|
+
expect(directMatch).toBe(pages.length > 0 && pages[0].score >= 95);
|
|
69
|
+
|
|
70
|
+
// Domain partitioning: pages = non-block templates, blocks = block templates,
|
|
71
|
+
// domain = components/hooks.
|
|
72
|
+
for (const p of pages) {
|
|
73
|
+
expect(p.domain).toBe('template');
|
|
74
|
+
expect(p.kind).not.toBe('block');
|
|
75
|
+
}
|
|
76
|
+
for (const b of blocks) {
|
|
77
|
+
expect(b.domain).toBe('template');
|
|
78
|
+
expect(b.kind).toBe('block');
|
|
79
|
+
}
|
|
80
|
+
for (const d of domain) expect(['component', 'hook']).toContain(d.domain);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('no matches → build.kit with hasResults=false and empty groups', async () => {
|
|
84
|
+
const r = await build('zzznomatch99', {cwd: REPO});
|
|
85
|
+
expect(r.type).toBe('build.kit');
|
|
86
|
+
if (r.type !== 'build.kit') return;
|
|
87
|
+
expect(r.data.hasResults).toBe(false);
|
|
88
|
+
expect(r.data.pages).toHaveLength(0);
|
|
89
|
+
expect(r.data.blocks).toHaveLength(0);
|
|
90
|
+
expect(r.data.domain).toHaveLength(0);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
import * as fs from 'node:fs';
|
|
11
11
|
import * as path from 'node:path';
|
|
12
|
-
import {ERROR_CODES} from '
|
|
13
|
-
import {findCoreDir, discoverExternalPackages} from '
|
|
12
|
+
import {ERROR_CODES} from '../../lib/error-codes.mjs';
|
|
13
|
+
import {findCoreDir, discoverExternalPackages} from '../../utils/paths.mjs';
|
|
14
14
|
import {
|
|
15
15
|
CORE_PACKAGE,
|
|
16
16
|
discoverComponents,
|
|
@@ -22,24 +22,46 @@ import {
|
|
|
22
22
|
findIntegrationComponentDoc,
|
|
23
23
|
findIntegrationComponentSource,
|
|
24
24
|
resolveImportPath,
|
|
25
|
-
} from '
|
|
26
|
-
import {Project} from '
|
|
27
|
-
import {loadDocs} from '
|
|
28
|
-
import {searchComponents} from '
|
|
29
|
-
import {AstryxError} from '
|
|
30
|
-
import {findShowcase, findRelatedBlocks} from '
|
|
25
|
+
} from '../../lib/component-discovery.mjs';
|
|
26
|
+
import {Project} from '../../lib/project.mjs';
|
|
27
|
+
import {loadDocs} from '../../lib/component-loader.mjs';
|
|
28
|
+
import {searchComponents} from '../../lib/string-utils.mjs';
|
|
29
|
+
import {AstryxError} from '../error.mjs';
|
|
30
|
+
import {findShowcase, findRelatedBlocks} from '../template/template.mjs';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A loaded component doc. `loadDocs` returns the authored `.doc.mjs` shape,
|
|
34
|
+
* which is either a single-component or multi-component doc; this loose view
|
|
35
|
+
* captures the fields the API reads across both forms.
|
|
36
|
+
* @typedef {object} LoadedComponentDoc
|
|
37
|
+
* @property {string} [name]
|
|
38
|
+
* @property {string} [description]
|
|
39
|
+
* @property {any[]} [props]
|
|
40
|
+
* @property {any[]} [components]
|
|
41
|
+
* @property {{description?: string}} [usage]
|
|
42
|
+
* @property {any} [theming]
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Options object for `loadDocs`, matching its declared parameter shape (used
|
|
47
|
+
* as a cast target so `lang` (which the API may hold as `string|null`) type
|
|
48
|
+
* checks against `loadDocs`'s `lang?: string`).
|
|
49
|
+
* @typedef {{zh?: boolean, dense?: boolean, lang?: string}} LoadDocsOpts
|
|
50
|
+
*/
|
|
31
51
|
|
|
32
52
|
/**
|
|
33
53
|
* Load the configured integrations for `cwd`, swallowing any config errors so
|
|
34
54
|
* component discovery never hard-fails on a malformed/absent integration. An
|
|
35
55
|
* empty list means "core only".
|
|
36
56
|
* @param {string} cwd
|
|
37
|
-
* @returns {Promise<
|
|
57
|
+
* @returns {Promise<import('../../lib/integrations.mjs').LoadedIntegration[]>}
|
|
38
58
|
*/
|
|
39
59
|
async function loadIntegrationsSafely(cwd) {
|
|
40
60
|
try {
|
|
41
61
|
const project = await Project.load(cwd);
|
|
42
|
-
return
|
|
62
|
+
return /** @type {import('../../lib/integrations.mjs').LoadedIntegration[]} */ (
|
|
63
|
+
project.loadedIntegrations
|
|
64
|
+
);
|
|
43
65
|
} catch {
|
|
44
66
|
return [];
|
|
45
67
|
}
|
|
@@ -47,7 +69,7 @@ async function loadIntegrationsSafely(cwd) {
|
|
|
47
69
|
|
|
48
70
|
/**
|
|
49
71
|
* Resolve a loaded integration by package name.
|
|
50
|
-
* @param {
|
|
72
|
+
* @param {import('../../lib/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
51
73
|
* @param {string} packageName
|
|
52
74
|
*/
|
|
53
75
|
function findLoadedIntegration(loadedIntegrations, packageName) {
|
|
@@ -133,7 +155,7 @@ export async function component(name, options = {}) {
|
|
|
133
155
|
const readme = findComponentReadme(coreDir, comp);
|
|
134
156
|
if (readme && readme.endsWith('.doc.mjs')) {
|
|
135
157
|
try {
|
|
136
|
-
const docs = await loadDocs(readme, {zh, lang});
|
|
158
|
+
const docs = /** @type {LoadedComponentDoc} */ (await loadDocs(readme, /** @type {LoadDocsOpts} */ ({zh, lang})));
|
|
137
159
|
entries.push({name: comp, description: docs.usage?.description || docs.description || '', import: resolveImportPath(coreDir, comp)});
|
|
138
160
|
} catch {
|
|
139
161
|
entries.push({name: comp, description: '', import: resolveImportPath(coreDir, comp)});
|
|
@@ -151,7 +173,7 @@ export async function component(name, options = {}) {
|
|
|
151
173
|
const readme = findComponentReadme(coreDir, comp);
|
|
152
174
|
if (readme && readme.endsWith('.doc.mjs')) {
|
|
153
175
|
try {
|
|
154
|
-
entries.push(await loadDocs(readme, {zh, lang, dense}));
|
|
176
|
+
entries.push(await loadDocs(readme, /** @type {LoadDocsOpts} */ ({zh, lang, dense})));
|
|
155
177
|
} catch {
|
|
156
178
|
entries.push({name: `XDS${comp}`, description: ''});
|
|
157
179
|
}
|
|
@@ -173,7 +195,7 @@ export async function component(name, options = {}) {
|
|
|
173
195
|
|
|
174
196
|
// All components — merge core + external packages with grouped subcategories
|
|
175
197
|
if (detail === 'compact') {
|
|
176
|
-
/** @type {Record<string, Array<import('
|
|
198
|
+
/** @type {Record<string, Array<import('../../types/component').ComponentBriefEntry>>} */
|
|
177
199
|
const result = {};
|
|
178
200
|
for (const [cat, comps] of Object.entries(components)) {
|
|
179
201
|
result[cat] = [];
|
|
@@ -181,7 +203,7 @@ export async function component(name, options = {}) {
|
|
|
181
203
|
const readme = findComponentReadme(coreDir, comp);
|
|
182
204
|
if (readme && readme.endsWith('.doc.mjs')) {
|
|
183
205
|
try {
|
|
184
|
-
const docs = await loadDocs(readme, {zh, lang});
|
|
206
|
+
const docs = /** @type {LoadedComponentDoc} */ (await loadDocs(readme, /** @type {LoadDocsOpts} */ ({zh, lang})));
|
|
185
207
|
result[cat].push({name: comp, description: docs.usage?.description || docs.description || '', import: resolveImportPath(coreDir, comp)});
|
|
186
208
|
} catch {
|
|
187
209
|
result[cat].push({name: comp, description: '', import: resolveImportPath(coreDir, comp)});
|
|
@@ -203,7 +225,7 @@ export async function component(name, options = {}) {
|
|
|
203
225
|
const readme = findComponentReadme(coreDir, comp);
|
|
204
226
|
if (readme && readme.endsWith('.doc.mjs')) {
|
|
205
227
|
try {
|
|
206
|
-
result[cat].push(await loadDocs(readme, {zh, lang, dense}));
|
|
228
|
+
result[cat].push(await loadDocs(readme, /** @type {LoadDocsOpts} */ ({zh, lang, dense})));
|
|
207
229
|
} catch {
|
|
208
230
|
result[cat].push({name: `XDS${comp}`, description: ''});
|
|
209
231
|
}
|
|
@@ -238,7 +260,7 @@ export async function component(name, options = {}) {
|
|
|
238
260
|
const groupLabel = rec.group ?? integration.name;
|
|
239
261
|
const key = `${groupLabel} (${integration.name})`;
|
|
240
262
|
if (!byGroup.has(key)) byGroup.set(key, []);
|
|
241
|
-
byGroup.get(key)
|
|
263
|
+
byGroup.get(key)?.push({name: rec.name, package: integration.name});
|
|
242
264
|
}
|
|
243
265
|
for (const [key, members] of byGroup) {
|
|
244
266
|
members.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -334,14 +356,14 @@ export async function component(name, options = {}) {
|
|
|
334
356
|
* `package`, the resolved `import` specifier, and `sourceAvailable` (whether
|
|
335
357
|
* a swizzleable source file exists for the owner). Existing doc fields
|
|
336
358
|
* (name, usage, props, …) are preserved.
|
|
337
|
-
* @param {
|
|
359
|
+
* @param {LoadedComponentDoc} docs
|
|
338
360
|
* @param {{package: string, sourcePath: string|null}} owner
|
|
339
361
|
* @param {string} componentName
|
|
340
362
|
*/
|
|
341
363
|
function withOwnership(docs, owner, componentName) {
|
|
342
364
|
const importSpec =
|
|
343
365
|
owner.package === CORE_PACKAGE
|
|
344
|
-
? resolveImportPath(coreDir, componentName)
|
|
366
|
+
? resolveImportPath(/** @type {string} */ (coreDir), componentName)
|
|
345
367
|
: `${owner.package}/${componentName}`;
|
|
346
368
|
return {
|
|
347
369
|
...docs,
|
|
@@ -368,7 +390,7 @@ export async function component(name, options = {}) {
|
|
|
368
390
|
}
|
|
369
391
|
return {type: 'component.detail.source', data: {component: dirName, source: fs.readFileSync(owner.sourcePath, 'utf-8')}};
|
|
370
392
|
}
|
|
371
|
-
const docs = await loadDocs(owner.docPath, {zh, dense, lang});
|
|
393
|
+
const docs = /** @type {LoadedComponentDoc} */ (await loadDocs(owner.docPath, /** @type {LoadDocsOpts} */ ({zh, dense, lang})));
|
|
372
394
|
if (props) {
|
|
373
395
|
const p = docs.props || (docs.components ? docs.components.flatMap(c => c.props || []) : []);
|
|
374
396
|
return {type: 'component.detail.props', data: p};
|
|
@@ -389,7 +411,7 @@ export async function component(name, options = {}) {
|
|
|
389
411
|
}
|
|
390
412
|
return {type: 'component.detail.source', data: {component: dirName, source: fs.readFileSync(owner.sourcePath, 'utf-8')}};
|
|
391
413
|
}
|
|
392
|
-
const docs = await loadDocs(owner.docPath, {zh, dense, lang});
|
|
414
|
+
const docs = /** @type {LoadedComponentDoc} */ (await loadDocs(owner.docPath, /** @type {LoadDocsOpts} */ ({zh, dense, lang})));
|
|
393
415
|
if (props) {
|
|
394
416
|
const p = docs.props || (docs.components ? docs.components.flatMap(c => c.props || []) : []);
|
|
395
417
|
return {type: 'component.detail.props', data: p};
|
|
@@ -420,7 +442,7 @@ export async function component(name, options = {}) {
|
|
|
420
442
|
|
|
421
443
|
const extDocPath = findExternalComponentDoc(ext.docsDir, dirName);
|
|
422
444
|
if (extDocPath && extDocPath.endsWith('.doc.mjs')) {
|
|
423
|
-
const docs = await loadDocs(extDocPath, {zh, dense, lang});
|
|
445
|
+
const docs = /** @type {LoadedComponentDoc} */ (await loadDocs(extDocPath, /** @type {LoadDocsOpts} */ ({zh, dense, lang})));
|
|
424
446
|
|
|
425
447
|
if (props) {
|
|
426
448
|
const p = docs.props || (docs.components ? docs.components.flatMap(c => c.props || []) : []);
|
|
@@ -461,7 +483,7 @@ export async function component(name, options = {}) {
|
|
|
461
483
|
if (showcase) {
|
|
462
484
|
throw new AstryxError(`No showcase found for "${name}"`, undefined, ERROR_CODES.ERR_NO_SHOWCASE);
|
|
463
485
|
}
|
|
464
|
-
const docs = await loadDocs(owner.docPath, {zh, dense, lang});
|
|
486
|
+
const docs = /** @type {LoadedComponentDoc} */ (await loadDocs(owner.docPath, /** @type {LoadDocsOpts} */ ({zh, dense, lang})));
|
|
465
487
|
if (props) {
|
|
466
488
|
const p = docs.props || (docs.components ? docs.components.flatMap(c => c.props || []) : []);
|
|
467
489
|
return {type: 'component.detail.props', data: p};
|
|
@@ -546,12 +568,12 @@ export async function component(name, options = {}) {
|
|
|
546
568
|
throw new AstryxError(`No .doc.mjs found for "${resolvedName}". The component needs a typed doc file.`, undefined, ERROR_CODES.ERR_NO_DOC);
|
|
547
569
|
}
|
|
548
570
|
|
|
549
|
-
const docs = await loadDocs(readmePath, {zh, dense, lang});
|
|
571
|
+
const docs = /** @type {LoadedComponentDoc} */ (await loadDocs(readmePath, /** @type {LoadDocsOpts} */ ({zh, dense, lang})));
|
|
550
572
|
|
|
551
573
|
// ── Blocks mode ──────────────────────────────────────────────
|
|
552
574
|
if (blocks) {
|
|
553
575
|
const allBlocks = await findRelatedBlocks(dirName);
|
|
554
|
-
const toEntry = (b) => ({
|
|
576
|
+
const toEntry = (/** @type {any} */ b) => ({
|
|
555
577
|
name: b.dirName,
|
|
556
578
|
displayName: b.name,
|
|
557
579
|
description: b.description,
|
|
@@ -561,7 +583,7 @@ export async function component(name, options = {}) {
|
|
|
561
583
|
|
|
562
584
|
// Examples: blocks in the component's own directory, or
|
|
563
585
|
// componentsUsed match for sub-components without a directory.
|
|
564
|
-
const ownDir = allBlocks.filter(b => path.basename(b.category) === dirName);
|
|
586
|
+
const ownDir = allBlocks.filter((/** @type {any} */ b) => path.basename(b.category) === dirName);
|
|
565
587
|
const examples = ownDir.length > 0
|
|
566
588
|
? ownDir
|
|
567
589
|
: allBlocks.filter(b => b.componentsUsed?.some(c => c === dirName));
|
|
@@ -595,6 +617,7 @@ export async function component(name, options = {}) {
|
|
|
595
617
|
: null;
|
|
596
618
|
|
|
597
619
|
if (matchingComponent) {
|
|
620
|
+
/** @type {LoadedComponentDoc & {parentDoc?: string, import?: string}} */
|
|
598
621
|
const scoped = {
|
|
599
622
|
name: dirName,
|
|
600
623
|
description: matchingComponent.description,
|
|
@@ -4,28 +4,37 @@
|
|
|
4
4
|
* @file Programmatic API for the discover command.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {Project} from '
|
|
7
|
+
import {Project} from '../../lib/project.mjs';
|
|
8
8
|
import {
|
|
9
9
|
scanAllPackages,
|
|
10
10
|
findComponentInPackages,
|
|
11
|
-
} from '
|
|
12
|
-
import {loadDocs} from '
|
|
13
|
-
import {levenshteinDistance} from '
|
|
14
|
-
import {AstryxError} from '
|
|
15
|
-
import {ERROR_CODES} from '
|
|
11
|
+
} from '../../lib/package-scanner.mjs';
|
|
12
|
+
import {loadDocs} from '../../lib/component-loader.mjs';
|
|
13
|
+
import {levenshteinDistance} from '../../lib/string-utils.mjs';
|
|
14
|
+
import {AstryxError} from '../error.mjs';
|
|
15
|
+
import {ERROR_CODES} from '../../lib/error-codes.mjs';
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {import('../../lib/package-scanner.mjs').ScannedPackage} ScannedPackage
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {unknown} docs
|
|
23
|
+
* @returns {string | null}
|
|
24
|
+
*/
|
|
17
25
|
function validateDocs(docs) {
|
|
18
26
|
if (!docs || typeof docs !== 'object')
|
|
19
27
|
return 'docs export is missing or not an object';
|
|
20
|
-
|
|
28
|
+
const d = /** @type {Record<string, any>} */ (docs);
|
|
29
|
+
if (typeof d.name !== 'string' || !d.name)
|
|
21
30
|
return 'docs.name is missing or not a string';
|
|
22
|
-
if (!
|
|
31
|
+
if (!d.usage || typeof d.usage.description !== 'string')
|
|
23
32
|
return 'docs.usage.description is missing or not a string';
|
|
24
|
-
if (
|
|
33
|
+
if (d.props && !Array.isArray(d.props))
|
|
25
34
|
return 'docs.props must be an array';
|
|
26
|
-
if (
|
|
35
|
+
if (d.components && !Array.isArray(d.components))
|
|
27
36
|
return 'docs.components must be an array';
|
|
28
|
-
if (
|
|
37
|
+
if (d.usage?.bestPractices && !Array.isArray(d.usage.bestPractices))
|
|
29
38
|
return 'docs.usage.bestPractices must be an array';
|
|
30
39
|
return null;
|
|
31
40
|
}
|
|
@@ -36,11 +45,21 @@ function validateDocs(docs) {
|
|
|
36
45
|
* @param {boolean} [options.components]
|
|
37
46
|
* @param {string} [options.lang]
|
|
38
47
|
* @param {boolean} [options.zh]
|
|
39
|
-
* @returns {Promise<
|
|
48
|
+
* @returns {Promise<
|
|
49
|
+
* import('../../types/discover').DiscoverListResponse |
|
|
50
|
+
* import('../../types/discover').DiscoverDetailResponse |
|
|
51
|
+
* import('../../types/discover').DiscoverDetailDocResponse |
|
|
52
|
+
* import('../../types/discover').DiscoverSearchResponse
|
|
53
|
+
* >}
|
|
40
54
|
*/
|
|
41
55
|
export async function discover(query, options = {}) {
|
|
42
56
|
const {lang = null, zh = false} = options;
|
|
43
57
|
const project = await Project.load();
|
|
58
|
+
const loadedIntegrations =
|
|
59
|
+
/** @type {import('../../lib/integrations.mjs').LoadedIntegration[]} */ (
|
|
60
|
+
project.loadedIntegrations
|
|
61
|
+
);
|
|
62
|
+
/** @param {ScannedPackage} pkg */
|
|
44
63
|
const toEntry = pkg => ({
|
|
45
64
|
name: pkg.name,
|
|
46
65
|
category: pkg.category,
|
|
@@ -52,7 +71,7 @@ export async function discover(query, options = {}) {
|
|
|
52
71
|
|
|
53
72
|
// External packages come from configured integrations that declare a
|
|
54
73
|
// components root. Each becomes a scannable package keyed by its docsDir.
|
|
55
|
-
const explicitPackages =
|
|
74
|
+
const explicitPackages = loadedIntegrations
|
|
56
75
|
.filter(integration => integration.components)
|
|
57
76
|
.map(integration => ({
|
|
58
77
|
name: integration.name,
|
|
@@ -64,7 +83,10 @@ export async function discover(query, options = {}) {
|
|
|
64
83
|
return {type: 'discover.list', data: [], meta: {configured: false}};
|
|
65
84
|
}
|
|
66
85
|
|
|
67
|
-
const packages = scanAllPackages(
|
|
86
|
+
const packages = scanAllPackages(
|
|
87
|
+
[],
|
|
88
|
+
/** @type {ScannedPackage[]} */ (/** @type {unknown} */ (explicitPackages)),
|
|
89
|
+
);
|
|
68
90
|
|
|
69
91
|
if (packages.length === 0) {
|
|
70
92
|
return {type: 'discover.list', data: [], meta: {configured: true}};
|
|
@@ -105,7 +127,7 @@ export async function discover(query, options = {}) {
|
|
|
105
127
|
return await loadAndValidate(exact, {lang, zh});
|
|
106
128
|
}
|
|
107
129
|
|
|
108
|
-
const substringMatches = [];
|
|
130
|
+
const substringMatches = /** @type {Array<{pkg: ScannedPackage, comp: string}>} */ ([]);
|
|
109
131
|
for (const pkg of packages) {
|
|
110
132
|
for (const comp of pkg.components) {
|
|
111
133
|
if (comp.toLowerCase().includes(lower)) {
|
|
@@ -134,7 +156,7 @@ export async function discover(query, options = {}) {
|
|
|
134
156
|
}
|
|
135
157
|
|
|
136
158
|
// Fuzzy fallback
|
|
137
|
-
const allComponents = [];
|
|
159
|
+
const allComponents = /** @type {Array<{pkg: ScannedPackage, comp: string}>} */ ([]);
|
|
138
160
|
for (const pkg of packages) {
|
|
139
161
|
for (const comp of pkg.components) {
|
|
140
162
|
allComponents.push({pkg, comp});
|
|
@@ -167,6 +189,13 @@ export async function discover(query, options = {}) {
|
|
|
167
189
|
);
|
|
168
190
|
}
|
|
169
191
|
|
|
192
|
+
/**
|
|
193
|
+
* @param {ScannedPackage[]} packages
|
|
194
|
+
* @param {string} compName
|
|
195
|
+
* @param {string} pkgName
|
|
196
|
+
* @param {{lang?: string|null, zh?: boolean}} opts
|
|
197
|
+
* @returns {Promise<import('../../types/discover').DiscoverDetailDocResponse>}
|
|
198
|
+
*/
|
|
170
199
|
async function resolveComponentDocs(packages, compName, pkgName, {lang, zh}) {
|
|
171
200
|
const pkg = packages.find(p => p.name === pkgName);
|
|
172
201
|
if (!pkg)
|
|
@@ -202,13 +231,21 @@ async function resolveComponentDocs(packages, compName, pkgName, {lang, zh}) {
|
|
|
202
231
|
return await loadAndValidate(result, {lang, zh});
|
|
203
232
|
}
|
|
204
233
|
|
|
234
|
+
/**
|
|
235
|
+
* @param {{docPath: string, componentName: string, pkg: ScannedPackage}} result
|
|
236
|
+
* @param {{lang?: string|null, zh?: boolean}} opts
|
|
237
|
+
* @returns {Promise<import('../../types/discover').DiscoverDetailDocResponse>}
|
|
238
|
+
*/
|
|
205
239
|
async function loadAndValidate(result, {lang, zh}) {
|
|
206
240
|
let docs;
|
|
207
241
|
try {
|
|
208
|
-
docs = await loadDocs(
|
|
242
|
+
docs = await loadDocs(
|
|
243
|
+
result.docPath,
|
|
244
|
+
/** @type {{zh?: boolean, dense?: boolean, lang?: string}} */ ({zh, lang}),
|
|
245
|
+
);
|
|
209
246
|
} catch (e) {
|
|
210
247
|
throw new AstryxError(
|
|
211
|
-
`Failed to load docs for ${result.componentName}: ${e.message}`,
|
|
248
|
+
`Failed to load docs for ${result.componentName}: ${/** @type {any} */ (e).message}`,
|
|
212
249
|
undefined,
|
|
213
250
|
ERROR_CODES.ERR_INVALID_DOC,
|
|
214
251
|
);
|