@barefootjs/jsx 0.35.5 → 0.35.6

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 (102) hide show
  1. package/dist/analyzer-context.d.ts +5 -4
  2. package/dist/analyzer-context.d.ts.map +1 -1
  3. package/dist/analyzer.d.ts.map +1 -1
  4. package/dist/errors.d.ts +0 -1
  5. package/dist/errors.d.ts.map +1 -1
  6. package/dist/index.js +6711 -6471
  7. package/dist/ir-to-client-js/compute-prop-usage.d.ts +6 -0
  8. package/dist/ir-to-client-js/compute-prop-usage.d.ts.map +1 -1
  9. package/dist/ir-to-client-js/control-flow/plan/build-event-delegation.d.ts +3 -2
  10. package/dist/ir-to-client-js/control-flow/plan/build-event-delegation.d.ts.map +1 -1
  11. package/dist/ir-to-client-js/control-flow/plan/build-loop.d.ts +12 -2
  12. package/dist/ir-to-client-js/control-flow/plan/build-loop.d.ts.map +1 -1
  13. package/dist/ir-to-client-js/control-flow/plan/event-collision.d.ts +40 -0
  14. package/dist/ir-to-client-js/control-flow/plan/event-collision.d.ts.map +1 -0
  15. package/dist/ir-to-client-js/control-flow/plan/event-delegation.d.ts +13 -0
  16. package/dist/ir-to-client-js/control-flow/plan/event-delegation.d.ts.map +1 -1
  17. package/dist/ir-to-client-js/control-flow/plan/loop-delegation-index.d.ts +45 -0
  18. package/dist/ir-to-client-js/control-flow/plan/loop-delegation-index.d.ts.map +1 -0
  19. package/dist/ir-to-client-js/control-flow/plan/types.d.ts +2 -0
  20. package/dist/ir-to-client-js/control-flow/plan/types.d.ts.map +1 -1
  21. package/dist/ir-to-client-js/control-flow/stringify/event-delegation.d.ts +12 -0
  22. package/dist/ir-to-client-js/control-flow/stringify/event-delegation.d.ts.map +1 -1
  23. package/dist/ir-to-client-js/control-flow.d.ts +2 -1
  24. package/dist/ir-to-client-js/control-flow.d.ts.map +1 -1
  25. package/dist/ir-to-client-js/emit-reactive.d.ts +7 -3
  26. package/dist/ir-to-client-js/emit-reactive.d.ts.map +1 -1
  27. package/dist/ir-to-client-js/generate-init.d.ts.map +1 -1
  28. package/dist/ir-to-client-js/index.d.ts +1 -0
  29. package/dist/ir-to-client-js/index.d.ts.map +1 -1
  30. package/dist/ir-to-client-js/phases/event-handlers.d.ts +9 -1
  31. package/dist/ir-to-client-js/phases/event-handlers.d.ts.map +1 -1
  32. package/dist/ir-to-client-js/phases/props-event-handlers.d.ts +5 -0
  33. package/dist/ir-to-client-js/phases/props-event-handlers.d.ts.map +1 -1
  34. package/dist/ir-to-client-js/phases/props-extraction.d.ts +15 -13
  35. package/dist/ir-to-client-js/phases/props-extraction.d.ts.map +1 -1
  36. package/dist/ir-to-client-js/phases.d.ts +12 -1
  37. package/dist/ir-to-client-js/phases.d.ts.map +1 -1
  38. package/dist/ir-to-client-js/plan/build-declaration-emit.d.ts.map +1 -1
  39. package/dist/ir-to-client-js/prune-unused-prop-extractions.d.ts +50 -0
  40. package/dist/ir-to-client-js/prune-unused-prop-extractions.d.ts.map +1 -1
  41. package/dist/ir-to-client-js/rewrite-destructured-props.d.ts +29 -0
  42. package/dist/ir-to-client-js/rewrite-destructured-props.d.ts.map +1 -0
  43. package/dist/ir-to-client-js/utils.d.ts +9 -0
  44. package/dist/ir-to-client-js/utils.d.ts.map +1 -1
  45. package/dist/jsx-to-ir.d.ts.map +1 -1
  46. package/dist/prop-rewrite.d.ts.map +1 -1
  47. package/dist/props-binding.d.ts +112 -1
  48. package/dist/props-binding.d.ts.map +1 -1
  49. package/dist/ssr-defaults.d.ts.map +1 -1
  50. package/dist/static-literal.d.ts +20 -8
  51. package/dist/static-literal.d.ts.map +1 -1
  52. package/dist/types.d.ts +7 -0
  53. package/dist/types.d.ts.map +1 -1
  54. package/package.json +2 -2
  55. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +31 -35
  56. package/src/__tests__/aliased-destructured-prop-csr.test.ts +19 -7
  57. package/src/__tests__/body-destructured-prop-default-propsparams.test.ts +153 -0
  58. package/src/__tests__/body-destructured-props-live.test.ts +245 -0
  59. package/src/__tests__/client-js-generation.test.ts +11 -4
  60. package/src/__tests__/client-only-date-lowering.test.ts +5 -2
  61. package/src/__tests__/destructured-from-props-localconst-value.test.ts +17 -6
  62. package/src/__tests__/destructured-props-live.test.ts +167 -0
  63. package/src/__tests__/doc-examples.test.ts +2 -4
  64. package/src/__tests__/event-delegation-container-collision-2930.test.ts +197 -0
  65. package/src/__tests__/format-error.test.ts +5 -3
  66. package/src/__tests__/live-only-props.test.ts +160 -0
  67. package/src/__tests__/prop-references.test.ts +26 -17
  68. package/src/__tests__/props-destructuring.test.ts +6 -275
  69. package/src/__tests__/prune-unused-prop-extractions.test.ts +11 -5
  70. package/src/__tests__/signal-getter-not-called.test.ts +5 -0
  71. package/src/__tests__/ssr-defaults.test.ts +83 -0
  72. package/src/__tests__/staged-ir/02-shadow-guards.test.ts +12 -5
  73. package/src/__tests__/static-literal.test.ts +39 -4
  74. package/src/analyzer-context.ts +8 -7
  75. package/src/analyzer.ts +76 -84
  76. package/src/errors.ts +7 -8
  77. package/src/ir-to-client-js/compute-prop-usage.ts +19 -0
  78. package/src/ir-to-client-js/control-flow/plan/build-event-delegation.ts +5 -0
  79. package/src/ir-to-client-js/control-flow/plan/build-loop.ts +27 -11
  80. package/src/ir-to-client-js/control-flow/plan/event-collision.ts +55 -0
  81. package/src/ir-to-client-js/control-flow/plan/event-delegation.ts +13 -0
  82. package/src/ir-to-client-js/control-flow/plan/loop-delegation-index.ts +79 -0
  83. package/src/ir-to-client-js/control-flow/plan/types.ts +2 -0
  84. package/src/ir-to-client-js/control-flow/stringify/event-delegation.ts +50 -10
  85. package/src/ir-to-client-js/control-flow.ts +68 -31
  86. package/src/ir-to-client-js/emit-reactive.ts +12 -8
  87. package/src/ir-to-client-js/generate-init.ts +6 -0
  88. package/src/ir-to-client-js/index.ts +45 -3
  89. package/src/ir-to-client-js/phases/event-handlers.ts +10 -0
  90. package/src/ir-to-client-js/phases/props-event-handlers.ts +6 -0
  91. package/src/ir-to-client-js/phases/props-extraction.ts +29 -48
  92. package/src/ir-to-client-js/phases.ts +17 -3
  93. package/src/ir-to-client-js/plan/build-declaration-emit.ts +6 -5
  94. package/src/ir-to-client-js/prune-unused-prop-extractions.ts +31 -10
  95. package/src/ir-to-client-js/rewrite-destructured-props.ts +210 -0
  96. package/src/ir-to-client-js/utils.ts +14 -0
  97. package/src/jsx-to-ir.ts +96 -48
  98. package/src/prop-rewrite.ts +11 -0
  99. package/src/props-binding.ts +171 -6
  100. package/src/ssr-defaults.ts +10 -5
  101. package/src/static-literal.ts +21 -9
  102. package/src/types.ts +7 -0
@@ -1,5 +1,8 @@
1
1
  import ts from 'typescript'
2
- import type { ConstantInfo, ParamInfo } from './types.ts'
2
+ import type { ConstantInfo, ParamInfo, PropUsage } from './types.ts'
3
+ import { propHasPropertyAccess } from './ir-to-client-js/compute-prop-usage.ts'
4
+ import { parsePropReadInitializer } from './ir-to-client-js/prune-unused-prop-extractions.ts'
5
+ import { PROPS_PARAM } from './ir-to-client-js/utils.ts'
3
6
 
4
7
  /**
5
8
  * Authoritative IdentifierName classification for a destructure-pattern
@@ -88,19 +91,117 @@ export function buildPropAliasMap(params: readonly ParamInfo[]): Map<string, str
88
91
  * Returns an empty map for a parameter-destructuring component
89
92
  * (`propsObjectName === null`) — that shape's aliasing is already fully
90
93
  * covered by `buildPropAliasMap`.
94
+ *
95
+ * Passes `requireLiveRewriteSafe: false` to `resolveBodyPropAliases` — this
96
+ * consumer only needs the local-name↔caller-key mapping to seed the SSR
97
+ * stash under the local's name (#2788), which is sound regardless of
98
+ * `const`/`let` or a later mutation: those two exclusions exist solely to
99
+ * protect the LIVE client-JS rewrite (`rewriteBodyAliasReads`) from turning
100
+ * a reassignment into a silent write-through to the caller's prop, a
101
+ * concern this SSR-side, declaration-time alias mapping doesn't share. A
102
+ * `let`-declared renamed body destructure (`let { children: kids } =
103
+ * props`) is exactly as valid an alias for stash-seeding purposes as a
104
+ * `const` one — inheriting the stricter filter here would silently drop
105
+ * its stash entry and reintroduce #2788 for that one shape.
91
106
  */
92
107
  export function resolveBodyDestructuredPropAliases(
93
108
  localConstants: readonly ConstantInfo[],
94
109
  propsObjectName: string | null,
95
110
  ): Map<string, string> {
96
111
  const aliases = new Map<string, string>()
112
+ for (const [local, alias] of resolveBodyPropAliases(localConstants, propsObjectName, { requireLiveRewriteSafe: false })) {
113
+ if (!alias.hasDefault) aliases.set(local, alias.key)
114
+ }
115
+ return aliases
116
+ }
117
+
118
+ /**
119
+ * A local `const`/`let` in a bare-props-form component (`function
120
+ * Foo(props: Props)`) whose value is a PURE alias of a single caller-facing
121
+ * prop — either a body destructure (`const { value } = props`, `const {
122
+ * label = 'none' } = props`) or an equivalent bare member read (`const label
123
+ * = props.label ?? 'fallback'`); the analyzer's IR can't distinguish the two
124
+ * shapes (both parse to the same `ConstantInfo`), and neither can this
125
+ * resolver — see `resolveBodyAliasReads`'s (`rewrite-destructured-props.ts`)
126
+ * docstring for why that's the right call.
127
+ */
128
+ export interface BodyPropAlias {
129
+ /** Caller-facing prop key (`props.<key>`). */
130
+ key: string
131
+ /** Whether the value has a `?? <default>` (destructure default, or an
132
+ * explicit `props.x ?? d` alias) — `resolveBodyDestructuredPropAliases`
133
+ * excludes these; `resolveBodyAliasReads` handles them itself. */
134
+ hasDefault: boolean
135
+ /** When true, the default value contains an arrow function or function
136
+ * expression — mirrors `ParamInfo.defaultContainsArrow`. `hasDefault`'s
137
+ * own source text is NOT carried here (unlike `defaultContainsArrow`):
138
+ * `rewriteBodyAliasReads` re-derives it from the emitted init body's own
139
+ * declaration rather than from this alias (see its docstring), and the
140
+ * only OTHER consumer that once read a `defaultValue` field here — the
141
+ * `jsx-to-ir.ts` CSR-template overlay — is gone since #2943 folded the
142
+ * default straight onto `ParamInfo.defaultValue` at the analyzer level. */
143
+ defaultContainsArrow?: boolean
144
+ }
145
+
146
+ /**
147
+ * Local-name → alias-info map for every PURE prop-passthrough local in a
148
+ * bare-props-form component — the superset `resolveBodyDestructuredPropAliases`
149
+ * (defaultless only, for the SSR-stash use above) and `resolveBodyAliasReads`
150
+ * (`rewrite-destructured-props.ts`, live-read rewrite including defaults)
151
+ * both build on.
152
+ *
153
+ * Excludes:
154
+ * - `propsObjectName === null` (parameter-destructuring components — that
155
+ * shape's aliasing is fully covered by `buildPropAliasMap` instead).
156
+ * - `isModule` (module-scope constants aren't per-instance prop reads).
157
+ * - When `requireLiveRewriteSafe` is true (the default — the right
158
+ * setting for a caller that turns the alias into a LIVE `_p.X` read,
159
+ * e.g. `rewriteBodyAliasReads`), also excludes:
160
+ * - `let` bindings: a later reassignment (`value = 9`) would need to
161
+ * become `_p.value = 9`, silently writing through to the caller's
162
+ * prop instead of a local variable — never safe to infer.
163
+ * - `mutatedAfterDeclaration` (#2910's `markMutatedConstants`): once
164
+ * something mutates the binding in place after its declaration,
165
+ * `value` no longer tracks the live prop, and treating it as a
166
+ * passthrough alias would silently drop the mutation.
167
+ * A caller that only needs the declaration-time local↔caller-key
168
+ * mapping (e.g. `resolveBodyDestructuredPropAliases`, feeding the SSR
169
+ * stash seed) passes `requireLiveRewriteSafe: false` — a `let` local or
170
+ * one mutated later in the function body is still a perfectly valid
171
+ * alias AT its declaration, which is all an initial SSR-stash seed
172
+ * needs.
173
+ */
174
+ export function resolveBodyPropAliases(
175
+ localConstants: readonly ConstantInfo[],
176
+ propsObjectName: string | null,
177
+ options: { requireLiveRewriteSafe?: boolean } = {},
178
+ ): Map<string, BodyPropAlias> {
179
+ const { requireLiveRewriteSafe = true } = options
180
+ const aliases = new Map<string, BodyPropAlias>()
97
181
  if (propsObjectName === null) return aliases
98
182
  for (const c of localConstants) {
99
- if (c.isModule) continue
100
- const m = c.parsed
101
- if (m?.kind === 'member' && !m.computed && m.object.kind === 'identifier' && m.object.name === propsObjectName) {
102
- aliases.set(c.name, m.property)
103
- }
183
+ if (c.isModule || !c.value) continue
184
+ if (requireLiveRewriteSafe && (c.declarationKind !== 'const' || c.mutatedAfterDeclaration)) continue
185
+ // Re-parse `value` (rather than walking `c.parsed`) so the default's
186
+ // SOURCE TEXT is available verbatim — `ParsedExpr` structures the
187
+ // default but doesn't retain its original formatting, and this reuses
188
+ // the one recognizer (`parsePropReadInitializer`) the emit-time passes
189
+ // (`prune-unused-prop-extractions.ts`, `rewrite-destructured-props.ts`)
190
+ // already share, rather than a third bespoke shape check. Wrapped in
191
+ // parens so a bare object-literal-like value still parses as an
192
+ // expression, matching `ConstantInfo.parsed`'s own convention.
193
+ const sourceFile = ts.createSourceFile('__alias__.ts', `(${c.value.trim()});`, ts.ScriptTarget.Latest, false, ts.ScriptKind.TS)
194
+ const stmt = sourceFile.statements[0]
195
+ if (!stmt || !ts.isExpressionStatement(stmt)) continue
196
+ const node = ts.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression
197
+ const read = parsePropReadInitializer(node, propsObjectName)
198
+ if (read === null) continue
199
+ const hasDefault = read.fallback !== null
200
+ aliases.set(c.name, {
201
+ key: read.key,
202
+ hasDefault,
203
+ defaultContainsArrow: hasDefault ? c.containsArrow : undefined,
204
+ })
104
205
  }
105
206
  return aliases
106
207
  }
@@ -130,6 +231,70 @@ export function boundPropLocalNames(b: PropsParamBindings): ReadonlySet<string>
130
231
 
131
232
  const EMPTY_SET: ReadonlySet<string> = new Set()
132
233
 
234
+ /**
235
+ * The subset of `ParamInfo` a live prop read actually needs. A body-level
236
+ * pure-alias local (`resolveBodyPropAliases`) has no real `ParamInfo` — it
237
+ * never bound a parameter — so callers synthesize one of these instead of a
238
+ * full `ParamInfo` (which would need a fabricated `type`/`optional`).
239
+ */
240
+ export type LivePropReadInfo = Pick<ParamInfo, 'name' | 'sourceName' | 'defaultValue' | 'defaultContainsArrow'>
241
+
242
+ /** `_p.<callerKey>` — `_p` is always keyed by the caller-facing name (#2524 CSR half). */
243
+ export function propReadBase(p: LivePropReadInfo): string {
244
+ return `${PROPS_PARAM}.${p.sourceName ?? p.name}`
245
+ }
246
+
247
+ /**
248
+ * The `??` right-hand side for a prop read, or null when the bare read is
249
+ * correct. Precedence:
250
+ * 1. an explicit destructure default (`{ x = 1 }`) — an arrow default gets
251
+ * an extra paren, since `??` binds tighter than the arrow head and
252
+ * `_p.onInput ?? () => {}` would be a syntax error.
253
+ * 2. `usedAsLoopArray` → `[]`.
254
+ * 3. property/index access → `{}`, UNLESS the prop also guards a
255
+ * conditional: `{}` is truthy, so that would always render the branch.
256
+ * 4. otherwise null — a defaultless optional reads `undefined` when
257
+ * absent, which is what the JS binding did and what SSR produces. A
258
+ * synthesized zero default would diverge from SSR instead (`size ?? 1`
259
+ * seeds 1 server-side; a `_p.size ?? 0` read would hydrate to 0).
260
+ */
261
+ export function propReadFallback(
262
+ p: LivePropReadInfo,
263
+ usage: PropUsage | undefined,
264
+ usedAsCondition: boolean,
265
+ ): string | null {
266
+ if (p.defaultValue) return p.defaultContainsArrow ? `(${p.defaultValue})` : p.defaultValue
267
+ if (usage?.usedAsLoopArray) return '[]'
268
+ if (propHasPropertyAccess(usage) && !usedAsCondition) return '{}'
269
+ return null
270
+ }
271
+
272
+ /**
273
+ * The live read of a destructured prop inside init scope, in the same shape
274
+ * props-object mode emits for `props.X`. The one formula every live-read
275
+ * call site shares: the whole-init-body rewrite
276
+ * (`rewriteDestructuredPropReads`), the reactive attribute rewrite
277
+ * (`emit-reactive.ts`), the controlled-signal sync effect
278
+ * (`build-declaration-emit.ts`), and the Phase-1 CSR `template:` rewrite
279
+ * (`jsx-to-ir.ts`).
280
+ *
281
+ * Parenthesized whenever a fallback is present so it splices safely into an
282
+ * arbitrary read position (a member access, a call argument, …).
283
+ * `emitPropsExtraction` deliberately does NOT use this: its `children` line
284
+ * must stay an unparenthesized `const X = _p.X [?? d]` for
285
+ * `pruneUnusedPropExtractions`'s AST matcher, so it composes
286
+ * `propReadBase`/`propReadFallback` itself.
287
+ */
288
+ export function livePropReadExpr(
289
+ p: LivePropReadInfo,
290
+ usage: PropUsage | undefined,
291
+ usedAsCondition: boolean,
292
+ ): string {
293
+ const base = propReadBase(p)
294
+ const fallback = propReadFallback(p, usage, usedAsCondition)
295
+ return fallback === null ? base : `(${base} ?? ${fallback})`
296
+ }
297
+
133
298
  /**
134
299
  * The two component bindings that forward the caller's leftover props:
135
300
  * the destructured `...rest` binding and a whole undestructured `(props)`
@@ -184,10 +184,15 @@ export function extractSsrDefaults(metadata: IRMetadata): Record<string, SsrDefa
184
184
  // adapters flatten `props.X` to the same bare scalar (`$X` — see
185
185
  // the Mojo emitter's `member()`), NOT a `$props->{X}` hash read,
186
186
  // so an unseeded prop the caller forgets to pass is a strict-mode
187
- // compile error, not a soft `undef` (#2126). Seed every declared
188
- // prop with a `null` fallback (→ undef; the template-side `// …`
189
- // recompute supplies the real default, and a caller-passed prop
190
- // wins via `propName`).
187
+ // compile error, not a soft `undef` (#2126). A BODY-destructured
188
+ // default (`const { label = 'none' } = props`, #2943) reaches this
189
+ // same `p.defaultValue` too — the analyzer overlays it onto
190
+ // `propsParams` at the binding's own declaration (`collectConstant`,
191
+ // `analyzer.ts`) — so it needs no separate branch here: any prop
192
+ // with a static default, from either destructuring form, seeds the
193
+ // evaluated value; one with none seeds `null` (→ undef; the
194
+ // template-side `// …` recompute supplies the real default, and a
195
+ // caller-passed prop wins via `propName`).
191
196
  for (const p of metadata.propsParams) {
192
197
  if (p.isRest) continue
193
198
  // `propName` is the CALLER-facing key (`$props->{propName}` in the Perl
@@ -195,7 +200,7 @@ export function extractSsrDefaults(metadata: IRMetadata): Record<string, SsrDefa
195
200
  // `n`, not the local binding `count` the template variable is keyed by.
196
201
  // `sourceName ?? name` is an identity for every un-aliased prop.
197
202
  const callerPropName = p.sourceName ?? p.name
198
- if (metadata.propsObjectName === null && p.defaultValue !== undefined) {
203
+ if (p.defaultValue !== undefined) {
199
204
  const value = tryStaticEval(p.defaultValue, { bindings: {}, propsLike })
200
205
  out[p.name] = { propName: callerPropName, value: resultToJsonable(value) }
201
206
  } else {
@@ -3,9 +3,9 @@
3
3
  * is a literal, a no-substitution (or fully-static) template literal, an
4
4
  * array-literal of pure elements, or an object-literal of pure values
5
5
  * evaluates here to its plain JS value. Consumed by each adapter's
6
- * `renderLoop` to admit a function-scope local const whose initializer is
7
- * entirely known at compile time as a loop source — inlining its value the
8
- * same way a module-scope const already is — while still refusing a
6
+ * `renderLoop` to admit a local const (module- or function-scope alike,
7
+ * #2946) whose initializer is entirely known at compile time as a loop
8
+ * source — inlining its value as a native literal — while still refusing a
9
9
  * runtime-computed expression (`Object.entries(props.tags).filter(...)`,
10
10
  * #2069) with BF101, since `call`/unresolvable-`member` shapes fall through
11
11
  * to `null` below.
@@ -117,11 +117,23 @@ export function isFullyStaticLiteral(expr: ParsedExpr): boolean {
117
117
  /**
118
118
  * Shared loop-source resolution for `renderLoop` across adapters: the loop
119
119
  * array is either an inline array-literal, or a bare identifier naming a
120
- * FUNCTION-scope (`!isModule`) local const whose initializer evaluates
121
- * statically. Module-scope consts are deliberately excluded — an existing,
122
- * separate seeding path already handles those. Returns the evaluated items,
123
- * or `null` if the source isn't resolvable this way (including when it
124
- * resolves to something other than an array).
120
+ * local const — module-scope or function-scope alike (#2946) — whose
121
+ * initializer evaluates statically. The only exclusions are (1) a name the
122
+ * enclosing loop scope already binds (`isNameShadowed`), (2) a const flagged
123
+ * `mutatedAfterDeclaration` (#2910 — its initializer is a stale snapshot,
124
+ * not the const's current value), and (3) a non-literal initializer.
125
+ *
126
+ * Module-scope consts used to be excluded outright on the theory that an
127
+ * existing, separate seeding path already handled them — but that path
128
+ * (`ssr-defaults.ts`'s `tryStaticEval`/`bindings`, and Go's
129
+ * `convertInitialValue`) only ever sees a module const through a
130
+ * `createSignal(...)` argument. A module const `.map()`'d directly, with no
131
+ * signal in between, was never seeded by anything and silently rendered
132
+ * empty (ERB/Jinja/Twig/Blade/Xslate/minijinja), failed to compile
133
+ * (Mojolicious), or failed at execution time (Go) — see #2946.
134
+ *
135
+ * Returns the evaluated items, or `null` if the source isn't resolvable this
136
+ * way (including when it resolves to something other than an array).
125
137
  */
126
138
  export function resolveStaticLoopSource(
127
139
  arrayParsed: ParsedExpr | undefined,
@@ -133,7 +145,7 @@ export function resolveStaticLoopSource(
133
145
  if (arrayParsed.kind === 'identifier') {
134
146
  if (opts?.isNameShadowed?.(arrayParsed.name)) return null
135
147
  const local = localConstants?.find(c => c.name === arrayParsed.name)
136
- if (!local || local.isModule || !local.parsed) return null
148
+ if (!local?.parsed || local.mutatedAfterDeclaration) return null
137
149
  target = local.parsed
138
150
  }
139
151
  const resolved = evaluateStaticLiteral(target)
package/src/types.ts CHANGED
@@ -2253,6 +2253,13 @@ export interface PropUsage {
2253
2253
  export interface ClientAnalysis {
2254
2254
  needsInit: boolean
2255
2255
  usedProps: string[]
2256
+ /**
2257
+ * The subset of `usedProps` whose declared type is a function — the client
2258
+ * code CALLS these, so they cannot arrive as JSON. Keyed by caller-facing
2259
+ * name (the `bf-p` blob key), valued by the declared type's printable
2260
+ * text. See `computeLiveOnlyProps` (`ir-to-client-js/index.ts`).
2261
+ */
2262
+ liveOnlyProps: Record<string, string>
2256
2263
  }
2257
2264
 
2258
2265
  // =============================================================================