@component-compass/reference-graph 0.1.18 → 0.1.20
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 +10 -4
- package/dist/builder.js +13 -9
- package/dist/builder.js.map +1 -1
- package/dist/engine/assert-never.d.ts +1 -1
- package/dist/engine/assert-never.js +1 -1
- package/dist/engine/component-shape.d.ts +18 -7
- package/dist/engine/component-shape.js +48 -18
- package/dist/engine/component-shape.js.map +1 -1
- package/dist/engine/helper-callers.d.ts +24 -14
- package/dist/engine/helper-callers.js +43 -70
- package/dist/engine/helper-callers.js.map +1 -1
- package/dist/engine/host-element.d.ts +37 -0
- package/dist/engine/host-element.js +55 -0
- package/dist/engine/host-element.js.map +1 -0
- package/dist/engine/index.d.ts +4 -4
- package/dist/engine/index.js +181 -91
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/library-stubs.js +1 -1
- package/dist/engine/member-identity.d.ts +9 -10
- package/dist/engine/member-identity.js +9 -10
- package/dist/engine/member-identity.js.map +1 -1
- package/dist/engine/re-export-chain.d.ts +1 -1
- package/dist/engine/re-export-chain.js +4 -3
- package/dist/engine/re-export-chain.js.map +1 -1
- package/dist/engine/registry.d.ts +43 -19
- package/dist/engine/registry.js +66 -50
- package/dist/engine/registry.js.map +1 -1
- package/dist/engine/resolve-reference.js +1 -1
- package/dist/engine/resolve-reference.js.map +1 -1
- package/dist/engine/resolve-type.d.ts +12 -0
- package/dist/engine/resolve-type.js +44 -52
- package/dist/engine/resolve-type.js.map +1 -1
- package/dist/engine/wrapper-folding.d.ts +22 -3
- package/dist/engine/wrapper-folding.js +146 -132
- package/dist/engine/wrapper-folding.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/file-graph.d.ts +29 -13
- package/dist/types/inferred-type.d.ts +2 -1
- package/package.json +2 -2
package/dist/builder.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OccurrenceVia, PropUsage, ResolveImport } from "@component-compass/plugin-core";
|
|
2
|
-
import type { BindingDecl, ExportRecord, Graph, ImportRecord, Reference, ScopeId } from "./index.js";
|
|
2
|
+
import type { BindingDecl, ExportRecord, Graph, ImportRecord, InferredType, Reference, ScopeId } from "./index.js";
|
|
3
3
|
import type { Dialect, GraphHostHooks } from "./types/file-graph.js";
|
|
4
4
|
export interface FileBuilder {
|
|
5
5
|
/** Repo-relative POSIX path of the file this builder is emitting into. */
|
|
@@ -59,18 +59,18 @@ export interface FileBuilder {
|
|
|
59
59
|
* (or vice versa). No-op when no tag-kind ownership entry exists. */
|
|
60
60
|
setTagOwner(ownerSymbolRef: Reference | null, viaOverride?: OccurrenceVia): void;
|
|
61
61
|
/** Same as setOwner but addresses a specific ownership entry by index.
|
|
62
|
-
* Used by parser-react's prop-forward finalize pass
|
|
62
|
+
* Used by parser-react's prop-forward finalize pass to re-attribute
|
|
63
63
|
* the original construction-site ownership entry without disturbing later
|
|
64
64
|
* fan-out duplicates. */
|
|
65
65
|
setOwnerAt(usageIdx: number, ownerSymbolRef: Reference | null, viaOverride?: OccurrenceVia): void;
|
|
66
66
|
/** Returns the current count of emitted JsxUsages in this file. Pragmatic
|
|
67
|
-
* read accessor — used by parser-react's prop-forward registration
|
|
67
|
+
* read accessor — used by parser-react's prop-forward registration
|
|
68
68
|
* to capture the index of the construction-site JsxUsage emitted during
|
|
69
69
|
* walkJsxIn. Kept minimal to preserve the otherwise-write-only contract. */
|
|
70
70
|
jsxUsageCount(): number;
|
|
71
71
|
/** Returns a structural snapshot of the JsxUsage at the given index, or
|
|
72
72
|
* undefined if out of range. Pragmatic read accessor — used by
|
|
73
|
-
* parser-react's prop-forward finalize
|
|
73
|
+
* parser-react's prop-forward finalize pass to clone every
|
|
74
74
|
* usage in a binding's init range for multi-read fan-out. Returns a
|
|
75
75
|
* shallow copy of the stored fields to keep the builder's internal array
|
|
76
76
|
* encapsulated. */
|
|
@@ -92,6 +92,12 @@ export interface FileBuilder {
|
|
|
92
92
|
callee: Omit<Reference, "scope"> & {
|
|
93
93
|
scope?: ScopeId;
|
|
94
94
|
};
|
|
95
|
+
args?: InferredType[];
|
|
96
|
+
}): void;
|
|
97
|
+
/** Record an identifier read in value position. See `FileGraph.heldRefs`.
|
|
98
|
+
* Scope defaults to the current scope, as for a JSX usage. */
|
|
99
|
+
addHeldRef(ref: Omit<Reference, "scope"> & {
|
|
100
|
+
scope?: ScopeId;
|
|
95
101
|
}): void;
|
|
96
102
|
/** Mark the most-recently-emitted usage as the lexical parent for any
|
|
97
103
|
* subsequent usages emitted before the matching `popUsageScope`. Parsers
|
package/dist/builder.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// API surface
|
|
2
|
-
//
|
|
3
|
-
// - parser-vue: paper sketch (Task 0.2, see plan doc)
|
|
4
|
-
// Members not justified by either should not be added speculatively.
|
|
1
|
+
// API surface is justified by its emitters (parser-react, parser-vue).
|
|
2
|
+
// Members not justified by one should not be added speculatively.
|
|
5
3
|
import { isAbsolute, relative, resolve } from "node:path";
|
|
4
|
+
import { posixPath } from "@component-compass/plugin-core";
|
|
6
5
|
import { MODULE_SCOPE } from "./index.js";
|
|
7
6
|
export function createGraphBuilder(opts) {
|
|
8
7
|
const files = new Map();
|
|
@@ -17,6 +16,7 @@ export function createGraphBuilder(opts) {
|
|
|
17
16
|
const tagUsages = [];
|
|
18
17
|
const ownership = [];
|
|
19
18
|
const bodyCalls = [];
|
|
19
|
+
const heldRefs = [];
|
|
20
20
|
const scopeStack = [MODULE_SCOPE];
|
|
21
21
|
let nextScopeId = 1;
|
|
22
22
|
// Deterministic scope ids per AST node key (`fn@<span-start>`): value
|
|
@@ -30,7 +30,7 @@ export function createGraphBuilder(opts) {
|
|
|
30
30
|
// `pushUsageScope` was called. See FileGraph.ownership.parentUsageIdx /
|
|
31
31
|
// depth.
|
|
32
32
|
const parentStack = [];
|
|
33
|
-
const fg = { filePath, dialect, scopes, declarations, imports, importsByLocal, exports, jsxUsages, tagUsages, ownership, bodyCalls };
|
|
33
|
+
const fg = { filePath, dialect, scopes, declarations, imports, importsByLocal, exports, jsxUsages, tagUsages, ownership, bodyCalls, heldRefs };
|
|
34
34
|
files.set(filePath, fg);
|
|
35
35
|
return {
|
|
36
36
|
filePath,
|
|
@@ -158,7 +158,11 @@ export function createGraphBuilder(opts) {
|
|
|
158
158
|
},
|
|
159
159
|
addBodyCall(record) {
|
|
160
160
|
const scope = record.callee.scope ?? scopeStack[scopeStack.length - 1] ?? MODULE_SCOPE;
|
|
161
|
-
bodyCalls.push({ ownerSymbol: record.ownerSymbol, callee: { ...record.callee, scope } });
|
|
161
|
+
bodyCalls.push({ ownerSymbol: record.ownerSymbol, callee: { ...record.callee, scope }, args: record.args ?? [] });
|
|
162
|
+
},
|
|
163
|
+
addHeldRef(ref) {
|
|
164
|
+
const scope = ref.scope ?? scopeStack[scopeStack.length - 1] ?? MODULE_SCOPE;
|
|
165
|
+
heldRefs.push({ ...ref, scope });
|
|
162
166
|
},
|
|
163
167
|
pushUsageScope() {
|
|
164
168
|
// Push the most-recently-emitted usage as the parent frame. No-op
|
|
@@ -193,7 +197,7 @@ export function createGraphBuilder(opts) {
|
|
|
193
197
|
const resolveToGraphKey = (absPath) => {
|
|
194
198
|
if (!isAbsolute(absPath))
|
|
195
199
|
return null;
|
|
196
|
-
const rel = relative(repoRoot, absPath)
|
|
200
|
+
const rel = posixPath(relative(repoRoot, absPath));
|
|
197
201
|
// Reject paths that escape the repo root (e.g. node_modules sibling
|
|
198
202
|
// checkouts). Callers fall back to the absolute path; `files.get`
|
|
199
203
|
// returns undefined for both cases. Repo-internal paths return the
|
|
@@ -206,8 +210,8 @@ export function createGraphBuilder(opts) {
|
|
|
206
210
|
};
|
|
207
211
|
// Graph keys are repoRoot-relative, but the host's moduleResolver
|
|
208
212
|
// anchors relative `from` paths against its OWN root, which may
|
|
209
|
-
// differ (e.g. the workspace root when scanning a monorepo subdir
|
|
210
|
-
//
|
|
213
|
+
// differ (e.g. the workspace root when scanning a monorepo subdir).
|
|
214
|
+
// Absolutise `from` against the graph's repoRoot before
|
|
211
215
|
// delegating so relative-specifier resolution is anchor-invariant.
|
|
212
216
|
const moduleResolver = (from, spec) => opts.moduleResolver(isAbsolute(from) ? from : resolve(repoRoot, from), spec);
|
|
213
217
|
return {
|
package/dist/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,kEAAkE;AAElE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAY3D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAuG1C,MAAM,UAAU,kBAAkB,CAAC,IAA+B;IAChE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;IAE3C,OAAO;QACL,SAAS,CAAC,QAAgB,EAAE,UAAmB,OAAO;YACpD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAsC,CAAC,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAChG,MAAM,YAAY,GAAG,IAAI,GAAG,EAAuB,CAAC;YACpD,MAAM,OAAO,GAAmB,EAAE,CAAC;YACnC,MAAM,cAAc,GAAG,IAAI,GAAG,EAAwB,CAAC;YACvD,MAAM,OAAO,GAAmB,EAAE,CAAC;YACnC,MAAM,SAAS,GAAe,EAAE,CAAC;YACjC,MAAM,SAAS,GAAe,EAAE,CAAC;YACjC,MAAM,SAAS,GAA2B,EAAE,CAAC;YAC7C,MAAM,SAAS,GAA4E,EAAE,CAAC;YAC9F,MAAM,QAAQ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C;wBAAE,OAAO,IAAI,CAAC;oBACtC,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;oBACnD,oEAAoE;oBACpE,kEAAkE;oBAClE,mEAAmE;oBACnE,mEAAmE;oBACnE,kEAAkE;oBAClE,6BAA6B;oBAC7B,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;wBAAE,OAAO,IAAI,CAAC;oBACtC,OAAO,GAAG,CAAC;gBACb,CAAC,CAAC;gBACF,kEAAkE;gBAClE,gEAAgE;gBAChE,oEAAoE;gBACpE,wDAAwD;gBACxD,mEAAmE;gBACnE,MAAM,cAAc,GAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CACnD,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;gBAC/E,OAAO;oBACL,KAAK;oBACL,cAAc;oBACd,iBAAiB;oBACjB,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,IAAI,KAAK;oBAC5D,GAAG,SAAS;iBACb,CAAC;YACJ,CAAC;YACD,OAAO;gBACL,KAAK;gBACL,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,IAAI,KAAK;gBAC5D,GAAG,SAAS;aACb,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Exhaustiveness guard for every `switch (type.kind)` over `InferredType`
|
|
3
|
-
*
|
|
3
|
+
* Reaching it is a type error at compile time — adding a kind to
|
|
4
4
|
* the IR must fail to build in every interpreter — and a loud error at
|
|
5
5
|
* runtime for the one way TypeScript can be bypassed (a cast).
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Exhaustiveness guard for every `switch (type.kind)` over `InferredType`
|
|
3
|
-
*
|
|
3
|
+
* Reaching it is a type error at compile time — adding a kind to
|
|
4
4
|
* the IR must fail to build in every interpreter — and a loud error at
|
|
5
5
|
* runtime for the one way TypeScript can be bypassed (a cast).
|
|
6
6
|
*/
|
|
@@ -2,7 +2,7 @@ import type { FileGraph, Graph, InferredType } from "../index.js";
|
|
|
2
2
|
import { type ArgumentMap } from "./argument-map.js";
|
|
3
3
|
import { type CycleGuard } from "./cycle-detection.js";
|
|
4
4
|
/**
|
|
5
|
-
* THE component-shape predicate
|
|
5
|
+
* THE component-shape predicate. Reduces an InferredType
|
|
6
6
|
* to what its VALUE is:
|
|
7
7
|
*
|
|
8
8
|
* "jsx" — a JSX value (`const br = <br/>`, or what calling a
|
|
@@ -10,14 +10,14 @@ import { type CycleGuard } from "./cycle-detection.js";
|
|
|
10
10
|
* "component" — a function whose returns are DIRECTLY JSX, or a call that
|
|
11
11
|
* evaluates to one.
|
|
12
12
|
* "unresolved" — bottoms out at an import the graph cannot see with nothing
|
|
13
|
-
* component-shaped in hand
|
|
13
|
+
* component-shaped in hand.
|
|
14
14
|
* "other" — anything else: factories, data, hooks, strings.
|
|
15
15
|
*
|
|
16
16
|
* The non-recursion into nested Function returns is load-bearing: a Function
|
|
17
17
|
* whose return is itself a Function evaluates that return to "component",
|
|
18
18
|
* not "jsx", so the outer function is "other" — a factory. That single rule
|
|
19
|
-
* separates `createField` from its products
|
|
20
|
-
*
|
|
19
|
+
* separates `createField` from its products. Do not add a second
|
|
20
|
+
* implementation anywhere; every
|
|
21
21
|
* caller — registry membership, owner classification, occurrence admission —
|
|
22
22
|
* calls this one. Named in docs/CONTEXT.md ("Component-shape seam").
|
|
23
23
|
*/
|
|
@@ -26,13 +26,24 @@ export declare function evalKind(type: InferredType, graph: Graph, fileGraph: Fi
|
|
|
26
26
|
export declare function isComponentShaped(type: InferredType, graph: Graph, fileGraph: FileGraph): boolean;
|
|
27
27
|
/** A TypeOf (possibly under a ReturnTypeOf chain, or a MemberOf access on
|
|
28
28
|
* one — `Sentry.withProfiler`) that names an import the graph cannot
|
|
29
|
-
* resolve — the shape the opaque-HOC fold synthesises identity from
|
|
30
|
-
* Unwrapping MemberOf.obj is what lets
|
|
29
|
+
* resolve — the shape the opaque-HOC fold synthesises identity from.
|
|
30
|
+
* Unwrapping MemberOf.obj is what lets the render-callback
|
|
31
31
|
* narrowing correctly except FOR an import-backed namespace member call.
|
|
32
32
|
*
|
|
33
|
-
* Exported
|
|
33
|
+
* Exported: `wrapper-folding.ts`'s opaque-callee identity-fold
|
|
34
34
|
* step shares this EXACT predicate for its parallel "is this a data-method
|
|
35
35
|
* render call, not a wrapper" decision — never re-derive it there. Takes
|
|
36
36
|
* plain params (not this module's private `Ctx`) so a caller outside this
|
|
37
37
|
* file doesn't need to construct one. */
|
|
38
38
|
export declare function isImportBackedLeaf(t: InferredType, graph: Graph, fileGraph: FileGraph, guard: CycleGuard): boolean;
|
|
39
|
+
/** Answers "is there an `import()` anywhere in this value" — for reporting
|
|
40
|
+
* only. It descends every node kind that can hold one and never claims a
|
|
41
|
+
* projection, so the specifier it hands back names the import the diagnostic
|
|
42
|
+
* points at, nothing more.
|
|
43
|
+
*
|
|
44
|
+
* Not `findFirstDynamicImport` (`wrapper-folding.ts`): that one decides
|
|
45
|
+
* credit, is deliberately narrower, and is the only one that may claim a
|
|
46
|
+
* projection. */
|
|
47
|
+
export declare function firstDynamicImport(t: InferredType): Extract<InferredType, {
|
|
48
|
+
kind: "DynamicImport";
|
|
49
|
+
}> | null;
|
|
@@ -46,7 +46,7 @@ function evalInner(t, ctx) {
|
|
|
46
46
|
for (const { type: obj } of objs) {
|
|
47
47
|
if (obj.kind !== "Object")
|
|
48
48
|
continue;
|
|
49
|
-
//
|
|
49
|
+
// A dynamic-key access (`BannerComponent[type]`)
|
|
50
50
|
// could select any prop at runtime — merge the shape of every
|
|
51
51
|
// prop the object carries, the same "any branch could be it"
|
|
52
52
|
// treatment Union already gets.
|
|
@@ -70,10 +70,10 @@ function evalInner(t, ctx) {
|
|
|
70
70
|
case "DynamicImport":
|
|
71
71
|
// A literal array of JSX elements is deliberately "other", the same
|
|
72
72
|
// treatment a Function returning Object-containing-JSX gets ("data
|
|
73
|
-
// factory"): helper-callers.ts's helper/component split
|
|
73
|
+
// factory"): helper-callers.ts's helper/component split depends
|
|
74
74
|
// on a Function returning Array<JSX> classifying as a helper, not a
|
|
75
75
|
// component, so its callers attribute correctly via helper-call
|
|
76
|
-
// chains instead of it becoming a standalone identity.
|
|
76
|
+
// chains instead of it becoming a standalone identity. The
|
|
77
77
|
// ".map(render)" and dynamic-member patterns don't need this arm —
|
|
78
78
|
// both resolve to "jsx" through evalCall's opaque-MemberOf-callee
|
|
79
79
|
// rule and the MemberOf DYNAMIC_MEMBER_KEY merge instead.
|
|
@@ -98,18 +98,18 @@ function evalCall(t, ctx) {
|
|
|
98
98
|
resolvable.push(f);
|
|
99
99
|
}
|
|
100
100
|
if (resolvable.length === 0) {
|
|
101
|
-
// Opaque callee
|
|
101
|
+
// Opaque callee: component iff some argument is
|
|
102
102
|
// component-shaped or an import-backed leaf the engine will fold to.
|
|
103
103
|
const carries = t.args.some((a) => evalInner(a, ctx) === "component" || isImportBackedLeaf(a, ctx.graph, ctx.fileGraph, ctx.guard));
|
|
104
104
|
if (!carries)
|
|
105
105
|
return "unresolved";
|
|
106
|
-
//
|
|
106
|
+
// A method call on non-import-backed data — a parameter,
|
|
107
107
|
// a local array/object literal, a hook result, a global like
|
|
108
108
|
// `Object.keys(x)` — with a component-shaped argument is a *render
|
|
109
109
|
// callback* (`items.map(({...}) => <Button/>)`), not a wrapper that
|
|
110
110
|
// takes a component as a prop: the call's OUTPUT is rendered JSX, not a
|
|
111
|
-
// component. An import-backed callee (the
|
|
112
|
-
//
|
|
111
|
+
// component. An import-backed callee (the genuinely unresolvable HOC)
|
|
112
|
+
// keeps "component". wrapper-folding.ts's
|
|
113
113
|
// opaque step shares this exact condition (isImportBackedLeaf, exported
|
|
114
114
|
// below) for the parallel identity-folding decision — don't re-derive it.
|
|
115
115
|
if (t.callee.kind === "MemberOf" && !isImportBackedLeaf(t.callee, ctx.graph, ctx.fileGraph, ctx.guard))
|
|
@@ -138,11 +138,11 @@ function isImportBacked(t, graph, fileGraph) {
|
|
|
138
138
|
}
|
|
139
139
|
/** A TypeOf (possibly under a ReturnTypeOf chain, or a MemberOf access on
|
|
140
140
|
* one — `Sentry.withProfiler`) that names an import the graph cannot
|
|
141
|
-
* resolve — the shape the opaque-HOC fold synthesises identity from
|
|
142
|
-
* Unwrapping MemberOf.obj is what lets
|
|
141
|
+
* resolve — the shape the opaque-HOC fold synthesises identity from.
|
|
142
|
+
* Unwrapping MemberOf.obj is what lets the render-callback
|
|
143
143
|
* narrowing correctly except FOR an import-backed namespace member call.
|
|
144
144
|
*
|
|
145
|
-
* Exported
|
|
145
|
+
* Exported: `wrapper-folding.ts`'s opaque-callee identity-fold
|
|
146
146
|
* step shares this EXACT predicate for its parallel "is this a data-method
|
|
147
147
|
* render call, not a wrapper" decision — never re-derive it there. Takes
|
|
148
148
|
* plain params (not this module's private `Ctx`) so a caller outside this
|
|
@@ -158,20 +158,50 @@ export function isImportBackedLeaf(t, graph, fileGraph, guard) {
|
|
|
158
158
|
return false;
|
|
159
159
|
return resolveReference(graph, fileGraph, cur.ref, guard).kind === "Unknown";
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
/** Answers "is there an `import()` anywhere in this value" — for reporting
|
|
162
|
+
* only. It descends every node kind that can hold one and never claims a
|
|
163
|
+
* projection, so the specifier it hands back names the import the diagnostic
|
|
164
|
+
* points at, nothing more.
|
|
165
|
+
*
|
|
166
|
+
* Not `findFirstDynamicImport` (`wrapper-folding.ts`): that one decides
|
|
167
|
+
* credit, is deliberately narrower, and is the only one that may claim a
|
|
168
|
+
* projection. */
|
|
169
|
+
export function firstDynamicImport(t) {
|
|
162
170
|
switch (t.kind) {
|
|
163
171
|
case "DynamicImport":
|
|
164
|
-
return
|
|
172
|
+
return t;
|
|
165
173
|
case "Function":
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
174
|
+
for (const r of t.returns) {
|
|
175
|
+
const hit = firstDynamicImport(r);
|
|
176
|
+
if (hit)
|
|
177
|
+
return hit;
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
180
|
+
case "ReturnTypeOf": {
|
|
181
|
+
const inCallee = firstDynamicImport(t.callee);
|
|
182
|
+
if (inCallee)
|
|
183
|
+
return inCallee;
|
|
184
|
+
for (const a of t.args) {
|
|
185
|
+
const hit = firstDynamicImport(a);
|
|
186
|
+
if (hit)
|
|
187
|
+
return hit;
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
169
191
|
case "MemberOf":
|
|
170
|
-
return
|
|
192
|
+
return firstDynamicImport(t.obj);
|
|
171
193
|
case "Union":
|
|
172
|
-
|
|
194
|
+
for (const u of t.types) {
|
|
195
|
+
const hit = firstDynamicImport(u);
|
|
196
|
+
if (hit)
|
|
197
|
+
return hit;
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
173
200
|
default:
|
|
174
|
-
return
|
|
201
|
+
return null;
|
|
175
202
|
}
|
|
176
203
|
}
|
|
204
|
+
function containsDynamicImport(t) {
|
|
205
|
+
return firstDynamicImport(t) !== null;
|
|
206
|
+
}
|
|
177
207
|
//# sourceMappingURL=component-shape.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-shape.js","sourceRoot":"","sources":["../../src/engine/component-shape.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAmB,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAA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,kBAAkB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACnC,KAAK,OAAO;YACV,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;gBACxB,MAAM,GAAG,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;gBAClC,IAAI,GAAG;oBAAE,OAAO,GAAG,CAAC;YACtB,CAAC;YACD,OAAO,IAAI,CAAC;QACd;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,CAAe;IAC5C,OAAO,kBAAkB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AACxC,CAAC"}
|
|
@@ -1,21 +1,33 @@
|
|
|
1
1
|
import type { BindingDecl, FileGraph, Graph, Reference } from "../index.js";
|
|
2
|
+
import type { ComponentRegistry } from "./registry.js";
|
|
2
3
|
/**
|
|
3
4
|
* Walk the scope chain for `ref.symbol` in `fileGraph.declarations` and
|
|
4
5
|
* return the first matching BindingDecl, or null if not found. THE
|
|
5
|
-
* scope-chain walk
|
|
6
|
+
* scope-chain walk — `registry.ts`'s `resolveUsageTarget` calls this
|
|
6
7
|
* seam instead of re-deriving it.
|
|
7
8
|
*/
|
|
8
9
|
export declare function findLocalDeclaration(fileGraph: FileGraph, ref: Reference): BindingDecl | null;
|
|
9
10
|
export type Classification = "component" | "helper" | "unknown";
|
|
10
11
|
/**
|
|
11
|
-
* Component-vs-helper classification for owner attribution
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
12
|
+
* Component-vs-helper classification for owner attribution: owners
|
|
13
|
+
* are registry members, or they fan out. A Function- or call-valued
|
|
14
|
+
* declaration the registry admits is a "component" and owns its JSX; one it
|
|
15
|
+
* does not admit is a "helper", and the JSX inside it belongs to its callers
|
|
16
|
+
* (`resolveOwnerChain`). Plain values stay "unknown".
|
|
17
|
+
*
|
|
18
|
+
* No second shape test and no second naming rule live here: `registry` is
|
|
19
|
+
* the roster view (`excludeHostElementNames` applied), so a lowercase render
|
|
20
|
+
* helper, a capitalised function only ever called (`ActionButtons({…})`),
|
|
21
|
+
* and a dead JSX-returning declaration are all helpers for the same reason —
|
|
22
|
+
* the registry did not admit them.
|
|
23
|
+
*
|
|
24
|
+
* A Vue SFC — the default-exported declaration of a vue-dialect file — is
|
|
25
|
+
* outside the registry by design (it is not typed by this algebra) and the
|
|
26
|
+
* engine admits its identity unconditionally; ownership follows the same
|
|
27
|
+
* rule, so an SFC always owns its template. Any other declaration in a Vue
|
|
28
|
+
* file (a `<script>` helper) is judged like a React one.
|
|
17
29
|
*/
|
|
18
|
-
export declare function classifyDeclaration(decl: BindingDecl,
|
|
30
|
+
export declare function classifyDeclaration(decl: BindingDecl, registry: ComponentRegistry, fileGraph: FileGraph): Classification;
|
|
19
31
|
export type SymbolKey = {
|
|
20
32
|
file: string;
|
|
21
33
|
symbol: string;
|
|
@@ -32,7 +44,7 @@ export type ClassifiedHelperIndex = HelperCallerIndex & {
|
|
|
32
44
|
*
|
|
33
45
|
* Phase 1 (collect) walks every module-scope `Function`- or
|
|
34
46
|
* `ReturnTypeOf`-valued BindingDecl across the graph (the latter is a
|
|
35
|
-
* factory's product
|
|
47
|
+
* factory's product), collecting caller-side references from
|
|
36
48
|
* three sources:
|
|
37
49
|
*
|
|
38
50
|
* 1. `TypeOf` refs inside the decl's return-type expressions
|
|
@@ -50,10 +62,8 @@ export type ClassifiedHelperIndex = HelperCallerIndex & {
|
|
|
50
62
|
* Without this pass, helper-classified functions consumed via JSX
|
|
51
63
|
* (the dominant React call shape) never appear as called by anyone.
|
|
52
64
|
*
|
|
53
|
-
* Phase 2 (classify) runs
|
|
54
|
-
*
|
|
55
|
-
* `"component"` but consumed only as a value (never JSX) is reclassified
|
|
56
|
-
* as `"helper"`.
|
|
65
|
+
* Phase 2 (classify) runs classification on every module-scope Function- or
|
|
66
|
+
* ReturnTypeOf-valued decl.
|
|
57
67
|
*
|
|
58
68
|
* Phase 3 (index) walks the pending value-refs and JSX-calls collected in
|
|
59
69
|
* phase 1, recording caller edges for targets classified as `"helper"`. Each
|
|
@@ -63,7 +73,7 @@ export type ClassifiedHelperIndex = HelperCallerIndex & {
|
|
|
63
73
|
* Cost: O(declarations × refs-per-declaration + jsx-usages). Cross-file
|
|
64
74
|
* resolution uses the existing module resolver — no new IO.
|
|
65
75
|
*/
|
|
66
|
-
export declare function buildHelperCallers(graph: Graph): ClassifiedHelperIndex;
|
|
76
|
+
export declare function buildHelperCallers(graph: Graph, registry: ComponentRegistry): ClassifiedHelperIndex;
|
|
67
77
|
/**
|
|
68
78
|
* Resolve a Reference to the BindingDecl it ultimately points at, crossing
|
|
69
79
|
* files via imports + the module resolver. Returns `{file, decl}` keyed by
|