@contentful/experience-design-system-extraction 2.33.1-dev-build-3d84cf3.0 → 2.33.1-dev-build-c4ed223.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/astro.js +40 -102
- package/dist/src/extract/file-extraction-workers.d.ts +25 -0
- package/dist/src/extract/file-extraction-workers.js +48 -0
- package/dist/src/extract/non-authorable-filter.d.ts +2 -1
- package/dist/src/extract/parse-imported-names.d.ts +1 -0
- package/dist/src/extract/parse-imported-names.js +27 -0
- package/dist/src/extract/pipeline.d.ts +2 -1
- package/dist/src/extract/react.js +156 -392
- package/dist/src/extract/resolve-local-module.d.ts +3 -0
- package/dist/src/extract/resolve-local-module.js +26 -0
- package/dist/src/extract/resolve-type-property.d.ts +16 -0
- package/dist/src/extract/resolve-type-property.js +11 -0
- package/dist/src/extract/slot-detection.js +11 -14
- package/dist/src/extract/source-inspection.js +1 -27
- package/dist/src/extract/source-line-metadata.d.ts +3 -0
- package/dist/src/extract/source-line-metadata.js +13 -0
- package/dist/src/extract/stencil.js +10 -26
- package/dist/src/extract/svelte.js +11 -58
- package/dist/src/extract/tsx-shared.d.ts +9 -1
- package/dist/src/extract/tsx-shared.js +48 -1
- package/dist/src/extract/validate.d.ts +4 -1
- package/dist/src/extract/validate.js +10 -5
- package/dist/src/extract/vue-tsx.js +20 -43
- package/dist/src/extract/vue.js +17 -64
- package/dist/src/extract/web-components.js +26 -39
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +2 -1
- package/package.json +1 -1
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
2
2
|
import { Project, Node, SyntaxKind } from 'ts-morph';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
.split('-')
|
|
6
|
-
.filter(Boolean)
|
|
7
|
-
.map((s) => s.charAt(0).toUpperCase() + s.slice(1))
|
|
8
|
-
.join('');
|
|
9
|
-
}
|
|
3
|
+
import { createSortedExtractionResult, extractProjectSourceFiles } from './file-extraction-workers.js';
|
|
4
|
+
import { kebabToPascal } from './tsx-shared.js';
|
|
10
5
|
function normalizeComponentName(input) {
|
|
11
6
|
return input.replace(/[^a-zA-Z0-9]/g, '').toLowerCase();
|
|
12
7
|
}
|
|
@@ -70,6 +65,21 @@ function loadSourceFile(project, filePath) {
|
|
|
70
65
|
return null;
|
|
71
66
|
}
|
|
72
67
|
}
|
|
68
|
+
function resolveImportSpecifierSource(declarationNode, sourceFile, project) {
|
|
69
|
+
if (!Node.isImportSpecifier(declarationNode))
|
|
70
|
+
return undefined;
|
|
71
|
+
const importDecl = declarationNode.getImportDeclaration();
|
|
72
|
+
const resolvedImportPath = resolveImportSourcePath(sourceFile.getFilePath(), importDecl.getModuleSpecifierValue());
|
|
73
|
+
if (!resolvedImportPath)
|
|
74
|
+
return undefined;
|
|
75
|
+
const importedFile = loadSourceFile(project, resolvedImportPath);
|
|
76
|
+
if (!importedFile)
|
|
77
|
+
return undefined;
|
|
78
|
+
return {
|
|
79
|
+
sourceFile: importedFile,
|
|
80
|
+
importedName: declarationNode.getNameNode().getText(),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
73
83
|
function resolveStaticStringExpression(node, sourceFile, project) {
|
|
74
84
|
if (!node)
|
|
75
85
|
return null;
|
|
@@ -98,18 +108,13 @@ function resolveStaticStringExpression(node, sourceFile, project) {
|
|
|
98
108
|
return resolved;
|
|
99
109
|
}
|
|
100
110
|
if (Node.isImportSpecifier(declarationNode)) {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
if (!resolvedImportPath)
|
|
104
|
-
continue;
|
|
105
|
-
const importedFile = loadSourceFile(project, resolvedImportPath);
|
|
106
|
-
if (!importedFile)
|
|
111
|
+
const importedSource = resolveImportSpecifierSource(declarationNode, sourceFile, project);
|
|
112
|
+
if (!importedSource)
|
|
107
113
|
continue;
|
|
108
|
-
const
|
|
109
|
-
const importedDeclaration = importedFile.getVariableDeclaration(importedName);
|
|
114
|
+
const importedDeclaration = importedSource.sourceFile.getVariableDeclaration(importedSource.importedName);
|
|
110
115
|
if (!importedDeclaration)
|
|
111
116
|
continue;
|
|
112
|
-
const resolved = resolveStaticStringExpression(importedDeclaration.getInitializer(),
|
|
117
|
+
const resolved = resolveStaticStringExpression(importedDeclaration.getInitializer(), importedSource.sourceFile, project);
|
|
113
118
|
if (resolved)
|
|
114
119
|
return resolved;
|
|
115
120
|
}
|
|
@@ -134,15 +139,10 @@ function resolveStaticStringExpression(node, sourceFile, project) {
|
|
|
134
139
|
variableDeclaration = declarationNode;
|
|
135
140
|
}
|
|
136
141
|
else if (Node.isImportSpecifier(declarationNode)) {
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
if (!resolvedImportPath)
|
|
140
|
-
continue;
|
|
141
|
-
const importedFile = loadSourceFile(project, resolvedImportPath);
|
|
142
|
-
if (!importedFile)
|
|
142
|
+
const importedSource = resolveImportSpecifierSource(declarationNode, sourceFile, project);
|
|
143
|
+
if (!importedSource)
|
|
143
144
|
continue;
|
|
144
|
-
|
|
145
|
-
variableDeclaration = importedFile.getVariableDeclaration(importedName);
|
|
145
|
+
variableDeclaration = importedSource.sourceFile.getVariableDeclaration(importedSource.importedName);
|
|
146
146
|
}
|
|
147
147
|
if (!variableDeclaration)
|
|
148
148
|
continue;
|
|
@@ -858,19 +858,6 @@ export async function extractWebComponentDefinitions(filePaths) {
|
|
|
858
858
|
for (const filePath of tsFiles) {
|
|
859
859
|
project.addSourceFileAtPath(filePath);
|
|
860
860
|
}
|
|
861
|
-
const warnings =
|
|
862
|
-
|
|
863
|
-
for (const sourceFile of project.getSourceFiles()) {
|
|
864
|
-
try {
|
|
865
|
-
const extracted = extractFromSourceFile(sourceFile, project);
|
|
866
|
-
components.push(...extracted);
|
|
867
|
-
}
|
|
868
|
-
catch (e) {
|
|
869
|
-
warnings.push(`Failed to extract from ${sourceFile.getFilePath()}: ${e instanceof Error ? e.message : String(e)}`);
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
return {
|
|
873
|
-
components: components.sort((a, b) => a.name.localeCompare(b.name)),
|
|
874
|
-
warnings,
|
|
875
|
-
};
|
|
861
|
+
const { items: components, warnings } = extractProjectSourceFiles(project, (sourceFile) => extractFromSourceFile(sourceFile, project));
|
|
862
|
+
return createSortedExtractionResult(components, warnings);
|
|
876
863
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ export { computeExtractionScore, deriveNeedsReview } from './extract/scoring.js'
|
|
|
14
14
|
export type { ExtractionScore, ExtractionScoreOptions, ExtractionConfidence } from './extract/scoring.js';
|
|
15
15
|
export { inspectComponentSource, describeReviewReasons, describeReviewReason, isDataWrapperReviewReason, HIGH_CONFIDENCE_DATA_FETCH_WRAPPER_REASON, POSSIBLE_DATA_FETCH_WRAPPER_REASON, ZERO_SURFACE_RENDERED_UI_REASON, } from './extract/source-inspection.js';
|
|
16
16
|
export type { ComponentSourceInspection } from './extract/source-inspection.js';
|
|
17
|
-
export { validateExtractedComponents, shouldExcludeDueToValidation, formatExclusionWarning, } from './extract/validate.js';
|
|
17
|
+
export { validateExtractedComponents, shouldExcludeDueToValidation, formatExclusionWarning, formatExcludedComponentLines, } from './extract/validate.js';
|
|
18
|
+
export { parseImportedNames } from './extract/parse-imported-names.js';
|
|
18
19
|
export { CONTENT_NAME_EXCEPTIONS, isReactNodeType, isArrayReactNodeType, shouldBeSlot, } from './extract/slot-detection.js';
|
|
19
20
|
export { preClassifyProp, preClassifyComponent } from './pre-classify.js';
|
|
20
21
|
export type { PreClassification } from './pre-classify.js';
|
package/dist/src/index.js
CHANGED
|
@@ -15,7 +15,8 @@ export { isNonAuthorableComponent } from './extract/non-authorable-filter.js';
|
|
|
15
15
|
export { computeExtractionScore, deriveNeedsReview } from './extract/scoring.js';
|
|
16
16
|
export { inspectComponentSource, describeReviewReasons, describeReviewReason, isDataWrapperReviewReason, HIGH_CONFIDENCE_DATA_FETCH_WRAPPER_REASON, POSSIBLE_DATA_FETCH_WRAPPER_REASON, ZERO_SURFACE_RENDERED_UI_REASON, } from './extract/source-inspection.js';
|
|
17
17
|
// Validation
|
|
18
|
-
export { validateExtractedComponents, shouldExcludeDueToValidation, formatExclusionWarning, } from './extract/validate.js';
|
|
18
|
+
export { validateExtractedComponents, shouldExcludeDueToValidation, formatExclusionWarning, formatExcludedComponentLines, } from './extract/validate.js';
|
|
19
|
+
export { parseImportedNames } from './extract/parse-imported-names.js';
|
|
19
20
|
// Slot detection helpers
|
|
20
21
|
export { CONTENT_NAME_EXCEPTIONS, isReactNodeType, isArrayReactNodeType, shouldBeSlot, } from './extract/slot-detection.js';
|
|
21
22
|
// Pre-classification
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experience-design-system-extraction",
|
|
3
|
-
"version": "2.33.1-dev-build-
|
|
3
|
+
"version": "2.33.1-dev-build-c4ed223.0",
|
|
4
4
|
"description": "Component extraction engine for the Contentful Experience Design System SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|