@component-compass/reference-graph 0.1.23 → 0.1.25
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/engine/argument-map.d.ts +7 -0
- package/dist/engine/argument-map.js +7 -0
- package/dist/engine/argument-map.js.map +1 -1
- package/dist/engine/component-shape.d.ts +26 -2
- package/dist/engine/component-shape.js +75 -12
- package/dist/engine/component-shape.js.map +1 -1
- package/dist/engine/denotation.d.ts +90 -0
- package/dist/engine/denotation.js +55 -0
- package/dist/engine/denotation.js.map +1 -0
- package/dist/engine/host-element.d.ts +7 -3
- package/dist/engine/host-element.js +7 -3
- package/dist/engine/host-element.js.map +1 -1
- package/dist/engine/index.d.ts +1 -1
- package/dist/engine/index.js +389 -291
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/library-stubs.d.ts +36 -0
- package/dist/engine/library-stubs.js +26 -29
- package/dist/engine/library-stubs.js.map +1 -1
- package/dist/engine/member-identity.d.ts +8 -0
- package/dist/engine/member-identity.js +15 -0
- package/dist/engine/member-identity.js.map +1 -1
- package/dist/engine/registry.d.ts +70 -15
- package/dist/engine/registry.js +164 -80
- package/dist/engine/registry.js.map +1 -1
- package/dist/engine/resolve-type.d.ts +1 -1
- package/dist/engine/resolve-type.js +3 -2
- package/dist/engine/resolve-type.js.map +1 -1
- package/dist/engine/wrapper-folding.d.ts +12 -15
- package/dist/engine/wrapper-folding.js +361 -75
- package/dist/engine/wrapper-folding.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -11,6 +11,13 @@ export interface ArgumentMap {
|
|
|
11
11
|
unbind(fn: Reference): void;
|
|
12
12
|
lookup(fn: Reference, index: number): InferredType | undefined;
|
|
13
13
|
}
|
|
14
|
+
/** THE question "did the call the walk is inside bind this parameter", and the
|
|
15
|
+
* argument it bound, asked once. Every reader of a `ParameterOf` — the
|
|
16
|
+
* algebra's substitution, the component-shape predicate, the walker's
|
|
17
|
+
* late-bound naming — calls this rather than keying the map itself. */
|
|
18
|
+
export declare function boundArgument(argMap: ArgumentMap, param: Extract<InferredType, {
|
|
19
|
+
kind: "ParameterOf";
|
|
20
|
+
}>): InferredType | undefined;
|
|
14
21
|
/** Key an ArgumentMap frame by. Exported so wrapper-folding's structural
|
|
15
22
|
* pass-through check compares `ParameterOf.fn` against a callee's
|
|
16
23
|
* `bindingRef` exactly the way `lookup` would. */
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/** THE question "did the call the walk is inside bind this parameter", and the
|
|
2
|
+
* argument it bound, asked once. Every reader of a `ParameterOf` — the
|
|
3
|
+
* algebra's substitution, the component-shape predicate, the walker's
|
|
4
|
+
* late-bound naming — calls this rather than keying the map itself. */
|
|
5
|
+
export function boundArgument(argMap, param) {
|
|
6
|
+
return argMap.lookup(param.fn, param.index);
|
|
7
|
+
}
|
|
1
8
|
/** Key an ArgumentMap frame by. Exported so wrapper-folding's structural
|
|
2
9
|
* pass-through check compares `ParameterOf.fn` against a callee's
|
|
3
10
|
* `bindingRef` exactly the way `lookup` would. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"argument-map.js","sourceRoot":"","sources":["../../src/engine/argument-map.ts"],"names":[],"mappings":"AAeA;;mDAEmD;AACnD,MAAM,UAAU,cAAc,CAAC,GAAc;IAC3C,OAAO,GAAG,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,MAAM,KAAK,GAAiD,EAAE,CAAC;IAC/D,OAAO;QACL,IAAI,CAAC,EAAE,EAAE,IAAI;YACX,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,CAAC,EAAE;YACP,MAAM,GAAG,GAAG,cAAc,CAAC,EAAE,CA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E,IAAI;YACX,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,CAAC,EAAE;YACP,MAAM,GAAG,GAAG,cAAc,CAAC,EAAE,CAAC,CAAC;YAC/B,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC3C,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,GAAG,EAAE,CAAC;oBAC1B,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBACnB,OAAO;gBACT,CAAC;YACH,CAAC;QACH,CAAC;QACD,MAAM,CAAC,EAAE,EAAE,KAAK;YACd,MAAM,GAAG,GAAG,cAAc,CAAC,EAAE,CAAC,CAAC;YAC/B,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACvB,IAAI,KAAK,EAAE,GAAG,KAAK,GAAG;oBAAE,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnD,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
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
|
+
import type { OpaqueSemantics } from "./denotation.js";
|
|
4
5
|
/**
|
|
5
6
|
* THE component-shape predicate. Reduces an InferredType
|
|
6
7
|
* to what its VALUE is:
|
|
@@ -18,8 +19,8 @@ import { type CycleGuard } from "./cycle-detection.js";
|
|
|
18
19
|
* not "jsx", so the outer function is "other" — a factory. That single rule
|
|
19
20
|
* separates `createField` from its products. Do not add a second
|
|
20
21
|
* implementation anywhere; every
|
|
21
|
-
* caller — registry membership
|
|
22
|
-
* calls this one. Named in docs/CONTEXT.md ("Component-shape seam").
|
|
22
|
+
* caller — registry membership and the registry's component judge, owner
|
|
23
|
+
* classification — calls this one. Named in docs/CONTEXT.md ("Component-shape seam").
|
|
23
24
|
*/
|
|
24
25
|
export type ValueKind = "jsx" | "component" | "unresolved" | "other";
|
|
25
26
|
export declare function evalKind(type: InferredType, graph: Graph, fileGraph: FileGraph, argMap?: ArgumentMap, guard?: CycleGuard): ValueKind;
|
|
@@ -36,6 +37,20 @@ export declare function isComponentShaped(type: InferredType, graph: Graph, file
|
|
|
36
37
|
* plain params (not this module's private `Ctx`) so a caller outside this
|
|
37
38
|
* file doesn't need to construct one. */
|
|
38
39
|
export declare function isImportBackedLeaf(t: InferredType, graph: Graph, fileGraph: FileGraph, guard: CycleGuard): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The semantics of the non-component value a call produces: the stub table's
|
|
42
|
+
* entry for the callee's export, when the callee is an import the graph cannot
|
|
43
|
+
* see (`isImportBackedLeaf`, the same predicate the unseen-hook rule uses).
|
|
44
|
+
* Null for every other call. Exported: `walkReturnTypeOf` names such a call's
|
|
45
|
+
* product from it, and `evalCall` below answers "other" for it; neither
|
|
46
|
+
* re-derives it.
|
|
47
|
+
*
|
|
48
|
+
* The callee's spelling is read through `libraryExportFor`, the one table
|
|
49
|
+
* `libraryStubFor` reads: a reference (a named import, or a default /
|
|
50
|
+
* namespace import carrying the member on the ref) or a member access on one
|
|
51
|
+
* (`React.createContext`).
|
|
52
|
+
*/
|
|
53
|
+
export declare function nonComponentProduct(graph: Graph, fileGraph: FileGraph, callee: InferredType, guard: CycleGuard): OpaqueSemantics | null;
|
|
39
54
|
/** Answers "is there an `import()` anywhere in this value" — for reporting
|
|
40
55
|
* only. It descends every node kind that can hold one and never claims a
|
|
41
56
|
* projection, so the specifier it hands back names the import the diagnostic
|
|
@@ -47,3 +62,12 @@ export declare function isImportBackedLeaf(t: InferredType, graph: Graph, fileGr
|
|
|
47
62
|
export declare function firstDynamicImport(t: InferredType): Extract<InferredType, {
|
|
48
63
|
kind: "DynamicImport";
|
|
49
64
|
}> | null;
|
|
65
|
+
/** True when there is an `import()` anywhere in this value, by
|
|
66
|
+
* `firstDynamicImport`'s descent; it claims no projection. Given `at`, a
|
|
67
|
+
* reference is followed once: the binding it names is found scope-aware in
|
|
68
|
+
* the file the reference was written in, and that binding's value is
|
|
69
|
+
* searched with no further peek. */
|
|
70
|
+
export declare function containsDynamicImport(t: InferredType, at?: {
|
|
71
|
+
graph: Graph;
|
|
72
|
+
fileGraph: FileGraph;
|
|
73
|
+
}): boolean;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { createArgumentMap } from "./argument-map.js";
|
|
1
|
+
import { boundArgument, createArgumentMap } from "./argument-map.js";
|
|
2
2
|
import { createCycleGuard } from "./cycle-detection.js";
|
|
3
3
|
import { fileGraphForRef, resolveReference } from "./resolve-reference.js";
|
|
4
4
|
import { resolveToFunctions, resolveType, DYNAMIC_MEMBER_KEY } from "./resolve-type.js";
|
|
5
5
|
import { assertNever } from "./assert-never.js";
|
|
6
|
+
import { libraryExportFor } from "./library-stubs.js";
|
|
7
|
+
import { findLocalDeclaration } from "./helper-callers.js";
|
|
6
8
|
export function evalKind(type, graph, fileGraph, argMap = createArgumentMap(), guard = createCycleGuard()) {
|
|
7
9
|
return evalInner(type, { graph, fileGraph, argMap, guard });
|
|
8
10
|
}
|
|
@@ -31,7 +33,7 @@ function evalInner(t, ctx) {
|
|
|
31
33
|
case "Union":
|
|
32
34
|
return merge(t.types.map((u) => evalInner(u, ctx)));
|
|
33
35
|
case "ParameterOf": {
|
|
34
|
-
const bound = ctx.argMap
|
|
36
|
+
const bound = boundArgument(ctx.argMap, t);
|
|
35
37
|
return bound ? evalInner(bound, ctx) : "other";
|
|
36
38
|
}
|
|
37
39
|
case "TypeOf": {
|
|
@@ -87,9 +89,12 @@ function evalInner(t, ctx) {
|
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
function evalCall(t, ctx) {
|
|
92
|
+
// A non-component product (a context) holds its arguments; it never wraps them.
|
|
93
|
+
if (nonComponentProduct(ctx.graph, ctx.fileGraph, t.callee, ctx.guard) !== null)
|
|
94
|
+
return "other";
|
|
90
95
|
// `lazy(() => import('./x'))` and friends: the engine's lazy-import rule
|
|
91
96
|
// owns identity; for shape purposes the call is a component.
|
|
92
|
-
if (t.args.some(containsDynamicImport))
|
|
97
|
+
if (t.args.some((a) => containsDynamicImport(a)))
|
|
93
98
|
return "component";
|
|
94
99
|
const fns = resolveToFunctions(ctx.graph, ctx.fileGraph, t.callee, ctx.argMap, ctx.guard);
|
|
95
100
|
const resolvable = [];
|
|
@@ -99,8 +104,10 @@ function evalCall(t, ctx) {
|
|
|
99
104
|
}
|
|
100
105
|
if (resolvable.length === 0) {
|
|
101
106
|
// Opaque callee: component iff some argument is
|
|
102
|
-
// component-shaped or an import-backed leaf the engine will fold to.
|
|
103
|
-
|
|
107
|
+
// component-shaped or an import-backed leaf the engine will fold to. A
|
|
108
|
+
// non-component product call (`withX(createContext(…))`) is neither.
|
|
109
|
+
const isProductCall = (a) => a.kind === "ReturnTypeOf" && nonComponentProduct(ctx.graph, ctx.fileGraph, a.callee, ctx.guard) !== null;
|
|
110
|
+
const carries = t.args.some((a) => evalInner(a, ctx) === "component" || (isImportBackedLeaf(a, ctx.graph, ctx.fileGraph, ctx.guard) && !isProductCall(a)));
|
|
104
111
|
if (!carries)
|
|
105
112
|
return "unresolved";
|
|
106
113
|
// A method call on non-import-backed data — a parameter,
|
|
@@ -158,6 +165,33 @@ export function isImportBackedLeaf(t, graph, fileGraph, guard) {
|
|
|
158
165
|
return false;
|
|
159
166
|
return resolveReference(graph, fileGraph, cur.ref, guard).kind === "Unknown";
|
|
160
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* The semantics of the non-component value a call produces: the stub table's
|
|
170
|
+
* entry for the callee's export, when the callee is an import the graph cannot
|
|
171
|
+
* see (`isImportBackedLeaf`, the same predicate the unseen-hook rule uses).
|
|
172
|
+
* Null for every other call. Exported: `walkReturnTypeOf` names such a call's
|
|
173
|
+
* product from it, and `evalCall` below answers "other" for it; neither
|
|
174
|
+
* re-derives it.
|
|
175
|
+
*
|
|
176
|
+
* The callee's spelling is read through `libraryExportFor`, the one table
|
|
177
|
+
* `libraryStubFor` reads: a reference (a named import, or a default /
|
|
178
|
+
* namespace import carrying the member on the ref) or a member access on one
|
|
179
|
+
* (`React.createContext`).
|
|
180
|
+
*/
|
|
181
|
+
export function nonComponentProduct(graph, fileGraph, callee, guard) {
|
|
182
|
+
const ref = callee.kind === "TypeOf"
|
|
183
|
+
? callee.ref
|
|
184
|
+
: callee.kind === "MemberOf" && callee.obj.kind === "TypeOf"
|
|
185
|
+
? { ...callee.obj.ref, memberChain: [callee.member] }
|
|
186
|
+
: null;
|
|
187
|
+
if (ref === null)
|
|
188
|
+
return null;
|
|
189
|
+
const imp = fileGraphForRef(graph, ref, fileGraph).importsByLocal.get(ref.symbol);
|
|
190
|
+
const entry = imp === undefined ? null : libraryExportFor(imp, ref);
|
|
191
|
+
if (entry === null || entry.kind !== "non-component-product")
|
|
192
|
+
return null;
|
|
193
|
+
return isImportBackedLeaf(callee, graph, fileGraph, guard) ? entry.semantics : null;
|
|
194
|
+
}
|
|
161
195
|
/** Answers "is there an `import()` anywhere in this value" — for reporting
|
|
162
196
|
* only. It descends every node kind that can hold one and never claims a
|
|
163
197
|
* projection, so the specifier it hands back names the import the diagnostic
|
|
@@ -167,41 +201,70 @@ export function isImportBackedLeaf(t, graph, fileGraph, guard) {
|
|
|
167
201
|
* credit, is deliberately narrower, and is the only one that may claim a
|
|
168
202
|
* projection. */
|
|
169
203
|
export function firstDynamicImport(t) {
|
|
204
|
+
return searchDynamicImport(t, null);
|
|
205
|
+
}
|
|
206
|
+
function searchDynamicImport(t, peek) {
|
|
170
207
|
switch (t.kind) {
|
|
171
208
|
case "DynamicImport":
|
|
172
209
|
return t;
|
|
173
210
|
case "Function":
|
|
174
211
|
for (const r of t.returns) {
|
|
175
|
-
const hit =
|
|
212
|
+
const hit = searchDynamicImport(r, peek);
|
|
176
213
|
if (hit)
|
|
177
214
|
return hit;
|
|
178
215
|
}
|
|
179
216
|
return null;
|
|
180
217
|
case "ReturnTypeOf": {
|
|
181
|
-
const inCallee =
|
|
218
|
+
const inCallee = searchDynamicImport(t.callee, peek);
|
|
182
219
|
if (inCallee)
|
|
183
220
|
return inCallee;
|
|
184
221
|
for (const a of t.args) {
|
|
185
|
-
const hit =
|
|
222
|
+
const hit = searchDynamicImport(a, peek);
|
|
186
223
|
if (hit)
|
|
187
224
|
return hit;
|
|
188
225
|
}
|
|
189
226
|
return null;
|
|
190
227
|
}
|
|
191
228
|
case "MemberOf":
|
|
192
|
-
return
|
|
229
|
+
return searchDynamicImport(t.obj, peek);
|
|
193
230
|
case "Union":
|
|
194
231
|
for (const u of t.types) {
|
|
195
|
-
const hit =
|
|
232
|
+
const hit = searchDynamicImport(u, peek);
|
|
196
233
|
if (hit)
|
|
197
234
|
return hit;
|
|
198
235
|
}
|
|
199
236
|
return null;
|
|
237
|
+
case "Object":
|
|
238
|
+
for (const v of Object.values(t.props)) {
|
|
239
|
+
const hit = searchDynamicImport(v, peek);
|
|
240
|
+
if (hit)
|
|
241
|
+
return hit;
|
|
242
|
+
}
|
|
243
|
+
return null;
|
|
244
|
+
case "Array":
|
|
245
|
+
for (const e of t.elements) {
|
|
246
|
+
const hit = searchDynamicImport(e, peek);
|
|
247
|
+
if (hit)
|
|
248
|
+
return hit;
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
case "TypeOf": {
|
|
252
|
+
const bound = peek?.(t) ?? null;
|
|
253
|
+
return bound === null ? null : searchDynamicImport(bound, null);
|
|
254
|
+
}
|
|
200
255
|
default:
|
|
201
256
|
return null;
|
|
202
257
|
}
|
|
203
258
|
}
|
|
204
|
-
|
|
205
|
-
|
|
259
|
+
/** True when there is an `import()` anywhere in this value, by
|
|
260
|
+
* `firstDynamicImport`'s descent; it claims no projection. Given `at`, a
|
|
261
|
+
* reference is followed once: the binding it names is found scope-aware in
|
|
262
|
+
* the file the reference was written in, and that binding's value is
|
|
263
|
+
* searched with no further peek. */
|
|
264
|
+
export function containsDynamicImport(t, at) {
|
|
265
|
+
const peek = at === undefined
|
|
266
|
+
? null
|
|
267
|
+
: (ref) => findLocalDeclaration(fileGraphForRef(at.graph, ref.ref, at.fileGraph), ref.ref)?.value ?? null;
|
|
268
|
+
return searchDynamicImport(t, peek) !== null;
|
|
206
269
|
}
|
|
207
270
|
//# 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;
|
|
1
|
+
{"version":3,"file":"component-shape.js","sourceRoot":"","sources":["../../src/engine/component-shape.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AACvF,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,EAAgB,MAAM,mBAAmB,CAAC;AACtG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AA0B3D,MAAM,UAAU,QAAQ,CACtB,IAAkB,EAClB,KAAY,EACZ,S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CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,IAAI,IAAI,CAAC;IAC9G,OAAO,mBAAmB,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { OccurrenceVia } from "@component-compass/plugin-core";
|
|
2
|
+
import type { TerminalIdentity } from "./wrapper-folding.js";
|
|
3
|
+
/**
|
|
4
|
+
* THE closed set of things a value can denote when something asks "what is
|
|
5
|
+
* this tag". One variant per outcome a caller can act on differently. Adding a
|
|
6
|
+
* variant is a compile error at every `matchDenotation` call and in
|
|
7
|
+
* `RENDER_VERDICT`.
|
|
8
|
+
*/
|
|
9
|
+
export type Denotation =
|
|
10
|
+
/** An element value: a render body, or an already-rendered `const br = <br/>`. */
|
|
11
|
+
{
|
|
12
|
+
kind: "element";
|
|
13
|
+
}
|
|
14
|
+
/** A string the walk reached through value hops only — a reference, a union
|
|
15
|
+
* branch, a member of an object or array literal — so the TAG itself is the
|
|
16
|
+
* string: an intrinsic host element. */
|
|
17
|
+
| {
|
|
18
|
+
kind: "host-string";
|
|
19
|
+
value: string | null;
|
|
20
|
+
}
|
|
21
|
+
/** A framework value that is provably not a component (a context object). */
|
|
22
|
+
| {
|
|
23
|
+
kind: "opaque";
|
|
24
|
+
semantics: OpaqueSemantics;
|
|
25
|
+
}
|
|
26
|
+
/** A value supplied somewhere else: an unsubstituted parameter, a prop read
|
|
27
|
+
* off one, a hook result. */
|
|
28
|
+
| {
|
|
29
|
+
kind: "late-bound";
|
|
30
|
+
source: LateBoundSource;
|
|
31
|
+
}
|
|
32
|
+
/** An import the graph cannot see. Identity known, shape unknowable. */
|
|
33
|
+
| {
|
|
34
|
+
kind: "foreign";
|
|
35
|
+
}
|
|
36
|
+
/** Data: a value that reached tag position without being one — an object or
|
|
37
|
+
* array literal, or a string a function body or a call returned. */
|
|
38
|
+
| {
|
|
39
|
+
kind: "data";
|
|
40
|
+
shape: "object" | "array" | "string";
|
|
41
|
+
}
|
|
42
|
+
/** Nothing known. */
|
|
43
|
+
| {
|
|
44
|
+
kind: "indeterminate";
|
|
45
|
+
}
|
|
46
|
+
/** A function reached at a tag position: what JSX renders is the function
|
|
47
|
+
* itself, whatever it returns. */
|
|
48
|
+
| {
|
|
49
|
+
kind: "callable";
|
|
50
|
+
};
|
|
51
|
+
export type OpaqueSemantics = "context";
|
|
52
|
+
export type LateBoundSource = "parameter" | "parameter-member" | "hook-result";
|
|
53
|
+
/**
|
|
54
|
+
* One branch of an evaluation. `identity` is the binding this branch credits
|
|
55
|
+
* (null = "the caller's own fallback names this render"); `viaTrail` is the
|
|
56
|
+
* fold's hops, outermost-first, excluding the caller's outer via.
|
|
57
|
+
*/
|
|
58
|
+
export type Terminal = {
|
|
59
|
+
denotation: Denotation;
|
|
60
|
+
identity: TerminalIdentity;
|
|
61
|
+
viaTrail: OccurrenceVia[];
|
|
62
|
+
};
|
|
63
|
+
/** The result of evaluating one value. Never empty. */
|
|
64
|
+
export type Evaluation = readonly [Terminal, ...Terminal[]];
|
|
65
|
+
/** One handler per denotation kind. A missing key is a type error; there is
|
|
66
|
+
* deliberately no default case and no `Partial`. */
|
|
67
|
+
export type DenotationCases<R> = {
|
|
68
|
+
[K in Denotation["kind"]]: (d: Extract<Denotation, {
|
|
69
|
+
kind: K;
|
|
70
|
+
}>, t: Terminal) => R;
|
|
71
|
+
};
|
|
72
|
+
/** The only sanctioned reader of `Denotation["kind"]` outside this module. */
|
|
73
|
+
export declare function matchDenotation<R>(t: Terminal, cases: DenotationCases<R>): R;
|
|
74
|
+
export type RenderOutcome = {
|
|
75
|
+
kind: "credit";
|
|
76
|
+
terminals: readonly [Terminal, ...Terminal[]];
|
|
77
|
+
} | {
|
|
78
|
+
kind: "silent";
|
|
79
|
+
because: "host-string" | "opaque";
|
|
80
|
+
} | {
|
|
81
|
+
kind: "diagnose";
|
|
82
|
+
code: "late-bound-render" | "unresolved-reference";
|
|
83
|
+
};
|
|
84
|
+
/** The terminals a render of this value credits — rule 1 of the table, shared
|
|
85
|
+
* with the holder fold and argument-site seeding so there is not one
|
|
86
|
+
* classification per arm. Empty when nothing is credited. */
|
|
87
|
+
export declare function creditedTerminals(e: readonly Terminal[]): Terminal[];
|
|
88
|
+
/** True when this terminal is a function a tag renders. */
|
|
89
|
+
export declare function isCallable(t: Terminal): boolean;
|
|
90
|
+
export declare function renderOutcome(e: Evaluation): RenderOutcome;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** The only sanctioned reader of `Denotation["kind"]` outside this module. */
|
|
2
|
+
export function matchDenotation(t, cases) {
|
|
3
|
+
const handler = cases[t.denotation.kind];
|
|
4
|
+
return handler(t.denotation, t);
|
|
5
|
+
}
|
|
6
|
+
/** THE table: what one denotation means for a tag position. Stated once. */
|
|
7
|
+
const RENDER_VERDICT = {
|
|
8
|
+
element: () => "credit",
|
|
9
|
+
foreign: () => "credit",
|
|
10
|
+
"host-string": () => "silent",
|
|
11
|
+
opaque: () => "silent",
|
|
12
|
+
"late-bound": () => "late-bound",
|
|
13
|
+
data: () => "unresolved",
|
|
14
|
+
indeterminate: () => "unresolved",
|
|
15
|
+
callable: () => "credit",
|
|
16
|
+
};
|
|
17
|
+
/** THE fan-out precedence: a Union / dynamic-map evaluation has several
|
|
18
|
+
* terminals with different verdicts. Highest wins, once, here. */
|
|
19
|
+
const VERDICT_ORDER = ["credit", "silent", "late-bound", "unresolved"];
|
|
20
|
+
/** The terminals a render of this value credits — rule 1 of the table, shared
|
|
21
|
+
* with the holder fold and argument-site seeding so there is not one
|
|
22
|
+
* classification per arm. Empty when nothing is credited. */
|
|
23
|
+
export function creditedTerminals(e) {
|
|
24
|
+
return e.filter((t) => matchDenotation(t, RENDER_VERDICT) === "credit");
|
|
25
|
+
}
|
|
26
|
+
const IS_CALLABLE = {
|
|
27
|
+
element: () => false,
|
|
28
|
+
foreign: () => false,
|
|
29
|
+
"host-string": () => false,
|
|
30
|
+
opaque: () => false,
|
|
31
|
+
"late-bound": () => false,
|
|
32
|
+
data: () => false,
|
|
33
|
+
indeterminate: () => false,
|
|
34
|
+
callable: () => true,
|
|
35
|
+
};
|
|
36
|
+
/** True when this terminal is a function a tag renders. */
|
|
37
|
+
export function isCallable(t) {
|
|
38
|
+
return matchDenotation(t, IS_CALLABLE);
|
|
39
|
+
}
|
|
40
|
+
export function renderOutcome(e) {
|
|
41
|
+
const verdicts = e.map((t) => matchDenotation(t, RENDER_VERDICT));
|
|
42
|
+
const winner = VERDICT_ORDER.find((v) => verdicts.includes(v)) ?? "unresolved";
|
|
43
|
+
const first = e[verdicts.indexOf(winner)] ?? e[0];
|
|
44
|
+
switch (winner) {
|
|
45
|
+
case "credit":
|
|
46
|
+
return { kind: "credit", terminals: creditedTerminals(e) };
|
|
47
|
+
case "silent":
|
|
48
|
+
return { kind: "silent", because: first.denotation.kind === "opaque" ? "opaque" : "host-string" };
|
|
49
|
+
case "late-bound":
|
|
50
|
+
return { kind: "diagnose", code: "late-bound-render" };
|
|
51
|
+
case "unresolved":
|
|
52
|
+
return { kind: "diagnose", code: "unresolved-reference" };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=denotation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"denotation.js","sourceRoot":"","sources":["../../src/engine/denotation.ts"],"names":[],"mappings":"AAuDA,8EAA8E;AAC9E,MAAM,UAAU,eAAe,CAAI,CAAW,EAAE,KAAyB;IACvE,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAsC,CAAC;IAC9E,OAAO,OAAO,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;AAClC,CAAC;AAID,4EAA4E;AAC5E,MAAM,cAAc,GAAmC;IACrD,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ;IACvB,OAAO,EAAE,GAAG,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AC,CAAC,CAAC;IAClE,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC;IAC/E,MAAM,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAA8B,EAAE,CAAC;QAC1F,KAAK,QAAQ;YACX,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;QACpG,KAAK,YAAY;YACf,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC;QACzD,KAAK,YAAY;YACf,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC;IAC9D,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { FileGraph } from "../index.js";
|
|
2
|
+
/**
|
|
3
|
+
* React's own hook predicate (`isHookName` in rules-of-hooks and the
|
|
4
|
+
* compiler).
|
|
5
|
+
*/
|
|
6
|
+
export declare const HOOK_NAME: RegExp;
|
|
2
7
|
/**
|
|
3
8
|
* THE JSX host-element naming rule. JSX compiles a bare,
|
|
4
9
|
* lowercase-initial element name to a string — `div`, `svg`, `web-button` —
|
|
@@ -9,9 +14,8 @@ import type { FileGraph } from "../index.js";
|
|
|
9
14
|
* intrinsic, so a caller holding a reference checks `memberChain.length === 0`
|
|
10
15
|
* first (`isHostElementRoot`, `engine/index.ts`).
|
|
11
16
|
*
|
|
12
|
-
* `isPascalCase` in `ast-utils/src/find-owner.ts`
|
|
13
|
-
*
|
|
14
|
-
* which rejects `_Foo`). Do not fold them into this one.
|
|
17
|
+
* `isPascalCase` in `ast-utils/src/find-owner.ts` is a DIFFERENT predicate
|
|
18
|
+
* (`/^[A-Z]/`, which rejects `_Foo`). Do not fold it into this one.
|
|
15
19
|
*/
|
|
16
20
|
export declare function isHostElementName(name: string): boolean;
|
|
17
21
|
/**
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React's own hook predicate (`isHookName` in rules-of-hooks and the
|
|
3
|
+
* compiler).
|
|
4
|
+
*/
|
|
5
|
+
export const HOOK_NAME = /^use[A-Z0-9]/;
|
|
1
6
|
/**
|
|
2
7
|
* THE JSX host-element naming rule. JSX compiles a bare,
|
|
3
8
|
* lowercase-initial element name to a string — `div`, `svg`, `web-button` —
|
|
@@ -8,9 +13,8 @@
|
|
|
8
13
|
* intrinsic, so a caller holding a reference checks `memberChain.length === 0`
|
|
9
14
|
* first (`isHostElementRoot`, `engine/index.ts`).
|
|
10
15
|
*
|
|
11
|
-
* `isPascalCase` in `ast-utils/src/find-owner.ts`
|
|
12
|
-
*
|
|
13
|
-
* which rejects `_Foo`). Do not fold them into this one.
|
|
16
|
+
* `isPascalCase` in `ast-utils/src/find-owner.ts` is a DIFFERENT predicate
|
|
17
|
+
* (`/^[A-Z]/`, which rejects `_Foo`). Do not fold it into this one.
|
|
14
18
|
*/
|
|
15
19
|
export function isHostElementName(name) {
|
|
16
20
|
return /^[a-z]/.test(name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-element.js","sourceRoot":"","sources":["../../src/engine/host-element.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"host-element.js","sourceRoot":"","sources":["../../src/engine/host-element.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,cAAc,CAAC;AAExC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAc,EAAE,SAAgC;IACtF,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAC7C,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACvC,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACzC,KAAK,MAAM,GAAG,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;QACpC,IAAI,CAAC,CAAC,OAAO,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,KAAK,KAAK,MAAM;YAAE,SAAS;QACxD,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QACzC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC;YAAE,OAAO,KAAK,CAAC;IACvD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export type EngineOccurrence = {
|
|
|
53
53
|
};
|
|
54
54
|
export type ResolvedGraph = {
|
|
55
55
|
occurrences: EngineOccurrence[];
|
|
56
|
-
/** The component registry this resolution
|
|
56
|
+
/** The component registry this resolution judged identities against.
|
|
57
57
|
* The CLI's roster join (`buildComponentSeeds`) reads it. */
|
|
58
58
|
registry: ComponentRegistry;
|
|
59
59
|
};
|