@barefootjs/jsx 0.39.7 → 0.39.8
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/adapters/callback-method.d.ts +17 -0
- package/dist/adapters/callback-method.d.ts.map +1 -1
- package/dist/adapters/component-props.d.ts +80 -13
- package/dist/adapters/component-props.d.ts.map +1 -1
- package/dist/adapters/dsl-template-adapter.d.ts +151 -0
- package/dist/adapters/dsl-template-adapter.d.ts.map +1 -0
- package/dist/adapters/jsx-adapter.d.ts +4 -0
- package/dist/adapters/jsx-adapter.d.ts.map +1 -1
- package/dist/adapters/literal-value.d.ts +2 -2
- package/dist/adapters/literal-value.d.ts.map +1 -1
- package/dist/adapters/parsed-expr-emitter.d.ts +27 -0
- package/dist/adapters/parsed-expr-emitter.d.ts.map +1 -1
- package/dist/adapters/style-object.d.ts +33 -0
- package/dist/adapters/style-object.d.ts.map +1 -0
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/children-nullish.d.ts +22 -0
- package/dist/children-nullish.d.ts.map +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/expression-parser.d.ts +9 -19
- package/dist/expression-parser.d.ts.map +1 -1
- package/dist/free-refs.d.ts +6 -0
- package/dist/free-refs.d.ts.map +1 -1
- package/dist/index.d.ts +14 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14685 -14000
- package/dist/ir-to-client-js/compute-inlinability.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/event-collision.d.ts +2 -1
- package/dist/ir-to-client-js/control-flow/plan/event-collision.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/plan/insert.d.ts +2 -2
- package/dist/ir-to-client-js/control-flow/plan/insert.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/event-delegation.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts +10 -9
- package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts.map +1 -1
- package/dist/ir-to-client-js/csr-substitute.d.ts.map +1 -1
- package/dist/ir-to-client-js/emit-reactive.d.ts +1 -1
- package/dist/ir-to-client-js/emit-reactive.d.ts.map +1 -1
- package/dist/ir-to-client-js/emit-registration.d.ts +10 -8
- package/dist/ir-to-client-js/emit-registration.d.ts.map +1 -1
- package/dist/ir-to-client-js/generate-init.d.ts.map +1 -1
- package/dist/ir-to-client-js/html-template.d.ts +0 -9
- package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
- package/dist/ir-to-client-js/identifiers.d.ts +6 -8
- package/dist/ir-to-client-js/identifiers.d.ts.map +1 -1
- package/dist/ir-to-client-js/imports.d.ts +23 -2
- package/dist/ir-to-client-js/imports.d.ts.map +1 -1
- package/dist/ir-to-client-js/phases/props-extraction.d.ts +3 -2
- package/dist/ir-to-client-js/phases/props-extraction.d.ts.map +1 -1
- package/dist/ir-to-client-js/prune-unused-prop-extractions.d.ts +1 -1
- package/dist/ir-to-client-js/prune-unused-prop-extractions.d.ts.map +1 -1
- package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
- package/dist/ir-to-client-js/rewrite-destructured-props.d.ts +1 -1
- package/dist/ir-to-client-js/rewrite-destructured-props.d.ts.map +1 -1
- package/dist/ir-to-client-js/safe-html.d.ts +20 -2
- package/dist/ir-to-client-js/safe-html.d.ts.map +1 -1
- package/dist/ir-to-client-js/types.d.ts +3 -3
- package/dist/ir-to-client-js/types.d.ts.map +1 -1
- package/dist/ir-to-client-js/utils.d.ts +2 -11
- package/dist/ir-to-client-js/utils.d.ts.map +1 -1
- package/dist/jsx-to-ir.d.ts.map +1 -1
- package/dist/nullable-signal-attr.d.ts +40 -10
- package/dist/nullable-signal-attr.d.ts.map +1 -1
- package/dist/prop-rewrite.d.ts +18 -0
- package/dist/prop-rewrite.d.ts.map +1 -1
- package/dist/props-binding.d.ts +9 -1
- package/dist/props-binding.d.ts.map +1 -1
- package/dist/scanner/js-scanner.d.ts.map +1 -1
- package/dist/scanner/js-scanner.js +30 -2
- package/dist/signal-prop-name-collision.d.ts +6 -5
- package/dist/signal-prop-name-collision.d.ts.map +1 -1
- package/dist/ssr-defaults.d.ts +28 -0
- package/dist/ssr-defaults.d.ts.map +1 -1
- package/dist/ssr-seed-plan.d.ts +39 -14
- package/dist/ssr-seed-plan.d.ts.map +1 -1
- package/dist/types.d.ts +108 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/value-references.d.ts +21 -0
- package/dist/value-references.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +18 -18
- package/src/__tests__/adapter-output.test.ts +5 -3
- package/src/__tests__/analyzer.test.ts +33 -0
- package/src/__tests__/arithmetic-lowering.test.ts +44 -0
- package/src/__tests__/children-read.test.ts +226 -0
- package/src/__tests__/client-template-escape-soundness.test.ts +31 -1
- package/src/__tests__/component-props.test.ts +68 -1
- package/src/__tests__/constant-inlining-tree.test.ts +136 -0
- package/src/__tests__/destructure-default-reads-earlier-param.test.ts +138 -0
- package/src/__tests__/dsl-template-adapter.test.ts +173 -0
- package/src/__tests__/event-handler-verbatim.test.ts +73 -0
- package/src/__tests__/expression-parser.test.ts +1 -44
- package/src/__tests__/nullable-signal-attr.test.ts +67 -3
- package/src/__tests__/reference-graph-identifiers.test.ts +161 -0
- package/src/__tests__/runtime-import-detection.test.ts +134 -0
- package/src/__tests__/signal-prop-name-collision.test.ts +30 -0
- package/src/__tests__/ssr-defaults.test.ts +19 -1
- package/src/__tests__/ssr-seed-plan.test.ts +119 -0
- package/src/__tests__/style-object-plan.test.ts +54 -0
- package/src/__tests__/zero-param-helper-inline.test.ts +57 -0
- package/src/adapters/callback-method.ts +23 -0
- package/src/adapters/component-props.ts +130 -12
- package/src/adapters/dsl-template-adapter.ts +248 -0
- package/src/adapters/jsx-adapter.ts +12 -6
- package/src/adapters/literal-value.ts +2 -2
- package/src/adapters/parsed-expr-emitter.ts +34 -0
- package/src/adapters/style-object.ts +61 -0
- package/src/analyzer.ts +114 -15
- package/src/children-nullish.ts +33 -0
- package/src/debug.ts +2 -2
- package/src/errors.ts +12 -0
- package/src/expression-parser.ts +56 -53
- package/src/free-refs.ts +28 -17
- package/src/index.ts +18 -8
- package/src/ir-to-client-js/compute-inlinability.ts +29 -2
- package/src/ir-to-client-js/control-flow/plan/event-collision.ts +2 -1
- package/src/ir-to-client-js/control-flow/plan/insert.ts +2 -2
- package/src/ir-to-client-js/control-flow/stringify/event-delegation.ts +3 -2
- package/src/ir-to-client-js/control-flow/stringify/event-listener.ts +13 -12
- package/src/ir-to-client-js/csr-substitute.ts +12 -2
- package/src/ir-to-client-js/emit-reactive.ts +2 -2
- package/src/ir-to-client-js/emit-registration.ts +28 -57
- package/src/ir-to-client-js/generate-init.ts +17 -1
- package/src/ir-to-client-js/html-template.ts +30 -50
- package/src/ir-to-client-js/identifiers.ts +75 -24
- package/src/ir-to-client-js/imports.ts +56 -19
- package/src/ir-to-client-js/index.ts +2 -1
- package/src/ir-to-client-js/phases/event-handlers.ts +2 -2
- package/src/ir-to-client-js/phases/props-extraction.ts +16 -15
- package/src/ir-to-client-js/plan/build-declaration-emit.ts +2 -2
- package/src/ir-to-client-js/prune-unused-prop-extractions.ts +7 -4
- package/src/ir-to-client-js/reactivity.ts +2 -2
- package/src/ir-to-client-js/rewrite-destructured-props.ts +21 -4
- package/src/ir-to-client-js/safe-html.ts +29 -35
- package/src/ir-to-client-js/types.ts +3 -2
- package/src/ir-to-client-js/utils.ts +2 -26
- package/src/jsx-to-ir.ts +279 -78
- package/src/nullable-signal-attr.ts +149 -33
- package/src/prop-rewrite.ts +41 -0
- package/src/props-binding.ts +17 -2
- package/src/scanner/__tests__/js-scanner.test.ts +37 -0
- package/src/scanner/js-scanner.ts +64 -4
- package/src/signal-prop-name-collision.ts +50 -24
- package/src/ssr-defaults.ts +47 -20
- package/src/ssr-seed-plan.ts +103 -23
- package/src/types.ts +115 -19
- package/src/value-references.ts +132 -0
package/src/ssr-defaults.ts
CHANGED
|
@@ -33,6 +33,7 @@ import ts from 'typescript'
|
|
|
33
33
|
import { extractFreeIdentifiersFromNode } from './analyzer.ts'
|
|
34
34
|
import { resolveGetterAliases, collectAliasableGetterNames } from './ir-to-client-js/csr-substitute.ts'
|
|
35
35
|
import { resolveBodyDestructuredPropAliases } from './props-binding.ts'
|
|
36
|
+
import { computeSsrSeedPlan } from './ssr-seed-plan.ts'
|
|
36
37
|
import type { IRMetadata } from './types.ts'
|
|
37
38
|
import { isElidedFactoryGetter } from './types.ts'
|
|
38
39
|
|
|
@@ -162,6 +163,44 @@ interface EvalContext {
|
|
|
162
163
|
propsLike: ReadonlySet<string>
|
|
163
164
|
}
|
|
164
165
|
|
|
166
|
+
/**
|
|
167
|
+
* One entry per prop for {@link extractSsrDefaults} (see its comment on the
|
|
168
|
+
* two parameter forms): a static destructure default seeds its evaluated
|
|
169
|
+
* value, any other prop seeds `null`.
|
|
170
|
+
*/
|
|
171
|
+
function addPropSsrDefaults(
|
|
172
|
+
metadata: IRMetadata,
|
|
173
|
+
propsLike: ReadonlySet<string>,
|
|
174
|
+
out: Record<string, SsrDefault>,
|
|
175
|
+
): void {
|
|
176
|
+
// A prop whose default reads an earlier prop (`{ off = false, on = !off }`,
|
|
177
|
+
// #3531) and that the seed plan re-binds in-template: its value depends on
|
|
178
|
+
// what the caller passed, so no static value is right, and a non-null seed
|
|
179
|
+
// would read as caller-supplied to the template's own `on ?? !off`.
|
|
180
|
+
const plan = metadata.ssrSeedPlan ?? computeSsrSeedPlan(metadata)
|
|
181
|
+
const templateDefaulted = new Set(
|
|
182
|
+
plan.steps.filter(s => s.kind === 'derived' && s.origin === 'prop').map(s => s.name),
|
|
183
|
+
)
|
|
184
|
+
for (const p of metadata.propsParams) {
|
|
185
|
+
if (p.isRest) continue
|
|
186
|
+
// `propName` is the CALLER-facing key (`$props->{propName}` in the Perl
|
|
187
|
+
// consumer above) — for a renaming destructure (`{ n: count }`) that's
|
|
188
|
+
// `n`, not the local binding `count` the template variable is keyed by.
|
|
189
|
+
// `sourceName ?? name` is an identity for every un-aliased prop.
|
|
190
|
+
const callerPropName = p.sourceName ?? p.name
|
|
191
|
+
if (p.defaultValue !== undefined && !templateDefaulted.has(p.name)) {
|
|
192
|
+
const value = tryStaticEval(p.defaultValue, { bindings: {}, propsLike })
|
|
193
|
+
out[p.name] = { propName: callerPropName, value: resultToJsonable(value) }
|
|
194
|
+
} else {
|
|
195
|
+
// No destructure default — the template reads the prop as-is;
|
|
196
|
+
// Perl's `//` operator decides what `undef` becomes. The entry
|
|
197
|
+
// still matters so the template variable exists and consumers
|
|
198
|
+
// can supply the propName even with no static fallback.
|
|
199
|
+
out[p.name] = { propName: callerPropName, value: null }
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
165
204
|
/**
|
|
166
205
|
* Extract a JSON-encodable defaults map for the SSR stash.
|
|
167
206
|
*
|
|
@@ -194,24 +233,7 @@ export function extractSsrDefaults(metadata: IRMetadata): Record<string, SsrDefa
|
|
|
194
233
|
// evaluated value; one with none seeds `null` (→ undef; the
|
|
195
234
|
// template-side `// …` recompute supplies the real default, and a
|
|
196
235
|
// caller-passed prop wins via `propName`).
|
|
197
|
-
|
|
198
|
-
if (p.isRest) continue
|
|
199
|
-
// `propName` is the CALLER-facing key (`$props->{propName}` in the Perl
|
|
200
|
-
// consumer above) — for a renaming destructure (`{ n: count }`) that's
|
|
201
|
-
// `n`, not the local binding `count` the template variable is keyed by.
|
|
202
|
-
// `sourceName ?? name` is an identity for every un-aliased prop.
|
|
203
|
-
const callerPropName = p.sourceName ?? p.name
|
|
204
|
-
if (p.defaultValue !== undefined) {
|
|
205
|
-
const value = tryStaticEval(p.defaultValue, { bindings: {}, propsLike })
|
|
206
|
-
out[p.name] = { propName: callerPropName, value: resultToJsonable(value) }
|
|
207
|
-
} else {
|
|
208
|
-
// No destructure default — the template reads the prop as-is;
|
|
209
|
-
// Perl's `//` operator decides what `undef` becomes. The entry
|
|
210
|
-
// still matters so the template variable exists and consumers
|
|
211
|
-
// can supply the propName even with no static fallback.
|
|
212
|
-
out[p.name] = { propName: callerPropName, value: null }
|
|
213
|
-
}
|
|
214
|
-
}
|
|
236
|
+
addPropSsrDefaults(metadata, propsLike, out)
|
|
215
237
|
// Rest-props bag (`...props`) — tracked separately from `propsParams`
|
|
216
238
|
// by the analyzer. Default to an empty plain hash so adapters can
|
|
217
239
|
// forward it through `spreadAttrs` without a nullability check.
|
|
@@ -444,7 +466,7 @@ export function extractSsrDefaults(metadata: IRMetadata): Record<string, SsrDefa
|
|
|
444
466
|
* (a module const referencing `props` isn't legal JS — `props` is a
|
|
445
467
|
* function parameter), so it can never contribute a prop reference here.
|
|
446
468
|
*/
|
|
447
|
-
function localConstValuesByName(metadata: IRMetadata): ReadonlyMap<string, string> {
|
|
469
|
+
export function localConstValuesByName(metadata: Pick<IRMetadata, 'localConstants'>): ReadonlyMap<string, string> {
|
|
448
470
|
const out = new Map<string, string>()
|
|
449
471
|
for (const c of metadata.localConstants ?? []) {
|
|
450
472
|
if (c.isModule || c.value === undefined) continue
|
|
@@ -462,8 +484,13 @@ function localConstValuesByName(metadata: IRMetadata): ReadonlyMap<string, strin
|
|
|
462
484
|
* (never a bespoke walker — see the CLAUDE.md rule this file already
|
|
463
485
|
* follows for `props.X` collection) and just checks membership of the one
|
|
464
486
|
* name we care about.
|
|
487
|
+
*
|
|
488
|
+
* Also the analyzer's test for which same-named signal/memo keeps sharing
|
|
489
|
+
* the prop's template variable (`separateSignalPropBindings`): a binding
|
|
490
|
+
* this answers `false` for is renamed before IR is built, so the two
|
|
491
|
+
* callers cannot disagree about which collisions stay collapsed.
|
|
465
492
|
*/
|
|
466
|
-
function referencesOwnProp(
|
|
493
|
+
export function referencesOwnProp(
|
|
467
494
|
expr: string | undefined,
|
|
468
495
|
propsObjectName: string,
|
|
469
496
|
name: string,
|
package/src/ssr-seed-plan.ts
CHANGED
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
* template adapters' seed paths; this module computes it once, on the IR, so
|
|
9
9
|
* every adapter consumes the same plan and only supplies its own syntax.
|
|
10
10
|
*
|
|
11
|
-
* Ordering / acyclicity guarantee: `steps` lists the
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Ordering / acyclicity guarantee: `steps` lists the props whose destructure
|
|
12
|
+
* default reads an earlier prop first, in parameter order, then the
|
|
13
|
+
* component's signals, then its memos, each group in declaration order
|
|
14
|
+
* (matching `IRMetadata.signals` / `IRMetadata.memos`), then canonical getter
|
|
15
|
+
* aliases.
|
|
14
16
|
* A binding's name only enters
|
|
15
17
|
* the scope set AFTER its own step is decided, so a `derived` step's `frees`
|
|
16
18
|
* can only name `baseScope` entries or EARLIER steps — self- and
|
|
@@ -22,11 +24,11 @@
|
|
|
22
24
|
* literal value — `collectModuleStringConsts` is the shared source of that
|
|
23
25
|
* set — so a reference to one is never a template-variable read.
|
|
24
26
|
*
|
|
25
|
-
* A `derived` step
|
|
26
|
-
* `createSignal('b')`)
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* A `derived` step whose `frees` name only module pure-string consts (or
|
|
28
|
+
* nothing, e.g. `createSignal('b')`) is a constant expression, marked
|
|
29
|
+
* `constant`: the plan still classifies it as derived because the expression
|
|
30
|
+
* is fully analyzable, and adapters keep their static ssr-defaults seed for
|
|
31
|
+
* it instead of computing it in-template. Likewise the plan makes no backend-specific choices —
|
|
30
32
|
* no target-variable checks, no self-shadowing rules, no per-backend shape
|
|
31
33
|
* catalogs — those stay in the adapters.
|
|
32
34
|
*/
|
|
@@ -42,12 +44,13 @@ import {
|
|
|
42
44
|
stringifyParsedExpr,
|
|
43
45
|
type ParsedExpr,
|
|
44
46
|
} from './expression-parser.ts'
|
|
45
|
-
import type { IRMetadata } from './types.ts'
|
|
47
|
+
import type { IRMetadata, ParamInfo } from './types.ts'
|
|
46
48
|
import { isElidedFactoryGetter } from './types.ts'
|
|
47
49
|
|
|
48
50
|
/**
|
|
49
|
-
* One binding in dependency order (signals, memos,
|
|
50
|
-
* matching `IRMetadata` order and the adapters'
|
|
51
|
+
* One binding in dependency order (dependent prop defaults, signals, memos,
|
|
52
|
+
* then getter aliases — matching `IRMetadata` order and the adapters'
|
|
53
|
+
* iteration).
|
|
51
54
|
*
|
|
52
55
|
* - `env-reader`: an env signal whose `envReader` key resolves in the shared
|
|
53
56
|
* registry (`envSignalReaderFor`). The runtime provides the per-request
|
|
@@ -56,7 +59,12 @@ import { isElidedFactoryGetter } from './types.ts'
|
|
|
56
59
|
* registry falls through to the normal derived/opaque rules instead.
|
|
57
60
|
* - `derived`: the binding's value expression is a supported shape whose free
|
|
58
61
|
* identifiers are all in scope at this point (baseScope + earlier steps) —
|
|
59
|
-
* an adapter may seed it in-template by lowering `parsed`/`expr`.
|
|
62
|
+
* an adapter may seed it in-template by lowering `parsed`/`expr`. An
|
|
63
|
+
* `origin: 'prop'` step re-binds a prop whose destructure default reads an
|
|
64
|
+
* earlier prop (`{ off = false, on = off }` → `on ?? off`, #3531): the
|
|
65
|
+
* static ssr-defaults seed cannot hold a value that depends on what the
|
|
66
|
+
* caller passed, so the template applies the default itself, reading the
|
|
67
|
+
* earlier prop's template variable.
|
|
60
68
|
* - `opaque`: not seedable this way (empty init, unsupported shape,
|
|
61
69
|
* unanalyzable free set, out-of-scope reference, or a block-bodied memo).
|
|
62
70
|
* The name still enters scope for later steps; adapters keep their static
|
|
@@ -64,8 +72,21 @@ import { isElidedFactoryGetter } from './types.ts'
|
|
|
64
72
|
*/
|
|
65
73
|
export type SsrSeedStep =
|
|
66
74
|
| { kind: 'env-reader'; name: string; reader: EnvSignalReader }
|
|
67
|
-
| {
|
|
68
|
-
|
|
75
|
+
| {
|
|
76
|
+
kind: 'derived'
|
|
77
|
+
name: string
|
|
78
|
+
origin: 'signal' | 'memo' | 'prop'
|
|
79
|
+
expr: string
|
|
80
|
+
parsed: ParsedExpr
|
|
81
|
+
frees: string[]
|
|
82
|
+
/**
|
|
83
|
+
* Every free identifier is a module pure-string const, which every
|
|
84
|
+
* adapter inlines, so the lowered expression reads no template
|
|
85
|
+
* variable (#3542).
|
|
86
|
+
*/
|
|
87
|
+
constant: boolean
|
|
88
|
+
}
|
|
89
|
+
| { kind: 'opaque'; name: string; origin: 'signal' | 'memo' | 'prop' }
|
|
69
90
|
|
|
70
91
|
export interface SsrSeedPlan {
|
|
71
92
|
/**
|
|
@@ -92,18 +113,21 @@ export interface SsrSeedPlan {
|
|
|
92
113
|
*/
|
|
93
114
|
function classify(
|
|
94
115
|
name: string,
|
|
95
|
-
origin: 'signal' | 'memo',
|
|
116
|
+
origin: 'signal' | 'memo' | 'prop',
|
|
96
117
|
expr: string,
|
|
97
118
|
parsed: ParsedExpr,
|
|
98
119
|
available: ReadonlySet<string>,
|
|
120
|
+
inlined: ReadonlySet<string>,
|
|
99
121
|
): SsrSeedStep {
|
|
100
|
-
|
|
122
|
+
const opaque: SsrSeedStep = { kind: 'opaque', name, origin }
|
|
123
|
+
if (!isSupportedValue(parsed).supported) return opaque
|
|
101
124
|
const frees = freeIdentifiers(parsed)
|
|
102
|
-
if (frees === null) return
|
|
125
|
+
if (frees === null) return opaque
|
|
103
126
|
for (const free of frees) {
|
|
104
|
-
if (!available.has(free)) return
|
|
127
|
+
if (!available.has(free)) return opaque
|
|
105
128
|
}
|
|
106
|
-
|
|
129
|
+
const constant = [...frees].every(free => inlined.has(free))
|
|
130
|
+
return { kind: 'derived', name, origin, expr, parsed, frees: [...frees], constant }
|
|
107
131
|
}
|
|
108
132
|
|
|
109
133
|
/**
|
|
@@ -191,17 +215,71 @@ function memoSeedExpr(memo: IRMetadata['memos'][number]): string {
|
|
|
191
215
|
return memo.parsed ? stringifyParsedExpr(memo.parsed) : ''
|
|
192
216
|
}
|
|
193
217
|
|
|
218
|
+
/**
|
|
219
|
+
* A `derived` step per prop whose destructure default reads an earlier prop of
|
|
220
|
+
* the same pattern (`ParamInfo.defaultParts`, #3531): `on ?? <default>`, where
|
|
221
|
+
* the default's identifiers are the earlier props' template variables. Every
|
|
222
|
+
* prop is already in `available` (baseScope), and the steps run in dependency
|
|
223
|
+
* order ({@link inDefaultReadOrder}), so a chain (`{ a = 1, b = a, c = b }`)
|
|
224
|
+
* reads `b` after its own step re-bound it. A default the plan cannot lower
|
|
225
|
+
* (or a function default) adds no step and keeps the static ssr-defaults
|
|
226
|
+
* seed. A callback inside the default (`a.filter((x) => …)`) does not make
|
|
227
|
+
* it a function default.
|
|
228
|
+
*/
|
|
229
|
+
function dependentPropDefaultSteps(
|
|
230
|
+
metadata: IRMetadata,
|
|
231
|
+
available: ReadonlySet<string>,
|
|
232
|
+
inlined: ReadonlySet<string>,
|
|
233
|
+
): SsrSeedStep[] {
|
|
234
|
+
const steps: SsrSeedStep[] = []
|
|
235
|
+
for (const p of inDefaultReadOrder(metadata.propsParams)) {
|
|
236
|
+
if (p.isRest || !p.defaultParts || !p.parsed || p.parsed.kind === 'arrow') continue
|
|
237
|
+
const parsed: ParsedExpr = { kind: 'logical', op: '??', left: { kind: 'identifier', name: p.name }, right: p.parsed }
|
|
238
|
+
const step = classify(p.name, 'prop', stringifyParsedExpr(parsed), parsed, available, inlined)
|
|
239
|
+
if (step.kind === 'derived') steps.push(step)
|
|
240
|
+
}
|
|
241
|
+
return steps
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* `params` with every prop placed after the props its destructure default
|
|
246
|
+
* reads (`ParamInfo.defaultParts`). `propsParams` follows the props TYPE's
|
|
247
|
+
* member order for a body destructure (`const { a = 'x', b = a } = props`
|
|
248
|
+
* over `{ b?: string; a?: string }`), which need not be the pattern's order,
|
|
249
|
+
* so the order comes from the reads themselves. The reads only ever name an
|
|
250
|
+
* EARLIER binding of the same pattern, so they form no cycle; otherwise the
|
|
251
|
+
* input order is kept. Every backend applying these defaults one prop at a
|
|
252
|
+
* time (the in-template re-binds here, Go's constructor) uses this order.
|
|
253
|
+
*/
|
|
254
|
+
export function inDefaultReadOrder(params: readonly ParamInfo[]): ParamInfo[] {
|
|
255
|
+
const byName = new Map(params.filter(p => !p.isRest).map(p => [p.name, p]))
|
|
256
|
+
const ordered: ParamInfo[] = []
|
|
257
|
+
const placed = new Set<ParamInfo>()
|
|
258
|
+
const place = (p: ParamInfo): void => {
|
|
259
|
+
if (placed.has(p)) return
|
|
260
|
+
placed.add(p)
|
|
261
|
+
for (const part of p.defaultParts ?? []) {
|
|
262
|
+
const read = part.kind === 'param' ? byName.get(part.param.name) : undefined
|
|
263
|
+
if (read) place(read)
|
|
264
|
+
}
|
|
265
|
+
ordered.push(p)
|
|
266
|
+
}
|
|
267
|
+
for (const p of params) place(p)
|
|
268
|
+
return ordered
|
|
269
|
+
}
|
|
270
|
+
|
|
194
271
|
export function computeSsrSeedPlan(metadata: IRMetadata): SsrSeedPlan {
|
|
195
272
|
const baseScope: string[] = metadata.propsParams.map(p => p.name)
|
|
196
273
|
if (metadata.propsObjectName) baseScope.push(metadata.propsObjectName)
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
274
|
+
const inlined = new Set(collectModuleStringConsts(metadata.localConstants).keys())
|
|
275
|
+
baseScope.push(...inlined)
|
|
200
276
|
|
|
201
277
|
const available = new Set<string>(baseScope)
|
|
202
278
|
const localConsts = localConstExprsByName(metadata)
|
|
203
279
|
const steps: SsrSeedStep[] = []
|
|
204
280
|
|
|
281
|
+
steps.push(...dependentPropDefaultSteps(metadata, available, inlined))
|
|
282
|
+
|
|
205
283
|
for (const signal of metadata.signals) {
|
|
206
284
|
if (signal.envReader) {
|
|
207
285
|
const reader = envSignalReaderFor(signal.envReader)
|
|
@@ -243,6 +321,7 @@ export function computeSsrSeedPlan(metadata: IRMetadata): SsrSeedPlan {
|
|
|
243
321
|
// undefined) equally safe.
|
|
244
322
|
resolveThroughLocalConsts(signal.parsed ?? parseExpression(`(${expr})`), localConsts),
|
|
245
323
|
available,
|
|
324
|
+
inlined,
|
|
246
325
|
),
|
|
247
326
|
)
|
|
248
327
|
available.add(signal.getter)
|
|
@@ -259,6 +338,7 @@ export function computeSsrSeedPlan(metadata: IRMetadata): SsrSeedPlan {
|
|
|
259
338
|
expr,
|
|
260
339
|
resolveThroughLocalConsts(memo.parsed ?? parseExpression(expr), localConsts),
|
|
261
340
|
available,
|
|
341
|
+
inlined,
|
|
262
342
|
),
|
|
263
343
|
)
|
|
264
344
|
available.add(memo.name)
|
|
@@ -271,7 +351,7 @@ export function computeSsrSeedPlan(metadata: IRMetadata): SsrSeedPlan {
|
|
|
271
351
|
for (const [alias, origin] of resolveGetterAliases(metadata.localConstants ?? [], name => getters.has(name))) {
|
|
272
352
|
if (metadata.propsParams.some(p => p.name === alias)) continue
|
|
273
353
|
const parsed: ParsedExpr = { kind: 'call', callee: { kind: 'identifier', name: origin }, args: [] }
|
|
274
|
-
steps.push(classify(alias, 'memo', `${origin}()`, parsed, available))
|
|
354
|
+
steps.push(classify(alias, 'memo', `${origin}()`, parsed, available, inlined))
|
|
275
355
|
available.add(alias)
|
|
276
356
|
}
|
|
277
357
|
return { baseScope, steps }
|
package/src/types.ts
CHANGED
|
@@ -7,6 +7,17 @@
|
|
|
7
7
|
import type { ParsedExpr, ParsedStatement } from './expression-parser.ts'
|
|
8
8
|
import type { SsrSeedPlan } from './ssr-seed-plan.ts'
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* JS/TS source text the IR carries verbatim (an expression, a handler, a
|
|
12
|
+
* statement body), as written in the component. Phase 2 passes it through to
|
|
13
|
+
* output or reads the parsed tree beside it; it does not re-derive meaning
|
|
14
|
+
* from the text with regex or string search (spec/adapter-architecture.md,
|
|
15
|
+
* rule 1). A flavor, not a strict brand: a plain `string` is assignable, so
|
|
16
|
+
* producers need no cast, while a read keeps the type and the emit-parse
|
|
17
|
+
* ratchet counts a string operation on it (#3543).
|
|
18
|
+
*/
|
|
19
|
+
export type JsSourceText = string & { readonly __jsSourceText?: 'JsSourceText' }
|
|
20
|
+
|
|
10
21
|
/**
|
|
11
22
|
* Loop-hoisted sort comparator for the `.sort().map()` / `.toSorted().map()`
|
|
12
23
|
* pattern (#2018 P5). Carries the generic comparator `arrow` (params + body)
|
|
@@ -92,7 +103,7 @@ export interface ParamInfo {
|
|
|
92
103
|
name: string
|
|
93
104
|
type: TypeInfo
|
|
94
105
|
optional: boolean
|
|
95
|
-
defaultValue?:
|
|
106
|
+
defaultValue?: JsSourceText
|
|
96
107
|
/**
|
|
97
108
|
* `defaultValue` parsed into a structured tree, mirroring `SignalInfo.parsed`
|
|
98
109
|
* (Roadmap A). Attached best-effort by the analyzer (`tsNodeToParsedExpr` on
|
|
@@ -105,6 +116,16 @@ export interface ParamInfo {
|
|
|
105
116
|
parsed?: ParsedExpr
|
|
106
117
|
/** When true, the default value contains an arrow function or function expression (computed from AST). */
|
|
107
118
|
defaultContainsArrow?: boolean
|
|
119
|
+
/**
|
|
120
|
+
* `defaultValue` split at each read of an EARLIER binding of the same props
|
|
121
|
+
* destructure (`{ off = false, on = off }` → `on`'s parts are one `param`
|
|
122
|
+
* part naming `off`). The analyzer resolves the references against the
|
|
123
|
+
* pattern's own bindings (#3531): an earlier binding is in scope for a later
|
|
124
|
+
* default, so its name there is that prop, never an outer name. Set only
|
|
125
|
+
* when the default reads at least one; `parsed` keeps the identifiers, which
|
|
126
|
+
* a template backend reads as the earlier props' own template variables.
|
|
127
|
+
*/
|
|
128
|
+
defaultParts?: PropDefaultPart[]
|
|
108
129
|
/** When true, the parameter is a rest spread (`...args`) — emit must prepend `...`. */
|
|
109
130
|
isRest?: boolean
|
|
110
131
|
/**
|
|
@@ -118,6 +139,22 @@ export interface ParamInfo {
|
|
|
118
139
|
sourceName?: string
|
|
119
140
|
}
|
|
120
141
|
|
|
142
|
+
/**
|
|
143
|
+
* One piece of a destructure default that reads an earlier binding of its own
|
|
144
|
+
* pattern (`ParamInfo.defaultParts`): the default's text between the reads,
|
|
145
|
+
* and each read as the earlier prop it names. A client-JS emitter renders a
|
|
146
|
+
* `param` part as that prop's own live read (`_p.off ?? false`), so the
|
|
147
|
+
* default never names a binding the emitted scope lacks. A `param` part
|
|
148
|
+
* carries what that read needs, its own `defaultParts` included, so a chain
|
|
149
|
+
* (`{ a = 1, b = a, c = b }`) renders without a lookup.
|
|
150
|
+
*/
|
|
151
|
+
export type PropDefaultPart =
|
|
152
|
+
| { kind: 'text'; text: JsSourceText }
|
|
153
|
+
| { kind: 'param'; param: PropDefaultRead }
|
|
154
|
+
|
|
155
|
+
/** The earlier binding a `param` part reads: the fields a live prop read needs. */
|
|
156
|
+
export type PropDefaultRead = Pick<ParamInfo, 'name' | 'sourceName' | 'defaultValue' | 'defaultContainsArrow' | 'defaultParts'>
|
|
157
|
+
|
|
121
158
|
// =============================================================================
|
|
122
159
|
// Staged-IR primitives: Phase / Scope / Effect (#1138)
|
|
123
160
|
// =============================================================================
|
|
@@ -412,7 +449,7 @@ export interface IRText {
|
|
|
412
449
|
|
|
413
450
|
export interface IRExpression {
|
|
414
451
|
type: 'expression'
|
|
415
|
-
expr:
|
|
452
|
+
expr: JsSourceText
|
|
416
453
|
/**
|
|
417
454
|
* Pre-transformed expr with destructured prop refs rewritten to _p.xxx
|
|
418
455
|
* (for client JS templates). Carries ONLY that rewrite — never an
|
|
@@ -459,6 +496,20 @@ export interface IRExpression {
|
|
|
459
496
|
* unification A3) is its only wiring.
|
|
460
497
|
*/
|
|
461
498
|
preambleRegion?: boolean
|
|
499
|
+
/**
|
|
500
|
+
* How the expression reads the component's own `children` prop (#3539):
|
|
501
|
+
* a bare read (`children` bound by the props destructure, renamed or not,
|
|
502
|
+
* `<propsObject>.children`, or a body alias such as `const { children: kids }
|
|
503
|
+
* = props`), that read on the left of `?? ''`, on the
|
|
504
|
+
* left of `?? <other fallback>`, or on the left of `|| <fallback>` (#3554).
|
|
505
|
+
* Decided once in Phase 1 from the binding,
|
|
506
|
+
* so a local `const children`, a loop row named `children`, or another
|
|
507
|
+
* object's `.children` is never mistaken for the prop. The children value
|
|
508
|
+
* is pre-rendered markup: adapters that cannot tell markup from a string
|
|
509
|
+
* by value (ERB) and the client template's child splice read this to skip
|
|
510
|
+
* escaping it, while a non-empty fallback stays escaped text.
|
|
511
|
+
*/
|
|
512
|
+
childrenRead?: 'bare' | 'nullish-empty' | 'nullish-fallback' | 'or-fallback'
|
|
462
513
|
/** When true, expression calls signal getters or memos (has reactive `foo()` pattern). */
|
|
463
514
|
callsReactiveGetters?: boolean
|
|
464
515
|
/** When true, expression contains function call(s) — any `identifier()` pattern (computed from AST). */
|
|
@@ -496,7 +547,7 @@ export interface IRExpression {
|
|
|
496
547
|
|
|
497
548
|
export interface IRConditional {
|
|
498
549
|
type: 'conditional'
|
|
499
|
-
condition:
|
|
550
|
+
condition: JsSourceText
|
|
500
551
|
/** Pre-transformed condition with destructured prop refs rewritten to _p.xxx. */
|
|
501
552
|
templateCondition?: string
|
|
502
553
|
/**
|
|
@@ -562,7 +613,7 @@ export interface IRLoop {
|
|
|
562
613
|
* inline via placeholder substitution — see `FlatMapCallback`.
|
|
563
614
|
*/
|
|
564
615
|
method?: 'flatMap'
|
|
565
|
-
array:
|
|
616
|
+
array: JsSourceText
|
|
566
617
|
/**
|
|
567
618
|
* Structured parse of `array` (`parseExpression(array.trim())`), attached
|
|
568
619
|
* during IR construction so adapters lower the loop's array from the tree
|
|
@@ -577,7 +628,7 @@ export interface IRLoop {
|
|
|
577
628
|
itemType: TypeInfo | null
|
|
578
629
|
param: string
|
|
579
630
|
index: string | null
|
|
580
|
-
key:
|
|
631
|
+
key: JsSourceText | null
|
|
581
632
|
children: IRNode[]
|
|
582
633
|
slotId: string | null
|
|
583
634
|
/**
|
|
@@ -1024,7 +1075,7 @@ export interface PreambleValueDeclaration {
|
|
|
1024
1075
|
*/
|
|
1025
1076
|
export interface PreambleRegionSource {
|
|
1026
1077
|
slotId: string
|
|
1027
|
-
expr:
|
|
1078
|
+
expr: JsSourceText
|
|
1028
1079
|
joinArrayChild?: boolean
|
|
1029
1080
|
}
|
|
1030
1081
|
|
|
@@ -1238,7 +1289,7 @@ export interface IRAsync {
|
|
|
1238
1289
|
export interface IRIfStatement {
|
|
1239
1290
|
type: 'if-statement'
|
|
1240
1291
|
/** The condition expression (e.g., "name === 'github'") */
|
|
1241
|
-
condition:
|
|
1292
|
+
condition: JsSourceText
|
|
1242
1293
|
/** Pre-transformed condition with destructured prop refs rewritten to _p.xxx. */
|
|
1243
1294
|
templateCondition?: string
|
|
1244
1295
|
/**
|
|
@@ -1337,10 +1388,10 @@ export interface LiteralAttr {
|
|
|
1337
1388
|
export interface ExpressionAttr {
|
|
1338
1389
|
kind: 'expression'
|
|
1339
1390
|
/** Source-level JS expression text (e.g. `count()`, `props.checked`). */
|
|
1340
|
-
expr:
|
|
1391
|
+
expr: JsSourceText
|
|
1341
1392
|
/** `expr` with destructured prop refs rewritten to `_p.xxx`, for SSR
|
|
1342
1393
|
* template inlining. Absent when no rewrite was needed. */
|
|
1343
|
-
templateExpr?:
|
|
1394
|
+
templateExpr?: JsSourceText
|
|
1344
1395
|
/**
|
|
1345
1396
|
* Structured parse of `expr` (`parseExpression(expr.trim())`), attached
|
|
1346
1397
|
* during IR construction so adapters lower the attribute value from the tree
|
|
@@ -1364,6 +1415,21 @@ export interface ExpressionAttr {
|
|
|
1364
1415
|
* props.
|
|
1365
1416
|
*/
|
|
1366
1417
|
parts?: IRTemplatePart[]
|
|
1418
|
+
/**
|
|
1419
|
+
* The author's source for `expr` with its TypeScript syntax intact
|
|
1420
|
+
* (`store as never`, `value!`, `(v: string) => …`), for adapters that emit
|
|
1421
|
+
* type-checked TSX (`preserveTypes`). Set only when `expr` came from a
|
|
1422
|
+
* type-stripped read of the source and the two texts differ. `forExpr` is
|
|
1423
|
+
* the `expr` it was captured beside: a later rewrite of `expr` makes them
|
|
1424
|
+
* differ, and the adapter then falls back to `expr`.
|
|
1425
|
+
*/
|
|
1426
|
+
typed?: TypedExprSource
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
/** See {@link ExpressionAttr.typed}. */
|
|
1430
|
+
export interface TypedExprSource {
|
|
1431
|
+
tsx: TsxSourceText
|
|
1432
|
+
forExpr: JsSourceText
|
|
1367
1433
|
}
|
|
1368
1434
|
|
|
1369
1435
|
export interface BooleanAttr {
|
|
@@ -1381,7 +1447,7 @@ export interface TemplateAttr {
|
|
|
1381
1447
|
|
|
1382
1448
|
export interface SpreadAttr {
|
|
1383
1449
|
kind: 'spread'
|
|
1384
|
-
expr:
|
|
1450
|
+
expr: JsSourceText
|
|
1385
1451
|
templateExpr?: string
|
|
1386
1452
|
/**
|
|
1387
1453
|
* Structured parse of `expr` (`parseExpression(expr.trim())`), attached
|
|
@@ -1421,7 +1487,12 @@ export const AttrValueOf = {
|
|
|
1421
1487
|
},
|
|
1422
1488
|
expression(
|
|
1423
1489
|
expr: string,
|
|
1424
|
-
opts?: {
|
|
1490
|
+
opts?: {
|
|
1491
|
+
templateExpr?: string
|
|
1492
|
+
presenceOrUndefined?: boolean
|
|
1493
|
+
parts?: IRTemplatePart[]
|
|
1494
|
+
typed?: TypedExprSource
|
|
1495
|
+
},
|
|
1425
1496
|
): ExpressionAttr {
|
|
1426
1497
|
return {
|
|
1427
1498
|
kind: 'expression',
|
|
@@ -1429,6 +1500,7 @@ export const AttrValueOf = {
|
|
|
1429
1500
|
...(opts?.templateExpr !== undefined && { templateExpr: opts.templateExpr }),
|
|
1430
1501
|
...(opts?.presenceOrUndefined !== undefined && { presenceOrUndefined: opts.presenceOrUndefined }),
|
|
1431
1502
|
...(opts?.parts !== undefined && { parts: opts.parts }),
|
|
1503
|
+
...(opts?.typed !== undefined && { typed: opts.typed }),
|
|
1432
1504
|
}
|
|
1433
1505
|
},
|
|
1434
1506
|
booleanAttr(): BooleanAttr {
|
|
@@ -1550,7 +1622,12 @@ export interface IRAttribute extends AttrMeta {
|
|
|
1550
1622
|
export interface IREvent {
|
|
1551
1623
|
name: string // 'click', 'input', 'keydown'
|
|
1552
1624
|
originalAttr?: string // Original JSX attribute name: 'onClick', 'onKeyDown'
|
|
1553
|
-
|
|
1625
|
+
/**
|
|
1626
|
+
* JS expression: '() => setCount(n => n + 1)'. Always a single expression
|
|
1627
|
+
* (a comma sequence arrives parenthesized), passed verbatim as the
|
|
1628
|
+
* listener argument.
|
|
1629
|
+
*/
|
|
1630
|
+
handler: JsSourceText
|
|
1554
1631
|
loc: SourceLocation
|
|
1555
1632
|
}
|
|
1556
1633
|
|
|
@@ -1593,7 +1670,7 @@ export interface SignalPropSeed {
|
|
|
1593
1670
|
export interface SignalInfo {
|
|
1594
1671
|
getter: string
|
|
1595
1672
|
setter: string | null
|
|
1596
|
-
initialValue:
|
|
1673
|
+
initialValue: JsSourceText
|
|
1597
1674
|
/**
|
|
1598
1675
|
* `initialValue` parsed into a structured tree (Roadmap A). Attached
|
|
1599
1676
|
* best-effort by the analyzer so adapters can lower a literal initial value
|
|
@@ -1725,6 +1802,18 @@ export function isElidedFactoryGetter(signal: Pick<SignalInfo, 'factory' | 'gett
|
|
|
1725
1802
|
return Boolean(signal.factory && signal.getterElided)
|
|
1726
1803
|
}
|
|
1727
1804
|
|
|
1805
|
+
/**
|
|
1806
|
+
* Whether a props param binds the component's own `children` prop. Keyed by
|
|
1807
|
+
* the caller-facing key (`sourceName ?? name`), so a binding renamed in the
|
|
1808
|
+
* destructure (`{ children: kids }`) is the children prop exactly as
|
|
1809
|
+
* `{ children }` is (#3572). The one answer for every site that sets the
|
|
1810
|
+
* children prop apart from the data props: it is content the parent
|
|
1811
|
+
* renders, not a reactive value, a client-side prop read or hydration data.
|
|
1812
|
+
*/
|
|
1813
|
+
export function isChildrenPropParam(p: Pick<ParamInfo, 'name' | 'sourceName'>): boolean {
|
|
1814
|
+
return (p.sourceName ?? p.name) === 'children'
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1728
1817
|
/**
|
|
1729
1818
|
* The async reactive factory call a signal's value comes from (#3165). Every
|
|
1730
1819
|
* backend that re-emits the declaration reads this instead of assuming
|
|
@@ -1758,7 +1847,7 @@ export interface SignalFactoryCall {
|
|
|
1758
1847
|
|
|
1759
1848
|
export interface MemoInfo {
|
|
1760
1849
|
name: string
|
|
1761
|
-
computation:
|
|
1850
|
+
computation: JsSourceText
|
|
1762
1851
|
/**
|
|
1763
1852
|
* The expression the memo evaluates to, read from the callback node at
|
|
1764
1853
|
* analysis time (#3510): the body of a zero-parameter arrow or `function`
|
|
@@ -1848,7 +1937,7 @@ export interface MemoInfo {
|
|
|
1848
1937
|
}
|
|
1849
1938
|
|
|
1850
1939
|
export interface EffectInfo {
|
|
1851
|
-
body:
|
|
1940
|
+
body: JsSourceText
|
|
1852
1941
|
deps: string[]
|
|
1853
1942
|
/**
|
|
1854
1943
|
* When set, the effect was captured as `const <captureName> = createEffect(...)`
|
|
@@ -1861,7 +1950,7 @@ export interface EffectInfo {
|
|
|
1861
1950
|
}
|
|
1862
1951
|
|
|
1863
1952
|
export interface OnMountInfo {
|
|
1864
|
-
body:
|
|
1953
|
+
body: JsSourceText
|
|
1865
1954
|
loc: SourceLocation
|
|
1866
1955
|
}
|
|
1867
1956
|
|
|
@@ -1878,7 +1967,7 @@ export interface OnMountInfo {
|
|
|
1878
1967
|
*/
|
|
1879
1968
|
export interface InitStatementInfo {
|
|
1880
1969
|
/** Raw JS source of the statement (TypeScript types already stripped). */
|
|
1881
|
-
body:
|
|
1970
|
+
body: JsSourceText
|
|
1882
1971
|
loc: SourceLocation
|
|
1883
1972
|
/**
|
|
1884
1973
|
* Free identifier references used by this statement. Used by the emitter
|
|
@@ -2061,7 +2150,7 @@ export interface ImportSpecifier {
|
|
|
2061
2150
|
export interface FunctionInfo {
|
|
2062
2151
|
name: string
|
|
2063
2152
|
params: ParamInfo[]
|
|
2064
|
-
body:
|
|
2153
|
+
body: JsSourceText
|
|
2065
2154
|
/** Body with TypeScript type annotations preserved, for .tsx output */
|
|
2066
2155
|
typedBody?: string
|
|
2067
2156
|
/**
|
|
@@ -2120,7 +2209,7 @@ export interface FunctionInfo {
|
|
|
2120
2209
|
|
|
2121
2210
|
export interface ConstantInfo {
|
|
2122
2211
|
name: string
|
|
2123
|
-
value?:
|
|
2212
|
+
value?: JsSourceText
|
|
2124
2213
|
/**
|
|
2125
2214
|
* `value` parsed into a structured tree (Roadmap A). Attached best-effort by
|
|
2126
2215
|
* the analyzer (parsed from the parenthesised value so a bare object literal
|
|
@@ -2216,6 +2305,13 @@ export interface TypeDefinition {
|
|
|
2216
2305
|
* type aliases that aren't object types (e.g. string-literal unions).
|
|
2217
2306
|
*/
|
|
2218
2307
|
properties?: PropertyInfo[]
|
|
2308
|
+
/**
|
|
2309
|
+
* The members of a type alias whose type is a string literal or a union of
|
|
2310
|
+
* string literals only (`type Mode = 'light' | 'dark'`, in any quoting or
|
|
2311
|
+
* layout). Absent for every other definition, a union mixing in a
|
|
2312
|
+
* non-string member included, so adapters need not re-read `definition`.
|
|
2313
|
+
*/
|
|
2314
|
+
stringLiteralUnion?: string[]
|
|
2219
2315
|
loc: SourceLocation
|
|
2220
2316
|
}
|
|
2221
2317
|
|