@contentful/experience-design-system-extraction 2.34.5-dev-build-4a4b9e84.0 → 2.34.5-dev-build-9dff4380.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.
Files changed (88) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/extract/{adapters/astro/extractor.d.ts → astro.d.ts} +1 -1
  3. package/dist/src/extract/{adapters/astro/extractor.js → astro.js} +3 -4
  4. package/dist/src/extract/{adapters/support/file-processing/file-workers.d.ts → file-extraction-workers.d.ts} +13 -1
  5. package/dist/src/extract/{adapters/support/file-processing/file-workers.js → file-extraction-workers.js} +19 -0
  6. package/dist/src/extract/{policies/quality/authorability.d.ts → non-authorable-filter.d.ts} +1 -1
  7. package/dist/src/extract/pipeline.d.ts +7 -0
  8. package/dist/src/extract/{services/component-deduplicator.js → pipeline.js} +137 -13
  9. package/dist/src/extract/{adapters/react/extractor.d.ts → react.d.ts} +1 -1
  10. package/dist/src/extract/{adapters/react/extractor.js → react.js} +353 -9
  11. package/dist/src/extract/scoring.d.ts +12 -0
  12. package/dist/src/extract/{policies/quality/scoring.js → scoring.js} +0 -1
  13. package/dist/src/extract/{policies/quality/source-inspection.d.ts → source-inspection.d.ts} +1 -1
  14. package/dist/src/extract/{policies/quality/source-inspection.js → source-inspection.js} +1 -1
  15. package/dist/src/extract/{adapters/support/resolution/source-location.d.ts → source-line-metadata.d.ts} +1 -1
  16. package/dist/src/extract/{adapters/stencil/extractor.d.ts → stencil.d.ts} +1 -1
  17. package/dist/src/extract/{adapters/stencil/extractor.js → stencil.js} +2 -3
  18. package/dist/src/extract/{evidence/structural-slot-evidence.d.ts → structural-slot-evidence.d.ts} +1 -1
  19. package/dist/src/extract/{evidence/structural-slot-evidence.js → structural-slot-evidence.js} +2 -2
  20. package/dist/src/extract/{adapters/svelte/extractor.d.ts → svelte.d.ts} +1 -2
  21. package/dist/src/extract/{adapters/svelte/extractor.js → svelte.js} +91 -7
  22. package/dist/src/extract/{adapters/support/tsx-shared.d.ts → tsx-shared.d.ts} +1 -1
  23. package/dist/src/extract/{policies/quality/validation.d.ts → validate.d.ts} +1 -1
  24. package/dist/src/extract/{adapters/vue-tsx/extractor.d.ts → vue-tsx.d.ts} +1 -1
  25. package/dist/src/extract/{adapters/vue-tsx/extractor.js → vue-tsx.js} +1 -1
  26. package/dist/src/extract/{adapters/vue/extractor.d.ts → vue.d.ts} +1 -1
  27. package/dist/src/extract/{adapters/vue/extractor.js → vue.js} +3 -4
  28. package/dist/src/extract/{adapters/web-components/extractor.d.ts → web-components.d.ts} +1 -1
  29. package/dist/src/extract/{adapters/web-components/extractor.js → web-components.js} +213 -4
  30. package/dist/src/index.d.ts +21 -25
  31. package/dist/src/index.js +17 -18
  32. package/dist/src/{extract/services/classification-service.d.ts → pre-classify.d.ts} +1 -1
  33. package/dist/src/{extract/model/component.d.ts → types.d.ts} +20 -0
  34. package/package.json +1 -1
  35. package/dist/src/extract/adapters/react/function-resolution.d.ts +0 -4
  36. package/dist/src/extract/adapters/react/function-resolution.js +0 -131
  37. package/dist/src/extract/adapters/react/prop-dataflow.d.ts +0 -14
  38. package/dist/src/extract/adapters/react/prop-dataflow.js +0 -220
  39. package/dist/src/extract/adapters/support/file-processing/project-source-files.d.ts +0 -5
  40. package/dist/src/extract/adapters/support/file-processing/project-source-files.js +0 -13
  41. package/dist/src/extract/adapters/support/file-processing/result-normalizer.d.ts +0 -6
  42. package/dist/src/extract/adapters/support/file-processing/result-normalizer.js +0 -6
  43. package/dist/src/extract/adapters/svelte/ast.d.ts +0 -12
  44. package/dist/src/extract/adapters/svelte/ast.js +0 -1
  45. package/dist/src/extract/adapters/svelte/identity.d.ts +0 -1
  46. package/dist/src/extract/adapters/svelte/identity.js +0 -26
  47. package/dist/src/extract/adapters/svelte/slots.d.ts +0 -7
  48. package/dist/src/extract/adapters/svelte/slots.js +0 -63
  49. package/dist/src/extract/adapters/web-components/properties.d.ts +0 -9
  50. package/dist/src/extract/adapters/web-components/properties.js +0 -212
  51. package/dist/src/extract/controller/extract-controller.d.ts +0 -10
  52. package/dist/src/extract/controller/extract-controller.js +0 -56
  53. package/dist/src/extract/model/contract.d.ts +0 -16
  54. package/dist/src/extract/model/contract.js +0 -1
  55. package/dist/src/extract/model/options.d.ts +0 -15
  56. package/dist/src/extract/model/options.js +0 -1
  57. package/dist/src/extract/model/scoring.d.ts +0 -9
  58. package/dist/src/extract/model/scoring.js +0 -1
  59. package/dist/src/extract/policies/quality/scoring.d.ts +0 -5
  60. package/dist/src/extract/services/component-deduplicator.d.ts +0 -2
  61. package/dist/src/extract/services/extraction-pipeline.d.ts +0 -3
  62. package/dist/src/extract/services/extraction-pipeline.js +0 -43
  63. package/dist/src/extract/services/extraction-runner.d.ts +0 -4
  64. package/dist/src/extract/services/extraction-runner.js +0 -21
  65. package/dist/src/extract/services/extraction-service.d.ts +0 -13
  66. package/dist/src/extract/services/extraction-service.js +0 -17
  67. package/dist/src/extract/services/extractor-registry.d.ts +0 -8
  68. package/dist/src/extract/services/extractor-registry.js +0 -68
  69. package/dist/src/extract/services/ports/component-extractor.d.ts +0 -7
  70. package/dist/src/extract/services/ports/component-extractor.js +0 -1
  71. package/dist/src/extract/services/quality-service.d.ts +0 -4
  72. package/dist/src/extract/services/quality-service.js +0 -61
  73. /package/dist/src/extract/{policies/quality/authorability.js → non-authorable-filter.js} +0 -0
  74. /package/dist/src/extract/{evidence/source-evidence.d.ts → parse-imported-names.d.ts} +0 -0
  75. /package/dist/src/extract/{evidence/source-evidence.js → parse-imported-names.js} +0 -0
  76. /package/dist/src/extract/{adapters/support/resolution/local-module.d.ts → resolve-local-module.d.ts} +0 -0
  77. /package/dist/src/extract/{adapters/support/resolution/local-module.js → resolve-local-module.js} +0 -0
  78. /package/dist/src/extract/{adapters/support/resolution/type-property.d.ts → resolve-type-property.d.ts} +0 -0
  79. /package/dist/src/extract/{adapters/support/resolution/type-property.js → resolve-type-property.js} +0 -0
  80. /package/dist/src/extract/{evidence/allowed-components.d.ts → slot-allowed-components.d.ts} +0 -0
  81. /package/dist/src/extract/{evidence/allowed-components.js → slot-allowed-components.js} +0 -0
  82. /package/dist/src/extract/{evidence/slot-evidence.d.ts → slot-detection.d.ts} +0 -0
  83. /package/dist/src/extract/{evidence/slot-evidence.js → slot-detection.js} +0 -0
  84. /package/dist/src/extract/{adapters/support/resolution/source-location.js → source-line-metadata.js} +0 -0
  85. /package/dist/src/extract/{adapters/support/tsx-shared.js → tsx-shared.js} +0 -0
  86. /package/dist/src/extract/{policies/quality/validation.js → validate.js} +0 -0
  87. /package/dist/src/{extract/services/classification-service.js → pre-classify.js} +0 -0
  88. /package/dist/src/{extract/model/component.js → types.js} +0 -0
@@ -1,16 +0,0 @@
1
- import type { RawComponentDefinition } from './component.js';
2
- import type { ExtractorOptions } from './options.js';
3
- export type ExtractionEndpointProgress = {
4
- phase: 'extract';
5
- filesProcessed: number;
6
- totalFiles: number;
7
- componentsFound: number;
8
- };
9
- export interface ExtractionEndpointRequest extends ExtractorOptions {
10
- readonly filePaths: readonly string[];
11
- onProgress?: (progress: ExtractionEndpointProgress) => void;
12
- }
13
- export interface ExtractionEndpointResponse {
14
- components: RawComponentDefinition[];
15
- warnings: string[];
16
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- /**
2
- * Optional extraction-time settings forwarded from the CLI through the
3
- * pipeline to each extractor. Only the Svelte extractor currently consumes
4
- * any of these; other extractors ignore the value.
5
- */
6
- export interface ExtractorOptions {
7
- /**
8
- * Whether the Svelte extractor should run a retry pass for components whose
9
- * declared Props type could not be resolved on the first pass (cross-package
10
- * extends, path-alias-only types, etc.). See svelte.ts for the policy.
11
- */
12
- resolveUnreachable?: 'auto' | 'always' | 'never';
13
- /** Absolute project root — used by the retry pass to locate tsconfig.json and node_modules. */
14
- projectRoot?: string;
15
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- export type ExtractionConfidence = 1 | 2 | 3 | 4 | 5;
2
- export type ExtractionScore = {
3
- confidence: ExtractionConfidence;
4
- reasons: string[];
5
- };
6
- export interface ExtractionScoreOptions {
7
- additionalIssueCount?: number;
8
- additionalReasons?: string[];
9
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import type { RawComponentDefinition } from '../../model/component.js';
2
- import type { ExtractionConfidence, ExtractionScore, ExtractionScoreOptions } from '../../model/scoring.js';
3
- export type { ExtractionConfidence, ExtractionScore, ExtractionScoreOptions } from '../../model/scoring.js';
4
- export declare function computeExtractionScore(component: RawComponentDefinition, options?: ExtractionScoreOptions): ExtractionScore;
5
- export declare function deriveNeedsReview(confidence: ExtractionConfidence): boolean;
@@ -1,2 +0,0 @@
1
- import type { ComponentExtractionResult } from '../model/component.js';
2
- export declare function deduplicateComponents(results: readonly ComponentExtractionResult[]): ComponentExtractionResult;
@@ -1,3 +0,0 @@
1
- import type { ComponentExtractionResult, ExtractorProgress } from '../model/component.js';
2
- import type { ExtractorOptions } from '../model/options.js';
3
- export declare function extractComponents(filePaths: string[], onProgress?: (progress: ExtractorProgress) => void, opts?: ExtractorOptions): Promise<ComponentExtractionResult>;
@@ -1,43 +0,0 @@
1
- import { deduplicateComponents } from './component-deduplicator.js';
2
- import { extractorRegistry, routeFilesToExtractors } from './extractor-registry.js';
3
- import { runExtractorBatches } from './extraction-runner.js';
4
- export async function extractComponents(filePaths, onProgress, opts) {
5
- const exclusions = filePaths.flatMap((filePath) => {
6
- if (!filePath.endsWith('.svelte'))
7
- return [];
8
- const name = filePath.replace(/\\/g, '/').split('/').pop() ?? '';
9
- if (!/^\+(page|layout|error)\.svelte$/.test(name))
10
- return [];
11
- return [
12
- {
13
- itemType: 'file',
14
- name,
15
- source: filePath,
16
- reason: 'SvelteKit route entrypoints are framework-managed, not authorable components',
17
- stage: 'file-filter',
18
- },
19
- ];
20
- });
21
- const routedFiles = routeFilesToExtractors(filePaths, extractorRegistry);
22
- const results = await runExtractorBatches(routedFiles, onProgress, opts);
23
- const deduplicated = deduplicateComponents(results);
24
- const components = deduplicated.components.filter((component) => {
25
- if (!/^use[A-Z]/.test(component.name))
26
- return true;
27
- deduplicated.warnings.push(`Skipped hook: ${component.name} (hooks are not renderable components)`);
28
- exclusions.push({
29
- itemType: 'component',
30
- name: component.name,
31
- source: component.source,
32
- reason: 'Hook names are not renderable components',
33
- stage: 'component-filter',
34
- });
35
- return false;
36
- });
37
- const allExclusions = [...exclusions, ...(deduplicated.exclusions ?? [])];
38
- return {
39
- components,
40
- warnings: deduplicated.warnings,
41
- ...(allExclusions.length > 0 ? { exclusions: allExclusions } : {}),
42
- };
43
- }
@@ -1,4 +0,0 @@
1
- import type { ComponentExtractionResult, ExtractorProgress } from '../model/component.js';
2
- import type { ExtractorOptions } from '../model/options.js';
3
- import type { ExtractorFileGroup } from './extractor-registry.js';
4
- export declare function runExtractorBatches(batches: readonly ExtractorFileGroup[], onProgress?: (progress: ExtractorProgress) => void, options?: ExtractorOptions): Promise<ComponentExtractionResult[]>;
@@ -1,21 +0,0 @@
1
- export async function runExtractorBatches(batches, onProgress, options) {
2
- const perExtractorFiles = new Map();
3
- const perExtractorComponents = new Map();
4
- let totalFilesProcessed = 0;
5
- let totalComponentsFound = 0;
6
- return Promise.all(batches.map(async ({ extractor, filePaths }) => {
7
- if (filePaths.length === 0)
8
- return { components: [], warnings: [] };
9
- perExtractorFiles.set(extractor, 0);
10
- perExtractorComponents.set(extractor, 0);
11
- return extractor.extract(filePaths, (progress) => {
12
- const previousFiles = perExtractorFiles.get(extractor) ?? 0;
13
- const previousComponents = perExtractorComponents.get(extractor) ?? 0;
14
- totalFilesProcessed += progress.filesProcessed - previousFiles;
15
- totalComponentsFound += progress.componentsFound - previousComponents;
16
- perExtractorFiles.set(extractor, progress.filesProcessed);
17
- perExtractorComponents.set(extractor, progress.componentsFound);
18
- onProgress?.({ filesProcessed: totalFilesProcessed, componentsFound: totalComponentsFound });
19
- }, options);
20
- }));
21
- }
@@ -1,13 +0,0 @@
1
- import type { ExtractorProgress } from '../model/component.js';
2
- import type { ExtractionEndpointResponse } from '../model/contract.js';
3
- import type { ExtractorOptions } from '../model/options.js';
4
- export interface ExtractionServiceRequest extends ExtractorOptions {
5
- readonly filePaths: readonly string[];
6
- onProgress?: (progress: ExtractorProgress) => void;
7
- }
8
- /**
9
- * Executes the extraction use case after the controller has validated the
10
- * public request. This service owns extraction-time classification, inspection,
11
- * quality signals, scoring, and validation, but not transport or persistence.
12
- */
13
- export declare function runExtractionService(request: ExtractionServiceRequest): Promise<ExtractionEndpointResponse>;
@@ -1,17 +0,0 @@
1
- import { extractComponents } from './extraction-pipeline.js';
2
- import { preClassifyComponent } from './classification-service.js';
3
- import { evaluateExtractionQuality } from './quality-service.js';
4
- /**
5
- * Executes the extraction use case after the controller has validated the
6
- * public request. This service owns extraction-time classification, inspection,
7
- * quality signals, scoring, and validation, but not transport or persistence.
8
- */
9
- export async function runExtractionService(request) {
10
- const filePaths = [...request.filePaths];
11
- const extraction = await extractComponents(filePaths, request.onProgress, {
12
- ...(request.resolveUnreachable !== undefined ? { resolveUnreachable: request.resolveUnreachable } : {}),
13
- ...(request.projectRoot !== undefined ? { projectRoot: request.projectRoot } : {}),
14
- });
15
- const classifiedComponents = extraction.components.map(preClassifyComponent);
16
- return evaluateExtractionQuality(classifiedComponents, extraction.warnings);
17
- }
@@ -1,8 +0,0 @@
1
- import type { ComponentExtractor } from './ports/component-extractor.js';
2
- export interface ExtractorFileGroup {
3
- extractor: ComponentExtractor;
4
- filePaths: string[];
5
- }
6
- /** Ordered adapter registration; overlapping filters intentionally allow a file to be inspected by multiple adapters. */
7
- export declare const extractorRegistry: readonly ComponentExtractor[];
8
- export declare function routeFilesToExtractors(filePaths: readonly string[], extractors?: readonly ComponentExtractor[]): ExtractorFileGroup[];
@@ -1,68 +0,0 @@
1
- import { extractAstroComponents } from '../adapters/astro/extractor.js';
2
- import { extractReactComponents } from '../adapters/react/extractor.js';
3
- import { extractStencilComponents } from '../adapters/stencil/extractor.js';
4
- import { extractSvelteComponents } from '../adapters/svelte/extractor.js';
5
- import { extractVueTsxComponents } from '../adapters/vue-tsx/extractor.js';
6
- import { extractVueComponents } from '../adapters/vue/extractor.js';
7
- import { extractWebComponentDefinitions } from '../adapters/web-components/extractor.js';
8
- /** Ordered adapter registration; overlapping filters intentionally allow a file to be inspected by multiple adapters. */
9
- export const extractorRegistry = [
10
- {
11
- name: 'stencil',
12
- fileFilter: (filePath) => /\.[jt]sx$/.test(filePath),
13
- extract: extractStencilComponents,
14
- },
15
- {
16
- name: 'react',
17
- fileFilter: (filePath) => /\.[jt]sx?$/.test(filePath) && !filePath.endsWith('.d.ts'),
18
- extract: extractReactComponents,
19
- },
20
- {
21
- name: 'vue-tsx',
22
- fileFilter: (filePath) => /\.[jt]sx?$/.test(filePath) && !filePath.endsWith('.d.ts'),
23
- extract: extractVueTsxComponents,
24
- },
25
- {
26
- name: 'vue',
27
- fileFilter: (filePath) => filePath.endsWith('.vue'),
28
- extract: extractVueComponents,
29
- },
30
- {
31
- name: 'astro',
32
- fileFilter: (filePath) => filePath.endsWith('.astro'),
33
- extract: extractAstroComponents,
34
- },
35
- {
36
- name: 'web-components',
37
- fileFilter: (filePath) => /\.[jt]s$/.test(filePath) && !/\.[jt]sx$/.test(filePath) && !filePath.endsWith('.d.ts'),
38
- extract: extractWebComponentDefinitions,
39
- },
40
- {
41
- name: 'svelte',
42
- fileFilter: (filePath) => {
43
- if (!filePath.endsWith('.svelte'))
44
- return false;
45
- const filename = filePath.replace(/\\/g, '/').split('/').pop() ?? '';
46
- if (/^\+(page|layout|error)\.svelte$/.test(filename))
47
- return false;
48
- return true;
49
- },
50
- extract: extractSvelteComponents,
51
- },
52
- ];
53
- export function routeFilesToExtractors(filePaths, extractors = extractorRegistry) {
54
- const filesByExtractor = new Map();
55
- for (const extractor of extractors) {
56
- filesByExtractor.set(extractor, []);
57
- }
58
- for (const filePath of filePaths) {
59
- for (const extractor of extractors) {
60
- if (extractor.fileFilter(filePath)) {
61
- filesByExtractor.get(extractor)?.push(filePath);
62
- }
63
- }
64
- }
65
- return extractors
66
- .map((extractor) => ({ extractor, filePaths: filesByExtractor.get(extractor) ?? [] }))
67
- .filter(({ filePaths: groupedFilePaths }) => groupedFilePaths.length > 0);
68
- }
@@ -1,7 +0,0 @@
1
- import type { ComponentExtractionResult, ExtractorProgress } from '../../model/component.js';
2
- import type { ExtractorOptions } from '../../model/options.js';
3
- export interface ComponentExtractor {
4
- name: string;
5
- fileFilter: (filePath: string) => boolean;
6
- extract(filePaths: string[], onProgress?: (progress: ExtractorProgress) => void, options?: ExtractorOptions): Promise<ComponentExtractionResult>;
7
- }
@@ -1,4 +0,0 @@
1
- import type { RawComponentDefinition } from '../model/component.js';
2
- import type { ExtractionEndpointResponse } from '../model/contract.js';
3
- /** Applies inspection, authorability, scoring, review, and validation policies to extracted models. */
4
- export declare function evaluateExtractionQuality(components: readonly RawComponentDefinition[], initialWarnings?: readonly string[]): Promise<ExtractionEndpointResponse>;
@@ -1,61 +0,0 @@
1
- import { isNonAuthorableComponent } from '../policies/quality/authorability.js';
2
- import { computeExtractionScore, deriveNeedsReview } from '../policies/quality/scoring.js';
3
- import { inspectComponentSource, describeReviewReasons } from '../policies/quality/source-inspection.js';
4
- import { validateExtractedComponents } from '../policies/quality/validation.js';
5
- function wrapperConfidenceToIssueCount(confidence) {
6
- if (confidence >= 4)
7
- return 2;
8
- if (confidence === 3)
9
- return 1;
10
- return 0;
11
- }
12
- /** Applies inspection, authorability, scoring, review, and validation policies to extracted models. */
13
- export async function evaluateExtractionQuality(components, initialWarnings = []) {
14
- const inspectedComponents = await Promise.all(components.map(async (component) => ({
15
- component,
16
- inspection: await inspectComponentSource(component),
17
- })));
18
- const scoredComponents = [];
19
- const warnings = [...initialWarnings];
20
- for (const { component, inspection } of inspectedComponents) {
21
- const verdict = isNonAuthorableComponent(component);
22
- const keepDespiteZeroSurface = verdict.skip && verdict.reason === 'component has no props and no slots' && inspection.keepDespiteZeroSurface;
23
- const retainedForReview = verdict.skip && !keepDespiteZeroSurface;
24
- if (retainedForReview) {
25
- warnings.push(`${component.name}: requires operator review (${verdict.reason})`);
26
- }
27
- if (keepDespiteZeroSurface) {
28
- warnings.push(`${component.name}: retained despite 0 props/slots because the source renders visible or compositional UI`);
29
- }
30
- if (inspection.reviewReasons.length > 0) {
31
- const reviewNotes = describeReviewReasons(inspection.reviewReasons)
32
- .filter((note) => note !== 'high-confidence data-fetch wrapper')
33
- .join('; ');
34
- if (reviewNotes)
35
- warnings.push(`${component.name}: ${reviewNotes}`);
36
- }
37
- const extractorReasons = component.reviewReasons ?? [];
38
- const nonAuthorableReason = retainedForReview ? [`non-authorable:${verdict.reason}`] : [];
39
- const { confidence, reasons } = computeExtractionScore(component, {
40
- additionalIssueCount: wrapperConfidenceToIssueCount(inspection.wrapperConfidence) +
41
- extractorReasons.length +
42
- nonAuthorableReason.length,
43
- additionalReasons: [...extractorReasons, ...inspection.reviewReasons, ...nonAuthorableReason],
44
- });
45
- scoredComponents.push({
46
- ...component,
47
- extractionConfidence: confidence,
48
- reviewReasons: reasons,
49
- needsReview: deriveNeedsReview(confidence) ||
50
- inspection.wrapperConfidence >= 4 ||
51
- inspection.keepDespiteZeroSurface ||
52
- retainedForReview ||
53
- extractorReasons.includes('props-type-unresolved') ||
54
- (component.needsReview ?? false),
55
- });
56
- }
57
- return {
58
- components: validateExtractedComponents(scoredComponents),
59
- warnings,
60
- };
61
- }