@contentful/experience-design-system-extraction 2.36.2-dev-build-a6f80ae6.0 → 2.36.2-dev-build-7907fec3.0
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/dist/package.json +1 -1
- package/dist/src/extract/controller/extract-controller.d.ts +10 -0
- package/dist/src/extract/controller/extract-controller.js +33 -0
- package/dist/src/extract/controller/helpers/validate-endpoint-request.d.ts +2 -0
- package/dist/src/extract/controller/helpers/validate-endpoint-request.js +24 -0
- package/dist/src/extract/{astro.d.ts → framework-adapters/astro/extractor.d.ts} +1 -1
- package/dist/src/extract/framework-adapters/astro/extractor.js +45 -0
- package/dist/src/extract/framework-adapters/astro/frontmatter.d.ts +11 -0
- package/dist/src/extract/framework-adapters/astro/frontmatter.js +96 -0
- package/dist/src/extract/framework-adapters/astro/helpers/collect-astro-props-bindings.d.ts +4 -0
- package/dist/src/extract/framework-adapters/astro/helpers/collect-astro-props-bindings.js +47 -0
- package/dist/src/extract/framework-adapters/astro/slots.d.ts +7 -0
- package/dist/src/extract/framework-adapters/astro/slots.js +44 -0
- package/dist/src/extract/{react.d.ts → framework-adapters/react/extractor.d.ts} +1 -1
- package/dist/src/extract/framework-adapters/react/extractor.js +31 -0
- package/dist/src/extract/framework-adapters/react/helpers/collect-dom-wrapper-contexts.d.ts +4 -0
- package/dist/src/extract/framework-adapters/react/helpers/collect-dom-wrapper-contexts.js +73 -0
- package/dist/src/extract/framework-adapters/react/helpers/collect-prop-dataflow.d.ts +14 -0
- package/dist/src/extract/framework-adapters/react/helpers/collect-prop-dataflow.js +220 -0
- package/dist/src/extract/framework-adapters/react/helpers/collect-react-impl-hints.d.ts +5 -0
- package/dist/src/extract/framework-adapters/react/helpers/collect-react-impl-hints.js +32 -0
- package/dist/src/extract/framework-adapters/react/helpers/detect-dom-is-pure-wrapper.d.ts +2 -0
- package/dist/src/extract/framework-adapters/react/helpers/detect-dom-is-pure-wrapper.js +59 -0
- package/dist/src/extract/framework-adapters/react/helpers/detect-dom-type-patterns.d.ts +8 -0
- package/dist/src/extract/framework-adapters/react/helpers/detect-dom-type-patterns.js +29 -0
- package/dist/src/extract/framework-adapters/react/helpers/detect-omit-wrapped-custom-props.d.ts +2 -0
- package/dist/src/extract/framework-adapters/react/helpers/detect-omit-wrapped-custom-props.js +64 -0
- package/dist/src/extract/framework-adapters/react/helpers/detect-pick-type-patterns.d.ts +4 -0
- package/dist/src/extract/framework-adapters/react/helpers/detect-pick-type-patterns.js +64 -0
- package/dist/src/extract/framework-adapters/react/helpers/detect-react-polymorphic.d.ts +5 -0
- package/dist/src/extract/framework-adapters/react/helpers/detect-react-polymorphic.js +170 -0
- package/dist/src/extract/framework-adapters/react/helpers/dom-attribute-surfaces.d.ts +15 -0
- package/dist/src/extract/framework-adapters/react/helpers/dom-attribute-surfaces.js +231 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-binding-fallback-props.d.ts +4 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-binding-fallback-props.js +50 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-from-react-source-file.d.ts +5 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-from-react-source-file.js +23 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-react-allowed-components.d.ts +2 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-react-allowed-components.js +25 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-react-binding-defaults.d.ts +6 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-react-binding-defaults.js +48 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-react-component-from-export.d.ts +15 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-react-component-from-export.js +106 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-react-prop-types.d.ts +3 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-react-prop-types.js +64 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-react-props-from-type.d.ts +15 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-react-props-from-type.js +318 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-react-slots.d.ts +6 -0
- package/dist/src/extract/framework-adapters/react/helpers/extract-react-slots.js +44 -0
- package/dist/src/extract/framework-adapters/react/helpers/filter-impl-alias-props.d.ts +4 -0
- package/dist/src/extract/framework-adapters/react/helpers/filter-impl-alias-props.js +52 -0
- package/dist/src/extract/framework-adapters/react/helpers/infer-primitive-dom-props.d.ts +6 -0
- package/dist/src/extract/framework-adapters/react/helpers/infer-primitive-dom-props.js +69 -0
- package/dist/src/extract/framework-adapters/react/helpers/resolve-component-function.d.ts +4 -0
- package/dist/src/extract/framework-adapters/react/helpers/resolve-component-function.js +131 -0
- package/dist/src/extract/framework-adapters/react/helpers/resolve-react-prop-forwarding.d.ts +8 -0
- package/dist/src/extract/framework-adapters/react/helpers/resolve-react-prop-forwarding.js +22 -0
- package/dist/src/extract/framework-adapters/react/helpers/resolve-react-props-type.d.ts +14 -0
- package/dist/src/extract/framework-adapters/react/helpers/resolve-react-props-type.js +86 -0
- package/dist/src/extract/framework-adapters/react/helpers/synthesize-react-structural-slots.d.ts +8 -0
- package/dist/src/extract/framework-adapters/react/helpers/synthesize-react-structural-slots.js +44 -0
- package/dist/src/extract/framework-adapters/shared/helpers/build-component-lookup-maps.d.ts +5 -0
- package/dist/src/extract/framework-adapters/shared/helpers/build-component-lookup-maps.js +10 -0
- package/dist/src/extract/framework-adapters/shared/helpers/collect-jsdoc-slot-comments.d.ts +2 -0
- package/dist/src/extract/framework-adapters/shared/helpers/collect-jsdoc-slot-comments.js +13 -0
- package/dist/src/extract/{file-extraction-workers.d.ts → framework-adapters/shared/helpers/file-processing/file-workers.d.ts} +1 -13
- package/dist/src/extract/{file-extraction-workers.js → framework-adapters/shared/helpers/file-processing/file-workers.js} +0 -19
- package/dist/src/extract/framework-adapters/shared/helpers/file-processing/project-source-files.d.ts +5 -0
- package/dist/src/extract/framework-adapters/shared/helpers/file-processing/project-source-files.js +13 -0
- package/dist/src/extract/framework-adapters/shared/helpers/file-processing/result-normalizer.d.ts +6 -0
- package/dist/src/extract/framework-adapters/shared/helpers/file-processing/result-normalizer.js +6 -0
- package/dist/src/extract/framework-adapters/shared/helpers/find-tsx-workspace-package.d.ts +2 -0
- package/dist/src/extract/framework-adapters/shared/helpers/find-tsx-workspace-package.js +62 -0
- package/dist/src/extract/{source-line-metadata.d.ts → framework-adapters/shared/helpers/get-node-source-lines.d.ts} +1 -1
- package/dist/src/extract/framework-adapters/shared/helpers/resolve-tsx-tsconfig-path.d.ts +7 -0
- package/dist/src/extract/framework-adapters/shared/helpers/resolve-tsx-tsconfig-path.js +93 -0
- package/dist/src/extract/framework-adapters/shared/helpers/resolve-tsx-workspace-imports.d.ts +6 -0
- package/dist/src/extract/framework-adapters/shared/helpers/resolve-tsx-workspace-imports.js +58 -0
- package/dist/src/extract/framework-adapters/shared/helpers/tsx-node-utils.d.ts +13 -0
- package/dist/src/extract/framework-adapters/shared/helpers/tsx-node-utils.js +76 -0
- package/dist/src/extract/framework-adapters/shared/helpers/tsx-renderable-exports.d.ts +12 -0
- package/dist/src/extract/framework-adapters/shared/helpers/tsx-renderable-exports.js +35 -0
- package/dist/src/extract/framework-adapters/shared/helpers/tsx-shared.d.ts +14 -0
- package/dist/src/extract/framework-adapters/shared/helpers/tsx-shared.js +54 -0
- package/dist/src/extract/{stencil.d.ts → framework-adapters/stencil/extractor.d.ts} +1 -1
- package/dist/src/extract/framework-adapters/stencil/extractor.js +82 -0
- package/dist/src/extract/framework-adapters/stencil/helpers/detect-stencil-class.d.ts +7 -0
- package/dist/src/extract/framework-adapters/stencil/helpers/detect-stencil-class.js +32 -0
- package/dist/src/extract/framework-adapters/stencil/helpers/extract-stencil-props.d.ts +5 -0
- package/dist/src/extract/framework-adapters/stencil/helpers/extract-stencil-props.js +62 -0
- package/dist/src/extract/framework-adapters/stencil/helpers/extract-stencil-slots.d.ts +6 -0
- package/dist/src/extract/framework-adapters/stencil/helpers/extract-stencil-slots.js +87 -0
- package/dist/src/extract/framework-adapters/stencil/helpers/stencil-prop-helpers.d.ts +5 -0
- package/dist/src/extract/framework-adapters/stencil/helpers/stencil-prop-helpers.js +39 -0
- package/dist/src/extract/{svelte.d.ts → framework-adapters/svelte/extractor.d.ts} +2 -1
- package/dist/src/extract/framework-adapters/svelte/extractor.js +27 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/classify-svelte-props-annotation.d.ts +6 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/classify-svelte-props-annotation.js +51 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/collect-svelte-type-references.d.ts +3 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/collect-svelte-type-references.js +52 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-from-svelte-file.d.ts +7 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-from-svelte-file.js +90 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-svelte-ast-type-members.d.ts +15 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-svelte-ast-type-members.js +46 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-svelte-declaration-data.d.ts +7 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-svelte-declaration-data.js +64 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-svelte-external-type-members.d.ts +4 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-svelte-external-type-members.js +58 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-svelte-from-destructure.d.ts +4 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-svelte-from-destructure.js +85 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-svelte-props.d.ts +22 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-svelte-props.js +55 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-svelte-template-slots.d.ts +7 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-svelte-template-slots.js +63 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-svelte-type-member-props.d.ts +3 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/extract-svelte-type-member-props.js +31 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/find-svelte-script-declarations.d.ts +8 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/find-svelte-script-declarations.js +91 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/get-svelte-component-name.d.ts +1 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/get-svelte-component-name.js +26 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/render-svelte-type-strings.d.ts +3 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/render-svelte-type-strings.js +91 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/render-svelte-type.d.ts +11 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/render-svelte-type.js +68 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/resolve-dts-location.d.ts +1 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/resolve-dts-location.js +90 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/resolve-svelte-allowed-components.d.ts +2 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/resolve-svelte-allowed-components.js +20 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/resolve-svelte-external-type-readers.d.ts +3 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/resolve-svelte-external-type-readers.js +68 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/resolve-svelte-type-checker.d.ts +4 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/resolve-svelte-type-checker.js +68 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/resolve-svelte-type-members.d.ts +6 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/resolve-svelte-type-members.js +30 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/resolve-svelte-unresolved-retry.d.ts +13 -0
- package/dist/src/extract/framework-adapters/svelte/helpers/resolve-svelte-unresolved-retry.js +192 -0
- package/dist/src/extract/framework-adapters/svelte/types/svelte-ast-node.d.ts +12 -0
- package/dist/src/extract/framework-adapters/svelte/types/svelte-ast-node.js +1 -0
- package/dist/src/extract/{vue.d.ts → framework-adapters/vue/extractor.d.ts} +1 -1
- package/dist/src/extract/framework-adapters/vue/extractor.js +61 -0
- package/dist/src/extract/framework-adapters/vue/helpers/extract-vue-object-props.d.ts +3 -0
- package/dist/src/extract/framework-adapters/vue/helpers/extract-vue-object-props.js +67 -0
- package/dist/src/extract/framework-adapters/vue/helpers/extract-vue-options-props.d.ts +4 -0
- package/dist/src/extract/framework-adapters/vue/helpers/extract-vue-options-props.js +72 -0
- package/dist/src/extract/framework-adapters/vue/helpers/extract-vue-setup-object-props.d.ts +8 -0
- package/dist/src/extract/framework-adapters/vue/helpers/extract-vue-setup-object-props.js +64 -0
- package/dist/src/extract/framework-adapters/vue/helpers/extract-vue-setup-props.d.ts +2 -0
- package/dist/src/extract/framework-adapters/vue/helpers/extract-vue-setup-props.js +66 -0
- package/dist/src/extract/framework-adapters/vue/helpers/extract-vue-slots.d.ts +24 -0
- package/dist/src/extract/framework-adapters/vue/helpers/extract-vue-slots.js +56 -0
- package/dist/src/extract/framework-adapters/vue/helpers/resolve-vue-component-name.d.ts +2 -0
- package/dist/src/extract/framework-adapters/vue/helpers/resolve-vue-component-name.js +9 -0
- package/dist/src/extract/framework-adapters/vue/helpers/resolve-workspace-module.d.ts +1 -0
- package/dist/src/extract/framework-adapters/vue/helpers/resolve-workspace-module.js +76 -0
- package/dist/src/extract/framework-adapters/vue/helpers/workspace-package-dirs.d.ts +2 -0
- package/dist/src/extract/framework-adapters/vue/helpers/workspace-package-dirs.js +77 -0
- package/dist/src/extract/{vue-tsx.d.ts → framework-adapters/vue-tsx/extractor.d.ts} +1 -1
- package/dist/src/extract/framework-adapters/vue-tsx/extractor.js +82 -0
- package/dist/src/extract/framework-adapters/vue-tsx/helpers/extract-vue-tsx-props.d.ts +5 -0
- package/dist/src/extract/framework-adapters/vue-tsx/helpers/extract-vue-tsx-props.js +189 -0
- package/dist/src/extract/framework-adapters/vue-tsx/helpers/extract-vue-tsx-slots.d.ts +4 -0
- package/dist/src/extract/framework-adapters/vue-tsx/helpers/extract-vue-tsx-slots.js +91 -0
- package/dist/src/extract/framework-adapters/vue-tsx/helpers/resolve-ast-object.d.ts +11 -0
- package/dist/src/extract/framework-adapters/vue-tsx/helpers/resolve-ast-object.js +95 -0
- package/dist/src/extract/{web-components.d.ts → framework-adapters/web-components/extractor.d.ts} +1 -1
- package/dist/src/extract/framework-adapters/web-components/extractor.js +55 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/collect-wc-html-templates.d.ts +4 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/collect-wc-html-templates.js +67 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/detect-wc-non-public-members.d.ts +9 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/detect-wc-non-public-members.js +11 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/extract-wc-accessor-props.d.ts +3 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/extract-wc-accessor-props.js +65 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/extract-wc-class-properties.d.ts +3 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/extract-wc-class-properties.js +60 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/extract-wc-inheritance.d.ts +4 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/extract-wc-inheritance.js +16 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/extract-wc-jsdoc-attr-props.d.ts +3 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/extract-wc-jsdoc-attr-props.js +24 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/extract-wc-observed-attrs.d.ts +3 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/extract-wc-observed-attrs.js +27 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/extract-wc-slots.d.ts +6 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/extract-wc-slots.js +56 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/extract-wc-template-content.d.ts +4 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/extract-wc-template-content.js +49 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/merge-wc-prop-lists.d.ts +9 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/merge-wc-prop-lists.js +19 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/resolve-wc-base-class.d.ts +2 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/resolve-wc-base-class.js +59 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/resolve-wc-decorator-tag.d.ts +2 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/resolve-wc-decorator-tag.js +54 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/resolve-wc-import-source.d.ts +7 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/resolve-wc-import-source.js +47 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/resolve-wc-import.d.ts +4 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/resolve-wc-import.js +93 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/resolve-wc-sibling-definition.d.ts +4 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/resolve-wc-sibling-definition.js +79 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/resolve-wc-tag-name.d.ts +7 -0
- package/dist/src/extract/framework-adapters/web-components/helpers/resolve-wc-tag-name.js +62 -0
- package/dist/src/extract/helpers/evidence/ast/collect-structural-jsx-evidence.d.ts +5 -0
- package/dist/src/extract/helpers/evidence/ast/collect-structural-jsx-evidence.js +63 -0
- package/dist/src/extract/helpers/evidence/ast/detect-react-node-types.d.ts +2 -0
- package/dist/src/extract/helpers/evidence/ast/detect-react-node-types.js +24 -0
- package/dist/src/extract/helpers/evidence/ast/get-jsx-ast-data.d.ts +14 -0
- package/dist/src/extract/helpers/evidence/ast/get-jsx-ast-data.js +85 -0
- package/dist/src/extract/helpers/evidence/collect-jsx-component-references.d.ts +5 -0
- package/dist/src/extract/helpers/evidence/collect-jsx-component-references.js +52 -0
- package/dist/src/extract/helpers/evidence/detect-slot-from-prop.d.ts +16 -0
- package/dist/src/extract/helpers/evidence/detect-slot-from-prop.js +39 -0
- package/dist/src/extract/orchestrator/execute-extraction-orchestrator.d.ts +13 -0
- package/dist/src/extract/orchestrator/execute-extraction-orchestrator.js +17 -0
- package/dist/src/{pre-classify.d.ts → extract/services/classification/classify-component-props.d.ts} +3 -5
- package/dist/src/{pre-classify.js → extract/services/classification/classify-component-props.js} +8 -100
- package/dist/src/extract/services/classification/helpers/check-prop-types.d.ts +7 -0
- package/dist/src/extract/services/classification/helpers/check-prop-types.js +22 -0
- package/dist/src/extract/services/classification/helpers/detect-dom-props.d.ts +2 -0
- package/dist/src/extract/services/classification/helpers/detect-dom-props.js +63 -0
- package/dist/src/extract/services/deduplication/deduplicate-components.d.ts +2 -0
- package/dist/src/extract/services/deduplication/deduplicate-components.js +58 -0
- package/dist/src/extract/services/deduplication/helpers/component-path-analysis.d.ts +10 -0
- package/dist/src/extract/services/deduplication/helpers/component-path-analysis.js +85 -0
- package/dist/src/extract/services/deduplication/helpers/component-path-scoring.d.ts +10 -0
- package/dist/src/extract/services/deduplication/helpers/component-path-scoring.js +73 -0
- package/dist/src/extract/services/extraction/extract-components.d.ts +3 -0
- package/dist/src/extract/services/extraction/extract-components.js +19 -0
- package/dist/src/extract/services/extraction/helpers/collect-sveltekit-route-exclusions.d.ts +2 -0
- package/dist/src/extract/services/extraction/helpers/collect-sveltekit-route-exclusions.js +18 -0
- package/dist/src/extract/services/extraction/helpers/filter-hook-components.d.ts +6 -0
- package/dist/src/extract/services/extraction/helpers/filter-hook-components.js +18 -0
- package/dist/src/extract/services/extraction/helpers/register-extractors.d.ts +8 -0
- package/dist/src/extract/services/extraction/helpers/register-extractors.js +71 -0
- package/dist/src/extract/services/extraction/helpers/run-extractor-batches.d.ts +4 -0
- package/dist/src/extract/services/extraction/helpers/run-extractor-batches.js +24 -0
- package/dist/src/extract/services/quality/evaluate-extraction-quality.d.ts +4 -0
- package/dist/src/extract/services/quality/evaluate-extraction-quality.js +61 -0
- package/dist/src/extract/services/quality/helpers/authorability/evaluate-authorability.d.ts +28 -0
- package/dist/src/extract/services/quality/helpers/authorability/evaluate-authorability.js +67 -0
- package/dist/src/extract/services/quality/helpers/inspection/detect-data-wrapper-patterns.d.ts +16 -0
- package/dist/src/extract/services/quality/helpers/inspection/detect-data-wrapper-patterns.js +63 -0
- package/dist/src/extract/{source-inspection.d.ts → services/quality/helpers/inspection/inspect-component-source.d.ts} +3 -6
- package/dist/src/extract/{source-inspection.js → services/quality/helpers/inspection/inspect-component-source.js} +5 -65
- package/dist/src/extract/{validate.d.ts → services/quality/helpers/inspection/validate-extracted-components.d.ts} +1 -1
- package/dist/src/extract/services/quality/helpers/scoring/collect-scoring-inputs.d.ts +14 -0
- package/dist/src/extract/{scoring.js → services/quality/helpers/scoring/collect-scoring-inputs.js} +10 -24
- package/dist/src/extract/services/quality/helpers/scoring/compute-extraction-score.d.ts +6 -0
- package/dist/src/extract/services/quality/helpers/scoring/compute-extraction-score.js +12 -0
- package/dist/src/extract/types/classification.d.ts +4 -0
- package/dist/src/extract/types/classification.js +1 -0
- package/dist/src/extract/types/component-extractor.d.ts +7 -0
- package/dist/src/extract/types/component-extractor.js +1 -0
- package/dist/src/{types.d.ts → extract/types/component.d.ts} +0 -22
- package/dist/src/extract/types/component.js +1 -0
- package/dist/src/extract/types/contract.d.ts +16 -0
- package/dist/src/extract/types/contract.js +1 -0
- package/dist/src/extract/types/display.d.ts +3 -0
- package/dist/src/{types.js → extract/types/display.js} +1 -1
- package/dist/src/extract/types/options.d.ts +15 -0
- package/dist/src/extract/types/options.js +1 -0
- package/dist/src/extract/types/scoring.d.ts +9 -0
- package/dist/src/extract/types/scoring.js +1 -0
- package/dist/src/extract/types/source-inspection.d.ts +5 -0
- package/dist/src/extract/types/source-inspection.js +1 -0
- package/dist/src/index.d.ts +27 -21
- package/dist/src/index.js +21 -17
- package/package.json +1 -1
- package/dist/src/extract/astro.js +0 -226
- package/dist/src/extract/non-authorable-filter.d.ts +0 -17
- package/dist/src/extract/non-authorable-filter.js +0 -60
- package/dist/src/extract/pipeline.d.ts +0 -7
- package/dist/src/extract/pipeline.js +0 -343
- package/dist/src/extract/react.js +0 -2069
- package/dist/src/extract/scoring.d.ts +0 -12
- package/dist/src/extract/slot-detection.d.ts +0 -35
- package/dist/src/extract/slot-detection.js +0 -98
- package/dist/src/extract/stencil.js +0 -312
- package/dist/src/extract/structural-slot-evidence.d.ts +0 -63
- package/dist/src/extract/structural-slot-evidence.js +0 -278
- package/dist/src/extract/svelte.js +0 -1309
- package/dist/src/extract/tsx-shared.d.ts +0 -37
- package/dist/src/extract/tsx-shared.js +0 -368
- package/dist/src/extract/vue-tsx.js +0 -449
- package/dist/src/extract/vue.js +0 -605
- package/dist/src/extract/web-components.js +0 -863
- /package/dist/src/extract/{source-line-metadata.js → framework-adapters/shared/helpers/get-node-source-lines.js} +0 -0
- /package/dist/src/extract/{resolve-local-module.d.ts → framework-adapters/shared/helpers/resolve-import-file-path.d.ts} +0 -0
- /package/dist/src/extract/{resolve-local-module.js → framework-adapters/shared/helpers/resolve-import-file-path.js} +0 -0
- /package/dist/src/extract/{resolve-type-property.d.ts → framework-adapters/shared/helpers/resolve-type-symbol.d.ts} +0 -0
- /package/dist/src/extract/{resolve-type-property.js → framework-adapters/shared/helpers/resolve-type-symbol.js} +0 -0
- /package/dist/src/extract/{slot-allowed-components.d.ts → helpers/evidence/collect-allowed-component-names.d.ts} +0 -0
- /package/dist/src/extract/{slot-allowed-components.js → helpers/evidence/collect-allowed-component-names.js} +0 -0
- /package/dist/src/extract/{parse-imported-names.d.ts → helpers/evidence/parse-source-imports.d.ts} +0 -0
- /package/dist/src/extract/{parse-imported-names.js → helpers/evidence/parse-source-imports.js} +0 -0
- /package/dist/src/extract/{validate.js → services/quality/helpers/inspection/validate-extracted-components.js} +0 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import ts from 'typescript';
|
|
4
|
+
const nearestTsConfigPathCache = new Map();
|
|
5
|
+
const tsConfigPathsCache = new Map();
|
|
6
|
+
export function matchTsConfigPathPattern(pattern, specifier) {
|
|
7
|
+
if (!pattern.includes('*'))
|
|
8
|
+
return { matched: pattern === specifier };
|
|
9
|
+
const [prefix, suffix] = pattern.split('*');
|
|
10
|
+
if (!specifier.startsWith(prefix) || !specifier.endsWith(suffix))
|
|
11
|
+
return { matched: false };
|
|
12
|
+
return {
|
|
13
|
+
matched: true,
|
|
14
|
+
wildcard: specifier.slice(prefix.length, specifier.length - suffix.length),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function substituteTsConfigPathTarget(targetPattern, wildcard) {
|
|
18
|
+
return wildcard === undefined ? targetPattern : targetPattern.replace('*', wildcard);
|
|
19
|
+
}
|
|
20
|
+
function findNearestTsConfigPath(filePath) {
|
|
21
|
+
if (nearestTsConfigPathCache.has(filePath))
|
|
22
|
+
return nearestTsConfigPathCache.get(filePath) ?? undefined;
|
|
23
|
+
let currentDir = dirname(filePath);
|
|
24
|
+
while (true) {
|
|
25
|
+
for (const candidateName of ['tsconfig.json', 'jsconfig.json']) {
|
|
26
|
+
const candidatePath = join(currentDir, candidateName);
|
|
27
|
+
if (existsSync(candidatePath)) {
|
|
28
|
+
nearestTsConfigPathCache.set(filePath, candidatePath);
|
|
29
|
+
return candidatePath;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const parentDir = dirname(currentDir);
|
|
33
|
+
if (parentDir === currentDir) {
|
|
34
|
+
nearestTsConfigPathCache.set(filePath, null);
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
currentDir = parentDir;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function getTsConfigPaths(tsConfigPath) {
|
|
41
|
+
if (tsConfigPathsCache.has(tsConfigPath))
|
|
42
|
+
return tsConfigPathsCache.get(tsConfigPath) ?? undefined;
|
|
43
|
+
const configFile = ts.readConfigFile(tsConfigPath, ts.sys.readFile);
|
|
44
|
+
if (configFile.error || !configFile.config) {
|
|
45
|
+
tsConfigPathsCache.set(tsConfigPath, null);
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, dirname(tsConfigPath));
|
|
49
|
+
const paths = parsedConfig.options.paths;
|
|
50
|
+
if (!paths || Object.keys(paths).length === 0) {
|
|
51
|
+
tsConfigPathsCache.set(tsConfigPath, null);
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
const baseUrl = parsedConfig.options.baseUrl ?? dirname(tsConfigPath);
|
|
55
|
+
const result = { baseUrl, paths };
|
|
56
|
+
tsConfigPathsCache.set(tsConfigPath, result);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
export function resolveImportSourcePath(basePath) {
|
|
60
|
+
const candidates = [
|
|
61
|
+
basePath,
|
|
62
|
+
`${basePath}.ts`,
|
|
63
|
+
`${basePath}.tsx`,
|
|
64
|
+
`${basePath}.js`,
|
|
65
|
+
`${basePath}.jsx`,
|
|
66
|
+
join(basePath, 'index.ts'),
|
|
67
|
+
join(basePath, 'index.tsx'),
|
|
68
|
+
join(basePath, 'index.js'),
|
|
69
|
+
join(basePath, 'index.jsx'),
|
|
70
|
+
];
|
|
71
|
+
return candidates.find((candidatePath) => existsSync(candidatePath));
|
|
72
|
+
}
|
|
73
|
+
export function resolveRepoLocalAliasImportPath(importingFilePath, moduleSpecifier) {
|
|
74
|
+
const nearestTsConfigPath = findNearestTsConfigPath(importingFilePath);
|
|
75
|
+
if (!nearestTsConfigPath)
|
|
76
|
+
return undefined;
|
|
77
|
+
const tsConfigPaths = getTsConfigPaths(nearestTsConfigPath);
|
|
78
|
+
if (!tsConfigPaths)
|
|
79
|
+
return undefined;
|
|
80
|
+
for (const [pattern, targets] of Object.entries(tsConfigPaths.paths)) {
|
|
81
|
+
const match = matchTsConfigPathPattern(pattern, moduleSpecifier);
|
|
82
|
+
if (!match.matched)
|
|
83
|
+
continue;
|
|
84
|
+
for (const targetPattern of targets) {
|
|
85
|
+
const substitutedTarget = substituteTsConfigPathTarget(targetPattern, match.wildcard);
|
|
86
|
+
const resolvedPath = resolve(tsConfigPaths.baseUrl, substitutedTarget);
|
|
87
|
+
const sourceFilePath = resolveImportSourcePath(resolvedPath);
|
|
88
|
+
if (sourceFilePath)
|
|
89
|
+
return sourceFilePath;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Node } from 'ts-morph';
|
|
2
|
+
import { matchTsConfigPathPattern, substituteTsConfigPathTarget, resolveImportSourcePath } from './resolve-tsx-tsconfig-path.js';
|
|
3
|
+
export { matchTsConfigPathPattern, substituteTsConfigPathTarget };
|
|
4
|
+
export declare function isBareModuleSpecifier(moduleSpecifier: string): boolean;
|
|
5
|
+
export declare function resolveWorkspaceImportSpecifierDeclarations(importSpecifier: Node, referenceNode: Node): Node[];
|
|
6
|
+
export { resolveImportSourcePath };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { Node } from 'ts-morph';
|
|
3
|
+
import { matchTsConfigPathPattern, substituteTsConfigPathTarget, resolveImportSourcePath, resolveRepoLocalAliasImportPath, } from './resolve-tsx-tsconfig-path.js';
|
|
4
|
+
import { findWorkspacePackageEntrySourceFile } from './find-tsx-workspace-package.js';
|
|
5
|
+
export { matchTsConfigPathPattern, substituteTsConfigPathTarget };
|
|
6
|
+
export function isBareModuleSpecifier(moduleSpecifier) {
|
|
7
|
+
return !moduleSpecifier.startsWith('.') && !moduleSpecifier.startsWith('/');
|
|
8
|
+
}
|
|
9
|
+
function findProjectSourceFileByImportPath(project, resolvedPath) {
|
|
10
|
+
const candidatePaths = [
|
|
11
|
+
resolvedPath,
|
|
12
|
+
`${resolvedPath}.ts`,
|
|
13
|
+
`${resolvedPath}.tsx`,
|
|
14
|
+
`${resolvedPath}.js`,
|
|
15
|
+
`${resolvedPath}.jsx`,
|
|
16
|
+
join(resolvedPath, 'index.ts'),
|
|
17
|
+
join(resolvedPath, 'index.tsx'),
|
|
18
|
+
join(resolvedPath, 'index.js'),
|
|
19
|
+
join(resolvedPath, 'index.jsx'),
|
|
20
|
+
];
|
|
21
|
+
for (const candidatePath of candidatePaths) {
|
|
22
|
+
const sourceFile = project.getSourceFile(candidatePath);
|
|
23
|
+
if (sourceFile)
|
|
24
|
+
return sourceFile;
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
function findRepoLocalAliasSourceFile(originSourceFile, moduleSpecifier) {
|
|
29
|
+
const resolvedPath = resolveRepoLocalAliasImportPath(originSourceFile.getFilePath(), moduleSpecifier);
|
|
30
|
+
if (!resolvedPath)
|
|
31
|
+
return undefined;
|
|
32
|
+
return findProjectSourceFileByImportPath(originSourceFile.getProject(), resolvedPath);
|
|
33
|
+
}
|
|
34
|
+
function getExportedDeclarationsForImportSpecifier(importSpecifier, sourceFile) {
|
|
35
|
+
if (!Node.isImportSpecifier(importSpecifier))
|
|
36
|
+
return [];
|
|
37
|
+
const exportedName = importSpecifier.getNameNode().getText();
|
|
38
|
+
return sourceFile.getExportedDeclarations().get(exportedName) ?? [];
|
|
39
|
+
}
|
|
40
|
+
export function resolveWorkspaceImportSpecifierDeclarations(importSpecifier, referenceNode) {
|
|
41
|
+
if (!Node.isImportSpecifier(importSpecifier))
|
|
42
|
+
return [];
|
|
43
|
+
const importDeclaration = importSpecifier.getImportDeclaration();
|
|
44
|
+
const moduleSpecifierSourceFile = importDeclaration.getModuleSpecifierSourceFile();
|
|
45
|
+
if (moduleSpecifierSourceFile)
|
|
46
|
+
return getExportedDeclarationsForImportSpecifier(importSpecifier, moduleSpecifierSourceFile);
|
|
47
|
+
const moduleSpecifier = importDeclaration.getModuleSpecifierValue();
|
|
48
|
+
if (!isBareModuleSpecifier(moduleSpecifier))
|
|
49
|
+
return [];
|
|
50
|
+
const workspaceEntrySourceFile = findWorkspacePackageEntrySourceFile(referenceNode.getSourceFile(), moduleSpecifier);
|
|
51
|
+
if (workspaceEntrySourceFile)
|
|
52
|
+
return getExportedDeclarationsForImportSpecifier(importSpecifier, workspaceEntrySourceFile);
|
|
53
|
+
const aliasedSourceFile = findRepoLocalAliasSourceFile(referenceNode.getSourceFile(), moduleSpecifier);
|
|
54
|
+
if (!aliasedSourceFile)
|
|
55
|
+
return [];
|
|
56
|
+
return getExportedDeclarationsForImportSpecifier(importSpecifier, aliasedSourceFile);
|
|
57
|
+
}
|
|
58
|
+
export { resolveImportSourcePath };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Node, type Type } from 'ts-morph';
|
|
2
|
+
export declare function kebabToPascal(input: string): string;
|
|
3
|
+
export declare function extractAllowedValues(type: Type): string[] | undefined;
|
|
4
|
+
export declare function isIntrinsicJsxElement(tagName: string): boolean;
|
|
5
|
+
export declare function getJsxTagNameNode(node: Node): Node | undefined;
|
|
6
|
+
export declare function getNodeDefinitions(node: Node): {
|
|
7
|
+
getDeclarationNode(): Node | undefined;
|
|
8
|
+
}[];
|
|
9
|
+
export declare function getTypeTargetDeclarations(targetNode: Node, allowWorkspaceImportFallback?: boolean): Node[];
|
|
10
|
+
export declare function getValueTargetDeclarations(targetNode: Node): Node[];
|
|
11
|
+
export declare function getTypeReferenceTargetNode(typeNode: Node): Node | undefined;
|
|
12
|
+
export declare function getTypeReferenceArguments(typeNode: Node): Node[];
|
|
13
|
+
export declare function getTypeReferenceName(typeNode: Node): string | undefined;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Node, SyntaxKind } from 'ts-morph';
|
|
2
|
+
import { resolveWorkspaceImportSpecifierDeclarations } from './resolve-tsx-workspace-imports.js';
|
|
3
|
+
export function kebabToPascal(input) {
|
|
4
|
+
return input
|
|
5
|
+
.split('-')
|
|
6
|
+
.filter(Boolean)
|
|
7
|
+
.map((s) => s.charAt(0).toUpperCase() + s.slice(1))
|
|
8
|
+
.join('');
|
|
9
|
+
}
|
|
10
|
+
export function extractAllowedValues(type) {
|
|
11
|
+
if (!type.isUnion())
|
|
12
|
+
return undefined;
|
|
13
|
+
const literals = type
|
|
14
|
+
.getUnionTypes()
|
|
15
|
+
.filter((t) => t.isStringLiteral())
|
|
16
|
+
.map((t) => t.getLiteralValueOrThrow());
|
|
17
|
+
return literals.length >= 2 ? literals.sort() : undefined;
|
|
18
|
+
}
|
|
19
|
+
export function isIntrinsicJsxElement(tagName) {
|
|
20
|
+
return /^[a-z][A-Za-z0-9]*$/.test(tagName);
|
|
21
|
+
}
|
|
22
|
+
export function getJsxTagNameNode(node) {
|
|
23
|
+
const openingElement = node.getFirstAncestorByKind(SyntaxKind.JsxOpeningElement);
|
|
24
|
+
const selfClosingElement = node.getFirstAncestorByKind(SyntaxKind.JsxSelfClosingElement);
|
|
25
|
+
return openingElement?.getTagNameNode() ?? selfClosingElement?.getTagNameNode();
|
|
26
|
+
}
|
|
27
|
+
export function getNodeDefinitions(node) {
|
|
28
|
+
const anyNode = node;
|
|
29
|
+
return anyNode.getDefinitions?.() ?? [];
|
|
30
|
+
}
|
|
31
|
+
export function getTypeTargetDeclarations(targetNode, allowWorkspaceImportFallback = false) {
|
|
32
|
+
return getNodeDefinitions(targetNode).flatMap((definition) => {
|
|
33
|
+
const declaration = definition.getDeclarationNode();
|
|
34
|
+
if (!declaration)
|
|
35
|
+
return [];
|
|
36
|
+
if (!allowWorkspaceImportFallback || !Node.isImportSpecifier(declaration)) {
|
|
37
|
+
return [declaration];
|
|
38
|
+
}
|
|
39
|
+
const resolvedDeclarations = resolveWorkspaceImportSpecifierDeclarations(declaration, targetNode);
|
|
40
|
+
return resolvedDeclarations.length > 0 ? resolvedDeclarations : [declaration];
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export function getValueTargetDeclarations(targetNode) {
|
|
44
|
+
return getNodeDefinitions(targetNode).flatMap((definition) => {
|
|
45
|
+
const declaration = definition.getDeclarationNode();
|
|
46
|
+
if (!declaration)
|
|
47
|
+
return [];
|
|
48
|
+
if (!Node.isImportSpecifier(declaration)) {
|
|
49
|
+
return [declaration];
|
|
50
|
+
}
|
|
51
|
+
const resolvedDeclarations = resolveWorkspaceImportSpecifierDeclarations(declaration, targetNode);
|
|
52
|
+
return resolvedDeclarations.length > 0 ? resolvedDeclarations : [declaration];
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export function getTypeReferenceTargetNode(typeNode) {
|
|
56
|
+
if (Node.isTypeReference(typeNode))
|
|
57
|
+
return typeNode.getTypeName();
|
|
58
|
+
if (Node.isExpressionWithTypeArguments(typeNode))
|
|
59
|
+
return typeNode.getExpression();
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
export function getTypeReferenceArguments(typeNode) {
|
|
63
|
+
if (Node.isTypeReference(typeNode) || Node.isExpressionWithTypeArguments(typeNode)) {
|
|
64
|
+
return typeNode.getTypeArguments();
|
|
65
|
+
}
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
export function getTypeReferenceName(typeNode) {
|
|
69
|
+
if (Node.isTypeReference(typeNode)) {
|
|
70
|
+
return typeNode.getTypeName().getText().split('.').pop();
|
|
71
|
+
}
|
|
72
|
+
if (Node.isExpressionWithTypeArguments(typeNode)) {
|
|
73
|
+
return typeNode.getExpression().getText().split('.').pop();
|
|
74
|
+
}
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Node, type SourceFile } from 'ts-morph';
|
|
2
|
+
import type { ExtractionExclusion } from '../../../types/component.js';
|
|
3
|
+
export declare function resolveDefaultExportName(declarations: Node[], exported: {
|
|
4
|
+
has(name: string): boolean;
|
|
5
|
+
}, allowVariableDeclaration?: boolean): string | undefined;
|
|
6
|
+
export declare function getRenderableExports(sourceFile: SourceFile, exclusions: ExtractionExclusion[], options: {
|
|
7
|
+
allowVariableDeclaration?: boolean;
|
|
8
|
+
hookReason: string;
|
|
9
|
+
}): Array<{
|
|
10
|
+
name: string;
|
|
11
|
+
declarations: Node[];
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Node } from 'ts-morph';
|
|
2
|
+
export function resolveDefaultExportName(declarations, exported, allowVariableDeclaration = false) {
|
|
3
|
+
const declaration = declarations[0];
|
|
4
|
+
const name = Node.isFunctionDeclaration(declaration)
|
|
5
|
+
? declaration.getName()
|
|
6
|
+
: allowVariableDeclaration && Node.isVariableDeclaration(declaration)
|
|
7
|
+
? declaration.getName()
|
|
8
|
+
: undefined;
|
|
9
|
+
if (!name || !/^[A-Z]/.test(name) || exported.has(name))
|
|
10
|
+
return undefined;
|
|
11
|
+
return name;
|
|
12
|
+
}
|
|
13
|
+
export function getRenderableExports(sourceFile, exclusions, options) {
|
|
14
|
+
const renderable = [];
|
|
15
|
+
const exported = sourceFile.getExportedDeclarations();
|
|
16
|
+
for (const [exportKey, declarations] of exported) {
|
|
17
|
+
const name = exportKey === 'default'
|
|
18
|
+
? resolveDefaultExportName(declarations, exported, options.allowVariableDeclaration)
|
|
19
|
+
: exportKey;
|
|
20
|
+
if (!name || !/^[A-Z]/.test(name))
|
|
21
|
+
continue;
|
|
22
|
+
if (name.startsWith('use')) {
|
|
23
|
+
exclusions.push({
|
|
24
|
+
itemType: 'component',
|
|
25
|
+
name,
|
|
26
|
+
source: sourceFile.getFilePath(),
|
|
27
|
+
reason: options.hookReason,
|
|
28
|
+
stage: 'component-filter',
|
|
29
|
+
});
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
renderable.push({ name, declarations });
|
|
33
|
+
}
|
|
34
|
+
return renderable;
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Project, type SourceFile } from 'ts-morph';
|
|
2
|
+
import type { ExtractionExclusion } from '../../../types/component.js';
|
|
3
|
+
export { kebabToPascal, extractAllowedValues, isIntrinsicJsxElement, getJsxTagNameNode, getNodeDefinitions, getTypeTargetDeclarations, getValueTargetDeclarations, getTypeReferenceName, } from './tsx-node-utils.js';
|
|
4
|
+
export { resolveDefaultExportName, getRenderableExports } from './tsx-renderable-exports.js';
|
|
5
|
+
export declare function getTsxExtractionContext(filePaths: string[], componentFilePattern: RegExp): {
|
|
6
|
+
componentFiles: string[];
|
|
7
|
+
project: Project;
|
|
8
|
+
} | undefined;
|
|
9
|
+
export declare function extractTsxComponents<T>(filePaths: string[], componentFilePattern: RegExp, extract: (sourceFile: SourceFile, exclusions: ExtractionExclusion[]) => T[]): {
|
|
10
|
+
components: T[];
|
|
11
|
+
warnings: string[];
|
|
12
|
+
exclusions: ExtractionExclusion[];
|
|
13
|
+
project?: Project;
|
|
14
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Project } from 'ts-morph';
|
|
2
|
+
export { kebabToPascal, extractAllowedValues, isIntrinsicJsxElement, getJsxTagNameNode, getNodeDefinitions, getTypeTargetDeclarations, getValueTargetDeclarations, getTypeReferenceName, } from './tsx-node-utils.js';
|
|
3
|
+
export { resolveDefaultExportName, getRenderableExports } from './tsx-renderable-exports.js';
|
|
4
|
+
function createTsxProject(filePaths) {
|
|
5
|
+
const project = new Project({
|
|
6
|
+
compilerOptions: {
|
|
7
|
+
jsx: 1,
|
|
8
|
+
target: 99,
|
|
9
|
+
module: 99,
|
|
10
|
+
moduleResolution: 100,
|
|
11
|
+
skipLibCheck: true,
|
|
12
|
+
allowJs: true,
|
|
13
|
+
},
|
|
14
|
+
skipAddingFilesFromTsConfig: true,
|
|
15
|
+
});
|
|
16
|
+
for (const filePath of filePaths) {
|
|
17
|
+
project.addSourceFileAtPath(filePath);
|
|
18
|
+
}
|
|
19
|
+
return project;
|
|
20
|
+
}
|
|
21
|
+
function getTsxProjectFiles(filePaths) {
|
|
22
|
+
return filePaths.filter((filePath) => /\.[jt]sx?$/.test(filePath) && !filePath.endsWith('.d.ts'));
|
|
23
|
+
}
|
|
24
|
+
export function getTsxExtractionContext(filePaths, componentFilePattern) {
|
|
25
|
+
const componentFiles = filePaths.filter((filePath) => componentFilePattern.test(filePath));
|
|
26
|
+
if (componentFiles.length === 0)
|
|
27
|
+
return undefined;
|
|
28
|
+
return {
|
|
29
|
+
componentFiles,
|
|
30
|
+
project: createTsxProject(getTsxProjectFiles(filePaths)),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function extractTsxComponents(filePaths, componentFilePattern, extract) {
|
|
34
|
+
const extractionContext = getTsxExtractionContext(filePaths, componentFilePattern);
|
|
35
|
+
if (!extractionContext) {
|
|
36
|
+
return { components: [], warnings: [], exclusions: [] };
|
|
37
|
+
}
|
|
38
|
+
const { componentFiles, project } = extractionContext;
|
|
39
|
+
const components = [];
|
|
40
|
+
const warnings = [];
|
|
41
|
+
const exclusions = [];
|
|
42
|
+
for (const filePath of componentFiles) {
|
|
43
|
+
try {
|
|
44
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
45
|
+
if (!sourceFile)
|
|
46
|
+
continue;
|
|
47
|
+
components.push(...extract(sourceFile, exclusions));
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
warnings.push(`Failed to extract from ${filePath}: ${e instanceof Error ? e.message : String(e)}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return { components, warnings, exclusions, project };
|
|
54
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ComponentExtractionResult } from '
|
|
1
|
+
import type { ComponentExtractionResult } from '../../types/component.js';
|
|
2
2
|
export declare function extractStencilComponents(filePaths: string[]): Promise<ComponentExtractionResult>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Project, Node } from 'ts-morph';
|
|
2
|
+
import { kebabToPascal } from '../shared/helpers/tsx-shared.js';
|
|
3
|
+
import { createSortedExtractionResult } from '../shared/helpers/file-processing/result-normalizer.js';
|
|
4
|
+
import { extractProjectSourceFiles } from '../shared/helpers/file-processing/project-source-files.js';
|
|
5
|
+
import { isStencilFile, readComponentTag, hasPropertyDecorator } from './helpers/detect-stencil-class.js';
|
|
6
|
+
import { extractStencilProps } from './helpers/extract-stencil-props.js';
|
|
7
|
+
import { extractStencilSlots } from './helpers/extract-stencil-slots.js';
|
|
8
|
+
function collectEventNames(classDecl) {
|
|
9
|
+
const eventNames = [];
|
|
10
|
+
for (const property of classDecl.getProperties()) {
|
|
11
|
+
if (!hasPropertyDecorator(property, 'Event'))
|
|
12
|
+
continue;
|
|
13
|
+
eventNames.push(property.getName());
|
|
14
|
+
}
|
|
15
|
+
return eventNames.sort();
|
|
16
|
+
}
|
|
17
|
+
function detectFunctionalComponents(sourceFile, warnings) {
|
|
18
|
+
for (const [exportName, declarations] of sourceFile.getExportedDeclarations()) {
|
|
19
|
+
for (const decl of declarations) {
|
|
20
|
+
if (!Node.isVariableDeclaration(decl))
|
|
21
|
+
continue;
|
|
22
|
+
const typeNode = decl.getTypeNode();
|
|
23
|
+
if (!typeNode)
|
|
24
|
+
continue;
|
|
25
|
+
if (!typeNode.getText().startsWith('FunctionalComponent'))
|
|
26
|
+
continue;
|
|
27
|
+
warnings.push(`Stencil FunctionalComponent detected but not extracted: ${exportName} in ${sourceFile.getFilePath()}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function extractFromStencilSourceFile(sourceFile, warnings) {
|
|
32
|
+
const components = [];
|
|
33
|
+
for (const classDecl of sourceFile.getClasses()) {
|
|
34
|
+
const tag = readComponentTag(classDecl);
|
|
35
|
+
if (!tag)
|
|
36
|
+
continue;
|
|
37
|
+
const name = kebabToPascal(tag);
|
|
38
|
+
const props = extractStencilProps(classDecl);
|
|
39
|
+
const slots = extractStencilSlots(classDecl, warnings, name);
|
|
40
|
+
const eventNames = collectEventNames(classDecl);
|
|
41
|
+
if (eventNames.length > 0) {
|
|
42
|
+
warnings.push(`Component ${name} has ${eventNames.length} events not captured: ${eventNames.join(', ')}`);
|
|
43
|
+
}
|
|
44
|
+
components.push({
|
|
45
|
+
name,
|
|
46
|
+
source: sourceFile.getFilePath(),
|
|
47
|
+
sourcePath: sourceFile.getFilePath(),
|
|
48
|
+
framework: 'stencil',
|
|
49
|
+
props,
|
|
50
|
+
slots,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return components;
|
|
54
|
+
}
|
|
55
|
+
export async function extractStencilComponents(filePaths) {
|
|
56
|
+
const tsxFiles = filePaths.filter((f) => /\.[jt]sx$/.test(f));
|
|
57
|
+
if (tsxFiles.length === 0) {
|
|
58
|
+
return { components: [], warnings: [] };
|
|
59
|
+
}
|
|
60
|
+
const project = new Project({
|
|
61
|
+
compilerOptions: {
|
|
62
|
+
jsx: 1, // JsxEmit.Preserve
|
|
63
|
+
target: 99, // ScriptTarget.ESNext
|
|
64
|
+
module: 99, // ModuleKind.ESNext
|
|
65
|
+
moduleResolution: 100, // ModuleResolutionKind.Bundler
|
|
66
|
+
skipLibCheck: true,
|
|
67
|
+
allowJs: true,
|
|
68
|
+
},
|
|
69
|
+
skipAddingFilesFromTsConfig: true,
|
|
70
|
+
});
|
|
71
|
+
for (const filePath of tsxFiles) {
|
|
72
|
+
project.addSourceFileAtPath(filePath);
|
|
73
|
+
}
|
|
74
|
+
const { items: components, warnings } = extractProjectSourceFiles(project, (sourceFile, sourceWarnings) => {
|
|
75
|
+
if (!isStencilFile(sourceFile))
|
|
76
|
+
return [];
|
|
77
|
+
const extracted = extractFromStencilSourceFile(sourceFile, sourceWarnings);
|
|
78
|
+
detectFunctionalComponents(sourceFile, sourceWarnings);
|
|
79
|
+
return extracted;
|
|
80
|
+
});
|
|
81
|
+
return createSortedExtractionResult(components, warnings);
|
|
82
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Node, type SourceFile, type ClassDeclaration } from 'ts-morph';
|
|
2
|
+
/** Returns true when the file imports from @stencil/core — used to skip non-Stencil files. */
|
|
3
|
+
export declare function isStencilFile(sourceFile: SourceFile): boolean;
|
|
4
|
+
/** Reads the `tag` value from the @Component({ tag: '...' }) decorator on a class. */
|
|
5
|
+
export declare function readComponentTag(classDecl: ClassDeclaration): string | undefined;
|
|
6
|
+
/** Returns true when the node is a property declaration with a given decorator name. */
|
|
7
|
+
export declare function hasPropertyDecorator(node: Node, decoratorName: string): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Node } from 'ts-morph';
|
|
2
|
+
/** Returns true when the file imports from @stencil/core — used to skip non-Stencil files. */
|
|
3
|
+
export function isStencilFile(sourceFile) {
|
|
4
|
+
return sourceFile.getImportDeclarations().some((imp) => imp.getModuleSpecifierValue() === '@stencil/core');
|
|
5
|
+
}
|
|
6
|
+
/** Reads the `tag` value from the @Component({ tag: '...' }) decorator on a class. */
|
|
7
|
+
export function readComponentTag(classDecl) {
|
|
8
|
+
for (const decorator of classDecl.getDecorators()) {
|
|
9
|
+
if (decorator.getName() !== 'Component')
|
|
10
|
+
continue;
|
|
11
|
+
const args = decorator.getArguments();
|
|
12
|
+
if (args.length === 0)
|
|
13
|
+
continue;
|
|
14
|
+
const arg = args[0];
|
|
15
|
+
if (!Node.isObjectLiteralExpression(arg))
|
|
16
|
+
continue;
|
|
17
|
+
const tagProp = arg.getProperty('tag');
|
|
18
|
+
if (!tagProp || !Node.isPropertyAssignment(tagProp))
|
|
19
|
+
continue;
|
|
20
|
+
const initializer = tagProp.getInitializer();
|
|
21
|
+
if (!initializer || !Node.isStringLiteral(initializer))
|
|
22
|
+
continue;
|
|
23
|
+
return initializer.getLiteralValue();
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
/** Returns true when the node is a property declaration with a given decorator name. */
|
|
28
|
+
export function hasPropertyDecorator(node, decoratorName) {
|
|
29
|
+
if (!Node.isPropertyDeclaration(node))
|
|
30
|
+
return false;
|
|
31
|
+
return node.getDecorators().some((d) => d.getName() === decoratorName);
|
|
32
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ClassDeclaration } from 'ts-morph';
|
|
2
|
+
import type { RawPropDefinition } from '../../../types/component.js';
|
|
3
|
+
export { parseAllowedValues, collectDomAttributePropNames } from './stencil-prop-helpers.js';
|
|
4
|
+
/** Extracts all @Prop-decorated properties from a Stencil class as RawPropDefinitions. */
|
|
5
|
+
export declare function extractStencilProps(classDecl: ClassDeclaration): RawPropDefinition[];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Node } from 'ts-morph';
|
|
2
|
+
import { hasPropertyDecorator } from './detect-stencil-class.js';
|
|
3
|
+
import { parseAllowedValues, collectDomAttributePropNames } from './stencil-prop-helpers.js';
|
|
4
|
+
export { parseAllowedValues, collectDomAttributePropNames } from './stencil-prop-helpers.js';
|
|
5
|
+
/** Extracts all @Prop-decorated properties from a Stencil class as RawPropDefinitions. */
|
|
6
|
+
export function extractStencilProps(classDecl) {
|
|
7
|
+
const props = [];
|
|
8
|
+
const propNames = new Set(classDecl
|
|
9
|
+
.getProperties()
|
|
10
|
+
.filter((property) => hasPropertyDecorator(property, 'Prop'))
|
|
11
|
+
.map((property) => property.getName()));
|
|
12
|
+
const domAttributePropNames = collectDomAttributePropNames(classDecl, propNames);
|
|
13
|
+
for (const property of classDecl.getProperties()) {
|
|
14
|
+
if (!hasPropertyDecorator(property, 'Prop'))
|
|
15
|
+
continue;
|
|
16
|
+
const name = property.getName();
|
|
17
|
+
const typeNode = property.getTypeNode();
|
|
18
|
+
const typeText = typeNode ? typeNode.getText() : 'unknown';
|
|
19
|
+
const hasQuestionToken = property.hasQuestionToken();
|
|
20
|
+
const hasExclamation = property.hasExclamationToken();
|
|
21
|
+
const initializer = property.getInitializer();
|
|
22
|
+
let defaultValue;
|
|
23
|
+
if (initializer) {
|
|
24
|
+
defaultValue = Node.isStringLiteral(initializer) ? initializer.getLiteralValue() : initializer.getText();
|
|
25
|
+
}
|
|
26
|
+
const isRequired = hasExclamation || (!hasQuestionToken && !initializer);
|
|
27
|
+
const jsDocs = property.getJsDocs();
|
|
28
|
+
let description;
|
|
29
|
+
let isDeprecated = false;
|
|
30
|
+
if (jsDocs.length > 0) {
|
|
31
|
+
const jsDoc = jsDocs[0];
|
|
32
|
+
description = jsDoc.getDescription().trim() || undefined;
|
|
33
|
+
for (const tag of jsDoc.getTags()) {
|
|
34
|
+
if (tag.getTagName() === 'deprecated') {
|
|
35
|
+
isDeprecated = true;
|
|
36
|
+
const tagComment = tag.getCommentText()?.trim();
|
|
37
|
+
if (tagComment && !description)
|
|
38
|
+
description = tagComment;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (isDeprecated && description) {
|
|
43
|
+
description = `[DEPRECATED] ${description}`;
|
|
44
|
+
}
|
|
45
|
+
else if (isDeprecated) {
|
|
46
|
+
description = '[DEPRECATED]';
|
|
47
|
+
}
|
|
48
|
+
const allowedValues = parseAllowedValues(typeText);
|
|
49
|
+
props.push({
|
|
50
|
+
name,
|
|
51
|
+
type: typeText,
|
|
52
|
+
required: isRequired,
|
|
53
|
+
...(defaultValue !== undefined && { defaultValue }),
|
|
54
|
+
...(description && { description }),
|
|
55
|
+
...(allowedValues && { allowedValues }),
|
|
56
|
+
...(domAttributePropNames.has(name) && { domAttribute: true }),
|
|
57
|
+
sourceStartLine: property.getStartLineNumber(),
|
|
58
|
+
sourceEndLine: property.getEndLineNumber(),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return props.sort((a, b) => a.name.localeCompare(b.name));
|
|
62
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ClassDeclaration } from 'ts-morph';
|
|
2
|
+
import type { RawSlotDefinition } from '../../../types/component.js';
|
|
3
|
+
/** Normalises a raw slot name string to a RawSlotDefinition, treating blank/undefined as "default". */
|
|
4
|
+
export declare function parseStencilSlot(name: string | undefined): RawSlotDefinition;
|
|
5
|
+
/** Extracts all slots from a Stencil class — via @slot JSDoc tags and template <slot> elements. */
|
|
6
|
+
export declare function extractStencilSlots(classDecl: ClassDeclaration, warnings: string[], componentName: string): RawSlotDefinition[];
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Node } from 'ts-morph';
|
|
2
|
+
import { collectJsDocSlotComments } from '../../shared/helpers/collect-jsdoc-slot-comments.js';
|
|
3
|
+
/** Normalises a raw slot name string to a RawSlotDefinition, treating blank/undefined as "default". */
|
|
4
|
+
export function parseStencilSlot(name) {
|
|
5
|
+
const normalizedName = name && name.length > 0 ? name : 'default';
|
|
6
|
+
return { name: normalizedName, isDefault: normalizedName === 'default' };
|
|
7
|
+
}
|
|
8
|
+
/** Extracts all slots from a Stencil class — via @slot JSDoc tags and template <slot> elements. */
|
|
9
|
+
export function extractStencilSlots(classDecl, warnings, componentName) {
|
|
10
|
+
const slots = new Map();
|
|
11
|
+
const upsertSlot = (slot) => {
|
|
12
|
+
const existing = slots.get(slot.name);
|
|
13
|
+
if (!existing) {
|
|
14
|
+
slots.set(slot.name, slot);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
slots.set(slot.name, {
|
|
18
|
+
...existing,
|
|
19
|
+
...slot,
|
|
20
|
+
description: existing.description ?? slot.description,
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
// JSDoc @slot tags
|
|
24
|
+
for (const comment of collectJsDocSlotComments(classDecl)) {
|
|
25
|
+
if (comment.startsWith('{')) {
|
|
26
|
+
try {
|
|
27
|
+
const parsed = JSON.parse(comment);
|
|
28
|
+
const slot = parseStencilSlot(parsed.name);
|
|
29
|
+
let description = parsed.description || undefined;
|
|
30
|
+
if (parsed.isDeprecated && description) {
|
|
31
|
+
description = `[DEPRECATED] ${description}`;
|
|
32
|
+
}
|
|
33
|
+
else if (parsed.isDeprecated) {
|
|
34
|
+
description = '[DEPRECATED]';
|
|
35
|
+
}
|
|
36
|
+
upsertSlot({ ...slot, ...(description && { description }) });
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
warnings.push(`Failed to parse @slot JSDoc in ${componentName}: invalid JSON "${comment}"`);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const match = comment.match(/^(?:(\S+)\s*-\s*)?(.*)$/s);
|
|
45
|
+
if (!match)
|
|
46
|
+
continue;
|
|
47
|
+
const [, rawName, rawDescription] = match;
|
|
48
|
+
const slot = parseStencilSlot(rawName);
|
|
49
|
+
const description = rawDescription.trim() || undefined;
|
|
50
|
+
upsertSlot({ ...slot, ...(description && { description }) });
|
|
51
|
+
}
|
|
52
|
+
// Template <slot> elements
|
|
53
|
+
for (const method of classDecl.getMethods()) {
|
|
54
|
+
method.forEachDescendant((node) => {
|
|
55
|
+
if (!Node.isJsxSelfClosingElement(node) && !Node.isJsxElement(node))
|
|
56
|
+
return;
|
|
57
|
+
const openingElement = Node.isJsxElement(node) ? node.getOpeningElement() : node;
|
|
58
|
+
const tagName = openingElement.getTagNameNode().getText();
|
|
59
|
+
const slotAttribute = openingElement
|
|
60
|
+
.getAttributes()
|
|
61
|
+
.find((attribute) => Node.isJsxAttribute(attribute) && attribute.getNameNode().getText() === 'slot');
|
|
62
|
+
if (tagName === 'slot') {
|
|
63
|
+
const nameAttribute = openingElement
|
|
64
|
+
.getAttributes()
|
|
65
|
+
.find((attribute) => Node.isJsxAttribute(attribute) && attribute.getNameNode().getText() === 'name');
|
|
66
|
+
const initializer = Node.isJsxAttribute(nameAttribute) ? nameAttribute.getInitializer() : undefined;
|
|
67
|
+
const name = initializer && Node.isStringLiteral(initializer)
|
|
68
|
+
? initializer.getLiteralValue()
|
|
69
|
+
: initializer && Node.isJsxExpression(initializer)
|
|
70
|
+
? (initializer.getExpression()?.getText() ?? '')
|
|
71
|
+
: '';
|
|
72
|
+
upsertSlot({ ...parseStencilSlot(name) });
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!Node.isJsxAttribute(slotAttribute))
|
|
76
|
+
return;
|
|
77
|
+
const initializer = slotAttribute.getInitializer();
|
|
78
|
+
if (!initializer || !Node.isStringLiteral(initializer))
|
|
79
|
+
return;
|
|
80
|
+
const name = initializer.getLiteralValue();
|
|
81
|
+
if (!name)
|
|
82
|
+
return;
|
|
83
|
+
upsertSlot({ name, isDefault: false });
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return [...slots.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
87
|
+
}
|