@barefootjs/jsx 0.41.1 → 0.41.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/adapters/attr-plan.d.ts +8 -0
  2. package/dist/adapters/attr-plan.d.ts.map +1 -1
  3. package/dist/adapters/component-props.d.ts.map +1 -1
  4. package/dist/adapters/computed-const.d.ts +19 -0
  5. package/dist/adapters/computed-const.d.ts.map +1 -1
  6. package/dist/adapters/dsl-template-adapter.d.ts +2 -1
  7. package/dist/adapters/dsl-template-adapter.d.ts.map +1 -1
  8. package/dist/adapters/inherited-const-server-read.d.ts +37 -0
  9. package/dist/adapters/inherited-const-server-read.d.ts.map +1 -0
  10. package/dist/adapters/loop-row-type.d.ts +18 -0
  11. package/dist/adapters/loop-row-type.d.ts.map +1 -1
  12. package/dist/adapters/non-primitive-equality.d.ts +8 -2
  13. package/dist/adapters/non-primitive-equality.d.ts.map +1 -1
  14. package/dist/adapters/unapplied-prop-default.d.ts +34 -0
  15. package/dist/adapters/unapplied-prop-default.d.ts.map +1 -0
  16. package/dist/adapters/uninlinable-seed-call.d.ts +29 -0
  17. package/dist/adapters/uninlinable-seed-call.d.ts.map +1 -0
  18. package/dist/analyzer.d.ts.map +1 -1
  19. package/dist/augment-inherited-props.d.ts +4 -22
  20. package/dist/augment-inherited-props.d.ts.map +1 -1
  21. package/dist/caller-value-reach.d.ts +57 -0
  22. package/dist/caller-value-reach.d.ts.map +1 -0
  23. package/dist/const-identity.d.ts +38 -0
  24. package/dist/const-identity.d.ts.map +1 -0
  25. package/dist/index.d.ts +10 -5
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +2685 -1381
  28. package/dist/ir-to-client-js/child-props-object.d.ts +39 -41
  29. package/dist/ir-to-client-js/child-props-object.d.ts.map +1 -1
  30. package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
  31. package/dist/ir-to-client-js/component-scope.d.ts +13 -2
  32. package/dist/ir-to-client-js/component-scope.d.ts.map +1 -1
  33. package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts.map +1 -1
  34. package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts.map +1 -1
  35. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  36. package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
  37. package/dist/jsx-to-ir.d.ts.map +1 -1
  38. package/dist/local-call-body.d.ts +112 -0
  39. package/dist/local-call-body.d.ts.map +1 -0
  40. package/dist/nullable-signal-attr.d.ts +10 -0
  41. package/dist/nullable-signal-attr.d.ts.map +1 -1
  42. package/dist/prop-default-resolution.d.ts +52 -0
  43. package/dist/prop-default-resolution.d.ts.map +1 -0
  44. package/dist/props-binding.d.ts +15 -0
  45. package/dist/props-binding.d.ts.map +1 -1
  46. package/dist/server-read-walk.d.ts +66 -0
  47. package/dist/server-read-walk.d.ts.map +1 -0
  48. package/dist/ssr-defaults.d.ts.map +1 -1
  49. package/dist/ssr-seed-plan.d.ts +24 -1
  50. package/dist/ssr-seed-plan.d.ts.map +1 -1
  51. package/dist/static-const-member.d.ts +92 -0
  52. package/dist/static-const-member.d.ts.map +1 -0
  53. package/dist/static-literal.d.ts +21 -1
  54. package/dist/static-literal.d.ts.map +1 -1
  55. package/dist/types.d.ts +63 -0
  56. package/dist/types.d.ts.map +1 -1
  57. package/package.json +2 -2
  58. package/src/__tests__/computed-const.test.ts +7 -1
  59. package/src/__tests__/const-identity-child-prop.test.ts +127 -0
  60. package/src/__tests__/inherited-const-server-read.test.ts +116 -0
  61. package/src/__tests__/issue-3688-props-spread-child-csr.test.ts +8 -3
  62. package/src/__tests__/issue-3714-open-rest-spread-child.test.ts +188 -0
  63. package/src/__tests__/local-call-body.test.ts +101 -0
  64. package/src/__tests__/loop-branch-bare-expression-reactive-text.test.ts +212 -56
  65. package/src/__tests__/nested-loop-conditional.test.ts +16 -16
  66. package/src/__tests__/prop-default-resolution.test.ts +185 -0
  67. package/src/__tests__/props-spread-shadowed.test.ts +113 -0
  68. package/src/__tests__/server-read-walk.test.ts +125 -0
  69. package/src/__tests__/ssr-defaults.test.ts +67 -7
  70. package/src/__tests__/static-literal.test.ts +47 -2
  71. package/src/__tests__/static-record-literal-array.test.ts +82 -11
  72. package/src/adapters/attr-plan.ts +12 -1
  73. package/src/adapters/component-props.ts +2 -1
  74. package/src/adapters/computed-const.ts +108 -12
  75. package/src/adapters/dsl-template-adapter.ts +17 -4
  76. package/src/adapters/inherited-const-server-read.ts +174 -0
  77. package/src/adapters/loop-row-type.ts +69 -2
  78. package/src/adapters/non-primitive-equality.ts +17 -2
  79. package/src/adapters/unapplied-prop-default.ts +83 -0
  80. package/src/adapters/uninlinable-seed-call.ts +62 -0
  81. package/src/analyzer.ts +43 -3
  82. package/src/augment-inherited-props.ts +4 -49
  83. package/src/caller-value-reach.ts +436 -0
  84. package/src/compiler.ts +4 -4
  85. package/src/const-identity.ts +189 -0
  86. package/src/index.ts +10 -5
  87. package/src/ir-to-client-js/child-props-object.ts +94 -62
  88. package/src/ir-to-client-js/collect-elements.ts +53 -68
  89. package/src/ir-to-client-js/component-scope.ts +16 -2
  90. package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +1 -0
  91. package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +1 -0
  92. package/src/ir-to-client-js/html-template.ts +24 -4
  93. package/src/ir-to-client-js/index.ts +2 -2
  94. package/src/ir-to-client-js/prop-handling.ts +4 -0
  95. package/src/jsx-to-ir.ts +40 -2
  96. package/src/local-call-body.ts +191 -0
  97. package/src/nullable-signal-attr.ts +39 -17
  98. package/src/prop-default-resolution.ts +195 -0
  99. package/src/props-binding.ts +16 -0
  100. package/src/server-read-walk.ts +174 -0
  101. package/src/ssr-defaults.ts +93 -10
  102. package/src/ssr-seed-plan.ts +104 -18
  103. package/src/static-const-member.ts +243 -0
  104. package/src/static-literal.ts +55 -1
  105. package/src/types.ts +63 -1
@@ -0,0 +1,243 @@
1
+ /**
2
+ * What a read of a literal const's member (`QS[0]`, `QS[9]`, `REC['k']`,
3
+ * `NEST.a.c`) sees, decided from the const's parsed literal value — the ONE
4
+ * decision behind every template adapter's compile-time member lookup of a
5
+ * module or component-local array / object literal const.
6
+ *
7
+ * The template receives the props, not the module's consts, so a read the
8
+ * lookup does not answer falls back to a lowering that reads the const as a
9
+ * template variable. That variable does not exist: some engines render it
10
+ * empty by accident, others fail the render (Perl `strict`, Go's field
11
+ * lookup). So a key the literal provably lacks is answered here too, as
12
+ * `undefined`, which every emitter already spells. A key the literal lacks
13
+ * but its prototype has (`REC['toString']`, `QS['map']`) reads a function
14
+ * in JS, which no template can render; that read is `inherited`, and
15
+ * `spellStaticConstMember` refuses it with BF101 where the adapter spells
16
+ * it; `refuseInheritedConstServerReads` does for a value the server render
17
+ * computes without an emitter.
18
+ */
19
+
20
+ import { resolveStaticConstBinding } from './augment-inherited-props.ts'
21
+ import { exprToString, type ObjectLiteralProperty, type ParsedExpr } from './expression-parser.ts'
22
+ import { literalMemberIndex } from './literal-member-index.ts'
23
+ import type { CompilerError, IRMetadata, SourceLocation } from './types.ts'
24
+
25
+ type StaticConstants = IRMetadata['localConstants'] | undefined
26
+
27
+ /**
28
+ * A literal const member read:
29
+ *
30
+ * - `value`: the read's value as a typed `ParsedExpr` — a string or number
31
+ * `literal`, a unary `-` over a number literal, or the identifier
32
+ * `undefined` for a key the literal provably lacks;
33
+ * - `inherited`: a key only the prototype has (a function in JS).
34
+ *
35
+ * `null` when the read is not a member of a literal const, or the literal
36
+ * cannot answer it (a hole or spread before the element, a non-literal
37
+ * value, an `__proto__` key); the caller falls back to its generic lowering.
38
+ */
39
+ export type StaticConstMemberRead =
40
+ | { kind: 'value'; expr: ParsedExpr }
41
+ | { kind: 'inherited'; key: string }
42
+
43
+ const UNDEFINED_EXPR: ParsedExpr = { kind: 'identifier', name: 'undefined' }
44
+
45
+ /** The literal key of an index (`QS[-1]`, `QS[-0]`), as JS converts it to a property key. */
46
+ export function staticIndexKey(index: ParsedExpr): string | null {
47
+ if (index.kind === 'literal' && (index.literalType === 'string' || index.literalType === 'number')) {
48
+ return String(index.value)
49
+ }
50
+ if (
51
+ index.kind === 'unary' && index.op === '-' &&
52
+ index.argument.kind === 'literal' && index.argument.literalType === 'number' &&
53
+ typeof index.argument.value === 'number'
54
+ ) {
55
+ return String(-index.argument.value)
56
+ }
57
+ return null
58
+ }
59
+
60
+ /**
61
+ * Read `key` of `object`, where `object` is a literal const (`QS`) or a
62
+ * literal-valued member of one (`NEST.a`). `isShadowed` is REQUIRED for the
63
+ * same reason as in `lookupStaticRecordLiteral`.
64
+ */
65
+ export function readStaticConstMember(
66
+ object: ParsedExpr,
67
+ key: string,
68
+ constants: StaticConstants,
69
+ isShadowed: (name: string) => boolean,
70
+ ): StaticConstMemberRead | null {
71
+ const receiver = staticLiteralValue(object, constants, isShadowed)
72
+ if (receiver === null) return null
73
+ const read = readLiteralMember(receiver, key)
74
+ if (read === null || read.kind === 'inherited') return read
75
+ return isRenderableScalar(read.expr) ? read : null
76
+ }
77
+
78
+ /**
79
+ * The value of a literal const member read, or `null` when the read has no
80
+ * compile-time value (including an `inherited` read, refused separately).
81
+ */
82
+ export function lookupStaticConstMember(
83
+ object: ParsedExpr,
84
+ key: string,
85
+ constants: StaticConstants,
86
+ isShadowed: (name: string) => boolean,
87
+ ): ParsedExpr | null {
88
+ const read = readStaticConstMember(object, key, constants, isShadowed)
89
+ return read?.kind === 'value' ? read.expr : null
90
+ }
91
+
92
+ /** The place of an `inherited` read, as far as the caller of `spellStaticConstMember` knows it. */
93
+ export interface InheritedReadPlace {
94
+ loc: SourceLocation
95
+ /** `false` when `/* @client *\/` cannot defer the read. */
96
+ deferrable?: boolean
97
+ }
98
+
99
+ /** Where a template adapter records the refusal of an `inherited` read. */
100
+ export interface StaticConstMemberSink {
101
+ readonly errors: CompilerError[]
102
+ readonly componentName: string
103
+ }
104
+
105
+ /**
106
+ * The value a template adapter spells for a literal const member read it is
107
+ * emitting, as `lookupStaticConstMember`; and, for a key only the literal's
108
+ * prototype has (`REC['toString']`, `QS['map']`), BF101 recorded in `sink`.
109
+ * Every template adapter's member and index emitters (value, condition and
110
+ * child-prop position, and a constant or function body the adapter inlines)
111
+ * read through this, so the refusal fires exactly where a template would
112
+ * spell the read: a position deferred with `/* @client *\/`, a method the
113
+ * template never renders, or a name a binding shadows never reaches it.
114
+ * `where` is what the caller knows about the read's place: its location,
115
+ * and whether `/* @client *\/` can defer it (a child component's prop
116
+ * cannot be: the component renders on the server either way).
117
+ */
118
+ export function spellStaticConstMember(
119
+ object: ParsedExpr,
120
+ key: string,
121
+ constants: StaticConstants,
122
+ isShadowed: (name: string) => boolean,
123
+ sink: StaticConstMemberSink,
124
+ where?: InheritedReadPlace,
125
+ ): ParsedExpr | null {
126
+ const read = readStaticConstMember(object, key, constants, isShadowed)
127
+ if (read?.kind === 'inherited') {
128
+ recordInheritedRead(exprToString({ kind: 'member', object, property: key, computed: false, optional: false }), sink, where)
129
+ return null
130
+ }
131
+ return read?.kind === 'value' ? read.expr : null
132
+ }
133
+
134
+ function recordInheritedRead(read: string, sink: StaticConstMemberSink, where: InheritedReadPlace | undefined): void {
135
+ const message =
136
+ `\`${read}\` reads a key the const's literal value does not have but its prototype does, so JS reads an inherited ` +
137
+ 'function there. A template holds the literal value without a prototype, so the server render cannot give the JS answer.'
138
+ if (sink.errors.some(e => e.code === 'BF101' && e.message === message)) return
139
+ sink.errors.push({
140
+ code: 'BF101',
141
+ severity: 'error',
142
+ message,
143
+ loc: where?.loc ?? { file: `${sink.componentName}.tsx`, start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
144
+ suggestion: where?.deferrable === false
145
+ ? { message: 'Read a key the literal lists.' }
146
+ : {
147
+ message: 'Read a key the literal lists, or defer the read to the client with /* @client */.',
148
+ escape: [{ kind: 'client-directive' }],
149
+ },
150
+ })
151
+ }
152
+
153
+ /**
154
+ * The expression a literal const, or a member of one read by literal keys
155
+ * (`H.get`, `NEST.a[0]`), holds: whatever the literal lists there, a
156
+ * function included. `null` when no literal const answers the read.
157
+ */
158
+ export function staticConstValue(
159
+ expr: ParsedExpr,
160
+ constants: StaticConstants,
161
+ isShadowed: (name: string) => boolean,
162
+ ): ParsedExpr | null {
163
+ return staticLiteralValue(expr, constants, isShadowed)
164
+ }
165
+
166
+ /** The literal (array / object / scalar) `expr` evaluates to, read through literal consts. */
167
+ function staticLiteralValue(
168
+ expr: ParsedExpr,
169
+ constants: StaticConstants,
170
+ isShadowed: (name: string) => boolean,
171
+ ): ParsedExpr | null {
172
+ if (expr.kind === 'identifier') {
173
+ const value = resolveStaticConstBinding(expr.name, constants, isShadowed)?.parsed
174
+ return value?.kind === 'array-literal' || value?.kind === 'object-literal' ? value : null
175
+ }
176
+ const key = expr.kind === 'member' ? expr.property : expr.kind === 'index-access' ? staticIndexKey(expr.index) : null
177
+ if (key === null || (expr.kind !== 'member' && expr.kind !== 'index-access')) return null
178
+ const receiver = staticLiteralValue(expr.object, constants, isShadowed)
179
+ if (receiver === null) return null
180
+ const read = readLiteralMember(receiver, key)
181
+ return read?.kind === 'value' ? read.expr : null
182
+ }
183
+
184
+ /**
185
+ * `key` of an array or object literal: its value, `undefined` for a key it
186
+ * provably lacks, `inherited` for a key only its prototype has, or `null`
187
+ * when the literal cannot answer.
188
+ */
189
+ export function readLiteralMember(receiver: ParsedExpr, key: string): StaticConstMemberRead | null {
190
+ if (receiver.kind === 'array-literal') return readArrayMember(receiver.elements, key)
191
+ if (receiver.kind === 'object-literal') return readObjectMember(receiver.properties, key)
192
+ return null
193
+ }
194
+
195
+ /**
196
+ * An array literal's `length`, element, or missing key. A hole or spread
197
+ * (`unsupported`) at or before an index makes the element unknown, and
198
+ * anywhere makes the length (so whether an index is past the end) unknown.
199
+ */
200
+ function readArrayMember(elements: readonly ParsedExpr[], key: string): StaticConstMemberRead | null {
201
+ const unknownAt = elements.findIndex(e => e.kind === 'unsupported')
202
+ if (key === 'length') {
203
+ return unknownAt >= 0 ? null : { kind: 'value', expr: numberLiteral(elements.length) }
204
+ }
205
+ const index = literalMemberIndex(key)
206
+ if (index.kind === 'literal' && typeof index.value === 'number') {
207
+ if (unknownAt >= 0 && unknownAt <= index.value) return null
208
+ if (index.value < elements.length) return { kind: 'value', expr: elements[index.value] }
209
+ return unknownAt >= 0 ? null : { kind: 'value', expr: UNDEFINED_EXPR }
210
+ }
211
+ // Not an array index (`'01'`, `'-1'`, `'foo'`): no element holds it, and a
212
+ // spread or hole adds none.
213
+ if (key in Array.prototype) return { kind: 'inherited', key }
214
+ return { kind: 'value', expr: UNDEFINED_EXPR }
215
+ }
216
+
217
+ /**
218
+ * An object literal's own key, or a key it provably lacks. A spread may
219
+ * bring any key, and an `__proto__` entry sets the prototype instead of a
220
+ * key, so either makes a missing key unknown. A later entry of the same key
221
+ * overrides an earlier one.
222
+ */
223
+ function readObjectMember(properties: readonly ObjectLiteralProperty[], key: string): StaticConstMemberRead | null {
224
+ if (properties.some(p => p.kind === 'spread' || p.key === '__proto__')) return null
225
+ const own = properties.filter(p => p.kind === 'prop' && p.key === key).at(-1)
226
+ if (own?.kind === 'prop') return { kind: 'value', expr: own.value }
227
+ if (key in Object.prototype) return { kind: 'inherited', key }
228
+ return { kind: 'value', expr: UNDEFINED_EXPR }
229
+ }
230
+
231
+ /** A value every template emitter spells as the source would: a string or number, or `undefined`. */
232
+ function isRenderableScalar(expr: ParsedExpr): boolean {
233
+ if (expr.kind === 'identifier') return expr.name === 'undefined'
234
+ if (expr.kind === 'literal') return expr.literalType === 'string' || expr.literalType === 'number'
235
+ return (
236
+ expr.kind === 'unary' && expr.op === '-' &&
237
+ expr.argument.kind === 'literal' && expr.argument.literalType === 'number'
238
+ )
239
+ }
240
+
241
+ function numberLiteral(value: number): ParsedExpr {
242
+ return { kind: 'literal', value, literalType: 'number', raw: String(value) }
243
+ }
@@ -15,7 +15,7 @@
15
15
  * (`packages/adapter-<name>/src/adapter/lib/static-value.ts`).
16
16
  */
17
17
 
18
- import type { ParsedExpr } from './expression-parser.ts'
18
+ import { freeIdentifiers, mapParsedExpr, type ParsedExpr } from './expression-parser.ts'
19
19
  import type { ConstantInfo } from './types.ts'
20
20
 
21
21
  /**
@@ -109,6 +109,60 @@ export function evaluateStaticLiteral(
109
109
  }
110
110
  }
111
111
 
112
+ /**
113
+ * The expression a compile-time-unrolled loop row lowers, with every part
114
+ * that reads the row replaced by its value (#3798). `bindings` maps the
115
+ * unrolled loop parameters (outer to inner) to the row values the caller
116
+ * already resolved. Each maximal subtree that reads a bound name and
117
+ * evaluates ({@link evaluateStaticLiteral}) to a scalar becomes a `literal`
118
+ * node: `q` becomes `'x'` and `item.label` the label. A template literal keeps
119
+ * its shape and folds the parts inside its `${}`.
120
+ * The rest of the tree is left as is, so a backend lowers it through its
121
+ * ordinary path: `q === 'x' ? props.label : '0'` becomes
122
+ * `'x' === 'x' ? props.label : '0'`, which reads the component's own
123
+ * scope as it does outside a loop.
124
+ *
125
+ * Returns `null` when a bound name remains in the result: a row value that
126
+ * is not a scalar (an object read by something other than a static member
127
+ * chain), or a bound name the evaluator cannot resolve. The caller refuses
128
+ * rather than lower a name that has no `{{range}}` behind it. An arrow
129
+ * parameter named like a bound name shadows it.
130
+ */
131
+ export function foldStaticBindings(
132
+ expr: ParsedExpr,
133
+ bindings: ReadonlyMap<string, unknown>,
134
+ ): ParsedExpr | null {
135
+ if (bindings.size === 0) return expr
136
+ const folded = mapParsedExpr(expr, (e, enclosing) => {
137
+ // A template literal keeps its node (only its `${}` parts fold): a
138
+ // backend lowers it to text interleaved with actions, not to one value.
139
+ if (e.kind === 'literal' || e.kind === 'unsupported' || e.kind === 'template-literal') return null
140
+ const visible = new Map([...bindings].filter(([name]) => !enclosing.has(name)))
141
+ const free = freeIdentifiers(e)
142
+ if (free === null || ![...free].some(name => visible.has(name))) return null
143
+ const resolved = evaluateStaticLiteral(e, visible)
144
+ return resolved === null ? null : scalarToLiteral(resolved.value)
145
+ })
146
+ const remaining = freeIdentifiers(folded)
147
+ if (remaining === null || [...remaining].some(name => bindings.has(name))) return null
148
+ return folded
149
+ }
150
+
151
+ /** A string, number, boolean or `null` value as a `literal` node, or `null` for anything else (an absent member reads `undefined`, which a backend lowers differently, so it is refused). */
152
+ function scalarToLiteral(value: unknown): ParsedExpr | null {
153
+ if (value === null) return { kind: 'literal', value: null, literalType: 'null' }
154
+ switch (typeof value) {
155
+ case 'string':
156
+ return { kind: 'literal', value, literalType: 'string' }
157
+ case 'boolean':
158
+ return { kind: 'literal', value, literalType: 'boolean' }
159
+ case 'number':
160
+ return Number.isFinite(value) ? { kind: 'literal', value, literalType: 'number' } : null
161
+ default:
162
+ return null
163
+ }
164
+ }
165
+
112
166
  /** `true` iff {@link evaluateStaticLiteral} resolves `expr` with no bindings. */
113
167
  export function isFullyStaticLiteral(expr: ParsedExpr): boolean {
114
168
  return evaluateStaticLiteral(expr) !== null
package/src/types.ts CHANGED
@@ -562,6 +562,23 @@ export interface IRExpression {
562
562
  * is never flagged and stays escaped text.
563
563
  */
564
564
  loopRowPropRead?: true
565
+ /**
566
+ * Set on a conditional branch that contains a call and reads a value the
567
+ * component's caller supplied that may be, or may build, a live element:
568
+ * anything reached from the props other than a prop whose declared type
569
+ * holds data only (`caller-value-reach.ts` has the full rule). The read
570
+ * can be the callee (`props.renderNode(n)`, `props['renderNode'](n)`), an
571
+ * argument (`apply(props.renderNode, n)`), or a component declaration
572
+ * that reads one (`const draw = n => props.renderNode(n)`). Decided once
573
+ * in Phase 1 from the component's own declarations and the props type.
574
+ *
575
+ * Such a branch may hold an element the caller built
576
+ * (`renderNode={(n) => <Pill id={n.id} />}`), which owns its own state.
577
+ * A loop row keeps the element it got when the branch was mounted rather
578
+ * than evaluating the branch again each time the row's item changes, so
579
+ * the client gives this branch no update effect.
580
+ */
581
+ readsCallerValue?: true
565
582
  /** When true, expression calls signal getters or memos (has reactive `foo()` pattern). */
566
583
  callsReactiveGetters?: boolean
567
584
  /** When true, expression contains function call(s) — any `identifier()` pattern (computed from AST). */
@@ -1390,7 +1407,7 @@ export interface IRIfStatement {
1390
1407
  export type IRTemplatePart =
1391
1408
  | { type: 'string'; value: string }
1392
1409
  | { type: 'expression'; expr: JsSourceText; templateExpr?: JsSourceText; parsed: ParsedExpr }
1393
- | { type: 'ternary'; condition: string; templateCondition?: string; whenTrue: string; whenFalse: string }
1410
+ | { type: 'ternary'; condition: string; templateCondition?: string; parsedCondition?: ParsedExpr; whenTrue: string; whenFalse: string }
1394
1411
  /**
1395
1412
  * `${MAP[KEY]}` indexed lookup against a `Record<T, string>` literal
1396
1413
  * (e.g. `${variantClasses[variant]}` where `variantClasses` is a
@@ -1562,6 +1579,26 @@ export interface SpreadAttr {
1562
1579
  * carry the caller's whole bag (`ClientAnalysis.readsCallerBag`, #3845).
1563
1580
  */
1564
1581
  callerBag?: 'props' | 'rest'
1582
+ /**
1583
+ * The caller keys a `callerBag: 'rest'` spread leaves out: the keys the
1584
+ * component destructured before the rest element, as the caller spells
1585
+ * them (`{ title: t, ...rest }` omits `title`), from the signature or
1586
+ * from a body destructure of the props object (`restBagOmittedKeys`).
1587
+ * The client holds the rest bag as the caller's whole props object
1588
+ * (`_p`), so every reader of the bag (the child props object, the
1589
+ * registration template, `applyRestAttrs`) takes these keys out
1590
+ * (#3714). Set exactly when `callerBag` is `'rest'`.
1591
+ */
1592
+ restOmittedKeys?: readonly string[]
1593
+ /**
1594
+ * Set when the spread's identifier is spelled like the component's props
1595
+ * object but a loop row, callback parameter, destructured field or
1596
+ * preamble local binds that name at the spread (`rows.map((props) => <li
1597
+ * {...props} />)`, #3727). It spreads that binding, not the props object, so
1598
+ * `spreadsPropsObject` is false for it. Decided once in Phase 1; unset for
1599
+ * every other spread.
1600
+ */
1601
+ shadowsPropsObject?: true
1565
1602
  }
1566
1603
 
1567
1604
  export interface JsxChildrenAttr {
@@ -2298,6 +2335,20 @@ export interface FunctionInfo {
2298
2335
  freeIdentifiers?: ReadonlySet<string>
2299
2336
  /** When true, declared at module level (outside the component function). */
2300
2337
  isModule?: boolean
2338
+ /**
2339
+ * When true, the declaration sits inside the component function's body. A
2340
+ * `function` declaration there is collected with `isModule` set too (the
2341
+ * module walk is the one that reaches it, and client-JS scope placement
2342
+ * demotes it later), so this is what says where its body's names resolve.
2343
+ */
2344
+ inComponentBody?: boolean
2345
+ /**
2346
+ * What a call with no arguments returns, for a function that takes no
2347
+ * parameters and whose body is a single `return <expr>`: the returned
2348
+ * expression's tree. A template inlines such a call (`value()` → `1`)
2349
+ * where it reads the function (`localCallBodies`).
2350
+ */
2351
+ returnParsed?: ParsedExpr
2301
2352
  /** When true, this function returns JSX and is inlined at call sites (#569). */
2302
2353
  isJsxFunction?: boolean
2303
2354
  /**
@@ -2388,6 +2439,17 @@ export interface ConstantInfo {
2388
2439
  * was supposed to do.
2389
2440
  */
2390
2441
  mutatedAfterDeclaration?: boolean
2442
+ /**
2443
+ * When true, the initializer creates a new value each time it is evaluated
2444
+ * (an object or array literal, `new X()`, a call, a function expression)
2445
+ * and reads nothing reactive (no signal, memo, prop or `Reactive<T>`
2446
+ * brand), so every read must see the one value the declaration created. A
2447
+ * read site references the binding; it never re-evaluates the initializer
2448
+ * in its place, which would hand each read a different object (#3868).
2449
+ * Set by `markIdentityBoundConstants` (`const-identity.ts`). Consumed by
2450
+ * `expandDynamicPropValue`, which builds a child component's prop getters.
2451
+ */
2452
+ identityBound?: boolean
2391
2453
  /**
2392
2454
  * When true, this module-level const is shadowed inside the component: a
2393
2455
  * destructured prop, the props object, or a component-scope const,