@component-compass/parser-react 0.0.0-pr-3-8916f3c-20260507145532
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/README.md +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/walk-jsx.d.ts +17 -0
- package/dist/walk-jsx.js +429 -0
- package/dist/walk-jsx.js.map +1 -0
- package/package.json +49 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { walkJsx } from "./walk-jsx.js";
|
|
2
|
+
export const reactPlugin = {
|
|
3
|
+
name: "react",
|
|
4
|
+
extensions: [".tsx", ".jsx", ".ts", ".js"],
|
|
5
|
+
parse(file, source, ctx) {
|
|
6
|
+
return walkJsx({
|
|
7
|
+
file,
|
|
8
|
+
source,
|
|
9
|
+
index: ctx.index,
|
|
10
|
+
captureValues: ctx.config.captureValues,
|
|
11
|
+
packageScopes: ctx.config.packageScopes,
|
|
12
|
+
repoRoot: ctx.repoRoot,
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,MAAM,WAAW,GAAiB;IACvC,IAAI,EAAE,OAAO;IACb,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC;IAC1C,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;QACrB,OAAO,OAAO,CAAC;YACb,IAAI;YACJ,MAAM;YACN,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,aAAa;YACvC,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,aAAa;YACvC,QAAQ,EAAE,GAAG,CAAC,QAAQ;SACvB,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComponentIndex, Occurrence, FileImport, WrapperDef, Warning } from "@component-compass/plugin-core";
|
|
2
|
+
type WalkOptions = {
|
|
3
|
+
file: string;
|
|
4
|
+
source: string;
|
|
5
|
+
index: ComponentIndex;
|
|
6
|
+
captureValues: boolean;
|
|
7
|
+
packageScopes: string[];
|
|
8
|
+
repoRoot: string;
|
|
9
|
+
};
|
|
10
|
+
export type WalkOutput = {
|
|
11
|
+
occurrences: Occurrence[];
|
|
12
|
+
wrappers: WrapperDef[];
|
|
13
|
+
imports: FileImport[];
|
|
14
|
+
warnings: Warning[];
|
|
15
|
+
};
|
|
16
|
+
export declare function walkJsx(opts: WalkOptions): WalkOutput;
|
|
17
|
+
export {};
|
package/dist/walk-jsx.js
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import { parse } from "@babel/parser";
|
|
2
|
+
import picomatch from "picomatch";
|
|
3
|
+
import { serialiseComponentId, externalPackageOf } from "@component-compass/plugin-core";
|
|
4
|
+
import { asTagName, asWrapperId } from "@component-compass/plugin-core";
|
|
5
|
+
import { traverse, posixPath, classifyImportOrigin } from "@component-compass/ast-utils";
|
|
6
|
+
// `errorRecovery: true` only handles a narrow band of recoverable parse errors;
|
|
7
|
+
// unrecoverable syntax errors still throw synchronously. Callers must wrap
|
|
8
|
+
// invocations in try/catch and convert thrown errors into PARSE_FAILURE warnings.
|
|
9
|
+
export function walkJsx(opts) {
|
|
10
|
+
const ast = parse(opts.source, {
|
|
11
|
+
sourceType: "module",
|
|
12
|
+
plugins: ["typescript", "jsx", "decorators-legacy", "classProperties"],
|
|
13
|
+
errorRecovery: true,
|
|
14
|
+
});
|
|
15
|
+
const occurrences = [];
|
|
16
|
+
const wrappers = [];
|
|
17
|
+
const imports = [];
|
|
18
|
+
const warnings = [];
|
|
19
|
+
const recovered = ast.errors ?? [];
|
|
20
|
+
for (const err of recovered) {
|
|
21
|
+
warnings.push({
|
|
22
|
+
code: "PARSE_FAILURE",
|
|
23
|
+
message: `Recovered parse error: ${err.message}`,
|
|
24
|
+
file: opts.file,
|
|
25
|
+
// line: 0 means "unknown" when Babel didn't supply a location.
|
|
26
|
+
line: typeof err.loc?.line === "number" ? err.loc.line : 0,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const localBindings = new Map();
|
|
30
|
+
// Tracks imports that did NOT match a manifest entry: local → { importedName, specifier }.
|
|
31
|
+
// Used in the third pass to opportunistically classify and emit external occurrences.
|
|
32
|
+
const unmappedImports = new Map();
|
|
33
|
+
// First pass: collect imports and resolve to known tags / react-component entries.
|
|
34
|
+
traverse(ast, {
|
|
35
|
+
ImportDeclaration(path) {
|
|
36
|
+
const source = path.node.source.value;
|
|
37
|
+
for (const spec of path.node.specifiers) {
|
|
38
|
+
if (spec.type !== "ImportSpecifier" && spec.type !== "ImportDefaultSpecifier")
|
|
39
|
+
continue;
|
|
40
|
+
const imported = spec.type === "ImportSpecifier" ? identName(spec.imported) : "default";
|
|
41
|
+
const local = spec.local.name;
|
|
42
|
+
const wrapperKey = `${source}::${imported}`;
|
|
43
|
+
const indexed = opts.index.byImport.get(wrapperKey);
|
|
44
|
+
if (indexed?.kind === "custom-element") {
|
|
45
|
+
localBindings.set(local, {
|
|
46
|
+
kind: "wc-wrapper",
|
|
47
|
+
tagName: asTagName(indexed.tagName),
|
|
48
|
+
package: externalPackageOf(indexed.source),
|
|
49
|
+
specifier: source,
|
|
50
|
+
importName: imported,
|
|
51
|
+
viaHeuristic: false,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else if (indexed?.kind === "react-component") {
|
|
55
|
+
localBindings.set(local, {
|
|
56
|
+
kind: "react-direct",
|
|
57
|
+
package: externalPackageOf(indexed.source),
|
|
58
|
+
export: indexed.export,
|
|
59
|
+
specifier: source,
|
|
60
|
+
importName: imported,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// Heuristic: source matches one of the configured packageScopes (glob patterns),
|
|
65
|
+
// and the imported name matches a className in the index. WC-only fallback.
|
|
66
|
+
const heuristicTag = heuristicMatch(source, imported, opts.index, opts.packageScopes);
|
|
67
|
+
if (heuristicTag) {
|
|
68
|
+
const indexedHeur = opts.index.byTag.get(heuristicTag);
|
|
69
|
+
if (indexedHeur) {
|
|
70
|
+
localBindings.set(local, {
|
|
71
|
+
kind: "wc-wrapper",
|
|
72
|
+
tagName: heuristicTag,
|
|
73
|
+
package: externalPackageOf(indexedHeur.source),
|
|
74
|
+
specifier: source,
|
|
75
|
+
importName: imported,
|
|
76
|
+
viaHeuristic: true,
|
|
77
|
+
});
|
|
78
|
+
warnings.push({
|
|
79
|
+
code: "MISSING_REACT_EXPORT_EXTENSION",
|
|
80
|
+
message: `Heuristic match for ${imported} from ${source}; resolved to <${heuristicTag}>. Recommend publishing componentCompass.imports.react in the manifest.`,
|
|
81
|
+
file: opts.file,
|
|
82
|
+
package: source,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// Heuristic found a tag but it's not in byTag — treat as unmapped.
|
|
87
|
+
unmappedImports.set(local, { importedName: imported, specifier: source });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// No manifest match, no heuristic match — track for opportunistic classification.
|
|
92
|
+
unmappedImports.set(local, { importedName: imported, specifier: source });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
imports.push({ file: posixPath(opts.file), imported: local, source, loc: locOf(spec, opts.file) });
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
// Second pass: detect wrapper definitions.
|
|
100
|
+
traverse(ast, {
|
|
101
|
+
Function(path) {
|
|
102
|
+
detectWrapper(path, opts.file, localBindings, opts.index, wrappers);
|
|
103
|
+
},
|
|
104
|
+
ClassDeclaration(path) {
|
|
105
|
+
detectWrapper(path, opts.file, localBindings, opts.index, wrappers);
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
traverse(ast, {
|
|
109
|
+
JSXOpeningElement(path) {
|
|
110
|
+
const nameNode = path.node.name;
|
|
111
|
+
let resolved;
|
|
112
|
+
if (nameNode.type === "JSXIdentifier") {
|
|
113
|
+
const id = nameNode.name;
|
|
114
|
+
if (/^[a-z]/.test(id) && id.includes("-")) {
|
|
115
|
+
const indexed = opts.index.byTag.get(asTagName(id));
|
|
116
|
+
if (indexed) {
|
|
117
|
+
resolved = { kind: "wc-tag", tagName: asTagName(id), package: externalPackageOf(indexed.source) };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
const bound = localBindings.get(id);
|
|
122
|
+
if (bound?.kind === "wc-wrapper") {
|
|
123
|
+
resolved = {
|
|
124
|
+
kind: "wc-wrapper",
|
|
125
|
+
tagName: bound.tagName,
|
|
126
|
+
package: bound.package,
|
|
127
|
+
specifier: bound.specifier,
|
|
128
|
+
importName: bound.importName,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
else if (bound?.kind === "react-direct") {
|
|
132
|
+
resolved = {
|
|
133
|
+
kind: "react-direct",
|
|
134
|
+
package: bound.package,
|
|
135
|
+
export: bound.export,
|
|
136
|
+
specifier: bound.specifier,
|
|
137
|
+
importName: bound.importName,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
// Opportunistic emission: classify unmapped imports and emit for external ones.
|
|
142
|
+
const unmapped = unmappedImports.get(id);
|
|
143
|
+
if (unmapped) {
|
|
144
|
+
const origin = classifyImportOrigin(unmapped.specifier, {
|
|
145
|
+
repoRoot: opts.repoRoot,
|
|
146
|
+
fromFile: opts.file,
|
|
147
|
+
});
|
|
148
|
+
if (origin.type === "external") {
|
|
149
|
+
const { props, events } = readJsxAttrs(path.node, opts.captureValues);
|
|
150
|
+
const loc = locOf(path.node, opts.file);
|
|
151
|
+
const occurrence = {
|
|
152
|
+
componentId: {
|
|
153
|
+
kind: "react-component",
|
|
154
|
+
export: unmapped.importedName,
|
|
155
|
+
source: { type: "external", package: origin.package },
|
|
156
|
+
},
|
|
157
|
+
loc,
|
|
158
|
+
via: { kind: "direct-import", specifier: unmapped.specifier, import: unmapped.importedName },
|
|
159
|
+
props,
|
|
160
|
+
events,
|
|
161
|
+
};
|
|
162
|
+
occurrences.push(occurrence);
|
|
163
|
+
}
|
|
164
|
+
else if (origin.type === "local") {
|
|
165
|
+
// Look up the local-component definition by repo-relative path,
|
|
166
|
+
// then match the imported binding (default vs named) against
|
|
167
|
+
// a recorded LocalDefinition. Misses skip silently — this avoids
|
|
168
|
+
// mis-emitting identities for local utilities, hooks, or
|
|
169
|
+
// re-exports that don't have a detector match.
|
|
170
|
+
const localDefs = opts.index.local.byPath.get(origin.filePath);
|
|
171
|
+
const matched = localDefs?.find((d) => unmapped.importedName === "default"
|
|
172
|
+
? d.isDefault
|
|
173
|
+
: d.exportName === unmapped.importedName && !d.isDefault);
|
|
174
|
+
if (matched && matched.componentId.kind === "react-component") {
|
|
175
|
+
const { props, events } = readJsxAttrs(path.node, opts.captureValues);
|
|
176
|
+
const loc = locOf(path.node, opts.file);
|
|
177
|
+
const occurrence = {
|
|
178
|
+
componentId: matched.componentId,
|
|
179
|
+
loc,
|
|
180
|
+
via: { kind: "direct-import", specifier: unmapped.specifier, import: unmapped.importedName },
|
|
181
|
+
props,
|
|
182
|
+
events,
|
|
183
|
+
};
|
|
184
|
+
occurrences.push(occurrence);
|
|
185
|
+
}
|
|
186
|
+
// Miss → skip silently.
|
|
187
|
+
}
|
|
188
|
+
// unresolved → skip silently
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (!resolved)
|
|
194
|
+
return;
|
|
195
|
+
const { props, events } = readJsxAttrs(path.node, opts.captureValues);
|
|
196
|
+
const loc = locOf(path.node, opts.file);
|
|
197
|
+
let occurrence;
|
|
198
|
+
if (resolved.kind === "wc-tag") {
|
|
199
|
+
occurrence = {
|
|
200
|
+
componentId: { kind: "custom-element", tagName: resolved.tagName, source: { type: "external", package: resolved.package } },
|
|
201
|
+
loc,
|
|
202
|
+
via: { kind: "html-tag" },
|
|
203
|
+
props,
|
|
204
|
+
events,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
else if (resolved.kind === "wc-wrapper") {
|
|
208
|
+
occurrence = {
|
|
209
|
+
componentId: { kind: "custom-element", tagName: resolved.tagName, source: { type: "external", package: resolved.package } },
|
|
210
|
+
loc,
|
|
211
|
+
via: { kind: "react-wrapper", specifier: resolved.specifier, import: resolved.importName },
|
|
212
|
+
props,
|
|
213
|
+
events,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
occurrence = {
|
|
218
|
+
componentId: { kind: "react-component", export: resolved.export, source: { type: "external", package: resolved.package } },
|
|
219
|
+
loc,
|
|
220
|
+
via: { kind: "direct-import", specifier: resolved.specifier, import: resolved.importName },
|
|
221
|
+
props,
|
|
222
|
+
events,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
occurrences.push(occurrence);
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
return { occurrences, wrappers, imports, warnings };
|
|
229
|
+
}
|
|
230
|
+
function locOf(node, file) {
|
|
231
|
+
return {
|
|
232
|
+
file: posixPath(file),
|
|
233
|
+
line: node.loc?.start?.line ?? 1,
|
|
234
|
+
column: (node.loc?.start?.column ?? 0) + 1,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function identName(node) {
|
|
238
|
+
return node.type === "Identifier" ? node.name : node.value;
|
|
239
|
+
}
|
|
240
|
+
function heuristicMatch(source, imported, index, packageScopes) {
|
|
241
|
+
const matchesScope = packageScopes.some((pattern) => {
|
|
242
|
+
if (!/^[@a-zA-Z*]/.test(pattern))
|
|
243
|
+
return false;
|
|
244
|
+
return picomatch.isMatch(source, pattern) ||
|
|
245
|
+
picomatch.isMatch(source, `${pattern}/**`);
|
|
246
|
+
});
|
|
247
|
+
if (!matchesScope)
|
|
248
|
+
return undefined;
|
|
249
|
+
for (const def of index.byTag.values()) {
|
|
250
|
+
if (def.className === imported)
|
|
251
|
+
return asTagName(def.tagName);
|
|
252
|
+
}
|
|
253
|
+
return undefined;
|
|
254
|
+
}
|
|
255
|
+
function readJsxAttrs(node, captureValues) {
|
|
256
|
+
const props = [];
|
|
257
|
+
const events = [];
|
|
258
|
+
for (const attr of node.attributes) {
|
|
259
|
+
// Spread attributes (`{...rest}`) are recorded as a single sentinel prop
|
|
260
|
+
// so consumers can distinguish "we don't know what props were passed" from
|
|
261
|
+
// "no props passed". Spec §3.4 — three-state prop tracking.
|
|
262
|
+
if (attr.type === "JSXSpreadAttribute") {
|
|
263
|
+
if (props.some((p) => p.name === "...rest"))
|
|
264
|
+
continue;
|
|
265
|
+
props.push({ name: "...rest", isDynamic: true, dynamicKind: "spread" });
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
if (attr.type !== "JSXAttribute")
|
|
269
|
+
continue;
|
|
270
|
+
const name = attr.name.type === "JSXIdentifier" ? attr.name.name : "";
|
|
271
|
+
if (!name)
|
|
272
|
+
continue;
|
|
273
|
+
// React event handlers are conventionally `on<Event>` props on the JSX side.
|
|
274
|
+
if (name.startsWith("on") && name.length > 2 && /[A-Z]/.test(name.charAt(2))) {
|
|
275
|
+
events.push(name.slice(2).toLowerCase());
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (!attr.value) {
|
|
279
|
+
// Boolean shorthand `<Foo bar />` → literal `true`.
|
|
280
|
+
const usage = { name, isDynamic: false };
|
|
281
|
+
if (captureValues)
|
|
282
|
+
usage.literalValue = true;
|
|
283
|
+
props.push(usage);
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
if (attr.value.type === "StringLiteral") {
|
|
287
|
+
const usage = { name, isDynamic: false };
|
|
288
|
+
if (captureValues)
|
|
289
|
+
usage.literalValue = attr.value.value;
|
|
290
|
+
props.push(usage);
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (attr.value.type === "JSXExpressionContainer") {
|
|
294
|
+
const expr = attr.value.expression;
|
|
295
|
+
if (expr.type === "StringLiteral") {
|
|
296
|
+
const usage = { name, isDynamic: false };
|
|
297
|
+
if (captureValues)
|
|
298
|
+
usage.literalValue = expr.value;
|
|
299
|
+
props.push(usage);
|
|
300
|
+
}
|
|
301
|
+
else if (expr.type === "NumericLiteral") {
|
|
302
|
+
const usage = { name, isDynamic: false };
|
|
303
|
+
if (captureValues)
|
|
304
|
+
usage.literalValue = expr.value;
|
|
305
|
+
props.push(usage);
|
|
306
|
+
}
|
|
307
|
+
else if (expr.type === "BooleanLiteral") {
|
|
308
|
+
const usage = { name, isDynamic: false };
|
|
309
|
+
if (captureValues)
|
|
310
|
+
usage.literalValue = expr.value;
|
|
311
|
+
props.push(usage);
|
|
312
|
+
}
|
|
313
|
+
else if (expr.type === "Identifier") {
|
|
314
|
+
props.push({ name, isDynamic: true, dynamicKind: "identifier" });
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
props.push({ name, isDynamic: true, dynamicKind: "expr" });
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return { props, events };
|
|
322
|
+
}
|
|
323
|
+
function detectWrapper(path, file, localBindings, index, wrappers) {
|
|
324
|
+
const name = wrapperName(path);
|
|
325
|
+
if (!name)
|
|
326
|
+
return;
|
|
327
|
+
if (!/^[A-Z]/.test(name))
|
|
328
|
+
return;
|
|
329
|
+
const seen = new Set();
|
|
330
|
+
const deps = [];
|
|
331
|
+
function addDep(cid) {
|
|
332
|
+
const key = serialiseComponentId(cid);
|
|
333
|
+
if (!seen.has(key)) {
|
|
334
|
+
seen.add(key);
|
|
335
|
+
deps.push(cid);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
path.traverse({
|
|
339
|
+
JSXOpeningElement(inner) {
|
|
340
|
+
const n = inner.node.name;
|
|
341
|
+
if (n.type !== "JSXIdentifier")
|
|
342
|
+
return;
|
|
343
|
+
const id = n.name;
|
|
344
|
+
if (/^[a-z]/.test(id) && id.includes("-")) {
|
|
345
|
+
const indexed = index.byTag.get(asTagName(id));
|
|
346
|
+
if (indexed) {
|
|
347
|
+
addDep({
|
|
348
|
+
kind: "custom-element",
|
|
349
|
+
tagName: asTagName(id),
|
|
350
|
+
source: { type: "external", package: externalPackageOf(indexed.source) },
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
const bound = localBindings.get(id);
|
|
356
|
+
// Only WC-wrapper bindings count as wrapper component-deps; React-direct
|
|
357
|
+
// bindings refer to other React components, which are not WC-wrappers.
|
|
358
|
+
if (bound && bound.kind === "wc-wrapper") {
|
|
359
|
+
addDep({
|
|
360
|
+
kind: "custom-element",
|
|
361
|
+
tagName: bound.tagName,
|
|
362
|
+
source: { type: "external", package: bound.package },
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
});
|
|
367
|
+
if (deps.length === 0)
|
|
368
|
+
return;
|
|
369
|
+
const id = wrapperId(name);
|
|
370
|
+
wrappers.push({
|
|
371
|
+
id,
|
|
372
|
+
name,
|
|
373
|
+
file: posixPath(file),
|
|
374
|
+
exportName: detectExportName(path, name),
|
|
375
|
+
componentDeps: deps,
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
function wrapperName(path) {
|
|
379
|
+
const node = path.node;
|
|
380
|
+
if (node.type === "FunctionDeclaration" && node.id)
|
|
381
|
+
return node.id.name;
|
|
382
|
+
if (node.type === "ClassDeclaration" && node.id)
|
|
383
|
+
return node.id.name;
|
|
384
|
+
if (path.parent.type === "VariableDeclarator" && path.parent.id.type === "Identifier") {
|
|
385
|
+
return path.parent.id.name;
|
|
386
|
+
}
|
|
387
|
+
return undefined;
|
|
388
|
+
}
|
|
389
|
+
function detectExportName(path, declName) {
|
|
390
|
+
// Direct containment: declaration is itself part of an export statement.
|
|
391
|
+
let p = path;
|
|
392
|
+
while (p) {
|
|
393
|
+
if (p.parent && p.parent.type === "ExportDefaultDeclaration")
|
|
394
|
+
return "default";
|
|
395
|
+
if (p.parent && p.parent.type === "ExportNamedDeclaration")
|
|
396
|
+
return declName;
|
|
397
|
+
p = p.parentPath;
|
|
398
|
+
}
|
|
399
|
+
// Indirect: a separate `export default Foo;` or `export { Foo as Bar };` references
|
|
400
|
+
// this declaration by name. Scan the top-level program body.
|
|
401
|
+
const program = path.findParent((parent) => parent.isProgram());
|
|
402
|
+
if (program?.isProgram()) {
|
|
403
|
+
for (const stmt of program.node.body) {
|
|
404
|
+
if (stmt.type === "ExportDefaultDeclaration" &&
|
|
405
|
+
stmt.declaration.type === "Identifier" &&
|
|
406
|
+
stmt.declaration.name === declName) {
|
|
407
|
+
return "default";
|
|
408
|
+
}
|
|
409
|
+
if (stmt.type === "ExportNamedDeclaration" && !stmt.declaration) {
|
|
410
|
+
for (const spec of stmt.specifiers) {
|
|
411
|
+
if (spec.type !== "ExportSpecifier")
|
|
412
|
+
continue;
|
|
413
|
+
if (spec.local.name !== declName)
|
|
414
|
+
continue;
|
|
415
|
+
if (spec.exported.type === "Identifier" && spec.exported.name === "default") {
|
|
416
|
+
return "default";
|
|
417
|
+
}
|
|
418
|
+
return declName;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return declName;
|
|
424
|
+
}
|
|
425
|
+
function wrapperId(name) {
|
|
426
|
+
const kebab = name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
427
|
+
return asWrapperId(`wrap-${kebab}`);
|
|
428
|
+
}
|
|
429
|
+
//# sourceMappingURL=walk-jsx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk-jsx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AAI,KAAK,QAAQ;wBAAE,SAAS;oBAC3C,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;wBAC5E,OAAO,SAAS,CAAC;oBACnB,CAAC;oBACD,OAAO,QAAQ,CAAC;gBAClB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IACxE,OAAO,WAAW,CAAC,QAAQ,KAAK,EAAE,CAAC,CAAC;AACtC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@component-compass/parser-react",
|
|
3
|
+
"version": "0.0.0-pr-3-8916f3c-20260507145532",
|
|
4
|
+
"description": "Consumer-scan parser for React JSX. Detects component usages in .tsx and .jsx files.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"componentCompass": {
|
|
10
|
+
"kind": "parser"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.json",
|
|
24
|
+
"test": "vitest run --passWithNoTests",
|
|
25
|
+
"typecheck": "tsc --noEmit",
|
|
26
|
+
"lint": "biome lint src tests",
|
|
27
|
+
"clean": "rm -rf dist .turbo"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@babel/parser": "^7.29.0",
|
|
31
|
+
"@babel/types": "^7.29.0",
|
|
32
|
+
"@component-compass/ast-utils": "0.0.0-pr-3-8916f3c-20260507145532",
|
|
33
|
+
"@component-compass/plugin-core": "0.0.0-pr-3-8916f3c-20260507145532",
|
|
34
|
+
"picomatch": "^4.0.4"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/babel__traverse": "^7.28.0",
|
|
38
|
+
"@types/node": "^24.0.0",
|
|
39
|
+
"@types/picomatch": "^4.0.3",
|
|
40
|
+
"typescript": "^5.9.0",
|
|
41
|
+
"vitest": "^4.0.0"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=24"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
}
|
|
49
|
+
}
|