@component-compass/plugin-core 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/dist/builder.d.ts +4 -10
- package/dist/builder.js +1 -1
- package/dist/builder.js.map +1 -1
- package/dist/diagnostic.d.ts +68 -0
- package/dist/diagnostic.js +69 -0
- package/dist/diagnostic.js.map +1 -0
- package/dist/enrichment.d.ts +45 -0
- package/dist/enrichment.js +2 -0
- package/dist/enrichment.js.map +1 -0
- package/dist/id.d.ts +5 -0
- package/dist/id.js +8 -0
- package/dist/id.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/occurrence-id.d.ts +11 -0
- package/dist/occurrence-id.js +18 -0
- package/dist/occurrence-id.js.map +1 -0
- package/dist/output-types.d.ts +89 -23
- package/dist/output-types.js +0 -5
- package/dist/output-types.js.map +1 -1
- package/dist/scan-types.d.ts +66 -41
- package/dist/scan-types.js.map +1 -1
- package/dist/schema.d.ts +6 -7
- package/dist/schema.js +3 -2
- package/dist/schema.js.map +1 -1
- package/dist/types.d.ts +20 -12
- package/dist/via-types.d.ts +28 -0
- package/dist/via-types.js +2 -0
- package/dist/via-types.js.map +1 -0
- package/package.json +1 -1
package/dist/builder.d.ts
CHANGED
|
@@ -3,19 +3,13 @@ type BuilderOpts = {
|
|
|
3
3
|
source: ManifestSource;
|
|
4
4
|
package: string;
|
|
5
5
|
};
|
|
6
|
-
type AddInput =
|
|
6
|
+
type AddInput = Extract<ManifestComponent, {
|
|
7
7
|
kind: "custom-element";
|
|
8
|
-
}
|
|
9
|
-
deprecated?: boolean | string;
|
|
10
|
-
}) | (Omit<Extract<ManifestComponent, {
|
|
8
|
+
}> | Extract<ManifestComponent, {
|
|
11
9
|
kind: "react-component";
|
|
12
|
-
}
|
|
13
|
-
deprecated?: boolean | string;
|
|
14
|
-
}) | (Omit<Extract<ManifestComponent, {
|
|
10
|
+
}> | Extract<ManifestComponent, {
|
|
15
11
|
kind: "vue-component";
|
|
16
|
-
}
|
|
17
|
-
deprecated?: boolean | string;
|
|
18
|
-
});
|
|
12
|
+
}>;
|
|
19
13
|
export declare class ManifestBuilder {
|
|
20
14
|
private readonly source;
|
|
21
15
|
private readonly packageName;
|
package/dist/builder.js
CHANGED
|
@@ -19,7 +19,7 @@ export class ManifestBuilder {
|
|
|
19
19
|
if (c.kind !== expected) {
|
|
20
20
|
throw new Error(`Component kind "${c.kind}" does not match builder source "${this.source}" (expected kind "${expected}")`);
|
|
21
21
|
}
|
|
22
|
-
this.components.push(
|
|
22
|
+
this.components.push(c);
|
|
23
23
|
return this;
|
|
24
24
|
}
|
|
25
25
|
build() {
|
package/dist/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,cAAc,GAAG,OAAO,CAAC;AAE/B,MAAM,eAAe,GAAsD;IACzE,GAAG,EAAE,gBAAgB;IACrB,KAAK,EAAE,iBAAiB;IACxB,GAAG,EAAE,eAAe;CACrB,CAAC;AASF,MAAM,OAAO,eAAe;IACT,MAAM,CAAiB;IACvB,WAAW,CAAS;IACpB,UAAU,GAAwB,EAAE,CAAC;IAEtD,YAAY,IAAiB;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,YAAY,CAAC,CAAW;QACtB,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,mB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B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,WAAW;YACzB,UAAU,EAAE,MAAM;SACnB,CAAC;QACF,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACnF,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAED,SAAS,iBAAiB,CAAC,CAAoB,EAAE,CAAoB;IACnE,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,IAAI,CAAC,CAAoB;IAChC,IAAI,CAAC,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QAChC,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1E,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified diagnostic surface for parsers, resolver, and local-index.
|
|
3
|
+
* Discriminated union by `code`; severity drives `--strict` exit code.
|
|
4
|
+
*
|
|
5
|
+
* Lives in plugin-core so resolver, parsers, local-index, and CLI all
|
|
6
|
+
* share one source of truth.
|
|
7
|
+
*/
|
|
8
|
+
export type DiagnosticSeverity = "info" | "warning";
|
|
9
|
+
export type Diagnostic = {
|
|
10
|
+
code: "jsx-shape-unsupported";
|
|
11
|
+
severity: "warning";
|
|
12
|
+
filePath: string;
|
|
13
|
+
line?: number;
|
|
14
|
+
column?: number;
|
|
15
|
+
nameType: string;
|
|
16
|
+
detail: string;
|
|
17
|
+
} | {
|
|
18
|
+
code: "vue-tag-low-confidence";
|
|
19
|
+
severity: "info";
|
|
20
|
+
filePath: string;
|
|
21
|
+
line?: number;
|
|
22
|
+
column?: number;
|
|
23
|
+
tagName: string;
|
|
24
|
+
emittedAs: "vue-component" | "custom-element";
|
|
25
|
+
} | {
|
|
26
|
+
code: "local-index-duplicate-tag";
|
|
27
|
+
severity: "warning";
|
|
28
|
+
filePath: string;
|
|
29
|
+
tagName: string;
|
|
30
|
+
conflictsWith: string;
|
|
31
|
+
} | {
|
|
32
|
+
code: "barrel-unsupported-form";
|
|
33
|
+
severity: "info";
|
|
34
|
+
filePath: string;
|
|
35
|
+
form: string;
|
|
36
|
+
line?: number;
|
|
37
|
+
packageName?: string;
|
|
38
|
+
} | {
|
|
39
|
+
code: "untraceable-barrel";
|
|
40
|
+
severity: "info";
|
|
41
|
+
packageName: string;
|
|
42
|
+
resolvedFile: string;
|
|
43
|
+
} | {
|
|
44
|
+
code: "cycle-detected";
|
|
45
|
+
severity: "warning";
|
|
46
|
+
filePath: string;
|
|
47
|
+
exportName: string;
|
|
48
|
+
packageName?: string;
|
|
49
|
+
} | {
|
|
50
|
+
code: "chain-too-deep";
|
|
51
|
+
severity: "warning";
|
|
52
|
+
filePath: string;
|
|
53
|
+
exportName: string;
|
|
54
|
+
depth: number;
|
|
55
|
+
packageName?: string;
|
|
56
|
+
} | {
|
|
57
|
+
code: "no-deps-match-scopes";
|
|
58
|
+
severity: "info";
|
|
59
|
+
packageScopes: readonly string[];
|
|
60
|
+
packageManager: "yarn" | "npm" | "pnpm" | "unknown";
|
|
61
|
+
workspacePackageCount: number;
|
|
62
|
+
};
|
|
63
|
+
export interface DiagnosticCollector {
|
|
64
|
+
emit(d: Diagnostic): void;
|
|
65
|
+
drain(): Diagnostic[];
|
|
66
|
+
}
|
|
67
|
+
export type DiagnosticCode = Diagnostic["code"];
|
|
68
|
+
export declare function createDiagnosticCollector(): DiagnosticCollector;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified diagnostic surface for parsers, resolver, and local-index.
|
|
3
|
+
* Discriminated union by `code`; severity drives `--strict` exit code.
|
|
4
|
+
*
|
|
5
|
+
* Lives in plugin-core so resolver, parsers, local-index, and CLI all
|
|
6
|
+
* share one source of truth.
|
|
7
|
+
*/
|
|
8
|
+
function assertUnreachable(x) {
|
|
9
|
+
throw new Error(`Unhandled diagnostic code: ${x.code}`);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Compute a stable dedup key for a diagnostic. Two diagnostics with
|
|
13
|
+
* identical keys are treated as the same observation and only emitted once.
|
|
14
|
+
*
|
|
15
|
+
* Keys are constructed per-code from the fields that identify the OBSERVATION
|
|
16
|
+
* (e.g. file + line, or package + resolvedFile) — not the severity or
|
|
17
|
+
* descriptive `detail`/`form` fields.
|
|
18
|
+
*
|
|
19
|
+
* Note on `packageName` omission: for `barrel-unsupported-form`,
|
|
20
|
+
* `cycle-detected`, and `chain-too-deep`, the diagnostic describes a property
|
|
21
|
+
* of the barrel/re-export (file, line, exportName), not the consumer package
|
|
22
|
+
* that triggered resolution. Including `packageName` (which is the consumer's
|
|
23
|
+
* package) would un-dedup based on consumer attribution and re-introduce the
|
|
24
|
+
* noise pattern this collector exists to suppress (GH issue #12). For
|
|
25
|
+
* `untraceable-barrel`, `packageName` IS included — it's the barrel's own
|
|
26
|
+
* package name there, part of the observation identity.
|
|
27
|
+
*/
|
|
28
|
+
function dedupKey(d) {
|
|
29
|
+
switch (d.code) {
|
|
30
|
+
case "jsx-shape-unsupported":
|
|
31
|
+
return `${d.code}::${d.filePath}::${d.line ?? ""}::${d.column ?? ""}::${d.nameType}`;
|
|
32
|
+
case "vue-tag-low-confidence":
|
|
33
|
+
return `${d.code}::${d.filePath}::${d.line ?? ""}::${d.column ?? ""}::${d.tagName}`;
|
|
34
|
+
case "local-index-duplicate-tag":
|
|
35
|
+
return `${d.code}::${d.filePath}::${d.tagName}`;
|
|
36
|
+
case "barrel-unsupported-form":
|
|
37
|
+
return `${d.code}::${d.filePath}::${d.line ?? ""}::${d.form}`;
|
|
38
|
+
case "untraceable-barrel":
|
|
39
|
+
return `${d.code}::${d.packageName}::${d.resolvedFile}`;
|
|
40
|
+
case "cycle-detected":
|
|
41
|
+
return `${d.code}::${d.filePath}::${d.exportName}`;
|
|
42
|
+
case "chain-too-deep":
|
|
43
|
+
return `${d.code}::${d.filePath}::${d.exportName}`;
|
|
44
|
+
case "no-deps-match-scopes":
|
|
45
|
+
return `${d.code}::${d.packageScopes.join(",")}::${d.packageManager}`;
|
|
46
|
+
default:
|
|
47
|
+
return assertUnreachable(d);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function createDiagnosticCollector() {
|
|
51
|
+
const seen = new Set();
|
|
52
|
+
const ordered = [];
|
|
53
|
+
return {
|
|
54
|
+
emit(d) {
|
|
55
|
+
const key = dedupKey(d);
|
|
56
|
+
if (seen.has(key))
|
|
57
|
+
return;
|
|
58
|
+
seen.add(key);
|
|
59
|
+
ordered.push(d);
|
|
60
|
+
},
|
|
61
|
+
drain() {
|
|
62
|
+
const out = ordered.slice();
|
|
63
|
+
ordered.length = 0;
|
|
64
|
+
seen.clear();
|
|
65
|
+
return out;
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=diagnostic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic.js","sourceRoot":"","sources":["../src/diagnostic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2EH,SAAS,iBAAiB,CAAC,CAAQ;IACjC,MAAM,IAAI,KAAK,CAAC,8BAA+B,CAAsB,CAAC,IAAI,EAAE,CAAC,CAAC;AAChF,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AAC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xE;YACE,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAID,MAAM,UAAU,yBAAyB;IACvC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,OAAO;QACL,IAAI,CAAC,CAAC;YACJ,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YACxB,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,OAAO;YAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,KAAK;YACH,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;YAC5B,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;YACnB,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,OAAO,GAAG,CAAC;QACb,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { IndexedComponent } from "./scan-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Manifest source for enrichment of a resolver-discovered leaf package.
|
|
4
|
+
*
|
|
5
|
+
* - "authored": leaf shipped a `custom-elements.json` or
|
|
6
|
+
* `component-compass-manifest.json` at its package root.
|
|
7
|
+
* - "derived": leaf carries no authored manifest but `manifest-react` /
|
|
8
|
+
* `manifest-vue` extractors (Phase 4) produced one from source.
|
|
9
|
+
* - null: no enrichment available — identity stays opaque
|
|
10
|
+
* (`components[].manifest === null` in the artifact).
|
|
11
|
+
*
|
|
12
|
+
* Open envelope: `data` shape grows in Phase 3 (CEM depth) and Phase 4
|
|
13
|
+
* (extractor maturity) without changing this discriminator.
|
|
14
|
+
*/
|
|
15
|
+
export type Enrichment = {
|
|
16
|
+
source: "authored";
|
|
17
|
+
data: AuthoredLeafPayload;
|
|
18
|
+
} | {
|
|
19
|
+
source: "derived";
|
|
20
|
+
data: DerivedLeafPayload;
|
|
21
|
+
} | null;
|
|
22
|
+
/**
|
|
23
|
+
* Payload shape held by the lazy resolver for a successfully-loaded leaf
|
|
24
|
+
* manifest. Per-leaf, not per-component — carries every component the leaf
|
|
25
|
+
* declares plus the manifest source metadata.
|
|
26
|
+
*/
|
|
27
|
+
export type AuthoredLeafPayload = {
|
|
28
|
+
/** Every component declared in the leaf's authored manifest. */
|
|
29
|
+
components: IndexedComponent[];
|
|
30
|
+
/** Absolute filesystem path of the loaded manifest file. */
|
|
31
|
+
manifestPath: string;
|
|
32
|
+
/** Authored format the manifest was loaded from. */
|
|
33
|
+
manifestKind: "cem" | "component-compass-manifest";
|
|
34
|
+
/** Leaf package's `version` field, when readable. */
|
|
35
|
+
packageVersion?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Phase 4 hook: per-leaf payload populated by the source-extraction fallback
|
|
39
|
+
* (manifest-react / manifest-vue extractors). Same per-leaf shape as
|
|
40
|
+
* `AuthoredLeafPayload`; field set narrows to whatever the extractors recover.
|
|
41
|
+
*/
|
|
42
|
+
export type DerivedLeafPayload = {
|
|
43
|
+
/** Components extracted from leaf source by Phase 4 extractors. */
|
|
44
|
+
components: IndexedComponent[];
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichment.js","sourceRoot":"","sources":["../src/enrichment.ts"],"names":[],"mappings":""}
|
package/dist/id.d.ts
CHANGED
|
@@ -2,3 +2,8 @@ import type { ComponentId, ComponentSource } from "./types.js";
|
|
|
2
2
|
export declare function externalPackageOf(source: ComponentSource): string;
|
|
3
3
|
export declare function serialiseComponentId(id: ComponentId): string;
|
|
4
4
|
export declare function compareComponentId(a: ComponentId, b: ComponentId): number;
|
|
5
|
+
export declare function parseCompoundExport(exportName: string): {
|
|
6
|
+
root: string;
|
|
7
|
+
path: string[];
|
|
8
|
+
isCompound: boolean;
|
|
9
|
+
};
|
package/dist/id.js
CHANGED
|
@@ -28,4 +28,12 @@ export function serialiseComponentId(id) {
|
|
|
28
28
|
export function compareComponentId(a, b) {
|
|
29
29
|
return serialiseComponentId(a).localeCompare(serialiseComponentId(b));
|
|
30
30
|
}
|
|
31
|
+
export function parseCompoundExport(exportName) {
|
|
32
|
+
const [root, ...path] = exportName.split(".");
|
|
33
|
+
return {
|
|
34
|
+
root: root ?? "",
|
|
35
|
+
path,
|
|
36
|
+
isCompound: path.length > 0,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
31
39
|
//# sourceMappingURL=id.js.map
|
package/dist/id.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id.js","sourceRoot":"","sources":["../src/id.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iBAAiB,CAAC,MAAuB;IACvD,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU;QAAE,OAAO,MAAM,CAAC,OAAO,CAAC;IACtD,MAAM,IAAI,KAAK,CACb,2DAA2D,MAAM,CAAC,IAAI,qEAAqE,CAC5I,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,MAAuB;IAC5C,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,UAAU;YACb,OAAO,YAAY,MAAM,CAAC,OAAO,EAAE,CAAC;QACtC,KAAK,OAAO;YACV,OAAO,SAAS,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpC,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,EAAe;IACtC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;QAChB,KAAK,gBAAgB;YACnB,OAAO,EAAE,CAAC,OAAO,CAAC;QACpB,KAAK,iBAAiB,CAAC;QACvB,KAAK,eAAe;YAClB,OAAO,EAAE,CAAC,MAAM,CAAC;IACrB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,EAAe;IAClD,OAAO,GA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,MAAM,UAAU,kBAAkB,CAAC,CAAc,EAAE,CAAc;IAC/D,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,UAAkB;IAKpD,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9C,OAAO;QACL,IAAI,EAAE,IAAI,IAAI,EAAE;QAChB,IAAI;QACJ,UAAU,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC;KAC5B,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export type { ComponentId, ComponentKind, ComponentSource, Lifecycle, ManifestComponent, ManifestEvent, ManifestFile, ManifestProp, ManifestSlot, ManifestSource, } from "./types.js";
|
|
2
|
-
export { serialiseComponentId, compareComponentId, externalPackageOf } from "./id.js";
|
|
2
|
+
export { serialiseComponentId, compareComponentId, externalPackageOf, parseCompoundExport } from "./id.js";
|
|
3
3
|
export { validateManifest } from "./validate.js";
|
|
4
4
|
export type { ValidationResult } from "./validate.js";
|
|
5
5
|
export { manifestJsonSchema } from "./schema.js";
|
|
6
6
|
export { ManifestBuilder } from "./builder.js";
|
|
7
|
-
export type { TagName, WrapperId, ImportRole, ImportEntry, IndexedComponent,
|
|
7
|
+
export type { TagName, WrapperId, ImportRole, ImportEntry, IndexedComponent, Loc, WarningCode, Warning, ScanConfig, PropUsage, OccurrenceVia, Occurrence, WrapperDef, FileImport, ParseResult, ParseContext, ParserPlugin, ScanEnvelope, ScanOutput, ManifestRef, ScanStats, DetectorId, LocalDefinition, LocalDefinitionIndex, ResolveLazyManifest, LookupByTag, LazyResolverHit, } from "./scan-types.js";
|
|
8
8
|
export { asTagName, asWrapperId, emptyLocalIndex } from "./scan-types.js";
|
|
9
|
+
export type { Enrichment, AuthoredLeafPayload, DerivedLeafPayload } from "./enrichment.js";
|
|
10
|
+
export { computeOccurrenceId } from "./occurrence-id.js";
|
|
11
|
+
export type { CompositionRollup } from "./output-types.js";
|
|
9
12
|
export * from "./output-types.js";
|
|
13
|
+
export type { Diagnostic, DiagnosticSeverity, DiagnosticCollector, DiagnosticCode } from "./diagnostic.js";
|
|
14
|
+
export { createDiagnosticCollector } from "./diagnostic.js";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export { serialiseComponentId, compareComponentId, externalPackageOf } from "./id.js";
|
|
1
|
+
export { serialiseComponentId, compareComponentId, externalPackageOf, parseCompoundExport } from "./id.js";
|
|
2
2
|
export { validateManifest } from "./validate.js";
|
|
3
3
|
export { manifestJsonSchema } from "./schema.js";
|
|
4
4
|
export { ManifestBuilder } from "./builder.js";
|
|
5
5
|
export { asTagName, asWrapperId, emptyLocalIndex } from "./scan-types.js";
|
|
6
|
+
export { computeOccurrenceId } from "./occurrence-id.js";
|
|
6
7
|
export * from "./output-types.js";
|
|
8
|
+
export { createDiagnosticCollector } from "./diagnostic.js";
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC3G,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAc/C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAI1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable per-occurrence id keyed on (componentId, filePath, line, column).
|
|
3
|
+
*
|
|
4
|
+
* Inputs use the FINAL artifact componentId string (the hashed form that
|
|
5
|
+
* appears on `OutputOccurrence.componentId`), so downstream consumers can
|
|
6
|
+
* re-derive: `id === computeOccurrenceId(o.componentId, o.filePath, o.line, o.column)`.
|
|
7
|
+
*
|
|
8
|
+
* 64 bits of entropy via 16-char SHA-256 truncation. Birthday-bound collision
|
|
9
|
+
* at ~4 billion occurrences; full hash is overkill for current scale.
|
|
10
|
+
*/
|
|
11
|
+
export declare function computeOccurrenceId(componentId: string, filePath: string, line: number, column: number): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
/**
|
|
3
|
+
* Stable per-occurrence id keyed on (componentId, filePath, line, column).
|
|
4
|
+
*
|
|
5
|
+
* Inputs use the FINAL artifact componentId string (the hashed form that
|
|
6
|
+
* appears on `OutputOccurrence.componentId`), so downstream consumers can
|
|
7
|
+
* re-derive: `id === computeOccurrenceId(o.componentId, o.filePath, o.line, o.column)`.
|
|
8
|
+
*
|
|
9
|
+
* 64 bits of entropy via 16-char SHA-256 truncation. Birthday-bound collision
|
|
10
|
+
* at ~4 billion occurrences; full hash is overkill for current scale.
|
|
11
|
+
*/
|
|
12
|
+
export function computeOccurrenceId(componentId, filePath, line, column) {
|
|
13
|
+
return createHash("sha256")
|
|
14
|
+
.update(`${componentId}|${filePath}|${line}|${column}`)
|
|
15
|
+
.digest("hex")
|
|
16
|
+
.slice(0, 16);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=occurrence-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"occurrence-id.js","sourceRoot":"","sources":["../src/occurrence-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CACjC,WAAmB,EACnB,QAAgB,EAChB,IAAY,EACZ,MAAc;IAEd,OAAO,UAAU,CAAC,QAAQ,CAAC;SACxB,MAAM,CAAC,GAAG,WAAW,IAAI,QAAQ,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;SACtD,MAAM,CAAC,KAAK,CAAC;SACb,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
package/dist/output-types.d.ts
CHANGED
|
@@ -3,37 +3,78 @@
|
|
|
3
3
|
* occurrences). Lives in plugin-core so consumers (cli, future analytics,
|
|
4
4
|
* agents) share one source of truth without depending on cli internals.
|
|
5
5
|
*/
|
|
6
|
+
import type { OccurrenceVia } from "./via-types.js";
|
|
7
|
+
import type { Lifecycle } from "./types.js";
|
|
6
8
|
export type ComponentScope = "ds" | "external" | "local";
|
|
7
9
|
export type ComponentKindOutput = "custom-element" | "react-component" | "vue-component";
|
|
8
|
-
export type ViaKindOutput = "html-tag" | "lit-template" | "react-wrapper" | "direct-import" | "vue-template";
|
|
9
10
|
export type OutputIdentity = {
|
|
10
11
|
scope: ComponentScope;
|
|
11
12
|
kind: ComponentKindOutput;
|
|
12
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* For ds + external lanes: the npm package name as resolved by the manifest layer.
|
|
15
|
+
* For local lane: the owning workspace package's name when the file resides inside
|
|
16
|
+
* one. Absent for root-level local files (non-workspace single-package repos).
|
|
17
|
+
*/
|
|
13
18
|
packageName?: string;
|
|
14
19
|
/** For react-component / vue-component. */
|
|
15
20
|
exportName?: string;
|
|
16
21
|
/** For custom-element. */
|
|
17
22
|
tagName?: string;
|
|
18
|
-
via: {
|
|
19
|
-
kind: ViaKindOutput;
|
|
20
|
-
};
|
|
21
23
|
/** Present for local; absent for ds/external. */
|
|
22
24
|
repoId?: string;
|
|
23
25
|
/** Present for local; absent for ds/external. Repo-relative path of the defining file. */
|
|
24
26
|
filePath?: string;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Source position of the local-component declaration (the function/class
|
|
29
|
+
* keyword for declarations; the variable identifier for `const Foo = ...`).
|
|
30
|
+
* Only set when `scope === "local"`. Absent for ds / external / wc.
|
|
31
|
+
*/
|
|
32
|
+
definition?: {
|
|
33
|
+
line: number;
|
|
34
|
+
column: number;
|
|
33
35
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
};
|
|
37
|
+
export type PropDecl = {
|
|
38
|
+
type?: string;
|
|
39
|
+
default?: string | number | boolean | null;
|
|
40
|
+
values?: string[];
|
|
41
|
+
required?: boolean;
|
|
42
|
+
description?: string;
|
|
43
|
+
lifecycle?: Lifecycle;
|
|
44
|
+
};
|
|
45
|
+
export type SlotDecl = {
|
|
46
|
+
description?: string;
|
|
47
|
+
lifecycle?: Lifecycle;
|
|
48
|
+
};
|
|
49
|
+
export type InvocableDecl = {
|
|
50
|
+
kind: "dom-event" | "callback-prop";
|
|
51
|
+
payloadType?: string;
|
|
52
|
+
description?: string;
|
|
53
|
+
lifecycle?: Lifecycle;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Per-component manifest payload as it appears in `component-compass.json`.
|
|
57
|
+
* Field set is the closed-form Phase 3 schema (trimmed): description, lifecycle,
|
|
58
|
+
* and the three per-feature record maps. Methods, CSS surfaces, inheritance,
|
|
59
|
+
* and `since` are deferred to later sub-plans / phases.
|
|
60
|
+
*/
|
|
61
|
+
export type AuthoredManifestData = {
|
|
62
|
+
description?: string;
|
|
63
|
+
lifecycle?: Lifecycle;
|
|
64
|
+
props?: Record<string, PropDecl>;
|
|
65
|
+
slots?: Record<string, SlotDecl>;
|
|
66
|
+
invocable?: Record<string, InvocableDecl>;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Phase 4 hook: per-component payload populated by source-extraction fallback.
|
|
70
|
+
* Structurally a subset of `AuthoredManifestData`; ships empty in Phase 3.
|
|
71
|
+
*/
|
|
72
|
+
export type DerivedManifestData = {
|
|
73
|
+
description?: string;
|
|
74
|
+
lifecycle?: Lifecycle;
|
|
75
|
+
props?: Record<string, PropDecl>;
|
|
76
|
+
slots?: Record<string, SlotDecl>;
|
|
77
|
+
invocable?: Record<string, InvocableDecl>;
|
|
37
78
|
};
|
|
38
79
|
export type DynamicKind = "spread" | "expr" | "identifier";
|
|
39
80
|
/**
|
|
@@ -52,28 +93,53 @@ export type PropDistribution = {
|
|
|
52
93
|
omitted: number;
|
|
53
94
|
defaultApplied: number;
|
|
54
95
|
};
|
|
55
|
-
export type
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
|
|
96
|
+
export type CompositionRollup = {
|
|
97
|
+
/** child componentId → count of occurrences owned by this component (owner-edge children). */
|
|
98
|
+
rendersByCount: Record<string, number>;
|
|
99
|
+
/** parent componentId → count of occurrences in which this component is owned by that parent. */
|
|
100
|
+
renderedByCount: Record<string, number>;
|
|
101
|
+
/** # of this component's occurrences with no ownerComponentId. */
|
|
102
|
+
isRootCount: number;
|
|
103
|
+
/** # of this component's occurrences whose component has empty rendersByCount. */
|
|
104
|
+
isLeafCount: number;
|
|
60
105
|
};
|
|
61
106
|
export type OutputComponent = {
|
|
62
107
|
id: string;
|
|
63
108
|
identity: OutputIdentity;
|
|
64
109
|
derivedTags: string[];
|
|
65
|
-
manifest:
|
|
110
|
+
manifest: {
|
|
111
|
+
source: "authored";
|
|
112
|
+
data: AuthoredManifestData;
|
|
113
|
+
} | {
|
|
114
|
+
source: "derived";
|
|
115
|
+
data: DerivedManifestData;
|
|
116
|
+
} | null;
|
|
66
117
|
stats: {
|
|
67
118
|
occurrenceCount: number;
|
|
68
119
|
fileCount: number;
|
|
69
120
|
};
|
|
70
121
|
props: Record<string, PropDistribution>;
|
|
71
|
-
|
|
122
|
+
/** Per-component composition rollup (owner-edge driven). Always emitted. */
|
|
123
|
+
composition?: CompositionRollup;
|
|
72
124
|
};
|
|
73
125
|
export type OutputOccurrence = {
|
|
74
126
|
componentId: string;
|
|
75
127
|
filePath: string;
|
|
76
128
|
line: number;
|
|
77
129
|
column: number;
|
|
130
|
+
via: OccurrenceVia;
|
|
78
131
|
props: Record<string, PropValueState>;
|
|
132
|
+
/** Phase 2: stable id keyed on (componentId, filePath, line, column). */
|
|
133
|
+
occurrenceId: string;
|
|
134
|
+
/** Phase 2: occurrenceId of nearest tracked ancestor. Absent if root in this scope. */
|
|
135
|
+
parentOccurrenceId?: string;
|
|
136
|
+
/** Phase 2: distance from highest tracked-rootless ancestor in same lexical scope. */
|
|
137
|
+
depth?: number;
|
|
138
|
+
/**
|
|
139
|
+
* Stable id of the component-definition that lexically contains this call
|
|
140
|
+
* site (the enclosing function/class). Drives the owner-edge composition
|
|
141
|
+
* graph. Absent when the occurrence is module-scope JSX, in a `.html`
|
|
142
|
+
* file, or the parser couldn't resolve an enclosing tracked component.
|
|
143
|
+
*/
|
|
144
|
+
ownerComponentId?: string;
|
|
79
145
|
};
|
package/dist/output-types.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types describing the CLI's emitted JSON artifact (two-grain: components +
|
|
3
|
-
* occurrences). Lives in plugin-core so consumers (cli, future analytics,
|
|
4
|
-
* agents) share one source of truth without depending on cli internals.
|
|
5
|
-
*/
|
|
6
1
|
export {};
|
|
7
2
|
//# sourceMappingURL=output-types.js.map
|
package/dist/output-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-types.js","sourceRoot":"","sources":["../src/output-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"output-types.js","sourceRoot":"","sources":["../src/output-types.ts"],"names":[],"mappings":""}
|
package/dist/scan-types.d.ts
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* parser ↔ CLI boundary lives here in `plugin-core`.
|
|
7
7
|
*/
|
|
8
8
|
import type { OutputComponent, OutputOccurrence } from "./output-types.js";
|
|
9
|
-
import type {
|
|
9
|
+
import type { Diagnostic, DiagnosticCollector } from "./diagnostic.js";
|
|
10
|
+
import type { ComponentId, ManifestComponent, ManifestSource } from "./types.js";
|
|
11
|
+
import type { OccurrenceVia } from "./via-types.js";
|
|
10
12
|
declare const __brand: unique symbol;
|
|
11
13
|
type Brand<K, T> = K & {
|
|
12
14
|
readonly [__brand]: T;
|
|
@@ -29,22 +31,21 @@ export type IndexedComponent = (Extract<ManifestComponent, {
|
|
|
29
31
|
}) | Extract<ManifestComponent, {
|
|
30
32
|
kind: "react-component" | "vue-component";
|
|
31
33
|
}>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
byNativeSpecifier: Map<string, Extract<IndexedComponent, {
|
|
43
|
-
kind: "custom-element";
|
|
44
|
-
}>>;
|
|
45
|
-
/** Local-component definitions discovered in repo source. */
|
|
46
|
-
local: LocalDefinitionIndex;
|
|
34
|
+
/**
|
|
35
|
+
* A single resolution outcome for one `(fromFile, specifier, exportName)`
|
|
36
|
+
* triple. `matched` is null when the resolved leaf has no manifest entry
|
|
37
|
+
* for `exportName` — the caller should fall back to opaque opportunistic
|
|
38
|
+
* emission (current `react-component` / `vue-component` with `manifest: null`
|
|
39
|
+
* shape, package = `leafPackage`).
|
|
40
|
+
*/
|
|
41
|
+
export type LazyResolverHit = {
|
|
42
|
+
leafPackage: string;
|
|
43
|
+
matched: IndexedComponent | null;
|
|
47
44
|
};
|
|
45
|
+
export type ResolveLazyManifest = (fromFile: string, specifier: string, exportName: string) => LazyResolverHit | null;
|
|
46
|
+
export type LookupByTag = (tagName: string) => Extract<IndexedComponent, {
|
|
47
|
+
kind: "custom-element";
|
|
48
|
+
}> | null;
|
|
48
49
|
export type DetectorId = "react-default-fn" | "react-arrow" | "react-class" | "react-forward-ref" | "react-memo" | "vue-sfc" | "vue-define-component" | "vue-functional" | "wc-decorator" | "wc-customelements-define";
|
|
49
50
|
export type LocalDefinition = {
|
|
50
51
|
/** componentId.source is always { type: "local", filePath }. */
|
|
@@ -58,6 +59,8 @@ export type LocalDefinition = {
|
|
|
58
59
|
/** True when emitted via `export default`. */
|
|
59
60
|
isDefault: boolean;
|
|
60
61
|
detector: DetectorId;
|
|
62
|
+
/** Source position of the declaration site. Populated by detectors. */
|
|
63
|
+
loc?: Loc;
|
|
61
64
|
};
|
|
62
65
|
export type LocalDefinitionIndex = {
|
|
63
66
|
/** POSIX repo-relative filePath → definitions in that file. */
|
|
@@ -71,7 +74,7 @@ export type Loc = {
|
|
|
71
74
|
line: number;
|
|
72
75
|
column: number;
|
|
73
76
|
};
|
|
74
|
-
export type WarningCode = "
|
|
77
|
+
export type WarningCode = "PARSE_FAILURE" | "IMPORT_UNRESOLVABLE" | "MANIFEST_TAG_COLLISION" | "EMPTY_INCLUDE";
|
|
75
78
|
interface WarningBase {
|
|
76
79
|
message: string;
|
|
77
80
|
}
|
|
@@ -83,10 +86,6 @@ export type Warning = (WarningBase & {
|
|
|
83
86
|
code: "IMPORT_UNRESOLVABLE";
|
|
84
87
|
file: string;
|
|
85
88
|
line: number;
|
|
86
|
-
}) | (WarningBase & {
|
|
87
|
-
code: "MISSING_REACT_EXPORT_EXTENSION";
|
|
88
|
-
package: string;
|
|
89
|
-
file: string;
|
|
90
89
|
}) | (WarningBase & {
|
|
91
90
|
code: "MANIFEST_TAG_COLLISION";
|
|
92
91
|
package: string;
|
|
@@ -115,30 +114,36 @@ export type PropUsage = {
|
|
|
115
114
|
*/
|
|
116
115
|
dynamicKind?: "spread" | "expr" | "identifier";
|
|
117
116
|
};
|
|
118
|
-
export type OccurrenceVia
|
|
119
|
-
kind: "html-tag";
|
|
120
|
-
} | {
|
|
121
|
-
kind: "lit-template";
|
|
122
|
-
specifier?: string;
|
|
123
|
-
} | {
|
|
124
|
-
kind: "react-wrapper";
|
|
125
|
-
specifier: string;
|
|
126
|
-
import: string;
|
|
127
|
-
} | {
|
|
128
|
-
kind: "direct-import";
|
|
129
|
-
specifier: string;
|
|
130
|
-
import: string;
|
|
131
|
-
} | {
|
|
132
|
-
kind: "vue-template";
|
|
133
|
-
specifier: string;
|
|
134
|
-
import: string;
|
|
135
|
-
};
|
|
117
|
+
export type { OccurrenceVia } from "./via-types.js";
|
|
136
118
|
export type Occurrence = {
|
|
137
119
|
componentId: ComponentId;
|
|
138
120
|
loc: Loc;
|
|
139
121
|
via: OccurrenceVia;
|
|
140
122
|
props: PropUsage[];
|
|
141
123
|
events: string[];
|
|
124
|
+
/**
|
|
125
|
+
* Phase 2: parser-side parent reference. Index into the same
|
|
126
|
+
* ParseResult.occurrences array. `undefined` = no tracked parent in this
|
|
127
|
+
* lexical scope. The CLI's projection layer (`parseResultsToOccurrences`)
|
|
128
|
+
* resolves this index into a `parentOccurrenceId` string; downstream
|
|
129
|
+
* queries needing the parent's componentId look it up via the flat
|
|
130
|
+
* occurrence stream. Cross-file composition is out of scope (per spec
|
|
131
|
+
* non-goal), so the index is local to one ParseResult.
|
|
132
|
+
*/
|
|
133
|
+
parentRef?: number;
|
|
134
|
+
/**
|
|
135
|
+
* Phase 2: distance from the highest tracked-rootless ancestor in the
|
|
136
|
+
* same lexical scope. 0 for roots; matches `parentStack.length` at the
|
|
137
|
+
* time the occurrence was emitted.
|
|
138
|
+
*/
|
|
139
|
+
depth?: number;
|
|
140
|
+
/**
|
|
141
|
+
* ComponentId of the enclosing component-definition. Resolved by parsers
|
|
142
|
+
* via ancestor walk. The CLI projection layer hashes this into
|
|
143
|
+
* `OutputOccurrence.ownerComponentId`. Undefined when no enclosing tracked
|
|
144
|
+
* component was found.
|
|
145
|
+
*/
|
|
146
|
+
ownerComponentId?: ComponentId;
|
|
142
147
|
};
|
|
143
148
|
export type WrapperDef = {
|
|
144
149
|
id: WrapperId;
|
|
@@ -161,10 +166,15 @@ export type ParseResult = {
|
|
|
161
166
|
warnings: Warning[];
|
|
162
167
|
};
|
|
163
168
|
export type ParseContext = {
|
|
164
|
-
|
|
169
|
+
/** Local-component definitions discovered in repo source. */
|
|
170
|
+
localIndex: LocalDefinitionIndex;
|
|
165
171
|
config: ScanConfig;
|
|
166
172
|
resolveImport: (from: string, spec: string) => string | null;
|
|
173
|
+
resolveLazyManifest: ResolveLazyManifest;
|
|
174
|
+
lookupByTag: LookupByTag;
|
|
167
175
|
repoRoot: string;
|
|
176
|
+
/** Shared diagnostic collector for the scan run. */
|
|
177
|
+
collector?: DiagnosticCollector;
|
|
168
178
|
};
|
|
169
179
|
export interface ParserPlugin {
|
|
170
180
|
name: string;
|
|
@@ -180,9 +190,24 @@ export type ScanEnvelope = {
|
|
|
180
190
|
toolVersion: string;
|
|
181
191
|
cwd: string;
|
|
182
192
|
};
|
|
193
|
+
export type ManifestRef = {
|
|
194
|
+
source: ManifestSource;
|
|
195
|
+
package: string;
|
|
196
|
+
path: string;
|
|
197
|
+
version: string | null;
|
|
198
|
+
};
|
|
199
|
+
export type ScanStats = {
|
|
200
|
+
filesScanned: number;
|
|
201
|
+
filesWithUsage: number;
|
|
202
|
+
scanDurationMs: number;
|
|
203
|
+
componentsDetected: number;
|
|
204
|
+
totalOccurrences: number;
|
|
205
|
+
};
|
|
183
206
|
export type ScanOutput = {
|
|
184
207
|
envelope: ScanEnvelope;
|
|
208
|
+
manifests: ManifestRef[];
|
|
209
|
+
stats: ScanStats;
|
|
185
210
|
components: OutputComponent[];
|
|
186
211
|
occurrences: OutputOccurrence[];
|
|
212
|
+
diagnostics: Diagnostic[];
|
|
187
213
|
};
|
|
188
|
-
export {};
|
package/dist/scan-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-types.js","sourceRoot":"","sources":["../src/scan-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scan-types.js","sourceRoot":"","sources":["../src/scan-types.ts"],"names":[],"mappings":"AAsBA,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAW,EAAE,CAAC,CAAY,CAAC;AAC9D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAS,EAAa,EAAE,CAAC,CAAc,CAAC;AAsFpE,MAAM,CAAC,MAAM,eAAe,GAAyB;IACnD,MAAM,EAAE,IAAI,GAAG,EAAE;IACjB,KAAK,EAAE,IAAI,GAAG,EAAE;CACjB,CAAC"}
|
package/dist/schema.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const manifestJsonSchema: {
|
|
|
18
18
|
readonly type: "array";
|
|
19
19
|
readonly items: {
|
|
20
20
|
readonly type: "object";
|
|
21
|
-
readonly required: readonly ["kind", "source", "
|
|
21
|
+
readonly required: readonly ["kind", "source", "props"];
|
|
22
22
|
readonly properties: {
|
|
23
23
|
readonly kind: {
|
|
24
24
|
readonly enum: readonly ["custom-element", "react-component", "vue-component"];
|
|
@@ -69,12 +69,11 @@ export declare const manifestJsonSchema: {
|
|
|
69
69
|
readonly tagName: {
|
|
70
70
|
readonly type: "string";
|
|
71
71
|
};
|
|
72
|
-
readonly
|
|
73
|
-
readonly
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}];
|
|
72
|
+
readonly description: {
|
|
73
|
+
readonly type: "string";
|
|
74
|
+
};
|
|
75
|
+
readonly lifecycle: {
|
|
76
|
+
readonly type: "object";
|
|
78
77
|
};
|
|
79
78
|
readonly props: {
|
|
80
79
|
readonly type: "array";
|
package/dist/schema.js
CHANGED
|
@@ -12,7 +12,7 @@ export const manifestJsonSchema = {
|
|
|
12
12
|
type: "array",
|
|
13
13
|
items: {
|
|
14
14
|
type: "object",
|
|
15
|
-
required: ["kind", "source", "
|
|
15
|
+
required: ["kind", "source", "props"],
|
|
16
16
|
properties: {
|
|
17
17
|
kind: { enum: ["custom-element", "react-component", "vue-component"] },
|
|
18
18
|
source: {
|
|
@@ -32,7 +32,8 @@ export const manifestJsonSchema = {
|
|
|
32
32
|
},
|
|
33
33
|
export: { type: "string" },
|
|
34
34
|
tagName: { type: "string" },
|
|
35
|
-
|
|
35
|
+
description: { type: "string" },
|
|
36
|
+
lifecycle: { type: "object" },
|
|
36
37
|
props: { type: "array", items: { type: "object", required: ["name"], properties: { name: { type: "string" } } } },
|
|
37
38
|
events: { type: "array" },
|
|
38
39
|
slots: { type: "array" },
|
package/dist/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,GAAG,EAAE,mDAAmD;IACxD,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,eAAe,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC;IAC9D,oBAAoB,EAAE,IAAI;IAC1B,UAAU,EAAE;QACV,aAAa,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;QACjC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE;QACzC,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE;QACzC,UAAU,EAAE;YACV,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/sch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|
|
23
23
|
};
|
|
24
|
+
export type Lifecycle = {
|
|
25
|
+
status: "stable";
|
|
26
|
+
} | {
|
|
27
|
+
status: "deprecated";
|
|
28
|
+
supersededBy?: {
|
|
29
|
+
packageName: string;
|
|
30
|
+
exportName: string;
|
|
31
|
+
};
|
|
32
|
+
deprecationReason?: string;
|
|
33
|
+
};
|
|
24
34
|
export type ManifestProp = {
|
|
25
35
|
name: string;
|
|
26
36
|
type?: string;
|
|
27
|
-
deprecated?: boolean | string;
|
|
28
37
|
default?: string | number | boolean | null;
|
|
38
|
+
values?: string[];
|
|
39
|
+
required?: boolean;
|
|
40
|
+
description?: string;
|
|
41
|
+
lifecycle?: Lifecycle;
|
|
29
42
|
};
|
|
30
43
|
export type ManifestEvent = {
|
|
31
44
|
name: string;
|
|
32
|
-
|
|
45
|
+
payloadType?: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
lifecycle?: Lifecycle;
|
|
33
48
|
};
|
|
34
49
|
export type ManifestSlot = {
|
|
35
50
|
name: string;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
status: "stable";
|
|
39
|
-
} | {
|
|
40
|
-
status: "deprecated";
|
|
41
|
-
supersededBy?: {
|
|
42
|
-
packageName: string;
|
|
43
|
-
exportName: string;
|
|
44
|
-
};
|
|
51
|
+
description?: string;
|
|
52
|
+
lifecycle?: Lifecycle;
|
|
45
53
|
};
|
|
46
54
|
type ComponentBase = {
|
|
47
55
|
source: ComponentSource;
|
|
48
|
-
|
|
56
|
+
description?: string;
|
|
49
57
|
props: ManifestProp[];
|
|
50
58
|
lifecycle?: Lifecycle;
|
|
51
59
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discriminated union describing how a component instance was used.
|
|
3
|
+
* Shared between parser-emitted Occurrence (scan-types.ts) and the artifact-shape
|
|
4
|
+
* OutputOccurrence (output-types.ts). Lives in its own module to keep the two
|
|
5
|
+
* type files acyclic.
|
|
6
|
+
*/
|
|
7
|
+
export type OccurrenceVia = {
|
|
8
|
+
kind: "html-tag";
|
|
9
|
+
} | {
|
|
10
|
+
kind: "lit-template";
|
|
11
|
+
specifier?: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "react-wrapper";
|
|
14
|
+
specifier: string;
|
|
15
|
+
import: string;
|
|
16
|
+
} | {
|
|
17
|
+
kind: "direct-import";
|
|
18
|
+
specifier: string;
|
|
19
|
+
import: string;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "vue-template";
|
|
22
|
+
specifier: string;
|
|
23
|
+
import: string;
|
|
24
|
+
} | {
|
|
25
|
+
kind: "context-provider";
|
|
26
|
+
} | {
|
|
27
|
+
kind: "local-component";
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"via-types.js","sourceRoot":"","sources":["../src/via-types.ts"],"names":[],"mappings":""}
|