@barefootjs/jsx 0.40.0 → 0.40.1

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 (140) hide show
  1. package/dist/adapters/ambiguous-nil-arithmetic.d.ts +41 -0
  2. package/dist/adapters/ambiguous-nil-arithmetic.d.ts.map +1 -0
  3. package/dist/adapters/attr-plan.d.ts.map +1 -1
  4. package/dist/adapters/boolean-carrier.d.ts +31 -0
  5. package/dist/adapters/boolean-carrier.d.ts.map +1 -0
  6. package/dist/adapters/component-props.d.ts +22 -7
  7. package/dist/adapters/component-props.d.ts.map +1 -1
  8. package/dist/adapters/computed-const.d.ts +17 -0
  9. package/dist/adapters/computed-const.d.ts.map +1 -1
  10. package/dist/adapters/dsl-template-adapter.d.ts +18 -1
  11. package/dist/adapters/dsl-template-adapter.d.ts.map +1 -1
  12. package/dist/adapters/number-value.d.ts +43 -0
  13. package/dist/adapters/number-value.d.ts.map +1 -0
  14. package/dist/analyzer-context.d.ts +7 -0
  15. package/dist/analyzer-context.d.ts.map +1 -1
  16. package/dist/analyzer.d.ts +34 -0
  17. package/dist/analyzer.d.ts.map +1 -1
  18. package/dist/expression-parser.d.ts.map +1 -1
  19. package/dist/index.d.ts +6 -3
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +1006 -351
  22. package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
  23. package/dist/ir-to-client-js/control-flow/plan/build-component-loop.d.ts.map +1 -1
  24. package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts +29 -0
  25. package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts.map +1 -1
  26. package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts +2 -0
  27. package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts.map +1 -1
  28. package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts.map +1 -1
  29. package/dist/ir-to-client-js/control-flow/plan/build-reactive-effects.d.ts.map +1 -1
  30. package/dist/ir-to-client-js/control-flow/plan/inner-loop.d.ts +5 -4
  31. package/dist/ir-to-client-js/control-flow/plan/inner-loop.d.ts.map +1 -1
  32. package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts +2 -0
  33. package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts.map +1 -1
  34. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts +15 -0
  35. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts.map +1 -1
  36. package/dist/ir-to-client-js/control-flow/plan/reactive-effects.d.ts +2 -0
  37. package/dist/ir-to-client-js/control-flow/plan/reactive-effects.d.ts.map +1 -1
  38. package/dist/ir-to-client-js/control-flow/shared.d.ts.map +1 -1
  39. package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts +20 -0
  40. package/dist/ir-to-client-js/control-flow/stringify/claim-plan.d.ts.map +1 -1
  41. package/dist/ir-to-client-js/control-flow/stringify/component-loop.d.ts.map +1 -1
  42. package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts +1 -1
  43. package/dist/ir-to-client-js/control-flow/stringify/event-listener.d.ts.map +1 -1
  44. package/dist/ir-to-client-js/control-flow/stringify/lazy-row.d.ts.map +1 -1
  45. package/dist/ir-to-client-js/html-template.d.ts +3 -2
  46. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  47. package/dist/ir-to-client-js/plan/build-static-array-child-init.d.ts.map +1 -1
  48. package/dist/ir-to-client-js/plan/static-array-child-init.d.ts +7 -1
  49. package/dist/ir-to-client-js/plan/static-array-child-init.d.ts.map +1 -1
  50. package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
  51. package/dist/ir-to-client-js/safe-html.d.ts +9 -3
  52. package/dist/ir-to-client-js/safe-html.d.ts.map +1 -1
  53. package/dist/ir-to-client-js/stringify/static-array-child-init.d.ts.map +1 -1
  54. package/dist/ir-to-client-js/types.d.ts +30 -0
  55. package/dist/ir-to-client-js/types.d.ts.map +1 -1
  56. package/dist/ir-to-client-js/utils.d.ts +8 -0
  57. package/dist/ir-to-client-js/utils.d.ts.map +1 -1
  58. package/dist/jsx-to-ir.d.ts.map +1 -1
  59. package/dist/nullable-signal-attr.d.ts +29 -3
  60. package/dist/nullable-signal-attr.d.ts.map +1 -1
  61. package/dist/props-binding.d.ts +27 -3
  62. package/dist/props-binding.d.ts.map +1 -1
  63. package/dist/scope/binding-scope.d.ts +22 -1
  64. package/dist/scope/binding-scope.d.ts.map +1 -1
  65. package/dist/scope/root-prop-alias.d.ts +14 -1
  66. package/dist/scope/root-prop-alias.d.ts.map +1 -1
  67. package/dist/signal-prop-name-collision.d.ts.map +1 -1
  68. package/dist/ssr-defaults.d.ts +4 -2
  69. package/dist/ssr-defaults.d.ts.map +1 -1
  70. package/dist/ssr-seed-plan.d.ts +14 -0
  71. package/dist/ssr-seed-plan.d.ts.map +1 -1
  72. package/dist/template-parts.d.ts.map +1 -1
  73. package/dist/types.d.ts +30 -0
  74. package/dist/types.d.ts.map +1 -1
  75. package/package.json +2 -2
  76. package/src/__tests__/binding-scope-ratchet.test.ts +12 -2
  77. package/src/__tests__/boolean-carrier.test.ts +74 -0
  78. package/src/__tests__/component-props.test.ts +14 -0
  79. package/src/__tests__/computed-const.test.ts +85 -0
  80. package/src/__tests__/expression-parser.test.ts +24 -0
  81. package/src/__tests__/issue-3688-props-spread-child-csr.test.ts +142 -0
  82. package/src/__tests__/loop-row-prop-read.test.ts +111 -0
  83. package/src/__tests__/memo-body-expr.test.ts +137 -0
  84. package/src/__tests__/nullable-signal-attr.test.ts +97 -2
  85. package/src/__tests__/profile-binding-ids.test.ts +14 -0
  86. package/src/__tests__/root-prop-alias.test.ts +34 -1
  87. package/src/__tests__/signal-prop-name-collision.test.ts +102 -2
  88. package/src/__tests__/source-file-cache.test.ts +105 -0
  89. package/src/__tests__/ssr-seed-plan.test.ts +43 -0
  90. package/src/__tests__/template-parts-literal-boundary.test.ts +19 -0
  91. package/src/adapters/ambiguous-nil-arithmetic.ts +94 -0
  92. package/src/adapters/attr-plan.ts +6 -2
  93. package/src/adapters/boolean-carrier.ts +76 -0
  94. package/src/adapters/component-props.ts +28 -8
  95. package/src/adapters/computed-const.ts +206 -7
  96. package/src/adapters/dsl-template-adapter.ts +39 -0
  97. package/src/adapters/number-value.ts +95 -0
  98. package/src/analyzer-context.ts +8 -0
  99. package/src/analyzer.ts +187 -66
  100. package/src/expression-parser.ts +4 -1
  101. package/src/index.ts +12 -2
  102. package/src/ir-to-client-js/collect-elements.ts +104 -46
  103. package/src/ir-to-client-js/compute-inlinability.ts +1 -1
  104. package/src/ir-to-client-js/control-flow/plan/build-component-loop.ts +15 -1
  105. package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +79 -4
  106. package/src/ir-to-client-js/control-flow/plan/build-lazy-row.ts +3 -0
  107. package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +1 -0
  108. package/src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts +1 -0
  109. package/src/ir-to-client-js/control-flow/plan/inner-loop.ts +5 -4
  110. package/src/ir-to-client-js/control-flow/plan/loop-child-arm.ts +2 -0
  111. package/src/ir-to-client-js/control-flow/plan/loop.ts +12 -0
  112. package/src/ir-to-client-js/control-flow/plan/reactive-effects.ts +2 -0
  113. package/src/ir-to-client-js/control-flow/shared.ts +3 -2
  114. package/src/ir-to-client-js/control-flow/stringify/claim-plan.ts +27 -0
  115. package/src/ir-to-client-js/control-flow/stringify/component-loop.ts +8 -2
  116. package/src/ir-to-client-js/control-flow/stringify/event-listener.ts +8 -1
  117. package/src/ir-to-client-js/control-flow/stringify/inner-loop.ts +8 -7
  118. package/src/ir-to-client-js/control-flow/stringify/lazy-row.ts +8 -7
  119. package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +4 -4
  120. package/src/ir-to-client-js/control-flow/stringify/loop.ts +3 -3
  121. package/src/ir-to-client-js/control-flow/stringify/reactive-effects.ts +6 -6
  122. package/src/ir-to-client-js/emit-reactive.ts +1 -1
  123. package/src/ir-to-client-js/html-template.ts +70 -30
  124. package/src/ir-to-client-js/plan/build-static-array-child-init.ts +11 -1
  125. package/src/ir-to-client-js/plan/static-array-child-init.ts +7 -1
  126. package/src/ir-to-client-js/reactivity.ts +14 -0
  127. package/src/ir-to-client-js/safe-html.ts +11 -4
  128. package/src/ir-to-client-js/stringify/static-array-child-init.ts +6 -4
  129. package/src/ir-to-client-js/types.ts +23 -0
  130. package/src/ir-to-client-js/utils.ts +15 -1
  131. package/src/jsx-to-ir.ts +78 -35
  132. package/src/nullable-signal-attr.ts +134 -13
  133. package/src/props-binding.ts +54 -3
  134. package/src/scope/binding-scope.ts +30 -2
  135. package/src/scope/root-prop-alias.ts +17 -1
  136. package/src/signal-prop-name-collision.ts +113 -22
  137. package/src/ssr-defaults.ts +10 -4
  138. package/src/ssr-seed-plan.ts +82 -17
  139. package/src/template-parts.ts +21 -1
  140. package/src/types.ts +30 -0
package/src/analyzer.ts CHANGED
@@ -9,12 +9,12 @@
9
9
  import ts from 'typescript'
10
10
  import { foldRenderReassignmentsInSource } from './fold-render-reassignments.ts'
11
11
  import { CLIENT_DIRECTIVE_INTERIOR_RE, USE_CLIENT_DIRECTIVE, isUseClientDirectiveText } from './directives.ts'
12
- import type { ImportSpecifier, TypeInfo, ParamInfo, PropDefaultPart, PropDefaultRead, ReactiveFactoryInfo, DeclinedReactiveFactory, RequiredFactoryImport, FactoryRenameSite, SourceLocation, SignalFactoryCall, MemoInfo } from './types.ts'
12
+ import type { ImportSpecifier, TypeInfo, ParamInfo, PropDefaultPart, PropDefaultRead, ReactiveFactoryInfo, DeclinedReactiveFactory, RequiredFactoryImport, FactoryRenameSite, SourceLocation, SignalFactoryCall, MemoInfo, SignalInfo } from './types.ts'
13
13
  import { CALLBACK_METHODS, parseExpression, parseBlockBodyTolerant, foldBlockToExpr, tsNodeToParsedExpr, stringifyParsedExpr, type ParsedExpr } from './expression-parser.ts'
14
14
  import type { CallbackBodyAcceptor } from './adapters/interface.ts'
15
15
  import { collectAssignmentTargets, rewriteBarePropRefs, splitScopedValueRefs } from './prop-rewrite.ts'
16
16
  import { isEventHandlerName } from './event-handler-name.ts'
17
- import { buildPropAliasMap, coalesceDefaultText, livePropReadExpr, signalPropSeed } from './props-binding.ts'
17
+ import { buildPropAliasMap, coalesceDefaultText, livePropReadExpr, signalPropSeed, templatePropReadParams } from './props-binding.ts'
18
18
  import { incrementCounter } from './instrumentation.ts'
19
19
  import {
20
20
  type AnalyzerContext,
@@ -150,10 +150,26 @@ export function createProgramForFile(
150
150
  source: string,
151
151
  filePath: string,
152
152
  hostOptions: { currentDirectory?: string } = {}
153
+ ): { program: ts.Program; sourceFile: ts.SourceFile; checker: ts.TypeChecker } | null {
154
+ return buildProgramForFile(source, filePath, hostOptions)
155
+ }
156
+
157
+ /**
158
+ * `createProgramForFile`, plus `sourceFiles`: Programs built one after
159
+ * another share parsed (and bound) SourceFiles through it. Every file the
160
+ * host serves, `source` included, is parsed once per distinct text. Not
161
+ * exported from the package: every Program built here has the same compiler
162
+ * options, which is what makes sharing bound SourceFiles between them safe
163
+ * (see `SourceFileCache`).
164
+ */
165
+ function buildProgramForFile(
166
+ source: string,
167
+ filePath: string,
168
+ hostOptions: { currentDirectory?: string; sourceFiles?: SourceFileCache },
153
169
  ): { program: ts.Program; sourceFile: ts.SourceFile; checker: ts.TypeChecker } | null {
154
170
  incrementCounter('programCreations')
155
171
  try {
156
- const { currentDirectory } = hostOptions
172
+ const { currentDirectory, sourceFiles } = hostOptions
157
173
  const resolveFrom = (fileName: string): string =>
158
174
  currentDirectory === undefined ? path.resolve(fileName) : path.resolve(currentDirectory, fileName)
159
175
  const normalizedPath = resolveFrom(filePath)
@@ -176,8 +192,13 @@ export function createProgramForFile(
176
192
  ...(currentDirectory === undefined ? {} : { getCurrentDirectory: () => currentDirectory }),
177
193
  getSourceFile(fileName, languageVersion) {
178
194
  if (resolveFrom(fileName) === normalizedPath) {
195
+ if (sourceFiles) return sourceFiles.get(fileName, languageVersion, source, VIRTUAL_SOURCE_PARSE)
179
196
  return ts.createSourceFile(fileName, source, languageVersion, true, ts.ScriptKind.TSX)
180
197
  }
198
+ if (sourceFiles) {
199
+ const text = defaultHost.readFile(fileName)
200
+ return text === undefined ? undefined : sourceFiles.get(fileName, languageVersion, text, DISK_FILE_PARSE)
201
+ }
181
202
  return defaultHost.getSourceFile(fileName, languageVersion)
182
203
  },
183
204
  fileExists(fileName) {
@@ -232,12 +253,79 @@ function rewriteSourceForAnalysis(
232
253
  * implementation for every harness that compiles under relative names:
233
254
  * the conformance harness (`packages/adapter-tests/src/harness-program.ts`)
234
255
  * and the docs-example suite (`doc-examples.test.ts`).
256
+ *
257
+ * Every Program it builds draws on one process-wide `SourceFileCache` that
258
+ * is never evicted, so it suits a test process over a fixed corpus. Do not
259
+ * call it from a long-running watcher.
235
260
  */
236
261
  export function createAnchoredProgram(source: string, filename: string, anchorDir: string): ts.Program | undefined {
237
262
  if (!needsTypeBasedDetection(source)) return undefined
238
- return createProgramForFile(source, filename, { currentDirectory: anchorDir })?.program
263
+ return buildProgramForFile(source, filename, { currentDirectory: anchorDir, sourceFiles: anchoredSourceFiles })?.program
239
264
  }
240
265
 
266
+ /**
267
+ * Parsed SourceFiles shared by consecutive Programs, keyed by file name, the
268
+ * parse options the Program asks for, and the text. A file is parsed once per
269
+ * distinct text: a file that changed on disk (a rebuilt `@barefootjs/client`
270
+ * `dist`) is parsed again, never served stale, and the many different sources
271
+ * a harness compiles under one virtual name (`component.tsx`) each keep their
272
+ * own entry.
273
+ *
274
+ * A reused SourceFile also keeps its binding, so a Program built from cached
275
+ * files costs module resolution and checker setup, not a parse of
276
+ * `lib.*.d.ts` and every imported declaration (~430 ms → ~30 ms per Program
277
+ * in the conformance harness, #3666). Sharing SourceFiles between Programs
278
+ * with the same compiler options is how TypeScript's own DocumentRegistry
279
+ * serves language services. The Programs themselves are not shared: a
280
+ * checker assigns type ids in the order it is queried, so one reused across
281
+ * compiles could make a compile's output depend on what ran before it.
282
+ *
283
+ * Only for Programs built with the same compiler options: the cache does not
284
+ * key on them. Entries are never evicted, which suits a test process over a
285
+ * fixed corpus, not a long-running watcher.
286
+ */
287
+ export class SourceFileCache {
288
+ private readonly files = new Map<string, Map<string, ts.SourceFile>>()
289
+
290
+ get(
291
+ fileName: string,
292
+ languageVersion: ts.ScriptTarget | ts.CreateSourceFileOptions,
293
+ text: string,
294
+ parse: SourceFileParse,
295
+ ): ts.SourceFile {
296
+ const key = `${fileName}\0${parseOptionsKey(languageVersion)}\0${parse.scriptKind ?? ''}\0${parse.setParentNodes}`
297
+ let byText = this.files.get(key)
298
+ if (!byText) {
299
+ byText = new Map()
300
+ this.files.set(key, byText)
301
+ }
302
+ const cached = byText.get(text)
303
+ if (cached) return cached
304
+ const parsed = ts.createSourceFile(fileName, text, languageVersion, parse.setParentNodes, parse.scriptKind)
305
+ byText.set(text, parsed)
306
+ return parsed
307
+ }
308
+ }
309
+
310
+ /** How `SourceFileCache` parses a file; part of its key. */
311
+ export interface SourceFileParse {
312
+ scriptKind?: ts.ScriptKind
313
+ setParentNodes: boolean
314
+ }
315
+
316
+ /** The virtual source, parsed as `createProgramForFile` always parsed it. */
317
+ const VIRTUAL_SOURCE_PARSE: SourceFileParse = { scriptKind: ts.ScriptKind.TSX, setParentNodes: true }
318
+ /** A file read from disk, parsed the way the default compiler host parses it. */
319
+ const DISK_FILE_PARSE: SourceFileParse = { setParentNodes: false }
320
+
321
+ function parseOptionsKey(languageVersion: ts.ScriptTarget | ts.CreateSourceFileOptions): string {
322
+ if (typeof languageVersion === 'number') return String(languageVersion)
323
+ return `${languageVersion.languageVersion}:${languageVersion.impliedNodeFormat ?? ''}:${languageVersion.jsDocParsingMode ?? ''}`
324
+ }
325
+
326
+ /** The cache behind every `createAnchoredProgram` Program in this process. */
327
+ const anchoredSourceFiles = new SourceFileCache()
328
+
241
329
  /**
242
330
  * Parse a signal's initializer into the IR, and record which prop it seeds
243
331
  * from and with what fallback (#3508).
@@ -1527,37 +1615,29 @@ function collectSignal(node: ts.VariableDeclaration, ctx: AnalyzerContext): void
1527
1615
  // the binding actually in scope rather than a hardcoded canonical name (#2057).
1528
1616
  const envFactory = envReader ? callExpr.expression.getText(ctx.sourceFile) : undefined
1529
1617
 
1530
- // Destructured-arg components only (#2265): a signal's initial value
1531
- // referencing a bare destructured prop (`createSignal(size ?? 1)` with
1532
- // `{ size }: { size?: number }`) needs `_p.size` for the CSR
1533
- // `template:` arrow's module-scope SSR fallback — that arrow isn't a
1534
- // closure over `initXxx`'s `const size = _p.size` extraction. Mirrors
1535
- // the local-constant rewrite a few hundred lines up (`propNames` built
1536
- // the same way from `ctx.propsParams`).
1537
- let templateInitialValue: string | undefined
1538
- if (!ctx.propsObjectName && callExpr.arguments[0]) {
1539
- const propNames = new Set(ctx.propsParams.map(p => p.name))
1540
- if (propNames.size > 0) {
1541
- const propAliases = buildPropAliasMap(ctx.propsParams)
1542
- templateInitialValue = rewriteBarePropRefs(initialValue, callExpr.arguments[0], propNames, undefined, propAliases, destructuredPropTemplateRead(ctx))
1543
- }
1544
- }
1545
-
1546
- ctx.signals.push({
1618
+ // A signal's initial value referencing a bare destructured prop
1619
+ // (`createSignal(size ?? 1)` with `{ size }: { size?: number }`, #2265,
1620
+ // or a `(props)`-arg component's body destructure binding) needs
1621
+ // `_p.size` for the CSR `template:` arrow's module-scope SSR fallback —
1622
+ // that arrow isn't a closure over `initXxx`'s `const size = _p.size`
1623
+ // extraction (`deferTemplatePropRead`).
1624
+ const seedNode = callExpr.arguments[0]
1625
+ const signal: SignalInfo = {
1547
1626
  getter,
1548
1627
  setter,
1549
1628
  getterElided: getterElided || undefined,
1550
1629
  initialValue,
1551
1630
  typedInitialValue: typedInitialValue !== initialValue ? typedInitialValue : undefined,
1552
- templateInitialValue,
1553
1631
  type,
1554
1632
  loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
1555
- initialFreeIdentifiers: callExpr.arguments[0]
1556
- ? extractFreeIdentifiersFromNode(callExpr.arguments[0])
1633
+ initialFreeIdentifiers: seedNode
1634
+ ? extractFreeIdentifiersFromNode(seedNode)
1557
1635
  : new Set(),
1558
1636
  envReader,
1559
1637
  envFactory,
1560
- })
1638
+ }
1639
+ ctx.signals.push(signal)
1640
+ if (seedNode) deferTemplatePropRead(initialValue, seedNode, ctx, text => { signal.templateInitialValue = text })
1561
1641
  }
1562
1642
 
1563
1643
  /**
@@ -1623,28 +1703,15 @@ function collectFactorySignal(
1623
1703
  type = inferTypeFromValue(initialValue)
1624
1704
  }
1625
1705
 
1626
- // Destructured-arg components (#2265): the CSR `template:` arrow's
1627
- // module-scope fallback needs `_p.<name>` for a bare destructured prop in
1628
- // `initial`, same as a `createSignal` initial value.
1629
- let templateInitialValue: string | undefined
1630
- if (!ctx.propsObjectName && initialNode.kind === 'expression') {
1631
- const propNames = new Set(ctx.propsParams.map(p => p.name))
1632
- if (propNames.size > 0) {
1633
- const propAliases = buildPropAliasMap(ctx.propsParams)
1634
- templateInitialValue = rewriteBarePropRefs(initialValue, initialNode.node, propNames, undefined, propAliases, destructuredPropTemplateRead(ctx))
1635
- }
1636
- }
1637
-
1638
1706
  const argTexts = callExpr.arguments.map(arg => ctx.getJS(arg))
1639
1707
  const requestArg = callExpr.arguments[0]
1640
1708
 
1641
- ctx.signals.push({
1709
+ const signal: SignalInfo = {
1642
1710
  getter: valueName ?? `__bfGet_${action}`,
1643
1711
  setter: null,
1644
1712
  getterElided: getterElided || undefined,
1645
1713
  initialValue,
1646
1714
  typedInitialValue: typedInitialValue !== undefined && typedInitialValue !== initialValue ? typedInitialValue : undefined,
1647
- templateInitialValue,
1648
1715
  type,
1649
1716
  loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
1650
1717
  initialFreeIdentifiers,
@@ -1656,7 +1723,14 @@ function collectFactorySignal(
1656
1723
  requestFreeIdentifiers: requestArg ? extractFreeIdentifiersFromNode(requestArg) : new Set(),
1657
1724
  action,
1658
1725
  },
1659
- })
1726
+ }
1727
+ ctx.signals.push(signal)
1728
+ // The CSR `template:` arrow's module-scope fallback needs `_p.<name>` for
1729
+ // a bare destructured prop in `initial`, same as a `createSignal` initial
1730
+ // value (#2265).
1731
+ if (initialNode.kind === 'expression') {
1732
+ deferTemplatePropRead(initialValue, initialNode.node, ctx, text => { signal.templateInitialValue = text })
1733
+ }
1660
1734
  }
1661
1735
 
1662
1736
  /**
@@ -2062,33 +2136,33 @@ function memoStructuredBody(
2062
2136
  }
2063
2137
 
2064
2138
  /**
2065
- * `MemoInfo.bodyExpr` / `bodyExprIsCall` / `templateBodyExpr` from the
2066
- * callback's body node (#3510).
2139
+ * `MemoInfo.bodyExpr` / `bodyExprIsCall` from the callback's body node
2140
+ * (#3510).
2067
2141
  */
2068
2142
  function memoBodyFields(
2069
2143
  body: { node: ts.Node; call: boolean },
2070
2144
  ctx: AnalyzerContext,
2071
- ): Pick<MemoInfo, 'bodyExpr' | 'bodyExprIsCall' | 'templateBodyExpr'> {
2072
- // Destructured-arg components only — the memo twin of the signal
2073
- // `templateInitialValue` rewrite (#2265) a few hundred lines up: a memo
2074
- // body referencing a bare destructured prop (`createMemo(() => value *
2075
- // 10)` with `{ value }: { value: number }`) is inlined into the CSR
2076
- // `template:` arrow by `buildSignalMemoEnv`, and that arrow runs at
2077
- // module scope — it is not a closure over `initXxx`'s `const value =
2078
- // _p.value` extraction, so the bare ref must become `_p.value`
2079
- // (adapter-tests scope-gate, #2468 sweep).
2080
- const asBodyExpr = (text: string): string => (body.call ? `(${text})()` : text)
2081
- const bodyExpr = asBodyExpr(ctx.getJS(body.node))
2082
- let templateBodyExpr: string | undefined
2083
- if (!ctx.propsObjectName) {
2084
- const propNames = new Set(ctx.propsParams.map(p => p.name))
2085
- if (propNames.size > 0) {
2086
- const propAliases = buildPropAliasMap(ctx.propsParams)
2087
- const rewritten = rewriteBarePropRefs(ctx.getJS(body.node), body.node, propNames, undefined, propAliases, destructuredPropTemplateRead(ctx))
2088
- templateBodyExpr = rewritten === undefined ? undefined : asBodyExpr(rewritten)
2089
- }
2090
- }
2091
- return { bodyExpr, bodyExprIsCall: body.call || undefined, templateBodyExpr }
2145
+ ): Pick<MemoInfo, 'bodyExpr' | 'bodyExprIsCall'> {
2146
+ return { bodyExpr: asMemoBodyExpr(ctx.getJS(body.node), body.call), bodyExprIsCall: body.call || undefined }
2147
+ }
2148
+
2149
+ function asMemoBodyExpr(text: string, call: boolean): string {
2150
+ return call ? `(${text})()` : text
2151
+ }
2152
+
2153
+ /**
2154
+ * `MemoInfo.templateBodyExpr`: the memo twin of the signal
2155
+ * `templateInitialValue` rewrite (#2265). A memo body referencing a bare
2156
+ * destructured prop (`createMemo(() => value * 10)` with
2157
+ * `{ value }: { value: number }`) is inlined into the CSR `template:` arrow
2158
+ * by `buildSignalMemoEnv`, and that arrow runs at module scope — it is not a
2159
+ * closure over `initXxx`'s `const value = _p.value` extraction, so the bare
2160
+ * ref must become `_p.value` (adapter-tests scope-gate, #2468 sweep).
2161
+ */
2162
+ function deferMemoTemplateBody(memo: MemoInfo, body: { node: ts.Node; call: boolean }, ctx: AnalyzerContext): void {
2163
+ deferTemplatePropRead(ctx.getJS(body.node), body.node, ctx, text => {
2164
+ memo.templateBodyExpr = text === undefined ? undefined : asMemoBodyExpr(text, body.call)
2165
+ })
2092
2166
  }
2093
2167
 
2094
2168
  function collectMemo(node: ts.VariableDeclaration, ctx: AnalyzerContext): void {
@@ -2169,6 +2243,7 @@ function collectMemo(node: ts.VariableDeclaration, ctx: AnalyzerContext): void {
2169
2243
  : new Set(),
2170
2244
  }
2171
2245
  ctx.memos.push(memo)
2246
+ if (body) deferMemoTemplateBody(memo, body, ctx)
2172
2247
  markBlockMemo(memo, blockTyped, body?.node, ctx)
2173
2248
  }
2174
2249
 
@@ -3676,6 +3751,32 @@ function destructuredPropTemplateRead(ctx: AnalyzerContext): (localName: string,
3676
3751
  return (localName, callerKey) => livePropReadExpr(byName.get(localName) ?? { name: localName, sourceName: callerKey }, undefined, false)
3677
3752
  }
3678
3753
 
3754
+ /**
3755
+ * Queue the client template text of a signal seed or memo body: `text` (the
3756
+ * source of `node`) with each read of a props binding the template reads live
3757
+ * (`templatePropReadParams`) rewritten to that read, or undefined when it
3758
+ * reads none, handed to `write` by `writeTemplatePropReads`. In a
3759
+ * `(props)`-arg component such a binding is a body destructure binding holding
3760
+ * its prop (`const { b: local = d } = props`), so a memo over it reads the
3761
+ * default just as markup does. The set is decided once the whole body is
3762
+ * walked: a binding written later no longer holds its prop, and a local
3763
+ * function or constant declared later keeps its own meaning.
3764
+ */
3765
+ function deferTemplatePropRead(text: string, node: ts.Node, ctx: AnalyzerContext, write: (text: string | undefined) => void): void {
3766
+ ctx.templatePropReadWriters.push(() => {
3767
+ const readable = templatePropReadParams(ctx)
3768
+ if (readable.length === 0) return
3769
+ const propNames = new Set(readable.map(p => p.name))
3770
+ write(rewriteBarePropRefs(text, node, propNames, undefined, buildPropAliasMap(readable), destructuredPropTemplateRead(ctx)))
3771
+ })
3772
+ }
3773
+
3774
+ /** Run the writers `deferTemplatePropRead` queued, against the walked body. */
3775
+ function writeTemplatePropReads(ctx: AnalyzerContext): void {
3776
+ for (const write of ctx.templatePropReadWriters) write()
3777
+ ctx.templatePropReadWriters.length = 0
3778
+ }
3779
+
3679
3780
  /**
3680
3781
  * The default-value-shaped fields a binding element's own `initializer`
3681
3782
  * contributes to a `ParamInfo` — `defaultValue`'s source text, `parsed`'s
@@ -4166,6 +4267,7 @@ function extractProps(param: ts.ParameterDeclaration, ctx: AnalyzerContext): voi
4166
4267
  const info: ParamInfo = {
4167
4268
  name: localName,
4168
4269
  type: resolvedType,
4270
+ ...unresolvedDeclaredType(member),
4169
4271
  // The type's `?` and a destructure default (`{ x = 1 }`) both mean
4170
4272
  // the caller may omit the prop.
4171
4273
  optional: !!member?.optional || !!element.initializer,
@@ -4423,20 +4525,38 @@ function localObjectMemberTypesFor(ctx: AnalyzerContext): LocalObjectMemberTypes
4423
4525
  * `isResolvableMemberType`'s own docstring for why the structural cases
4424
4526
  * are safe to admit and why those three still are not.
4425
4527
  */
4528
+ /**
4529
+ * A destructured binding's member type: `type` when it resolves to a
4530
+ * concrete representation (`isResolvableMemberType`), and the declared
4531
+ * type as written (`declared`), which `ParamInfo.declaredType` carries when
4532
+ * `type` does not resolve.
4533
+ */
4534
+ interface DestructuredMemberType {
4535
+ type: TypeInfo | null
4536
+ declared: TypeInfo | null
4537
+ optional: boolean
4538
+ }
4539
+
4540
+ /** `ParamInfo.declaredType` for a member whose declared type did not resolve to `type`. */
4541
+ function unresolvedDeclaredType(member: DestructuredMemberType | undefined): Pick<ParamInfo, 'declaredType'> {
4542
+ return member && !member.type && member.declared ? { declaredType: member.declared } : {}
4543
+ }
4544
+
4426
4545
  function collectMemberTypes(
4427
4546
  typeNode: ts.TypeNode,
4428
4547
  ctx: AnalyzerContext
4429
- ): Map<string, { type: TypeInfo | null; optional: boolean }> | null {
4548
+ ): Map<string, DestructuredMemberType> | null {
4430
4549
  const localObjectMembers = localObjectMemberTypesFor(ctx)
4431
4550
  const fromMembers = (
4432
4551
  members: ts.NodeArray<ts.TypeElement>
4433
- ): Map<string, { type: TypeInfo | null; optional: boolean }> => {
4434
- const map = new Map<string, { type: TypeInfo | null; optional: boolean }>()
4552
+ ): Map<string, DestructuredMemberType> => {
4553
+ const map = new Map<string, DestructuredMemberType>()
4435
4554
  for (const member of members) {
4436
4555
  if (ts.isPropertySignature(member) && member.name) {
4437
4556
  const info = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : null
4438
4557
  map.set(member.name.getText(ctx.sourceFile), {
4439
4558
  type: info && isResolvableMemberType(info, localObjectMembers) ? info : null,
4559
+ declared: info,
4440
4560
  optional: !!member.questionToken,
4441
4561
  })
4442
4562
  }
@@ -4707,6 +4827,7 @@ function validateContext(ctx: AnalyzerContext): void {
4707
4827
  // downstream inlining never re-embeds their stale initializer text (#2910).
4708
4828
  markMutatedConstants(ctx)
4709
4829
  markWrittenBindings(ctx)
4830
+ writeTemplatePropReads(ctx)
4710
4831
 
4711
4832
  // BF052: init statements that write to an identifier with no visible
4712
4833
  // declaration cause a ReferenceError in ESM strict mode. Flag them
@@ -1029,7 +1029,10 @@ function convertNode(node: ts.Node, raw: string): ParsedExpr {
1029
1029
  if (ts.isNumericLiteral(argNode)) {
1030
1030
  return { kind: 'member', object, property: argNode.text, computed: true, optional: !!node.questionDotToken }
1031
1031
  }
1032
- if (ts.isStringLiteral(argNode)) {
1032
+ // A no-substitution template literal key (`` obj[`key`] ``) is the
1033
+ // same static key as `obj['key']` — fold both so every adapter sees
1034
+ // one shape (#3763).
1035
+ if (ts.isStringLiteralLike(argNode)) {
1033
1036
  return { kind: 'member', object, property: argNode.text, computed: true, optional: !!node.questionDotToken }
1034
1037
  }
1035
1038
  // Variable / expression index (`selected()[index]`, `rows[i + 1]`):
package/src/index.ts CHANGED
@@ -39,7 +39,7 @@ export { resolveGetterAliases, collectAliasableGetterNames } from './ir-to-clien
39
39
  export { buildImportAliasMap } from './ir-to-client-js/component-scope.ts'
40
40
 
41
41
  // Backend-neutral SSR seed plan (in-template derived signal/memo seeding)
42
- export { computeSsrSeedPlan, inDefaultReadOrder } from './ssr-seed-plan.ts'
42
+ export { computeSsrSeedPlan, hasComputedDefault, inDefaultReadOrder } from './ssr-seed-plan.ts'
43
43
  export type { SsrSeedPlan, SsrSeedStep } from './ssr-seed-plan.ts'
44
44
 
45
45
  // Pure IR types
@@ -131,11 +131,19 @@ export { JsxAdapter } from './adapters/jsx-adapter.ts'
131
131
  export type { JsxAdapterConfig } from './adapters/jsx-adapter.ts'
132
132
  export { rewriteImportsForTemplate, rewriteDynamicImportsInSource } from './adapters/template-imports.ts'
133
133
  export { emitParsedExpr, arithmeticHelper, groupBinaryOperand, groupUnaryOperand, groupObjectLiteralSegments, isStringTypedOperand, isStringConcatBinary, isNumericArithmeticResult } from './adapters/parsed-expr-emitter.ts'
134
+ export { collectNumberValueNames, isNumberValuedExpr, numberValuedSeedNames } from './adapters/number-value.ts'
135
+ export { collectBooleanCarrierNames, mayYieldBooleanCarrier } from './adapters/boolean-carrier.ts'
134
136
  export type { ArithmeticHelper, ParsedExprEmitter, LoweringEmitter, HigherOrderMethod, ArrayMethod, SortMethod, LiteralType } from './adapters/parsed-expr-emitter.ts'
135
137
  export { collectLoopBoundNames } from './adapters/loop-bound-names.ts'
136
138
  export { planStyleObject, type StyleObjectPlanEntry } from './adapters/style-object.ts'
137
139
  export { filterCaptureCollisions } from './adapters/filter-capture-collisions.ts'
138
140
  export { templateNameCollisionErrors } from './adapters/template-name-collisions.ts'
141
+ export {
142
+ arithmeticCoercionOrRefuse,
143
+ refuseAmbiguousNilArithmetic,
144
+ refuseAmbiguousNilMemoArithmetic,
145
+ type AmbiguousNilArithmeticSink,
146
+ } from './adapters/ambiguous-nil-arithmetic.ts'
139
147
  export {
140
148
  collectBooleanValueNames,
141
149
  isAriaBooleanAttr,
@@ -211,6 +219,8 @@ export {
211
219
  arithmeticOperandIsNull,
212
220
  arithmeticOperandIsUndefined,
213
221
  arithmeticOperandCoercion,
222
+ arithmeticOperandNilIsAmbiguous,
223
+ ambiguousNilArithmeticOperands,
214
224
  bareGetterCallName,
215
225
  attrValueMayBeNullish,
216
226
  collectAbsentPropSeedReads,
@@ -352,7 +362,7 @@ export { isLowerableLoopDestructure, isLowerableObjectRestDestructure } from './
352
362
  // Binding scope (#2482) — shared loop-bound-name resolution service
353
363
  export { BindingScope } from './scope/binding-scope.ts'
354
364
  export type { ScopeBindingSource, ScopeBinding, ScopeFrame, LoopBindingSource } from './scope/binding-scope.ts'
355
- export { rootPropAliasNames, rootPropAliasesForLoop, rootPropReadName } from './scope/root-prop-alias.ts'
365
+ export { isRootPropsObject, rootPropAliasNames, rootPropAliasesForLoop, rootPropReadName } from './scope/root-prop-alias.ts'
356
366
 
357
367
  // Debug analysis
358
368
  export {
@@ -445,6 +445,11 @@ export function collectInnerLoops(
445
445
  childComponents,
446
446
  insideConditional: !flat && scope.insideCond ? true : undefined,
447
447
  offset: flat ? undefined : resolveLoopOffset(siblingOffsets.get(n)),
448
+ filterPredicate: n.filterPredicate ? { param: n.filterPredicate.param, raw: n.filterPredicate.raw } : undefined,
449
+ sortComparator: n.sortComparator
450
+ ? { paramA: n.sortComparator.paramA, paramB: n.sortComparator.paramB, raw: n.sortComparator.raw }
451
+ : undefined,
452
+ chainOrder: n.chainOrder,
448
453
  bindings,
449
454
  })
450
455
  // Branch-mode callers handle deeper nesting via their own collection paths.
@@ -504,6 +509,18 @@ function decideLoopRendering(
504
509
  return { useElementReconciliation, innerLoops }
505
510
  }
506
511
 
512
+ /**
513
+ * Whether a top-level loop carries its collected inner loops to the client
514
+ * JS plans: a reconciled (composite) row, a static array's row, and a
515
+ * component-root row (#3694), whose forwarded children's inner loops get
516
+ * their event handlers wired per row (`buildForwardedInnerLoopsPlan`).
517
+ */
518
+ function keepsInnerLoops(loop: IRLoop, useElementReconciliation: boolean, innerLoops: NestedLoop[] | undefined): boolean {
519
+ if (useElementReconciliation) return true
520
+ if (!innerLoops || innerLoops.length === 0) return false
521
+ return loop.isStaticArray || !!loop.childComponent
522
+ }
523
+
507
524
  /** Check whether an array of IR nodes contains any component nodes (recursively). */
508
525
  function jsxChildrenContainComponent(nodes: IRNode[]): boolean {
509
526
  for (const node of nodes) {
@@ -517,6 +534,76 @@ function jsxChildrenContainComponent(nodes: IRNode[]): boolean {
517
534
  return false
518
535
  }
519
536
 
537
+ /**
538
+ * One explicit prop's `initChild` props-object entry: its value expression,
539
+ * and whether it is read through a getter (deferred, so reactive) or is a
540
+ * plain data property.
541
+ */
542
+ function componentInitPropValue(prop: IRProp, ctx: ClientJsContext): { expr: string; getter: boolean } {
543
+ if (isEventHandlerName(prop.name)) {
544
+ // Event handlers reach here only as `expression` variants.
545
+ return { expr: attrValueToString(prop.value) ?? prop.name, getter: false }
546
+ }
547
+ switch (prop.value.kind) {
548
+ case 'jsx-children':
549
+ if (jsxChildrenContainComponent(prop.value.children)) {
550
+ return { expr: `__slot(() => ${irChildrenToJsExpr(prop.value.children)})`, getter: true }
551
+ }
552
+ // Brand via the shared door (#2651/#2702) — see
553
+ // `jsxChildrenPropGetterExpr`'s docstring.
554
+ return { expr: jsxChildrenPropGetterExpr(prop.value.children, prop.name), getter: true }
555
+ case 'expression':
556
+ case 'template':
557
+ case 'spread':
558
+ return { expr: expandDynamicPropValue(attrValueToString(prop.value)!, ctx), getter: true }
559
+ case 'literal':
560
+ return { expr: JSON.stringify(prop.value.value), getter: false }
561
+ case 'boolean-shorthand':
562
+ case 'boolean-attr':
563
+ // `boolean-attr` should not reach here for component props
564
+ // (processComponentProps promotes it to boolean-shorthand), but handle
565
+ // it defensively.
566
+ return { expr: 'true', getter: false }
567
+ }
568
+ }
569
+
570
+ /**
571
+ * Index of the last spread of the component's own props object in a child
572
+ * component call (`<Tag tone="first" {...props} />`), or -1. An explicit
573
+ * prop written before it is only a default: the spread overrides it when
574
+ * the caller passed that key, as in JS (#3688). This is the one source-order
575
+ * decision `initChild`'s props and both reactive DOM mirrors
576
+ * (`ctx.reactiveProps`, `ctx.reactiveChildProps`) read, so an overridden
577
+ * explicit expression can't overwrite the spread-selected value on update.
578
+ */
579
+ function lastPropsObjectSpreadIndex(props: IRProp[]): number {
580
+ let at = -1
581
+ props.forEach((p, index) => {
582
+ if (p.value.kind === 'spread' && p.value.propsObject === true) at = index
583
+ })
584
+ return at
585
+ }
586
+
587
+ /**
588
+ * The value of an explicit prop a later props-object spread overrides (see
589
+ * `lastPropsObjectSpreadIndex`): the caller's own value when it passed the
590
+ * key, `expr` otherwise. `forwardProps` lets every override win, so the
591
+ * merge is spelled into the value itself.
592
+ */
593
+ function callerFirstPropExpr(name: string, expr: string): string {
594
+ const key = JSON.stringify(name)
595
+ return `(${key} in ${PROPS_PARAM} ? ${PROPS_PARAM}[${key}] : ${expr})`
596
+ }
597
+
598
+ /**
599
+ * The merged value of the explicit prop at `index` for a reactive DOM
600
+ * mirror: caller-first when a later props-object spread (at `spreadAt`, see
601
+ * `lastPropsObjectSpreadIndex`) overrides it, `expr` as written otherwise.
602
+ */
603
+ function mergedMirrorExpr(name: string, expr: string, index: number, spreadAt: number): string {
604
+ return index < spreadAt ? callerFirstPropExpr(name, expr) : expr
605
+ }
606
+
520
607
  /** Build propsExpr for a child component from its IR props. */
521
608
  function buildComponentPropsExpr(props: IRProp[], ctx: ClientJsContext): string {
522
609
  const knownSpreadProp = props.find(p => {
@@ -528,52 +615,21 @@ function buildComponentPropsExpr(props: IRProp[], ctx: ClientJsContext): string
528
615
  return resolveRestSpreadOrigin(ctx, expr) !== null
529
616
  })
530
617
  const spreadSource = knownSpreadProp ? PROPS_PARAM : null
618
+ const spreadAt = lastPropsObjectSpreadIndex(props)
531
619
 
532
620
  const propsForInit: string[] = []
533
621
  const explicitPropNames: string[] = []
534
- for (const prop of props) {
535
- if (prop.name === '...' || prop.name.startsWith('...')) continue
622
+ props.forEach((prop, index) => {
623
+ if (prop.name === '...' || prop.name.startsWith('...')) return
536
624
  explicitPropNames.push(prop.name)
537
- const isEventHandler = isEventHandlerName(prop.name)
538
- if (isEventHandler) {
539
- // Event handlers reach here only as `expression` variants.
540
- propsForInit.push(`${quotePropName(prop.name)}: ${attrValueToString(prop.value) ?? prop.name}`)
541
- continue
542
- }
543
- switch (prop.value.kind) {
544
- case 'jsx-children': {
545
- if (jsxChildrenContainComponent(prop.value.children)) {
546
- const jsxExpr = irChildrenToJsExpr(prop.value.children)
547
- propsForInit.push(`get ${quotePropName(prop.name)}() { return __slot(() => ${jsxExpr}) }`)
548
- } else {
549
- // Brand via the shared door (#2651/#2702) — see
550
- // `jsxChildrenPropGetterExpr`'s docstring.
551
- const jsxExpr = jsxChildrenPropGetterExpr(prop.value.children, prop.name)
552
- propsForInit.push(`get ${quotePropName(prop.name)}() { return ${jsxExpr} }`)
553
- }
554
- break
555
- }
556
- case 'expression':
557
- case 'template':
558
- case 'spread': {
559
- const valueExpr = attrValueToString(prop.value)!
560
- const expandedValue = expandDynamicPropValue(valueExpr, ctx)
561
- propsForInit.push(`get ${quotePropName(prop.name)}() { return ${expandedValue} }`)
562
- break
563
- }
564
- case 'literal':
565
- propsForInit.push(`${quotePropName(prop.name)}: ${JSON.stringify(prop.value.value)}`)
566
- break
567
- case 'boolean-shorthand':
568
- propsForInit.push(`${quotePropName(prop.name)}: true`)
569
- break
570
- case 'boolean-attr':
571
- // Should not reach here for component props (processComponentProps
572
- // promotes to boolean-shorthand), but handle defensively.
573
- propsForInit.push(`${quotePropName(prop.name)}: true`)
574
- break
625
+ const key = quotePropName(prop.name)
626
+ const { expr, getter } = componentInitPropValue(prop, ctx)
627
+ if (index < spreadAt) {
628
+ propsForInit.push(`get ${key}() { return ${callerFirstPropExpr(prop.name, expr)} }`)
629
+ } else {
630
+ propsForInit.push(getter ? `get ${key}() { return ${expr} }` : `${key}: ${expr}`)
575
631
  }
576
- }
632
+ })
577
633
 
578
634
  if (spreadSource) {
579
635
  const overrides = propsForInit.length > 0 ? `{ ${propsForInit.join(', ')} }` : '{}'
@@ -589,7 +645,8 @@ function buildComponentPropsExpr(props: IRProp[], ctx: ClientJsContext): string
589
645
  * side-effect helper so `buildComponentPropsExpr` stays a pure function.
590
646
  */
591
647
  function collectReactiveChildProps(node: IRComponent, ctx: ClientJsContext): void {
592
- for (const prop of node.props) {
648
+ const spreadAt = lastPropsObjectSpreadIndex(node.props)
649
+ for (const [index, prop] of node.props.entries()) {
593
650
  if (prop.name === '...' || prop.name.startsWith('...')) continue
594
651
  if (prop.value.kind === 'jsx-children') continue
595
652
  // `classifyDOMProp` is the single source of truth for "how does this prop
@@ -629,7 +686,7 @@ function collectReactiveChildProps(node: IRComponent, ctx: ClientJsContext): voi
629
686
  slotId: node.slotId,
630
687
  propName: prop.name,
631
688
  attrName,
632
- expression: expandedValue,
689
+ expression: mergedMirrorExpr(prop.name, expandedValue, index, spreadAt),
633
690
  ...pickAttrMetaFromIR(prop),
634
691
  })
635
692
  }
@@ -971,7 +1028,7 @@ export function collectElements(
971
1028
  nestedComponents: l.nestedComponents,
972
1029
  isStaticArray: clientIsStaticArray,
973
1030
  useElementReconciliation,
974
- innerLoops: (useElementReconciliation || (l.isStaticArray && innerLoops?.length)) ? innerLoops : undefined,
1031
+ innerLoops: keepsInnerLoops(l, useElementReconciliation, innerLoops) ? innerLoops : undefined,
975
1032
  offset: resolveLoopOffset(siblingOffsets.get(l)),
976
1033
  filterPredicate: l.filterPredicate ? {
977
1034
  param: l.filterPredicate.param,
@@ -1004,7 +1061,8 @@ export function collectElements(
1004
1061
  component: ({ node: c, descend, descendJsxChildren }) => {
1005
1062
  if (c.slotId) {
1006
1063
  // Reactive props need effects to update the element when values change.
1007
- for (const prop of c.props) {
1064
+ const spreadAt = lastPropsObjectSpreadIndex(c.props)
1065
+ for (const [index, prop] of c.props.entries()) {
1008
1066
  if (prop.value.kind === 'jsx-children') continue
1009
1067
  if (isEventHandlerName(prop.name)) continue
1010
1068
  // Only `expression` variants reach the signal/memo getter heuristic
@@ -1020,7 +1078,7 @@ export function collectElements(
1020
1078
  ctx.reactiveProps.push({
1021
1079
  slotId: c.slotId,
1022
1080
  propName: prop.name,
1023
- expression: fnName,
1081
+ expression: mergedMirrorExpr(prop.name, value, index, spreadAt),
1024
1082
  componentName: c.name,
1025
1083
  })
1026
1084
  }