@component-compass/cli 0.0.1 → 0.0.3
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 +1 -1
- package/dist/cli.js +12 -4
- package/dist/cli.js.map +1 -1
- package/dist/commands/init.d.ts +3 -2
- package/dist/commands/init.js +50 -62
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/no-deps-diagnostic.d.ts +15 -0
- package/dist/commands/no-deps-diagnostic.js +23 -0
- package/dist/commands/no-deps-diagnostic.js.map +1 -0
- package/dist/commands/scan.d.ts +1 -0
- package/dist/commands/scan.js +126 -82
- package/dist/commands/scan.js.map +1 -1
- package/dist/composition-rollup.d.ts +23 -0
- package/dist/composition-rollup.js +64 -0
- package/dist/composition-rollup.js.map +1 -0
- package/dist/config/loader.js +5 -3
- package/dist/config/loader.js.map +1 -1
- package/dist/config/schema.d.ts +1 -2
- package/dist/config/schema.js.map +1 -1
- package/dist/identity.d.ts +21 -3
- package/dist/identity.js +40 -3
- package/dist/identity.js.map +1 -1
- package/dist/local-index/detect-react.js +224 -47
- package/dist/local-index/detect-react.js.map +1 -1
- package/dist/local-index/index.d.ts +4 -1
- package/dist/local-index/index.js +30 -13
- package/dist/local-index/index.js.map +1 -1
- package/dist/manifest/barrel-parser.d.ts +20 -0
- package/dist/manifest/barrel-parser.js +101 -16
- package/dist/manifest/barrel-parser.js.map +1 -1
- package/dist/manifest/derived-manifest-stub.d.ts +9 -0
- package/dist/manifest/derived-manifest-stub.js +11 -0
- package/dist/manifest/derived-manifest-stub.js.map +1 -0
- package/dist/manifest/diagnostic-filter.d.ts +13 -0
- package/dist/manifest/diagnostic-filter.js +36 -0
- package/dist/manifest/diagnostic-filter.js.map +1 -0
- package/dist/manifest/lazy-resolver.d.ts +44 -0
- package/dist/manifest/lazy-resolver.js +532 -0
- package/dist/manifest/lazy-resolver.js.map +1 -0
- package/dist/occurrences.d.ts +17 -0
- package/dist/occurrences.js +97 -0
- package/dist/occurrences.js.map +1 -0
- package/dist/reporter/index.d.ts +47 -9
- package/dist/reporter/index.js +167 -17
- package/dist/reporter/index.js.map +1 -1
- package/dist/reporter/json.d.ts +6 -2
- package/dist/reporter/json.js +7 -3
- package/dist/reporter/json.js.map +1 -1
- package/dist/reporter/stdout.d.ts +2 -2
- package/dist/reporter/stdout.js +11 -23
- package/dist/reporter/stdout.js.map +1 -1
- package/dist/rollup.d.ts +8 -2
- package/dist/rollup.js +2 -3
- package/dist/rollup.js.map +1 -1
- package/dist/seeds.d.ts +41 -0
- package/dist/seeds.js +145 -0
- package/dist/seeds.js.map +1 -0
- package/dist/types.d.ts +0 -1
- package/dist/workspace/build-graph.d.ts +2 -0
- package/dist/workspace/build-graph.js +117 -0
- package/dist/workspace/build-graph.js.map +1 -0
- package/dist/workspace/declared-deps.d.ts +5 -0
- package/dist/workspace/declared-deps.js +42 -0
- package/dist/workspace/declared-deps.js.map +1 -0
- package/dist/workspace/find-owning-package.d.ts +2 -0
- package/dist/workspace/find-owning-package.js +49 -0
- package/dist/workspace/find-owning-package.js.map +1 -0
- package/dist/workspace/index.d.ts +4 -0
- package/dist/workspace/index.js +4 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/types.d.ts +46 -0
- package/dist/workspace/types.js +13 -0
- package/dist/workspace/types.js.map +1 -0
- package/package.json +11 -9
- package/schema/config.schema.json +2 -10
- package/dist/graph/builder.d.ts +0 -25
- package/dist/graph/builder.js +0 -176
- package/dist/graph/builder.js.map +0 -1
- package/dist/manifest/discovery.d.ts +0 -24
- package/dist/manifest/discovery.js +0 -194
- package/dist/manifest/discovery.js.map +0 -1
- package/dist/manifest/index.d.ts +0 -6
- package/dist/manifest/index.js +0 -98
- package/dist/manifest/index.js.map +0 -1
- package/dist/manifest/resolver.d.ts +0 -30
- package/dist/manifest/resolver.js +0 -136
- package/dist/manifest/resolver.js.map +0 -1
- package/dist/manifest/run-discovery.d.ts +0 -12
- package/dist/manifest/run-discovery.js +0 -46
- package/dist/manifest/run-discovery.js.map +0 -1
- package/dist/manifest/types.d.ts +0 -3
- package/dist/manifest/types.js +0 -2
- package/dist/manifest/types.js.map +0 -1
- package/dist/reporter/types.d.ts +0 -69
- package/dist/reporter/types.js +0 -2
- package/dist/reporter/types.js.map +0 -1
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { dirname, join, resolve as pathResolve } from "node:path";
|
|
4
|
+
import { validateManifest, createDiagnosticCollector, } from "@component-compass/plugin-core";
|
|
5
|
+
import { parseBarrelTopLevelDetailed } from "./barrel-parser.js";
|
|
6
|
+
import { extractDerivedManifest as extractDerivedManifestStub } from "./derived-manifest-stub.js";
|
|
7
|
+
import { findOwningPackage } from "../workspace/find-owning-package.js";
|
|
8
|
+
/**
|
|
9
|
+
* Hard ceiling on re-export hops a single resolution may walk. Real chains
|
|
10
|
+
* top out around 10 hops (deep barrel piles); 32 is a pathological-input
|
|
11
|
+
* safety net. When this fires we emit a `chain-too-deep` diagnostic and
|
|
12
|
+
* treat the current file as terminal so the user sees a signal rather than
|
|
13
|
+
* a silent wrong-leaf attribution.
|
|
14
|
+
*/
|
|
15
|
+
const MAX_REEXPORT_HOPS = 32;
|
|
16
|
+
export function createLazyResolver(opts) {
|
|
17
|
+
const { resolveImport } = opts;
|
|
18
|
+
const extractDerived = opts.extractDerivedManifest ?? extractDerivedManifestStub;
|
|
19
|
+
// (absoluteFilePath::exportName) → cached hit (or null for negative cache).
|
|
20
|
+
const hitCache = new Map();
|
|
21
|
+
// tagName → custom-element entry (populated as authored manifests load).
|
|
22
|
+
const byTag = new Map();
|
|
23
|
+
// Leaf packages whose authored manifest has been loaded.
|
|
24
|
+
const visitedLeafs = new Map();
|
|
25
|
+
const collector = opts.collector ?? createDiagnosticCollector();
|
|
26
|
+
function loadLeafManifest(leafPackage, leafDir) {
|
|
27
|
+
const cached = visitedLeafs.get(leafPackage);
|
|
28
|
+
if (cached)
|
|
29
|
+
return cached.components;
|
|
30
|
+
const cemPath = join(leafDir, "custom-elements.json");
|
|
31
|
+
const ccmPath = join(leafDir, "component-compass-manifest.json");
|
|
32
|
+
let components = [];
|
|
33
|
+
let manifestPath = null;
|
|
34
|
+
let manifestSource = null;
|
|
35
|
+
let pkgVersion;
|
|
36
|
+
try {
|
|
37
|
+
const raw = readFileSync(join(leafDir, "package.json"), "utf8");
|
|
38
|
+
const pkg = JSON.parse(raw);
|
|
39
|
+
pkgVersion = pkg.version;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// Best-effort; leave undefined.
|
|
43
|
+
}
|
|
44
|
+
if (existsSync(cemPath)) {
|
|
45
|
+
try {
|
|
46
|
+
const raw = readFileSync(cemPath, "utf8");
|
|
47
|
+
const cem = JSON.parse(raw);
|
|
48
|
+
components = absorbCemDeclarations(cem, leafPackage);
|
|
49
|
+
manifestPath = cemPath;
|
|
50
|
+
manifestSource = "cem";
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Treat malformed CEM as no manifest.
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (existsSync(ccmPath)) {
|
|
57
|
+
try {
|
|
58
|
+
const raw = readFileSync(ccmPath, "utf8");
|
|
59
|
+
const parsed = JSON.parse(raw);
|
|
60
|
+
const v = validateManifest(parsed);
|
|
61
|
+
if (v.ok) {
|
|
62
|
+
components = absorbCcmComponents(v.data, leafPackage);
|
|
63
|
+
manifestPath = ccmPath;
|
|
64
|
+
manifestSource = v.data.source;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Treat malformed CCM as no manifest.
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (!manifestPath || !manifestSource) {
|
|
72
|
+
// No authored manifest — try derived (Phase 4 hook).
|
|
73
|
+
const derived = extractDerived(leafDir);
|
|
74
|
+
if (derived) {
|
|
75
|
+
components = derived.components;
|
|
76
|
+
for (const c of components) {
|
|
77
|
+
if (c.kind === "custom-element")
|
|
78
|
+
byTag.set(c.tagName, c);
|
|
79
|
+
}
|
|
80
|
+
// `path: ""` filters this entry out of `snapshotManifestRefs()`. The
|
|
81
|
+
// resolver-internal `source` is `ManifestSource` ("cem" | "react" |
|
|
82
|
+
// "vue"); "react" is a placeholder here — the artifact-facing
|
|
83
|
+
// distinction between authored and derived is carried by
|
|
84
|
+
// `OutputManifest.source` (added in Task 8), not this internal field.
|
|
85
|
+
visitedLeafs.set(leafPackage, {
|
|
86
|
+
components,
|
|
87
|
+
manifestRef: { source: "react", package: leafPackage, path: "", version: pkgVersion ?? null },
|
|
88
|
+
});
|
|
89
|
+
return components;
|
|
90
|
+
}
|
|
91
|
+
visitedLeafs.set(leafPackage, {
|
|
92
|
+
components: [],
|
|
93
|
+
manifestRef: { source: "cem", package: leafPackage, path: "", version: pkgVersion ?? null },
|
|
94
|
+
});
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
// Index custom elements by tagName.
|
|
98
|
+
for (const c of components) {
|
|
99
|
+
if (c.kind === "custom-element")
|
|
100
|
+
byTag.set(c.tagName, c);
|
|
101
|
+
}
|
|
102
|
+
visitedLeafs.set(leafPackage, {
|
|
103
|
+
components,
|
|
104
|
+
manifestRef: {
|
|
105
|
+
source: manifestSource,
|
|
106
|
+
package: leafPackage,
|
|
107
|
+
path: manifestPath,
|
|
108
|
+
version: pkgVersion ?? null,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
return components;
|
|
112
|
+
}
|
|
113
|
+
function findPackageRoot(absFile) {
|
|
114
|
+
let dir = dirname(absFile);
|
|
115
|
+
while (dir !== dirname(dir)) {
|
|
116
|
+
const pkgJson = join(dir, "package.json");
|
|
117
|
+
if (existsSync(pkgJson)) {
|
|
118
|
+
try {
|
|
119
|
+
const pkg = JSON.parse(readFileSync(pkgJson, "utf8"));
|
|
120
|
+
if (pkg.name)
|
|
121
|
+
return { name: pkg.name, dir };
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
// Continue walking if unreadable.
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
dir = dirname(dir);
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
function matchInLeaf(components, chainSpecifiers, exportName) {
|
|
132
|
+
// First pass: explicit imports.react[] match (strongest signal).
|
|
133
|
+
for (const c of components) {
|
|
134
|
+
if (c.kind === "custom-element") {
|
|
135
|
+
const imports = c.imports?.react ?? [];
|
|
136
|
+
for (const i of imports) {
|
|
137
|
+
if (i.export !== exportName)
|
|
138
|
+
continue;
|
|
139
|
+
// Match if any specifier in the chain equals i.specifier (or stripped form).
|
|
140
|
+
const stripped = i.specifier.replace(/\.(js|mjs|cjs)$/, "");
|
|
141
|
+
if (chainSpecifiers.some((s) => s === i.specifier || s === stripped))
|
|
142
|
+
return c;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else if (c.kind === "react-component" || c.kind === "vue-component") {
|
|
146
|
+
if (c.export === exportName)
|
|
147
|
+
return c;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// Second pass: className-equality fallback for CEMs that don't declare
|
|
151
|
+
// componentCompass.imports.react[]. Scoped to THIS leaf only — never
|
|
152
|
+
// iterates a global byTag map (the old heuristic's failure mode). Safe
|
|
153
|
+
// because the resolver has already traversed the chain to a specific
|
|
154
|
+
// leaf package; if that leaf's CEM declares a custom-element class with
|
|
155
|
+
// exactly this name, the consumer's import is the React wrapper for it.
|
|
156
|
+
for (const c of components) {
|
|
157
|
+
if (c.kind === "custom-element" && c.className === exportName)
|
|
158
|
+
return c;
|
|
159
|
+
}
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
function resolveLazyManifest(fromFile, specifier, exportName) {
|
|
163
|
+
const initialAbs = resolveImport(fromFile, specifier);
|
|
164
|
+
if (!initialAbs)
|
|
165
|
+
return null;
|
|
166
|
+
// Workspace-membership short-circuit: if both the importer and the
|
|
167
|
+
// resolved target live inside any workspace package of this repo, the
|
|
168
|
+
// import is a consumer-internal sibling reference (e.g. `@proton/atoms`
|
|
169
|
+
// imported from `applications/account`). Treat as local so the parser's
|
|
170
|
+
// local-detection pipeline owns identity. Yarn/pnpm install workspace
|
|
171
|
+
// packages as symlinks under node_modules; findOwningPackage is
|
|
172
|
+
// realpath-aware so both the direct path and the symlinked node_modules
|
|
173
|
+
// path map back to the workspace.
|
|
174
|
+
if (opts.workspaceGraph) {
|
|
175
|
+
const fromOwning = findOwningPackage(opts.workspaceGraph, fromFile);
|
|
176
|
+
const initialOwning = findOwningPackage(opts.workspaceGraph, initialAbs);
|
|
177
|
+
if (fromOwning && initialOwning) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// Resolved file lives in the same package as the importer (e.g.
|
|
182
|
+
// `../components/Foo.vue` from a sibling file in the consumer repo).
|
|
183
|
+
// The lazy resolver's contract is "external packages are opaque tuples";
|
|
184
|
+
// local files belong to the local-detection pipeline. Return null so the
|
|
185
|
+
// parser falls back to classifyImportOrigin / localIndex. Different
|
|
186
|
+
// package names — whether resolved through node_modules or through a
|
|
187
|
+
// yarn workspace symlink — are external and continue normal resolution.
|
|
188
|
+
const fromPkg = findPackageRoot(fromFile);
|
|
189
|
+
const initialPkg = findPackageRoot(initialAbs);
|
|
190
|
+
if (fromPkg && initialPkg && fromPkg.name === initialPkg.name) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
const cacheKey = `${initialAbs}::${exportName}`;
|
|
194
|
+
if (hitCache.has(cacheKey))
|
|
195
|
+
return hitCache.get(cacheKey) ?? null;
|
|
196
|
+
const visited = new Set();
|
|
197
|
+
const chainSpecifiers = [specifier];
|
|
198
|
+
let currentAbs = initialAbs;
|
|
199
|
+
let currentExport = exportName;
|
|
200
|
+
// Walk the re-export chain. If we advance MAX_REEXPORT_HOPS times without
|
|
201
|
+
// the chain naturally terminating (i.e. the next file would also be a
|
|
202
|
+
// barrel carrying our export), surface `chain-too-deep` and treat the
|
|
203
|
+
// current file as terminal so a wrong-leaf attribution is never silent.
|
|
204
|
+
let hops = 0;
|
|
205
|
+
while (true) {
|
|
206
|
+
const visitKey = `${currentAbs}::${currentExport}`;
|
|
207
|
+
if (visited.has(visitKey)) {
|
|
208
|
+
const cyclePkg = findPackageRoot(currentAbs)?.name;
|
|
209
|
+
collector.emit({
|
|
210
|
+
code: "cycle-detected",
|
|
211
|
+
severity: "warning",
|
|
212
|
+
filePath: currentAbs,
|
|
213
|
+
exportName: currentExport,
|
|
214
|
+
...(cyclePkg !== undefined ? { packageName: cyclePkg } : {}),
|
|
215
|
+
});
|
|
216
|
+
hitCache.set(cacheKey, null);
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
visited.add(visitKey);
|
|
220
|
+
const source = safeReadFile(currentAbs);
|
|
221
|
+
if (source === null)
|
|
222
|
+
break;
|
|
223
|
+
const { reExports, unsupported } = parseBarrelTopLevelDetailed(source);
|
|
224
|
+
const unsupportedPkg = unsupported.length > 0 ? findPackageRoot(currentAbs)?.name : undefined;
|
|
225
|
+
for (const u of unsupported) {
|
|
226
|
+
collector.emit({
|
|
227
|
+
code: "barrel-unsupported-form",
|
|
228
|
+
severity: "info",
|
|
229
|
+
filePath: currentAbs,
|
|
230
|
+
form: u.form,
|
|
231
|
+
...(u.line !== undefined ? { line: u.line } : {}),
|
|
232
|
+
...(unsupportedPkg !== undefined ? { packageName: unsupportedPkg } : {}),
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
if (reExports.length === 0)
|
|
236
|
+
break; // terminal
|
|
237
|
+
// Find the re-export that carries `currentExport`.
|
|
238
|
+
const next = pickReExportFor(reExports, currentExport);
|
|
239
|
+
if (!next)
|
|
240
|
+
break; // terminal — none of the re-exports carry this export
|
|
241
|
+
const nextAbs = resolveImport(currentAbs, next.from);
|
|
242
|
+
if (!nextAbs)
|
|
243
|
+
break; // unresolvable next hop → treat current as terminal
|
|
244
|
+
// We're about to advance. If we've already consumed our budget, bail
|
|
245
|
+
// out with a diagnostic instead. `currentAbs` stays on the last barrel
|
|
246
|
+
// we successfully read so package-root walk continues from there.
|
|
247
|
+
if (hops >= MAX_REEXPORT_HOPS) {
|
|
248
|
+
const deepPkg = findPackageRoot(currentAbs)?.name;
|
|
249
|
+
collector.emit({
|
|
250
|
+
code: "chain-too-deep",
|
|
251
|
+
severity: "warning",
|
|
252
|
+
filePath: currentAbs,
|
|
253
|
+
exportName: currentExport,
|
|
254
|
+
depth: MAX_REEXPORT_HOPS,
|
|
255
|
+
...(deepPkg !== undefined ? { packageName: deepPkg } : {}),
|
|
256
|
+
});
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
chainSpecifiers.push(next.from);
|
|
260
|
+
currentAbs = nextAbs;
|
|
261
|
+
currentExport = next.targetExport;
|
|
262
|
+
hops++;
|
|
263
|
+
}
|
|
264
|
+
// Walk up to the package root of currentAbs.
|
|
265
|
+
const pkg = findPackageRoot(currentAbs);
|
|
266
|
+
if (!pkg) {
|
|
267
|
+
hitCache.set(cacheKey, null);
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
const components = loadLeafManifest(pkg.name, pkg.dir);
|
|
271
|
+
const matched = matchInLeaf(components, chainSpecifiers, currentExport);
|
|
272
|
+
if (!matched && components.length === 0) {
|
|
273
|
+
// Untraceable + no manifest at all; surface diagnostic.
|
|
274
|
+
collector.emit({
|
|
275
|
+
code: "untraceable-barrel",
|
|
276
|
+
severity: "info",
|
|
277
|
+
packageName: pkg.name,
|
|
278
|
+
resolvedFile: currentAbs,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
const hit = { leafPackage: pkg.name, matched };
|
|
282
|
+
hitCache.set(cacheKey, hit);
|
|
283
|
+
return hit;
|
|
284
|
+
}
|
|
285
|
+
function lookupByTag(tagName) {
|
|
286
|
+
return byTag.get(tagName) ?? null;
|
|
287
|
+
}
|
|
288
|
+
function snapshotComponents() {
|
|
289
|
+
const out = [];
|
|
290
|
+
for (const v of visitedLeafs.values())
|
|
291
|
+
out.push(...v.components);
|
|
292
|
+
return out;
|
|
293
|
+
}
|
|
294
|
+
function snapshotManifestRefs() {
|
|
295
|
+
const out = [];
|
|
296
|
+
for (const v of visitedLeafs.values()) {
|
|
297
|
+
if (v.manifestRef.path)
|
|
298
|
+
out.push(v.manifestRef);
|
|
299
|
+
}
|
|
300
|
+
return out;
|
|
301
|
+
}
|
|
302
|
+
function warmRoots(packageNames) {
|
|
303
|
+
// Anchor at <repoRoot>/_ so Node's resolution walks up through
|
|
304
|
+
// <repoRoot>/node_modules and parents, mirroring resolve-import.ts.
|
|
305
|
+
const anchor = pathResolve(opts.repoRoot ?? process.cwd(), "_");
|
|
306
|
+
const requireFromRepo = createRequire(anchor);
|
|
307
|
+
for (const name of packageNames) {
|
|
308
|
+
if (visitedLeafs.has(name))
|
|
309
|
+
continue;
|
|
310
|
+
try {
|
|
311
|
+
const pkgJsonPath = requireFromRepo.resolve(`${name}/package.json`);
|
|
312
|
+
loadLeafManifest(name, dirname(pkgJsonPath));
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
// Package not installed or its package.json not exposed via exports —
|
|
316
|
+
// skip silently. Warm-up is best-effort; missing entries are fine.
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return {
|
|
321
|
+
resolveLazyManifest,
|
|
322
|
+
lookupByTag,
|
|
323
|
+
snapshotComponents,
|
|
324
|
+
snapshotManifestRefs,
|
|
325
|
+
diagnostics: () => collector.drain(),
|
|
326
|
+
warmRoots,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
// ---------------------------------------------------------------------------
|
|
330
|
+
// Helpers
|
|
331
|
+
// ---------------------------------------------------------------------------
|
|
332
|
+
function safeReadFile(path) {
|
|
333
|
+
try {
|
|
334
|
+
if (!statSync(path).isFile())
|
|
335
|
+
return null;
|
|
336
|
+
return readFileSync(path, "utf8");
|
|
337
|
+
}
|
|
338
|
+
catch {
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function pickReExportFor(reExports, exportName) {
|
|
343
|
+
// Named re-export carrying our export wins over star re-exports.
|
|
344
|
+
for (const re of reExports) {
|
|
345
|
+
if (re.kind === "named") {
|
|
346
|
+
const found = re.names.find((n) => n.exported === exportName);
|
|
347
|
+
if (found)
|
|
348
|
+
return { from: re.from, targetExport: found.local };
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
// Star re-export: any star may carry the export; resolver tries the first
|
|
352
|
+
// and its terminal will tell us whether the leaf has it. v1 picks the first
|
|
353
|
+
// star — multi-star ambiguity in the same file is rare and a `barrel-
|
|
354
|
+
// unsupported-form` diagnostic could be added in a patch if real cases
|
|
355
|
+
// surface.
|
|
356
|
+
for (const re of reExports) {
|
|
357
|
+
if (re.kind === "star")
|
|
358
|
+
return { from: re.from, targetExport: exportName };
|
|
359
|
+
}
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
function absorbCemDeclarations(cem, packageName) {
|
|
363
|
+
const out = [];
|
|
364
|
+
for (const mod of cem.modules ?? []) {
|
|
365
|
+
for (const decl of mod.declarations ?? []) {
|
|
366
|
+
const d = decl;
|
|
367
|
+
if (!d.customElement || !d.tagName || !d.name)
|
|
368
|
+
continue;
|
|
369
|
+
const props = buildPropsFromCem(d);
|
|
370
|
+
const events = buildEventsFromCem(d);
|
|
371
|
+
const slots = buildSlotsFromCem(d);
|
|
372
|
+
const componentLifecycle = buildLifecycleFromDeprecated(d.deprecated);
|
|
373
|
+
const entry = {
|
|
374
|
+
kind: "custom-element",
|
|
375
|
+
tagName: d.tagName,
|
|
376
|
+
source: { type: "external", package: packageName },
|
|
377
|
+
props,
|
|
378
|
+
events,
|
|
379
|
+
slots,
|
|
380
|
+
className: d.name,
|
|
381
|
+
imports: d.componentCompass?.imports ?? {},
|
|
382
|
+
};
|
|
383
|
+
if (d.description !== undefined)
|
|
384
|
+
entry.description = d.description;
|
|
385
|
+
if (componentLifecycle !== undefined)
|
|
386
|
+
entry.lifecycle = componentLifecycle;
|
|
387
|
+
out.push(entry);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return out;
|
|
391
|
+
}
|
|
392
|
+
function buildPropsFromCem(decl) {
|
|
393
|
+
const props = [];
|
|
394
|
+
const seen = new Set();
|
|
395
|
+
// Pass 1: `attributes[]` are the canonical source for prop names + values.
|
|
396
|
+
for (const attr of decl.attributes ?? []) {
|
|
397
|
+
if (!attr.name || seen.has(attr.name))
|
|
398
|
+
continue;
|
|
399
|
+
seen.add(attr.name);
|
|
400
|
+
props.push(buildPropFromCemField(attr));
|
|
401
|
+
}
|
|
402
|
+
// Pass 2: `members[]` of `kind: "field"` fall through for any field that
|
|
403
|
+
// doesn't have an attribute counterpart (DOM-only properties). Mirror the
|
|
404
|
+
// privacy gate from before — private fields stay out.
|
|
405
|
+
for (const member of decl.members ?? []) {
|
|
406
|
+
if (member.kind !== "field" || member.privacy === "private")
|
|
407
|
+
continue;
|
|
408
|
+
if (!member.name || seen.has(member.name))
|
|
409
|
+
continue;
|
|
410
|
+
seen.add(member.name);
|
|
411
|
+
props.push(buildPropFromCemField(member));
|
|
412
|
+
}
|
|
413
|
+
return props;
|
|
414
|
+
}
|
|
415
|
+
function buildPropFromCemField(field) {
|
|
416
|
+
// `field.name` is asserted by the caller (gating happens in the loops above).
|
|
417
|
+
const prop = { name: field.name };
|
|
418
|
+
if (field.type?.text !== undefined)
|
|
419
|
+
prop.type = field.type.text;
|
|
420
|
+
// CEM declares `default` as the source-form string of the field's
|
|
421
|
+
// initializer (e.g. "'medium'" for a string literal, "42" for a
|
|
422
|
+
// number). Pass through as-is; rollup's `defaultApplied` matcher
|
|
423
|
+
// only checks for !== undefined, and richer coercion is a separate
|
|
424
|
+
// display concern tracked downstream.
|
|
425
|
+
if (field.default !== undefined)
|
|
426
|
+
prop.default = field.default;
|
|
427
|
+
if (field.description !== undefined)
|
|
428
|
+
prop.description = field.description;
|
|
429
|
+
const values = parseStringUnionValues(field.type?.text);
|
|
430
|
+
if (values !== undefined)
|
|
431
|
+
prop.values = values;
|
|
432
|
+
const lifecycle = buildLifecycleFromDeprecated(field.deprecated);
|
|
433
|
+
if (lifecycle !== undefined)
|
|
434
|
+
prop.lifecycle = lifecycle;
|
|
435
|
+
return prop;
|
|
436
|
+
}
|
|
437
|
+
function buildEventsFromCem(decl) {
|
|
438
|
+
const events = [];
|
|
439
|
+
for (const e of decl.events ?? []) {
|
|
440
|
+
if (!e.name)
|
|
441
|
+
continue;
|
|
442
|
+
const event = { name: e.name };
|
|
443
|
+
if (e.type?.text !== undefined)
|
|
444
|
+
event.payloadType = e.type.text;
|
|
445
|
+
if (e.description !== undefined)
|
|
446
|
+
event.description = e.description;
|
|
447
|
+
const lifecycle = buildLifecycleFromDeprecated(e.deprecated);
|
|
448
|
+
if (lifecycle !== undefined)
|
|
449
|
+
event.lifecycle = lifecycle;
|
|
450
|
+
events.push(event);
|
|
451
|
+
}
|
|
452
|
+
return events;
|
|
453
|
+
}
|
|
454
|
+
function buildSlotsFromCem(decl) {
|
|
455
|
+
const slots = [];
|
|
456
|
+
for (const s of decl.slots ?? []) {
|
|
457
|
+
const slot = { name: s.name ?? "" };
|
|
458
|
+
if (s.description !== undefined)
|
|
459
|
+
slot.description = s.description;
|
|
460
|
+
const lifecycle = buildLifecycleFromDeprecated(s.deprecated);
|
|
461
|
+
if (lifecycle !== undefined)
|
|
462
|
+
slot.lifecycle = lifecycle;
|
|
463
|
+
slots.push(slot);
|
|
464
|
+
}
|
|
465
|
+
return slots;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* CEM `deprecated` is `true` (deprecated, no reason) or a reason string.
|
|
469
|
+
* Both shape into a `Lifecycle` with status: "deprecated"; `false` / undefined
|
|
470
|
+
* leave the lifecycle unset (consumers default to "stable" when absent).
|
|
471
|
+
*/
|
|
472
|
+
function buildLifecycleFromDeprecated(deprecated) {
|
|
473
|
+
if (deprecated === undefined || deprecated === false)
|
|
474
|
+
return undefined;
|
|
475
|
+
if (typeof deprecated === "string") {
|
|
476
|
+
return { status: "deprecated", deprecationReason: deprecated };
|
|
477
|
+
}
|
|
478
|
+
return { status: "deprecated" };
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Parse a CEM `type.text` like `"'small' | 'medium' | 'large'"` into the
|
|
482
|
+
* declared allowed values `["small", "medium", "large"]`. Only returns a
|
|
483
|
+
* result when EVERY `|`-separated part is a single-quoted or double-quoted
|
|
484
|
+
* string literal (mixed unions like `"'small' | number"` return undefined).
|
|
485
|
+
*/
|
|
486
|
+
function parseStringUnionValues(typeText) {
|
|
487
|
+
if (!typeText)
|
|
488
|
+
return undefined;
|
|
489
|
+
const parts = typeText.split("|").map((s) => s.trim());
|
|
490
|
+
const stringLiterals = parts
|
|
491
|
+
.map((p) => {
|
|
492
|
+
const m = /^['"](.*)['"]$/.exec(p);
|
|
493
|
+
return m ? m[1] : null;
|
|
494
|
+
})
|
|
495
|
+
.filter((v) => v !== null);
|
|
496
|
+
return stringLiterals.length === parts.length && stringLiterals.length > 0
|
|
497
|
+
? stringLiterals
|
|
498
|
+
: undefined;
|
|
499
|
+
}
|
|
500
|
+
function absorbCcmComponents(manifest, packageName) {
|
|
501
|
+
const out = [];
|
|
502
|
+
for (const c of manifest.components) {
|
|
503
|
+
if (c.kind === "custom-element")
|
|
504
|
+
continue;
|
|
505
|
+
if (c.kind !== "react-component" && c.kind !== "vue-component")
|
|
506
|
+
continue;
|
|
507
|
+
if (!c.export)
|
|
508
|
+
continue;
|
|
509
|
+
const externalSrc = { type: "external", package: packageName };
|
|
510
|
+
// Thread `default` and `type` from each CCM-declared prop through to the
|
|
511
|
+
// absorbed IndexedComponent. Mirrors `absorbCemDeclarations`' members[]
|
|
512
|
+
// handling so the `defaultApplied` rollup matcher fires for CCM-sourced
|
|
513
|
+
// consumers (manifest-react / manifest-vue outputs) on parity with
|
|
514
|
+
// CEM-sourced ones.
|
|
515
|
+
const props = (c.props ?? []).map((p) => {
|
|
516
|
+
const absorbed = { name: p.name };
|
|
517
|
+
if (p.type !== undefined)
|
|
518
|
+
absorbed.type = p.type;
|
|
519
|
+
if (p.default !== undefined)
|
|
520
|
+
absorbed.default = p.default;
|
|
521
|
+
return absorbed;
|
|
522
|
+
});
|
|
523
|
+
out.push({
|
|
524
|
+
kind: c.kind,
|
|
525
|
+
export: c.export,
|
|
526
|
+
source: externalSrc,
|
|
527
|
+
props,
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
return out;
|
|
531
|
+
}
|
|
532
|
+
//# sourceMappingURL=lazy-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-resolver.js","sourceRoot":"","sources":["../../src/manifest/lazy-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EACL,gBAAgB,EAWhB,yBAAyB,GAC1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,sBAAsB,IAAI,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAElG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AA4BxE;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAiB7B,MAAM,UAAU,kBAAkB,CAAC,IAA+B;IAChE,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;IAC/B,MAAM,cAAc,GAAG,IAAI,CAAC,sBAAsB,IAAI,0BAA0B,CAAC;IAEjF,4EAA4E;I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AG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project parser-emitted occurrences onto the artifact-shape OutputOccurrence
|
|
3
|
+
* stream, preserving the three-state attribute model:
|
|
4
|
+
* - literal value (when captureValues is true and source value was static),
|
|
5
|
+
* - { __dynamic: DynamicKind } marker (always, when source was non-literal),
|
|
6
|
+
* - null (when captureValues is false and source was static, OR when source
|
|
7
|
+
* value was literal null).
|
|
8
|
+
*
|
|
9
|
+
* Phase 2: also resolves parser-side `parentRef` (intra-ParseResult occurrence
|
|
10
|
+
* index) into artifact-side `parentOccurrenceId` strings and carries through
|
|
11
|
+
* `depth`. Parent resolution stays scoped to one ParseResult — cross-file
|
|
12
|
+
* composition is not tracked.
|
|
13
|
+
*
|
|
14
|
+
* Pure function; no I/O.
|
|
15
|
+
*/
|
|
16
|
+
import { type OutputOccurrence, type ParseResult } from "@component-compass/plugin-core";
|
|
17
|
+
export declare function parseResultsToOccurrences(results: ParseResult[], captureValues: boolean, repoRoot?: string): OutputOccurrence[];
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project parser-emitted occurrences onto the artifact-shape OutputOccurrence
|
|
3
|
+
* stream, preserving the three-state attribute model:
|
|
4
|
+
* - literal value (when captureValues is true and source value was static),
|
|
5
|
+
* - { __dynamic: DynamicKind } marker (always, when source was non-literal),
|
|
6
|
+
* - null (when captureValues is false and source was static, OR when source
|
|
7
|
+
* value was literal null).
|
|
8
|
+
*
|
|
9
|
+
* Phase 2: also resolves parser-side `parentRef` (intra-ParseResult occurrence
|
|
10
|
+
* index) into artifact-side `parentOccurrenceId` strings and carries through
|
|
11
|
+
* `depth`. Parent resolution stays scoped to one ParseResult — cross-file
|
|
12
|
+
* composition is not tracked.
|
|
13
|
+
*
|
|
14
|
+
* Pure function; no I/O.
|
|
15
|
+
*/
|
|
16
|
+
import { relative, isAbsolute } from "node:path";
|
|
17
|
+
import { computeOccurrenceId, } from "@component-compass/plugin-core";
|
|
18
|
+
import { computeStableIdFromComponentId } from "./identity.js";
|
|
19
|
+
/**
|
|
20
|
+
* Normalise a local-source ComponentId's filePath to be repo-root-relative so
|
|
21
|
+
* that the stable hash matches the one produced for seeds built from the local
|
|
22
|
+
* index (which uses relative paths from the walker). Without this, owner edges
|
|
23
|
+
* from parsers (which use absolute file paths) would hash-diverge from the
|
|
24
|
+
* component entries they reference.
|
|
25
|
+
*/
|
|
26
|
+
function normaliseLocalFilePath(c, repoRoot) {
|
|
27
|
+
if (c.source.type !== "local")
|
|
28
|
+
return c;
|
|
29
|
+
const fp = c.source.filePath;
|
|
30
|
+
if (!isAbsolute(fp))
|
|
31
|
+
return c;
|
|
32
|
+
return {
|
|
33
|
+
...c,
|
|
34
|
+
source: { type: "local", filePath: relative(repoRoot, fp).replace(/\\/g, "/") },
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function parseResultsToOccurrences(results, captureValues, repoRoot = "") {
|
|
38
|
+
const out = [];
|
|
39
|
+
for (const result of results) {
|
|
40
|
+
// First pass: compute (final componentId hash, occurrenceId) for every
|
|
41
|
+
// parser-emitted occurrence in THIS ParseResult. Indexes align with
|
|
42
|
+
// result.occurrences, so parentRef indices resolve correctly in pass two.
|
|
43
|
+
const computed = result.occurrences.map((occ) => {
|
|
44
|
+
const componentId = computeStableIdFromComponentId(occ.componentId);
|
|
45
|
+
const occurrenceId = computeOccurrenceId(componentId, occ.loc.file, occ.loc.line, occ.loc.column);
|
|
46
|
+
return { componentId, occurrenceId };
|
|
47
|
+
});
|
|
48
|
+
// Second pass: project to OutputOccurrence, resolving parentRef.
|
|
49
|
+
for (let i = 0; i < result.occurrences.length; i++) {
|
|
50
|
+
const occ = result.occurrences[i];
|
|
51
|
+
const meta = computed[i];
|
|
52
|
+
if (!occ || !meta)
|
|
53
|
+
continue;
|
|
54
|
+
const { componentId, occurrenceId } = meta;
|
|
55
|
+
const props = {};
|
|
56
|
+
for (const p of occ.props) {
|
|
57
|
+
if (p.isDynamic) {
|
|
58
|
+
// dynamicKind should always be set when isDynamic is true (per
|
|
59
|
+
// scan-types.ts), but defend against malformed parser output.
|
|
60
|
+
props[p.name] = { __dynamic: p.dynamicKind ?? "expr" };
|
|
61
|
+
}
|
|
62
|
+
else if (captureValues && p.literalValue !== undefined) {
|
|
63
|
+
props[p.name] = p.literalValue;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
props[p.name] = null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const output = {
|
|
70
|
+
componentId,
|
|
71
|
+
filePath: occ.loc.file,
|
|
72
|
+
line: occ.loc.line,
|
|
73
|
+
column: occ.loc.column,
|
|
74
|
+
via: occ.via,
|
|
75
|
+
props,
|
|
76
|
+
occurrenceId,
|
|
77
|
+
};
|
|
78
|
+
if (occ.parentRef !== undefined) {
|
|
79
|
+
const parent = computed[occ.parentRef];
|
|
80
|
+
if (parent) {
|
|
81
|
+
output.parentOccurrenceId = parent.occurrenceId;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (occ.depth !== undefined)
|
|
85
|
+
output.depth = occ.depth;
|
|
86
|
+
if (occ.ownerComponentId) {
|
|
87
|
+
const normOwner = repoRoot
|
|
88
|
+
? normaliseLocalFilePath(occ.ownerComponentId, repoRoot)
|
|
89
|
+
: occ.ownerComponentId;
|
|
90
|
+
output.ownerComponentId = computeStableIdFromComponentId(normOwner);
|
|
91
|
+
}
|
|
92
|
+
out.push(output);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=occurrences.js.map
|