@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.
Files changed (96) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +12 -4
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/init.d.ts +3 -2
  5. package/dist/commands/init.js +50 -62
  6. package/dist/commands/init.js.map +1 -1
  7. package/dist/commands/no-deps-diagnostic.d.ts +15 -0
  8. package/dist/commands/no-deps-diagnostic.js +23 -0
  9. package/dist/commands/no-deps-diagnostic.js.map +1 -0
  10. package/dist/commands/scan.d.ts +1 -0
  11. package/dist/commands/scan.js +126 -82
  12. package/dist/commands/scan.js.map +1 -1
  13. package/dist/composition-rollup.d.ts +23 -0
  14. package/dist/composition-rollup.js +64 -0
  15. package/dist/composition-rollup.js.map +1 -0
  16. package/dist/config/loader.js +5 -3
  17. package/dist/config/loader.js.map +1 -1
  18. package/dist/config/schema.d.ts +1 -2
  19. package/dist/config/schema.js.map +1 -1
  20. package/dist/identity.d.ts +21 -3
  21. package/dist/identity.js +40 -3
  22. package/dist/identity.js.map +1 -1
  23. package/dist/local-index/detect-react.js +224 -47
  24. package/dist/local-index/detect-react.js.map +1 -1
  25. package/dist/local-index/index.d.ts +4 -1
  26. package/dist/local-index/index.js +30 -13
  27. package/dist/local-index/index.js.map +1 -1
  28. package/dist/manifest/barrel-parser.d.ts +20 -0
  29. package/dist/manifest/barrel-parser.js +101 -16
  30. package/dist/manifest/barrel-parser.js.map +1 -1
  31. package/dist/manifest/derived-manifest-stub.d.ts +9 -0
  32. package/dist/manifest/derived-manifest-stub.js +11 -0
  33. package/dist/manifest/derived-manifest-stub.js.map +1 -0
  34. package/dist/manifest/diagnostic-filter.d.ts +13 -0
  35. package/dist/manifest/diagnostic-filter.js +36 -0
  36. package/dist/manifest/diagnostic-filter.js.map +1 -0
  37. package/dist/manifest/lazy-resolver.d.ts +44 -0
  38. package/dist/manifest/lazy-resolver.js +532 -0
  39. package/dist/manifest/lazy-resolver.js.map +1 -0
  40. package/dist/occurrences.d.ts +17 -0
  41. package/dist/occurrences.js +97 -0
  42. package/dist/occurrences.js.map +1 -0
  43. package/dist/reporter/index.d.ts +47 -9
  44. package/dist/reporter/index.js +167 -17
  45. package/dist/reporter/index.js.map +1 -1
  46. package/dist/reporter/json.d.ts +6 -2
  47. package/dist/reporter/json.js +7 -3
  48. package/dist/reporter/json.js.map +1 -1
  49. package/dist/reporter/stdout.d.ts +2 -2
  50. package/dist/reporter/stdout.js +11 -23
  51. package/dist/reporter/stdout.js.map +1 -1
  52. package/dist/rollup.d.ts +8 -2
  53. package/dist/rollup.js +2 -3
  54. package/dist/rollup.js.map +1 -1
  55. package/dist/seeds.d.ts +41 -0
  56. package/dist/seeds.js +145 -0
  57. package/dist/seeds.js.map +1 -0
  58. package/dist/types.d.ts +0 -1
  59. package/dist/workspace/build-graph.d.ts +2 -0
  60. package/dist/workspace/build-graph.js +117 -0
  61. package/dist/workspace/build-graph.js.map +1 -0
  62. package/dist/workspace/declared-deps.d.ts +5 -0
  63. package/dist/workspace/declared-deps.js +42 -0
  64. package/dist/workspace/declared-deps.js.map +1 -0
  65. package/dist/workspace/find-owning-package.d.ts +2 -0
  66. package/dist/workspace/find-owning-package.js +49 -0
  67. package/dist/workspace/find-owning-package.js.map +1 -0
  68. package/dist/workspace/index.d.ts +4 -0
  69. package/dist/workspace/index.js +4 -0
  70. package/dist/workspace/index.js.map +1 -0
  71. package/dist/workspace/types.d.ts +46 -0
  72. package/dist/workspace/types.js +13 -0
  73. package/dist/workspace/types.js.map +1 -0
  74. package/package.json +11 -9
  75. package/schema/config.schema.json +2 -10
  76. package/dist/graph/builder.d.ts +0 -25
  77. package/dist/graph/builder.js +0 -176
  78. package/dist/graph/builder.js.map +0 -1
  79. package/dist/manifest/discovery.d.ts +0 -24
  80. package/dist/manifest/discovery.js +0 -194
  81. package/dist/manifest/discovery.js.map +0 -1
  82. package/dist/manifest/index.d.ts +0 -6
  83. package/dist/manifest/index.js +0 -98
  84. package/dist/manifest/index.js.map +0 -1
  85. package/dist/manifest/resolver.d.ts +0 -30
  86. package/dist/manifest/resolver.js +0 -136
  87. package/dist/manifest/resolver.js.map +0 -1
  88. package/dist/manifest/run-discovery.d.ts +0 -12
  89. package/dist/manifest/run-discovery.js +0 -46
  90. package/dist/manifest/run-discovery.js.map +0 -1
  91. package/dist/manifest/types.d.ts +0 -3
  92. package/dist/manifest/types.js +0 -2
  93. package/dist/manifest/types.js.map +0 -1
  94. package/dist/reporter/types.d.ts +0 -69
  95. package/dist/reporter/types.js +0 -2
  96. package/dist/reporter/types.js.map +0 -1
@@ -1,6 +1,9 @@
1
1
  import { type WalkOptions } from "./walker.js";
2
2
  import type { LocalDefinitionIndex } from "./types.js";
3
- export type BuildLocalIndexOptions = WalkOptions;
3
+ import type { DiagnosticCollector } from "@component-compass/plugin-core";
4
+ export type BuildLocalIndexOptions = WalkOptions & {
5
+ collector?: DiagnosticCollector;
6
+ };
4
7
  export declare function buildLocalIndex(opts: BuildLocalIndexOptions): Promise<LocalDefinitionIndex>;
5
8
  export type { LocalDefinition, LocalDefinitionIndex, DetectorId } from "./types.js";
6
9
  export { emptyLocalIndex } from "./types.js";
@@ -2,9 +2,34 @@ import { walkLocalSources } from "./walker.js";
2
2
  import { detectReactComponents } from "./detect-react.js";
3
3
  import { detectVueComponents } from "./detect-vue.js";
4
4
  import { detectWebComponents } from "./detect-wc.js";
5
+ function indexDefinitions(definitions, collector) {
6
+ const index = { byPath: new Map(), byTag: new Map() };
7
+ for (const def of definitions) {
8
+ if (def.componentId.kind !== "custom-element")
9
+ continue;
10
+ const existing = index.byTag.get(def.componentId.tagName);
11
+ if (existing &&
12
+ existing.componentId.kind === "custom-element" &&
13
+ existing.componentId.source.type === "local" &&
14
+ def.componentId.source.type === "local" &&
15
+ existing.componentId.source.filePath !== def.componentId.source.filePath) {
16
+ collector?.emit({
17
+ code: "local-index-duplicate-tag",
18
+ severity: "warning",
19
+ filePath: def.componentId.source.filePath,
20
+ tagName: def.componentId.tagName,
21
+ conflictsWith: existing.componentId.source.filePath,
22
+ });
23
+ continue;
24
+ }
25
+ index.byTag.set(def.componentId.tagName, def);
26
+ }
27
+ return index;
28
+ }
5
29
  export async function buildLocalIndex(opts) {
6
30
  const files = await walkLocalSources(opts);
7
- const index = { byPath: new Map(), byTag: new Map() };
31
+ const byPath = new Map();
32
+ const allDefs = [];
8
33
  for (const file of files) {
9
34
  const found = [
10
35
  ...detectReactComponents(file.source, file.filePath, file.extension),
@@ -13,19 +38,11 @@ export async function buildLocalIndex(opts) {
13
38
  ];
14
39
  if (found.length === 0)
15
40
  continue;
16
- index.byPath.set(file.filePath, found);
17
- for (const def of found) {
18
- if (def.componentId.kind === "custom-element") {
19
- const existing = index.byTag.get(def.componentId.tagName);
20
- if (existing && existing.componentId.kind === "custom-element" && existing.componentId.source.type === "local" && existing.componentId.source.filePath !== file.filePath) {
21
- console.warn(`[component-compass] duplicate local custom-element <${def.componentId.tagName}> in ${file.filePath} (already registered from ${existing.componentId.source.filePath}); keeping first.`);
22
- continue;
23
- }
24
- index.byTag.set(def.componentId.tagName, def);
25
- }
26
- }
41
+ byPath.set(file.filePath, found);
42
+ allDefs.push(...found);
27
43
  }
28
- return index;
44
+ const tagIndex = indexDefinitions(allDefs, opts.collector);
45
+ return { byPath, byTag: tagIndex.byTag };
29
46
  }
30
47
  export { emptyLocalIndex } from "./types.js";
31
48
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/local-index/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAoB,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAKrD,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,KAAK,CAAC,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC3D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC3C,CAAC;AAGD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -20,3 +20,23 @@ export type BarrelReExport = {
20
20
  * Returns [] on parse failure rather than throwing.
21
21
  */
22
22
  export declare function parseBarrelTopLevel(source: string): BarrelReExport[];
23
+ export type BarrelUnsupportedForm = {
24
+ form: "cjs-reexport";
25
+ line?: number;
26
+ } | {
27
+ form: "conditional-reexport";
28
+ line?: number;
29
+ };
30
+ export type BarrelParseResult = {
31
+ reExports: BarrelReExport[];
32
+ unsupported: BarrelUnsupportedForm[];
33
+ };
34
+ /**
35
+ * Like {@link parseBarrelTopLevel}, but also returns a list of unsupported
36
+ * top-level shapes encountered (e.g. CJS re-exports, conditional re-exports)
37
+ * so callers can surface diagnostics rather than silently dropping leaves.
38
+ *
39
+ * Returns `{ reExports: [], unsupported: [] }` on parse failure rather than
40
+ * throwing.
41
+ */
42
+ export declare function parseBarrelTopLevelDetailed(source: string): BarrelParseResult;
@@ -1,4 +1,5 @@
1
1
  import { parse } from "@babel/parser";
2
+ import * as t from "@babel/types";
2
3
  /**
3
4
  * Extract top-level re-exports from a JS/TS source file. Returns only
4
5
  * `export * from "X"`, `export * as NS from "X"`, and
@@ -10,6 +11,17 @@ import { parse } from "@babel/parser";
10
11
  * Returns [] on parse failure rather than throwing.
11
12
  */
12
13
  export function parseBarrelTopLevel(source) {
14
+ return parseBarrelTopLevelDetailed(source).reExports;
15
+ }
16
+ /**
17
+ * Like {@link parseBarrelTopLevel}, but also returns a list of unsupported
18
+ * top-level shapes encountered (e.g. CJS re-exports, conditional re-exports)
19
+ * so callers can surface diagnostics rather than silently dropping leaves.
20
+ *
21
+ * Returns `{ reExports: [], unsupported: [] }` on parse failure rather than
22
+ * throwing.
23
+ */
24
+ export function parseBarrelTopLevelDetailed(source) {
13
25
  let ast;
14
26
  try {
15
27
  ast = parse(source, {
@@ -19,44 +31,117 @@ export function parseBarrelTopLevel(source) {
19
31
  });
20
32
  }
21
33
  catch {
22
- return [];
34
+ return { reExports: [], unsupported: [] };
23
35
  }
24
- const out = [];
36
+ const reExports = [];
37
+ const unsupported = [];
25
38
  for (const node of ast.program.body) {
26
- if (node.type === "ExportAllDeclaration") {
27
- out.push({ kind: "star", from: node.source.value });
39
+ if (t.isExportAllDeclaration(node)) {
40
+ reExports.push({ kind: "star", from: node.source.value });
28
41
  continue;
29
42
  }
30
- if (node.type === "ExportNamedDeclaration") {
31
- // export { local } — no `from` clause, ignore (not a re-export).
43
+ if (t.isExportNamedDeclaration(node)) {
32
44
  if (!node.source)
33
45
  continue;
34
- // export type { ... } from — strip.
35
46
  if (node.exportKind === "type")
36
47
  continue;
37
- // export * as NS from "X" — Babel parses this as ExportNamedDeclaration
38
- // with a single ExportNamespaceSpecifier; treat it as a star re-export.
39
48
  const onlySpec = node.specifiers[0];
40
- if (node.specifiers.length === 1 && onlySpec?.type === "ExportNamespaceSpecifier") {
41
- out.push({ kind: "star", from: node.source.value });
49
+ if (node.specifiers.length === 1 &&
50
+ onlySpec &&
51
+ t.isExportNamespaceSpecifier(onlySpec)) {
52
+ reExports.push({ kind: "star", from: node.source.value });
42
53
  continue;
43
54
  }
44
55
  const namesPart = [];
45
56
  for (const spec of node.specifiers) {
46
- if (spec.type !== "ExportSpecifier")
57
+ if (!t.isExportSpecifier(spec))
47
58
  continue;
48
- // Strip per-specifier `export type { Foo }`.
49
59
  if (spec.exportKind === "type")
50
60
  continue;
51
61
  const local = spec.local.name;
52
- const exported = spec.exported.type === "Identifier" ? spec.exported.name : spec.exported.value;
62
+ const exported = t.isIdentifier(spec.exported)
63
+ ? spec.exported.name
64
+ : spec.exported.value;
53
65
  namesPart.push({ local, exported });
54
66
  }
55
67
  if (namesPart.length === 0)
56
68
  continue;
57
- out.push({ kind: "named", from: node.source.value, names: namesPart });
69
+ reExports.push({ kind: "named", from: node.source.value, names: namesPart });
70
+ continue;
71
+ }
72
+ // CommonJS top-level reassignment: `module.exports = require(...)` /
73
+ // `module.exports = ...` covered by ExpressionStatement at top level.
74
+ if (t.isExpressionStatement(node) && isCjsReexport(node.expression)) {
75
+ const entry = { form: "cjs-reexport" };
76
+ if (typeof node.loc?.start.line === "number")
77
+ entry.line = node.loc.start.line;
78
+ unsupported.push(entry);
79
+ continue;
80
+ }
81
+ // Anything wrapping a CJS reassignment in a conditional.
82
+ if (t.isIfStatement(node) && containsCjsReexport(node)) {
83
+ const entry = { form: "conditional-reexport" };
84
+ if (typeof node.loc?.start.line === "number")
85
+ entry.line = node.loc.start.line;
86
+ unsupported.push(entry);
87
+ }
88
+ }
89
+ return { reExports, unsupported };
90
+ }
91
+ function isCjsReexport(expr) {
92
+ if (!expr || !t.isAssignmentExpression(expr))
93
+ return false;
94
+ if (!t.isMemberExpression(expr.left))
95
+ return false;
96
+ return (t.isIdentifier(expr.left.object, { name: "module" }) &&
97
+ t.isIdentifier(expr.left.property, { name: "exports" }));
98
+ }
99
+ /**
100
+ * Walk an `IfStatement` looking for a top-level `module.exports = ...`
101
+ * inside the consequent / alternate.
102
+ *
103
+ * The walk is type-aware: it descends only into structural children that
104
+ * execute when the if branch executes. Function and class bodies are
105
+ * treated as opaque boundaries — `module.exports = ...` defined inside a
106
+ * nested function declaration / arrow / class method does not run when the
107
+ * `if` body runs, so it would be a false positive to flag it.
108
+ */
109
+ function containsCjsReexport(node) {
110
+ return visitConditionalBody(node.consequent) || visitConditionalBody(node.alternate);
111
+ }
112
+ function visitConditionalBody(node) {
113
+ if (!node)
114
+ return false;
115
+ // Direct CJS reassignment.
116
+ if (t.isExpressionStatement(node) && isCjsReexport(node.expression)) {
117
+ return true;
118
+ }
119
+ // Function / class scopes don't execute now — opaque boundary.
120
+ if (t.isFunctionDeclaration(node) ||
121
+ t.isFunctionExpression(node) ||
122
+ t.isArrowFunctionExpression(node) ||
123
+ t.isObjectMethod(node) ||
124
+ t.isClassMethod(node) ||
125
+ t.isClassDeclaration(node) ||
126
+ t.isClassExpression(node)) {
127
+ return false;
128
+ }
129
+ if (t.isBlockStatement(node)) {
130
+ for (const stmt of node.body) {
131
+ if (visitConditionalBody(stmt))
132
+ return true;
58
133
  }
134
+ return false;
135
+ }
136
+ if (t.isIfStatement(node)) {
137
+ return (visitConditionalBody(node.consequent) || visitConditionalBody(node.alternate));
138
+ }
139
+ if (t.isLabeledStatement(node) || t.isWithStatement(node)) {
140
+ return visitConditionalBody(node.body);
59
141
  }
60
- return out;
142
+ // Other statement types (loops, try/catch, switch, return, throw, ...) are
143
+ // not unwrapped here. The Phase 1 spec is IfStatement-only; broader
144
+ // detection (try/catch, switch) is tracked as a follow-up.
145
+ return false;
61
146
  }
62
147
  //# sourceMappingURL=barrel-parser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"barrel-parser.js","sourceRoot":"","sources":["../../src/manifest/barrel-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAUtC;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAc;IAChD,IAAI,GAA6B,CAAC;IAClC,IAAI,CAAC;QACH,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE;YAClB,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC;YAC9B,aAAa,EAAE,IAAI;SACpB,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,GAAG,GAAqB,EAAE,CAAC;IACjC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACpC,IAAI,I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C;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,OAAO,CACL,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAC9E,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1D,OAAO,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,2EAA2E;IAC3E,oEAAoE;IACpE,2DAA2D;IAC3D,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { DerivedLeafPayload } from "@component-compass/plugin-core";
2
+ /**
3
+ * Phase 4 hook for extracting `derived` manifest data from leaf source when
4
+ * no authored manifest exists. Phase 1 ships the contract only — extractor
5
+ * implementations live in `manifest-react` / `manifest-vue` and land in
6
+ * Phase 4. Until then this returns null and `components[].manifest` stays
7
+ * null for any leaf without an authored manifest.
8
+ */
9
+ export declare function extractDerivedManifest(_leafPackageDir: string): DerivedLeafPayload | null;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Phase 4 hook for extracting `derived` manifest data from leaf source when
3
+ * no authored manifest exists. Phase 1 ships the contract only — extractor
4
+ * implementations live in `manifest-react` / `manifest-vue` and land in
5
+ * Phase 4. Until then this returns null and `components[].manifest` stays
6
+ * null for any leaf without an authored manifest.
7
+ */
8
+ export function extractDerivedManifest(_leafPackageDir) {
9
+ return null;
10
+ }
11
+ //# sourceMappingURL=derived-manifest-stub.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"derived-manifest-stub.js","sourceRoot":"","sources":["../../src/manifest/derived-manifest-stub.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,eAAuB;IAC5D,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Diagnostic } from "@component-compass/plugin-core";
2
+ /**
3
+ * Builds the predicate scan.ts uses to decide whether a resolver diagnostic
4
+ * should reach stderr.
5
+ *
6
+ * Empty `packageScopes` is the explicit "no filter" signal — every
7
+ * diagnostic surfaces. Otherwise the scopes act as an allowlist matched
8
+ * against the diagnostic's `packageName`. A diagnostic with no resolvable
9
+ * `packageName` is dropped under an active filter (we cannot prove the
10
+ * source is in scope, so it is treated as out-of-scope noise) — except
11
+ * scan-level codes, which are workspace-config signals and always surface.
12
+ */
13
+ export declare function buildDiagnosticGate(packageScopes: string[]): (d: Diagnostic) => boolean;
@@ -0,0 +1,36 @@
1
+ import picomatch from "picomatch";
2
+ /**
3
+ * Codes that describe a scan-level / config-level condition rather than a
4
+ * package-specific finding. They have no `packageName` by design and must
5
+ * pass the scope gate unconditionally — the gate's job is to drop noisy
6
+ * per-package signals from out-of-scope dependencies, not to silence the
7
+ * "your scopes matched nothing" report.
8
+ */
9
+ const SCAN_LEVEL_CODES = new Set([
10
+ "no-deps-match-scopes",
11
+ ]);
12
+ /**
13
+ * Builds the predicate scan.ts uses to decide whether a resolver diagnostic
14
+ * should reach stderr.
15
+ *
16
+ * Empty `packageScopes` is the explicit "no filter" signal — every
17
+ * diagnostic surfaces. Otherwise the scopes act as an allowlist matched
18
+ * against the diagnostic's `packageName`. A diagnostic with no resolvable
19
+ * `packageName` is dropped under an active filter (we cannot prove the
20
+ * source is in scope, so it is treated as out-of-scope noise) — except
21
+ * scan-level codes, which are workspace-config signals and always surface.
22
+ */
23
+ export function buildDiagnosticGate(packageScopes) {
24
+ if (packageScopes.length === 0)
25
+ return () => true;
26
+ const matchers = packageScopes.map((p) => picomatch(p));
27
+ return (d) => {
28
+ if (SCAN_LEVEL_CODES.has(d.code))
29
+ return true;
30
+ const pkg = "packageName" in d ? d.packageName : undefined;
31
+ if (!pkg)
32
+ return false;
33
+ return matchers.some((m) => m(pkg));
34
+ };
35
+ }
36
+ //# sourceMappingURL=diagnostic-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostic-filter.js","sourceRoot":"","sources":["../../src/manifest/diagnostic-filter.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAGlC;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAqB;IACnD,sBAAsB;CACvB,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CACjC,aAAuB;IAEvB,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC;IAClD,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,OAAO,CAAC,CAAC,EAAE,EAAE;QACX,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAC9C,MAAM,GAAG,GAAG,aAAa,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3D,IAAI,CAAC,GAAG;YAAE,OAAO,KAAK,CAAC;QACvB,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { type IndexedComponent, type LazyResolverHit, type ManifestRef, type Diagnostic, type DiagnosticCollector } from "@component-compass/plugin-core";
2
+ import type { ResolveImport } from "../walker/resolve-import.js";
3
+ import type { WorkspaceGraph } from "../workspace/types.js";
4
+ export type CreateLazyResolverOptions = {
5
+ resolveImport: ResolveImport;
6
+ /**
7
+ * Anchor for `warmRoots`-style eager loads. Optional — `resolveLazyManifest`
8
+ * itself never reads it (resolution is anchored on the calling file). When
9
+ * absent, `warmRoots` falls back to `process.cwd()`.
10
+ */
11
+ repoRoot?: string;
12
+ /** Phase 4 hook; defaults to the no-op stub. */
13
+ extractDerivedManifest?: (leafPackageDir: string) => import("@component-compass/plugin-core").DerivedLeafPayload | null;
14
+ /**
15
+ * Optional shared diagnostic collector. If absent, the resolver creates
16
+ * its own internal collector accessible via `diagnostics()`.
17
+ */
18
+ collector?: DiagnosticCollector;
19
+ /**
20
+ * Workspace graph for the current scan. When provided, imports whose
21
+ * importer and target both fall inside the workspace graph short-circuit
22
+ * to `null` so the parser's local-detection pipeline classifies them —
23
+ * sibling workspace packages are consumer-owned source, not vendor.
24
+ * Omitted in unit tests that don't exercise workspace-locality.
25
+ */
26
+ workspaceGraph?: WorkspaceGraph;
27
+ };
28
+ export interface LazyResolver {
29
+ resolveLazyManifest(fromFile: string, specifier: string, exportName: string): LazyResolverHit | null;
30
+ lookupByTag(tagName: string): Extract<IndexedComponent, {
31
+ kind: "custom-element";
32
+ }> | null;
33
+ snapshotComponents(): IndexedComponent[];
34
+ snapshotManifestRefs(): ManifestRef[];
35
+ diagnostics(): Diagnostic[];
36
+ /**
37
+ * Eagerly load each named package's root CEM/CCM (if present) so the
38
+ * `byTag` cache covers tag-only consumers (HTML / Vue templates with no
39
+ * JS-side import to prime the resolver). No barrel walking — just a single
40
+ * leaf-load per package, mirroring the resolver's terminal-load step.
41
+ */
42
+ warmRoots(packageNames: string[]): void;
43
+ }
44
+ export declare function createLazyResolver(opts: CreateLazyResolverOptions): LazyResolver;