@component-compass/plugin-core 0.1.5 → 0.1.7
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/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/output-types.d.ts +74 -8
- package/dist/project-props.d.ts +16 -0
- package/dist/project-props.js +36 -0
- package/dist/project-props.js.map +1 -0
- package/dist/scan-types.d.ts +26 -7
- package/dist/scan-types.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ export { asTagName, asWrapperId, emptyLocalIndex } from "./scan-types.js";
|
|
|
9
9
|
export type { Enrichment, AuthoredLeafPayload } from "./enrichment.js";
|
|
10
10
|
export { normalizeOwnerPath } from "./owner-utils.js";
|
|
11
11
|
export { computeOccurrenceId } from "./occurrence-id.js";
|
|
12
|
-
export
|
|
12
|
+
export { projectPropUsages, classifyExprText } from "./project-props.js";
|
|
13
|
+
export type { CompositionRollup, DeclaredProp, DeclaredPropApi } from "./output-types.js";
|
|
13
14
|
export * from "./output-types.js";
|
|
14
15
|
export type { Diagnostic, DiagnosticSeverity, DiagnosticCollector, DiagnosticCode } from "./diagnostic.js";
|
|
15
16
|
export { createDiagnosticCollector } from "./diagnostic.js";
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { ManifestBuilder } from "./builder.js";
|
|
|
5
5
|
export { asTagName, asWrapperId, emptyLocalIndex } from "./scan-types.js";
|
|
6
6
|
export { normalizeOwnerPath } from "./owner-utils.js";
|
|
7
7
|
export { computeOccurrenceId } from "./occurrence-id.js";
|
|
8
|
+
export { projectPropUsages, classifyExprText } from "./project-props.js";
|
|
8
9
|
export * from "./output-types.js";
|
|
9
10
|
export { createDiagnosticCollector } from "./diagnostic.js";
|
|
10
11
|
//# 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,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;AAe/C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAI1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,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;AAe/C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAI1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGzE,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/output-types.d.ts
CHANGED
|
@@ -97,20 +97,75 @@ export type AuthoredManifestData = {
|
|
|
97
97
|
invocable?: Record<string, InvocableDecl>;
|
|
98
98
|
};
|
|
99
99
|
/**
|
|
100
|
-
* Per-occurrence prop value
|
|
101
|
-
*
|
|
102
|
-
* - a `{ __dynamic: true }` marker when the value is a non-literal expression,
|
|
103
|
-
* - or absent (key omitted from the map) when the prop was not set on the occurrence.
|
|
100
|
+
* Per-occurrence prop value (keyed by prop name on OutputOccurrence.props).
|
|
101
|
+
* Same tiers as PropUsage minus `name`. Absent prop → key omitted.
|
|
104
102
|
*/
|
|
105
|
-
export type PropValueState =
|
|
106
|
-
|
|
103
|
+
export type PropValueState = {
|
|
104
|
+
tier: "written";
|
|
105
|
+
value: string | number | boolean | null;
|
|
106
|
+
} | {
|
|
107
|
+
tier: "written";
|
|
108
|
+
valueSet: (string | number | boolean)[];
|
|
109
|
+
} | {
|
|
110
|
+
tier: "reference";
|
|
111
|
+
ref: string;
|
|
112
|
+
} | {
|
|
113
|
+
tier: "dynamic";
|
|
107
114
|
};
|
|
115
|
+
/** One enumerable value bucket in a component-grain prop distribution. */
|
|
116
|
+
export type PropValueEntry = {
|
|
117
|
+
provenance: "written";
|
|
118
|
+
value: string | number | boolean | null;
|
|
119
|
+
count: number;
|
|
120
|
+
} | {
|
|
121
|
+
provenance: "written";
|
|
122
|
+
valueSet: (string | number | boolean)[];
|
|
123
|
+
count: number;
|
|
124
|
+
} | {
|
|
125
|
+
provenance: "reference";
|
|
126
|
+
ref: string;
|
|
127
|
+
count: number;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Component-grain rollup for one prop.
|
|
131
|
+
* Invariant: sum(values[].count) + dynamic + (other ?? 0) + omitted === occurrenceCount
|
|
132
|
+
* `defaultApplied` is a SUBSET of `omitted` (manifest declares a default), not additive.
|
|
133
|
+
*/
|
|
108
134
|
export type PropDistribution = {
|
|
109
|
-
|
|
110
|
-
distribution: Record<string, number>;
|
|
135
|
+
values: PropValueEntry[];
|
|
111
136
|
dynamic: number;
|
|
112
137
|
omitted: number;
|
|
113
138
|
defaultApplied: number;
|
|
139
|
+
other?: number;
|
|
140
|
+
truncated?: number;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* One prop in a source-derived declared API. Every field is explicit-only:
|
|
144
|
+
* present iff the declaration site literally states it.
|
|
145
|
+
*/
|
|
146
|
+
export type DeclaredProp = {
|
|
147
|
+
/** Inline type annotation as verbatim source text (Vue type-literal only;
|
|
148
|
+
* absent for React — a destructure exposes no reliable type). */
|
|
149
|
+
type?: string;
|
|
150
|
+
/** Optionality when stated. Vue: from the `?` marker. React: `false` when the
|
|
151
|
+
* prop has any default (a default makes it optional); otherwise absent. */
|
|
152
|
+
required?: boolean;
|
|
153
|
+
/** Literal default value, when the default is a literal. Same union as
|
|
154
|
+
* `PropValueEntry.value` so Spec 2 stringifies it identically to observed
|
|
155
|
+
* written values. Absent for no default or a non-literal default. */
|
|
156
|
+
default?: string | number | boolean | null;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Source-derived declared prop API for a local component. Absent on
|
|
160
|
+
* `OutputComponent` when the declaration site is unreadable (see readability
|
|
161
|
+
* gate). External components use `manifest` instead; the two can co-exist on a
|
|
162
|
+
* local workspace component that also ships an authored manifest.
|
|
163
|
+
*/
|
|
164
|
+
export type DeclaredPropApi = {
|
|
165
|
+
/** Prop name → what the site explicitly states. Keys in source order. */
|
|
166
|
+
props: Record<string, DeclaredProp>;
|
|
167
|
+
/** Component destructures `...rest` / declares an index signature. */
|
|
168
|
+
hasRest: boolean;
|
|
114
169
|
};
|
|
115
170
|
export type CompositionRollup = {
|
|
116
171
|
/** child componentId → count of occurrences owned by this component (owner-edge children). */
|
|
@@ -122,6 +177,10 @@ export type CompositionRollup = {
|
|
|
122
177
|
/** # of this component's occurrences whose component has empty rendersByCount. */
|
|
123
178
|
isLeafCount: number;
|
|
124
179
|
};
|
|
180
|
+
/** Per-component consumer-event usage rollup. `boundCount` = occurrences binding this event. */
|
|
181
|
+
export type EventDistribution = {
|
|
182
|
+
boundCount: number;
|
|
183
|
+
};
|
|
125
184
|
export type OutputComponent = {
|
|
126
185
|
id: string;
|
|
127
186
|
identity: OutputIdentity;
|
|
@@ -134,8 +193,13 @@ export type OutputComponent = {
|
|
|
134
193
|
fileCount: number;
|
|
135
194
|
};
|
|
136
195
|
props: Record<string, PropDistribution>;
|
|
196
|
+
/** Consumer-bound events rolled up across occurrences (Vue/html/lit native + React on* props). */
|
|
197
|
+
events?: Record<string, EventDistribution>;
|
|
137
198
|
/** Per-component composition rollup (owner-edge driven). Always emitted. */
|
|
138
199
|
composition?: CompositionRollup;
|
|
200
|
+
/** Source-derived declared prop API. Local components only; absent when the
|
|
201
|
+
* declaration site is unreadable. Orthogonal to `manifest`. */
|
|
202
|
+
declared?: DeclaredPropApi;
|
|
139
203
|
/** Package version from package.json or CEM. Null for external packages not versioned at scan time. */
|
|
140
204
|
version: string | null;
|
|
141
205
|
/** Git-mtime: first commit of the declaring file. ISO 8601 string, or null for external packages. */
|
|
@@ -155,6 +219,8 @@ export type OutputOccurrence = {
|
|
|
155
219
|
* through barrels, etc. */
|
|
156
220
|
viaChain: OccurrenceVia[];
|
|
157
221
|
props: Record<string, PropValueState>;
|
|
222
|
+
/** Event names bound at this call site (Vue/html/lit). React handlers stay in `props`. */
|
|
223
|
+
events?: string[];
|
|
158
224
|
/** Phase 2: stable id keyed on (componentId, filePath, line, column). */
|
|
159
225
|
occurrenceId: string;
|
|
160
226
|
/** Phase 2: occurrenceId of nearest tracked ancestor. Absent if root in this scope. */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PropUsage } from "./scan-types.js";
|
|
2
|
+
import type { PropValueState } from "./output-types.js";
|
|
3
|
+
/** Project parser-emitted PropUsage[] onto the per-occurrence value map. */
|
|
4
|
+
export declare function projectPropUsages(usages: PropUsage[]): Record<string, PropValueState>;
|
|
5
|
+
/**
|
|
6
|
+
* Classify an already-extracted expression *string* (Vue template binding /
|
|
7
|
+
* Lit placeholder) as a bare `reference` (identifier or dotted member path)
|
|
8
|
+
* or `dynamic`. AST-based parsers (React) do NOT use this — they classify
|
|
9
|
+
* structurally. This is the single seam so Vue and Lit don't re-derive it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function classifyExprText(text: string): {
|
|
12
|
+
tier: "reference";
|
|
13
|
+
ref: string;
|
|
14
|
+
} | {
|
|
15
|
+
tier: "dynamic";
|
|
16
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Project parser-emitted PropUsage[] onto the per-occurrence value map. */
|
|
2
|
+
export function projectPropUsages(usages) {
|
|
3
|
+
const out = {};
|
|
4
|
+
for (const p of usages) {
|
|
5
|
+
switch (p.tier) {
|
|
6
|
+
case "written":
|
|
7
|
+
out[p.name] =
|
|
8
|
+
"valueSet" in p
|
|
9
|
+
? { tier: "written", valueSet: p.valueSet }
|
|
10
|
+
: { tier: "written", value: p.value };
|
|
11
|
+
break;
|
|
12
|
+
case "reference":
|
|
13
|
+
out[p.name] = { tier: "reference", ref: p.ref };
|
|
14
|
+
break;
|
|
15
|
+
case "dynamic":
|
|
16
|
+
out[p.name] = { tier: "dynamic" };
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
const IDENT_RE = /^[A-Za-z_$][\w$]*$/;
|
|
23
|
+
const MEMBER_PATH_RE = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*)+$/;
|
|
24
|
+
/**
|
|
25
|
+
* Classify an already-extracted expression *string* (Vue template binding /
|
|
26
|
+
* Lit placeholder) as a bare `reference` (identifier or dotted member path)
|
|
27
|
+
* or `dynamic`. AST-based parsers (React) do NOT use this — they classify
|
|
28
|
+
* structurally. This is the single seam so Vue and Lit don't re-derive it.
|
|
29
|
+
*/
|
|
30
|
+
export function classifyExprText(text) {
|
|
31
|
+
const t = text.trim();
|
|
32
|
+
if (IDENT_RE.test(t) || MEMBER_PATH_RE.test(t))
|
|
33
|
+
return { tier: "reference", ref: t };
|
|
34
|
+
return { tier: "dynamic" };
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=project-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-props.js","sourceRoot":"","sources":["../src/project-props.ts"],"names":[],"mappings":"AAGA,4EAA4E;AAC5E,MAAM,UAAU,iBAAiB,CAAC,MAAmB;IACnD,MAAM,GAAG,GAAmC,EAAE,CAAC;IAC/C,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;YACf,KAAK,SAAS;gBACZ,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;oBACT,UAAU,IAAI,CAAC;wBACb,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE;wBAC3C,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;gBAC1C,MAAM;YACR,KAAK,WAAW;gBACd,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;gBAChD,MAAM;YACR,KAAK,SAAS;gBACZ,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;gBAClC,MAAM;QACV,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,QAAQ,GAAG,oBAAoB,CAAC;AACtC,MAAM,cAAc,GAAG,yCAAyC,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAY;IAEZ,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IACtB,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;IACrF,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC7B,CAAC"}
|
package/dist/scan-types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* depend on the CLI package (circular), so every type that crosses the
|
|
6
6
|
* parser ↔ CLI boundary lives here in `plugin-core`.
|
|
7
7
|
*/
|
|
8
|
-
import type { OutputComponent, OutputOccurrence, ScanMeta } from "./output-types.js";
|
|
8
|
+
import type { DeclaredPropApi, OutputComponent, OutputOccurrence, ScanMeta } from "./output-types.js";
|
|
9
9
|
import type { Diagnostic, DiagnosticCollector } from "./diagnostic.js";
|
|
10
10
|
import type { ComponentId, ManifestComponent, ManifestSource } from "./types.js";
|
|
11
11
|
import type { OccurrenceVia } from "./via-types.js";
|
|
@@ -89,6 +89,8 @@ export type LocalDefinition = {
|
|
|
89
89
|
detector: DetectorId;
|
|
90
90
|
/** Source position of the declaration site. Populated by detectors. */
|
|
91
91
|
loc?: Loc;
|
|
92
|
+
/** Source-derived declared prop API, when readable. Populated by detectors. */
|
|
93
|
+
declared?: DeclaredPropApi;
|
|
92
94
|
};
|
|
93
95
|
export type LocalDefinitionIndex = {
|
|
94
96
|
/** POSIX repo-relative filePath → definitions in that file. */
|
|
@@ -125,13 +127,30 @@ export type Warning = (WarningBase & {
|
|
|
125
127
|
* Using a structural interface rather than the full `ResolvedConfig` keeps
|
|
126
128
|
* parsers decoupled from CLI-specific fields (configPath, output, etc.).
|
|
127
129
|
*/
|
|
128
|
-
export type ScanConfig = {
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
export type ScanConfig = {};
|
|
131
|
+
/**
|
|
132
|
+
* Per-attribute usage emitted by a parser. Four-tier floor:
|
|
133
|
+
* - written: a literal value present verbatim in source (incl. a folded
|
|
134
|
+
* literal set from a ternary), or boolean-shorthand `true`, or literal `null`.
|
|
135
|
+
* - reference: a non-literal captured by name/path but not resolved.
|
|
136
|
+
* - dynamic: opaque (call, spread, object/array, mixed template, etc.).
|
|
137
|
+
* The `resolved` tier is added by the engine in Plan 2.
|
|
138
|
+
*/
|
|
131
139
|
export type PropUsage = {
|
|
132
140
|
name: string;
|
|
133
|
-
|
|
134
|
-
|
|
141
|
+
tier: "written";
|
|
142
|
+
value: string | number | boolean | null;
|
|
143
|
+
} | {
|
|
144
|
+
name: string;
|
|
145
|
+
tier: "written";
|
|
146
|
+
valueSet: (string | number | boolean)[];
|
|
147
|
+
} | {
|
|
148
|
+
name: string;
|
|
149
|
+
tier: "reference";
|
|
150
|
+
ref: string;
|
|
151
|
+
} | {
|
|
152
|
+
name: string;
|
|
153
|
+
tier: "dynamic";
|
|
135
154
|
};
|
|
136
155
|
export type { OccurrenceVia } from "./via-types.js";
|
|
137
156
|
export type Occurrence = {
|
|
@@ -233,7 +252,7 @@ export type ParseContext = {
|
|
|
233
252
|
/**
|
|
234
253
|
* Global CEM index built once at scan startup. Maps hyphenated tag names
|
|
235
254
|
* and package names to their manifest entries, enabling parsers to resolve
|
|
236
|
-
* tags like `<
|
|
255
|
+
* tags like `<x-link>` unconditionally.
|
|
237
256
|
* Provided by scan.ts; parsers consume it.
|
|
238
257
|
*/
|
|
239
258
|
cemIndex?: CemIndex;
|
package/dist/scan-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAoHpE,MAAM,CAAC,MAAM,eAAe,GAAyB;IACnD,MAAM,EAAE,IAAI,GAAG,EAAE;IACjB,KAAK,EAAE,IAAI,GAAG,EAAE;CACjB,CAAC"}
|