@barefootjs/jsx 0.34.0 → 0.35.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 (148) hide show
  1. package/dist/analyzer-context.d.ts.map +1 -1
  2. package/dist/analyzer.d.ts.map +1 -1
  3. package/dist/index.d.ts +2 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1072 -903
  6. package/dist/ir-to-client-js/collect-elements.d.ts +22 -2
  7. package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
  8. package/dist/ir-to-client-js/control-flow/plan/build-branch-loop.d.ts.map +1 -1
  9. package/dist/ir-to-client-js/control-flow/plan/build-component-loop.d.ts.map +1 -1
  10. package/dist/ir-to-client-js/control-flow/plan/build-composite-loop.d.ts.map +1 -1
  11. package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts +14 -2
  12. package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts.map +1 -1
  13. package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts +11 -0
  14. package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts.map +1 -1
  15. package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts +6 -1
  16. package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts.map +1 -1
  17. package/dist/ir-to-client-js/control-flow/plan/build-loop.d.ts.map +1 -1
  18. package/dist/ir-to-client-js/control-flow/plan/build-plain-row.d.ts +52 -0
  19. package/dist/ir-to-client-js/control-flow/plan/build-plain-row.d.ts.map +1 -0
  20. package/dist/ir-to-client-js/control-flow/plan/build-reactive-effects.d.ts +5 -2
  21. package/dist/ir-to-client-js/control-flow/plan/build-reactive-effects.d.ts.map +1 -1
  22. package/dist/ir-to-client-js/control-flow/plan/inner-loop.d.ts +24 -44
  23. package/dist/ir-to-client-js/control-flow/plan/inner-loop.d.ts.map +1 -1
  24. package/dist/ir-to-client-js/control-flow/plan/lazy-conditional.d.ts +6 -7
  25. package/dist/ir-to-client-js/control-flow/plan/lazy-conditional.d.ts.map +1 -1
  26. package/dist/ir-to-client-js/control-flow/plan/lazy-preamble.d.ts +5 -7
  27. package/dist/ir-to-client-js/control-flow/plan/lazy-preamble.d.ts.map +1 -1
  28. package/dist/ir-to-client-js/control-flow/plan/lazy-row-eligibility.d.ts.map +1 -1
  29. package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts +14 -0
  30. package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts.map +1 -1
  31. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts +10 -6
  32. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts.map +1 -1
  33. package/dist/ir-to-client-js/control-flow/shared.d.ts +11 -9
  34. package/dist/ir-to-client-js/control-flow/shared.d.ts.map +1 -1
  35. package/dist/ir-to-client-js/control-flow/stringify/composite-loop.d.ts.map +1 -1
  36. package/dist/ir-to-client-js/control-flow/stringify/inner-loop.d.ts +6 -14
  37. package/dist/ir-to-client-js/control-flow/stringify/inner-loop.d.ts.map +1 -1
  38. package/dist/ir-to-client-js/control-flow/stringify/lazy-row.d.ts +1 -3
  39. package/dist/ir-to-client-js/control-flow/stringify/lazy-row.d.ts.map +1 -1
  40. package/dist/ir-to-client-js/control-flow/stringify/loop-child-arm.d.ts +19 -3
  41. package/dist/ir-to-client-js/control-flow/stringify/loop-child-arm.d.ts.map +1 -1
  42. package/dist/ir-to-client-js/control-flow/stringify/loop.d.ts.map +1 -1
  43. package/dist/ir-to-client-js/control-flow/stringify/reactive-effects.d.ts +5 -1
  44. package/dist/ir-to-client-js/control-flow/stringify/reactive-effects.d.ts.map +1 -1
  45. package/dist/ir-to-client-js/csr-substitute.d.ts +16 -0
  46. package/dist/ir-to-client-js/csr-substitute.d.ts.map +1 -1
  47. package/dist/ir-to-client-js/emit-reactive.d.ts +54 -0
  48. package/dist/ir-to-client-js/emit-reactive.d.ts.map +1 -1
  49. package/dist/ir-to-client-js/emit-registration.d.ts.map +1 -1
  50. package/dist/ir-to-client-js/html-template.d.ts +2 -2
  51. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  52. package/dist/ir-to-client-js/imports.d.ts +2 -2
  53. package/dist/ir-to-client-js/imports.d.ts.map +1 -1
  54. package/dist/ir-to-client-js/index.d.ts.map +1 -1
  55. package/dist/ir-to-client-js/markup-slots.d.ts +21 -0
  56. package/dist/ir-to-client-js/markup-slots.d.ts.map +1 -0
  57. package/dist/ir-to-client-js/reactivity.d.ts +62 -18
  58. package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
  59. package/dist/ir-to-client-js/safe-html.d.ts +158 -0
  60. package/dist/ir-to-client-js/safe-html.d.ts.map +1 -0
  61. package/dist/ir-to-client-js/types.d.ts +18 -2
  62. package/dist/ir-to-client-js/types.d.ts.map +1 -1
  63. package/dist/ir-to-client-js/utils.d.ts +34 -1
  64. package/dist/ir-to-client-js/utils.d.ts.map +1 -1
  65. package/dist/jsx-to-ir.d.ts.map +1 -1
  66. package/dist/prop-rewrite.d.ts +8 -3
  67. package/dist/prop-rewrite.d.ts.map +1 -1
  68. package/dist/props-binding.d.ts +22 -1
  69. package/dist/props-binding.d.ts.map +1 -1
  70. package/dist/reactivity-checker.d.ts +18 -0
  71. package/dist/reactivity-checker.d.ts.map +1 -1
  72. package/dist/ssr-defaults.d.ts.map +1 -1
  73. package/dist/types.d.ts +5 -10
  74. package/dist/types.d.ts.map +1 -1
  75. package/package.json +2 -2
  76. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +138 -22
  77. package/src/__tests__/binding-scope-ratchet.test.ts +25 -2
  78. package/src/__tests__/build-plain-row-consolidation.test.ts +120 -0
  79. package/src/__tests__/child-prop-fallback-wrap.test.ts +4 -2
  80. package/src/__tests__/client-template-escape-soundness.test.ts +538 -0
  81. package/src/__tests__/compiler-stress-1244.test.ts +8 -8
  82. package/src/__tests__/csr-template-loop-shadowing.test.ts +4 -2
  83. package/src/__tests__/flatmap-segments.test.ts +1 -1
  84. package/src/__tests__/issue-2868-cond-arm-tag-collision.test.ts +185 -0
  85. package/src/__tests__/issue-2869-attr-dedup-guard.test.ts +141 -0
  86. package/src/__tests__/lazy-conditional.test.ts +52 -12
  87. package/src/__tests__/lazy-preamble.test.ts +11 -11
  88. package/src/__tests__/lazy-row-eligibility.test.ts +8 -3
  89. package/src/__tests__/loop-child-reactive-attr-const-shadow.test.ts +25 -3
  90. package/src/__tests__/loop-index-reactivity.test.ts +208 -0
  91. package/src/__tests__/loop-item-conditional-codegen.test.ts +4 -2
  92. package/src/__tests__/map-arbitrary-body.test.ts +1 -1
  93. package/src/__tests__/map-body-brand-checker.test.ts +176 -0
  94. package/src/__tests__/nested-loop-index-param.test.ts +41 -8
  95. package/src/__tests__/nested-loop-non-outer-reactivity.test.ts +177 -0
  96. package/src/__tests__/nested-loop-plain.test.ts +39 -25
  97. package/src/__tests__/nested-loop-reactive-attrs.test.ts +16 -6
  98. package/src/__tests__/preamble-branch-arm-rerun.test.ts +135 -0
  99. package/src/__tests__/reactive-attrs-in-map.test.ts +13 -10
  100. package/src/__tests__/rewrite-destructured-props.test.ts +37 -0
  101. package/src/__tests__/safe-html-splice-door.test.ts +61 -0
  102. package/src/__tests__/ssr-defaults.test.ts +59 -0
  103. package/src/__tests__/style-css-var-reactive.test.ts +4 -1
  104. package/src/analyzer-context.ts +12 -10
  105. package/src/analyzer.ts +4 -0
  106. package/src/index.ts +8 -2
  107. package/src/ir-to-client-js/collect-elements.ts +126 -32
  108. package/src/ir-to-client-js/control-flow/plan/build-branch-loop.ts +20 -28
  109. package/src/ir-to-client-js/control-flow/plan/build-component-loop.ts +9 -7
  110. package/src/ir-to-client-js/control-flow/plan/build-composite-loop.ts +12 -6
  111. package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +36 -59
  112. package/src/ir-to-client-js/control-flow/plan/build-lazy-row.ts +25 -4
  113. package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +36 -9
  114. package/src/ir-to-client-js/control-flow/plan/build-loop.ts +35 -35
  115. package/src/ir-to-client-js/control-flow/plan/build-plain-row.ts +116 -0
  116. package/src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts +23 -8
  117. package/src/ir-to-client-js/control-flow/plan/inner-loop.ts +24 -45
  118. package/src/ir-to-client-js/control-flow/plan/lazy-conditional.ts +11 -10
  119. package/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts +11 -13
  120. package/src/ir-to-client-js/control-flow/plan/lazy-row-eligibility.ts +13 -3
  121. package/src/ir-to-client-js/control-flow/plan/loop-child-arm.ts +14 -0
  122. package/src/ir-to-client-js/control-flow/plan/loop.ts +10 -6
  123. package/src/ir-to-client-js/control-flow/shared.ts +40 -17
  124. package/src/ir-to-client-js/control-flow/stringify/composite-loop.ts +2 -1
  125. package/src/ir-to-client-js/control-flow/stringify/inner-loop.ts +20 -66
  126. package/src/ir-to-client-js/control-flow/stringify/insert.ts +4 -2
  127. package/src/ir-to-client-js/control-flow/stringify/lazy-row.ts +22 -15
  128. package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +53 -11
  129. package/src/ir-to-client-js/control-flow/stringify/loop.ts +4 -2
  130. package/src/ir-to-client-js/control-flow/stringify/reactive-effects.ts +29 -18
  131. package/src/ir-to-client-js/csr-substitute.ts +29 -0
  132. package/src/ir-to-client-js/emit-reactive.ts +92 -6
  133. package/src/ir-to-client-js/emit-registration.ts +2 -4
  134. package/src/ir-to-client-js/html-template.ts +67 -245
  135. package/src/ir-to-client-js/imports.ts +3 -0
  136. package/src/ir-to-client-js/index.ts +4 -4
  137. package/src/ir-to-client-js/markup-slots.ts +25 -0
  138. package/src/ir-to-client-js/reactivity.ts +73 -27
  139. package/src/ir-to-client-js/safe-html.ts +243 -0
  140. package/src/ir-to-client-js/types.ts +19 -3
  141. package/src/ir-to-client-js/utils.ts +58 -10
  142. package/src/jsx-to-ir.ts +136 -24
  143. package/src/prop-rewrite.ts +8 -4
  144. package/src/props-binding.ts +37 -1
  145. package/src/reactivity-checker.ts +60 -0
  146. package/src/ssr-defaults.ts +45 -0
  147. package/src/types.ts +5 -10
  148. package/src/__tests__/text-slot-escaping.test.ts +0 -65
package/dist/index.js CHANGED
@@ -180,7 +180,7 @@ function findTopLevelTemplateLiterals(code) {
180
180
  import ts25 from "typescript";
181
181
 
182
182
  // src/analyzer.ts
183
- import ts10 from "typescript";
183
+ import ts11 from "typescript";
184
184
 
185
185
  // src/expression-parser.ts
186
186
  import ts2 from "typescript";
@@ -2689,12 +2689,22 @@ function renderLoopBindingAccess(b, base) {
2689
2689
  }
2690
2690
  return parent;
2691
2691
  }
2692
- function wrapLoopParamAsAccessor(expr, paramName, bindings) {
2692
+ function wrapLoopParamAsAccessor(expr, paramName, bindings, indexParam) {
2693
+ let result;
2693
2694
  if (bindings && bindings.length > 0) {
2694
- return rewriteLoopBindingRefs(expr, bindings, "__bfItem()");
2695
+ result = rewriteLoopBindingRefs(expr, bindings, "__bfItem()");
2696
+ } else {
2697
+ const re = new RegExp(`${ID_BOUNDARY_BEFORE}${escapeIdentifierForRegex(paramName)}(?!\\s*\\()(?!-)${ID_BOUNDARY_AFTER}`, "gu");
2698
+ result = replaceInExprContexts(expr, re, () => `${paramName}()`);
2695
2699
  }
2696
- const re = new RegExp(`${ID_BOUNDARY_BEFORE}${escapeIdentifierForRegex(paramName)}(?!\\s*\\()(?!-)${ID_BOUNDARY_AFTER}`, "gu");
2697
- return replaceInExprContexts(expr, re, () => `${paramName}()`);
2700
+ if (indexParam && indexParam !== paramName) {
2701
+ result = wrapIndexParamAsAccessor(result, indexParam);
2702
+ }
2703
+ return result;
2704
+ }
2705
+ function wrapIndexParamAsAccessor(expr, indexParam) {
2706
+ const re = new RegExp(`${ID_BOUNDARY_BEFORE}${escapeIdentifierForRegex(indexParam)}(?!\\s*\\()(?!-)${ID_BOUNDARY_AFTER}`, "gu");
2707
+ return replaceInExprContexts(expr, re, () => `${indexParam}()`);
2698
2708
  }
2699
2709
  function rewriteLoopBindingRefs(expr, bindings, accessor) {
2700
2710
  const byName = new Map;
@@ -2741,7 +2751,7 @@ function wrapExprWithLoopParams(expr, loopParams) {
2741
2751
  let result = expr;
2742
2752
  for (const p of loopParams) {
2743
2753
  const spec = typeof p === "string" ? { param: p } : p;
2744
- result = wrapLoopParamAsAccessor(result, spec.param, spec.bindings);
2754
+ result = wrapLoopParamAsAccessor(result, spec.param, spec.bindings, spec.index);
2745
2755
  }
2746
2756
  return result;
2747
2757
  }
@@ -3028,6 +3038,20 @@ function buildPropAliasMap(params) {
3028
3038
  }
3029
3039
  return map;
3030
3040
  }
3041
+ function resolveBodyDestructuredPropAliases(localConstants, propsObjectName) {
3042
+ const aliases = new Map;
3043
+ if (propsObjectName === null)
3044
+ return aliases;
3045
+ for (const c of localConstants) {
3046
+ if (c.isModule)
3047
+ continue;
3048
+ const m = c.parsed;
3049
+ if (m?.kind === "member" && !m.computed && m.object.kind === "identifier" && m.object.name === propsObjectName) {
3050
+ aliases.set(c.name, m.property);
3051
+ }
3052
+ }
3053
+ return aliases;
3054
+ }
3031
3055
  function boundPropLocalNames(b) {
3032
3056
  if (b.propsObjectName !== null)
3033
3057
  return EMPTY_SET;
@@ -3260,6 +3284,18 @@ function resolveGetterAliases(localConstants, isGetter) {
3260
3284
  }
3261
3285
  return aliases;
3262
3286
  }
3287
+ function collectAliasableGetterNames(signals, memos) {
3288
+ const getterNames = new Set;
3289
+ for (const sig of signals) {
3290
+ if (sig.getter && !sig.isModule && !sig.envReader)
3291
+ getterNames.add(sig.getter);
3292
+ }
3293
+ for (const memo of memos) {
3294
+ if (!memo.isModule)
3295
+ getterNames.add(memo.name);
3296
+ }
3297
+ return getterNames;
3298
+ }
3263
3299
  function buildSignalMemoEnv(signals, memos, propsObjectName, localConstants = []) {
3264
3300
  const substitutions = new Map;
3265
3301
  for (const s of signals) {
@@ -3439,6 +3475,65 @@ class BindingScope {
3439
3475
  }
3440
3476
  }
3441
3477
 
3478
+ // src/ir-to-client-js/safe-html.ts
3479
+ function safeHtml(expr) {
3480
+ return expr;
3481
+ }
3482
+ function interp(span) {
3483
+ return `\${${span}}`;
3484
+ }
3485
+ function escapedText(expr) {
3486
+ return safeHtml(`escapeText(${expr})`);
3487
+ }
3488
+ function escapedTextOrMarkup(expr) {
3489
+ return safeHtml(`escapeTextOrMarkup(${expr})`);
3490
+ }
3491
+ function branchSlotValue(expr, slotsVar) {
3492
+ return safeHtml(`__bfSlot(${expr}, ${slotsVar})`);
3493
+ }
3494
+ function childrenMarkup(expr) {
3495
+ return safeHtml(`markupOrEmpty(${expr})`);
3496
+ }
3497
+ function joinedMarkup(expr) {
3498
+ return safeHtml(`Array.isArray(${expr}) ? ${expr}.join('') : (${expr} ?? '')`);
3499
+ }
3500
+ function renderChildCall(registryName, propsExpr, tailArgs) {
3501
+ return safeHtml(`renderChild('${registryName}', ${propsExpr}${tailArgs})`);
3502
+ }
3503
+ function dangerousInnerHtml(expr) {
3504
+ return safeHtml(`((${expr}) ?? {}).__html ?? ''`);
3505
+ }
3506
+ function conditionalMarkup(condition, whenTrue, whenFalse) {
3507
+ return safeHtml(`${condition} ? \`${whenTrue}\` : \`${whenFalse}\``);
3508
+ }
3509
+ function mappedRowsMarkup(arrayExpr, method, params, body) {
3510
+ return safeHtml(`${arrayExpr}.${method}(${params} => ${body}).join('')`);
3511
+ }
3512
+ var EMPTY_MARKUP = safeHtml("''");
3513
+ function isChildrenPassthroughExpr(expr) {
3514
+ return /^([A-Za-z_$][\w$]*\.)?children$/.test(expr.trim());
3515
+ }
3516
+ function spliceChildValue(node, valueExpr, cx) {
3517
+ if (node.joinArrayChild)
3518
+ return joinedMarkup(valueExpr);
3519
+ if (cx.branchSlotsVar)
3520
+ return branchSlotValue(valueExpr, cx.branchSlotsVar);
3521
+ if (node.slotId) {
3522
+ return cx.markupSlotIds?.has(node.slotId) ? escapedTextOrMarkup(valueExpr) : escapedText(valueExpr);
3523
+ }
3524
+ const resolved = valueExpr.trim().replace(/^\(+|\)+$/g, "");
3525
+ if (isChildrenPassthroughExpr(node.expr) || isChildrenPassthroughExpr(resolved)) {
3526
+ return childrenMarkup(valueExpr);
3527
+ }
3528
+ return escapedText(valueExpr);
3529
+ }
3530
+
3531
+ // src/ir-to-client-js/markup-slots.ts
3532
+ var DYNAMIC_ELEMENT_WRITER_KIND = "markup";
3533
+ function markupSlotIdsOf(ctx) {
3534
+ return new Set(ctx.dynamicElements.map((e) => e.slotId));
3535
+ }
3536
+
3442
3537
  // src/ir-to-client-js/html-template.ts
3443
3538
  function createStringProtector() {
3444
3539
  const strings = [];
@@ -3608,22 +3703,11 @@ function templateAttrExpr(attrName, valExpr, presenceOrUndefined) {
3608
3703
  function escapeAttrValueExpr(valExpr) {
3609
3704
  return `escapeAttr(${valExpr})`;
3610
3705
  }
3611
- function escapeTextSlotExpr(innerExpr, isMarkup = false) {
3612
- return `${isMarkup ? "escapeTextOrMarkup" : "escapeText"}(${innerExpr})`;
3613
- }
3614
- function isChildrenPassthroughExpr(expr) {
3615
- return /^([A-Za-z_$][\w$]*\.)?children$/.test(expr.trim());
3616
- }
3617
- function bareSpliceExpr(node, valueExpr) {
3618
- const resolved = valueExpr.trim().replace(/^\(+|\)+$/g, "");
3619
- const isChildren = isChildrenPassthroughExpr(node.expr) || isChildrenPassthroughExpr(resolved);
3620
- return !node.joinArrayChild && isChildren ? `markupOrEmpty(${valueExpr})` : valueExpr;
3621
- }
3622
3706
  function dangerouslyHtmlChildren(attrs, toExpr) {
3623
3707
  const attr = attrs.find((a) => a.name === "dangerouslySetInnerHTML");
3624
3708
  if (!attr || attr.value.kind !== "expression")
3625
3709
  return null;
3626
- return `\${((${toExpr(attr.value)}) ?? {}).__html ?? ''}`;
3710
+ return interp(dangerousInnerHtml(toExpr(attr.value)));
3627
3711
  }
3628
3712
  function transformKeyValue(value, transformExpr) {
3629
3713
  switch (value.kind) {
@@ -3739,7 +3823,7 @@ function buildSpreadAttrsMergeCall(args) {
3739
3823
  return `\${spreadAttrs({${objMembers.join(", ")}})}`;
3740
3824
  }
3741
3825
  function itemAnchorTemplate(keyExpr) {
3742
- return `<!--${loopItemMarker("${" + keyExpr + "}")}-->`;
3826
+ return `<!--${loopItemMarker("${escapeCommentText(" + keyExpr + ")}")}-->`;
3743
3827
  }
3744
3828
  function renderPreamble(preamble, opts) {
3745
3829
  let out = "";
@@ -3748,9 +3832,9 @@ function renderPreamble(preamble, opts) {
3748
3832
  const text = opts.textVariant === "template" ? seg.templateText ?? seg.text : seg.text;
3749
3833
  out += opts.transformJs ? opts.transformJs(text) : text;
3750
3834
  } else if (opts.rawLeaf) {
3751
- out += opts.renderLeaf(escapeLeafTextExpressions(seg.ir));
3835
+ out += opts.renderLeaf(seg.ir);
3752
3836
  } else {
3753
- out += "`" + opts.renderLeaf(escapeLeafTextExpressions(seg.ir)) + "`";
3837
+ out += "`" + opts.renderLeaf(seg.ir) + "`";
3754
3838
  }
3755
3839
  }
3756
3840
  return out;
@@ -3795,36 +3879,12 @@ function renderFlatMapProjectionClientBody(inner, restSpreadNames) {
3795
3879
  const chained = applyLoopChain(inner);
3796
3880
  const params = inner.index ? `(${inner.param}, ${inner.index})` : `(${inner.param})`;
3797
3881
  const key = inner.key ? `(${inner.key})` : "undefined";
3798
- const html = inner.children.map((c) => irToHtmlTemplate(escapeLeafTextExpressions(c), restSpreadNames, 1, undefined, undefined)).join("");
3882
+ const html = inner.children.map((c) => irToHtmlTemplate(c, restSpreadNames, 1, undefined, undefined)).join("");
3799
3883
  return `${chained}.map(${params} => ({ k: ${key}, h: \`${html}\` }))`;
3800
3884
  }
3801
- function escapeLeafTextExpressions(ir) {
3802
- switch (ir.type) {
3803
- case "element":
3804
- return { ...ir, children: ir.children.map(escapeLeafTextExpressions) };
3805
- case "fragment":
3806
- return { ...ir, children: ir.children.map(escapeLeafTextExpressions) };
3807
- case "expression": {
3808
- if (ir.expr === "null" || ir.expr === "undefined")
3809
- return ir;
3810
- if (ir.slotId || ir.expr.trimStart().startsWith("escapeText("))
3811
- return ir;
3812
- return { ...ir, expr: `escapeText((${ir.expr}))`, templateExpr: ir.templateExpr ? `escapeText((${ir.templateExpr}))` : ir.templateExpr };
3813
- }
3814
- case "conditional":
3815
- return {
3816
- ...ir,
3817
- whenTrue: escapeLeafTextExpressions(ir.whenTrue),
3818
- whenFalse: ir.whenFalse ? escapeLeafTextExpressions(ir.whenFalse) : ir.whenFalse
3819
- };
3820
- default:
3821
- return ir;
3822
- }
3823
- }
3824
3885
  function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, branchSlotsVar, inHoistedChildren = false) {
3825
3886
  const recurse = (n) => irToHtmlTemplate(n, restSpreadNames, loopDepth, loopParams, branchSlotsVar, inHoistedChildren);
3826
3887
  const wrapExpr = (expr) => wrapExprWithLoopParams(expr, loopParams);
3827
- const wrapInterpolation = (expr) => branchSlotsVar ? `__bfSlot(${expr}, ${branchSlotsVar})` : expr;
3828
3888
  switch (node.type) {
3829
3889
  case "element": {
3830
3890
  const mergeCtx = {
@@ -3870,25 +3930,17 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3870
3930
  case "expression": {
3871
3931
  if (node.expr === "null" || node.expr === "undefined")
3872
3932
  return "";
3873
- const escapeForClient = (e) => node.escapeInClientTemplate ? `escapeText(${e})` : e;
3874
- if (node.markerless) {
3875
- const bare = escapeForClient(wrapInterpolation(wrapExpr(node.expr)));
3876
- return `\${${bare}}`;
3877
- }
3878
- const inner = escapeForClient(wrapInterpolation(wrapExpr(node.expr)));
3879
- const valueExpr = node.joinArrayChild ? `Array.isArray(${inner}) ? ${inner}.join('') : (${inner} ?? '')` : inner;
3880
- if (node.slotId) {
3881
- const slotted = branchSlotsVar || node.joinArrayChild ? valueExpr : escapeTextSlotExpr(valueExpr);
3882
- return `<!--bf:${node.slotId}-->\${${slotted}}<!--/-->`;
3883
- }
3884
- return `\${${bareSpliceExpr(node, valueExpr)}}`;
3933
+ const hole = interp(spliceChildValue(node, wrapExpr(node.expr), { branchSlotsVar }));
3934
+ if (node.markerless)
3935
+ return hole;
3936
+ return node.slotId ? `<!--bf:${node.slotId}-->${hole}<!--/-->` : hole;
3885
3937
  }
3886
3938
  case "conditional": {
3887
3939
  const trueBranch = recurse(node.whenTrue);
3888
3940
  const falseBranch = recurse(node.whenFalse);
3889
3941
  const trueHtml = node.slotId ? addCondAttrToTemplate(trueBranch, node.slotId) : trueBranch;
3890
3942
  const falseHtml = node.slotId ? addCondAttrToTemplate(falseBranch, node.slotId) : falseBranch;
3891
- return `\${${wrapExpr(node.condition)} ? \`${trueHtml}\` : \`${falseHtml}\`}`;
3943
+ return interp(conditionalMarkup(wrapExpr(node.condition), trueHtml, falseHtml));
3892
3944
  }
3893
3945
  case "fragment":
3894
3946
  return node.children.map(recurse).join("");
@@ -3914,7 +3966,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3914
3966
  case "expression":
3915
3967
  case "template":
3916
3968
  case "spread": {
3917
- const expr = attrValueToString(p.value, { useTemplate: true }) ?? "undefined";
3969
+ const expr = wrapExpr(attrValueToString(p.value, { useTemplate: true }) ?? "undefined");
3918
3970
  return `${quotePropName(p.name)}: ${expr}`;
3919
3971
  }
3920
3972
  }
@@ -3925,7 +3977,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3925
3977
  const propsExpr = propsEntries.length > 0 ? `{${propsEntries.join(", ")}}` : "{}";
3926
3978
  const keyProp = node.props.find((p) => p.name === "key");
3927
3979
  const keyArg = keyProp ? `, ${attrValueToString(keyProp.value) ?? "undefined"}` : "";
3928
- return `\${renderChild('${nameForRegistryRef(node.name)}', ${propsExpr}${renderChildScopeArgs(node, keyArg)})}`;
3980
+ return interp(renderChildCall(nameForRegistryRef(node.name), propsExpr, renderChildScopeArgs(node, keyArg)));
3929
3981
  }
3930
3982
  case "loop": {
3931
3983
  const innerRecurse = (n) => irToHtmlTemplate(n, restSpreadNames, loopDepth + 1, loopParams, branchSlotsVar);
@@ -3943,12 +3995,12 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3943
3995
  const body = renderPreamble(node.flatMapCallback, {
3944
3996
  renderLeaf: (ir) => irToHtmlTemplate(stripLeafKeyAttr(ir), restSpreadNames, loopDepth + 1, loopParams, branchSlotsVar)
3945
3997
  });
3946
- mapExpr = `\${${wrappedArray}.flatMap(${node.flatMapCallback.params} => ${body}).join('')}`;
3998
+ mapExpr = interp(mappedRowsMarkup(wrappedArray, "flatMap", node.flatMapCallback.params, body));
3947
3999
  } else if (node.preamble) {
3948
4000
  const preamble = renderPreamble(node.preamble, { textVariant: "client", renderLeaf: (ir) => irToHtmlTemplate(ir, restSpreadNames, loopDepth + 1, loopParams, branchSlotsVar) });
3949
- mapExpr = `\${${wrappedArray}.${iterMethod}(${callbackParam} => { ${preamble} return \`${childTemplate}\` }).join('')}`;
4001
+ mapExpr = interp(mappedRowsMarkup(wrappedArray, iterMethod, callbackParam, `{ ${preamble} return \`${childTemplate}\` }`));
3950
4002
  } else {
3951
- mapExpr = `\${${wrappedArray}.${iterMethod}(${callbackParam} => \`${childTemplate}\`).join('')}`;
4003
+ mapExpr = interp(mappedRowsMarkup(wrappedArray, iterMethod, callbackParam, `\`${childTemplate}\``));
3952
4004
  }
3953
4005
  return `<!--${loopStartMarker(node.markerId)}-->${mapExpr}<!--${loopEndMarker(node.markerId)}-->`;
3954
4006
  }
@@ -4207,20 +4259,15 @@ function irToPlaceholderTemplate(node, restSpreadNames, loopDepth = 0, loopParam
4207
4259
  case "expression": {
4208
4260
  if (node.expr === "null" || node.expr === "undefined")
4209
4261
  return "";
4210
- const wrapped = wrapExpr(node.expr);
4211
- const value = node.joinArrayChild ? `Array.isArray(${wrapped}) ? ${wrapped}.join('') : (${wrapped} ?? '')` : wrapped;
4212
- if (node.slotId) {
4213
- return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(wrapped)}}<!--/-->`;
4214
- }
4215
- const spliced = bareSpliceExpr(node, value);
4216
- return `\${${node.escapeInClientTemplate ? `escapeText(${spliced})` : spliced}}`;
4262
+ const hole = interp(spliceChildValue(node, wrapExpr(node.expr), {}));
4263
+ return node.slotId ? `<!--bf:${node.slotId}-->${hole}<!--/-->` : hole;
4217
4264
  }
4218
4265
  case "conditional": {
4219
4266
  const trueBranch = recurse(node.whenTrue);
4220
4267
  const falseBranch = recurse(node.whenFalse);
4221
4268
  const trueHtml = node.slotId ? addCondAttrToTemplate(trueBranch, node.slotId) : trueBranch;
4222
4269
  const falseHtml = node.slotId ? addCondAttrToTemplate(falseBranch, node.slotId) : falseBranch;
4223
- return `\${${wrapExpr(node.condition)} ? \`${trueHtml}\` : \`${falseHtml}\`}`;
4270
+ return interp(conditionalMarkup(wrapExpr(node.condition), trueHtml, falseHtml));
4224
4271
  }
4225
4272
  case "fragment":
4226
4273
  return node.children.map(recurse).join("");
@@ -4244,12 +4291,12 @@ function irToPlaceholderTemplate(node, restSpreadNames, loopDepth = 0, loopParam
4244
4291
  const body = renderPreamble(node.flatMapCallback, {
4245
4292
  renderLeaf: (ir) => irToPlaceholderTemplate(stripLeafKeyAttr(ir), restSpreadNames, loopDepth + 1, loopParams)
4246
4293
  });
4247
- mapExpr = `\${${wrappedArray}.flatMap(${node.flatMapCallback.params} => ${body}).join('')}`;
4294
+ mapExpr = interp(mappedRowsMarkup(wrappedArray, "flatMap", node.flatMapCallback.params, body));
4248
4295
  } else if (node.preamble) {
4249
4296
  const preamble = renderPreamble(node.preamble, { textVariant: "client", renderLeaf: (ir) => irToPlaceholderTemplate(ir, restSpreadNames, loopDepth + 1, loopParams) });
4250
- mapExpr = `\${${wrappedArray}.${iterMethod}(${callbackParam} => { ${preamble} return \`${childTemplate}\` }).join('')}`;
4297
+ mapExpr = interp(mappedRowsMarkup(wrappedArray, iterMethod, callbackParam, `{ ${preamble} return \`${childTemplate}\` }`));
4251
4298
  } else {
4252
- mapExpr = `\${${wrappedArray}.${iterMethod}(${callbackParam} => \`${childTemplate}\`).join('')}`;
4299
+ mapExpr = interp(mappedRowsMarkup(wrappedArray, iterMethod, callbackParam, `\`${childTemplate}\``));
4253
4300
  }
4254
4301
  return `<!--${loopStartMarker(node.markerId)}-->${mapExpr}<!--${loopEndMarker(node.markerId)}-->`;
4255
4302
  }
@@ -4451,13 +4498,8 @@ function irToComponentTemplateWithOpts(node, opts) {
4451
4498
  return "";
4452
4499
  return `<!--bf:${node.slotId}--><!--/-->`;
4453
4500
  }
4454
- const wrapped = transformExpr(node.expr, node.templateExpr);
4455
- const value = node.joinArrayChild ? `Array.isArray(${wrapped}) ? ${wrapped}.join('') : (${wrapped} ?? '')` : wrapped;
4456
- if (node.slotId) {
4457
- const isMarkup = opts.markupSlotIds?.has(node.slotId) ?? false;
4458
- return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(wrapped, isMarkup)}}<!--/-->`;
4459
- }
4460
- return `\${${bareSpliceExpr(node, value)}}`;
4501
+ const hole = interp(spliceChildValue(node, transformExpr(node.expr, node.templateExpr), { markupSlotIds: opts.markupSlotIds }));
4502
+ return node.slotId ? `<!--bf:${node.slotId}-->${hole}<!--/-->` : hole;
4461
4503
  }
4462
4504
  case "conditional": {
4463
4505
  if (node.clientOnly && node.slotId) {
@@ -4467,7 +4509,7 @@ function irToComponentTemplateWithOpts(node, opts) {
4467
4509
  const falseBranch = recurse(node.whenFalse);
4468
4510
  const trueHtml = node.slotId ? addCondAttrToTemplate(trueBranch, node.slotId) : trueBranch;
4469
4511
  const falseHtml = node.slotId ? addCondAttrToTemplate(falseBranch, node.slotId) : falseBranch;
4470
- return `\${${transformExpr(node.condition, node.templateCondition)} ? \`${trueHtml}\` : \`${falseHtml}\`}`;
4512
+ return interp(conditionalMarkup(transformExpr(node.condition, node.templateCondition), trueHtml, falseHtml));
4471
4513
  }
4472
4514
  case "fragment":
4473
4515
  return node.children.map(recurse).join("");
@@ -4505,7 +4547,7 @@ function irToComponentTemplateWithOpts(node, opts) {
4505
4547
  const propsExpr = propsEntries.length > 0 ? `{${propsEntries.join(", ")}}` : "{}";
4506
4548
  const keyProp = node.props.find((p) => p.name === "key");
4507
4549
  const keyArg = keyProp ? `, ${transformKeyValue(keyProp.value, transformExpr)}` : "";
4508
- return `\${renderChild('${nameForRegistryRef(node.name)}', ${propsExpr}${keyArg})}`;
4550
+ return interp(renderChildCall(nameForRegistryRef(node.name), propsExpr, keyArg));
4509
4551
  }
4510
4552
  case "loop": {
4511
4553
  const innerOpts = { ...opts, loopDepth: loopDepth + 1 };
@@ -4515,7 +4557,7 @@ function irToComponentTemplateWithOpts(node, opts) {
4515
4557
  case "if-statement": {
4516
4558
  const consequent = recurse(node.consequent);
4517
4559
  const alternate = node.alternate ? recurse(node.alternate) : "";
4518
- return `\${${transformExpr(node.condition, node.templateCondition)} ? \`${consequent}\` : \`${alternate}\`}`;
4560
+ return interp(conditionalMarkup(transformExpr(node.condition, node.templateCondition), consequent, alternate));
4519
4561
  }
4520
4562
  case "provider":
4521
4563
  case "async":
@@ -4603,7 +4645,7 @@ function generateCsrTemplate(node, inlinableConstants, ctx, restSpreadNames, pro
4603
4645
  }
4604
4646
  }
4605
4647
  const effectiveUnsafeLocalNames = mergeCsrNullUnsafe(ctx, unsafeLocalNames);
4606
- const markupSlotIds = new Set(ctx.dynamicElements.map((e) => e.slotId));
4648
+ const markupSlotIds = markupSlotIdsOf(ctx);
4607
4649
  return generateCsrTemplateWithOpts(node, { inlinableConstants, restSpreadNames, propsObjectName, csrEnv, unsafeLocalNames: effectiveUnsafeLocalNames, deferredChildSlots, loopDepth: -1, markupSlotIds, restPropsName: ctx.restPropsName });
4608
4650
  }
4609
4651
  function mergeCsrNullUnsafe(ctx, unsafeLocalNames) {
@@ -4802,13 +4844,8 @@ function generateCsrTemplateWithOpts(node, opts) {
4802
4844
  }
4803
4845
  {
4804
4846
  const transformed = transformExpr(node.expr, node.templateExpr);
4805
- const expr = transformed === UNSAFE_TEMPLATE_EXPR ? "''" : transformed;
4806
- const value = node.joinArrayChild ? `Array.isArray(${expr}) ? ${expr}.join('') : (${expr} ?? '')` : expr;
4807
- if (node.slotId) {
4808
- const isMarkup = opts.markupSlotIds?.has(node.slotId) ?? false;
4809
- return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(expr, isMarkup)}}<!--/-->`;
4810
- }
4811
- return `\${${bareSpliceExpr(node, value)}}`;
4847
+ const hole = interp(transformed === UNSAFE_TEMPLATE_EXPR ? EMPTY_MARKUP : spliceChildValue(node, transformed, { markupSlotIds: opts.markupSlotIds }));
4848
+ return node.slotId ? `<!--bf:${node.slotId}-->${hole}<!--/-->` : hole;
4812
4849
  }
4813
4850
  case "conditional": {
4814
4851
  if (node.clientOnly && node.slotId) {
@@ -4818,7 +4855,7 @@ function generateCsrTemplateWithOpts(node, opts) {
4818
4855
  const falseBranch = recurse(node.whenFalse);
4819
4856
  const trueHtml = node.slotId ? addCondAttrToTemplate(trueBranch, node.slotId) : trueBranch;
4820
4857
  const falseHtml = node.slotId ? addCondAttrToTemplate(falseBranch, node.slotId) : falseBranch;
4821
- return `\${${transformExpr(node.condition, node.templateCondition)} ? \`${trueHtml}\` : \`${falseHtml}\`}`;
4858
+ return interp(conditionalMarkup(transformExpr(node.condition, node.templateCondition), trueHtml, falseHtml));
4822
4859
  }
4823
4860
  case "fragment":
4824
4861
  return node.children.map(recurse).join("");
@@ -4867,7 +4904,7 @@ function generateCsrTemplateWithOpts(node, opts) {
4867
4904
  const propsExpr = propsEntries.length > 0 ? `{${propsEntries.join(", ")}}` : "{}";
4868
4905
  const keyProp = node.props.find((p) => p.name === "key");
4869
4906
  const keyArg = keyProp ? `, ${transformKeyValue(keyProp.value, transformExpr)}` : "";
4870
- return `\${renderChild('${nameForRegistryRef(node.name)}', ${propsExpr}${renderChildScopeArgs(node, keyArg)})}`;
4907
+ return interp(renderChildCall(nameForRegistryRef(node.name), propsExpr, renderChildScopeArgs(node, keyArg)));
4871
4908
  }
4872
4909
  case "loop": {
4873
4910
  const childScope = (opts.scope ?? BindingScope.EMPTY).enterLoopRow(node);
@@ -4900,19 +4937,19 @@ function generateCsrTemplateWithOpts(node, opts) {
4900
4937
  transformJs: (t) => rewritePropsObjectRef(t, propsObjectName ?? null, restPropsName ?? null, { enclosingScope: childScope }),
4901
4938
  renderLeaf: (ir) => recurseInLoopBody(stripLeafKeyAttr(ir))
4902
4939
  });
4903
- mapExpr = `\${${iterArrayExpr}.flatMap(${node.flatMapCallback.params} => ${body}).join('')}`;
4940
+ mapExpr = interp(mappedRowsMarkup(iterArrayExpr, "flatMap", node.flatMapCallback.params, body));
4904
4941
  } else if (node.preamble) {
4905
4942
  const preamble = renderPreamble(node.preamble, { textVariant: "template", transformJs: (t) => rewritePropsObjectRef(t, propsObjectName ?? null, restPropsName ?? null, { enclosingScope: childScope }), renderLeaf: (ir) => recurseInLoopBody(ir) });
4906
- mapExpr = `\${${iterArrayExpr}.${iterMethod}(${callbackParam} => { ${preamble} return \`${childTemplate}\` }).join('')}`;
4943
+ mapExpr = interp(mappedRowsMarkup(iterArrayExpr, iterMethod, callbackParam, `{ ${preamble} return \`${childTemplate}\` }`));
4907
4944
  } else {
4908
- mapExpr = `\${${iterArrayExpr}.${iterMethod}(${callbackParam} => \`${childTemplate}\`).join('')}`;
4945
+ mapExpr = interp(mappedRowsMarkup(iterArrayExpr, iterMethod, callbackParam, `\`${childTemplate}\``));
4909
4946
  }
4910
4947
  return `<!--${loopStartMarker(node.markerId)}-->${mapExpr}<!--${loopEndMarker(node.markerId)}-->`;
4911
4948
  }
4912
4949
  case "if-statement": {
4913
4950
  const consequent = recurse(node.consequent);
4914
4951
  const alternate = node.alternate ? recurse(node.alternate) : "";
4915
- return `\${${transformExpr(node.condition, node.templateCondition)} ? \`${consequent}\` : \`${alternate}\`}`;
4952
+ return interp(conditionalMarkup(transformExpr(node.condition, node.templateCondition), consequent, alternate));
4916
4953
  }
4917
4954
  case "provider":
4918
4955
  case "async":
@@ -5013,8 +5050,6 @@ function collectAstPropRefs(node, propNames, out) {
5013
5050
  walkWithScope(node, (n, parent, shadowed) => {
5014
5051
  if (shadowed || !propNames.has(n.text))
5015
5052
  return;
5016
- if (parent && ts7.isShorthandPropertyAssignment(parent) && parent.name === n)
5017
- return;
5018
5053
  if (isNonValuePosition(n, parent))
5019
5054
  return;
5020
5055
  out.add(n.text);
@@ -5116,7 +5151,7 @@ function incrementCounter(key) {
5116
5151
  }
5117
5152
 
5118
5153
  // src/analyzer-context.ts
5119
- import ts9 from "typescript";
5154
+ import ts10 from "typescript";
5120
5155
 
5121
5156
  // src/strip-types.ts
5122
5157
  import ts8 from "typescript";
@@ -5333,6 +5368,140 @@ function findAngleBracketAfter(lastTypeArg, fullText) {
5333
5368
  return -1;
5334
5369
  }
5335
5370
 
5371
+ // src/reactivity-checker.ts
5372
+ import ts9 from "typescript";
5373
+ var REACTIVE_BRAND = "__reactive";
5374
+ function queryType(checker, node) {
5375
+ incrementCounter("typeCheckerQueries");
5376
+ return checker.getTypeAtLocation(node);
5377
+ }
5378
+ function isReactiveType(type) {
5379
+ return type.getProperty(REACTIVE_BRAND) !== undefined;
5380
+ }
5381
+ var NOT_REACTIVE = { isReactive: false, reason: { kind: "not-reactive" } };
5382
+ function safeGetText(node) {
5383
+ try {
5384
+ return node.getText();
5385
+ } catch {
5386
+ return "";
5387
+ }
5388
+ }
5389
+ function analyze(node, checker) {
5390
+ if (ts9.isPropertyAccessExpression(node)) {
5391
+ try {
5392
+ const type = queryType(checker, node);
5393
+ if (isReactiveType(type)) {
5394
+ return {
5395
+ isReactive: true,
5396
+ reason: { kind: "brand", via: "property-access", nodeText: safeGetText(node) }
5397
+ };
5398
+ }
5399
+ } catch {}
5400
+ const sub = analyze(node.expression, checker);
5401
+ if (sub.isReactive) {
5402
+ return {
5403
+ isReactive: true,
5404
+ reason: {
5405
+ kind: "child",
5406
+ via: "property-access-object",
5407
+ childText: safeGetText(node.expression),
5408
+ childReason: sub.reason
5409
+ }
5410
+ };
5411
+ }
5412
+ return NOT_REACTIVE;
5413
+ }
5414
+ if (ts9.isIdentifier(node)) {
5415
+ try {
5416
+ const type = queryType(checker, node);
5417
+ if (isReactiveType(type)) {
5418
+ return {
5419
+ isReactive: true,
5420
+ reason: { kind: "brand", via: "identifier", nodeText: safeGetText(node) }
5421
+ };
5422
+ }
5423
+ } catch {}
5424
+ return NOT_REACTIVE;
5425
+ }
5426
+ if (ts9.isCallExpression(node)) {
5427
+ try {
5428
+ const calleeType = queryType(checker, node.expression);
5429
+ if (isReactiveType(calleeType)) {
5430
+ return {
5431
+ isReactive: true,
5432
+ reason: { kind: "brand", via: "callee", nodeText: safeGetText(node) }
5433
+ };
5434
+ }
5435
+ } catch {}
5436
+ }
5437
+ let foundChild;
5438
+ let foundChildText = "";
5439
+ ts9.forEachChild(node, (child) => {
5440
+ if (foundChild?.isReactive)
5441
+ return;
5442
+ const result = analyze(child, checker);
5443
+ if (result.isReactive) {
5444
+ foundChild = result;
5445
+ foundChildText = safeGetText(child);
5446
+ }
5447
+ });
5448
+ if (foundChild?.isReactive) {
5449
+ return {
5450
+ isReactive: true,
5451
+ reason: {
5452
+ kind: "child",
5453
+ via: "sub-expression",
5454
+ childText: foundChildText,
5455
+ childReason: foundChild.reason
5456
+ }
5457
+ };
5458
+ }
5459
+ return NOT_REACTIVE;
5460
+ }
5461
+ var brandTypeReactivityAnalyzer = { analyze };
5462
+ function containsReactiveExpression(node, checker) {
5463
+ incrementCounter("reactivityChecks");
5464
+ return brandTypeReactivityAnalyzer.analyze(node, checker).isReactive;
5465
+ }
5466
+ function nodeContainsJsx(node) {
5467
+ if (ts9.isJsxElement(node) || ts9.isJsxSelfClosingElement(node) || ts9.isJsxFragment(node))
5468
+ return true;
5469
+ return ts9.forEachChild(node, nodeContainsJsx) ?? false;
5470
+ }
5471
+ function collectReactiveBrandLeaves(node, checker) {
5472
+ const leaves = [];
5473
+ const visit = (n) => {
5474
+ if (ts9.isPropertyAccessExpression(n)) {
5475
+ try {
5476
+ if (isReactiveType(queryType(checker, n))) {
5477
+ leaves.push(n);
5478
+ return;
5479
+ }
5480
+ } catch {}
5481
+ visit(n.expression);
5482
+ return;
5483
+ }
5484
+ if (ts9.isIdentifier(n)) {
5485
+ try {
5486
+ if (isReactiveType(queryType(checker, n)))
5487
+ leaves.push(n);
5488
+ } catch {}
5489
+ return;
5490
+ }
5491
+ if (ts9.isCallExpression(n)) {
5492
+ try {
5493
+ if (isReactiveType(queryType(checker, n.expression))) {
5494
+ leaves.push(nodeContainsJsx(n) ? n.expression : n);
5495
+ return;
5496
+ }
5497
+ } catch {}
5498
+ }
5499
+ ts9.forEachChild(n, visit);
5500
+ };
5501
+ visit(node);
5502
+ return leaves;
5503
+ }
5504
+
5336
5505
  // src/analyzer-context.ts
5337
5506
  function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
5338
5507
  return {
@@ -5384,7 +5553,7 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
5384
5553
  } catch {
5385
5554
  ownSourceFile = undefined;
5386
5555
  }
5387
- if (process.env.BF_ASSERT_NO_JSX_IN_GETJS === "1" && this.errors.length === 0 && nodeContainsJsx(node)) {
5556
+ if (process.env.BF_ASSERT_NO_JSX_IN_GETJS === "1" && !this.errors.some((e) => e.severity === "error") && nodeContainsJsx(node)) {
5388
5557
  throw new Error("getJS() called on a JSX-bearing node — raw JSX must never be spliced " + "into emitted output. Carry mixed content as structured segments " + "(MapCallbackPreamble / FlatMapCallback) instead.");
5389
5558
  }
5390
5559
  if (ownSourceFile && ownSourceFile !== sourceFile) {
@@ -5394,11 +5563,6 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
5394
5563
  }
5395
5564
  };
5396
5565
  }
5397
- function nodeContainsJsx(node) {
5398
- if (ts9.isJsxElement(node) || ts9.isJsxSelfClosingElement(node) || ts9.isJsxFragment(node))
5399
- return true;
5400
- return ts9.forEachChild(node, nodeContainsJsx) ?? false;
5401
- }
5402
5566
  function getSourceLocation(node, sourceFile, filePath) {
5403
5567
  const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());
5404
5568
  const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());
@@ -5415,20 +5579,20 @@ function getSourceLocation(node, sourceFile, filePath) {
5415
5579
  };
5416
5580
  }
5417
5581
  function membersToProperties(members, sourceFile) {
5418
- return members.filter(ts9.isPropertySignature).map((member) => ({
5582
+ return members.filter(ts10.isPropertySignature).map((member) => ({
5419
5583
  name: propertyNameText(member.name, sourceFile),
5420
5584
  type: typeNodeToTypeInfo(member.type, sourceFile) ?? {
5421
5585
  kind: "unknown",
5422
5586
  raw: "unknown"
5423
5587
  },
5424
5588
  optional: !!member.questionToken,
5425
- readonly: !!member.modifiers?.some((m) => m.kind === ts9.SyntaxKind.ReadonlyKeyword)
5589
+ readonly: !!member.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ReadonlyKeyword)
5426
5590
  }));
5427
5591
  }
5428
5592
  function propertyNameText(name, sourceFile) {
5429
5593
  if (!name)
5430
5594
  return "";
5431
- if (ts9.isStringLiteral(name) || ts9.isNumericLiteral(name))
5595
+ if (ts10.isStringLiteral(name) || ts10.isNumericLiteral(name))
5432
5596
  return name.text;
5433
5597
  return name.getText(sourceFile);
5434
5598
  }
@@ -5439,56 +5603,56 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
5439
5603
  const raw = rawOf ? rawOf(typeNode) : typeNode.getText(sourceFile);
5440
5604
  const recurse = (n) => typeNodeToTypeInfo(n, sourceFile, rawOf) ?? { kind: "unknown", raw: "unknown" };
5441
5605
  switch (typeNode.kind) {
5442
- case ts9.SyntaxKind.StringKeyword:
5606
+ case ts10.SyntaxKind.StringKeyword:
5443
5607
  return { kind: "primitive", raw, primitive: "string" };
5444
- case ts9.SyntaxKind.NumberKeyword:
5608
+ case ts10.SyntaxKind.NumberKeyword:
5445
5609
  return { kind: "primitive", raw, primitive: "number" };
5446
- case ts9.SyntaxKind.BooleanKeyword:
5610
+ case ts10.SyntaxKind.BooleanKeyword:
5447
5611
  return { kind: "primitive", raw, primitive: "boolean" };
5448
- case ts9.SyntaxKind.NullKeyword:
5612
+ case ts10.SyntaxKind.NullKeyword:
5449
5613
  return { kind: "primitive", raw, primitive: "null" };
5450
- case ts9.SyntaxKind.UndefinedKeyword:
5614
+ case ts10.SyntaxKind.UndefinedKeyword:
5451
5615
  return { kind: "primitive", raw, primitive: "undefined" };
5452
5616
  }
5453
- if (ts9.isArrayTypeNode(typeNode)) {
5617
+ if (ts10.isArrayTypeNode(typeNode)) {
5454
5618
  return { kind: "array", raw, elementType: recurse(typeNode.elementType) };
5455
5619
  }
5456
- if (ts9.isLiteralTypeNode(typeNode)) {
5620
+ if (ts10.isLiteralTypeNode(typeNode)) {
5457
5621
  const lit = typeNode.literal;
5458
- if (ts9.isStringLiteral(lit) || ts9.isNoSubstitutionTemplateLiteral(lit)) {
5622
+ if (ts10.isStringLiteral(lit) || ts10.isNoSubstitutionTemplateLiteral(lit)) {
5459
5623
  return { kind: "primitive", raw, primitive: "string", literalValue: lit.text };
5460
5624
  }
5461
- if (ts9.isNumericLiteral(lit)) {
5625
+ if (ts10.isNumericLiteral(lit)) {
5462
5626
  return { kind: "primitive", raw, primitive: "number", literalValue: lit.text };
5463
5627
  }
5464
- if (ts9.isPrefixUnaryExpression(lit) && lit.operator === ts9.SyntaxKind.MinusToken && ts9.isNumericLiteral(lit.operand)) {
5628
+ if (ts10.isPrefixUnaryExpression(lit) && lit.operator === ts10.SyntaxKind.MinusToken && ts10.isNumericLiteral(lit.operand)) {
5465
5629
  return { kind: "primitive", raw, primitive: "number", literalValue: `-${lit.operand.text}` };
5466
5630
  }
5467
- if (lit.kind === ts9.SyntaxKind.TrueKeyword || lit.kind === ts9.SyntaxKind.FalseKeyword) {
5631
+ if (lit.kind === ts10.SyntaxKind.TrueKeyword || lit.kind === ts10.SyntaxKind.FalseKeyword) {
5468
5632
  return {
5469
5633
  kind: "primitive",
5470
5634
  raw,
5471
5635
  primitive: "boolean",
5472
- literalValue: lit.kind === ts9.SyntaxKind.TrueKeyword ? "true" : "false"
5636
+ literalValue: lit.kind === ts10.SyntaxKind.TrueKeyword ? "true" : "false"
5473
5637
  };
5474
5638
  }
5475
- if (lit.kind === ts9.SyntaxKind.NullKeyword) {
5639
+ if (lit.kind === ts10.SyntaxKind.NullKeyword) {
5476
5640
  return { kind: "primitive", raw, primitive: "null" };
5477
5641
  }
5478
5642
  return { kind: "unknown", raw };
5479
5643
  }
5480
- if (ts9.isUnionTypeNode(typeNode)) {
5644
+ if (ts10.isUnionTypeNode(typeNode)) {
5481
5645
  return { kind: "union", raw, unionTypes: typeNode.types.map(recurse) };
5482
5646
  }
5483
- if (ts9.isTypeLiteralNode(typeNode)) {
5647
+ if (ts10.isTypeLiteralNode(typeNode)) {
5484
5648
  return {
5485
5649
  kind: "object",
5486
5650
  raw,
5487
5651
  ...synthetic ? {} : { properties: membersToProperties(typeNode.members, sourceFile) }
5488
5652
  };
5489
5653
  }
5490
- if (ts9.isTypeReferenceNode(typeNode)) {
5491
- const refName = ts9.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : "";
5654
+ if (ts10.isTypeReferenceNode(typeNode)) {
5655
+ const refName = ts10.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : "";
5492
5656
  if ((refName === "Array" || refName === "ReadonlyArray") && typeNode.typeArguments?.length === 1) {
5493
5657
  return { kind: "array", raw, elementType: recurse(typeNode.typeArguments[0]) };
5494
5658
  }
@@ -5497,7 +5661,7 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
5497
5661
  raw
5498
5662
  };
5499
5663
  }
5500
- if (ts9.isFunctionTypeNode(typeNode)) {
5664
+ if (ts10.isFunctionTypeNode(typeNode)) {
5501
5665
  if (synthetic)
5502
5666
  return { kind: "function", raw };
5503
5667
  return {
@@ -5517,15 +5681,15 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
5517
5681
  }
5518
5682
  return { kind: "unknown", raw };
5519
5683
  }
5520
- var _typePrinter = ts9.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
5521
- var _blankTypeSourceFile = ts9.createSourceFile("__bf_types__.ts", "", ts9.ScriptTarget.Latest);
5684
+ var _typePrinter = ts10.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
5685
+ var _blankTypeSourceFile = ts10.createSourceFile("__bf_types__.ts", "", ts10.ScriptTarget.Latest);
5522
5686
  function tsTypeToTypeInfo(type, checker) {
5523
- const node = checker.typeToTypeNode(type, undefined, ts9.NodeBuilderFlags.NoTruncation);
5687
+ const node = checker.typeToTypeNode(type, undefined, ts10.NodeBuilderFlags.NoTruncation);
5524
5688
  if (!node)
5525
5689
  return null;
5526
5690
  const rawOf = (n) => {
5527
5691
  try {
5528
- return _typePrinter.printNode(ts9.EmitHint.Unspecified, n, _blankTypeSourceFile);
5692
+ return _typePrinter.printNode(ts10.EmitHint.Unspecified, n, _blankTypeSourceFile);
5529
5693
  } catch {
5530
5694
  return "unknown";
5531
5695
  }
@@ -5536,16 +5700,16 @@ function isPascalCase(name) {
5536
5700
  return /^[A-Z][a-zA-Z0-9]*$/.test(name);
5537
5701
  }
5538
5702
  function isComponentFunction(node) {
5539
- return ts9.isFunctionDeclaration(node) && !!node.name && isPascalCase(node.name.text) && !!node.body;
5703
+ return ts10.isFunctionDeclaration(node) && !!node.name && isPascalCase(node.name.text) && !!node.body;
5540
5704
  }
5541
5705
  function isArrowComponentFunction(node) {
5542
- if (!ts9.isVariableDeclaration(node))
5706
+ if (!ts10.isVariableDeclaration(node))
5543
5707
  return false;
5544
- if (!ts9.isIdentifier(node.name))
5708
+ if (!ts10.isIdentifier(node.name))
5545
5709
  return false;
5546
5710
  if (!isPascalCase(node.name.text))
5547
5711
  return false;
5548
- if (!node.initializer || !ts9.isArrowFunction(node.initializer))
5712
+ if (!node.initializer || !ts10.isArrowFunction(node.initializer))
5549
5713
  return false;
5550
5714
  return true;
5551
5715
  }
@@ -6191,9 +6355,9 @@ function needsTypeBasedDetection(source) {
6191
6355
  }
6192
6356
  function findBrandPackageImportLoc(sourceFile, filePath) {
6193
6357
  for (const stmt of sourceFile.statements) {
6194
- if (!ts10.isImportDeclaration(stmt))
6358
+ if (!ts11.isImportDeclaration(stmt))
6195
6359
  continue;
6196
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
6360
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
6197
6361
  continue;
6198
6362
  if (!REACTIVE_BRAND_PACKAGES.includes(stmt.moduleSpecifier.text))
6199
6363
  continue;
@@ -6212,21 +6376,21 @@ function createProgramForFile(source, filePath) {
6212
6376
  try {
6213
6377
  const normalizedPath = path_default.resolve(filePath);
6214
6378
  const compilerOptions = {
6215
- target: ts10.ScriptTarget.Latest,
6216
- module: ts10.ModuleKind.ESNext,
6217
- moduleResolution: ts10.ModuleResolutionKind.Bundler,
6218
- jsx: ts10.JsxEmit.ReactJSX,
6379
+ target: ts11.ScriptTarget.Latest,
6380
+ module: ts11.ModuleKind.ESNext,
6381
+ moduleResolution: ts11.ModuleResolutionKind.Bundler,
6382
+ jsx: ts11.JsxEmit.ReactJSX,
6219
6383
  strict: true,
6220
6384
  skipLibCheck: true,
6221
6385
  noEmit: true,
6222
6386
  baseUrl: path_default.dirname(normalizedPath)
6223
6387
  };
6224
- const defaultHost = ts10.createCompilerHost(compilerOptions);
6388
+ const defaultHost = ts11.createCompilerHost(compilerOptions);
6225
6389
  const virtualHost = {
6226
6390
  ...defaultHost,
6227
6391
  getSourceFile(fileName, languageVersion) {
6228
6392
  if (path_default.resolve(fileName) === normalizedPath) {
6229
- return ts10.createSourceFile(fileName, source, languageVersion, true, ts10.ScriptKind.TSX);
6393
+ return ts11.createSourceFile(fileName, source, languageVersion, true, ts11.ScriptKind.TSX);
6230
6394
  }
6231
6395
  return defaultHost.getSourceFile(fileName, languageVersion);
6232
6396
  },
@@ -6241,7 +6405,7 @@ function createProgramForFile(source, filePath) {
6241
6405
  return defaultHost.readFile(fileName);
6242
6406
  }
6243
6407
  };
6244
- const program = ts10.createProgram([normalizedPath], compilerOptions, virtualHost);
6408
+ const program = ts11.createProgram([normalizedPath], compilerOptions, virtualHost);
6245
6409
  const sourceFile = program.getSourceFile(normalizedPath);
6246
6410
  if (!sourceFile)
6247
6411
  return null;
@@ -6274,7 +6438,7 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
6274
6438
  }
6275
6439
  }
6276
6440
  if (!sourceFile) {
6277
- sourceFile = ts10.createSourceFile(filePath, source, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
6441
+ sourceFile = ts11.createSourceFile(filePath, source, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
6278
6442
  }
6279
6443
  if (!checker && needsTypeBasedDetection(source)) {
6280
6444
  const result = createProgramForFile(source, filePath);
@@ -6320,23 +6484,23 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
6320
6484
  function findDefaultExportedComponent(sourceFile) {
6321
6485
  let defaultExportName;
6322
6486
  function findDefaultExport(node) {
6323
- if (ts10.isExportAssignment(node) && !node.isExportEquals) {
6324
- if (ts10.isIdentifier(node.expression)) {
6487
+ if (ts11.isExportAssignment(node) && !node.isExportEquals) {
6488
+ if (ts11.isIdentifier(node.expression)) {
6325
6489
  defaultExportName = node.expression.text;
6326
6490
  }
6327
6491
  }
6328
- if (ts10.isFunctionDeclaration(node) && node.name && node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DefaultKeyword)) {
6492
+ if (ts11.isFunctionDeclaration(node) && node.name && node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DefaultKeyword)) {
6329
6493
  defaultExportName = node.name.text;
6330
6494
  }
6331
- ts10.forEachChild(node, findDefaultExport);
6495
+ ts11.forEachChild(node, findDefaultExport);
6332
6496
  }
6333
- ts10.forEachChild(sourceFile, findDefaultExport);
6497
+ ts11.forEachChild(sourceFile, findDefaultExport);
6334
6498
  return defaultExportName;
6335
6499
  }
6336
6500
  function collectNamedExports(sourceFile) {
6337
6501
  const exported = new Set;
6338
6502
  for (const stmt of sourceFile.statements) {
6339
- if (ts10.isExportDeclaration(stmt) && stmt.exportClause && ts10.isNamedExports(stmt.exportClause)) {
6503
+ if (ts11.isExportDeclaration(stmt) && stmt.exportClause && ts11.isNamedExports(stmt.exportClause)) {
6340
6504
  for (const spec of stmt.exportClause.elements) {
6341
6505
  const local = (spec.propertyName ?? spec.name).text;
6342
6506
  exported.add(local);
@@ -6346,22 +6510,22 @@ function collectNamedExports(sourceFile) {
6346
6510
  return exported;
6347
6511
  }
6348
6512
  function visit(node, ctx, targetComponentName, namedExports) {
6349
- if (ts10.isExpressionStatement(node) && ts10.isStringLiteral(node.expression)) {
6513
+ if (ts11.isExpressionStatement(node) && ts11.isStringLiteral(node.expression)) {
6350
6514
  if (node.expression.text === "use client" || node.expression.text === "'use client'") {
6351
6515
  ctx.hasUseClientDirective = true;
6352
6516
  }
6353
6517
  }
6354
- if (ts10.isImportDeclaration(node)) {
6518
+ if (ts11.isImportDeclaration(node)) {
6355
6519
  collectImport(node, ctx);
6356
6520
  }
6357
- if (ts10.isInterfaceDeclaration(node)) {
6521
+ if (ts11.isInterfaceDeclaration(node)) {
6358
6522
  collectInterfaceDefinition(node, ctx);
6359
6523
  }
6360
- if (ts10.isTypeAliasDeclaration(node)) {
6524
+ if (ts11.isTypeAliasDeclaration(node)) {
6361
6525
  collectTypeAliasDefinition(node, ctx);
6362
6526
  }
6363
- if (!ctx.hasUseClientDirective && ts10.isFunctionDeclaration(node) && node.name && node.body && isMultiReturnJsxFunctionBody(node.body)) {
6364
- const hasInlineExport = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6527
+ if (!ctx.hasUseClientDirective && ts11.isFunctionDeclaration(node) && node.name && node.body && isMultiReturnJsxFunctionBody(node.body)) {
6528
+ const hasInlineExport = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6365
6529
  const hasNamedExport = namedExports?.has(node.name.text) ?? false;
6366
6530
  if (!hasInlineExport && !hasNamedExport) {
6367
6531
  collectFunction(node, ctx, true, false);
@@ -6376,9 +6540,9 @@ function visit(node, ctx, targetComponentName, namedExports) {
6376
6540
  if (!ctx.componentName) {
6377
6541
  ctx.componentName = node.name.text;
6378
6542
  ctx.componentNode = node;
6379
- ctx.isExported = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6543
+ ctx.isExported = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6380
6544
  analyzeComponentBody(node, ctx);
6381
- if (node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DefaultKeyword)) {
6545
+ if (node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DefaultKeyword)) {
6382
6546
  ctx.hasDefaultExport = true;
6383
6547
  }
6384
6548
  }
@@ -6392,10 +6556,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
6392
6556
  ctx.componentName = node.name.text;
6393
6557
  ctx.componentNode = node.initializer;
6394
6558
  const parentStatement = node.parent;
6395
- if (ts10.isVariableDeclarationList(parentStatement)) {
6559
+ if (ts11.isVariableDeclarationList(parentStatement)) {
6396
6560
  const varStatement = parentStatement.parent;
6397
- if (ts10.isVariableStatement(varStatement)) {
6398
- ctx.isExported = varStatement.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6561
+ if (ts11.isVariableStatement(varStatement)) {
6562
+ ctx.isExported = varStatement.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6399
6563
  }
6400
6564
  }
6401
6565
  analyzeComponentBody(node.initializer, ctx);
@@ -6407,10 +6571,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
6407
6571
  if (!ctx.componentNode) {
6408
6572
  collectAmbientGlobals(node, ctx);
6409
6573
  }
6410
- const isDeclareStatement = ts10.isVariableStatement(node) && (node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DeclareKeyword) ?? false);
6411
- if (ts10.isVariableStatement(node) && !ctx.componentNode && !isDeclareStatement) {
6412
- const isExported = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6413
- const isLet = (node.declarationList.flags & ts10.NodeFlags.Let) !== 0;
6574
+ const isDeclareStatement = ts11.isVariableStatement(node) && (node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DeclareKeyword) ?? false);
6575
+ if (ts11.isVariableStatement(node) && !ctx.componentNode && !isDeclareStatement) {
6576
+ const isExported = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6577
+ const isLet = (node.declarationList.flags & ts11.NodeFlags.Let) !== 0;
6414
6578
  const isModuleClientDirective = hasLeadingClientDirectiveOnStatement(node, ctx.sourceFile);
6415
6579
  for (const decl of node.declarationList.declarations) {
6416
6580
  if (declarationIsReactiveFactoryCall(decl, ctx)) {
@@ -6421,19 +6585,19 @@ function visit(node, ctx, targetComponentName, namedExports) {
6421
6585
  }
6422
6586
  continue;
6423
6587
  }
6424
- if (ts10.isIdentifier(decl.name) && (decl.initializer || isLet) && !isArrowComponentFunction(decl)) {
6588
+ if (ts11.isIdentifier(decl.name) && (decl.initializer || isLet) && !isArrowComponentFunction(decl)) {
6425
6589
  collectConstant(decl, ctx, true, isLet ? "let" : "const", isExported);
6426
6590
  }
6427
6591
  }
6428
6592
  }
6429
- if (ts10.isFunctionDeclaration(node) && node.name && !isComponentFunction(node)) {
6430
- const isExported = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6593
+ if (ts11.isFunctionDeclaration(node) && node.name && !isComponentFunction(node)) {
6594
+ const isExported = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6431
6595
  collectFunction(node, ctx, true, isExported);
6432
6596
  return;
6433
6597
  }
6434
- if (ts10.isExportDeclaration(node) && node.exportClause && ts10.isNamedExports(node.exportClause)) {
6598
+ if (ts11.isExportDeclaration(node) && node.exportClause && ts11.isNamedExports(node.exportClause)) {
6435
6599
  const isFromReexport = !!node.moduleSpecifier;
6436
- const sourceSpec = node.moduleSpecifier && ts10.isStringLiteral(node.moduleSpecifier) ? node.moduleSpecifier.text : null;
6600
+ const sourceSpec = node.moduleSpecifier && ts11.isStringLiteral(node.moduleSpecifier) ? node.moduleSpecifier.text : null;
6437
6601
  const exportSpecifiers = node.exportClause.elements.map((spec) => ({
6438
6602
  name: (spec.propertyName ?? spec.name).text,
6439
6603
  alias: spec.propertyName ? spec.name.text : null,
@@ -6461,24 +6625,24 @@ function visit(node, ctx, targetComponentName, namedExports) {
6461
6625
  }
6462
6626
  }
6463
6627
  }
6464
- if (ts10.isExportAssignment(node) && !node.isExportEquals) {
6628
+ if (ts11.isExportAssignment(node) && !node.isExportEquals) {
6465
6629
  const expr = node.expression;
6466
- if (ts10.isIdentifier(expr)) {
6630
+ if (ts11.isIdentifier(expr)) {
6467
6631
  if (ctx.componentName && expr.text === ctx.componentName) {
6468
6632
  ctx.hasDefaultExport = true;
6469
6633
  ctx.isExported = true;
6470
6634
  }
6471
6635
  }
6472
6636
  }
6473
- ts10.forEachChild(node, (child) => visit(child, ctx, targetComponentName, namedExports));
6637
+ ts11.forEachChild(node, (child) => visit(child, ctx, targetComponentName, namedExports));
6474
6638
  }
6475
6639
  function analyzeComponentBody(node, ctx) {
6476
6640
  if (node.parameters.length > 0) {
6477
6641
  extractProps(node.parameters[0], ctx);
6478
6642
  }
6479
- const body = ts10.isFunctionDeclaration(node) ? node.body : getArrowFunctionBody(node);
6643
+ const body = ts11.isFunctionDeclaration(node) ? node.body : getArrowFunctionBody(node);
6480
6644
  if (body) {
6481
- ctx.componentBodyBlock = ts10.isBlock(body) ? body : null;
6645
+ ctx.componentBodyBlock = ts11.isBlock(body) ? body : null;
6482
6646
  if (!ctx.componentBodyBlock) {
6483
6647
  ctx.jsxReturn = unwrapJsxTransparent(body);
6484
6648
  }
@@ -6488,14 +6652,14 @@ function analyzeComponentBody(node, ctx) {
6488
6652
  }
6489
6653
  }
6490
6654
  function getArrowFunctionBody(node) {
6491
- if (ts10.isBlock(node.body)) {
6655
+ if (ts11.isBlock(node.body)) {
6492
6656
  return node.body;
6493
6657
  }
6494
6658
  return node.body;
6495
6659
  }
6496
6660
  function visitComponentBody(node, ctx) {
6497
6661
  const isTopLevel = ctx.componentBodyBlock !== null && node.parent === ctx.componentBodyBlock;
6498
- if (ts10.isVariableStatement(node)) {
6662
+ if (ts11.isVariableStatement(node)) {
6499
6663
  for (const decl of node.declarationList.declarations) {
6500
6664
  if (isSignalDeclaration(decl, ctx)) {
6501
6665
  collectSignal(decl, ctx);
@@ -6518,16 +6682,16 @@ function visitComponentBody(node, ctx) {
6518
6682
  collectEffect(decl.initializer, ctx, decl.name.text);
6519
6683
  continue;
6520
6684
  }
6521
- if (ts10.isIdentifier(decl.name)) {
6522
- const isLet = (node.declarationList.flags & ts10.NodeFlags.Let) !== 0;
6685
+ if (ts11.isIdentifier(decl.name)) {
6686
+ const isLet = (node.declarationList.flags & ts11.NodeFlags.Let) !== 0;
6523
6687
  collectConstant(decl, ctx, false, isLet ? "let" : "const");
6524
- } else if (ts10.isObjectBindingPattern(decl.name) && decl.initializer && ts10.isIdentifier(decl.initializer) && ctx.propsObjectName === decl.initializer.text) {
6525
- const isLet = (node.declarationList.flags & ts10.NodeFlags.Let) !== 0;
6688
+ } else if (ts11.isObjectBindingPattern(decl.name) && decl.initializer && ts11.isIdentifier(decl.initializer) && ctx.propsObjectName === decl.initializer.text) {
6689
+ const isLet = (node.declarationList.flags & ts11.NodeFlags.Let) !== 0;
6526
6690
  collectConstant(decl, ctx, false, isLet ? "let" : "const");
6527
6691
  }
6528
6692
  }
6529
6693
  }
6530
- if (ts10.isExpressionStatement(node)) {
6694
+ if (ts11.isExpressionStatement(node)) {
6531
6695
  if (isEffectCall(node.expression, ctx)) {
6532
6696
  collectEffect(node.expression, ctx);
6533
6697
  return;
@@ -6541,10 +6705,10 @@ function visitComponentBody(node, ctx) {
6541
6705
  return;
6542
6706
  }
6543
6707
  }
6544
- if (ts10.isFunctionDeclaration(node) && node.name) {
6708
+ if (ts11.isFunctionDeclaration(node) && node.name) {
6545
6709
  collectFunction(node, ctx, false);
6546
6710
  }
6547
- if (ts10.isIfStatement(node)) {
6711
+ if (ts11.isIfStatement(node)) {
6548
6712
  const jsxReturn = findJsxReturnInBlock(node.thenStatement);
6549
6713
  if (jsxReturn) {
6550
6714
  const scopeVars = collectScopeVariables(node.thenStatement, ctx);
@@ -6563,8 +6727,8 @@ function visitComponentBody(node, ctx) {
6563
6727
  return;
6564
6728
  }
6565
6729
  }
6566
- if (isTopLevel && (ts10.isTryStatement(node) || ts10.isSwitchStatement(node) || ts10.isForStatement(node) || ts10.isForInStatement(node) || ts10.isForOfStatement(node) || ts10.isWhileStatement(node) || ts10.isDoStatement(node) || ts10.isThrowStatement(node) || ts10.isBlock(node) && node.parent === ctx.componentBodyBlock)) {
6567
- if (ts10.isBlock(node)) {
6730
+ if (isTopLevel && (ts11.isTryStatement(node) || ts11.isSwitchStatement(node) || ts11.isForStatement(node) || ts11.isForInStatement(node) || ts11.isForOfStatement(node) || ts11.isWhileStatement(node) || ts11.isDoStatement(node) || ts11.isThrowStatement(node) || ts11.isBlock(node) && node.parent === ctx.componentBodyBlock)) {
6731
+ if (ts11.isBlock(node)) {
6568
6732
  const returnedLocal = findBlockBodyReturnedJsxLocalName(node);
6569
6733
  if (returnedLocal) {
6570
6734
  ctx.errors.push(createError(ErrorCodes.RETURN_VALUE_NOT_JSX, getSourceLocation(node, ctx.sourceFile, ctx.filePath), {
@@ -6575,34 +6739,34 @@ function visitComponentBody(node, ctx) {
6575
6739
  collectInitStatement(node, ctx);
6576
6740
  return;
6577
6741
  }
6578
- if (ts10.isReturnStatement(node) && node.expression) {
6742
+ if (ts11.isReturnStatement(node) && node.expression) {
6579
6743
  ctx.jsxReturn = unwrapJsxTransparent(node.expression);
6580
6744
  }
6581
- ts10.forEachChild(node, (child) => {
6582
- if (ts10.isArrowFunction(child) || ts10.isFunctionExpression(child) || ts10.isFunctionDeclaration(child)) {
6745
+ ts11.forEachChild(node, (child) => {
6746
+ if (ts11.isArrowFunction(child) || ts11.isFunctionExpression(child) || ts11.isFunctionDeclaration(child)) {
6583
6747
  return;
6584
6748
  }
6585
6749
  visitComponentBody(child, ctx);
6586
6750
  });
6587
6751
  }
6588
6752
  function findJsxReturnInBlock(node) {
6589
- if (ts10.isBlock(node)) {
6753
+ if (ts11.isBlock(node)) {
6590
6754
  for (const stmt of node.statements) {
6591
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
6755
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
6592
6756
  const jsx = extractJsxFromExpression(stmt.expression);
6593
6757
  if (jsx)
6594
6758
  return jsx;
6595
6759
  }
6596
6760
  }
6597
6761
  }
6598
- if (ts10.isReturnStatement(node) && node.expression) {
6762
+ if (ts11.isReturnStatement(node) && node.expression) {
6599
6763
  return extractJsxFromExpression(node.expression);
6600
6764
  }
6601
6765
  return null;
6602
6766
  }
6603
6767
  function unwrapJsxTransparent(expr) {
6604
6768
  let current = expr;
6605
- while (ts10.isParenthesizedExpression(current) || ts10.isAsExpression(current) || ts10.isSatisfiesExpression(current) || ts10.isNonNullExpression(current) || ts10.isTypeAssertionExpression(current) || current.kind === ts10.SyntaxKind.PartiallyEmittedExpression) {
6769
+ while (ts11.isParenthesizedExpression(current) || ts11.isAsExpression(current) || ts11.isSatisfiesExpression(current) || ts11.isNonNullExpression(current) || ts11.isTypeAssertionExpression(current) || current.kind === ts11.SyntaxKind.PartiallyEmittedExpression) {
6606
6770
  current = current.expression;
6607
6771
  }
6608
6772
  return current;
@@ -6610,22 +6774,22 @@ function unwrapJsxTransparent(expr) {
6610
6774
  function findBlockBodyReturnedJsxLocalName(block) {
6611
6775
  const stmts = block.statements;
6612
6776
  const last = stmts[stmts.length - 1];
6613
- if (!last || !ts10.isReturnStatement(last) || !last.expression)
6777
+ if (!last || !ts11.isReturnStatement(last) || !last.expression)
6614
6778
  return null;
6615
6779
  const returned = unwrapJsxTransparent(last.expression);
6616
- if (!ts10.isIdentifier(returned))
6780
+ if (!ts11.isIdentifier(returned))
6617
6781
  return null;
6618
6782
  const name = returned.text;
6619
6783
  for (const stmt of stmts) {
6620
- if (!ts10.isVariableStatement(stmt))
6784
+ if (!ts11.isVariableStatement(stmt))
6621
6785
  continue;
6622
6786
  for (const decl of stmt.declarationList.declarations) {
6623
- if (!ts10.isIdentifier(decl.name) || decl.name.text !== name || !decl.initializer)
6787
+ if (!ts11.isIdentifier(decl.name) || decl.name.text !== name || !decl.initializer)
6624
6788
  continue;
6625
6789
  let init = decl.initializer;
6626
- while (ts10.isParenthesizedExpression(init))
6790
+ while (ts11.isParenthesizedExpression(init))
6627
6791
  init = init.expression;
6628
- if (ts10.isJsxElement(init) || ts10.isJsxSelfClosingElement(init) || ts10.isJsxFragment(init) || initializerShapeContainsJsx(init) || isMapLikeCallWithJsx(init)) {
6792
+ if (ts11.isJsxElement(init) || ts11.isJsxSelfClosingElement(init) || ts11.isJsxFragment(init) || initializerShapeContainsJsx(init) || isMapLikeCallWithJsx(init)) {
6629
6793
  return name;
6630
6794
  }
6631
6795
  }
@@ -6634,16 +6798,16 @@ function findBlockBodyReturnedJsxLocalName(block) {
6634
6798
  }
6635
6799
  function extractJsxFromExpression(expr) {
6636
6800
  const inner = unwrapJsxTransparent(expr);
6637
- if (ts10.isJsxElement(inner) || ts10.isJsxFragment(inner) || ts10.isJsxSelfClosingElement(inner)) {
6801
+ if (ts11.isJsxElement(inner) || ts11.isJsxFragment(inner) || ts11.isJsxSelfClosingElement(inner)) {
6638
6802
  return inner;
6639
6803
  }
6640
6804
  return null;
6641
6805
  }
6642
6806
  function collectScopeVariables(node, ctx) {
6643
6807
  const variables = [];
6644
- if (ts10.isBlock(node)) {
6808
+ if (ts11.isBlock(node)) {
6645
6809
  for (const stmt of node.statements) {
6646
- if (ts10.isVariableStatement(stmt)) {
6810
+ if (ts11.isVariableStatement(stmt)) {
6647
6811
  for (const decl of stmt.declarationList.declarations) {
6648
6812
  variables.push(decl);
6649
6813
  }
@@ -6655,13 +6819,13 @@ function collectScopeVariables(node, ctx) {
6655
6819
  function collectParamBindingNames(params) {
6656
6820
  const out = new Set;
6657
6821
  const addBindingNames = (name) => {
6658
- if (ts10.isIdentifier(name)) {
6822
+ if (ts11.isIdentifier(name)) {
6659
6823
  out.add(name.text);
6660
- } else if (ts10.isObjectBindingPattern(name)) {
6824
+ } else if (ts11.isObjectBindingPattern(name)) {
6661
6825
  name.elements.forEach((e) => addBindingNames(e.name));
6662
- } else if (ts10.isArrayBindingPattern(name)) {
6826
+ } else if (ts11.isArrayBindingPattern(name)) {
6663
6827
  name.elements.forEach((e) => {
6664
- if (!ts10.isOmittedExpression(e))
6828
+ if (!ts11.isOmittedExpression(e))
6665
6829
  addBindingNames(e.name);
6666
6830
  });
6667
6831
  }
@@ -6678,7 +6842,7 @@ function collectEnclosingBranchVars(node, ctx) {
6678
6842
  if (cr.ifStatement.thenStatement !== current)
6679
6843
  continue;
6680
6844
  for (const decl of cr.scopeVariables) {
6681
- if (!ts10.isIdentifier(decl.name) || !decl.initializer)
6845
+ if (!ts11.isIdentifier(decl.name) || !decl.initializer)
6682
6846
  continue;
6683
6847
  const varName = decl.name.text;
6684
6848
  if (result.has(varName))
@@ -6693,10 +6857,10 @@ function collectEnclosingBranchVars(node, ctx) {
6693
6857
  return result;
6694
6858
  }
6695
6859
  function collectBranchSignals(thenStatement, ctx, branchCondition) {
6696
- if (!ts10.isBlock(thenStatement))
6860
+ if (!ts11.isBlock(thenStatement))
6697
6861
  return;
6698
6862
  for (const stmt of thenStatement.statements) {
6699
- if (!ts10.isVariableStatement(stmt))
6863
+ if (!ts11.isVariableStatement(stmt))
6700
6864
  continue;
6701
6865
  for (const decl of stmt.declarationList.declarations) {
6702
6866
  if (!isSignalDeclaration(decl, ctx))
@@ -6722,13 +6886,13 @@ var ENV_SIGNAL_FACTORIES = {
6722
6886
  createSearchParams: "search"
6723
6887
  };
6724
6888
  function resolvePrimitiveKind(callExpr, ctx) {
6725
- if (ts10.isIdentifier(callExpr.expression)) {
6889
+ if (ts11.isIdentifier(callExpr.expression)) {
6726
6890
  const hit = PRIMITIVE_CANONICAL_NAMES[callExpr.expression.text];
6727
6891
  if (hit)
6728
6892
  return hit;
6729
6893
  return resolveCalleeViaChecker(callExpr.expression, ctx);
6730
6894
  }
6731
- if (ts10.isPropertyAccessExpression(callExpr.expression)) {
6895
+ if (ts11.isPropertyAccessExpression(callExpr.expression)) {
6732
6896
  const propName = callExpr.expression.name.text;
6733
6897
  const hit = PRIMITIVE_CANONICAL_NAMES[propName];
6734
6898
  if (!hit)
@@ -6755,7 +6919,7 @@ function resolveCanonicalClientExportName(ident, ctx) {
6755
6919
  if (!symbol)
6756
6920
  return null;
6757
6921
  let target = symbol;
6758
- if (symbol.flags & ts10.SymbolFlags.Alias) {
6922
+ if (symbol.flags & ts11.SymbolFlags.Alias) {
6759
6923
  try {
6760
6924
  target = ctx.checker.getAliasedSymbol(symbol);
6761
6925
  } catch {
@@ -6771,14 +6935,14 @@ function resolveCanonicalClientExportName(ident, ctx) {
6771
6935
  return null;
6772
6936
  }
6773
6937
  function resolveEnvSignalKey(callExpr, ctx) {
6774
- if (ts10.isIdentifier(callExpr.expression)) {
6938
+ if (ts11.isIdentifier(callExpr.expression)) {
6775
6939
  const key = ENV_SIGNAL_FACTORIES[callExpr.expression.text];
6776
6940
  if (key)
6777
6941
  return key;
6778
6942
  const canonical = resolveCanonicalClientExportName(callExpr.expression, ctx);
6779
6943
  return canonical ? ENV_SIGNAL_FACTORIES[canonical] ?? null : null;
6780
6944
  }
6781
- if (ts10.isPropertyAccessExpression(callExpr.expression)) {
6945
+ if (ts11.isPropertyAccessExpression(callExpr.expression)) {
6782
6946
  const key = ENV_SIGNAL_FACTORIES[callExpr.expression.name.text];
6783
6947
  if (key && isBarefootClientNamespace(callExpr.expression.expression, ctx))
6784
6948
  return key;
@@ -6786,7 +6950,7 @@ function resolveEnvSignalKey(callExpr, ctx) {
6786
6950
  return null;
6787
6951
  }
6788
6952
  function isBarefootClientNamespace(expr, ctx) {
6789
- if (!ts10.isIdentifier(expr))
6953
+ if (!ts11.isIdentifier(expr))
6790
6954
  return false;
6791
6955
  if (!ctx.checker)
6792
6956
  return false;
@@ -6799,22 +6963,22 @@ function isBarefootClientNamespace(expr, ctx) {
6799
6963
  if (!symbol)
6800
6964
  return false;
6801
6965
  for (const decl of symbol.declarations ?? []) {
6802
- if (!ts10.isNamespaceImport(decl))
6966
+ if (!ts11.isNamespaceImport(decl))
6803
6967
  continue;
6804
6968
  const importDecl = decl.parent.parent;
6805
- if (!ts10.isImportDeclaration(importDecl))
6969
+ if (!ts11.isImportDeclaration(importDecl))
6806
6970
  continue;
6807
6971
  const mod = importDecl.moduleSpecifier;
6808
- if (ts10.isStringLiteral(mod) && mod.text === "@barefootjs/client") {
6972
+ if (ts11.isStringLiteral(mod) && mod.text === "@barefootjs/client") {
6809
6973
  return true;
6810
6974
  }
6811
6975
  }
6812
6976
  return false;
6813
6977
  }
6814
6978
  function isSignalDeclaration(node, ctx) {
6815
- if (!ts10.isArrayBindingPattern(node.name))
6979
+ if (!ts11.isArrayBindingPattern(node.name))
6816
6980
  return false;
6817
- if (!node.initializer || !ts10.isCallExpression(node.initializer))
6981
+ if (!node.initializer || !ts11.isCallExpression(node.initializer))
6818
6982
  return false;
6819
6983
  return resolvePrimitiveKind(node.initializer, ctx) === "signal";
6820
6984
  }
@@ -6822,14 +6986,14 @@ function collectSignal(node, ctx) {
6822
6986
  const pattern = node.name;
6823
6987
  const callExpr = node.initializer;
6824
6988
  const elements = pattern.elements;
6825
- const getterElided = elements.length === 2 && ts10.isOmittedExpression(elements[0]);
6826
- if (elements.length < 1 || elements.length > 2 || !getterElided && (!ts10.isBindingElement(elements[0]) || !ts10.isIdentifier(elements[0].name))) {
6989
+ const getterElided = elements.length === 2 && ts11.isOmittedExpression(elements[0]);
6990
+ if (elements.length < 1 || elements.length > 2 || !getterElided && (!ts11.isBindingElement(elements[0]) || !ts11.isIdentifier(elements[0].name))) {
6827
6991
  return;
6828
6992
  }
6829
- if (elements.length === 2 && (!ts10.isBindingElement(elements[1]) || !ts10.isIdentifier(elements[1].name))) {
6993
+ if (elements.length === 2 && (!ts11.isBindingElement(elements[1]) || !ts11.isIdentifier(elements[1].name))) {
6830
6994
  return;
6831
6995
  }
6832
- const setter = elements.length === 2 && ts10.isBindingElement(elements[1]) && ts10.isIdentifier(elements[1].name) ? elements[1].name.text : null;
6996
+ const setter = elements.length === 2 && ts11.isBindingElement(elements[1]) && ts11.isIdentifier(elements[1].name) ? elements[1].name.text : null;
6833
6997
  if (getterElided && !setter)
6834
6998
  return;
6835
6999
  const getter = getterElided ? `__bfGet_${setter}` : elements[0].name.text;
@@ -6866,33 +7030,33 @@ function collectSignal(node, ctx) {
6866
7030
  });
6867
7031
  }
6868
7032
  function isSignalTupleDeclaration(node) {
6869
- if (!ts10.isIdentifier(node.name))
7033
+ if (!ts11.isIdentifier(node.name))
6870
7034
  return false;
6871
- if (!node.initializer || !ts10.isCallExpression(node.initializer))
7035
+ if (!node.initializer || !ts11.isCallExpression(node.initializer))
6872
7036
  return false;
6873
7037
  const callExpr = node.initializer;
6874
- return ts10.isIdentifier(callExpr.expression) && callExpr.expression.text === "createSignal";
7038
+ return ts11.isIdentifier(callExpr.expression) && callExpr.expression.text === "createSignal";
6875
7039
  }
6876
7040
  function isSignalIndexAccess(node, ctx) {
6877
- if (!ts10.isIdentifier(node.name))
7041
+ if (!ts11.isIdentifier(node.name))
6878
7042
  return null;
6879
- if (!node.initializer || !ts10.isElementAccessExpression(node.initializer))
7043
+ if (!node.initializer || !ts11.isElementAccessExpression(node.initializer))
6880
7044
  return null;
6881
7045
  const access = node.initializer;
6882
- if (!ts10.isNumericLiteral(access.argumentExpression))
7046
+ if (!ts11.isNumericLiteral(access.argumentExpression))
6883
7047
  return null;
6884
7048
  const indexValue = Number(access.argumentExpression.text);
6885
7049
  if (indexValue !== 0 && indexValue !== 1)
6886
7050
  return null;
6887
7051
  const index = indexValue;
6888
- if (ts10.isCallExpression(access.expression)) {
7052
+ if (ts11.isCallExpression(access.expression)) {
6889
7053
  const call = access.expression;
6890
- if (ts10.isIdentifier(call.expression) && call.expression.text === "createSignal") {
7054
+ if (ts11.isIdentifier(call.expression) && call.expression.text === "createSignal") {
6891
7055
  return { kind: "direct", index, callExpr: call };
6892
7056
  }
6893
7057
  return null;
6894
7058
  }
6895
- if (ts10.isIdentifier(access.expression)) {
7059
+ if (ts11.isIdentifier(access.expression)) {
6896
7060
  const tupleName = access.expression.text;
6897
7061
  if (ctx.signalTupleRefs.has(tupleName)) {
6898
7062
  return { kind: "tupleRef", index, tupleName };
@@ -6987,30 +7151,30 @@ function flushPendingSignalTuples(ctx) {
6987
7151
  ctx.signalTupleRefs.clear();
6988
7152
  }
6989
7153
  function isMemoDeclaration(node, ctx) {
6990
- if (!ts10.isIdentifier(node.name))
7154
+ if (!ts11.isIdentifier(node.name))
6991
7155
  return false;
6992
- if (!node.initializer || !ts10.isCallExpression(node.initializer))
7156
+ if (!node.initializer || !ts11.isCallExpression(node.initializer))
6993
7157
  return false;
6994
7158
  return resolvePrimitiveKind(node.initializer, ctx) === "memo";
6995
7159
  }
6996
7160
  function memoBodyIsTemplateLiteral(memoArrow) {
6997
7161
  let node = memoArrow;
6998
- while (node && ts10.isParenthesizedExpression(node))
7162
+ while (node && ts11.isParenthesizedExpression(node))
6999
7163
  node = node.expression;
7000
- if (!node || !ts10.isArrowFunction(node))
7164
+ if (!node || !ts11.isArrowFunction(node))
7001
7165
  return false;
7002
7166
  let body = node.body;
7003
- while (ts10.isParenthesizedExpression(body))
7167
+ while (ts11.isParenthesizedExpression(body))
7004
7168
  body = body.expression;
7005
- if (ts10.isBlock(body)) {
7006
- const ret = body.statements.find(ts10.isReturnStatement);
7169
+ if (ts11.isBlock(body)) {
7170
+ const ret = body.statements.find(ts11.isReturnStatement);
7007
7171
  if (!ret || !ret.expression)
7008
7172
  return false;
7009
7173
  body = ret.expression;
7010
- while (ts10.isParenthesizedExpression(body))
7174
+ while (ts11.isParenthesizedExpression(body))
7011
7175
  body = body.expression;
7012
7176
  }
7013
- return ts10.isTemplateExpression(body) || ts10.isNoSubstitutionTemplateLiteral(body);
7177
+ return ts11.isTemplateExpression(body) || ts11.isNoSubstitutionTemplateLiteral(body);
7014
7178
  }
7015
7179
  function collectMemo(node, ctx) {
7016
7180
  const name = node.name.text;
@@ -7027,7 +7191,7 @@ function collectMemo(node, ctx) {
7027
7191
  type = inferTypeFromValue(arrowBody);
7028
7192
  }
7029
7193
  }
7030
- if (ctx.checker && (type.kind === "unknown" || type.kind === "object") && callExpr.arguments[0] && (ts10.isArrowFunction(callExpr.arguments[0]) || ts10.isFunctionExpression(callExpr.arguments[0]))) {
7194
+ if (ctx.checker && (type.kind === "unknown" || type.kind === "object") && callExpr.arguments[0] && (ts11.isArrowFunction(callExpr.arguments[0]) || ts11.isFunctionExpression(callExpr.arguments[0]))) {
7031
7195
  const fnType = ctx.checker.getTypeAtLocation(callExpr.arguments[0]);
7032
7196
  const sig = fnType.getCallSignatures()[0];
7033
7197
  if (sig) {
@@ -7037,12 +7201,12 @@ function collectMemo(node, ctx) {
7037
7201
  }
7038
7202
  }
7039
7203
  const memoArrow = callExpr.arguments[0];
7040
- const parsedBody = memoArrow && ts10.isArrowFunction(memoArrow) && !ts10.isBlock(memoArrow.body) ? parseExpression(ctx.getJS(memoArrow.body)) : undefined;
7204
+ const parsedBody = memoArrow && ts11.isArrowFunction(memoArrow) && !ts11.isBlock(memoArrow.body) ? parseExpression(ctx.getJS(memoArrow.body)) : undefined;
7041
7205
  const parsed = parsedBody && parsedBody.kind !== "unsupported" && parsedBody.kind !== "object-literal" ? parsedBody : undefined;
7042
7206
  let arrowNode = memoArrow;
7043
- while (arrowNode && ts10.isParenthesizedExpression(arrowNode))
7207
+ while (arrowNode && ts11.isParenthesizedExpression(arrowNode))
7044
7208
  arrowNode = arrowNode.expression;
7045
- const blockBody = arrowNode && ts10.isArrowFunction(arrowNode) && ts10.isBlock(arrowNode.body) ? arrowNode.body : undefined;
7209
+ const blockBody = arrowNode && ts11.isArrowFunction(arrowNode) && ts11.isBlock(arrowNode.body) ? arrowNode.body : undefined;
7046
7210
  const parsedBlock = blockBody ? parseBlockBodyTolerant(blockBody, ctx.sourceFile, (node2) => ctx.getJS(node2)) : undefined;
7047
7211
  const parsedBlockComplete = parsedBlock && blockBody ? parsedBlock.length === blockBody.statements.length : undefined;
7048
7212
  let templateComputation;
@@ -7069,14 +7233,14 @@ function collectMemo(node, ctx) {
7069
7233
  });
7070
7234
  }
7071
7235
  function isEffectCall(node, ctx) {
7072
- if (!ts10.isCallExpression(node))
7236
+ if (!ts11.isCallExpression(node))
7073
7237
  return false;
7074
7238
  return resolvePrimitiveKind(node, ctx) === "effect";
7075
7239
  }
7076
7240
  function isEffectDisposerCapture(node, ctx) {
7077
- if (!ts10.isIdentifier(node.name))
7241
+ if (!ts11.isIdentifier(node.name))
7078
7242
  return false;
7079
- if (!node.initializer || !ts10.isCallExpression(node.initializer))
7243
+ if (!node.initializer || !ts11.isCallExpression(node.initializer))
7080
7244
  return false;
7081
7245
  return resolvePrimitiveKind(node.initializer, ctx) === "effect";
7082
7246
  }
@@ -7091,7 +7255,7 @@ function collectEffect(node, ctx, captureName) {
7091
7255
  });
7092
7256
  }
7093
7257
  function isOnMountCall(node, ctx) {
7094
- if (!ts10.isCallExpression(node))
7258
+ if (!ts11.isCallExpression(node))
7095
7259
  return false;
7096
7260
  return resolvePrimitiveKind(node, ctx) === "onMount";
7097
7261
  }
@@ -7126,19 +7290,19 @@ function leadsWithAsiHazard(body) {
7126
7290
  function extractAssignedIdentifiersFromNode(node) {
7127
7291
  const ids = new Set;
7128
7292
  function addFromTarget(target) {
7129
- if (ts10.isIdentifier(target)) {
7293
+ if (ts11.isIdentifier(target)) {
7130
7294
  ids.add(target.text);
7131
7295
  return;
7132
7296
  }
7133
- if (ts10.isParenthesizedExpression(target)) {
7297
+ if (ts11.isParenthesizedExpression(target)) {
7134
7298
  addFromTarget(target.expression);
7135
7299
  return;
7136
7300
  }
7137
- if (ts10.isArrayLiteralExpression(target)) {
7301
+ if (ts11.isArrayLiteralExpression(target)) {
7138
7302
  for (const el of target.elements) {
7139
- if (ts10.isOmittedExpression(el))
7303
+ if (ts11.isOmittedExpression(el))
7140
7304
  continue;
7141
- if (ts10.isSpreadElement(el)) {
7305
+ if (ts11.isSpreadElement(el)) {
7142
7306
  addFromTarget(el.expression);
7143
7307
  continue;
7144
7308
  }
@@ -7146,17 +7310,17 @@ function extractAssignedIdentifiersFromNode(node) {
7146
7310
  }
7147
7311
  return;
7148
7312
  }
7149
- if (ts10.isObjectLiteralExpression(target)) {
7313
+ if (ts11.isObjectLiteralExpression(target)) {
7150
7314
  for (const prop of target.properties) {
7151
- if (ts10.isShorthandPropertyAssignment(prop)) {
7315
+ if (ts11.isShorthandPropertyAssignment(prop)) {
7152
7316
  ids.add(prop.name.text);
7153
7317
  continue;
7154
7318
  }
7155
- if (ts10.isPropertyAssignment(prop)) {
7319
+ if (ts11.isPropertyAssignment(prop)) {
7156
7320
  addFromTarget(prop.initializer);
7157
7321
  continue;
7158
7322
  }
7159
- if (ts10.isSpreadAssignment(prop)) {
7323
+ if (ts11.isSpreadAssignment(prop)) {
7160
7324
  addFromTarget(prop.expression);
7161
7325
  continue;
7162
7326
  }
@@ -7165,21 +7329,21 @@ function extractAssignedIdentifiersFromNode(node) {
7165
7329
  }
7166
7330
  }
7167
7331
  function visit2(n) {
7168
- if (ts10.isArrowFunction(n) || ts10.isFunctionExpression(n) || ts10.isFunctionDeclaration(n) || ts10.isMethodDeclaration(n) || ts10.isGetAccessorDeclaration(n) || ts10.isSetAccessorDeclaration(n) || ts10.isConstructorDeclaration(n)) {
7332
+ if (ts11.isArrowFunction(n) || ts11.isFunctionExpression(n) || ts11.isFunctionDeclaration(n) || ts11.isMethodDeclaration(n) || ts11.isGetAccessorDeclaration(n) || ts11.isSetAccessorDeclaration(n) || ts11.isConstructorDeclaration(n)) {
7169
7333
  return;
7170
7334
  }
7171
- if (ts10.isBinaryExpression(n)) {
7335
+ if (ts11.isBinaryExpression(n)) {
7172
7336
  const op = n.operatorToken.kind;
7173
- if (op === ts10.SyntaxKind.EqualsToken || op === ts10.SyntaxKind.PlusEqualsToken || op === ts10.SyntaxKind.MinusEqualsToken || op === ts10.SyntaxKind.AsteriskEqualsToken || op === ts10.SyntaxKind.SlashEqualsToken || op === ts10.SyntaxKind.PercentEqualsToken || op === ts10.SyntaxKind.AsteriskAsteriskEqualsToken || op === ts10.SyntaxKind.AmpersandEqualsToken || op === ts10.SyntaxKind.BarEqualsToken || op === ts10.SyntaxKind.CaretEqualsToken || op === ts10.SyntaxKind.LessThanLessThanEqualsToken || op === ts10.SyntaxKind.GreaterThanGreaterThanEqualsToken || op === ts10.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken || op === ts10.SyntaxKind.AmpersandAmpersandEqualsToken || op === ts10.SyntaxKind.BarBarEqualsToken || op === ts10.SyntaxKind.QuestionQuestionEqualsToken) {
7337
+ if (op === ts11.SyntaxKind.EqualsToken || op === ts11.SyntaxKind.PlusEqualsToken || op === ts11.SyntaxKind.MinusEqualsToken || op === ts11.SyntaxKind.AsteriskEqualsToken || op === ts11.SyntaxKind.SlashEqualsToken || op === ts11.SyntaxKind.PercentEqualsToken || op === ts11.SyntaxKind.AsteriskAsteriskEqualsToken || op === ts11.SyntaxKind.AmpersandEqualsToken || op === ts11.SyntaxKind.BarEqualsToken || op === ts11.SyntaxKind.CaretEqualsToken || op === ts11.SyntaxKind.LessThanLessThanEqualsToken || op === ts11.SyntaxKind.GreaterThanGreaterThanEqualsToken || op === ts11.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken || op === ts11.SyntaxKind.AmpersandAmpersandEqualsToken || op === ts11.SyntaxKind.BarBarEqualsToken || op === ts11.SyntaxKind.QuestionQuestionEqualsToken) {
7174
7338
  addFromTarget(n.left);
7175
7339
  }
7176
7340
  }
7177
- if (ts10.isPrefixUnaryExpression(n) || ts10.isPostfixUnaryExpression(n)) {
7178
- if (n.operator === ts10.SyntaxKind.PlusPlusToken || n.operator === ts10.SyntaxKind.MinusMinusToken) {
7341
+ if (ts11.isPrefixUnaryExpression(n) || ts11.isPostfixUnaryExpression(n)) {
7342
+ if (n.operator === ts11.SyntaxKind.PlusPlusToken || n.operator === ts11.SyntaxKind.MinusMinusToken) {
7179
7343
  addFromTarget(n.operand);
7180
7344
  }
7181
7345
  }
7182
- ts10.forEachChild(n, visit2);
7346
+ ts11.forEachChild(n, visit2);
7183
7347
  }
7184
7348
  visit2(node);
7185
7349
  const localDecls = collectLocalDeclarations(node);
@@ -7190,30 +7354,30 @@ function extractAssignedIdentifiersFromNode(node) {
7190
7354
  function collectLocalDeclarations(root) {
7191
7355
  const names = new Set;
7192
7356
  function addBindingName(name) {
7193
- if (ts10.isIdentifier(name)) {
7357
+ if (ts11.isIdentifier(name)) {
7194
7358
  names.add(name.text);
7195
7359
  return;
7196
7360
  }
7197
- if (ts10.isArrayBindingPattern(name)) {
7361
+ if (ts11.isArrayBindingPattern(name)) {
7198
7362
  for (const el of name.elements) {
7199
- if (ts10.isBindingElement(el))
7363
+ if (ts11.isBindingElement(el))
7200
7364
  addBindingName(el.name);
7201
7365
  }
7202
7366
  return;
7203
7367
  }
7204
- if (ts10.isObjectBindingPattern(name)) {
7368
+ if (ts11.isObjectBindingPattern(name)) {
7205
7369
  for (const el of name.elements) {
7206
7370
  addBindingName(el.name);
7207
7371
  }
7208
7372
  }
7209
7373
  }
7210
7374
  function visit2(n) {
7211
- if (ts10.isArrowFunction(n) || ts10.isFunctionExpression(n) || ts10.isFunctionDeclaration(n))
7375
+ if (ts11.isArrowFunction(n) || ts11.isFunctionExpression(n) || ts11.isFunctionDeclaration(n))
7212
7376
  return;
7213
- if (ts10.isVariableDeclaration(n)) {
7377
+ if (ts11.isVariableDeclaration(n)) {
7214
7378
  addBindingName(n.name);
7215
7379
  }
7216
- ts10.forEachChild(n, visit2);
7380
+ ts11.forEachChild(n, visit2);
7217
7381
  }
7218
7382
  visit2(root);
7219
7383
  return names;
@@ -7240,6 +7404,7 @@ var CLIENT_EXPORTS = new Set([
7240
7404
  "isSSRPortal",
7241
7405
  "findSiblingSlot",
7242
7406
  "cleanupPortalPlaceholder",
7407
+ "trackPosition",
7243
7408
  "createSearchParams",
7244
7409
  "queryHref",
7245
7410
  "formatDate",
@@ -7247,35 +7412,35 @@ var CLIENT_EXPORTS = new Set([
7247
7412
  "Region"
7248
7413
  ]);
7249
7414
  function collectAmbientGlobals(node, ctx) {
7250
- if (ts10.isVariableStatement(node)) {
7251
- const isDeclare = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DeclareKeyword) ?? false;
7415
+ if (ts11.isVariableStatement(node)) {
7416
+ const isDeclare = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DeclareKeyword) ?? false;
7252
7417
  if (!isDeclare)
7253
7418
  return;
7254
7419
  for (const decl of node.declarationList.declarations) {
7255
- if (ts10.isIdentifier(decl.name))
7420
+ if (ts11.isIdentifier(decl.name))
7256
7421
  ctx.ambientGlobals.add(decl.name.text);
7257
7422
  }
7258
7423
  return;
7259
7424
  }
7260
- if (ts10.isFunctionDeclaration(node) && node.name) {
7261
- const isDeclare = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DeclareKeyword) ?? false;
7425
+ if (ts11.isFunctionDeclaration(node) && node.name) {
7426
+ const isDeclare = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DeclareKeyword) ?? false;
7262
7427
  if (isDeclare)
7263
7428
  ctx.ambientGlobals.add(node.name.text);
7264
7429
  return;
7265
7430
  }
7266
- if (ts10.isModuleDeclaration(node)) {
7267
- const isGlobalAugmentation = (node.flags & ts10.NodeFlags.GlobalAugmentation) !== 0;
7431
+ if (ts11.isModuleDeclaration(node)) {
7432
+ const isGlobalAugmentation = (node.flags & ts11.NodeFlags.GlobalAugmentation) !== 0;
7268
7433
  if (!isGlobalAugmentation)
7269
7434
  return;
7270
- if (!node.body || !ts10.isModuleBlock(node.body))
7435
+ if (!node.body || !ts11.isModuleBlock(node.body))
7271
7436
  return;
7272
7437
  for (const inner of node.body.statements) {
7273
- if (ts10.isVariableStatement(inner)) {
7438
+ if (ts11.isVariableStatement(inner)) {
7274
7439
  for (const decl of inner.declarationList.declarations) {
7275
- if (ts10.isIdentifier(decl.name))
7440
+ if (ts11.isIdentifier(decl.name))
7276
7441
  ctx.ambientGlobals.add(decl.name.text);
7277
7442
  }
7278
- } else if (ts10.isFunctionDeclaration(inner) && inner.name) {
7443
+ } else if (ts11.isFunctionDeclaration(inner) && inner.name) {
7279
7444
  ctx.ambientGlobals.add(inner.name.text);
7280
7445
  }
7281
7446
  }
@@ -7286,7 +7451,7 @@ function collectImport(node, ctx) {
7286
7451
  const specifiers = [];
7287
7452
  const isTypeOnly = !!node.importClause?.isTypeOnly;
7288
7453
  const loc = getSourceLocation(node, ctx.sourceFile, ctx.filePath);
7289
- if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings && ts10.isNamedImports(node.importClause.namedBindings)) {
7454
+ if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings && ts11.isNamedImports(node.importClause.namedBindings)) {
7290
7455
  const wrongImports = [];
7291
7456
  for (const element of node.importClause.namedBindings.elements) {
7292
7457
  const name = element.propertyName?.text ?? element.name.text;
@@ -7314,7 +7479,7 @@ function collectImport(node, ctx) {
7314
7479
  });
7315
7480
  }
7316
7481
  if (node.importClause.namedBindings) {
7317
- if (ts10.isNamedImports(node.importClause.namedBindings)) {
7482
+ if (ts11.isNamedImports(node.importClause.namedBindings)) {
7318
7483
  for (const element of node.importClause.namedBindings.elements) {
7319
7484
  specifiers.push({
7320
7485
  name: element.propertyName?.text ?? element.name.text,
@@ -7325,7 +7490,7 @@ function collectImport(node, ctx) {
7325
7490
  });
7326
7491
  }
7327
7492
  }
7328
- if (ts10.isNamespaceImport(node.importClause.namedBindings)) {
7493
+ if (ts11.isNamespaceImport(node.importClause.namedBindings)) {
7329
7494
  specifiers.push({
7330
7495
  name: node.importClause.namedBindings.name.text,
7331
7496
  alias: null,
@@ -7352,7 +7517,7 @@ function collectInterfaceDefinition(node, ctx) {
7352
7517
  });
7353
7518
  }
7354
7519
  function collectTypeAliasDefinition(node, ctx) {
7355
- const properties = ts10.isTypeLiteralNode(node.type) ? membersToProperties(node.type.members, ctx.sourceFile) : undefined;
7520
+ const properties = ts11.isTypeLiteralNode(node.type) ? membersToProperties(node.type.members, ctx.sourceFile) : undefined;
7356
7521
  ctx.typeDefinitions.push({
7357
7522
  kind: "type",
7358
7523
  name: node.name.text,
@@ -7365,20 +7530,20 @@ function extractSingleJsxReturn(body) {
7365
7530
  let jsxReturn = null;
7366
7531
  let returnCount = 0;
7367
7532
  function visit2(node) {
7368
- if (ts10.isFunctionDeclaration(node) || ts10.isFunctionExpression(node) || ts10.isArrowFunction(node))
7533
+ if (ts11.isFunctionDeclaration(node) || ts11.isFunctionExpression(node) || ts11.isArrowFunction(node))
7369
7534
  return;
7370
- if (ts10.isReturnStatement(node)) {
7535
+ if (ts11.isReturnStatement(node)) {
7371
7536
  returnCount++;
7372
7537
  if (node.expression) {
7373
7538
  const expr = unwrapJsxTransparent(node.expression);
7374
- if (ts10.isJsxElement(expr) || ts10.isJsxSelfClosingElement(expr) || ts10.isJsxFragment(expr)) {
7539
+ if (ts11.isJsxElement(expr) || ts11.isJsxSelfClosingElement(expr) || ts11.isJsxFragment(expr)) {
7375
7540
  jsxReturn = expr;
7376
7541
  }
7377
7542
  }
7378
7543
  }
7379
- ts10.forEachChild(node, visit2);
7544
+ ts11.forEachChild(node, visit2);
7380
7545
  }
7381
- ts10.forEachChild(body, visit2);
7546
+ ts11.forEachChild(body, visit2);
7382
7547
  if (returnCount !== 1)
7383
7548
  return null;
7384
7549
  return jsxReturn;
@@ -7395,9 +7560,9 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
7395
7560
  const stmts = body.statements;
7396
7561
  for (let i = 0;i < stmts.length; i++) {
7397
7562
  const stmt = stmts[i];
7398
- if (ts10.isIfStatement(stmt)) {
7563
+ if (ts11.isIfStatement(stmt)) {
7399
7564
  let current = stmt;
7400
- while (ts10.isIfStatement(current)) {
7565
+ while (ts11.isIfStatement(current)) {
7401
7566
  const ifStmt = current;
7402
7567
  if (!isDirectReturnBlock(ifStmt.thenStatement))
7403
7568
  return null;
@@ -7407,7 +7572,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
7407
7572
  return null;
7408
7573
  branches.push({ condition: ifStmt.expression, jsxReturn: jsxReturn ?? null });
7409
7574
  if (ifStmt.elseStatement) {
7410
- if (ts10.isIfStatement(ifStmt.elseStatement)) {
7575
+ if (ts11.isIfStatement(ifStmt.elseStatement)) {
7411
7576
  current = ifStmt.elseStatement;
7412
7577
  continue;
7413
7578
  }
@@ -7429,18 +7594,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
7429
7594
  }
7430
7595
  continue;
7431
7596
  }
7432
- if (ts10.isSwitchStatement(stmt)) {
7597
+ if (ts11.isSwitchStatement(stmt)) {
7433
7598
  if (branches.length > 0)
7434
7599
  return null;
7435
- if (!ts10.isIdentifier(stmt.expression) && !ts10.isPropertyAccessExpression(stmt.expression)) {
7600
+ if (!ts11.isIdentifier(stmt.expression) && !ts11.isPropertyAccessExpression(stmt.expression)) {
7436
7601
  return null;
7437
7602
  }
7438
- const hasDefault = stmt.caseBlock.clauses.some((c) => ts10.isDefaultClause(c));
7603
+ const hasDefault = stmt.caseBlock.clauses.some((c) => ts11.isDefaultClause(c));
7439
7604
  if (!hasDefault)
7440
7605
  return null;
7441
7606
  let pendingCases = [];
7442
7607
  for (const clause of stmt.caseBlock.clauses) {
7443
- if (ts10.isCaseClause(clause) && clause.statements.length === 0) {
7608
+ if (ts11.isCaseClause(clause) && clause.statements.length === 0) {
7444
7609
  pendingCases.push(clause.expression);
7445
7610
  continue;
7446
7611
  }
@@ -7450,7 +7615,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
7450
7615
  return null;
7451
7616
  if (!caseClauseIsDirectReturn(clause))
7452
7617
  return null;
7453
- if (ts10.isCaseClause(clause)) {
7618
+ if (ts11.isCaseClause(clause)) {
7454
7619
  branches.push({
7455
7620
  condition: clause.expression,
7456
7621
  jsxReturn: jsxReturn ?? null,
@@ -7471,18 +7636,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
7471
7636
  return null;
7472
7637
  return { branches, fallback, switchDiscriminant: stmt.expression, preamble };
7473
7638
  }
7474
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7639
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
7475
7640
  const expr = unwrapJsxTransparent(stmt.expression);
7476
- if (ts10.isJsxElement(expr) || ts10.isJsxSelfClosingElement(expr) || ts10.isJsxFragment(expr)) {
7641
+ if (ts11.isJsxElement(expr) || ts11.isJsxSelfClosingElement(expr) || ts11.isJsxFragment(expr)) {
7477
7642
  fallback = expr;
7478
- } else if (expr.kind === ts10.SyntaxKind.NullKeyword) {} else {
7643
+ } else if (expr.kind === ts11.SyntaxKind.NullKeyword) {} else {
7479
7644
  return null;
7480
7645
  }
7481
7646
  continue;
7482
7647
  }
7483
- if (ts10.isVariableStatement(stmt)) {
7648
+ if (ts11.isVariableStatement(stmt)) {
7484
7649
  const declFlags = stmt.declarationList.flags;
7485
- const isConstOrLet = (declFlags & ts10.NodeFlags.Const) !== 0 || (declFlags & ts10.NodeFlags.Let) !== 0;
7650
+ const isConstOrLet = (declFlags & ts11.NodeFlags.Const) !== 0 || (declFlags & ts11.NodeFlags.Let) !== 0;
7486
7651
  if (allowPreamble && isConstOrLet && branches.length === 0 && fallback === null) {
7487
7652
  preamble.push(stmt);
7488
7653
  continue;
@@ -7498,12 +7663,12 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
7498
7663
  return { branches, fallback, preamble };
7499
7664
  }
7500
7665
  function isDirectReturnBlock(node) {
7501
- if (ts10.isReturnStatement(node))
7666
+ if (ts11.isReturnStatement(node))
7502
7667
  return true;
7503
- if (ts10.isBlock(node)) {
7668
+ if (ts11.isBlock(node)) {
7504
7669
  let returnCount = 0;
7505
7670
  for (const stmt of node.statements) {
7506
- if (ts10.isReturnStatement(stmt)) {
7671
+ if (ts11.isReturnStatement(stmt)) {
7507
7672
  returnCount++;
7508
7673
  continue;
7509
7674
  }
@@ -7514,25 +7679,25 @@ function isDirectReturnBlock(node) {
7514
7679
  return false;
7515
7680
  }
7516
7681
  function findNullReturnInBlock(node) {
7517
- if (ts10.isBlock(node)) {
7682
+ if (ts11.isBlock(node)) {
7518
7683
  for (const stmt of node.statements) {
7519
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7684
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
7520
7685
  const expr = unwrapJsxTransparent(stmt.expression);
7521
- if (expr.kind === ts10.SyntaxKind.NullKeyword)
7686
+ if (expr.kind === ts11.SyntaxKind.NullKeyword)
7522
7687
  return true;
7523
7688
  }
7524
7689
  }
7525
7690
  }
7526
- if (ts10.isReturnStatement(node) && node.expression) {
7691
+ if (ts11.isReturnStatement(node) && node.expression) {
7527
7692
  const expr = unwrapJsxTransparent(node.expression);
7528
- if (expr.kind === ts10.SyntaxKind.NullKeyword)
7693
+ if (expr.kind === ts11.SyntaxKind.NullKeyword)
7529
7694
  return true;
7530
7695
  }
7531
7696
  return false;
7532
7697
  }
7533
7698
  function findJsxReturnInCaseClause(clause) {
7534
7699
  for (const stmt of clause.statements) {
7535
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7700
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
7536
7701
  return extractJsxFromExpression(stmt.expression);
7537
7702
  }
7538
7703
  }
@@ -7542,12 +7707,12 @@ function caseClauseIsDirectReturn(clause) {
7542
7707
  let returnCount = 0;
7543
7708
  let seenReturn = false;
7544
7709
  for (const stmt of clause.statements) {
7545
- if (ts10.isReturnStatement(stmt)) {
7710
+ if (ts11.isReturnStatement(stmt)) {
7546
7711
  returnCount++;
7547
7712
  seenReturn = true;
7548
7713
  continue;
7549
7714
  }
7550
- if (ts10.isBreakStatement(stmt)) {
7715
+ if (ts11.isBreakStatement(stmt)) {
7551
7716
  if (!seenReturn)
7552
7717
  return false;
7553
7718
  continue;
@@ -7558,9 +7723,9 @@ function caseClauseIsDirectReturn(clause) {
7558
7723
  }
7559
7724
  function findNullReturnInCaseClause(clause) {
7560
7725
  for (const stmt of clause.statements) {
7561
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7726
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
7562
7727
  const expr = unwrapJsxTransparent(stmt.expression);
7563
- if (expr.kind === ts10.SyntaxKind.NullKeyword)
7728
+ if (expr.kind === ts11.SyntaxKind.NullKeyword)
7564
7729
  return true;
7565
7730
  }
7566
7731
  }
@@ -7571,26 +7736,26 @@ function isMultiReturnJsxFunctionBody(body) {
7571
7736
  let hasJsxReturn = false;
7572
7737
  let allReturnsAreJsxOrNull = true;
7573
7738
  function visit2(node) {
7574
- if (ts10.isFunctionDeclaration(node) || ts10.isFunctionExpression(node) || ts10.isArrowFunction(node))
7739
+ if (ts11.isFunctionDeclaration(node) || ts11.isFunctionExpression(node) || ts11.isArrowFunction(node))
7575
7740
  return;
7576
- if (ts10.isReturnStatement(node)) {
7741
+ if (ts11.isReturnStatement(node)) {
7577
7742
  returnCount++;
7578
7743
  if (!node.expression) {
7579
7744
  allReturnsAreJsxOrNull = false;
7580
7745
  return;
7581
7746
  }
7582
7747
  const expr = unwrapJsxTransparent(node.expression);
7583
- const isJsx = ts10.isJsxElement(expr) || ts10.isJsxSelfClosingElement(expr) || ts10.isJsxFragment(expr);
7584
- const isNull = expr.kind === ts10.SyntaxKind.NullKeyword;
7748
+ const isJsx = ts11.isJsxElement(expr) || ts11.isJsxSelfClosingElement(expr) || ts11.isJsxFragment(expr);
7749
+ const isNull = expr.kind === ts11.SyntaxKind.NullKeyword;
7585
7750
  if (isJsx)
7586
7751
  hasJsxReturn = true;
7587
7752
  if (!isJsx && !isNull)
7588
7753
  allReturnsAreJsxOrNull = false;
7589
7754
  return;
7590
7755
  }
7591
- ts10.forEachChild(node, visit2);
7756
+ ts11.forEachChild(node, visit2);
7592
7757
  }
7593
- ts10.forEachChild(body, visit2);
7758
+ ts11.forEachChild(body, visit2);
7594
7759
  return returnCount > 1 && hasJsxReturn && allReturnsAreJsxOrNull;
7595
7760
  }
7596
7761
  function collectFunction(node, ctx, _isModule, isExported = false) {
@@ -7660,7 +7825,7 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
7660
7825
  }
7661
7826
  }
7662
7827
  }
7663
- const isAsync = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.AsyncKeyword) ?? false;
7828
+ const isAsync = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.AsyncKeyword) ?? false;
7664
7829
  const isGenerator = !!node.asteriskToken;
7665
7830
  ctx.localFunctions.push({
7666
7831
  name,
@@ -7681,10 +7846,10 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
7681
7846
  });
7682
7847
  }
7683
7848
  function extractValueBranches(node, ctx) {
7684
- if (ts10.isParenthesizedExpression(node)) {
7849
+ if (ts11.isParenthesizedExpression(node)) {
7685
7850
  return extractValueBranches(node.expression, ctx);
7686
7851
  }
7687
- if (ts10.isConditionalExpression(node)) {
7852
+ if (ts11.isConditionalExpression(node)) {
7688
7853
  return [
7689
7854
  ...extractValueBranches(node.whenTrue, ctx),
7690
7855
  ...extractValueBranches(node.whenFalse, ctx)
@@ -7696,46 +7861,46 @@ function extractFreeIdentifiersFromNode(node) {
7696
7861
  const ids = new Set;
7697
7862
  const boundNames = new Set;
7698
7863
  function addBindingNames(name, out) {
7699
- if (ts10.isIdentifier(name))
7864
+ if (ts11.isIdentifier(name))
7700
7865
  out.push(name.text);
7701
- else if (ts10.isObjectBindingPattern(name))
7866
+ else if (ts11.isObjectBindingPattern(name))
7702
7867
  name.elements.forEach((e) => addBindingNames(e.name, out));
7703
- else if (ts10.isArrayBindingPattern(name))
7868
+ else if (ts11.isArrayBindingPattern(name))
7704
7869
  name.elements.forEach((e) => {
7705
- if (!ts10.isOmittedExpression(e))
7870
+ if (!ts11.isOmittedExpression(e))
7706
7871
  addBindingNames(e.name, out);
7707
7872
  });
7708
7873
  }
7709
7874
  function visit2(n) {
7710
- if (ts10.isTypeNode(n))
7875
+ if (ts11.isTypeNode(n))
7711
7876
  return;
7712
- if (ts10.isIdentifier(n)) {
7877
+ if (ts11.isIdentifier(n)) {
7713
7878
  const parent = n.parent;
7714
- if (parent && ts10.isPropertyAccessExpression(parent) && parent.name === n)
7879
+ if (parent && ts11.isPropertyAccessExpression(parent) && parent.name === n)
7715
7880
  return;
7716
- if (parent && ts10.isPropertyAssignment(parent) && parent.name === n)
7881
+ if (parent && ts11.isPropertyAssignment(parent) && parent.name === n)
7717
7882
  return;
7718
- if (parent && ts10.isParameter(parent) && parent.name === n)
7883
+ if (parent && ts11.isParameter(parent) && parent.name === n)
7719
7884
  return;
7720
- if (parent && ts10.isVariableDeclaration(parent) && parent.name === n)
7885
+ if (parent && ts11.isVariableDeclaration(parent) && parent.name === n)
7721
7886
  return;
7722
7887
  if (boundNames.has(n.text))
7723
7888
  return;
7724
7889
  ids.add(n.text);
7725
7890
  return;
7726
7891
  }
7727
- if (ts10.isArrowFunction(n)) {
7892
+ if (ts11.isArrowFunction(n)) {
7728
7893
  const params = [];
7729
7894
  for (const p of n.parameters)
7730
7895
  addBindingNames(p.name, params);
7731
7896
  for (const name of params)
7732
7897
  boundNames.add(name);
7733
- ts10.forEachChild(n, visit2);
7898
+ ts11.forEachChild(n, visit2);
7734
7899
  for (const name of params)
7735
7900
  boundNames.delete(name);
7736
7901
  return;
7737
7902
  }
7738
- ts10.forEachChild(n, visit2);
7903
+ ts11.forEachChild(n, visit2);
7739
7904
  }
7740
7905
  visit2(node);
7741
7906
  return ids;
@@ -7744,29 +7909,29 @@ function extractFreeTypeIdentifiersFromNode(node) {
7744
7909
  const ids = new Set;
7745
7910
  const boundTypeParams = new Set;
7746
7911
  function rootName(name) {
7747
- return ts10.isQualifiedName(name) ? rootName(name.left) : name;
7912
+ return ts11.isQualifiedName(name) ? rootName(name.left) : name;
7748
7913
  }
7749
7914
  function visit2(n) {
7750
- if (ts10.isTypeReferenceNode(n)) {
7915
+ if (ts11.isTypeReferenceNode(n)) {
7751
7916
  const name = rootName(n.typeName).text;
7752
7917
  if (!boundTypeParams.has(name))
7753
7918
  ids.add(name);
7754
7919
  }
7755
- if (ts10.isTypeQueryNode(n)) {
7920
+ if (ts11.isTypeQueryNode(n)) {
7756
7921
  const name = rootName(n.exprName).text;
7757
7922
  if (!boundTypeParams.has(name))
7758
7923
  ids.add(name);
7759
7924
  }
7760
- if (ts10.isFunctionLike(n) && n.typeParameters && n.typeParameters.length > 0) {
7925
+ if (ts11.isFunctionLike(n) && n.typeParameters && n.typeParameters.length > 0) {
7761
7926
  const names = n.typeParameters.map((p) => p.name.text);
7762
7927
  for (const p of names)
7763
7928
  boundTypeParams.add(p);
7764
- ts10.forEachChild(n, visit2);
7929
+ ts11.forEachChild(n, visit2);
7765
7930
  for (const p of names)
7766
7931
  boundTypeParams.delete(p);
7767
7932
  return;
7768
7933
  }
7769
- ts10.forEachChild(n, visit2);
7934
+ ts11.forEachChild(n, visit2);
7770
7935
  }
7771
7936
  visit2(node);
7772
7937
  return ids;
@@ -7776,22 +7941,22 @@ function initializerShapeContainsJsx(node) {
7776
7941
  function visit2(n) {
7777
7942
  if (found)
7778
7943
  return;
7779
- if (ts10.isJsxElement(n) || ts10.isJsxSelfClosingElement(n) || ts10.isJsxFragment(n)) {
7944
+ if (ts11.isJsxElement(n) || ts11.isJsxSelfClosingElement(n) || ts11.isJsxFragment(n)) {
7780
7945
  found = true;
7781
7946
  return;
7782
7947
  }
7783
- if (ts10.isFunctionDeclaration(n) || ts10.isFunctionExpression(n) || ts10.isArrowFunction(n)) {
7948
+ if (ts11.isFunctionDeclaration(n) || ts11.isFunctionExpression(n) || ts11.isArrowFunction(n)) {
7784
7949
  return;
7785
7950
  }
7786
- ts10.forEachChild(n, visit2);
7951
+ ts11.forEachChild(n, visit2);
7787
7952
  }
7788
7953
  visit2(node);
7789
7954
  return found;
7790
7955
  }
7791
7956
  function isMapLikeCallWithJsx(node) {
7792
- if (!ts10.isCallExpression(node))
7957
+ if (!ts11.isCallExpression(node))
7793
7958
  return false;
7794
- if (!ts10.isPropertyAccessExpression(node.expression))
7959
+ if (!ts11.isPropertyAccessExpression(node.expression))
7795
7960
  return false;
7796
7961
  const method = node.expression.name.text;
7797
7962
  if (method !== "map" && method !== "flatMap")
@@ -7799,12 +7964,12 @@ function isMapLikeCallWithJsx(node) {
7799
7964
  const callback = node.arguments[0];
7800
7965
  if (!callback)
7801
7966
  return false;
7802
- if (!ts10.isArrowFunction(callback) && !ts10.isFunctionExpression(callback))
7967
+ if (!ts11.isArrowFunction(callback) && !ts11.isFunctionExpression(callback))
7803
7968
  return false;
7804
7969
  return containsJsxDeep(callback.body);
7805
7970
  }
7806
7971
  function containsJsxDeep(node) {
7807
- if (ts10.isJsxElement(node) || ts10.isJsxSelfClosingElement(node) || ts10.isJsxFragment(node))
7972
+ if (ts11.isJsxElement(node) || ts11.isJsxSelfClosingElement(node) || ts11.isJsxFragment(node))
7808
7973
  return true;
7809
7974
  let found = false;
7810
7975
  node.forEachChild((child) => {
@@ -7818,11 +7983,11 @@ function nodeContainsArrow(node) {
7818
7983
  function visit2(n) {
7819
7984
  if (found)
7820
7985
  return;
7821
- if (ts10.isArrowFunction(n) || ts10.isFunctionExpression(n)) {
7986
+ if (ts11.isArrowFunction(n) || ts11.isFunctionExpression(n)) {
7822
7987
  found = true;
7823
7988
  return;
7824
7989
  }
7825
- ts10.forEachChild(n, visit2);
7990
+ ts11.forEachChild(n, visit2);
7826
7991
  }
7827
7992
  visit2(node);
7828
7993
  return found;
@@ -7870,20 +8035,20 @@ function collectModuleScopeReactive(decl, ctx, isExported) {
7870
8035
  }));
7871
8036
  }
7872
8037
  function getSystemConstructKind(node) {
7873
- if (ts10.isCallExpression(node) && ts10.isIdentifier(node.expression) && node.expression.text === "createContext")
8038
+ if (ts11.isCallExpression(node) && ts11.isIdentifier(node.expression) && node.expression.text === "createContext")
7874
8039
  return "createContext";
7875
- if (ts10.isNewExpression(node) && ts10.isIdentifier(node.expression) && node.expression.text === "WeakMap")
8040
+ if (ts11.isNewExpression(node) && ts11.isIdentifier(node.expression) && node.expression.text === "WeakMap")
7876
8041
  return "weakMap";
7877
8042
  return;
7878
8043
  }
7879
8044
  function collectConstant(node, ctx, _isModule, declarationKind = "const", isExported = false) {
7880
- if (!_isModule && ts10.isObjectBindingPattern(node.name) && node.initializer && ts10.isIdentifier(node.initializer) && ctx.propsObjectName === node.initializer.text) {
8045
+ if (!_isModule && ts11.isObjectBindingPattern(node.name) && node.initializer && ts11.isIdentifier(node.initializer) && ctx.propsObjectName === node.initializer.text) {
7881
8046
  const propsName = node.initializer.text;
7882
8047
  for (const el of node.name.elements) {
7883
- if (!ts10.isBindingElement(el) || !ts10.isIdentifier(el.name) || el.dotDotDotToken)
8048
+ if (!ts11.isBindingElement(el) || !ts11.isIdentifier(el.name) || el.dotDotDotToken)
7884
8049
  continue;
7885
8050
  const localName = el.name.text;
7886
- const sourceKey = el.propertyName && ts10.isIdentifier(el.propertyName) ? el.propertyName.text : localName;
8051
+ const sourceKey = el.propertyName && ts11.isIdentifier(el.propertyName) ? el.propertyName.text : localName;
7887
8052
  const defaultValueExpr = el.initializer ? ctx.getJS(el.initializer) : undefined;
7888
8053
  const baseValue = `${propsName}.${sourceKey}`;
7889
8054
  const value2 = defaultValueExpr ? `${baseValue} ?? ${defaultValueExpr}` : baseValue;
@@ -7905,7 +8070,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7905
8070
  }
7906
8071
  return;
7907
8072
  }
7908
- if (!ts10.isIdentifier(node.name))
8073
+ if (!ts11.isIdentifier(node.name))
7909
8074
  return;
7910
8075
  if (isSignalDeclaration(node, ctx) || isMemoDeclaration(node, ctx))
7911
8076
  return;
@@ -7923,9 +8088,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7923
8088
  let isJsxFunction = false;
7924
8089
  if (node.initializer) {
7925
8090
  let init = node.initializer;
7926
- while (ts10.isParenthesizedExpression(init))
8091
+ while (ts11.isParenthesizedExpression(init))
7927
8092
  init = init.expression;
7928
- if (ts10.isJsxElement(init) || ts10.isJsxSelfClosingElement(init) || ts10.isJsxFragment(init)) {
8093
+ if (ts11.isJsxElement(init) || ts11.isJsxSelfClosingElement(init) || ts11.isJsxFragment(init)) {
7929
8094
  isJsx = true;
7930
8095
  ctx.jsxConstants.set(name, init);
7931
8096
  } else if (initializerShapeContainsJsx(init)) {
@@ -7933,9 +8098,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7933
8098
  } else if (isMapLikeCallWithJsx(init)) {
7934
8099
  ctx.inlineableJsxConsts.set(name, init);
7935
8100
  }
7936
- if (ts10.isArrowFunction(init)) {
8101
+ if (ts11.isArrowFunction(init)) {
7937
8102
  const arrowBody = init.body;
7938
- if (ts10.isBlock(arrowBody)) {
8103
+ if (ts11.isBlock(arrowBody)) {
7939
8104
  const jsxReturn = extractSingleJsxReturn(arrowBody);
7940
8105
  if (jsxReturn) {
7941
8106
  isJsxFunction = true;
@@ -7955,9 +8120,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7955
8120
  }
7956
8121
  } else {
7957
8122
  let body = arrowBody;
7958
- while (ts10.isParenthesizedExpression(body))
8123
+ while (ts11.isParenthesizedExpression(body))
7959
8124
  body = body.expression;
7960
- if (ts10.isJsxElement(body) || ts10.isJsxSelfClosingElement(body) || ts10.isJsxFragment(body)) {
8125
+ if (ts11.isJsxElement(body) || ts11.isJsxSelfClosingElement(body) || ts11.isJsxFragment(body)) {
7961
8126
  isJsxFunction = true;
7962
8127
  ctx.jsxFunctions.set(name, {
7963
8128
  jsxReturn: body,
@@ -7970,9 +8135,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7970
8135
  let valueBranches;
7971
8136
  if (node.initializer) {
7972
8137
  let inner = node.initializer;
7973
- while (ts10.isParenthesizedExpression(inner))
8138
+ while (ts11.isParenthesizedExpression(inner))
7974
8139
  inner = inner.expression;
7975
- if (ts10.isConditionalExpression(inner)) {
8140
+ if (ts11.isConditionalExpression(inner)) {
7976
8141
  valueBranches = extractValueBranches(node.initializer, ctx);
7977
8142
  }
7978
8143
  }
@@ -8050,7 +8215,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
8050
8215
  function hasIgnoreDirective(node, sourceFile, ruleId) {
8051
8216
  const checkComments = (targetNode) => {
8052
8217
  const fullStart = targetNode.getFullStart();
8053
- const leadingComments = ts10.getLeadingCommentRanges(sourceFile.getFullText(), fullStart);
8218
+ const leadingComments = ts11.getLeadingCommentRanges(sourceFile.getFullText(), fullStart);
8054
8219
  if (!leadingComments)
8055
8220
  return false;
8056
8221
  for (const range of leadingComments) {
@@ -8063,10 +8228,10 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
8063
8228
  };
8064
8229
  if (checkComments(node))
8065
8230
  return true;
8066
- if (ts10.isArrowFunction(node)) {
8231
+ if (ts11.isArrowFunction(node)) {
8067
8232
  let current = node.parent;
8068
8233
  while (current) {
8069
- if (ts10.isVariableStatement(current)) {
8234
+ if (ts11.isVariableStatement(current)) {
8070
8235
  if (checkComments(current))
8071
8236
  return true;
8072
8237
  break;
@@ -8077,7 +8242,7 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
8077
8242
  return false;
8078
8243
  }
8079
8244
  function extractProps(param, ctx) {
8080
- if (ts10.isObjectBindingPattern(param.name)) {
8245
+ if (ts11.isObjectBindingPattern(param.name)) {
8081
8246
  const componentNode = ctx.componentNode;
8082
8247
  const ignored = !!(componentNode && hasIgnoreDirective(componentNode, ctx.sourceFile, "props-destructuring"));
8083
8248
  ctx.propsDestructuring = {
@@ -8086,14 +8251,14 @@ function extractProps(param, ctx) {
8086
8251
  };
8087
8252
  const memberTypes = param.type ? collectMemberTypes(param.type, ctx) : null;
8088
8253
  for (const element of param.name.elements) {
8089
- if (ts10.isBindingElement(element) && ts10.isIdentifier(element.name)) {
8254
+ if (ts11.isBindingElement(element) && ts11.isIdentifier(element.name)) {
8090
8255
  const localName = element.name.text;
8091
8256
  const defaultValue = element.initializer ? ctx.getJS(element.initializer) : undefined;
8092
8257
  if (element.dotDotDotToken) {
8093
8258
  ctx.restPropsName = localName;
8094
8259
  continue;
8095
8260
  }
8096
- const sourcePropName = element.propertyName && ts10.isIdentifier(element.propertyName) ? element.propertyName.text : localName;
8261
+ const sourcePropName = element.propertyName && ts11.isIdentifier(element.propertyName) ? element.propertyName.text : localName;
8097
8262
  const member = memberTypes?.get(sourcePropName);
8098
8263
  const resolvedType = member?.type ?? { kind: "unknown", raw: "unknown" };
8099
8264
  const defaultContainsArrow = element.initializer ? nodeContainsArrow(element.initializer) : false;
@@ -8117,7 +8282,7 @@ function extractProps(param, ctx) {
8117
8282
  }
8118
8283
  }
8119
8284
  }
8120
- if (ts10.isIdentifier(param.name)) {
8285
+ if (ts11.isIdentifier(param.name)) {
8121
8286
  ctx.propsObjectName = param.name.text;
8122
8287
  if (param.type) {
8123
8288
  extractPropsFromType(param.type, ctx);
@@ -8128,24 +8293,24 @@ function extractProps(param, ctx) {
8128
8293
  }
8129
8294
  }
8130
8295
  function collectTypeKeys(typeNode, ctx) {
8131
- if (ts10.isTypeLiteralNode(typeNode)) {
8296
+ if (ts11.isTypeLiteralNode(typeNode)) {
8132
8297
  return collectKeysFromMembers(typeNode.members, ctx);
8133
8298
  }
8134
- if (ts10.isTypeReferenceNode(typeNode)) {
8299
+ if (ts11.isTypeReferenceNode(typeNode)) {
8135
8300
  const typeName = typeNode.typeName.getText(ctx.sourceFile);
8136
8301
  const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
8137
8302
  if (!typeDecl)
8138
8303
  return null;
8139
- if (ts10.isInterfaceDeclaration(typeDecl)) {
8304
+ if (ts11.isInterfaceDeclaration(typeDecl)) {
8140
8305
  if (typeDecl.heritageClauses && typeDecl.heritageClauses.length > 0)
8141
8306
  return null;
8142
8307
  return collectKeysFromMembers(typeDecl.members, ctx);
8143
8308
  }
8144
- if (ts10.isTypeAliasDeclaration(typeDecl)) {
8145
- if (ts10.isTypeLiteralNode(typeDecl.type)) {
8309
+ if (ts11.isTypeAliasDeclaration(typeDecl)) {
8310
+ if (ts11.isTypeLiteralNode(typeDecl.type)) {
8146
8311
  return collectKeysFromMembers(typeDecl.type.members, ctx);
8147
8312
  }
8148
- if (ts10.isIntersectionTypeNode(typeDecl.type)) {
8313
+ if (ts11.isIntersectionTypeNode(typeDecl.type)) {
8149
8314
  return null;
8150
8315
  }
8151
8316
  }
@@ -8155,9 +8320,9 @@ function collectTypeKeys(typeNode, ctx) {
8155
8320
  function collectKeysFromMembers(members, ctx) {
8156
8321
  const keys = [];
8157
8322
  for (const member of members) {
8158
- if (ts10.isIndexSignatureDeclaration(member))
8323
+ if (ts11.isIndexSignatureDeclaration(member))
8159
8324
  return null;
8160
- if (ts10.isPropertySignature(member) && member.name) {
8325
+ if (ts11.isPropertySignature(member) && member.name) {
8161
8326
  keys.push(member.name.getText(ctx.sourceFile));
8162
8327
  }
8163
8328
  }
@@ -8181,7 +8346,7 @@ function collectMemberTypes(typeNode, ctx) {
8181
8346
  const fromMembers = (members) => {
8182
8347
  const map = new Map;
8183
8348
  for (const member of members) {
8184
- if (ts10.isPropertySignature(member) && member.name) {
8349
+ if (ts11.isPropertySignature(member) && member.name) {
8185
8350
  const info = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : null;
8186
8351
  map.set(member.name.getText(ctx.sourceFile), {
8187
8352
  type: info && isResolvableMemberType(info) ? info : null,
@@ -8191,35 +8356,35 @@ function collectMemberTypes(typeNode, ctx) {
8191
8356
  }
8192
8357
  return map;
8193
8358
  };
8194
- if (ts10.isTypeLiteralNode(typeNode)) {
8359
+ if (ts11.isTypeLiteralNode(typeNode)) {
8195
8360
  return fromMembers(typeNode.members);
8196
8361
  }
8197
- if (ts10.isTypeReferenceNode(typeNode)) {
8362
+ if (ts11.isTypeReferenceNode(typeNode)) {
8198
8363
  const typeName = typeNode.typeName.getText(ctx.sourceFile);
8199
8364
  const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
8200
8365
  if (!typeDecl)
8201
8366
  return null;
8202
- if (ts10.isInterfaceDeclaration(typeDecl)) {
8367
+ if (ts11.isInterfaceDeclaration(typeDecl)) {
8203
8368
  return fromMembers(typeDecl.members);
8204
8369
  }
8205
- if (ts10.isTypeAliasDeclaration(typeDecl) && ts10.isTypeLiteralNode(typeDecl.type)) {
8370
+ if (ts11.isTypeAliasDeclaration(typeDecl) && ts11.isTypeLiteralNode(typeDecl.type)) {
8206
8371
  return fromMembers(typeDecl.type.members);
8207
8372
  }
8208
8373
  }
8209
8374
  return null;
8210
8375
  }
8211
8376
  function extractPropsFromType(typeNode, ctx) {
8212
- if (ts10.isTypeLiteralNode(typeNode)) {
8377
+ if (ts11.isTypeLiteralNode(typeNode)) {
8213
8378
  extractPropsFromTypeMembers(typeNode.members, ctx);
8214
8379
  return;
8215
8380
  }
8216
- if (ts10.isTypeReferenceNode(typeNode)) {
8381
+ if (ts11.isTypeReferenceNode(typeNode)) {
8217
8382
  const typeName = typeNode.typeName.getText(ctx.sourceFile);
8218
8383
  const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
8219
8384
  if (typeDecl) {
8220
- if (ts10.isInterfaceDeclaration(typeDecl)) {
8385
+ if (ts11.isInterfaceDeclaration(typeDecl)) {
8221
8386
  extractPropsFromTypeMembers(typeDecl.members, ctx);
8222
- } else if (ts10.isTypeAliasDeclaration(typeDecl) && ts10.isTypeLiteralNode(typeDecl.type)) {
8387
+ } else if (ts11.isTypeAliasDeclaration(typeDecl) && ts11.isTypeLiteralNode(typeDecl.type)) {
8223
8388
  extractPropsFromTypeMembers(typeDecl.type.members, ctx);
8224
8389
  }
8225
8390
  }
@@ -8227,7 +8392,7 @@ function extractPropsFromType(typeNode, ctx) {
8227
8392
  }
8228
8393
  function extractPropsFromTypeMembers(members, ctx) {
8229
8394
  for (const member of members) {
8230
- if (ts10.isPropertySignature(member) && member.name) {
8395
+ if (ts11.isPropertySignature(member) && member.name) {
8231
8396
  const propName = member.name.getText(ctx.sourceFile);
8232
8397
  const isOptional = !!member.questionToken;
8233
8398
  const propType = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : { kind: "unknown", raw: "unknown" };
@@ -8243,17 +8408,17 @@ function extractPropsFromTypeMembers(members, ctx) {
8243
8408
  function findTypeDeclaration(typeName, sourceFile) {
8244
8409
  let result;
8245
8410
  function visit2(node) {
8246
- if (ts10.isInterfaceDeclaration(node) && node.name.text === typeName) {
8411
+ if (ts11.isInterfaceDeclaration(node) && node.name.text === typeName) {
8247
8412
  result = node;
8248
8413
  return;
8249
8414
  }
8250
- if (ts10.isTypeAliasDeclaration(node) && node.name.text === typeName) {
8415
+ if (ts11.isTypeAliasDeclaration(node) && node.name.text === typeName) {
8251
8416
  result = node;
8252
8417
  return;
8253
8418
  }
8254
- ts10.forEachChild(node, visit2);
8419
+ ts11.forEachChild(node, visit2);
8255
8420
  }
8256
- ts10.forEachChild(sourceFile, visit2);
8421
+ ts11.forEachChild(sourceFile, visit2);
8257
8422
  return result;
8258
8423
  }
8259
8424
  function inferTypeFromValue(value) {
@@ -8299,12 +8464,12 @@ function inferTypeFromValue(value) {
8299
8464
  }
8300
8465
  function collectCalledIdentifiers(code) {
8301
8466
  const called = new Set;
8302
- const sf = ts10.createSourceFile("__deps__.tsx", code, ts10.ScriptTarget.Latest, false, ts10.ScriptKind.TSX);
8467
+ const sf = ts11.createSourceFile("__deps__.tsx", code, ts11.ScriptTarget.Latest, false, ts11.ScriptKind.TSX);
8303
8468
  const visit2 = (node) => {
8304
- if (ts10.isCallExpression(node) && ts10.isIdentifier(node.expression)) {
8469
+ if (ts11.isCallExpression(node) && ts11.isIdentifier(node.expression)) {
8305
8470
  called.add(node.expression.text);
8306
8471
  }
8307
- ts10.forEachChild(node, visit2);
8472
+ ts11.forEachChild(node, visit2);
8308
8473
  };
8309
8474
  visit2(sf);
8310
8475
  return called;
@@ -8402,16 +8567,16 @@ function isResolvableComponentSource(source) {
8402
8567
  function collectJsxComponentTags(sourceFile) {
8403
8568
  const tags = new Set;
8404
8569
  function visit2(node) {
8405
- if (ts10.isJsxOpeningElement(node) || ts10.isJsxSelfClosingElement(node)) {
8570
+ if (ts11.isJsxOpeningElement(node) || ts11.isJsxSelfClosingElement(node)) {
8406
8571
  const tagName = node.tagName;
8407
- if (ts10.isIdentifier(tagName)) {
8572
+ if (ts11.isIdentifier(tagName)) {
8408
8573
  const first = tagName.text.charAt(0);
8409
8574
  if (first >= "A" && first <= "Z") {
8410
8575
  tags.add(tagName.text);
8411
8576
  }
8412
8577
  }
8413
8578
  }
8414
- ts10.forEachChild(node, visit2);
8579
+ ts11.forEachChild(node, visit2);
8415
8580
  }
8416
8581
  visit2(sourceFile);
8417
8582
  return tags;
@@ -8490,18 +8655,18 @@ function fileHasUseClientDirective(filePath) {
8490
8655
  } catch {
8491
8656
  return true;
8492
8657
  }
8493
- const sf = ts10.createSourceFile(filePath, content, ts10.ScriptTarget.Latest, false, ts10.ScriptKind.TSX);
8658
+ const sf = ts11.createSourceFile(filePath, content, ts11.ScriptTarget.Latest, false, ts11.ScriptKind.TSX);
8494
8659
  let found = false;
8495
8660
  function visit2(node) {
8496
8661
  if (found)
8497
8662
  return;
8498
- if (ts10.isExpressionStatement(node) && ts10.isStringLiteral(node.expression)) {
8663
+ if (ts11.isExpressionStatement(node) && ts11.isStringLiteral(node.expression)) {
8499
8664
  if (node.expression.text === "use client") {
8500
8665
  found = true;
8501
8666
  return;
8502
8667
  }
8503
8668
  }
8504
- ts10.forEachChild(node, visit2);
8669
+ ts11.forEachChild(node, visit2);
8505
8670
  }
8506
8671
  visit2(sf);
8507
8672
  return found;
@@ -8559,7 +8724,8 @@ var BROWSER_ONLY_CLIENT_APIS = new Set([
8559
8724
  "createPortal",
8560
8725
  "isSSRPortal",
8561
8726
  "findSiblingSlot",
8562
- "cleanupPortalPlaceholder"
8727
+ "cleanupPortalPlaceholder",
8728
+ "trackPosition"
8563
8729
  ]);
8564
8730
  function importsBrowserOnlyClientApi(ctx) {
8565
8731
  for (const imp of ctx.imports) {
@@ -8578,11 +8744,11 @@ function importsBrowserOnlyClientApi(ctx) {
8578
8744
  return false;
8579
8745
  }
8580
8746
  function listComponentFunctions(source, filePath) {
8581
- const sourceFile = ts10.createSourceFile(filePath, source, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
8747
+ const sourceFile = ts11.createSourceFile(filePath, source, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
8582
8748
  return listComponentFunctionsFromSourceFile(sourceFile);
8583
8749
  }
8584
8750
  function scanComponentFile(source, filePath) {
8585
- const sourceFile = ts10.createSourceFile(filePath, source, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
8751
+ const sourceFile = ts11.createSourceFile(filePath, source, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
8586
8752
  return {
8587
8753
  exports: listComponentFunctionsFromSourceFile(sourceFile),
8588
8754
  referencedComponents: [...collectJsxComponentTags(sourceFile)]
@@ -8590,11 +8756,11 @@ function scanComponentFile(source, filePath) {
8590
8756
  }
8591
8757
  function listComponentFunctionsFromSourceFile(sourceFile) {
8592
8758
  const componentNames = [];
8593
- const hasUseClient = sourceFile.statements.some((stmt) => ts10.isExpressionStatement(stmt) && ts10.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
8759
+ const hasUseClient = sourceFile.statements.some((stmt) => ts11.isExpressionStatement(stmt) && ts11.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
8594
8760
  const namedExports = collectNamedExports(sourceFile);
8595
8761
  function collectComponents(node) {
8596
8762
  if (isComponentFunction(node)) {
8597
- const hasInlineExport = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
8763
+ const hasInlineExport = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
8598
8764
  const hasNamedExport = namedExports.has(node.name.text);
8599
8765
  const isExported = hasInlineExport || hasNamedExport;
8600
8766
  if (!hasUseClient && !isExported && node.body && isMultiReturnJsxFunctionBody(node.body)) {} else {
@@ -8604,9 +8770,9 @@ function listComponentFunctionsFromSourceFile(sourceFile) {
8604
8770
  if (isArrowComponentFunction(node)) {
8605
8771
  componentNames.push(node.name.text);
8606
8772
  }
8607
- ts10.forEachChild(node, collectComponents);
8773
+ ts11.forEachChild(node, collectComponents);
8608
8774
  }
8609
- ts10.forEachChild(sourceFile, collectComponents);
8775
+ ts11.forEachChild(sourceFile, collectComponents);
8610
8776
  return componentNames;
8611
8777
  }
8612
8778
  var REACTIVE_PRIMITIVES = new Set([
@@ -8618,13 +8784,13 @@ var REACTIVE_PRIMITIVES = new Set([
8618
8784
  "onCleanup"
8619
8785
  ]);
8620
8786
  function prescanReactiveFactoriesInSource(source, filePath) {
8621
- const sourceFile = ts10.createSourceFile(filePath + ".prescan", source, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
8787
+ const sourceFile = ts11.createSourceFile(filePath + ".prescan", source, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
8622
8788
  const factories = new Map;
8623
8789
  const declined = new Map;
8624
8790
  const reactiveShaped = new Set;
8625
8791
  const cleanFactoryImports = new Set;
8626
8792
  function visitTop(node) {
8627
- if (ts10.isFunctionDeclaration(node) && node.name && node.body) {
8793
+ if (ts11.isFunctionDeclaration(node) && node.name && node.body) {
8628
8794
  const det = detectReactiveFactory(node, sourceFile, filePath);
8629
8795
  if (!det)
8630
8796
  return;
@@ -8641,7 +8807,7 @@ function prescanReactiveFactoriesInSource(source, filePath) {
8641
8807
  }
8642
8808
  }
8643
8809
  }
8644
- ts10.forEachChild(sourceFile, visitTop);
8810
+ ts11.forEachChild(sourceFile, visitTop);
8645
8811
  const result = { factories, declined, reactiveShaped, cleanFactoryImports, sourceFile };
8646
8812
  prescanImportedReactiveFactories(sourceFile, filePath, result);
8647
8813
  return result;
@@ -8658,15 +8824,15 @@ function toComponentRelativeSpecifier(resolvedAbs, componentFilePath) {
8658
8824
  function buildEntryImportIndex(sf, filePath) {
8659
8825
  const index = new Map;
8660
8826
  for (const stmt of sf.statements) {
8661
- if (!ts10.isImportDeclaration(stmt))
8827
+ if (!ts11.isImportDeclaration(stmt))
8662
8828
  continue;
8663
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
8829
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
8664
8830
  continue;
8665
8831
  const src = stmt.moduleSpecifier.text;
8666
8832
  const targetKey = src.startsWith("./") || src.startsWith("../") ? resolveRelativeImportToFile(src, filePath) ?? "unresolved:" + src : src;
8667
8833
  const wholeTypeOnly = stmt.importClause?.isTypeOnly === true;
8668
8834
  const namedBindings = stmt.importClause?.namedBindings;
8669
- if (namedBindings && ts10.isNamedImports(namedBindings)) {
8835
+ if (namedBindings && ts11.isNamedImports(namedBindings)) {
8670
8836
  for (const el of namedBindings.elements) {
8671
8837
  index.set(el.name.text, {
8672
8838
  targetKey,
@@ -8681,31 +8847,31 @@ function buildEntryImportIndex(sf, filePath) {
8681
8847
  function collectEntryBindingNames(sf) {
8682
8848
  const names = new Set;
8683
8849
  function visit2(node) {
8684
- if (ts10.isImportDeclaration(node) && node.importClause) {
8850
+ if (ts11.isImportDeclaration(node) && node.importClause) {
8685
8851
  if (node.importClause.name)
8686
8852
  names.add(node.importClause.name.text);
8687
8853
  const namedBindings = node.importClause.namedBindings;
8688
- if (namedBindings && ts10.isNamedImports(namedBindings)) {
8854
+ if (namedBindings && ts11.isNamedImports(namedBindings)) {
8689
8855
  for (const el of namedBindings.elements)
8690
8856
  names.add(el.name.text);
8691
8857
  }
8692
- if (namedBindings && ts10.isNamespaceImport(namedBindings)) {
8858
+ if (namedBindings && ts11.isNamespaceImport(namedBindings)) {
8693
8859
  names.add(namedBindings.name.text);
8694
8860
  }
8695
8861
  }
8696
- if (ts10.isVariableDeclaration(node)) {
8862
+ if (ts11.isVariableDeclaration(node)) {
8697
8863
  const out = [];
8698
8864
  addBindingNames(node.name, out);
8699
8865
  for (const n of out)
8700
8866
  names.add(n);
8701
8867
  }
8702
- if ((ts10.isFunctionDeclaration(node) || ts10.isClassDeclaration(node) || ts10.isEnumDeclaration(node)) && node.name) {
8868
+ if ((ts11.isFunctionDeclaration(node) || ts11.isClassDeclaration(node) || ts11.isEnumDeclaration(node)) && node.name) {
8703
8869
  names.add(node.name.text);
8704
8870
  }
8705
- if ((ts10.isTypeAliasDeclaration(node) || ts10.isInterfaceDeclaration(node)) && node.name) {
8871
+ if ((ts11.isTypeAliasDeclaration(node) || ts11.isInterfaceDeclaration(node)) && node.name) {
8706
8872
  names.add(node.name.text);
8707
8873
  }
8708
- if (ts10.isFunctionLike(node)) {
8874
+ if (ts11.isFunctionLike(node)) {
8709
8875
  for (const p of node.parameters) {
8710
8876
  const out = [];
8711
8877
  addBindingNames(p.name, out);
@@ -8713,7 +8879,7 @@ function collectEntryBindingNames(sf) {
8713
8879
  names.add(n);
8714
8880
  }
8715
8881
  }
8716
- ts10.forEachChild(node, visit2);
8882
+ ts11.forEachChild(node, visit2);
8717
8883
  }
8718
8884
  visit2(sf);
8719
8885
  return names;
@@ -8722,19 +8888,19 @@ var MAX_REEXPORT_HOPS = 1;
8722
8888
  function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8723
8889
  const candidateCallees = new Set;
8724
8890
  function collectCandidates(node) {
8725
- if (ts10.isVariableDeclaration(node) && (ts10.isArrayBindingPattern(node.name) || ts10.isObjectBindingPattern(node.name)) && node.initializer && ts10.isCallExpression(node.initializer) && ts10.isIdentifier(node.initializer.expression)) {
8891
+ if (ts11.isVariableDeclaration(node) && (ts11.isArrayBindingPattern(node.name) || ts11.isObjectBindingPattern(node.name)) && node.initializer && ts11.isCallExpression(node.initializer) && ts11.isIdentifier(node.initializer.expression)) {
8726
8892
  candidateCallees.add(node.initializer.expression.text);
8727
8893
  }
8728
- ts10.forEachChild(node, collectCandidates);
8894
+ ts11.forEachChild(node, collectCandidates);
8729
8895
  }
8730
8896
  collectCandidates(entrySourceFile);
8731
8897
  if (candidateCallees.size === 0)
8732
8898
  return;
8733
8899
  const importsToCheck = [];
8734
8900
  for (const stmt of entrySourceFile.statements) {
8735
- if (!ts10.isImportDeclaration(stmt))
8901
+ if (!ts11.isImportDeclaration(stmt))
8736
8902
  continue;
8737
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
8903
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
8738
8904
  continue;
8739
8905
  const src = stmt.moduleSpecifier.text;
8740
8906
  if (!src.startsWith("./") && !src.startsWith("../"))
@@ -8742,7 +8908,7 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8742
8908
  if (stmt.importClause?.isTypeOnly)
8743
8909
  continue;
8744
8910
  const namedBindings = stmt.importClause?.namedBindings;
8745
- if (!namedBindings || !ts10.isNamedImports(namedBindings))
8911
+ if (!namedBindings || !ts11.isNamedImports(namedBindings))
8746
8912
  continue;
8747
8913
  const specs = [];
8748
8914
  for (const el of namedBindings.elements) {
@@ -8780,14 +8946,14 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8780
8946
  helperCache.set(abs, "clean");
8781
8947
  return "clean";
8782
8948
  }
8783
- const sf = ts10.createSourceFile(abs + ".prescan", content, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
8949
+ const sf = ts11.createSourceFile(abs + ".prescan", content, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
8784
8950
  const localFns = new Map;
8785
8951
  const exportedFns = new Map;
8786
8952
  for (const stmt of sf.statements) {
8787
- if (ts10.isFunctionDeclaration(stmt) && stmt.name && stmt.body) {
8953
+ if (ts11.isFunctionDeclaration(stmt) && stmt.name && stmt.body) {
8788
8954
  localFns.set(stmt.name.text, stmt);
8789
- const hasExportModifier = stmt.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
8790
- const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DefaultKeyword) ?? false;
8955
+ const hasExportModifier = stmt.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
8956
+ const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DefaultKeyword) ?? false;
8791
8957
  if (hasExportModifier && !hasDefaultModifier) {
8792
8958
  exportedFns.set(stmt.name.text, stmt);
8793
8959
  }
@@ -8796,10 +8962,10 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8796
8962
  const reexports = new Map;
8797
8963
  let hasStarReexport = false;
8798
8964
  for (const stmt of sf.statements) {
8799
- if (!ts10.isExportDeclaration(stmt) || stmt.isTypeOnly)
8965
+ if (!ts11.isExportDeclaration(stmt) || stmt.isTypeOnly)
8800
8966
  continue;
8801
8967
  if (!stmt.moduleSpecifier) {
8802
- if (stmt.exportClause && ts10.isNamedExports(stmt.exportClause)) {
8968
+ if (stmt.exportClause && ts11.isNamedExports(stmt.exportClause)) {
8803
8969
  for (const el of stmt.exportClause.elements) {
8804
8970
  if (el.isTypeOnly)
8805
8971
  continue;
@@ -8810,9 +8976,9 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8810
8976
  }
8811
8977
  continue;
8812
8978
  }
8813
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
8979
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
8814
8980
  continue;
8815
- if (stmt.exportClause && ts10.isNamedExports(stmt.exportClause)) {
8981
+ if (stmt.exportClause && ts11.isNamedExports(stmt.exportClause)) {
8816
8982
  for (const el of stmt.exportClause.elements) {
8817
8983
  if (el.isTypeOnly)
8818
8984
  continue;
@@ -8962,7 +9128,7 @@ function collectHelperModuleValueBindings(sf) {
8962
9128
  const importedTypes = new Map;
8963
9129
  const imported = new Map;
8964
9130
  for (const stmt of sf.statements) {
8965
- if (ts10.isVariableStatement(stmt)) {
9131
+ if (ts11.isVariableStatement(stmt)) {
8966
9132
  const out = [];
8967
9133
  for (const decl of stmt.declarationList.declarations) {
8968
9134
  addBindingNames(decl.name, out);
@@ -8971,16 +9137,16 @@ function collectHelperModuleValueBindings(sf) {
8971
9137
  local.add(n);
8972
9138
  continue;
8973
9139
  }
8974
- if ((ts10.isFunctionDeclaration(stmt) || ts10.isClassDeclaration(stmt) || ts10.isEnumDeclaration(stmt)) && stmt.name) {
9140
+ if ((ts11.isFunctionDeclaration(stmt) || ts11.isClassDeclaration(stmt) || ts11.isEnumDeclaration(stmt)) && stmt.name) {
8975
9141
  local.add(stmt.name.text);
8976
9142
  continue;
8977
9143
  }
8978
- if ((ts10.isTypeAliasDeclaration(stmt) || ts10.isInterfaceDeclaration(stmt)) && stmt.name) {
9144
+ if ((ts11.isTypeAliasDeclaration(stmt) || ts11.isInterfaceDeclaration(stmt)) && stmt.name) {
8979
9145
  localTypes.add(stmt.name.text);
8980
9146
  continue;
8981
9147
  }
8982
- if (ts10.isImportDeclaration(stmt)) {
8983
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
9148
+ if (ts11.isImportDeclaration(stmt)) {
9149
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
8984
9150
  continue;
8985
9151
  const src = stmt.moduleSpecifier.text;
8986
9152
  if (src === "@barefootjs/client" || src === "@barefootjs/client/runtime")
@@ -8989,7 +9155,7 @@ function collectHelperModuleValueBindings(sf) {
8989
9155
  if (stmt.importClause?.name)
8990
9156
  (wholeTypeOnly ? localTypes : local).add(stmt.importClause.name.text);
8991
9157
  const namedBindings = stmt.importClause?.namedBindings;
8992
- if (namedBindings && ts10.isNamedImports(namedBindings)) {
9158
+ if (namedBindings && ts11.isNamedImports(namedBindings)) {
8993
9159
  for (const el of namedBindings.elements) {
8994
9160
  const entry = { source: src, exportedName: (el.propertyName ?? el.name).text };
8995
9161
  if (wholeTypeOnly || el.isTypeOnly)
@@ -8998,7 +9164,7 @@ function collectHelperModuleValueBindings(sf) {
8998
9164
  imported.set(el.name.text, entry);
8999
9165
  }
9000
9166
  }
9001
- if (namedBindings && ts10.isNamespaceImport(namedBindings)) {
9167
+ if (namedBindings && ts11.isNamespaceImport(namedBindings)) {
9002
9168
  (wholeTypeOnly ? localTypes : local).add(namedBindings.name.text);
9003
9169
  }
9004
9170
  }
@@ -9065,11 +9231,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9065
9231
  function checkForReactive(n) {
9066
9232
  if (hasReactiveCall)
9067
9233
  return;
9068
- if (ts10.isCallExpression(n) && ts10.isIdentifier(n.expression) && REACTIVE_PRIMITIVES.has(n.expression.text)) {
9234
+ if (ts11.isCallExpression(n) && ts11.isIdentifier(n.expression) && REACTIVE_PRIMITIVES.has(n.expression.text)) {
9069
9235
  hasReactiveCall = true;
9070
9236
  return;
9071
9237
  }
9072
- ts10.forEachChild(n, checkForReactive);
9238
+ ts11.forEachChild(n, checkForReactive);
9073
9239
  }
9074
9240
  checkForReactive(node.body);
9075
9241
  if (!hasReactiveCall)
@@ -9077,29 +9243,29 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9077
9243
  const loc = getSourceLocation(node, sourceFile, filePath);
9078
9244
  let totalReturnCount = 0;
9079
9245
  function countReturns(n) {
9080
- if (ts10.isFunctionLike(n))
9246
+ if (ts11.isFunctionLike(n))
9081
9247
  return;
9082
- if (ts10.isReturnStatement(n)) {
9248
+ if (ts11.isReturnStatement(n)) {
9083
9249
  totalReturnCount++;
9084
9250
  return;
9085
9251
  }
9086
- ts10.forEachChild(n, countReturns);
9252
+ ts11.forEachChild(n, countReturns);
9087
9253
  }
9088
- ts10.forEachChild(node.body, countReturns);
9254
+ ts11.forEachChild(node.body, countReturns);
9089
9255
  let returnExpr = null;
9090
9256
  let returnCount = 0;
9091
9257
  for (const stmt of node.body.statements) {
9092
- if (!ts10.isReturnStatement(stmt))
9258
+ if (!ts11.isReturnStatement(stmt))
9093
9259
  continue;
9094
9260
  returnCount++;
9095
9261
  if (!stmt.expression)
9096
9262
  return { kind: "reactive-shaped" };
9097
9263
  let expr = stmt.expression;
9098
- while (ts10.isParenthesizedExpression(expr))
9264
+ while (ts11.isParenthesizedExpression(expr))
9099
9265
  expr = expr.expression;
9100
- if (ts10.isAsExpression(expr))
9266
+ if (ts11.isAsExpression(expr))
9101
9267
  expr = expr.expression;
9102
- if (ts10.isTypeAssertionExpression(expr))
9268
+ if (ts11.isTypeAssertionExpression(expr))
9103
9269
  expr = expr.expression;
9104
9270
  returnExpr = expr;
9105
9271
  }
@@ -9107,18 +9273,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9107
9273
  return { kind: "reactive-shaped" };
9108
9274
  const returnTupleIdentifiers = [];
9109
9275
  let returnKind;
9110
- if (ts10.isArrayLiteralExpression(returnExpr)) {
9276
+ if (ts11.isArrayLiteralExpression(returnExpr)) {
9111
9277
  returnKind = "tuple";
9112
9278
  for (const el of returnExpr.elements) {
9113
- if (!ts10.isIdentifier(el))
9279
+ if (!ts11.isIdentifier(el))
9114
9280
  return { kind: "reactive-shaped" };
9115
9281
  returnTupleIdentifiers.push(el.text);
9116
9282
  }
9117
9283
  if (returnTupleIdentifiers.length === 0)
9118
9284
  return { kind: "reactive-shaped" };
9119
- } else if (ts10.isObjectLiteralExpression(returnExpr)) {
9285
+ } else if (ts11.isObjectLiteralExpression(returnExpr)) {
9120
9286
  returnKind = "object";
9121
- const hasNonShorthand = returnExpr.properties.some((p) => !ts10.isShorthandPropertyAssignment(p));
9287
+ const hasNonShorthand = returnExpr.properties.some((p) => !ts11.isShorthandPropertyAssignment(p));
9122
9288
  if (hasNonShorthand) {
9123
9289
  return {
9124
9290
  kind: "declined",
@@ -9139,7 +9305,7 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9139
9305
  }
9140
9306
  const params = [];
9141
9307
  for (const p of node.parameters) {
9142
- if (ts10.isIdentifier(p.name)) {
9308
+ if (ts11.isIdentifier(p.name)) {
9143
9309
  params.push(p.name.text);
9144
9310
  continue;
9145
9311
  }
@@ -9147,11 +9313,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9147
9313
  }
9148
9314
  const localBindings = [];
9149
9315
  for (const stmt of node.body.statements) {
9150
- if (ts10.isVariableStatement(stmt)) {
9316
+ if (ts11.isVariableStatement(stmt)) {
9151
9317
  for (const decl of stmt.declarationList.declarations) {
9152
9318
  addBindingNames(decl.name, localBindings);
9153
9319
  }
9154
- } else if (ts10.isFunctionDeclaration(stmt) && stmt.name) {
9320
+ } else if (ts11.isFunctionDeclaration(stmt) && stmt.name) {
9155
9321
  localBindings.push(stmt.name.text);
9156
9322
  }
9157
9323
  }
@@ -9171,47 +9337,47 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9171
9337
  if (!relevantNames.has(id.text))
9172
9338
  return;
9173
9339
  const p = id.parent;
9174
- if (ts10.isPropertyAccessExpression(p) && p.name === id)
9340
+ if (ts11.isPropertyAccessExpression(p) && p.name === id)
9175
9341
  return;
9176
- if (ts10.isPropertyAssignment(p) && p.name === id)
9342
+ if (ts11.isPropertyAssignment(p) && p.name === id)
9177
9343
  return;
9178
- if (ts10.isBindingElement(p) && p.propertyName === id)
9344
+ if (ts11.isBindingElement(p) && p.propertyName === id)
9179
9345
  return;
9180
- if ((ts10.isMethodDeclaration(p) || ts10.isGetAccessorDeclaration(p) || ts10.isSetAccessorDeclaration(p) || ts10.isPropertyDeclaration(p) || ts10.isEnumMember(p)) && p.name === id)
9346
+ if ((ts11.isMethodDeclaration(p) || ts11.isGetAccessorDeclaration(p) || ts11.isSetAccessorDeclaration(p) || ts11.isPropertyDeclaration(p) || ts11.isEnumMember(p)) && p.name === id)
9181
9347
  return;
9182
- if (ts10.isJsxAttribute(p) && p.name === id)
9348
+ if (ts11.isJsxAttribute(p) && p.name === id)
9183
9349
  return;
9184
- if (ts10.isLabeledStatement(p) && p.label === id || (ts10.isBreakStatement(p) || ts10.isContinueStatement(p)) && p.label === id)
9350
+ if (ts11.isLabeledStatement(p) && p.label === id || (ts11.isBreakStatement(p) || ts11.isContinueStatement(p)) && p.label === id)
9185
9351
  return;
9186
- if ((ts10.isJsxOpeningElement(p) || ts10.isJsxSelfClosingElement(p) || ts10.isJsxClosingElement(p)) && p.tagName === id && /^[a-z]/.test(id.text))
9352
+ if ((ts11.isJsxOpeningElement(p) || ts11.isJsxSelfClosingElement(p) || ts11.isJsxClosingElement(p)) && p.tagName === id && /^[a-z]/.test(id.text))
9187
9353
  return;
9188
- if (ts10.isShorthandPropertyAssignment(p) && p.name === id) {
9354
+ if (ts11.isShorthandPropertyAssignment(p) && p.name === id) {
9189
9355
  push(id, "shorthand");
9190
9356
  return;
9191
9357
  }
9192
- if (ts10.isBindingElement(p) && p.name === id && !p.propertyName && ts10.isObjectBindingPattern(p.parent)) {
9358
+ if (ts11.isBindingElement(p) && p.name === id && !p.propertyName && ts11.isObjectBindingPattern(p.parent)) {
9193
9359
  if (params.includes(id.text))
9194
9360
  shadowedParam = id.text;
9195
9361
  push(id, "shorthand");
9196
9362
  return;
9197
9363
  }
9198
- const isDecl = (ts10.isVariableDeclaration(p) || ts10.isParameter(p) || ts10.isBindingElement(p) || ts10.isFunctionDeclaration(p) || ts10.isFunctionExpression(p) || ts10.isClassDeclaration(p) || ts10.isClassExpression(p)) && p.name === id;
9364
+ const isDecl = (ts11.isVariableDeclaration(p) || ts11.isParameter(p) || ts11.isBindingElement(p) || ts11.isFunctionDeclaration(p) || ts11.isFunctionExpression(p) || ts11.isClassDeclaration(p) || ts11.isClassExpression(p)) && p.name === id;
9199
9365
  if (isDecl && params.includes(id.text))
9200
9366
  shadowedParam = id.text;
9201
9367
  push(id, "plain");
9202
9368
  }
9203
9369
  function visit2(n) {
9204
- if (ts10.isTypeNode(n) || ts10.isTypeParameterDeclaration(n) || ts10.isTypeAliasDeclaration(n) || ts10.isInterfaceDeclaration(n))
9370
+ if (ts11.isTypeNode(n) || ts11.isTypeParameterDeclaration(n) || ts11.isTypeAliasDeclaration(n) || ts11.isInterfaceDeclaration(n))
9205
9371
  return;
9206
- if (ts10.isIdentifier(n)) {
9372
+ if (ts11.isIdentifier(n)) {
9207
9373
  classify(n);
9208
9374
  return;
9209
9375
  }
9210
- ts10.forEachChild(n, visit2);
9376
+ ts11.forEachChild(n, visit2);
9211
9377
  }
9212
9378
  visit2(root);
9213
9379
  }
9214
- const keptStatements = node.body.statements.filter((s) => !ts10.isReturnStatement(s));
9380
+ const keptStatements = node.body.statements.filter((s) => !ts11.isReturnStatement(s));
9215
9381
  const pieces = [];
9216
9382
  let base = 0;
9217
9383
  for (const stmt of keptStatements) {
@@ -9259,18 +9425,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9259
9425
  };
9260
9426
  }
9261
9427
  function addBindingNames(name, out) {
9262
- if (ts10.isIdentifier(name)) {
9428
+ if (ts11.isIdentifier(name)) {
9263
9429
  out.push(name.text);
9264
9430
  return;
9265
9431
  }
9266
- if (ts10.isObjectBindingPattern(name)) {
9432
+ if (ts11.isObjectBindingPattern(name)) {
9267
9433
  for (const el of name.elements)
9268
9434
  addBindingNames(el.name, out);
9269
9435
  return;
9270
9436
  }
9271
- if (ts10.isArrayBindingPattern(name)) {
9437
+ if (ts11.isArrayBindingPattern(name)) {
9272
9438
  for (const el of name.elements) {
9273
- if (ts10.isOmittedExpression(el))
9439
+ if (ts11.isOmittedExpression(el))
9274
9440
  continue;
9275
9441
  addBindingNames(el.name, out);
9276
9442
  }
@@ -9282,33 +9448,33 @@ function rewriteFactoryCallsInSource(source, prescan) {
9282
9448
  let callSiteIndex = 0;
9283
9449
  const inlinedFactories = new Set;
9284
9450
  function visitStmt(node, inComponent) {
9285
- if (ts10.isVariableStatement(node) && inComponent) {
9451
+ if (ts11.isVariableStatement(node) && inComponent) {
9286
9452
  for (const decl of node.declarationList.declarations) {
9287
9453
  maybeRewriteDecl(node, decl);
9288
9454
  }
9289
9455
  }
9290
- ts10.forEachChild(node, (child) => {
9291
- if (ts10.isFunctionDeclaration(child) && child.name && factories.has(child.name.text))
9456
+ ts11.forEachChild(node, (child) => {
9457
+ if (ts11.isFunctionDeclaration(child) && child.name && factories.has(child.name.text))
9292
9458
  return;
9293
9459
  visitStmt(child, inComponent || isPascalCaseComponentFn(child));
9294
9460
  });
9295
9461
  }
9296
9462
  function maybeRewriteDecl(stmt, decl) {
9297
- if (!decl.initializer || !ts10.isCallExpression(decl.initializer))
9463
+ if (!decl.initializer || !ts11.isCallExpression(decl.initializer))
9298
9464
  return;
9299
- if (!ts10.isIdentifier(decl.initializer.expression))
9465
+ if (!ts11.isIdentifier(decl.initializer.expression))
9300
9466
  return;
9301
9467
  const factoryName = decl.initializer.expression.text;
9302
9468
  const factory = factories.get(factoryName);
9303
9469
  if (!factory)
9304
9470
  return;
9305
- if (ts10.isArrayBindingPattern(decl.name)) {
9471
+ if (ts11.isArrayBindingPattern(decl.name)) {
9306
9472
  if (factory.returnKind !== "tuple")
9307
9473
  return;
9308
9474
  rewriteTupleDecl(stmt, decl.name, decl.initializer, factory);
9309
9475
  return;
9310
9476
  }
9311
- if (ts10.isObjectBindingPattern(decl.name)) {
9477
+ if (ts11.isObjectBindingPattern(decl.name)) {
9312
9478
  if (factory.returnKind !== "object")
9313
9479
  return;
9314
9480
  rewriteObjectDecl(stmt, decl.name, decl.initializer, factory);
@@ -9321,7 +9487,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
9321
9487
  return;
9322
9488
  const callerNames = [];
9323
9489
  for (const el of elements) {
9324
- if (ts10.isOmittedExpression(el) || !ts10.isIdentifier(el.name))
9490
+ if (ts11.isOmittedExpression(el) || !ts11.isIdentifier(el.name))
9325
9491
  return;
9326
9492
  callerNames.push(el.name.text);
9327
9493
  }
@@ -9343,7 +9509,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
9343
9509
  return;
9344
9510
  if (el.initializer)
9345
9511
  return;
9346
- if (!ts10.isIdentifier(el.name))
9512
+ if (!ts11.isIdentifier(el.name))
9347
9513
  return;
9348
9514
  if (!factory.returnTupleIdentifiers.includes(el.name.text))
9349
9515
  return;
@@ -9452,21 +9618,21 @@ function factoryImportInsertionOffset(sf) {
9452
9618
  let lastImportEnd = -1;
9453
9619
  let directiveEnd = -1;
9454
9620
  for (const stmt of sf.statements) {
9455
- if (ts10.isImportDeclaration(stmt)) {
9621
+ if (ts11.isImportDeclaration(stmt)) {
9456
9622
  lastImportEnd = stmt.getEnd();
9457
9623
  continue;
9458
9624
  }
9459
- if (directiveEnd === -1 && ts10.isExpressionStatement(stmt) && ts10.isStringLiteral(stmt.expression) && stmt.expression.text === "use client") {
9625
+ if (directiveEnd === -1 && ts11.isExpressionStatement(stmt) && ts11.isStringLiteral(stmt.expression) && stmt.expression.text === "use client") {
9460
9626
  directiveEnd = stmt.getEnd();
9461
9627
  }
9462
9628
  }
9463
9629
  return lastImportEnd >= 0 ? lastImportEnd : directiveEnd >= 0 ? directiveEnd : 0;
9464
9630
  }
9465
9631
  function isPascalCaseComponentFn(node) {
9466
- if (ts10.isFunctionDeclaration(node) && node.name) {
9632
+ if (ts11.isFunctionDeclaration(node) && node.name) {
9467
9633
  return /^[A-Z]/.test(node.name.text);
9468
9634
  }
9469
- if (ts10.isVariableDeclaration(node) && ts10.isIdentifier(node.name) && node.initializer && ts10.isArrowFunction(node.initializer)) {
9635
+ if (ts11.isVariableDeclaration(node) && ts11.isIdentifier(node.name) && node.initializer && ts11.isArrowFunction(node.initializer)) {
9470
9636
  return /^[A-Z]/.test(node.name.text);
9471
9637
  }
9472
9638
  return false;
@@ -9495,20 +9661,20 @@ function declinedFactoryErrorCode(code) {
9495
9661
  function validateReactiveFactoryCalls(ctx) {
9496
9662
  if (!ctx.componentNode)
9497
9663
  return;
9498
- const body = ts10.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : ts10.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
9664
+ const body = ts11.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : ts11.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
9499
9665
  if (!body)
9500
9666
  return;
9501
9667
  for (const stmt of body.statements) {
9502
- if (!ts10.isVariableStatement(stmt))
9668
+ if (!ts11.isVariableStatement(stmt))
9503
9669
  continue;
9504
9670
  for (const decl of stmt.declarationList.declarations) {
9505
- if (!decl.initializer || !ts10.isCallExpression(decl.initializer))
9671
+ if (!decl.initializer || !ts11.isCallExpression(decl.initializer))
9506
9672
  continue;
9507
- if (!ts10.isIdentifier(decl.initializer.expression))
9673
+ if (!ts11.isIdentifier(decl.initializer.expression))
9508
9674
  continue;
9509
9675
  const callee = decl.initializer.expression.text;
9510
9676
  const loc = getSourceLocation(stmt, ctx.sourceFile, ctx.filePath);
9511
- if (ts10.isArrayBindingPattern(decl.name)) {
9677
+ if (ts11.isArrayBindingPattern(decl.name)) {
9512
9678
  if (callee === "createSignal" || callee === "createMemo")
9513
9679
  continue;
9514
9680
  if (resolveEnvSignalKey(decl.initializer, ctx))
@@ -9535,7 +9701,7 @@ function validateReactiveFactoryCalls(ctx) {
9535
9701
  }));
9536
9702
  continue;
9537
9703
  }
9538
- if (ts10.isObjectBindingPattern(decl.name)) {
9704
+ if (ts11.isObjectBindingPattern(decl.name)) {
9539
9705
  validateObjectFactoryDestructure(ctx, decl.name, callee, loc);
9540
9706
  }
9541
9707
  }
@@ -9544,25 +9710,25 @@ function validateReactiveFactoryCalls(ctx) {
9544
9710
  function validateNamespaceQualifiedPrimitives(ctx) {
9545
9711
  if (!ctx.componentNode)
9546
9712
  return;
9547
- const body = ts10.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : ts10.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
9713
+ const body = ts11.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : ts11.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
9548
9714
  if (!body)
9549
9715
  return;
9550
9716
  for (const stmt of body.statements) {
9551
9717
  const calls = [];
9552
- if (ts10.isVariableStatement(stmt)) {
9718
+ if (ts11.isVariableStatement(stmt)) {
9553
9719
  for (const decl of stmt.declarationList.declarations) {
9554
9720
  let init = decl.initializer;
9555
- if (init && ts10.isElementAccessExpression(init))
9721
+ if (init && ts11.isElementAccessExpression(init))
9556
9722
  init = init.expression;
9557
- if (init && ts10.isCallExpression(init))
9723
+ if (init && ts11.isCallExpression(init))
9558
9724
  calls.push(init);
9559
9725
  }
9560
- } else if (ts10.isExpressionStatement(stmt) && ts10.isCallExpression(stmt.expression)) {
9726
+ } else if (ts11.isExpressionStatement(stmt) && ts11.isCallExpression(stmt.expression)) {
9561
9727
  calls.push(stmt.expression);
9562
9728
  }
9563
9729
  for (const call of calls) {
9564
9730
  const callee = call.expression;
9565
- if (!ts10.isPropertyAccessExpression(callee) || !ts10.isIdentifier(callee.expression))
9731
+ if (!ts11.isPropertyAccessExpression(callee) || !ts11.isIdentifier(callee.expression))
9566
9732
  continue;
9567
9733
  const primitive = callee.name.text;
9568
9734
  if (!(primitive in PRIMITIVE_CANONICAL_NAMES))
@@ -9595,11 +9761,11 @@ function isNamespaceNameShadowedAtComponentTopLevel(name, body, ctx) {
9595
9761
  if (ctx.propsParams.some((p) => p.name === name))
9596
9762
  return true;
9597
9763
  for (const stmt of body.statements) {
9598
- if (ts10.isFunctionDeclaration(stmt) && stmt.name?.text === name)
9764
+ if (ts11.isFunctionDeclaration(stmt) && stmt.name?.text === name)
9599
9765
  return true;
9600
- if (ts10.isVariableStatement(stmt)) {
9766
+ if (ts11.isVariableStatement(stmt)) {
9601
9767
  for (const decl of stmt.declarationList.declarations) {
9602
- if (ts10.isIdentifier(decl.name) && decl.name.text === name)
9768
+ if (ts11.isIdentifier(decl.name) && decl.name.text === name)
9603
9769
  return true;
9604
9770
  }
9605
9771
  }
@@ -9616,7 +9782,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
9616
9782
  }));
9617
9783
  return;
9618
9784
  }
9619
- const hasUnsupportedElement = pattern.elements.some((el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !ts10.isIdentifier(el.name));
9785
+ const hasUnsupportedElement = pattern.elements.some((el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !ts11.isIdentifier(el.name));
9620
9786
  if (hasUnsupportedElement) {
9621
9787
  ctx.errors.push(createError(ErrorCodes.REACTIVE_FACTORY_RENAME_UNSUPPORTED, loc, {
9622
9788
  severity: "error",
@@ -9624,7 +9790,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
9624
9790
  }));
9625
9791
  return;
9626
9792
  }
9627
- const unknown = pattern.elements.map((el) => ts10.isIdentifier(el.name) ? el.name.text : "").filter((name) => name && !factory.returnTupleIdentifiers.includes(name));
9793
+ const unknown = pattern.elements.map((el) => ts11.isIdentifier(el.name) ? el.name.text : "").filter((name) => name && !factory.returnTupleIdentifiers.includes(name));
9628
9794
  if (unknown.length > 0) {
9629
9795
  const label = unknown.length === 1 ? "property" : "properties";
9630
9796
  ctx.errors.push(createError(ErrorCodes.UNRECOGNIZED_REACTIVE_FACTORY, loc, {
@@ -9779,7 +9945,7 @@ var ESCAPE_SSR_COST = {
9779
9945
  };
9780
9946
 
9781
9947
  // src/module-exports.ts
9782
- import ts11 from "typescript";
9948
+ import ts12 from "typescript";
9783
9949
  function generateModuleExports(ir, extraInlineExported = new Set, rewriteRelativeImport, options) {
9784
9950
  const lines = [];
9785
9951
  for (const constant of options?.skipValueDeclarations ? [] : ir.metadata.localConstants) {
@@ -9880,21 +10046,21 @@ function findAssignedNames(bodyText, candidates) {
9880
10046
  const assigned = new Set;
9881
10047
  if (candidates.size === 0)
9882
10048
  return assigned;
9883
- const sf = ts11.createSourceFile("bf-assignment-scan.tsx", bodyText, ts11.ScriptTarget.Latest, false, ts11.ScriptKind.TSX);
10049
+ const sf = ts12.createSourceFile("bf-assignment-scan.tsx", bodyText, ts12.ScriptTarget.Latest, false, ts12.ScriptKind.TSX);
9884
10050
  const record = (target) => {
9885
- if (ts11.isIdentifier(target) && candidates.has(target.text)) {
10051
+ if (ts12.isIdentifier(target) && candidates.has(target.text)) {
9886
10052
  assigned.add(target.text);
9887
10053
  }
9888
10054
  };
9889
10055
  const visit2 = (node) => {
9890
- if (ts11.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
10056
+ if (ts12.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
9891
10057
  record(node.left);
9892
- } else if ((ts11.isPrefixUnaryExpression(node) || ts11.isPostfixUnaryExpression(node)) && (node.operator === ts11.SyntaxKind.PlusPlusToken || node.operator === ts11.SyntaxKind.MinusMinusToken)) {
10058
+ } else if ((ts12.isPrefixUnaryExpression(node) || ts12.isPostfixUnaryExpression(node)) && (node.operator === ts12.SyntaxKind.PlusPlusToken || node.operator === ts12.SyntaxKind.MinusMinusToken)) {
9893
10059
  record(node.operand);
9894
10060
  }
9895
- ts11.forEachChild(node, visit2);
10061
+ ts12.forEachChild(node, visit2);
9896
10062
  };
9897
- ts11.forEachChild(sf, visit2);
10063
+ ts12.forEachChild(sf, visit2);
9898
10064
  return assigned;
9899
10065
  }
9900
10066
  function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
@@ -9917,7 +10083,7 @@ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNam
9917
10083
  return reachable;
9918
10084
  }
9919
10085
  function isAssignmentOperator(kind) {
9920
- return kind >= ts11.SyntaxKind.FirstAssignment && kind <= ts11.SyntaxKind.LastAssignment;
10086
+ return kind >= ts12.SyntaxKind.FirstAssignment && kind <= ts12.SyntaxKind.LastAssignment;
9921
10087
  }
9922
10088
  function extractFunctionParams(value) {
9923
10089
  const arrowMatch = value.match(/^(?:async\s*)?\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/);
@@ -9955,102 +10121,6 @@ function stripClientBuiltinImports(imports) {
9955
10121
  return result;
9956
10122
  }
9957
10123
 
9958
- // src/reactivity-checker.ts
9959
- import ts12 from "typescript";
9960
- var REACTIVE_BRAND = "__reactive";
9961
- function queryType(checker, node) {
9962
- incrementCounter("typeCheckerQueries");
9963
- return checker.getTypeAtLocation(node);
9964
- }
9965
- function isReactiveType(type) {
9966
- return type.getProperty(REACTIVE_BRAND) !== undefined;
9967
- }
9968
- var NOT_REACTIVE = { isReactive: false, reason: { kind: "not-reactive" } };
9969
- function safeGetText(node) {
9970
- try {
9971
- return node.getText();
9972
- } catch {
9973
- return "";
9974
- }
9975
- }
9976
- function analyze(node, checker) {
9977
- if (ts12.isPropertyAccessExpression(node)) {
9978
- try {
9979
- const type = queryType(checker, node);
9980
- if (isReactiveType(type)) {
9981
- return {
9982
- isReactive: true,
9983
- reason: { kind: "brand", via: "property-access", nodeText: safeGetText(node) }
9984
- };
9985
- }
9986
- } catch {}
9987
- const sub = analyze(node.expression, checker);
9988
- if (sub.isReactive) {
9989
- return {
9990
- isReactive: true,
9991
- reason: {
9992
- kind: "child",
9993
- via: "property-access-object",
9994
- childText: safeGetText(node.expression),
9995
- childReason: sub.reason
9996
- }
9997
- };
9998
- }
9999
- return NOT_REACTIVE;
10000
- }
10001
- if (ts12.isIdentifier(node)) {
10002
- try {
10003
- const type = queryType(checker, node);
10004
- if (isReactiveType(type)) {
10005
- return {
10006
- isReactive: true,
10007
- reason: { kind: "brand", via: "identifier", nodeText: safeGetText(node) }
10008
- };
10009
- }
10010
- } catch {}
10011
- return NOT_REACTIVE;
10012
- }
10013
- if (ts12.isCallExpression(node)) {
10014
- try {
10015
- const calleeType = queryType(checker, node.expression);
10016
- if (isReactiveType(calleeType)) {
10017
- return {
10018
- isReactive: true,
10019
- reason: { kind: "brand", via: "callee", nodeText: safeGetText(node) }
10020
- };
10021
- }
10022
- } catch {}
10023
- }
10024
- let foundChild;
10025
- let foundChildText = "";
10026
- ts12.forEachChild(node, (child) => {
10027
- if (foundChild?.isReactive)
10028
- return;
10029
- const result = analyze(child, checker);
10030
- if (result.isReactive) {
10031
- foundChild = result;
10032
- foundChildText = safeGetText(child);
10033
- }
10034
- });
10035
- if (foundChild?.isReactive) {
10036
- return {
10037
- isReactive: true,
10038
- reason: {
10039
- kind: "child",
10040
- via: "sub-expression",
10041
- childText: foundChildText,
10042
- childReason: foundChild.reason
10043
- }
10044
- };
10045
- }
10046
- return NOT_REACTIVE;
10047
- }
10048
- var brandTypeReactivityAnalyzer = { analyze };
10049
- function containsReactiveExpression(node, checker) {
10050
- incrementCounter("reactivityChecks");
10051
- return brandTypeReactivityAnalyzer.analyze(node, checker).isReactive;
10052
- }
10053
-
10054
10124
  // src/free-refs.ts
10055
10125
  import ts13 from "typescript";
10056
10126
  var _bindingMapCache = new WeakMap;
@@ -10795,9 +10865,8 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
10795
10865
  function visit2(n, parent) {
10796
10866
  if (ts14.isIdentifier(n) && propDepsMap.has(n.text)) {
10797
10867
  const isObjectKey = parent && ts14.isPropertyAssignment(parent) && parent.name === n;
10798
- const isShorthand = parent && ts14.isShorthandPropertyAssignment(parent) && parent.name === n;
10799
10868
  const isAccessName = parent && ts14.isPropertyAccessExpression(parent) && parent.name === n;
10800
- if (!isObjectKey && !isShorthand && !isAccessName) {
10869
+ if (!isObjectKey && !isAccessName) {
10801
10870
  const deps = propDepsMap.get(n.text);
10802
10871
  if (deps && deps.size > 0) {
10803
10872
  if (!acc)
@@ -11275,8 +11344,7 @@ function lowerFormControlValueSsr(tagName, attrs, children) {
11275
11344
  children.push({
11276
11345
  type: "expression",
11277
11346
  expr,
11278
- templateExpr: `escapeText(${templateExpr ?? expr})`,
11279
- escapeInClientTemplate: true,
11347
+ templateExpr,
11280
11348
  typeInfo: null,
11281
11349
  reactive: false,
11282
11350
  slotId: null,
@@ -11287,26 +11355,76 @@ function lowerFormControlValueSsr(tagName, attrs, children) {
11287
11355
  }
11288
11356
  const selectedForLiteral = (optValue) => AttrValueOf.expression(`(${expr}) === ${JSON.stringify(optValue)}`, templateExpr !== undefined ? { templateExpr: `(${templateExpr}) === ${JSON.stringify(optValue)}` } : undefined);
11289
11357
  const selectedForExpr = (optExpr, optTemplateExpr) => AttrValueOf.expression(`(${expr}) === (${optExpr})`, templateExpr !== undefined || optTemplateExpr !== undefined ? { templateExpr: `(${templateExpr ?? expr}) === (${optTemplateExpr ?? optExpr})` } : undefined);
11358
+ const matchConditions = [];
11359
+ let optionSetIsDynamic = false;
11290
11360
  const distribute = (nodes) => {
11291
11361
  for (const n of nodes) {
11362
+ if (n.type === "text")
11363
+ continue;
11292
11364
  if (n.type === "element" && n.tag === "option") {
11293
- if (n.attrs.some((a) => a.name === "selected"))
11365
+ if (n.attrs.some((a) => a.name === "selected")) {
11366
+ optionSetIsDynamic = true;
11294
11367
  continue;
11368
+ }
11295
11369
  const optValue = n.attrs.find((a) => a.name === "value");
11296
- if (!optValue)
11370
+ if (!optValue) {
11371
+ optionSetIsDynamic = true;
11297
11372
  continue;
11373
+ }
11298
11374
  if (optValue.value.kind === "literal") {
11299
- n.attrs.push({ name: "selected", value: selectedForLiteral(optValue.value.value), loc: n.loc });
11375
+ const selected = selectedForLiteral(optValue.value.value);
11376
+ n.attrs.push({ name: "selected", value: selected, loc: n.loc });
11377
+ matchConditions.push(selected);
11300
11378
  } else if (optValue.value.kind === "expression") {
11301
11379
  const selected = selectedForExpr(optValue.value.expr, optValue.value.templateExpr);
11302
11380
  n.attrs.push({ name: "selected", value: selected, loc: n.loc });
11381
+ matchConditions.push(selected);
11382
+ } else {
11383
+ optionSetIsDynamic = true;
11303
11384
  }
11304
- } else if (n.type === "fragment" || n.type === "loop" || n.type === "element" && n.tag === "optgroup") {
11385
+ } else if (n.type === "fragment" || n.type === "element" && n.tag === "optgroup") {
11386
+ distribute(n.children);
11387
+ } else if (n.type === "loop") {
11388
+ optionSetIsDynamic = true;
11305
11389
  distribute(n.children);
11390
+ } else {
11391
+ optionSetIsDynamic = true;
11306
11392
  }
11307
11393
  }
11308
11394
  };
11309
11395
  distribute(children);
11396
+ if (optionSetIsDynamic || matchConditions.length === 0)
11397
+ return;
11398
+ if (isMultiSelection(attrs))
11399
+ return;
11400
+ const orExpr = matchConditions.map((c) => `(${c.expr})`).join(" || ");
11401
+ const orTemplateExpr = matchConditions.some((c) => c.templateExpr !== undefined) ? matchConditions.map((c) => `(${c.templateExpr ?? c.expr})`).join(" || ") : undefined;
11402
+ children.unshift({
11403
+ type: "element",
11404
+ tag: "option",
11405
+ attrs: [
11406
+ { name: "value", value: AttrValueOf.literal(""), loc: valueAttr.loc },
11407
+ { name: "disabled", value: AttrValueOf.booleanAttr(), loc: valueAttr.loc },
11408
+ { name: "hidden", value: AttrValueOf.booleanAttr(), loc: valueAttr.loc },
11409
+ {
11410
+ name: "selected",
11411
+ value: AttrValueOf.expression(`!(${orExpr})`, orTemplateExpr !== undefined ? { templateExpr: `!(${orTemplateExpr})` } : undefined),
11412
+ loc: valueAttr.loc
11413
+ }
11414
+ ],
11415
+ events: [],
11416
+ ref: null,
11417
+ children: [],
11418
+ slotId: null,
11419
+ needsScope: false,
11420
+ loc: valueAttr.loc
11421
+ });
11422
+ }
11423
+ function isMultiSelection(attrs) {
11424
+ if (attrs.some((a) => a.name === "multiple"))
11425
+ return true;
11426
+ const sizeAttr = attrs.find((a) => a.name === "size");
11427
+ return sizeAttr?.value.kind === "literal" && Number(sizeAttr.value.value) > 1;
11310
11428
  }
11311
11429
  function transformHtmlElement(node, ctx, tagName) {
11312
11430
  const { attrs, events, ref } = processAttributes(node.openingElement.attributes, ctx);
@@ -11680,7 +11798,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
11680
11798
  }
11681
11799
  const ir = transformJsxExpression(expr, ctx, isClientOnly);
11682
11800
  if (ir !== null) {
11683
- if ((isClientOnly || shouldAutoDeferReactiveBrand(expr, ctx)) && ir.type === "conditional") {
11801
+ if (ir.type === "conditional" && (isClientOnly || shouldAutoDeferReactiveBrand(expr, ctx))) {
11684
11802
  ir.clientOnly = true;
11685
11803
  if (!ir.slotId) {
11686
11804
  ir.slotId = generateSlotId(ctx);
@@ -14627,9 +14745,10 @@ function shouldAutoDeferReactiveBrand(expr, ctx) {
14627
14745
  const checker = ctx.analyzer.checker;
14628
14746
  if (!checker)
14629
14747
  return false;
14630
- if (!containsReactiveExpression(expr, checker))
14748
+ const leaves = collectReactiveBrandLeaves(expr, checker);
14749
+ if (leaves.length === 0)
14631
14750
  return false;
14632
- if (isSignalOrMemoReference(ctx.getJS(expr), ctx))
14751
+ if (leaves.some((leaf) => isSignalOrMemoReference(ctx.getJS(leaf), ctx)))
14633
14752
  return false;
14634
14753
  return true;
14635
14754
  }
@@ -15012,10 +15131,10 @@ function getControlledPropName(signal, propsParams, propsObjectName = null) {
15012
15131
  }
15013
15132
 
15014
15133
  // src/ir-to-client-js/reactivity.ts
15015
- function buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex) {
15134
+ function buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope) {
15016
15135
  if (!loopParam)
15017
15136
  return;
15018
- return BindingScope.EMPTY.enterLoopRow({
15137
+ return (parentScope ?? BindingScope.EMPTY).enterLoopRow({
15019
15138
  param: loopParam,
15020
15139
  paramBindings: loopParamBindings,
15021
15140
  index: loopIndex,
@@ -15089,16 +15208,22 @@ function needsEffectWrapperCore(expr, ctx, freeIdentifiers2, visitedConstants) {
15089
15208
  }
15090
15209
  return false;
15091
15210
  }
15092
- function classifyReactivity(expr, ctx, loopParam, loopParamBindings, freeIdentifiers2) {
15211
+ function classifyReactivity(expr, ctx, scope, freeIdentifiers2) {
15093
15212
  const has = (name) => freeIdentifiers2 ? freeIdentifiers2.has(name) : tokenContainsIdent(expr, name);
15094
- if (loopParamBindings && loopParamBindings.length > 0) {
15095
- for (const b of loopParamBindings) {
15096
- if (has(b.name)) {
15097
- return { kind: "loop-param", param: loopParam ?? b.name };
15213
+ if (scope) {
15214
+ let indexHit;
15215
+ for (const name of scope.valueBoundNames()) {
15216
+ if (!has(name))
15217
+ continue;
15218
+ const source = scope.lookup(name)?.binding.source;
15219
+ if (source === "index") {
15220
+ indexHit ??= name;
15221
+ continue;
15098
15222
  }
15223
+ return { kind: "loop-param", param: name };
15099
15224
  }
15100
- } else if (loopParam && has(loopParam)) {
15101
- return { kind: "loop-param", param: loopParam };
15225
+ if (indexHit)
15226
+ return { kind: "loop-index", param: indexHit };
15102
15227
  }
15103
15228
  if (needsEffectWrapper(expr, ctx, freeIdentifiers2)) {
15104
15229
  return { kind: "signal-or-memo-or-prop" };
@@ -15261,9 +15386,9 @@ function traverseForComponents(node, components, skipConditionals = false) {
15261
15386
  }
15262
15387
  });
15263
15388
  }
15264
- function collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex) {
15389
+ function collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex, parentScope) {
15265
15390
  const texts = [];
15266
- const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
15391
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope);
15267
15392
  walkIR(node, false, {
15268
15393
  ...stopAt("loop", "async", "ifStatement"),
15269
15394
  expression: ({ node: n, scope: insideConditional }) => {
@@ -15273,7 +15398,7 @@ function collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings,
15273
15398
  return;
15274
15399
  const originFreeIds = freeIdsFromRefs(n.origin?.freeRefs);
15275
15400
  const expanded = expandConstantForReactivity(n.expr, ctx, originFreeIds, scope);
15276
- const reactive = classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind !== "none" || decideWrapFromAstFlags(n).wrap;
15401
+ const reactive = classifyReactivity(expanded.expr, ctx, scope, expanded.freeIds).kind !== "none" || decideWrapFromAstFlags(n).wrap;
15277
15402
  if (!reactive)
15278
15403
  return;
15279
15404
  texts.push({
@@ -15296,9 +15421,9 @@ function anyNameIn(names, set) {
15296
15421
  return true;
15297
15422
  return false;
15298
15423
  }
15299
- function collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex) {
15424
+ function collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex, parentScope) {
15300
15425
  const attrs = [];
15301
- const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
15426
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope);
15302
15427
  traverseElements(node, (el) => {
15303
15428
  if (el.slotId) {
15304
15429
  for (const attr of el.attrs) {
@@ -15313,7 +15438,7 @@ function collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings,
15313
15438
  continue;
15314
15439
  const expanded = expandConstantForReactivity(valueStr, ctx, attr.freeIdentifiers, scope);
15315
15440
  const readsPreamble = preambleNames !== undefined && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
15316
- const reactive = classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind !== "none" || readsPreamble || attr.callsReactiveGetters || attr.hasFunctionCalls;
15441
+ const reactive = classifyReactivity(expanded.expr, ctx, scope, expanded.freeIds).kind !== "none" || readsPreamble || attr.callsReactiveGetters || attr.hasFunctionCalls;
15317
15442
  if (!attr.clientOnly && !reactive)
15318
15443
  continue;
15319
15444
  attrs.push({
@@ -15653,7 +15778,9 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
15653
15778
  const flat = options?.flatBranchMode === true;
15654
15779
  const fixedDepth = options?.templateDepth;
15655
15780
  const collectBindings = options?.collectItemBindings === true;
15656
- const initialScope = { parentSlotId: null, depth: 0, insideCond: false };
15781
+ const outerSpec = typeof outerLoopParam === "string" ? { param: outerLoopParam } : outerLoopParam;
15782
+ const outerScope = buildLoopRowScope(outerSpec?.param, outerSpec?.bindings, undefined, outerSpec?.index);
15783
+ const initialScope = { parentSlotId: null, depth: 0, insideCond: false, bindingScope: outerScope };
15657
15784
  for (const root of nodes) {
15658
15785
  walkIR(root, initialScope, {
15659
15786
  element: ({ node: el, scope, descend }) => {
@@ -15669,18 +15796,17 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
15669
15796
  },
15670
15797
  loop: ({ node: n, scope, descend }) => {
15671
15798
  const emitDepth = fixedDepth ?? scope.depth + 1;
15672
- const loopParamsForTemplate = outerLoopParam ? [outerLoopParam, { param: n.param, bindings: n.paramBindings }] : undefined;
15799
+ const loopParamsForTemplate = outerSpec ? [outerSpec, { param: n.param, bindings: n.paramBindings, index: n.index }] : undefined;
15673
15800
  const template = n.children.map((c) => irToPlaceholderTemplate(c, undefined, emitDepth, loopParamsForTemplate)).join("");
15674
- const refsOuter = outerLoopParam ? identifierPattern(outerLoopParam).test(n.array) : false;
15675
15801
  const bindings = emptyLoopChildBindings();
15676
15802
  const innerPreambleNames = preambleNamesOf(n);
15677
15803
  if (ctx) {
15678
15804
  for (const child of n.children) {
15679
- bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx, n.param, n.paramBindings, true, innerPreambleNames, n.index));
15680
- bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx, n.param, n.paramBindings, true, innerPreambleNames, n.index));
15805
+ bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx, n.param, n.paramBindings, true, innerPreambleNames, n.index, scope.bindingScope));
15806
+ bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx, n.param, n.paramBindings, true, innerPreambleNames, n.index, scope.bindingScope));
15681
15807
  bindings.refs.push(...collectLoopChildRefs(child));
15682
15808
  }
15683
- bindings.conditionals.push(...collectLoopChildConditionals({ type: "fragment", children: n.children, loc: n.loc }, ctx, siblingOffsets, n.param, n.paramBindings, innerPreambleNames, n.index));
15809
+ bindings.conditionals.push(...collectLoopChildConditionals({ type: "fragment", children: n.children, loc: n.loc }, ctx, siblingOffsets, n.param, n.paramBindings, innerPreambleNames, n.index, loopParamsForTemplate, scope.bindingScope));
15684
15810
  }
15685
15811
  let childComponents;
15686
15812
  if (collectBindings) {
@@ -15722,14 +15848,17 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
15722
15848
  containerSlotId: scope.parentSlotId,
15723
15849
  template,
15724
15850
  preamble: n.preamble,
15725
- refsOuterParam: refsOuter,
15726
15851
  childComponents,
15727
15852
  insideConditional: !flat && scope.insideCond ? true : undefined,
15728
15853
  offset: flat ? undefined : resolveLoopOffset(siblingOffsets.get(n)),
15729
15854
  bindings
15730
15855
  });
15731
15856
  if (!flat) {
15732
- descend({ ...scope, depth: scope.depth + 1 });
15857
+ descend({
15858
+ ...scope,
15859
+ depth: scope.depth + 1,
15860
+ bindingScope: buildLoopRowScope(n.param, n.paramBindings, innerPreambleNames, n.index, scope.bindingScope)
15861
+ });
15733
15862
  }
15734
15863
  }
15735
15864
  });
@@ -15738,7 +15867,7 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
15738
15867
  }
15739
15868
  function decideLoopRendering(loop, siblingOffsets, ctx) {
15740
15869
  const hasNestedComps = (loop.nestedComponents?.length ?? 0) > 0;
15741
- const innerLoops = collectInnerLoops(loop.children, siblingOffsets, loop.param, ctx);
15870
+ const innerLoops = collectInnerLoops(loop.children, siblingOffsets, { param: loop.param, bindings: loop.paramBindings, index: loop.index }, ctx);
15742
15871
  const hasInnerLoops = (innerLoops?.length ?? 0) > 0;
15743
15872
  const useElementReconciliation = !loop.childComponent && !loop.isStaticArray && (hasNestedComps || hasInnerLoops);
15744
15873
  return { useElementReconciliation, innerLoops };
@@ -15906,6 +16035,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
15906
16035
  }
15907
16036
  const { useElementReconciliation, innerLoops } = projectionInner ? { useElementReconciliation: false, innerLoops: undefined } : decideLoopRendering(l, siblingOffsets, ctx);
15908
16037
  let template = "";
16038
+ let templateIndexed;
15909
16039
  let staticItemTemplate;
15910
16040
  let skeletonTemplate;
15911
16041
  let skeletonPaths;
@@ -15917,6 +16047,10 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
15917
16047
  } else if (l.children[0] && !projectionInner) {
15918
16048
  const loopParamSpec = [{ param: l.param, bindings: l.paramBindings }];
15919
16049
  template = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, loopParamSpec) : irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, loopParamSpec);
16050
+ if (l.index) {
16051
+ const loopParamSpecIndexed = [{ param: l.param, bindings: l.paramBindings, index: l.index }];
16052
+ templateIndexed = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, loopParamSpecIndexed) : irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, loopParamSpecIndexed);
16053
+ }
15920
16054
  if (l.isStaticArray) {
15921
16055
  staticItemTemplate = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], resolveRestSpreadNames(ctx), 0) : irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx), 0);
15922
16056
  } else if (!useElementReconciliation && !l.bodyIsMultiRoot && !l.bodyIsItemConditional) {
@@ -15945,6 +16079,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
15945
16079
  iterationShape: l.iterationShape,
15946
16080
  objectIteration: l.objectIteration,
15947
16081
  template,
16082
+ templateIndexed,
15948
16083
  staticItemTemplate,
15949
16084
  skeletonTemplate,
15950
16085
  skeletonPaths,
@@ -16135,6 +16270,7 @@ function collectBranchLoops(node, ctx, siblingOffsets) {
16135
16270
  const projectionInner = n.method === "flatMap" && n.children.length === 1 && n.children[0].type === "loop" ? n.children[0] : undefined;
16136
16271
  const { useElementReconciliation, innerLoops: innerLoopsCollected } = projectionInner ? { useElementReconciliation: false, innerLoops: undefined } : decideLoopRendering(n, siblingOffsets, undefined);
16137
16272
  let childTemplate;
16273
+ let childTemplateIndexed;
16138
16274
  const branchLoopParamSpec = [{ param: n.param, bindings: n.paramBindings }];
16139
16275
  if (projectionInner) {
16140
16276
  childTemplate = "";
@@ -16143,6 +16279,10 @@ function collectBranchLoops(node, ctx, siblingOffsets) {
16143
16279
  } else {
16144
16280
  childTemplate = n.children.map((c) => irToHtmlTemplate(c, undefined, 0, branchLoopParamSpec)).join("");
16145
16281
  }
16282
+ if (n.index && !projectionInner) {
16283
+ const branchLoopParamSpecIndexed = [{ param: n.param, bindings: n.paramBindings, index: n.index }];
16284
+ childTemplateIndexed = useElementReconciliation && n.children[0] ? irToPlaceholderTemplate(n.children[0], restNames, 0, branchLoopParamSpecIndexed) : n.children.map((c) => irToHtmlTemplate(c, undefined, 0, branchLoopParamSpecIndexed)).join("");
16285
+ }
16146
16286
  const branchBindings = ctx && !projectionInner ? collectLoopChildBindings(n.children, ctx, siblingOffsets, n.param, n.paramBindings, preambleNamesOf(n), n.index) : emptyLoopChildBindings();
16147
16287
  loops.push({
16148
16288
  kind: "branch",
@@ -16158,6 +16298,7 @@ function collectBranchLoops(node, ctx, siblingOffsets) {
16158
16298
  iterationShape: n.iterationShape,
16159
16299
  objectIteration: n.objectIteration,
16160
16300
  template: childTemplate,
16301
+ templateIndexed: childTemplateIndexed,
16161
16302
  containerSlotId: containerSlot,
16162
16303
  preamble: n.preamble,
16163
16304
  preambleRegions: n.preambleRegions,
@@ -16240,19 +16381,10 @@ function collectLoopChildBindings(children, ctx, siblingOffsets, loopParam, loop
16240
16381
  }
16241
16382
  return bindings;
16242
16383
  }
16243
- function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex) {
16384
+ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex, loopParams, parentScope) {
16244
16385
  const conditionals = [];
16245
- const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
16246
- const refsAnyBindingViaFreeIds = (freeIds) => {
16247
- if (loopParamBindings && loopParamBindings.length > 0) {
16248
- for (const b of loopParamBindings) {
16249
- if (freeIds.has(b.name))
16250
- return true;
16251
- }
16252
- return false;
16253
- }
16254
- return loopParam ? freeIds.has(loopParam) : false;
16255
- };
16386
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope);
16387
+ const refsAnyBindingViaFreeIds = (freeIds) => scope !== undefined && anyNameIn(scope.valueBoundNames(), freeIds);
16256
16388
  walkIR(node, null, {
16257
16389
  ...stopAt("loop", "async", "ifStatement"),
16258
16390
  conditional: ({ node: n }) => {
@@ -16264,9 +16396,9 @@ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loop
16264
16396
  return;
16265
16397
  const expanded = expandConstantForReactivity(n.condition, ctx, sourceFreeIds, scope);
16266
16398
  const readsPreamble = preambleNames !== undefined && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
16267
- if (!readsPreamble && classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind === "none")
16399
+ if (!readsPreamble && classifyReactivity(expanded.expr, ctx, scope, expanded.freeIds).kind === "none")
16268
16400
  return;
16269
- const loopParamsForCond = loopParam ? [{ param: loopParam, bindings: loopParamBindings }] : undefined;
16401
+ const loopParamsForCond = loopParams ?? (loopParam ? [{ param: loopParam, bindings: loopParamBindings, index: loopIndex }] : undefined);
16270
16402
  const whenTrueHtml = irToHtmlTemplate(n.whenTrue, undefined, 0, loopParamsForCond, "__slots");
16271
16403
  const whenFalseHtml = irToHtmlTemplate(n.whenFalse, undefined, 0, loopParamsForCond, "__slots");
16272
16404
  conditionals.push({
@@ -16284,7 +16416,7 @@ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loop
16284
16416
  return conditionals;
16285
16417
  }
16286
16418
  function summarizeLoopChildBranch(node, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex) {
16287
- const inner = collectInnerLoops([node], siblingOffsets, loopParam, ctx, branchInnerLoopOptions);
16419
+ const inner = collectInnerLoops([node], siblingOffsets, loopParam ? { param: loopParam, bindings: loopParamBindings, index: loopIndex } : undefined, ctx, branchInnerLoopOptions);
16288
16420
  return {
16289
16421
  childComponents: collectConditionalBranchChildComponents(node),
16290
16422
  innerLoops: inner.length > 0 ? inner : undefined,
@@ -16850,6 +16982,7 @@ var RUNTIME_IMPORT_CANDIDATES = [
16850
16982
  "escapeAttr",
16851
16983
  "escapeText",
16852
16984
  "escapeTextOrNode",
16985
+ "escapeCommentText",
16853
16986
  "bfMarkup",
16854
16987
  "escapeTextOrMarkup",
16855
16988
  "markupOrEmpty",
@@ -17909,7 +18042,7 @@ function emitRegistrationAndHydration(lines, ctx, _ir, graph, inlinability) {
17909
18042
  const isCommentScope = isFragmentRoot || _ir.root.type === "component";
17910
18043
  const defParts = [`init: init${name}`];
17911
18044
  if (canGenerateStaticTemplate(_ir.root, propNamesForStaticCheck, inlinableConstants, unsafeLocalNames)) {
17912
- const markupSlotIds = new Set(ctx.dynamicElements.map((e) => e.slotId));
18045
+ const markupSlotIds = markupSlotIdsOf(ctx);
17913
18046
  const templateHtml = irToComponentTemplate(_ir.root, inlinableConstants, restSpreadNames, ctx.propsObjectName, markupSlotIds, ctx.restPropsName);
17914
18047
  if (templateHtml) {
17915
18048
  defParts.push(buildTemplateDefPart(ctx, templateHtml));
@@ -18934,12 +19067,12 @@ function nestedLoopIndexAlias(inner, syntheticIndexVar, paramHead, comps, events
18934
19067
  return null;
18935
19068
  return `const ${index} = ${syntheticIndexVar}`;
18936
19069
  }
18937
- function buildChildRefBindings(refs, loopParam, loopParamBindings) {
19070
+ function buildChildRefBindings(refs, loopParam, loopParamBindings, loopIndex) {
18938
19071
  if (refs.length === 0)
18939
19072
  return [];
18940
19073
  return refs.map((r) => ({
18941
19074
  childSlotId: r.childSlotId,
18942
- callback: wrapLoopParamAsAccessor(r.callback, loopParam, loopParamBindings)
19075
+ callback: wrapLoopParamAsAccessor(r.callback, loopParam, loopParamBindings, loopIndex)
18943
19076
  }));
18944
19077
  }
18945
19078
  function buildStaticChildRefBindings(refs) {
@@ -18972,17 +19105,17 @@ function destructureLoopParam(param, paramBindings) {
18972
19105
  }
18973
19106
  return { head: param, unwrap: "" };
18974
19107
  }
18975
- function buildPreambleRegionPlans(regions, loopParam, loopParamBindings) {
19108
+ function buildPreambleRegionPlans(regions, loopParam, loopParamBindings, loopIndex) {
18976
19109
  if (!regions || regions.length === 0)
18977
19110
  return [];
18978
19111
  return regions.map((r) => {
18979
- const wrapped = wrapLoopParamAsAccessor(r.expr, loopParam, loopParamBindings);
18980
- const valueExpr = r.joinArrayChild ? `Array.isArray(${wrapped}) ? ${wrapped}.join('') : (${wrapped} ?? '')` : `escapeText(${wrapped})`;
19112
+ const wrapped = wrapLoopParamAsAccessor(r.expr, loopParam, loopParamBindings, loopIndex);
19113
+ const valueExpr = spliceChildValue({ expr: r.expr, slotId: r.slotId, joinArrayChild: r.joinArrayChild }, wrapped, {});
18981
19114
  return { slotId: r.slotId, valueExpr };
18982
19115
  });
18983
19116
  }
18984
- function buildComponentPropsExpr2(comp, loopParam, loopParamBindings) {
18985
- const wrap = loopParam ? (expr) => wrapLoopParamAsAccessor(expr, loopParam, loopParamBindings) : (expr) => expr;
19117
+ function buildComponentPropsExpr2(comp, loopParam, loopParamBindings, loopIndex) {
19118
+ const wrap = loopParam ? (expr) => wrapLoopParamAsAccessor(expr, loopParam, loopParamBindings, loopIndex) : (expr) => expr;
18986
19119
  const entries = comp.props.map((p) => {
18987
19120
  if (p.isEventHandler) {
18988
19121
  const handlerExpr = attrValueToString(p.value) ?? "undefined";
@@ -19026,8 +19159,8 @@ function buildDepthLevels(innerLoops, nestedComps, childEvents) {
19026
19159
  loopInfo: loop
19027
19160
  }));
19028
19161
  }
19029
- function emitEventSetup(ls, indent, elVar, ev, loopParam, loopParamBindings, bodyIsMultiRoot = false) {
19030
- const handler = loopParam ? wrapLoopParamAsAccessor(ev.handler, loopParam, loopParamBindings) : ev.handler;
19162
+ function emitEventSetup(ls, indent, elVar, ev, loopParam, loopParamBindings, bodyIsMultiRoot = false, loopIndex) {
19163
+ const handler = loopParam ? wrapLoopParamAsAccessor(ev.handler, loopParam, loopParamBindings, loopIndex) : ev.handler;
19031
19164
  emitListenerBlock(ls, indent, elVar, ev.childSlotId, "__e", ev.eventName, handler, "dom", bodyIsMultiRoot);
19032
19165
  }
19033
19166
  function buildCompSelector(comp) {
@@ -19039,15 +19172,15 @@ function isTextOnlyConditional(node) {
19039
19172
  const checkNode = (n) => n.type === "text" || n.type === "expression" || n.type === "conditional" && isTextOnlyConditional(n);
19040
19173
  return checkNode(node.whenTrue) && checkNode(node.whenFalse);
19041
19174
  }
19042
- function emitComponentAndEventSetup(ls, indent, elVar, comps, events, loopParam, loopParamBindings, bodyIsMultiRoot = false) {
19043
- const wrap = loopParam ? (expr) => wrapLoopParamAsAccessor(expr, loopParam, loopParamBindings) : (expr) => expr;
19175
+ function emitComponentAndEventSetup(ls, indent, elVar, comps, events, loopParam, loopParamBindings, bodyIsMultiRoot = false, loopIndex) {
19176
+ const wrap = loopParam ? (expr) => wrapLoopParamAsAccessor(expr, loopParam, loopParamBindings, loopIndex) : (expr) => expr;
19044
19177
  const upsertFn = bodyIsMultiRoot ? "upsertChildItem" : "upsertChild";
19045
19178
  for (const comp of comps) {
19046
- const propsExpr = buildComponentPropsExpr2(comp, loopParam, loopParamBindings);
19179
+ const propsExpr = buildComponentPropsExpr2(comp, loopParam, loopParamBindings, loopIndex);
19047
19180
  const isTextOnly = comp.children?.length ? comp.children.every((c) => c.type === "expression" || c.type === "text" || isTextOnlyConditional(c)) : false;
19048
19181
  const rawChildrenExpr = isTextOnly ? irChildrenToJsExpr(comp.children) : null;
19049
19182
  const childrenFreeIds = isTextOnly && comp.children ? irChildrenFreeIds(comp.children) : undefined;
19050
- const childrenRefsLoop = loopParam != null && rawChildrenExpr != null && childrenFreeIds != null && exprRefsLoopBinding(childrenFreeIds, { param: loopParam, paramBindings: loopParamBindings });
19183
+ const childrenRefsLoop = loopParam != null && rawChildrenExpr != null && childrenFreeIds != null && (exprRefsLoopBinding(childrenFreeIds, { param: loopParam, paramBindings: loopParamBindings }) || !!loopIndex && childrenFreeIds.has(loopIndex));
19051
19184
  const slotIdLit = comp.slotId ? `'${comp.slotId}'` : "null";
19052
19185
  const keyProp = comp.props.find((p) => p.name === "key");
19053
19186
  const keyArg = keyProp ? `, ${wrap(attrValueToString(keyProp.value) ?? "undefined")}` : ", undefined";
@@ -19060,7 +19193,7 @@ function emitComponentAndEventSetup(ls, indent, elVar, comps, events, loopParam,
19060
19193
  }
19061
19194
  }
19062
19195
  for (const ev of events) {
19063
- emitEventSetup(ls, indent, elVar, ev, loopParam, loopParamBindings, bodyIsMultiRoot);
19196
+ emitEventSetup(ls, indent, elVar, ev, loopParam, loopParamBindings, bodyIsMultiRoot, loopIndex);
19064
19197
  }
19065
19198
  }
19066
19199
 
@@ -19432,6 +19565,7 @@ function buildBranchInnerLoopsPlan(args) {
19432
19565
  condSlotId,
19433
19566
  outerLoopParam,
19434
19567
  outerLoopParamBindings,
19568
+ outerLoopIndex,
19435
19569
  wrapOuter
19436
19570
  } = args;
19437
19571
  if (!innerLoops || innerLoops.length === 0)
@@ -19439,14 +19573,14 @@ function buildBranchInnerLoopsPlan(args) {
19439
19573
  const plan = [];
19440
19574
  for (let i = 0;i < innerLoops.length; i++) {
19441
19575
  const inner = innerLoops[i];
19442
- if (!inner.refsOuterParam || !inner.template)
19576
+ if (!inner.template)
19443
19577
  continue;
19444
- const wrapInner = (expr) => wrapLoopParamAsAccessor(expr, inner.param, inner.paramBindings);
19445
- const wrapBoth = (expr) => wrapLoopParamAsAccessor(wrapOuter(expr), inner.param, inner.paramBindings);
19578
+ const wrapInner = (expr) => wrapLoopParamAsAccessor(expr, inner.param, inner.paramBindings, inner.index);
19579
+ const wrapBoth = (expr) => wrapLoopParamAsAccessor(wrapOuter(expr), inner.param, inner.paramBindings, inner.index);
19446
19580
  const csl = inner.containerSlotId;
19447
19581
  const containerExpr = csl ? `(${scopeVar}.querySelector('[bf="${csl}"]') ?? ${scopeVar}.querySelector(\`[${BF_HOST2}="\${__scopeId}"][${BF_AT2}="${csl}"]\`) ?? ${scopeVar})` : `findCondContainer(${scopeVar}, '${condSlotId}')`;
19448
19582
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(inner.param, inner.paramBindings);
19449
- const wrappedKey = inner.key ? wrapLoopParamAsAccessor(inner.key, inner.param, inner.paramBindings) : null;
19583
+ const wrappedKey = inner.key ? wrapLoopParamAsAccessor(inner.key, inner.param, inner.paramBindings, inner.index) : null;
19450
19584
  const wrapIRNode = (node) => {
19451
19585
  if (node.type === "component") {
19452
19586
  return {
@@ -19502,18 +19636,20 @@ function buildBranchInnerLoopsPlan(args) {
19502
19636
  scopeVar: `__belbr_${i}`,
19503
19637
  wrap: wrapBoth,
19504
19638
  loopParam: inner.param,
19505
- loopParamBindings: inner.paramBindings
19639
+ loopParamBindings: inner.paramBindings,
19640
+ loopIndex: inner.index
19506
19641
  }),
19507
19642
  innerLoopParam: inner.param,
19508
19643
  innerLoopParamBindings: inner.paramBindings,
19509
19644
  outerLoopParam,
19510
- outerLoopParamBindings
19645
+ outerLoopParamBindings,
19646
+ outerLoopIndex
19511
19647
  });
19512
19648
  }
19513
19649
  return plan;
19514
19650
  }
19515
19651
  function buildLoopChildConditionalsPlan(args) {
19516
- const { conditionals, scopeVar, wrap, loopParam, loopParamBindings } = args;
19652
+ const { conditionals, scopeVar, wrap, loopParam, loopParamBindings, loopIndex } = args;
19517
19653
  if (!conditionals || conditionals.length === 0)
19518
19654
  return [];
19519
19655
  const plans = [];
@@ -19522,13 +19658,14 @@ function buildLoopChildConditionalsPlan(args) {
19522
19658
  slotId: cond.slotId,
19523
19659
  scopeVar,
19524
19660
  wrappedCondition: wrap(cond.condition),
19525
- whenTrueTemplateHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
19526
- whenFalseTemplateHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId),
19661
+ whenTrueTemplateHtml: addCondAttrToTemplate(cond.whenTrueHtml, cond.slotId),
19662
+ whenFalseTemplateHtml: addCondAttrToTemplate(cond.whenFalseHtml, cond.slotId),
19527
19663
  whenTrueArm: buildLoopChildArmPlan({
19528
19664
  branch: cond.whenTrue,
19529
19665
  wrap,
19530
19666
  loopParam,
19531
19667
  loopParamBindings,
19668
+ loopIndex,
19532
19669
  condId: cond.slotId
19533
19670
  }),
19534
19671
  whenFalseArm: buildLoopChildArmPlan({
@@ -19536,8 +19673,10 @@ function buildLoopChildConditionalsPlan(args) {
19536
19673
  wrap,
19537
19674
  loopParam,
19538
19675
  loopParamBindings,
19676
+ loopIndex,
19539
19677
  condId: cond.slotId
19540
- })
19678
+ }),
19679
+ ...cond.readsPreamble && { readsPreamble: true }
19541
19680
  });
19542
19681
  }
19543
19682
  return plans;
@@ -19561,7 +19700,8 @@ function buildArmAttrsPlan(attrs, wrap) {
19561
19700
  attrs: slotAttrs.map((attr) => ({
19562
19701
  attrName: attr.attrName,
19563
19702
  wrappedExpression: wrap(attr.expression),
19564
- meta: pickAttrMeta(attr)
19703
+ meta: pickAttrMeta(attr),
19704
+ ...attr.readsPreamble && { readsPreamble: true }
19565
19705
  }))
19566
19706
  });
19567
19707
  }
@@ -19576,7 +19716,7 @@ function buildArmTextsPlan(texts, wrap) {
19576
19716
  }));
19577
19717
  }
19578
19718
  function buildLoopChildArmPlan(args) {
19579
- const { branch, wrap, loopParam, loopParamBindings, condId } = args;
19719
+ const { branch, wrap, loopParam, loopParamBindings, loopIndex, condId } = args;
19580
19720
  return {
19581
19721
  events: buildBranchEventBindingsPlan({
19582
19722
  events: branch.events,
@@ -19592,6 +19732,7 @@ function buildLoopChildArmPlan(args) {
19592
19732
  condSlotId: condId,
19593
19733
  outerLoopParam: loopParam,
19594
19734
  outerLoopParamBindings: loopParamBindings,
19735
+ outerLoopIndex: loopIndex,
19595
19736
  wrapOuter: wrap
19596
19737
  }),
19597
19738
  nestedConditionals: buildLoopChildConditionalsPlan({
@@ -19599,7 +19740,8 @@ function buildLoopChildArmPlan(args) {
19599
19740
  scopeVar: "__branchScope",
19600
19741
  wrap,
19601
19742
  loopParam,
19602
- loopParamBindings
19743
+ loopParamBindings,
19744
+ loopIndex
19603
19745
  }),
19604
19746
  attrs: buildArmAttrsPlan(branch.reactiveAttrs, wrap),
19605
19747
  texts: buildArmTextsPlan(branch.reactiveTexts, wrap)
@@ -19608,8 +19750,8 @@ function buildLoopChildArmPlan(args) {
19608
19750
 
19609
19751
  // src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts
19610
19752
  function buildReactiveEffectsPlan(args) {
19611
- const { attrs, texts, conditionals, loopParam, loopParamBindings, profileComponentName } = args;
19612
- const wrap = (expr) => wrapLoopParamAsAccessor(expr, loopParam, loopParamBindings);
19753
+ const { attrs, texts, conditionals, loopParam, loopParamBindings, loopIndex, profileComponentName } = args;
19754
+ const wrap = (expr) => wrapLoopParamAsAccessor(expr, loopParam, loopParamBindings, loopIndex);
19613
19755
  const attrsBySlot = new Map;
19614
19756
  for (const attr of attrs) {
19615
19757
  let bucket = attrsBySlot.get(attr.childSlotId);
@@ -19641,10 +19783,10 @@ function buildReactiveEffectsPlan(args) {
19641
19783
  conditionalPlans.push({
19642
19784
  slotId: cond.slotId,
19643
19785
  wrappedCondition: wrap(cond.condition),
19644
- whenTrueTemplateHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
19645
- whenFalseTemplateHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId),
19646
- whenTrueArm: buildOuterArm(cond.whenTrue, wrap, loopParam, loopParamBindings, cond.slotId, profileComponentName),
19647
- whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, cond.slotId, profileComponentName),
19786
+ whenTrueTemplateHtml: addCondAttrToTemplate(cond.whenTrueHtml, cond.slotId),
19787
+ whenFalseTemplateHtml: addCondAttrToTemplate(cond.whenFalseHtml, cond.slotId),
19788
+ whenTrueArm: buildOuterArm(cond.whenTrue, wrap, loopParam, loopParamBindings, loopIndex, cond.slotId, profileComponentName),
19789
+ whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, loopIndex, cond.slotId, profileComponentName),
19648
19790
  ...cond.readsPreamble && { readsPreamble: true }
19649
19791
  });
19650
19792
  }
@@ -19656,7 +19798,7 @@ function buildReactiveEffectsPlan(args) {
19656
19798
  profileComponentName
19657
19799
  };
19658
19800
  }
19659
- function buildOuterArm(branch, wrap, loopParam, loopParamBindings, condSlotId, profileComponentName) {
19801
+ function buildOuterArm(branch, wrap, loopParam, loopParamBindings, loopIndex, condSlotId, profileComponentName) {
19660
19802
  return {
19661
19803
  events: buildBranchEventBindingsPlan({
19662
19804
  events: branch.events,
@@ -19673,6 +19815,7 @@ function buildOuterArm(branch, wrap, loopParam, loopParamBindings, condSlotId, p
19673
19815
  condSlotId,
19674
19816
  outerLoopParam: loopParam,
19675
19817
  outerLoopParamBindings: loopParamBindings,
19818
+ outerLoopIndex: loopIndex,
19676
19819
  wrapOuter: wrap
19677
19820
  }),
19678
19821
  nestedConditionals: buildLoopChildConditionalsPlan({
@@ -19680,7 +19823,8 @@ function buildOuterArm(branch, wrap, loopParam, loopParamBindings, condSlotId, p
19680
19823
  scopeVar: "__branchScope",
19681
19824
  wrap,
19682
19825
  loopParam,
19683
- loopParamBindings
19826
+ loopParamBindings,
19827
+ loopIndex
19684
19828
  }),
19685
19829
  attrs: buildArmAttrsPlan(branch.reactiveAttrs, wrap),
19686
19830
  texts: buildArmTextsPlan(branch.reactiveTexts, wrap)
@@ -19693,6 +19837,7 @@ function buildLoopReactiveEffectsPlan(elem, profileComponentName) {
19693
19837
  conditionals: elem.bindings.conditionals,
19694
19838
  loopParam: elem.param,
19695
19839
  loopParamBindings: elem.paramBindings,
19840
+ loopIndex: elem.index,
19696
19841
  profileComponentName
19697
19842
  });
19698
19843
  }
@@ -19719,8 +19864,8 @@ function wrapAttrValueExpression2(value, wrap) {
19719
19864
  }
19720
19865
  }
19721
19866
  function buildInnerLoopsPlan(args) {
19722
- const { levels, parentElVar, outerLoopParam, outerLoopParamBindings } = args;
19723
- const wrapOuter = outerLoopParam ? (expr) => wrapLoopParamAsAccessor(expr, outerLoopParam, outerLoopParamBindings) : (expr) => expr;
19867
+ const { levels, parentElVar, outerLoopParam, outerLoopParamBindings, outerLoopIndex } = args;
19868
+ const wrapOuter = outerLoopParam ? (expr) => wrapLoopParamAsAccessor(expr, outerLoopParam, outerLoopParamBindings, outerLoopIndex) : (expr) => expr;
19724
19869
  const plan = [];
19725
19870
  let i = 0;
19726
19871
  while (i < levels.length) {
@@ -19742,15 +19887,14 @@ function buildInnerLoopsPlan(args) {
19742
19887
  }
19743
19888
  const uidSuffix = `${inner.depth}_${i}`;
19744
19889
  const containerExpr = inner.containerSlotId ? `qsa(${parentElVar}, '[bf="${inner.containerSlotId}"]')` : parentElVar;
19745
- const refsParent = !!outerLoopParam && (inner.arrayFreeIdentifiers?.has(outerLoopParam) ?? false);
19746
- const useReactive = refsParent && !!inner.template;
19747
- const emit = useReactive ? buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings) : buildStaticEmit(inner, level, uidSuffix);
19748
- const arrayExpr = useReactive ? wrapOuter(inner.array) : inner.array;
19890
+ const emit = buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings, outerLoopIndex);
19891
+ const arrayExpr = wrapOuter(inner.array);
19749
19892
  const childLevelsPlan = childLevels.length > 0 ? buildInnerLoopsPlan({
19750
19893
  levels: childLevels,
19751
19894
  parentElVar: `__innerEl${uidSuffix}`,
19752
19895
  outerLoopParam: inner.param,
19753
- outerLoopParamBindings: inner.paramBindings
19896
+ outerLoopParamBindings: inner.paramBindings,
19897
+ outerLoopIndex: inner.index
19754
19898
  }) : [];
19755
19899
  plan.push({
19756
19900
  uidSuffix,
@@ -19764,17 +19908,18 @@ function buildInnerLoopsPlan(args) {
19764
19908
  emit,
19765
19909
  childLevels: childLevelsPlan,
19766
19910
  outerLoopParam,
19767
- outerLoopParamBindings
19911
+ outerLoopParamBindings,
19912
+ outerLoopIndex
19768
19913
  });
19769
19914
  i = j;
19770
19915
  }
19771
19916
  return plan;
19772
19917
  }
19773
- function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings) {
19774
- const wrapInner = (expr) => wrapLoopParamAsAccessor(expr, inner.param, inner.paramBindings);
19775
- const wrapBoth = (expr) => wrapLoopParamAsAccessor(wrapOuter(expr), inner.param, inner.paramBindings);
19918
+ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings, outerLoopIndex) {
19919
+ const wrapInner = (expr) => wrapLoopParamAsAccessor(expr, inner.param, inner.paramBindings, inner.index);
19920
+ const wrapBoth = (expr) => wrapLoopParamAsAccessor(wrapOuter(expr), inner.param, inner.paramBindings, inner.index);
19776
19921
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(inner.param, inner.paramBindings);
19777
- const wrappedKey = inner.key ? wrapLoopParamAsAccessor(inner.key, inner.param, inner.paramBindings) : null;
19922
+ const wrappedKey = inner.key ? wrapLoopParamAsAccessor(inner.key, inner.param, inner.paramBindings, inner.index) : null;
19778
19923
  const wrapIRNode = (node) => {
19779
19924
  if (node.type === "component") {
19780
19925
  return {
@@ -19805,11 +19950,11 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
19805
19950
  }));
19806
19951
  const reactiveTexts = inner.bindings.reactiveTexts.map((text) => ({
19807
19952
  slotId: text.slotId,
19808
- wrappedExpression: wrapLoopParamAsAccessor(wrapOuter(text.expression), inner.param, inner.paramBindings),
19953
+ wrappedExpression: wrapLoopParamAsAccessor(wrapOuter(text.expression), inner.param, inner.paramBindings, inner.index),
19809
19954
  insideConditional: !!text.insideConditional
19810
19955
  }));
19811
19956
  const reactiveAttrs = inner.bindings.reactiveAttrs.map((attr) => {
19812
- const wrapped = wrapLoopParamAsAccessor(wrapOuter(attr.expression), inner.param, inner.paramBindings);
19957
+ const wrapped = wrapLoopParamAsAccessor(wrapOuter(attr.expression), inner.param, inner.paramBindings, inner.index);
19813
19958
  return {
19814
19959
  slotId: attr.childSlotId,
19815
19960
  attrName: attr.attrName,
@@ -19825,21 +19970,22 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
19825
19970
  preludeStatements.push(paramUnwrap);
19826
19971
  if (inner.preamble) {
19827
19972
  const leafLoopParams = outerLoopParam ? [
19828
- { param: outerLoopParam, bindings: outerLoopParamBindings },
19829
- { param: inner.param, bindings: inner.paramBindings }
19830
- ] : [{ param: inner.param, bindings: inner.paramBindings }];
19973
+ { param: outerLoopParam, bindings: outerLoopParamBindings, index: outerLoopIndex },
19974
+ { param: inner.param, bindings: inner.paramBindings, index: inner.index }
19975
+ ] : [{ param: inner.param, bindings: inner.paramBindings, index: inner.index }];
19831
19976
  preludeStatements.push(renderPreamble(inner.preamble, {
19832
19977
  transformJs: (t) => wrapInner(wrapOuter(t)),
19833
19978
  renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, leafLoopParams, undefined)
19834
19979
  }));
19835
19980
  }
19836
- const childRefs = buildChildRefBindings(inner.bindings.refs, inner.param, inner.paramBindings);
19981
+ const childRefs = buildChildRefBindings(inner.bindings.refs, inner.param, inner.paramBindings, inner.index);
19837
19982
  const conditionals = buildLoopChildConditionalsPlan({
19838
19983
  conditionals: inner.bindings.conditionals,
19839
19984
  scopeVar: `__innerEl${uidSuffix}`,
19840
19985
  wrap: wrapBoth,
19841
19986
  loopParam: inner.param,
19842
- loopParamBindings: inner.paramBindings
19987
+ loopParamBindings: inner.paramBindings,
19988
+ loopIndex: inner.index
19843
19989
  });
19844
19990
  return {
19845
19991
  mode: "reactive",
@@ -19857,32 +20003,13 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
19857
20003
  childRefs
19858
20004
  };
19859
20005
  }
19860
- function buildStaticEmit(inner, level, uidSuffix) {
19861
- const preludeStatements = [];
19862
- const indexAlias = nestedLoopIndexAlias(inner, `__innerIdx${uidSuffix}`, inner.param, level.comps, level.events);
19863
- if (indexAlias)
19864
- preludeStatements.push(indexAlias);
19865
- if (inner.preamble) {
19866
- preludeStatements.push(renderPreamble(inner.preamble, {
19867
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, undefined, undefined)
19868
- }));
19869
- }
19870
- return {
19871
- mode: "static",
19872
- rawKey: inner.key ?? null,
19873
- preludeStatements,
19874
- components: level.comps,
19875
- events: level.events,
19876
- childRefs: buildStaticChildRefBindings(inner.bindings.refs)
19877
- };
19878
- }
19879
20006
 
19880
20007
  // src/ir-to-client-js/control-flow/plan/build-composite-loop.ts
19881
20008
  function buildTopLevelCompositePlan(elem, profileComponentName) {
19882
20009
  const nestedComps = elem.nestedComponents;
19883
20010
  const depthLevels = buildDepthLevels(elem.innerLoops ?? [], nestedComps, elem.bindings.events);
19884
20011
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(elem.param, elem.paramBindings);
19885
- const wrap = (expr) => wrapLoopParamAsAccessor(expr, elem.param, elem.paramBindings);
20012
+ const wrap = (expr) => wrapLoopParamAsAccessor(expr, elem.param, elem.paramBindings, elem.index);
19886
20013
  const outerCompsByDepth = nestedComps.filter((c) => !c.loopDepth || c.loopDepth === 0);
19887
20014
  return {
19888
20015
  kind: "composite",
@@ -19896,26 +20023,29 @@ function buildTopLevelCompositePlan(elem, profileComponentName) {
19896
20023
  indexParam: elem.index || "__idx",
19897
20024
  mapPreambleWrapped: elem.preamble ? renderPreamble(elem.preamble, {
19898
20025
  transformJs: wrap,
19899
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: elem.param, bindings: elem.paramBindings }], undefined)
20026
+ renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: elem.param, bindings: elem.paramBindings, index: elem.index }], undefined)
19900
20027
  }) : "",
19901
20028
  template: elem.template,
19902
20029
  outerComps: filterCondCompsOut(outerCompsByDepth, elem.bindings.conditionals),
19903
20030
  outerEvents: elem.bindings.events.filter((ev) => ev.nestedLoops.length === 0),
19904
- childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings),
20031
+ childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings, elem.index),
19905
20032
  innerLoops: buildInnerLoopsPlan({
19906
20033
  levels: depthLevels,
19907
20034
  parentElVar: "__el",
19908
20035
  outerLoopParam: elem.param,
19909
- outerLoopParamBindings: elem.paramBindings
20036
+ outerLoopParamBindings: elem.paramBindings,
20037
+ outerLoopIndex: elem.index
19910
20038
  }),
19911
20039
  loopParam: elem.param,
19912
20040
  loopParamBindings: elem.paramBindings,
20041
+ loopIndex: elem.index,
19913
20042
  reactiveEffects: hasReactive(elem) ? buildReactiveEffectsPlan({
19914
20043
  attrs: elem.bindings.reactiveAttrs,
19915
20044
  texts: elem.bindings.reactiveTexts,
19916
20045
  conditionals: elem.bindings.conditionals,
19917
20046
  loopParam: elem.param,
19918
20047
  loopParamBindings: elem.paramBindings,
20048
+ loopIndex: elem.index,
19919
20049
  profileComponentName
19920
20050
  }) : null,
19921
20051
  branchClearChildren: false,
@@ -19932,7 +20062,7 @@ function buildBranchCompositePlan(loop, cv, profileComponentName) {
19932
20062
  const childEvents = loop.bindings.events;
19933
20063
  const depthLevels = buildDepthLevels(innerLoops, nestedComps, childEvents);
19934
20064
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(loop.param, loop.paramBindings);
19935
- const wrap = (expr) => wrapLoopParamAsAccessor(expr, loop.param, loop.paramBindings);
20065
+ const wrap = (expr) => wrapLoopParamAsAccessor(expr, loop.param, loop.paramBindings, loop.index);
19936
20066
  const outerCompsByDepth = nestedComps.filter((c) => !c.loopDepth || c.loopDepth === 0);
19937
20067
  return {
19938
20068
  kind: "composite",
@@ -19946,26 +20076,29 @@ function buildBranchCompositePlan(loop, cv, profileComponentName) {
19946
20076
  indexParam: loop.index || "__idx",
19947
20077
  mapPreambleWrapped: loop.preamble ? renderPreamble(loop.preamble, {
19948
20078
  transformJs: wrap,
19949
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: loop.param, bindings: loop.paramBindings }], undefined)
20079
+ renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: loop.param, bindings: loop.paramBindings, index: loop.index }], undefined)
19950
20080
  }) : "",
19951
20081
  template: loop.template,
19952
20082
  outerComps: filterCondCompsOut(outerCompsByDepth, loop.bindings.conditionals),
19953
20083
  outerEvents: childEvents.filter((ev) => ev.nestedLoops.length === 0),
19954
- childRefs: buildChildRefBindings(loop.bindings.refs, loop.param, loop.paramBindings),
20084
+ childRefs: buildChildRefBindings(loop.bindings.refs, loop.param, loop.paramBindings, loop.index),
19955
20085
  innerLoops: buildInnerLoopsPlan({
19956
20086
  levels: depthLevels,
19957
20087
  parentElVar: "__el",
19958
20088
  outerLoopParam: loop.param,
19959
- outerLoopParamBindings: loop.paramBindings
20089
+ outerLoopParamBindings: loop.paramBindings,
20090
+ outerLoopIndex: loop.index
19960
20091
  }),
19961
20092
  loopParam: loop.param,
19962
20093
  loopParamBindings: loop.paramBindings,
20094
+ loopIndex: loop.index,
19963
20095
  reactiveEffects: hasReactiveBranch(loop) ? buildReactiveEffectsPlan({
19964
20096
  attrs: loop.bindings.reactiveAttrs,
19965
20097
  texts: loop.bindings.reactiveTexts,
19966
20098
  conditionals: loop.bindings.conditionals,
19967
20099
  loopParam: loop.param,
19968
20100
  loopParamBindings: loop.paramBindings,
20101
+ loopIndex: loop.index,
19969
20102
  profileComponentName
19970
20103
  }) : null,
19971
20104
  branchClearChildren: true,
@@ -20100,7 +20233,7 @@ function wiringOn(branch) {
20100
20233
  found.push("reactive text");
20101
20234
  return found;
20102
20235
  }
20103
- function analyzeLazyConditional(cond, indexParam, arms) {
20236
+ function analyzeLazyConditional(cond, arms) {
20104
20237
  for (const [label, branch] of [["true", cond.whenTrue], ["false", cond.whenFalse]]) {
20105
20238
  const wiring = wiringOn(branch);
20106
20239
  if (wiring.length > 0) {
@@ -20121,9 +20254,6 @@ function analyzeLazyConditional(cond, indexParam, arms) {
20121
20254
  if (!cond.conditionFreeIdentifiers) {
20122
20255
  return NO(`conditional on slot ${cond.slotId}: condition has no analyzable identifier set`);
20123
20256
  }
20124
- if (cond.conditionFreeIdentifiers.has(indexParam)) {
20125
- return NO(`conditional on slot ${cond.slotId}: condition reads the loop index parameter '${indexParam}'`);
20126
- }
20127
20257
  return {
20128
20258
  lazySafe: true,
20129
20259
  facts: {
@@ -20142,7 +20272,7 @@ var NO_PREAMBLE = {
20142
20272
  facts: { declaredNames: new Set, freeNames: new Set }
20143
20273
  };
20144
20274
  var NO2 = (reason) => ({ lazySafe: false, reason });
20145
- function analyzeLazyPreamble(preamble, indexParam, primableNames) {
20275
+ function analyzeLazyPreamble(preamble, primableNames) {
20146
20276
  if (!preamble)
20147
20277
  return NO_PREAMBLE;
20148
20278
  if (preamble.builderNames.length > 0) {
@@ -20181,9 +20311,6 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
20181
20311
  }
20182
20312
  }
20183
20313
  const readNames = extractFreeIdentifiersFromStatementText(text);
20184
- if (readNames.has(indexParam) && !declaredNames.has(indexParam)) {
20185
- return NO2(`map-callback preamble reads the loop index parameter '${indexParam}'`);
20186
- }
20187
20314
  const freeNames = new Set(readNames);
20188
20315
  for (const declared of declaredNames)
20189
20316
  freeNames.delete(declared);
@@ -20333,9 +20460,6 @@ function lazyRowEligibility(args) {
20333
20460
  if (shape.hasParamUnwrap)
20334
20461
  return NO3("destructured loop param without param bindings");
20335
20462
  for (const b of bindings) {
20336
- if (b.referencesIndex) {
20337
- return NO3(`binding on slot ${b.slotId} references the loop index parameter`);
20338
- }
20339
20463
  if (b.opaqueOuterNames.includes(UNKNOWN_IDENTIFIERS)) {
20340
20464
  return NO3(`binding on slot ${b.slotId} has no analyzable identifier set`);
20341
20465
  }
@@ -20420,6 +20544,7 @@ function classifyLazyBinding(args) {
20420
20544
  }
20421
20545
  if (name === indexParam) {
20422
20546
  referencesIndex = true;
20547
+ readsItem = true;
20423
20548
  return;
20424
20549
  }
20425
20550
  if (INERT_BINDING_GLOBALS.has(name))
@@ -20469,14 +20594,14 @@ function decideLazyRow(args) {
20469
20594
  for (const b of loop.paramBindings ?? [])
20470
20595
  rowLocalNames.add(b.name);
20471
20596
  const primableNames = new Set([...scope.signals.keys(), ...scope.memos]);
20472
- const preambleAnalysis = analyzeLazyPreamble(loop.preamble, args.indexParam, primableNames);
20597
+ const preambleAnalysis = analyzeLazyPreamble(loop.preamble, primableNames);
20473
20598
  const rawConditionals = loop.bindings.conditionals ?? [];
20474
20599
  const condFacts = [];
20475
20600
  let conditionalRefusal = null;
20476
20601
  for (const cond of rawConditionals) {
20477
- const verdict = analyzeLazyConditional(cond, args.indexParam, {
20478
- whenTrueHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
20479
- whenFalseHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId)
20602
+ const verdict = analyzeLazyConditional(cond, {
20603
+ whenTrueHtml: addCondAttrToTemplate(cond.whenTrueHtml, cond.slotId),
20604
+ whenFalseHtml: addCondAttrToTemplate(cond.whenFalseHtml, cond.slotId)
20480
20605
  });
20481
20606
  if (!verdict.lazySafe) {
20482
20607
  conditionalRefusal = verdict.reason;
@@ -20616,7 +20741,8 @@ function decideLazyRow(args) {
20616
20741
  preambleStatements: args.mapPreambleWrapped,
20617
20742
  itemNeedsPreamble: [...attrs, ...texts, ...conditionals].some((b) => b.readsItem && b.readsPreamble),
20618
20743
  outerNeedsPreamble: [...attrs, ...texts, ...conditionals].some((b) => b.readsOuter && b.readsPreamble),
20619
- conditionals
20744
+ conditionals,
20745
+ readsIndex: classified.some((c) => c.referencesIndex)
20620
20746
  },
20621
20747
  decision
20622
20748
  };
@@ -20667,6 +20793,43 @@ function loopSourceIdentifiers(loop, arrayExpr) {
20667
20793
  return names;
20668
20794
  }
20669
20795
 
20796
+ // src/ir-to-client-js/control-flow/plan/build-plain-row.ts
20797
+ function buildPlainRowCore(inputs) {
20798
+ const { loop, arrayExpr, callSite, flatMapLeafItem, anchored, scope } = inputs;
20799
+ const wrapItem = (expr) => wrapLoopParamAsAccessor(expr, loop.param, loop.paramBindings);
20800
+ const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(loop.param, loop.paramBindings);
20801
+ const indexParam = loop.index || "__idx";
20802
+ const mapPreambleWrapped = loop.preamble ? renderPreamble(loop.preamble, {
20803
+ transformJs: wrapItem,
20804
+ renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: loop.param, bindings: loop.paramBindings }], undefined)
20805
+ }) : "";
20806
+ const preambleRegions = buildPreambleRegionPlans(loop.preambleRegions, loop.param, loop.paramBindings, loop.index);
20807
+ const lazyRow = buildLazyRowPlan({
20808
+ loop,
20809
+ arrayExpr,
20810
+ indexParam,
20811
+ paramUnwrap,
20812
+ mapPreambleWrapped,
20813
+ preambleRegionCount: preambleRegions.length,
20814
+ callSite,
20815
+ flatMapLeafItem,
20816
+ anchored,
20817
+ scope
20818
+ }) ?? undefined;
20819
+ const mapPreambleWrappedFinal = !lazyRow && loop.index ? wrapIndexParamAsAccessor(mapPreambleWrapped, loop.index) : mapPreambleWrapped;
20820
+ const templateFinal = !lazyRow && loop.index ? loop.templateIndexed ?? loop.template : loop.template;
20821
+ return {
20822
+ indexParam,
20823
+ paramHead,
20824
+ paramUnwrap,
20825
+ preambleRegions,
20826
+ lazyRow,
20827
+ mapPreambleWrapped: mapPreambleWrappedFinal,
20828
+ template: templateFinal,
20829
+ wrapItem
20830
+ };
20831
+ }
20832
+
20670
20833
  // src/ir-to-client-js/control-flow/plan/build-branch-loop.ts
20671
20834
  function buildBranchLoopPlan(loop, profileComponentName, lazyScope) {
20672
20835
  const containerSlotId = loop.containerSlotId;
@@ -20681,16 +20844,18 @@ function buildBranchLoopPlan(loop, profileComponentName, lazyScope) {
20681
20844
  };
20682
20845
  return composite;
20683
20846
  }
20684
- const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(loop.param, loop.paramBindings);
20685
20847
  const hasReactiveEffects = loop.bindings.reactiveAttrs.length > 0 || loop.bindings.reactiveTexts.length > 0 || loop.bindings.conditionals.length > 0;
20686
20848
  const fm = loop.flatMapClient;
20687
20849
  const arrayExpr = fm ? `(${buildChainedArrayExpr(loop)}).flatMap(${fm.params} => ${fm.body})` : buildChainedArrayExpr(loop);
20688
- const indexParam = loop.index || "__idx";
20689
- const mapPreambleWrapped = loop.preamble ? renderPreamble(loop.preamble, {
20690
- transformJs: (t) => wrapLoopParamAsAccessor(t, loop.param, loop.paramBindings),
20691
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: loop.param, bindings: loop.paramBindings }], undefined)
20692
- }) : "";
20693
- const preambleRegions = buildPreambleRegionPlans(loop.preambleRegions, loop.param, loop.paramBindings);
20850
+ const core = buildPlainRowCore({
20851
+ loop,
20852
+ arrayExpr,
20853
+ callSite: "branch-plain",
20854
+ flatMapLeafItem: Boolean(fm),
20855
+ anchored: false,
20856
+ scope: lazyScope
20857
+ });
20858
+ const { paramHead, paramUnwrap, indexParam, preambleRegions, lazyRow } = core;
20694
20859
  const plan = {
20695
20860
  kind: "plain",
20696
20861
  rowConstruction: "string-template",
@@ -20703,30 +20868,20 @@ function buildBranchLoopPlan(loop, profileComponentName, lazyScope) {
20703
20868
  paramHead,
20704
20869
  paramUnwrap,
20705
20870
  indexParam,
20706
- mapPreambleWrapped,
20707
- lazyRow: buildLazyRowPlan({
20708
- loop,
20709
- arrayExpr,
20710
- indexParam,
20711
- paramUnwrap,
20712
- mapPreambleWrapped,
20713
- preambleRegionCount: preambleRegions.length,
20714
- callSite: "branch-plain",
20715
- flatMapLeafItem: Boolean(fm),
20716
- anchored: false,
20717
- scope: lazyScope
20718
- }) ?? undefined,
20719
- template: loop.template,
20871
+ mapPreambleWrapped: core.mapPreambleWrapped,
20872
+ lazyRow,
20873
+ template: core.template,
20720
20874
  reactiveEffects: hasReactiveEffects ? buildReactiveEffectsPlan({
20721
20875
  attrs: loop.bindings.reactiveAttrs,
20722
20876
  texts: loop.bindings.reactiveTexts,
20723
20877
  conditionals: loop.bindings.conditionals,
20724
20878
  loopParam: loop.param,
20725
20879
  loopParamBindings: loop.paramBindings,
20880
+ loopIndex: loop.index,
20726
20881
  profileComponentName
20727
20882
  }) : null,
20728
20883
  eventDelegation: buildBranchLoopDelegationPlan(loop, cv, profileComponentName),
20729
- childRefs: buildChildRefBindings(loop.bindings.refs, loop.param, loop.paramBindings),
20884
+ childRefs: buildChildRefBindings(loop.bindings.refs, loop.param, loop.paramBindings, loop.index),
20730
20885
  preambleRegions,
20731
20886
  bodyIsMultiRoot: loop.bodyIsMultiRoot ?? false,
20732
20887
  profileLoopId: profileComponentName ? `${profileComponentName}#binding:${containerSlotId}` : undefined
@@ -20851,6 +21006,24 @@ function emitAttrUpdate(target, attrName, expression, meta) {
20851
21006
  `{ const __v = ${expression}; if (__v != null) ${target}.setAttribute('${htmlName}', String(__v)); else ${target}.removeAttribute('${htmlName}') }`
20852
21007
  ];
20853
21008
  }
21009
+ var DEDUP_STORE_DECL = "const __l = []";
21010
+ function dedupGuard(ordinal) {
21011
+ return `!(${ordinal} in __l) || !Object.is(__l[${ordinal}], __x)`;
21012
+ }
21013
+ function emitDedupedAttrUpdate(target, attrName, expression, meta, ordinal, guard = dedupGuard(ordinal)) {
21014
+ const write = emitAttrUpdate(target, attrName, "__x", meta);
21015
+ const lines = [`{ const __x = ${expression}`];
21016
+ if (guard) {
21017
+ lines.push(`if (${guard}) {`);
21018
+ for (const stmt of write)
21019
+ lines.push(` ${stmt}`);
21020
+ lines.push(`}`);
21021
+ } else {
21022
+ lines.push(...write);
21023
+ }
21024
+ lines.push(`__l[${ordinal}] = __x }`);
21025
+ return lines;
21026
+ }
20854
21027
  function rewriteDestructuredPropsInExpr(expr, ctx) {
20855
21028
  if (ctx.propsObjectName)
20856
21029
  return expr;
@@ -21011,7 +21184,7 @@ function emitDynamicTextUpdates(lines, ctx) {
21011
21184
  const __textSlot = (normalElems[0] ?? conditionalElems[0])?.slotId;
21012
21185
  let writer = "";
21013
21186
  if (normalElems.length > 0) {
21014
- const slots = normalElems.map((elem) => ({ id: elem.slotId, kind: "markup", path: [] }));
21187
+ const slots = normalElems.map((elem) => ({ id: elem.slotId, kind: DYNAMIC_ELEMENT_WRITER_KIND, path: [] }));
21015
21188
  writer = claimWriterVarName(slots, varSlotId);
21016
21189
  lines.push(` const ${writer} = lazySlots(__scope, ${claimPlanLiteral(slots)})`);
21017
21190
  }
@@ -21065,16 +21238,18 @@ function emitReactiveAttributeUpdates(lines, ctx) {
21065
21238
  }
21066
21239
  for (const [slotId, attrs] of attrsBySlot) {
21067
21240
  const v = varSlotId(slotId);
21241
+ lines.push(` { ${DEDUP_STORE_DECL}`);
21068
21242
  lines.push(` createEffect(() => {`);
21069
21243
  lines.push(` if (_${v}) {`);
21244
+ let ordinal = 0;
21070
21245
  for (const attr of attrs) {
21071
21246
  const expression = rewriteDestructuredPropsInExpr(lower(attr.expression), ctx);
21072
- for (const stmt of emitAttrUpdate(`_${v}`, attr.attrName, expression, attr)) {
21247
+ for (const stmt of emitDedupedAttrUpdate(`_${v}`, attr.attrName, expression, attr, ordinal++)) {
21073
21248
  lines.push(` ${stmt}`);
21074
21249
  }
21075
21250
  }
21076
21251
  lines.push(` }`);
21077
- lines.push(` }${bindingIdArg(ctx, slotId)})`);
21252
+ lines.push(` }${bindingIdArg(ctx, slotId)}) }`);
21078
21253
  lines.push("");
21079
21254
  }
21080
21255
  }
@@ -21127,6 +21302,7 @@ function emitReactiveChildProps(lines, ctx) {
21127
21302
  if (ctx.reactiveChildProps.length > 0) {
21128
21303
  lines.push("");
21129
21304
  lines.push(` // Reactive child component props`);
21305
+ lines.push(` { ${DEDUP_STORE_DECL}`);
21130
21306
  lines.push(` createEffect(() => {`);
21131
21307
  const propsByComponent = new Map;
21132
21308
  for (const prop of ctx.reactiveChildProps) {
@@ -21136,6 +21312,7 @@ function emitReactiveChildProps(lines, ctx) {
21136
21312
  }
21137
21313
  propsByComponent.get(key).push(prop);
21138
21314
  }
21315
+ let ordinal = 0;
21139
21316
  for (const [, props] of propsByComponent) {
21140
21317
  const first = props[0];
21141
21318
  const isCommentRoot = first.slotId !== null && first.slotId === ctx.commentScopeRootSlotId;
@@ -21147,26 +21324,31 @@ function emitReactiveChildProps(lines, ctx) {
21147
21324
  }
21148
21325
  lines.push(` if (${varName}) {`);
21149
21326
  for (const prop of props) {
21150
- const stmts = toHtmlAttrName(prop.attrName) === "value" ? emitChildValueMirrorStatements(varName, prop.expression) : emitAttrUpdate(varName, prop.attrName, prop.expression, prop);
21327
+ const stmts = toHtmlAttrName(prop.attrName) === "value" ? emitChildValueMirrorStatements(varName, prop.expression) : emitDedupedAttrUpdate(varName, prop.attrName, prop.expression, prop, ordinal++);
21151
21328
  for (const stmt of stmts) {
21152
21329
  lines.push(` ${stmt}`);
21153
21330
  }
21154
21331
  }
21155
21332
  lines.push(` }`);
21156
21333
  }
21157
- lines.push(` }${bindingIdArg(ctx, ctx.reactiveChildProps[0]?.slotId ?? undefined)})`);
21334
+ lines.push(` }${bindingIdArg(ctx, ctx.reactiveChildProps[0]?.slotId ?? undefined)}) }`);
21158
21335
  }
21159
21336
  }
21160
21337
 
21161
21338
  // src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts
21162
- function stringifyBranchReactiveAttrs(lines, plan, indent, pc) {
21339
+ function stringifyBranchReactiveAttrs(lines, plan, indent, pc, mapPreambleWrapped) {
21163
21340
  for (const slot of plan) {
21164
21341
  const varName = `__ra_${varSlotId(slot.slotId)}`;
21165
21342
  lines.push(`${indent}{ const ${varName} = qsa(__branchScope, '[bf="${slot.slotId}"]')`);
21343
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
21166
21344
  lines.push(`${indent}if (${varName}) {`);
21345
+ let ordinal = 0;
21167
21346
  for (const attr of slot.attrs) {
21168
21347
  lines.push(`${indent} __disposers.push(createDisposableEffect(() => {`);
21169
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta)) {
21348
+ if (attr.readsPreamble && mapPreambleWrapped) {
21349
+ lines.push(`${indent} ${mapPreambleWrapped}`);
21350
+ }
21351
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta, ordinal++)) {
21170
21352
  lines.push(`${indent} ${stmt}`);
21171
21353
  }
21172
21354
  lines.push(`${indent} }${profileBindingId(pc, slot.slotId)}))`);
@@ -21209,7 +21391,7 @@ function stringifyBranchInnerLoops(lines, plan, indent, pc) {
21209
21391
  lines.push(`${indent} __bel${uid}.setAttribute('${keyAttrName(inner.keyDepth)}', String(${inner.wrappedKey}))`);
21210
21392
  }
21211
21393
  if (inner.legacyComponents.length > 0 || inner.legacyEvents.length > 0) {
21212
- emitComponentAndEventSetup(lines, `${indent} `, `__bel${uid}`, [...inner.legacyComponents], [...inner.legacyEvents], inner.outerLoopParam, inner.outerLoopParamBindings);
21394
+ emitComponentAndEventSetup(lines, `${indent} `, `__bel${uid}`, [...inner.legacyComponents], [...inner.legacyEvents], inner.outerLoopParam, inner.outerLoopParamBindings, false, inner.outerLoopIndex);
21213
21395
  }
21214
21396
  const conditionalTexts = inner.reactiveTexts.filter((t) => t.insideConditional);
21215
21397
  const plainTexts = inner.reactiveTexts.filter((t) => !t.insideConditional);
@@ -21226,32 +21408,35 @@ function stringifyBranchInnerLoops(lines, plan, indent, pc) {
21226
21408
  }
21227
21409
  }
21228
21410
  if (inner.nestedConditionals.length > 0) {
21229
- stringifyLoopChildConditionals(lines, inner.nestedConditionals, `${indent} `, pc);
21411
+ stringifyLoopChildConditionals(lines, inner.nestedConditionals, `${indent} `, pc, undefined);
21230
21412
  }
21231
21413
  lines.push(`${indent} return __bel${uid}`);
21232
21414
  lines.push(`${indent}}, '${inner.markerId}'${mapArrayKeyArgs(profileBindingId(pc, inner.slotId), !!inner.wrappedKey, inner.keyDepth)}) }`);
21233
21415
  }
21234
21416
  }
21235
- function stringifyLoopChildConditionals(lines, conditionals, indent, pc) {
21417
+ function stringifyLoopChildConditionals(lines, conditionals, indent, pc, mapPreambleWrapped) {
21236
21418
  for (const cond of conditionals) {
21237
- stringifyLoopChildConditional(lines, cond, indent, pc);
21419
+ stringifyLoopChildConditional(lines, cond, indent, pc, mapPreambleWrapped);
21238
21420
  }
21239
21421
  }
21240
- function stringifyLoopChildConditional(lines, cond, indent, pc) {
21422
+ function conditionGetterExpr(wrappedCondition, readsPreamble, mapPreambleWrapped) {
21423
+ return readsPreamble && mapPreambleWrapped ? `() => { ${mapPreambleWrapped}; return (${wrappedCondition}) }` : `() => ${wrappedCondition}`;
21424
+ }
21425
+ function stringifyLoopChildConditional(lines, cond, indent, pc, mapPreambleWrapped) {
21241
21426
  const armIndent = `${indent} `;
21242
- lines.push(`${indent}insert(${cond.scopeVar}, '${cond.slotId}', () => ${cond.wrappedCondition}, {`);
21427
+ lines.push(`${indent}insert(${cond.scopeVar}, '${cond.slotId}', ${conditionGetterExpr(cond.wrappedCondition, cond.readsPreamble, mapPreambleWrapped)}, {`);
21243
21428
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenTrueTemplateHtml}\`, slots: __slots } },`);
21244
21429
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
21245
- stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc);
21430
+ stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc, mapPreambleWrapped);
21246
21431
  lines.push(`${indent} }`);
21247
21432
  lines.push(`${indent}}, {`);
21248
21433
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenFalseTemplateHtml}\`, slots: __slots } },`);
21249
21434
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
21250
- stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc);
21435
+ stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc, mapPreambleWrapped);
21251
21436
  lines.push(`${indent} }`);
21252
21437
  lines.push(`${indent}}${profileBindingId(pc, cond.slotId)})`);
21253
21438
  }
21254
- function stringifyLoopChildArm(lines, arm, armIndent, pc) {
21439
+ function stringifyLoopChildArm(lines, arm, armIndent, pc, mapPreambleWrapped) {
21255
21440
  stringifyBranchEventBindings(lines, arm.events, armIndent);
21256
21441
  stringifyBranchChildComponentInits(lines, arm.childComponents, armIndent);
21257
21442
  stringifyBranchInnerLoops(lines, arm.innerLoops, armIndent, pc);
@@ -21259,10 +21444,10 @@ function stringifyLoopChildArm(lines, arm, armIndent, pc) {
21259
21444
  if (!hasDisposables)
21260
21445
  return;
21261
21446
  lines.push(`${armIndent}const __disposers = []`);
21262
- stringifyBranchReactiveAttrs(lines, arm.attrs, armIndent, pc);
21447
+ stringifyBranchReactiveAttrs(lines, arm.attrs, armIndent, pc, mapPreambleWrapped);
21263
21448
  for (const cond of arm.nestedConditionals) {
21264
21449
  lines.push(`${armIndent}__disposers.push(createDisposableEffect(() => {`);
21265
- stringifyLoopChildConditional(lines, cond, `${armIndent} `, pc);
21450
+ stringifyLoopChildConditional(lines, cond, `${armIndent} `, pc, mapPreambleWrapped);
21266
21451
  lines.push(`${armIndent}}))`);
21267
21452
  }
21268
21453
  if (arm.texts.length > 0) {
@@ -21301,13 +21486,15 @@ function emitAttrSlotsGranular(lines, indent, elVar, lookup, attrSlots, elementI
21301
21486
  const varName = `__ra_${varSlotId(slot.slotId)}`;
21302
21487
  const lookupExpr = attrLookupExpr(slot.slotId, varName, elVar, lookup, elementIndexBySlot);
21303
21488
  lines.push(`${indent}{ const ${varName} = ${lookupExpr}`);
21489
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
21304
21490
  lines.push(`${indent}if (${varName}) {`);
21491
+ let ordinal = 0;
21305
21492
  for (const attr of slot.attrs) {
21306
21493
  lines.push(`${indent} createEffect(() => {`);
21307
21494
  if (attr.readsPreamble && mapPreambleWrapped) {
21308
21495
  lines.push(`${indent} ${mapPreambleWrapped}`);
21309
21496
  }
21310
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta)) {
21497
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta, ordinal++)) {
21311
21498
  lines.push(`${indent} ${stmt}`);
21312
21499
  }
21313
21500
  lines.push(`${indent} }${bindingBfId(slot.slotId)})`);
@@ -21343,6 +21530,8 @@ function emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, oute
21343
21530
  const varName = `__ra_${varSlotId(slot.slotId)}`;
21344
21531
  lines.push(`${indent}const ${varName} = ${attrLookupExpr(slot.slotId, varName, elVar, lookup, elementIndexBySlot)}`);
21345
21532
  }
21533
+ if (attrSlots.length > 0)
21534
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
21346
21535
  const claimSlots = [
21347
21536
  ...outerTexts.map((t) => ({ id: t.slotId, kind: "text", path: [], pathExpr: textClaimPathExprs?.get(t.slotId) })),
21348
21537
  ...preambleRegions.map((r) => ({ id: r.slotId, kind: "markup", path: [] }))
@@ -21360,15 +21549,14 @@ function emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, oute
21360
21549
  if (mapPreambleWrapped && (preambleRegions.length > 0 || attrsReadPreamble(attrSlots))) {
21361
21550
  lines.push(`${indent} ${mapPreambleWrapped}`);
21362
21551
  }
21552
+ let ordinal = 0;
21363
21553
  for (const slot of attrSlots) {
21364
21554
  const varName = `__ra_${varSlotId(slot.slotId)}`;
21365
21555
  lines.push(`${indent} if (${varName}) {`);
21366
21556
  for (const attr of slot.attrs) {
21367
- lines.push(`${indent} {`);
21368
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta)) {
21369
- lines.push(`${indent} ${stmt}`);
21557
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta, ordinal++)) {
21558
+ lines.push(`${indent} ${stmt}`);
21370
21559
  }
21371
- lines.push(`${indent} }`);
21372
21560
  }
21373
21561
  lines.push(`${indent} }`);
21374
21562
  }
@@ -21397,16 +21585,16 @@ function emitOuterTexts(lines, indent, elVar, texts, bindingBfId, textClaimPathE
21397
21585
  }
21398
21586
  function emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped) {
21399
21587
  const armIndent = `${indent} `;
21400
- const conditionGetter = cond.readsPreamble && mapPreambleWrapped ? `() => { ${mapPreambleWrapped}; return (${cond.wrappedCondition}) }` : `() => ${cond.wrappedCondition}`;
21588
+ const conditionGetter = conditionGetterExpr(cond.wrappedCondition, cond.readsPreamble, mapPreambleWrapped);
21401
21589
  lines.push(`${indent}insert(${elVar}, '${cond.slotId}', ${conditionGetter}, {`);
21402
21590
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenTrueTemplateHtml}\`, slots: __slots } },`);
21403
21591
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
21404
- stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc);
21592
+ stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc, mapPreambleWrapped);
21405
21593
  lines.push(`${indent} }`);
21406
21594
  lines.push(`${indent}}, {`);
21407
21595
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenFalseTemplateHtml}\`, slots: __slots } },`);
21408
21596
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
21409
- stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc);
21597
+ stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc, mapPreambleWrapped);
21410
21598
  lines.push(`${indent} }`);
21411
21599
  lines.push(`${indent}}${profileBindingId(pc, cond.slotId)})`);
21412
21600
  }
@@ -21549,6 +21737,8 @@ function stringifyLazyRowLoop(lines, o) {
21549
21737
  lines.push(`${indent}${o.guardContainer ? `if (${o.containerVar}) ` : ""}${call}`);
21550
21738
  const b1 = `${indent} `;
21551
21739
  const b2 = `${indent} `;
21740
+ if (lazyRow.readsIndex)
21741
+ lines.push(`${b1}indexDriven: true,`);
21552
21742
  lines.push(`${b1}createRow: (__e, ${o.indexParam}) => {`);
21553
21743
  lines.push(`${b2}const ${paramHead} = () => __e.item`);
21554
21744
  if (lazyRow.preambleStatements)
@@ -21578,6 +21768,8 @@ function stringifyLazyRowLoop(lines, o) {
21578
21768
  } else {
21579
21769
  lines.push(`${b1}applyItem: (__e) => {`);
21580
21770
  lines.push(`${b2}const ${paramHead} = () => __e.item`);
21771
+ if (lazyRow.readsIndex)
21772
+ lines.push(`${b2}const ${o.indexParam} = __e.index`);
21581
21773
  lines.push(`${b2}const __r = __e.refs ?? (__e.refs = [])`);
21582
21774
  lines.push(`${b2}const __l = __e.last ?? (__e.last = [])`);
21583
21775
  if (lazyRow.itemNeedsPreamble && lazyRow.preambleStatements) {
@@ -21604,6 +21796,8 @@ function stringifyLazyRowLoop(lines, o) {
21604
21796
  lines.push(`${b2}${g}()`);
21605
21797
  lines.push(`${b2}for (const __e of __es) {`);
21606
21798
  lines.push(`${b3}const ${paramHead} = () => __e.item`);
21799
+ if (lazyRow.readsIndex)
21800
+ lines.push(`${b3}const ${o.indexParam} = __e.index`);
21607
21801
  lines.push(`${b3}const __r = __e.refs ?? (__e.refs = [])`);
21608
21802
  lines.push(`${b3}const __l = __e.last ?? (__e.last = [])`);
21609
21803
  if (lazyRow.outerNeedsPreamble && lazyRow.preambleStatements) {
@@ -21669,24 +21863,14 @@ function emitConditional(lines, ind, mid, c, mode) {
21669
21863
  lines.push(`${ind} __l[${c.ordinal}] = __x`);
21670
21864
  lines.push(`${ind}} }`);
21671
21865
  }
21672
- function dedupGuard(ordinal) {
21673
- return `!(${ordinal} in __l) || !Object.is(__l[${ordinal}], __x)`;
21674
- }
21675
21866
  function emitAttrBinding(lines, ind, a, mode) {
21676
21867
  const target = mode === "create" ? `__r[${a.refIndex}]` : elementAccess(a);
21868
+ const guard = mode === "create" ? null : mode === "item" ? dedupGuard(a.ordinal) : `__seed ? (${seedDiffersExpr("__t", a)}) : (${dedupGuard(a.ordinal)})`;
21677
21869
  lines.push(`${ind}{ const __t = ${target}`);
21678
21870
  lines.push(`${ind}if (__t) {`);
21679
- lines.push(`${ind} const __x = ${a.wrappedExpression}`);
21680
- const guard = mode === "create" ? null : mode === "item" ? dedupGuard(a.ordinal) : `__seed ? (${seedDiffersExpr("__t", a)}) : (${dedupGuard(a.ordinal)})`;
21681
- const writeIndent = guard ? `${ind} ` : `${ind} `;
21682
- if (guard)
21683
- lines.push(`${ind} if (${guard}) {`);
21684
- for (const stmt of emitAttrUpdate("__t", a.attrName, "__x", a.meta)) {
21685
- lines.push(`${writeIndent}${stmt}`);
21686
- }
21687
- if (guard)
21688
- lines.push(`${ind} }`);
21689
- lines.push(`${ind} __l[${a.ordinal}] = __x`);
21871
+ for (const stmt of emitDedupedAttrUpdate("__t", a.attrName, a.wrappedExpression, a.meta, a.ordinal, guard)) {
21872
+ lines.push(`${ind} ${stmt}`);
21873
+ }
21690
21874
  lines.push(`${ind}} }`);
21691
21875
  }
21692
21876
  function emitTextBinding(lines, ind, t, doorExpr, mode, rwDoor) {
@@ -21976,13 +22160,16 @@ function stringifyStaticLoop(lines, plan) {
21976
22160
  lines.push(` }`);
21977
22161
  }
21978
22162
  lines.push(` if (__iterEl) {`);
22163
+ if (attrsBySlot.length > 0)
22164
+ lines.push(` ${DEDUP_STORE_DECL}`);
22165
+ let ordinal = 0;
21979
22166
  for (const [slotId, attrs] of attrsBySlot) {
21980
22167
  const varName = `__t_${varSlotId(slotId)}`;
21981
22168
  lines.push(` const ${varName} = qsa(__iterEl, '[bf="${slotId}"]')`);
21982
22169
  lines.push(` if (${varName}) {`);
21983
22170
  for (const attr of attrs) {
21984
22171
  lines.push(` createEffect(() => {`);
21985
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.expression, attr)) {
22172
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.expression, attr, ordinal++)) {
21986
22173
  lines.push(` ${stmt}`);
21987
22174
  }
21988
22175
  lines.push(` }${profileBindingId(pc, slotId)})`);
@@ -22007,18 +22194,12 @@ function stringifyStaticLoop(lines, plan) {
22007
22194
  // src/ir-to-client-js/control-flow/stringify/inner-loop.ts
22008
22195
  function stringifyInnerLoops(lines, plan, indent, pc) {
22009
22196
  for (const inner of plan) {
22010
- if (inner.emit.mode === "reactive") {
22011
- emitReactive(lines, inner, indent, pc);
22012
- } else {
22013
- emitStatic(lines, inner, indent, pc);
22014
- }
22197
+ emitReactive(lines, inner, indent, pc);
22015
22198
  }
22016
22199
  }
22017
22200
  function emitReactive(lines, inner, indent, pc) {
22018
22201
  const uid = inner.uidSuffix;
22019
22202
  const emit = inner.emit;
22020
- if (emit.mode !== "reactive")
22021
- return;
22022
22203
  lines.push(`${indent}// Reactive inner loop: ${inner.arraySrc}`);
22023
22204
  lines.push(`${indent}{ const __ic${uid} = ${inner.containerExpr}`);
22024
22205
  lines.push(`${indent}if (__ic${uid}) mapArray(() => ${inner.arrayExpr} || [], __ic${uid}, ${emit.keyFn}, (${emit.paramHead}, __innerIdx${uid}, __existing) => {`);
@@ -22044,7 +22225,7 @@ function emitReactive(lines, inner, indent, pc) {
22044
22225
  lines.push(`${indent} __innerEl${uid}.setAttribute('${keyAttrName(inner.keyDepth)}', String(${emit.wrappedKey}))`);
22045
22226
  }
22046
22227
  if (emit.components.length > 0 || emit.events.length > 0) {
22047
- emitComponentAndEventSetup(lines, `${indent} `, `__innerEl${uid}`, [...emit.components], [...emit.events], inner.outerLoopParam, inner.outerLoopParamBindings);
22228
+ emitComponentAndEventSetup(lines, `${indent} `, `__innerEl${uid}`, [...emit.components], [...emit.events], inner.outerLoopParam, inner.outerLoopParamBindings, false, inner.outerLoopIndex);
22048
22229
  }
22049
22230
  if (inner.childLevels.length > 0) {
22050
22231
  stringifyInnerLoops(lines, inner.childLevels, `${indent} `, pc);
@@ -22063,17 +22244,20 @@ function emitReactive(lines, inner, indent, pc) {
22063
22244
  lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}', String(${text.wrappedExpression})) }${profileBindingId(pc, text.slotId)})`);
22064
22245
  }
22065
22246
  }
22247
+ if (emit.reactiveAttrs.length > 0)
22248
+ lines.push(`${indent} ${DEDUP_STORE_DECL}`);
22249
+ let attrOrdinal = 0;
22066
22250
  for (const attr of emit.reactiveAttrs) {
22067
22251
  const targetVar = `__ta_${attr.slotId.replace(/[^a-zA-Z0-9]/g, "_")}`;
22068
22252
  lines.push(`${indent} { const ${targetVar} = qsa(__innerEl${uid}, '[bf="${attr.slotId}"]')`);
22069
22253
  lines.push(`${indent} if (${targetVar}) createEffect(() => {`);
22070
- for (const stmt of emitAttrUpdate(targetVar, attr.attrName, attr.wrappedExpression, attr.meta)) {
22254
+ for (const stmt of emitDedupedAttrUpdate(targetVar, attr.attrName, attr.wrappedExpression, attr.meta, attrOrdinal++)) {
22071
22255
  lines.push(`${indent} ${stmt}`);
22072
22256
  }
22073
22257
  lines.push(`${indent} }${profileBindingId(pc, attr.slotId)}) }`);
22074
22258
  }
22075
22259
  if (emit.conditionals.length > 0) {
22076
- stringifyLoopChildConditionals(lines, emit.conditionals, `${indent} `, pc);
22260
+ stringifyLoopChildConditionals(lines, emit.conditionals, `${indent} `, pc, undefined);
22077
22261
  }
22078
22262
  emitLoopChildRefs(lines, emit.childRefs, {
22079
22263
  indent: `${indent} `,
@@ -22083,33 +22267,6 @@ function emitReactive(lines, inner, indent, pc) {
22083
22267
  lines.push(`${indent} return __innerEl${uid}`);
22084
22268
  lines.push(`${indent}}, '${inner.markerId}'${mapArrayKeyArgs(profileBindingId(pc, inner.slotId), !!emit.wrappedKey, inner.keyDepth)}) }`);
22085
22269
  }
22086
- function emitStatic(lines, inner, indent, pc) {
22087
- const uid = inner.uidSuffix;
22088
- const emit = inner.emit;
22089
- if (emit.mode !== "static")
22090
- return;
22091
- lines.push(`${indent}// Initialize ${inner.arraySrc} loop components and events`);
22092
- lines.push(`${indent}{ const __ic${uid} = ${inner.containerExpr}`);
22093
- lines.push(`${indent}if (__ic${uid} && ${inner.arrayExpr}) ${inner.arrayExpr}.forEach((${inner.param}, __innerIdx${uid}) => {`);
22094
- lines.push(`${indent} const __innerEl${uid} = __ic${uid}.children[__innerIdx${uid}]`);
22095
- lines.push(`${indent} if (!__innerEl${uid}) return`);
22096
- for (const stmt of emit.preludeStatements) {
22097
- lines.push(`${indent} ${stmt}`);
22098
- }
22099
- if (emit.rawKey) {
22100
- lines.push(`${indent} __innerEl${uid}.setAttribute('${keyAttrName(inner.keyDepth)}', String(${emit.rawKey}))`);
22101
- }
22102
- emitComponentAndEventSetup(lines, `${indent} `, `__innerEl${uid}`, [...emit.components], [...emit.events], inner.outerLoopParam, inner.outerLoopParamBindings);
22103
- if (inner.childLevels.length > 0) {
22104
- stringifyInnerLoops(lines, inner.childLevels, `${indent} `, pc);
22105
- }
22106
- emitLoopChildRefs(lines, emit.childRefs, {
22107
- indent: `${indent} `,
22108
- elVar: `__innerEl${uid}`,
22109
- bodyIsMultiRoot: false
22110
- });
22111
- lines.push(`${indent}}) }`);
22112
- }
22113
22270
 
22114
22271
  // src/ir-to-client-js/control-flow/stringify/composite-loop.ts
22115
22272
  function stringifyCompositeLoop(lines, plan) {
@@ -22128,6 +22285,7 @@ function stringifyCompositeLoop(lines, plan) {
22128
22285
  innerLoops,
22129
22286
  loopParam,
22130
22287
  loopParamBindings,
22288
+ loopIndex,
22131
22289
  reactiveEffects,
22132
22290
  childRefs,
22133
22291
  branchClearChildren,
@@ -22160,7 +22318,7 @@ function stringifyCompositeLoop(lines, plan) {
22160
22318
  singleRootLayout: "multiline",
22161
22319
  mountRow: true
22162
22320
  });
22163
- emitComponentAndEventSetup(lines, bodyIndent, "__el", compsArr, eventsArr, loopParam, loopParamBindings, bodyIsMultiRoot);
22321
+ emitComponentAndEventSetup(lines, bodyIndent, "__el", compsArr, eventsArr, loopParam, loopParamBindings, bodyIsMultiRoot, loopIndex);
22164
22322
  if (innerLoops.length > 0) {
22165
22323
  stringifyInnerLoops(lines, innerLoops, bodyIndent, pc);
22166
22324
  }
@@ -22537,10 +22695,12 @@ function emitArmBody(lines, body, mode, indent, profileComponentName) {
22537
22695
  const v = varSlotId(slotId);
22538
22696
  const elVar = `__ra_${v}`;
22539
22697
  lines.push(`${indent}{ const ${elVar} = qsa(__branchScope, '[bf="${slotId}"]')`);
22698
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
22540
22699
  lines.push(`${indent}if (${elVar}) {`);
22700
+ let ordinal = 0;
22541
22701
  for (const attr of attrs) {
22542
22702
  lines.push(`${indent} __disposers.push(createDisposableEffect(() => {`);
22543
- for (const stmt of emitAttrUpdate(elVar, attr.attrName, attr.expression, attr)) {
22703
+ for (const stmt of emitDedupedAttrUpdate(elVar, attr.attrName, attr.expression, attr, ordinal++)) {
22544
22704
  lines.push(`${indent} ${stmt}`);
22545
22705
  }
22546
22706
  lines.push(`${indent} }${bindingBfId(slotId)}))`);
@@ -22582,11 +22742,11 @@ function scopeRefToVar(ref) {
22582
22742
  // src/ir-to-client-js/control-flow/plan/build-component-loop.ts
22583
22743
  function buildComponentLoopPlan(elem, profileComponentName) {
22584
22744
  const { name } = elem.childComponent;
22585
- const propsExpr = buildComponentPropsExpr2(elem.childComponent, elem.param);
22586
- const keyExpr = wrapLoopParamAsAccessor(elem.key || "__idx", elem.param, elem.paramBindings);
22745
+ const propsExpr = buildComponentPropsExpr2(elem.childComponent, elem.param, undefined, elem.index);
22746
+ const keyExpr = wrapLoopParamAsAccessor(elem.key || "__idx", elem.param, elem.paramBindings, elem.index);
22587
22747
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(elem.param, elem.paramBindings);
22588
22748
  const mapPreambleWrapped = elem.preamble ? renderPreamble(elem.preamble, {
22589
- transformJs: (text) => wrapLoopParamAsAccessor(text, elem.param, elem.paramBindings),
22749
+ transformJs: (text) => wrapLoopParamAsAccessor(text, elem.param, elem.paramBindings, elem.index),
22590
22750
  renderLeaf: () => {
22591
22751
  internalInvariant(false, "component-root loop received a JSX-bearing preamble — Phase 1 should have refused it");
22592
22752
  }
@@ -22596,12 +22756,12 @@ function buildComponentLoopPlan(elem, profileComponentName) {
22596
22756
  const isTextOnly = comp.children?.length ? comp.children.every((c) => c.type === "expression" || c.type === "text" || isTextOnlyConditional(c)) : false;
22597
22757
  const rawChildrenExpr = isTextOnly ? irChildrenToJsExpr(comp.children) : null;
22598
22758
  const childrenFreeIds = isTextOnly && comp.children ? irChildrenFreeIds(comp.children) : undefined;
22599
- const childrenRefsLoop = rawChildrenExpr != null && childrenFreeIds != null && childrenFreeIds.has(elem.param);
22759
+ const childrenRefsLoop = rawChildrenExpr != null && childrenFreeIds != null && (childrenFreeIds.has(elem.param) || !!elem.index && childrenFreeIds.has(elem.index));
22600
22760
  return {
22601
22761
  componentName: comp.name,
22602
22762
  selector: buildCompSelector(comp),
22603
- propsExpr: buildComponentPropsExpr2(comp, elem.param),
22604
- childrenTextEffect: childrenRefsLoop ? { wrappedChildren: wrapLoopParamAsAccessor(rawChildrenExpr, elem.param, elem.paramBindings) } : null
22763
+ propsExpr: buildComponentPropsExpr2(comp, elem.param, undefined, elem.index),
22764
+ childrenTextEffect: childrenRefsLoop ? { wrappedChildren: wrapLoopParamAsAccessor(rawChildrenExpr, elem.param, elem.paramBindings, elem.index) } : null
22605
22765
  };
22606
22766
  });
22607
22767
  const hasChildConds = elem.bindings.conditionals.length > 0;
@@ -22620,7 +22780,7 @@ function buildComponentLoopPlan(elem, profileComponentName) {
22620
22780
  componentPropsExpr: propsExpr,
22621
22781
  keyExpr,
22622
22782
  nestedComps,
22623
- childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings),
22783
+ childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings, elem.index),
22624
22784
  profileLoopId: profileComponentName ? `${profileComponentName}#binding:${elem.slotId}` : undefined,
22625
22785
  childConditionalEffects: hasChildConds ? buildReactiveEffectsPlan({
22626
22786
  attrs: [],
@@ -22628,6 +22788,7 @@ function buildComponentLoopPlan(elem, profileComponentName) {
22628
22788
  conditionals: elem.bindings.conditionals,
22629
22789
  loopParam: elem.param,
22630
22790
  loopParamBindings: elem.paramBindings,
22791
+ loopIndex: elem.index,
22631
22792
  profileComponentName
22632
22793
  }) : null
22633
22794
  };
@@ -22651,8 +22812,6 @@ function buildLoopPlan(elem, opts) {
22651
22812
  return buildPlainLoopPlan(elem, opts.profileComponentName, opts.lazyScope);
22652
22813
  }
22653
22814
  function buildPlainLoopPlan(elem, profileComponentName, lazyScope) {
22654
- const wrap = (expr) => wrapLoopParamAsAccessor(expr, elem.param, elem.paramBindings);
22655
- const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(elem.param, elem.paramBindings);
22656
22815
  const hasReactive2 = elem.bindings.reactiveAttrs.length > 0 || elem.bindings.reactiveTexts.length > 0 || elem.bindings.conditionals.length > 0;
22657
22816
  if (elem.flatMapClient) {
22658
22817
  return {
@@ -22678,12 +22837,15 @@ function buildPlainLoopPlan(elem, profileComponentName, lazyScope) {
22678
22837
  };
22679
22838
  }
22680
22839
  const arrayExpr = buildChainedArrayExpr(elem);
22681
- const indexParam = elem.index || "__idx";
22682
- const mapPreambleWrapped = elem.preamble ? renderPreamble(elem.preamble, {
22683
- transformJs: wrap,
22684
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: elem.param, bindings: elem.paramBindings }], undefined)
22685
- }) : "";
22686
- const preambleRegions = buildPreambleRegionPlans(elem.preambleRegions, elem.param, elem.paramBindings);
22840
+ const core = buildPlainRowCore({
22841
+ loop: elem,
22842
+ arrayExpr,
22843
+ callSite: "plain",
22844
+ flatMapLeafItem: false,
22845
+ anchored: elem.bodyIsItemConditional ?? false,
22846
+ scope: lazyScope
22847
+ });
22848
+ const { paramHead, paramUnwrap, indexParam, preambleRegions, lazyRow, wrapItem: wrap } = core;
22687
22849
  return {
22688
22850
  kind: "plain",
22689
22851
  rowConstruction: "string-template",
@@ -22695,28 +22857,17 @@ function buildPlainLoopPlan(elem, profileComponentName, lazyScope) {
22695
22857
  paramHead,
22696
22858
  paramUnwrap,
22697
22859
  indexParam,
22698
- lazyRow: buildLazyRowPlan({
22699
- loop: elem,
22700
- arrayExpr,
22701
- indexParam,
22702
- paramUnwrap,
22703
- mapPreambleWrapped,
22704
- preambleRegionCount: preambleRegions.length,
22705
- callSite: "plain",
22706
- flatMapLeafItem: false,
22707
- anchored: elem.bodyIsItemConditional ?? false,
22708
- scope: lazyScope
22709
- }) ?? undefined,
22710
- mapPreambleWrapped,
22711
- template: elem.template,
22860
+ lazyRow,
22861
+ mapPreambleWrapped: core.mapPreambleWrapped,
22862
+ template: core.template,
22712
22863
  skeletonTemplate: elem.skeletonTemplate,
22713
22864
  skeletonPaths: elem.skeletonPaths,
22714
22865
  reactiveEffects: hasReactive2 ? buildLoopReactiveEffectsPlan(elem, profileComponentName) : null,
22715
- childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings),
22866
+ childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings, elem.index),
22716
22867
  preambleRegions,
22717
22868
  bodyIsMultiRoot: elem.bodyIsMultiRoot ?? false,
22718
22869
  anchored: elem.bodyIsItemConditional ?? false,
22719
- anchorKeyExpr: elem.key ? wrap(elem.key) : elem.index || "__idx"
22870
+ anchorKeyExpr: elem.key ? wrap(elem.key) : `${indexParam}()`
22720
22871
  };
22721
22872
  }
22722
22873
  function buildStaticLoopPlan(elem, unsafeLocalNames, profileComponentName) {
@@ -22758,7 +22909,7 @@ function buildStaticLoopMaterialize(elem, unsafeLocalNames) {
22758
22909
  return {
22759
22910
  itemTemplate: elem.staticItemTemplate,
22760
22911
  mapPreamble: elem.preamble ? renderPreamble(elem.preamble, {
22761
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: elem.param, bindings: elem.paramBindings }], undefined)
22912
+ renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: elem.param, bindings: elem.paramBindings, index: elem.index }], undefined)
22762
22913
  }) : "",
22763
22914
  bodyIsMultiRoot: elem.bodyIsMultiRoot ?? false
22764
22915
  };
@@ -23335,7 +23486,7 @@ function generateTemplateOnlyMount(ir, ctx) {
23335
23486
  const restSpreadNames = resolveRestSpreadNames(ctx);
23336
23487
  let templateHtml;
23337
23488
  if (canGenerateStaticTemplate(ir.root, propNamesForStaticCheck, inlinableConstants, unsafeLocalNames)) {
23338
- const markupSlotIds = new Set(ctx.dynamicElements.map((e) => e.slotId));
23489
+ const markupSlotIds = markupSlotIdsOf(ctx);
23339
23490
  templateHtml = irToComponentTemplate(ir.root, inlinableConstants, restSpreadNames, ctx.propsObjectName, markupSlotIds, ctx.restPropsName);
23340
23491
  }
23341
23492
  if (!templateHtml) {
@@ -24072,6 +24223,21 @@ function extractSsrDefaults(metadata) {
24072
24223
  }
24073
24224
  bindings[memo.name] = value;
24074
24225
  }
24226
+ {
24227
+ const getterNames = collectAliasableGetterNames(metadata.signals, metadata.memos);
24228
+ for (const [alias, origin] of resolveGetterAliases(metadata.localConstants ?? [], (n) => getterNames.has(n))) {
24229
+ if (alias in out)
24230
+ continue;
24231
+ out[alias] = out[origin];
24232
+ }
24233
+ }
24234
+ for (const [local, callerKey] of resolveBodyDestructuredPropAliases(metadata.localConstants ?? [], metadata.propsObjectName)) {
24235
+ if (local in out)
24236
+ continue;
24237
+ const origin = out[callerKey];
24238
+ if (origin)
24239
+ out[local] = origin;
24240
+ }
24075
24241
  if (metadata.propsObjectName !== null) {
24076
24242
  const referenced = new Set;
24077
24243
  for (const sig of metadata.signals) {
@@ -29750,7 +29916,9 @@ export {
29750
29916
  rewriteDynamicImportsInSource,
29751
29917
  resolveStaticLoopSource,
29752
29918
  resolveSetters,
29919
+ resolveGetterAliases,
29753
29920
  resolveDangerousInnerHtml,
29921
+ resolveBodyDestructuredPropAliases,
29754
29922
  resetCompilerCounters,
29755
29923
  registerLoweringPlugin,
29756
29924
  registerBuiltinLoweringPlugins,
@@ -29863,6 +30031,7 @@ export {
29863
30031
  collectModuleStringConsts,
29864
30032
  collectLoopBoundNames,
29865
30033
  collectContextConsumers,
30034
+ collectAliasableGetterNames,
29866
30035
  buildWhyUpdate,
29867
30036
  buildStaticBudget,
29868
30037
  buildSourceMapFromIR,