@barefootjs/vite 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 (2) hide show
  1. package/dist/index.js +1069 -903
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { relative as relative2, resolve as resolve7, sep as sep3 } from "node:pa
6
6
  import ts25 from "typescript";
7
7
 
8
8
  // ../jsx/src/analyzer.ts
9
- import ts10 from "typescript";
9
+ import ts11 from "typescript";
10
10
 
11
11
  // ../jsx/src/expression-parser.ts
12
12
  import ts from "typescript";
@@ -2473,12 +2473,22 @@ function renderLoopBindingAccess(b, base) {
2473
2473
  }
2474
2474
  return parent;
2475
2475
  }
2476
- function wrapLoopParamAsAccessor(expr, paramName, bindings) {
2476
+ function wrapLoopParamAsAccessor(expr, paramName, bindings, indexParam) {
2477
+ let result;
2477
2478
  if (bindings && bindings.length > 0) {
2478
- return rewriteLoopBindingRefs(expr, bindings, "__bfItem()");
2479
+ result = rewriteLoopBindingRefs(expr, bindings, "__bfItem()");
2480
+ } else {
2481
+ const re = new RegExp(`${ID_BOUNDARY_BEFORE}${escapeIdentifierForRegex(paramName)}(?!\\s*\\()(?!-)${ID_BOUNDARY_AFTER}`, "gu");
2482
+ result = replaceInExprContexts(expr, re, () => `${paramName}()`);
2479
2483
  }
2480
- const re = new RegExp(`${ID_BOUNDARY_BEFORE}${escapeIdentifierForRegex(paramName)}(?!\\s*\\()(?!-)${ID_BOUNDARY_AFTER}`, "gu");
2481
- return replaceInExprContexts(expr, re, () => `${paramName}()`);
2484
+ if (indexParam && indexParam !== paramName) {
2485
+ result = wrapIndexParamAsAccessor(result, indexParam);
2486
+ }
2487
+ return result;
2488
+ }
2489
+ function wrapIndexParamAsAccessor(expr, indexParam) {
2490
+ const re = new RegExp(`${ID_BOUNDARY_BEFORE}${escapeIdentifierForRegex(indexParam)}(?!\\s*\\()(?!-)${ID_BOUNDARY_AFTER}`, "gu");
2491
+ return replaceInExprContexts(expr, re, () => `${indexParam}()`);
2482
2492
  }
2483
2493
  function rewriteLoopBindingRefs(expr, bindings, accessor) {
2484
2494
  const byName = new Map;
@@ -2525,7 +2535,7 @@ function wrapExprWithLoopParams(expr, loopParams) {
2525
2535
  let result = expr;
2526
2536
  for (const p of loopParams) {
2527
2537
  const spec = typeof p === "string" ? { param: p } : p;
2528
- result = wrapLoopParamAsAccessor(result, spec.param, spec.bindings);
2538
+ result = wrapLoopParamAsAccessor(result, spec.param, spec.bindings, spec.index);
2529
2539
  }
2530
2540
  return result;
2531
2541
  }
@@ -2808,6 +2818,20 @@ function buildPropAliasMap(params) {
2808
2818
  }
2809
2819
  return map;
2810
2820
  }
2821
+ function resolveBodyDestructuredPropAliases(localConstants, propsObjectName) {
2822
+ const aliases = new Map;
2823
+ if (propsObjectName === null)
2824
+ return aliases;
2825
+ for (const c of localConstants) {
2826
+ if (c.isModule)
2827
+ continue;
2828
+ const m = c.parsed;
2829
+ if (m?.kind === "member" && !m.computed && m.object.kind === "identifier" && m.object.name === propsObjectName) {
2830
+ aliases.set(c.name, m.property);
2831
+ }
2832
+ }
2833
+ return aliases;
2834
+ }
2811
2835
  function boundPropLocalNames(b) {
2812
2836
  if (b.propsObjectName !== null)
2813
2837
  return EMPTY_SET;
@@ -3040,6 +3064,18 @@ function resolveGetterAliases(localConstants, isGetter) {
3040
3064
  }
3041
3065
  return aliases;
3042
3066
  }
3067
+ function collectAliasableGetterNames(signals, memos) {
3068
+ const getterNames = new Set;
3069
+ for (const sig of signals) {
3070
+ if (sig.getter && !sig.isModule && !sig.envReader)
3071
+ getterNames.add(sig.getter);
3072
+ }
3073
+ for (const memo of memos) {
3074
+ if (!memo.isModule)
3075
+ getterNames.add(memo.name);
3076
+ }
3077
+ return getterNames;
3078
+ }
3043
3079
  function buildSignalMemoEnv(signals, memos, propsObjectName, localConstants = []) {
3044
3080
  const substitutions = new Map;
3045
3081
  for (const s of signals) {
@@ -3216,6 +3252,65 @@ class BindingScope {
3216
3252
  }
3217
3253
  }
3218
3254
 
3255
+ // ../jsx/src/ir-to-client-js/safe-html.ts
3256
+ function safeHtml(expr) {
3257
+ return expr;
3258
+ }
3259
+ function interp(span) {
3260
+ return `\${${span}}`;
3261
+ }
3262
+ function escapedText(expr) {
3263
+ return safeHtml(`escapeText(${expr})`);
3264
+ }
3265
+ function escapedTextOrMarkup(expr) {
3266
+ return safeHtml(`escapeTextOrMarkup(${expr})`);
3267
+ }
3268
+ function branchSlotValue(expr, slotsVar) {
3269
+ return safeHtml(`__bfSlot(${expr}, ${slotsVar})`);
3270
+ }
3271
+ function childrenMarkup(expr) {
3272
+ return safeHtml(`markupOrEmpty(${expr})`);
3273
+ }
3274
+ function joinedMarkup(expr) {
3275
+ return safeHtml(`Array.isArray(${expr}) ? ${expr}.join('') : (${expr} ?? '')`);
3276
+ }
3277
+ function renderChildCall(registryName, propsExpr, tailArgs) {
3278
+ return safeHtml(`renderChild('${registryName}', ${propsExpr}${tailArgs})`);
3279
+ }
3280
+ function dangerousInnerHtml(expr) {
3281
+ return safeHtml(`((${expr}) ?? {}).__html ?? ''`);
3282
+ }
3283
+ function conditionalMarkup(condition, whenTrue, whenFalse) {
3284
+ return safeHtml(`${condition} ? \`${whenTrue}\` : \`${whenFalse}\``);
3285
+ }
3286
+ function mappedRowsMarkup(arrayExpr, method, params, body) {
3287
+ return safeHtml(`${arrayExpr}.${method}(${params} => ${body}).join('')`);
3288
+ }
3289
+ var EMPTY_MARKUP = safeHtml("''");
3290
+ function isChildrenPassthroughExpr(expr) {
3291
+ return /^([A-Za-z_$][\w$]*\.)?children$/.test(expr.trim());
3292
+ }
3293
+ function spliceChildValue(node, valueExpr, cx) {
3294
+ if (node.joinArrayChild)
3295
+ return joinedMarkup(valueExpr);
3296
+ if (cx.branchSlotsVar)
3297
+ return branchSlotValue(valueExpr, cx.branchSlotsVar);
3298
+ if (node.slotId) {
3299
+ return cx.markupSlotIds?.has(node.slotId) ? escapedTextOrMarkup(valueExpr) : escapedText(valueExpr);
3300
+ }
3301
+ const resolved = valueExpr.trim().replace(/^\(+|\)+$/g, "");
3302
+ if (isChildrenPassthroughExpr(node.expr) || isChildrenPassthroughExpr(resolved)) {
3303
+ return childrenMarkup(valueExpr);
3304
+ }
3305
+ return escapedText(valueExpr);
3306
+ }
3307
+
3308
+ // ../jsx/src/ir-to-client-js/markup-slots.ts
3309
+ var DYNAMIC_ELEMENT_WRITER_KIND = "markup";
3310
+ function markupSlotIdsOf(ctx) {
3311
+ return new Set(ctx.dynamicElements.map((e) => e.slotId));
3312
+ }
3313
+
3219
3314
  // ../jsx/src/ir-to-client-js/html-template.ts
3220
3315
  function createStringProtector() {
3221
3316
  const strings = [];
@@ -3385,22 +3480,11 @@ function templateAttrExpr(attrName, valExpr, presenceOrUndefined) {
3385
3480
  function escapeAttrValueExpr(valExpr) {
3386
3481
  return `escapeAttr(${valExpr})`;
3387
3482
  }
3388
- function escapeTextSlotExpr(innerExpr, isMarkup = false) {
3389
- return `${isMarkup ? "escapeTextOrMarkup" : "escapeText"}(${innerExpr})`;
3390
- }
3391
- function isChildrenPassthroughExpr(expr) {
3392
- return /^([A-Za-z_$][\w$]*\.)?children$/.test(expr.trim());
3393
- }
3394
- function bareSpliceExpr(node, valueExpr) {
3395
- const resolved = valueExpr.trim().replace(/^\(+|\)+$/g, "");
3396
- const isChildren = isChildrenPassthroughExpr(node.expr) || isChildrenPassthroughExpr(resolved);
3397
- return !node.joinArrayChild && isChildren ? `markupOrEmpty(${valueExpr})` : valueExpr;
3398
- }
3399
3483
  function dangerouslyHtmlChildren(attrs, toExpr) {
3400
3484
  const attr = attrs.find((a) => a.name === "dangerouslySetInnerHTML");
3401
3485
  if (!attr || attr.value.kind !== "expression")
3402
3486
  return null;
3403
- return `\${((${toExpr(attr.value)}) ?? {}).__html ?? ''}`;
3487
+ return interp(dangerousInnerHtml(toExpr(attr.value)));
3404
3488
  }
3405
3489
  function transformKeyValue(value, transformExpr) {
3406
3490
  switch (value.kind) {
@@ -3516,7 +3600,7 @@ function buildSpreadAttrsMergeCall(args) {
3516
3600
  return `\${spreadAttrs({${objMembers.join(", ")}})}`;
3517
3601
  }
3518
3602
  function itemAnchorTemplate(keyExpr) {
3519
- return `<!--${loopItemMarker("${" + keyExpr + "}")}-->`;
3603
+ return `<!--${loopItemMarker("${escapeCommentText(" + keyExpr + ")}")}-->`;
3520
3604
  }
3521
3605
  function renderPreamble(preamble, opts) {
3522
3606
  let out = "";
@@ -3525,9 +3609,9 @@ function renderPreamble(preamble, opts) {
3525
3609
  const text = opts.textVariant === "template" ? seg.templateText ?? seg.text : seg.text;
3526
3610
  out += opts.transformJs ? opts.transformJs(text) : text;
3527
3611
  } else if (opts.rawLeaf) {
3528
- out += opts.renderLeaf(escapeLeafTextExpressions(seg.ir));
3612
+ out += opts.renderLeaf(seg.ir);
3529
3613
  } else {
3530
- out += "`" + opts.renderLeaf(escapeLeafTextExpressions(seg.ir)) + "`";
3614
+ out += "`" + opts.renderLeaf(seg.ir) + "`";
3531
3615
  }
3532
3616
  }
3533
3617
  return out;
@@ -3572,36 +3656,12 @@ function renderFlatMapProjectionClientBody(inner, restSpreadNames) {
3572
3656
  const chained = applyLoopChain(inner);
3573
3657
  const params = inner.index ? `(${inner.param}, ${inner.index})` : `(${inner.param})`;
3574
3658
  const key = inner.key ? `(${inner.key})` : "undefined";
3575
- const html = inner.children.map((c) => irToHtmlTemplate(escapeLeafTextExpressions(c), restSpreadNames, 1, undefined, undefined)).join("");
3659
+ const html = inner.children.map((c) => irToHtmlTemplate(c, restSpreadNames, 1, undefined, undefined)).join("");
3576
3660
  return `${chained}.map(${params} => ({ k: ${key}, h: \`${html}\` }))`;
3577
3661
  }
3578
- function escapeLeafTextExpressions(ir) {
3579
- switch (ir.type) {
3580
- case "element":
3581
- return { ...ir, children: ir.children.map(escapeLeafTextExpressions) };
3582
- case "fragment":
3583
- return { ...ir, children: ir.children.map(escapeLeafTextExpressions) };
3584
- case "expression": {
3585
- if (ir.expr === "null" || ir.expr === "undefined")
3586
- return ir;
3587
- if (ir.slotId || ir.expr.trimStart().startsWith("escapeText("))
3588
- return ir;
3589
- return { ...ir, expr: `escapeText((${ir.expr}))`, templateExpr: ir.templateExpr ? `escapeText((${ir.templateExpr}))` : ir.templateExpr };
3590
- }
3591
- case "conditional":
3592
- return {
3593
- ...ir,
3594
- whenTrue: escapeLeafTextExpressions(ir.whenTrue),
3595
- whenFalse: ir.whenFalse ? escapeLeafTextExpressions(ir.whenFalse) : ir.whenFalse
3596
- };
3597
- default:
3598
- return ir;
3599
- }
3600
- }
3601
3662
  function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, branchSlotsVar, inHoistedChildren = false) {
3602
3663
  const recurse = (n) => irToHtmlTemplate(n, restSpreadNames, loopDepth, loopParams, branchSlotsVar, inHoistedChildren);
3603
3664
  const wrapExpr = (expr) => wrapExprWithLoopParams(expr, loopParams);
3604
- const wrapInterpolation = (expr) => branchSlotsVar ? `__bfSlot(${expr}, ${branchSlotsVar})` : expr;
3605
3665
  switch (node.type) {
3606
3666
  case "element": {
3607
3667
  const mergeCtx = {
@@ -3647,25 +3707,17 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3647
3707
  case "expression": {
3648
3708
  if (node.expr === "null" || node.expr === "undefined")
3649
3709
  return "";
3650
- const escapeForClient = (e) => node.escapeInClientTemplate ? `escapeText(${e})` : e;
3651
- if (node.markerless) {
3652
- const bare = escapeForClient(wrapInterpolation(wrapExpr(node.expr)));
3653
- return `\${${bare}}`;
3654
- }
3655
- const inner = escapeForClient(wrapInterpolation(wrapExpr(node.expr)));
3656
- const valueExpr = node.joinArrayChild ? `Array.isArray(${inner}) ? ${inner}.join('') : (${inner} ?? '')` : inner;
3657
- if (node.slotId) {
3658
- const slotted = branchSlotsVar || node.joinArrayChild ? valueExpr : escapeTextSlotExpr(valueExpr);
3659
- return `<!--bf:${node.slotId}-->\${${slotted}}<!--/-->`;
3660
- }
3661
- return `\${${bareSpliceExpr(node, valueExpr)}}`;
3710
+ const hole = interp(spliceChildValue(node, wrapExpr(node.expr), { branchSlotsVar }));
3711
+ if (node.markerless)
3712
+ return hole;
3713
+ return node.slotId ? `<!--bf:${node.slotId}-->${hole}<!--/-->` : hole;
3662
3714
  }
3663
3715
  case "conditional": {
3664
3716
  const trueBranch = recurse(node.whenTrue);
3665
3717
  const falseBranch = recurse(node.whenFalse);
3666
3718
  const trueHtml = node.slotId ? addCondAttrToTemplate(trueBranch, node.slotId) : trueBranch;
3667
3719
  const falseHtml = node.slotId ? addCondAttrToTemplate(falseBranch, node.slotId) : falseBranch;
3668
- return `\${${wrapExpr(node.condition)} ? \`${trueHtml}\` : \`${falseHtml}\`}`;
3720
+ return interp(conditionalMarkup(wrapExpr(node.condition), trueHtml, falseHtml));
3669
3721
  }
3670
3722
  case "fragment":
3671
3723
  return node.children.map(recurse).join("");
@@ -3691,7 +3743,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3691
3743
  case "expression":
3692
3744
  case "template":
3693
3745
  case "spread": {
3694
- const expr = attrValueToString(p.value, { useTemplate: true }) ?? "undefined";
3746
+ const expr = wrapExpr(attrValueToString(p.value, { useTemplate: true }) ?? "undefined");
3695
3747
  return `${quotePropName(p.name)}: ${expr}`;
3696
3748
  }
3697
3749
  }
@@ -3702,7 +3754,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3702
3754
  const propsExpr = propsEntries.length > 0 ? `{${propsEntries.join(", ")}}` : "{}";
3703
3755
  const keyProp = node.props.find((p) => p.name === "key");
3704
3756
  const keyArg = keyProp ? `, ${attrValueToString(keyProp.value) ?? "undefined"}` : "";
3705
- return `\${renderChild('${nameForRegistryRef(node.name)}', ${propsExpr}${renderChildScopeArgs(node, keyArg)})}`;
3757
+ return interp(renderChildCall(nameForRegistryRef(node.name), propsExpr, renderChildScopeArgs(node, keyArg)));
3706
3758
  }
3707
3759
  case "loop": {
3708
3760
  const innerRecurse = (n) => irToHtmlTemplate(n, restSpreadNames, loopDepth + 1, loopParams, branchSlotsVar);
@@ -3720,12 +3772,12 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3720
3772
  const body = renderPreamble(node.flatMapCallback, {
3721
3773
  renderLeaf: (ir) => irToHtmlTemplate(stripLeafKeyAttr(ir), restSpreadNames, loopDepth + 1, loopParams, branchSlotsVar)
3722
3774
  });
3723
- mapExpr = `\${${wrappedArray}.flatMap(${node.flatMapCallback.params} => ${body}).join('')}`;
3775
+ mapExpr = interp(mappedRowsMarkup(wrappedArray, "flatMap", node.flatMapCallback.params, body));
3724
3776
  } else if (node.preamble) {
3725
3777
  const preamble = renderPreamble(node.preamble, { textVariant: "client", renderLeaf: (ir) => irToHtmlTemplate(ir, restSpreadNames, loopDepth + 1, loopParams, branchSlotsVar) });
3726
- mapExpr = `\${${wrappedArray}.${iterMethod}(${callbackParam} => { ${preamble} return \`${childTemplate}\` }).join('')}`;
3778
+ mapExpr = interp(mappedRowsMarkup(wrappedArray, iterMethod, callbackParam, `{ ${preamble} return \`${childTemplate}\` }`));
3727
3779
  } else {
3728
- mapExpr = `\${${wrappedArray}.${iterMethod}(${callbackParam} => \`${childTemplate}\`).join('')}`;
3780
+ mapExpr = interp(mappedRowsMarkup(wrappedArray, iterMethod, callbackParam, `\`${childTemplate}\``));
3729
3781
  }
3730
3782
  return `<!--${loopStartMarker(node.markerId)}-->${mapExpr}<!--${loopEndMarker(node.markerId)}-->`;
3731
3783
  }
@@ -3984,20 +4036,15 @@ function irToPlaceholderTemplate(node, restSpreadNames, loopDepth = 0, loopParam
3984
4036
  case "expression": {
3985
4037
  if (node.expr === "null" || node.expr === "undefined")
3986
4038
  return "";
3987
- const wrapped = wrapExpr(node.expr);
3988
- const value = node.joinArrayChild ? `Array.isArray(${wrapped}) ? ${wrapped}.join('') : (${wrapped} ?? '')` : wrapped;
3989
- if (node.slotId) {
3990
- return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(wrapped)}}<!--/-->`;
3991
- }
3992
- const spliced = bareSpliceExpr(node, value);
3993
- return `\${${node.escapeInClientTemplate ? `escapeText(${spliced})` : spliced}}`;
4039
+ const hole = interp(spliceChildValue(node, wrapExpr(node.expr), {}));
4040
+ return node.slotId ? `<!--bf:${node.slotId}-->${hole}<!--/-->` : hole;
3994
4041
  }
3995
4042
  case "conditional": {
3996
4043
  const trueBranch = recurse(node.whenTrue);
3997
4044
  const falseBranch = recurse(node.whenFalse);
3998
4045
  const trueHtml = node.slotId ? addCondAttrToTemplate(trueBranch, node.slotId) : trueBranch;
3999
4046
  const falseHtml = node.slotId ? addCondAttrToTemplate(falseBranch, node.slotId) : falseBranch;
4000
- return `\${${wrapExpr(node.condition)} ? \`${trueHtml}\` : \`${falseHtml}\`}`;
4047
+ return interp(conditionalMarkup(wrapExpr(node.condition), trueHtml, falseHtml));
4001
4048
  }
4002
4049
  case "fragment":
4003
4050
  return node.children.map(recurse).join("");
@@ -4021,12 +4068,12 @@ function irToPlaceholderTemplate(node, restSpreadNames, loopDepth = 0, loopParam
4021
4068
  const body = renderPreamble(node.flatMapCallback, {
4022
4069
  renderLeaf: (ir) => irToPlaceholderTemplate(stripLeafKeyAttr(ir), restSpreadNames, loopDepth + 1, loopParams)
4023
4070
  });
4024
- mapExpr = `\${${wrappedArray}.flatMap(${node.flatMapCallback.params} => ${body}).join('')}`;
4071
+ mapExpr = interp(mappedRowsMarkup(wrappedArray, "flatMap", node.flatMapCallback.params, body));
4025
4072
  } else if (node.preamble) {
4026
4073
  const preamble = renderPreamble(node.preamble, { textVariant: "client", renderLeaf: (ir) => irToPlaceholderTemplate(ir, restSpreadNames, loopDepth + 1, loopParams) });
4027
- mapExpr = `\${${wrappedArray}.${iterMethod}(${callbackParam} => { ${preamble} return \`${childTemplate}\` }).join('')}`;
4074
+ mapExpr = interp(mappedRowsMarkup(wrappedArray, iterMethod, callbackParam, `{ ${preamble} return \`${childTemplate}\` }`));
4028
4075
  } else {
4029
- mapExpr = `\${${wrappedArray}.${iterMethod}(${callbackParam} => \`${childTemplate}\`).join('')}`;
4076
+ mapExpr = interp(mappedRowsMarkup(wrappedArray, iterMethod, callbackParam, `\`${childTemplate}\``));
4030
4077
  }
4031
4078
  return `<!--${loopStartMarker(node.markerId)}-->${mapExpr}<!--${loopEndMarker(node.markerId)}-->`;
4032
4079
  }
@@ -4228,13 +4275,8 @@ function irToComponentTemplateWithOpts(node, opts) {
4228
4275
  return "";
4229
4276
  return `<!--bf:${node.slotId}--><!--/-->`;
4230
4277
  }
4231
- const wrapped = transformExpr(node.expr, node.templateExpr);
4232
- const value = node.joinArrayChild ? `Array.isArray(${wrapped}) ? ${wrapped}.join('') : (${wrapped} ?? '')` : wrapped;
4233
- if (node.slotId) {
4234
- const isMarkup = opts.markupSlotIds?.has(node.slotId) ?? false;
4235
- return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(wrapped, isMarkup)}}<!--/-->`;
4236
- }
4237
- return `\${${bareSpliceExpr(node, value)}}`;
4278
+ const hole = interp(spliceChildValue(node, transformExpr(node.expr, node.templateExpr), { markupSlotIds: opts.markupSlotIds }));
4279
+ return node.slotId ? `<!--bf:${node.slotId}-->${hole}<!--/-->` : hole;
4238
4280
  }
4239
4281
  case "conditional": {
4240
4282
  if (node.clientOnly && node.slotId) {
@@ -4244,7 +4286,7 @@ function irToComponentTemplateWithOpts(node, opts) {
4244
4286
  const falseBranch = recurse(node.whenFalse);
4245
4287
  const trueHtml = node.slotId ? addCondAttrToTemplate(trueBranch, node.slotId) : trueBranch;
4246
4288
  const falseHtml = node.slotId ? addCondAttrToTemplate(falseBranch, node.slotId) : falseBranch;
4247
- return `\${${transformExpr(node.condition, node.templateCondition)} ? \`${trueHtml}\` : \`${falseHtml}\`}`;
4289
+ return interp(conditionalMarkup(transformExpr(node.condition, node.templateCondition), trueHtml, falseHtml));
4248
4290
  }
4249
4291
  case "fragment":
4250
4292
  return node.children.map(recurse).join("");
@@ -4282,7 +4324,7 @@ function irToComponentTemplateWithOpts(node, opts) {
4282
4324
  const propsExpr = propsEntries.length > 0 ? `{${propsEntries.join(", ")}}` : "{}";
4283
4325
  const keyProp = node.props.find((p) => p.name === "key");
4284
4326
  const keyArg = keyProp ? `, ${transformKeyValue(keyProp.value, transformExpr)}` : "";
4285
- return `\${renderChild('${nameForRegistryRef(node.name)}', ${propsExpr}${keyArg})}`;
4327
+ return interp(renderChildCall(nameForRegistryRef(node.name), propsExpr, keyArg));
4286
4328
  }
4287
4329
  case "loop": {
4288
4330
  const innerOpts = { ...opts, loopDepth: loopDepth + 1 };
@@ -4292,7 +4334,7 @@ function irToComponentTemplateWithOpts(node, opts) {
4292
4334
  case "if-statement": {
4293
4335
  const consequent = recurse(node.consequent);
4294
4336
  const alternate = node.alternate ? recurse(node.alternate) : "";
4295
- return `\${${transformExpr(node.condition, node.templateCondition)} ? \`${consequent}\` : \`${alternate}\`}`;
4337
+ return interp(conditionalMarkup(transformExpr(node.condition, node.templateCondition), consequent, alternate));
4296
4338
  }
4297
4339
  case "provider":
4298
4340
  case "async":
@@ -4380,7 +4422,7 @@ function generateCsrTemplate(node, inlinableConstants, ctx, restSpreadNames, pro
4380
4422
  }
4381
4423
  }
4382
4424
  const effectiveUnsafeLocalNames = mergeCsrNullUnsafe(ctx, unsafeLocalNames);
4383
- const markupSlotIds = new Set(ctx.dynamicElements.map((e) => e.slotId));
4425
+ const markupSlotIds = markupSlotIdsOf(ctx);
4384
4426
  return generateCsrTemplateWithOpts(node, { inlinableConstants, restSpreadNames, propsObjectName, csrEnv, unsafeLocalNames: effectiveUnsafeLocalNames, deferredChildSlots, loopDepth: -1, markupSlotIds, restPropsName: ctx.restPropsName });
4385
4427
  }
4386
4428
  function mergeCsrNullUnsafe(ctx, unsafeLocalNames) {
@@ -4579,13 +4621,8 @@ function generateCsrTemplateWithOpts(node, opts) {
4579
4621
  }
4580
4622
  {
4581
4623
  const transformed = transformExpr(node.expr, node.templateExpr);
4582
- const expr = transformed === UNSAFE_TEMPLATE_EXPR ? "''" : transformed;
4583
- const value = node.joinArrayChild ? `Array.isArray(${expr}) ? ${expr}.join('') : (${expr} ?? '')` : expr;
4584
- if (node.slotId) {
4585
- const isMarkup = opts.markupSlotIds?.has(node.slotId) ?? false;
4586
- return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(expr, isMarkup)}}<!--/-->`;
4587
- }
4588
- return `\${${bareSpliceExpr(node, value)}}`;
4624
+ const hole = interp(transformed === UNSAFE_TEMPLATE_EXPR ? EMPTY_MARKUP : spliceChildValue(node, transformed, { markupSlotIds: opts.markupSlotIds }));
4625
+ return node.slotId ? `<!--bf:${node.slotId}-->${hole}<!--/-->` : hole;
4589
4626
  }
4590
4627
  case "conditional": {
4591
4628
  if (node.clientOnly && node.slotId) {
@@ -4595,7 +4632,7 @@ function generateCsrTemplateWithOpts(node, opts) {
4595
4632
  const falseBranch = recurse(node.whenFalse);
4596
4633
  const trueHtml = node.slotId ? addCondAttrToTemplate(trueBranch, node.slotId) : trueBranch;
4597
4634
  const falseHtml = node.slotId ? addCondAttrToTemplate(falseBranch, node.slotId) : falseBranch;
4598
- return `\${${transformExpr(node.condition, node.templateCondition)} ? \`${trueHtml}\` : \`${falseHtml}\`}`;
4635
+ return interp(conditionalMarkup(transformExpr(node.condition, node.templateCondition), trueHtml, falseHtml));
4599
4636
  }
4600
4637
  case "fragment":
4601
4638
  return node.children.map(recurse).join("");
@@ -4644,7 +4681,7 @@ function generateCsrTemplateWithOpts(node, opts) {
4644
4681
  const propsExpr = propsEntries.length > 0 ? `{${propsEntries.join(", ")}}` : "{}";
4645
4682
  const keyProp = node.props.find((p) => p.name === "key");
4646
4683
  const keyArg = keyProp ? `, ${transformKeyValue(keyProp.value, transformExpr)}` : "";
4647
- return `\${renderChild('${nameForRegistryRef(node.name)}', ${propsExpr}${renderChildScopeArgs(node, keyArg)})}`;
4684
+ return interp(renderChildCall(nameForRegistryRef(node.name), propsExpr, renderChildScopeArgs(node, keyArg)));
4648
4685
  }
4649
4686
  case "loop": {
4650
4687
  const childScope = (opts.scope ?? BindingScope.EMPTY).enterLoopRow(node);
@@ -4677,19 +4714,19 @@ function generateCsrTemplateWithOpts(node, opts) {
4677
4714
  transformJs: (t) => rewritePropsObjectRef(t, propsObjectName ?? null, restPropsName ?? null, { enclosingScope: childScope }),
4678
4715
  renderLeaf: (ir) => recurseInLoopBody(stripLeafKeyAttr(ir))
4679
4716
  });
4680
- mapExpr = `\${${iterArrayExpr}.flatMap(${node.flatMapCallback.params} => ${body}).join('')}`;
4717
+ mapExpr = interp(mappedRowsMarkup(iterArrayExpr, "flatMap", node.flatMapCallback.params, body));
4681
4718
  } else if (node.preamble) {
4682
4719
  const preamble = renderPreamble(node.preamble, { textVariant: "template", transformJs: (t) => rewritePropsObjectRef(t, propsObjectName ?? null, restPropsName ?? null, { enclosingScope: childScope }), renderLeaf: (ir) => recurseInLoopBody(ir) });
4683
- mapExpr = `\${${iterArrayExpr}.${iterMethod}(${callbackParam} => { ${preamble} return \`${childTemplate}\` }).join('')}`;
4720
+ mapExpr = interp(mappedRowsMarkup(iterArrayExpr, iterMethod, callbackParam, `{ ${preamble} return \`${childTemplate}\` }`));
4684
4721
  } else {
4685
- mapExpr = `\${${iterArrayExpr}.${iterMethod}(${callbackParam} => \`${childTemplate}\`).join('')}`;
4722
+ mapExpr = interp(mappedRowsMarkup(iterArrayExpr, iterMethod, callbackParam, `\`${childTemplate}\``));
4686
4723
  }
4687
4724
  return `<!--${loopStartMarker(node.markerId)}-->${mapExpr}<!--${loopEndMarker(node.markerId)}-->`;
4688
4725
  }
4689
4726
  case "if-statement": {
4690
4727
  const consequent = recurse(node.consequent);
4691
4728
  const alternate = node.alternate ? recurse(node.alternate) : "";
4692
- return `\${${transformExpr(node.condition, node.templateCondition)} ? \`${consequent}\` : \`${alternate}\`}`;
4729
+ return interp(conditionalMarkup(transformExpr(node.condition, node.templateCondition), consequent, alternate));
4693
4730
  }
4694
4731
  case "provider":
4695
4732
  case "async":
@@ -4790,8 +4827,6 @@ function collectAstPropRefs(node, propNames, out) {
4790
4827
  walkWithScope(node, (n, parent, shadowed) => {
4791
4828
  if (shadowed || !propNames.has(n.text))
4792
4829
  return;
4793
- if (parent && ts7.isShorthandPropertyAssignment(parent) && parent.name === n)
4794
- return;
4795
4830
  if (isNonValuePosition(n, parent))
4796
4831
  return;
4797
4832
  out.add(n.text);
@@ -4881,7 +4916,7 @@ function incrementCounter(key) {
4881
4916
  }
4882
4917
 
4883
4918
  // ../jsx/src/analyzer-context.ts
4884
- import ts9 from "typescript";
4919
+ import ts10 from "typescript";
4885
4920
 
4886
4921
  // ../jsx/src/strip-types.ts
4887
4922
  import ts8 from "typescript";
@@ -5098,6 +5133,140 @@ function findAngleBracketAfter(lastTypeArg, fullText) {
5098
5133
  return -1;
5099
5134
  }
5100
5135
 
5136
+ // ../jsx/src/reactivity-checker.ts
5137
+ import ts9 from "typescript";
5138
+ var REACTIVE_BRAND = "__reactive";
5139
+ function queryType(checker, node) {
5140
+ incrementCounter("typeCheckerQueries");
5141
+ return checker.getTypeAtLocation(node);
5142
+ }
5143
+ function isReactiveType(type) {
5144
+ return type.getProperty(REACTIVE_BRAND) !== undefined;
5145
+ }
5146
+ var NOT_REACTIVE = { isReactive: false, reason: { kind: "not-reactive" } };
5147
+ function safeGetText(node) {
5148
+ try {
5149
+ return node.getText();
5150
+ } catch {
5151
+ return "";
5152
+ }
5153
+ }
5154
+ function analyze(node, checker) {
5155
+ if (ts9.isPropertyAccessExpression(node)) {
5156
+ try {
5157
+ const type = queryType(checker, node);
5158
+ if (isReactiveType(type)) {
5159
+ return {
5160
+ isReactive: true,
5161
+ reason: { kind: "brand", via: "property-access", nodeText: safeGetText(node) }
5162
+ };
5163
+ }
5164
+ } catch {}
5165
+ const sub = analyze(node.expression, checker);
5166
+ if (sub.isReactive) {
5167
+ return {
5168
+ isReactive: true,
5169
+ reason: {
5170
+ kind: "child",
5171
+ via: "property-access-object",
5172
+ childText: safeGetText(node.expression),
5173
+ childReason: sub.reason
5174
+ }
5175
+ };
5176
+ }
5177
+ return NOT_REACTIVE;
5178
+ }
5179
+ if (ts9.isIdentifier(node)) {
5180
+ try {
5181
+ const type = queryType(checker, node);
5182
+ if (isReactiveType(type)) {
5183
+ return {
5184
+ isReactive: true,
5185
+ reason: { kind: "brand", via: "identifier", nodeText: safeGetText(node) }
5186
+ };
5187
+ }
5188
+ } catch {}
5189
+ return NOT_REACTIVE;
5190
+ }
5191
+ if (ts9.isCallExpression(node)) {
5192
+ try {
5193
+ const calleeType = queryType(checker, node.expression);
5194
+ if (isReactiveType(calleeType)) {
5195
+ return {
5196
+ isReactive: true,
5197
+ reason: { kind: "brand", via: "callee", nodeText: safeGetText(node) }
5198
+ };
5199
+ }
5200
+ } catch {}
5201
+ }
5202
+ let foundChild;
5203
+ let foundChildText = "";
5204
+ ts9.forEachChild(node, (child) => {
5205
+ if (foundChild?.isReactive)
5206
+ return;
5207
+ const result = analyze(child, checker);
5208
+ if (result.isReactive) {
5209
+ foundChild = result;
5210
+ foundChildText = safeGetText(child);
5211
+ }
5212
+ });
5213
+ if (foundChild?.isReactive) {
5214
+ return {
5215
+ isReactive: true,
5216
+ reason: {
5217
+ kind: "child",
5218
+ via: "sub-expression",
5219
+ childText: foundChildText,
5220
+ childReason: foundChild.reason
5221
+ }
5222
+ };
5223
+ }
5224
+ return NOT_REACTIVE;
5225
+ }
5226
+ var brandTypeReactivityAnalyzer = { analyze };
5227
+ function containsReactiveExpression(node, checker) {
5228
+ incrementCounter("reactivityChecks");
5229
+ return brandTypeReactivityAnalyzer.analyze(node, checker).isReactive;
5230
+ }
5231
+ function nodeContainsJsx(node) {
5232
+ if (ts9.isJsxElement(node) || ts9.isJsxSelfClosingElement(node) || ts9.isJsxFragment(node))
5233
+ return true;
5234
+ return ts9.forEachChild(node, nodeContainsJsx) ?? false;
5235
+ }
5236
+ function collectReactiveBrandLeaves(node, checker) {
5237
+ const leaves = [];
5238
+ const visit = (n) => {
5239
+ if (ts9.isPropertyAccessExpression(n)) {
5240
+ try {
5241
+ if (isReactiveType(queryType(checker, n))) {
5242
+ leaves.push(n);
5243
+ return;
5244
+ }
5245
+ } catch {}
5246
+ visit(n.expression);
5247
+ return;
5248
+ }
5249
+ if (ts9.isIdentifier(n)) {
5250
+ try {
5251
+ if (isReactiveType(queryType(checker, n)))
5252
+ leaves.push(n);
5253
+ } catch {}
5254
+ return;
5255
+ }
5256
+ if (ts9.isCallExpression(n)) {
5257
+ try {
5258
+ if (isReactiveType(queryType(checker, n.expression))) {
5259
+ leaves.push(nodeContainsJsx(n) ? n.expression : n);
5260
+ return;
5261
+ }
5262
+ } catch {}
5263
+ }
5264
+ ts9.forEachChild(n, visit);
5265
+ };
5266
+ visit(node);
5267
+ return leaves;
5268
+ }
5269
+
5101
5270
  // ../jsx/src/analyzer-context.ts
5102
5271
  function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
5103
5272
  return {
@@ -5149,7 +5318,7 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
5149
5318
  } catch {
5150
5319
  ownSourceFile = undefined;
5151
5320
  }
5152
- if (process.env.BF_ASSERT_NO_JSX_IN_GETJS === "1" && this.errors.length === 0 && nodeContainsJsx(node)) {
5321
+ if (process.env.BF_ASSERT_NO_JSX_IN_GETJS === "1" && !this.errors.some((e) => e.severity === "error") && nodeContainsJsx(node)) {
5153
5322
  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.");
5154
5323
  }
5155
5324
  if (ownSourceFile && ownSourceFile !== sourceFile) {
@@ -5159,11 +5328,6 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
5159
5328
  }
5160
5329
  };
5161
5330
  }
5162
- function nodeContainsJsx(node) {
5163
- if (ts9.isJsxElement(node) || ts9.isJsxSelfClosingElement(node) || ts9.isJsxFragment(node))
5164
- return true;
5165
- return ts9.forEachChild(node, nodeContainsJsx) ?? false;
5166
- }
5167
5331
  function getSourceLocation(node, sourceFile, filePath) {
5168
5332
  const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());
5169
5333
  const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());
@@ -5180,20 +5344,20 @@ function getSourceLocation(node, sourceFile, filePath) {
5180
5344
  };
5181
5345
  }
5182
5346
  function membersToProperties(members, sourceFile) {
5183
- return members.filter(ts9.isPropertySignature).map((member) => ({
5347
+ return members.filter(ts10.isPropertySignature).map((member) => ({
5184
5348
  name: propertyNameText(member.name, sourceFile),
5185
5349
  type: typeNodeToTypeInfo(member.type, sourceFile) ?? {
5186
5350
  kind: "unknown",
5187
5351
  raw: "unknown"
5188
5352
  },
5189
5353
  optional: !!member.questionToken,
5190
- readonly: !!member.modifiers?.some((m) => m.kind === ts9.SyntaxKind.ReadonlyKeyword)
5354
+ readonly: !!member.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ReadonlyKeyword)
5191
5355
  }));
5192
5356
  }
5193
5357
  function propertyNameText(name, sourceFile) {
5194
5358
  if (!name)
5195
5359
  return "";
5196
- if (ts9.isStringLiteral(name) || ts9.isNumericLiteral(name))
5360
+ if (ts10.isStringLiteral(name) || ts10.isNumericLiteral(name))
5197
5361
  return name.text;
5198
5362
  return name.getText(sourceFile);
5199
5363
  }
@@ -5204,56 +5368,56 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
5204
5368
  const raw = rawOf ? rawOf(typeNode) : typeNode.getText(sourceFile);
5205
5369
  const recurse = (n) => typeNodeToTypeInfo(n, sourceFile, rawOf) ?? { kind: "unknown", raw: "unknown" };
5206
5370
  switch (typeNode.kind) {
5207
- case ts9.SyntaxKind.StringKeyword:
5371
+ case ts10.SyntaxKind.StringKeyword:
5208
5372
  return { kind: "primitive", raw, primitive: "string" };
5209
- case ts9.SyntaxKind.NumberKeyword:
5373
+ case ts10.SyntaxKind.NumberKeyword:
5210
5374
  return { kind: "primitive", raw, primitive: "number" };
5211
- case ts9.SyntaxKind.BooleanKeyword:
5375
+ case ts10.SyntaxKind.BooleanKeyword:
5212
5376
  return { kind: "primitive", raw, primitive: "boolean" };
5213
- case ts9.SyntaxKind.NullKeyword:
5377
+ case ts10.SyntaxKind.NullKeyword:
5214
5378
  return { kind: "primitive", raw, primitive: "null" };
5215
- case ts9.SyntaxKind.UndefinedKeyword:
5379
+ case ts10.SyntaxKind.UndefinedKeyword:
5216
5380
  return { kind: "primitive", raw, primitive: "undefined" };
5217
5381
  }
5218
- if (ts9.isArrayTypeNode(typeNode)) {
5382
+ if (ts10.isArrayTypeNode(typeNode)) {
5219
5383
  return { kind: "array", raw, elementType: recurse(typeNode.elementType) };
5220
5384
  }
5221
- if (ts9.isLiteralTypeNode(typeNode)) {
5385
+ if (ts10.isLiteralTypeNode(typeNode)) {
5222
5386
  const lit = typeNode.literal;
5223
- if (ts9.isStringLiteral(lit) || ts9.isNoSubstitutionTemplateLiteral(lit)) {
5387
+ if (ts10.isStringLiteral(lit) || ts10.isNoSubstitutionTemplateLiteral(lit)) {
5224
5388
  return { kind: "primitive", raw, primitive: "string", literalValue: lit.text };
5225
5389
  }
5226
- if (ts9.isNumericLiteral(lit)) {
5390
+ if (ts10.isNumericLiteral(lit)) {
5227
5391
  return { kind: "primitive", raw, primitive: "number", literalValue: lit.text };
5228
5392
  }
5229
- if (ts9.isPrefixUnaryExpression(lit) && lit.operator === ts9.SyntaxKind.MinusToken && ts9.isNumericLiteral(lit.operand)) {
5393
+ if (ts10.isPrefixUnaryExpression(lit) && lit.operator === ts10.SyntaxKind.MinusToken && ts10.isNumericLiteral(lit.operand)) {
5230
5394
  return { kind: "primitive", raw, primitive: "number", literalValue: `-${lit.operand.text}` };
5231
5395
  }
5232
- if (lit.kind === ts9.SyntaxKind.TrueKeyword || lit.kind === ts9.SyntaxKind.FalseKeyword) {
5396
+ if (lit.kind === ts10.SyntaxKind.TrueKeyword || lit.kind === ts10.SyntaxKind.FalseKeyword) {
5233
5397
  return {
5234
5398
  kind: "primitive",
5235
5399
  raw,
5236
5400
  primitive: "boolean",
5237
- literalValue: lit.kind === ts9.SyntaxKind.TrueKeyword ? "true" : "false"
5401
+ literalValue: lit.kind === ts10.SyntaxKind.TrueKeyword ? "true" : "false"
5238
5402
  };
5239
5403
  }
5240
- if (lit.kind === ts9.SyntaxKind.NullKeyword) {
5404
+ if (lit.kind === ts10.SyntaxKind.NullKeyword) {
5241
5405
  return { kind: "primitive", raw, primitive: "null" };
5242
5406
  }
5243
5407
  return { kind: "unknown", raw };
5244
5408
  }
5245
- if (ts9.isUnionTypeNode(typeNode)) {
5409
+ if (ts10.isUnionTypeNode(typeNode)) {
5246
5410
  return { kind: "union", raw, unionTypes: typeNode.types.map(recurse) };
5247
5411
  }
5248
- if (ts9.isTypeLiteralNode(typeNode)) {
5412
+ if (ts10.isTypeLiteralNode(typeNode)) {
5249
5413
  return {
5250
5414
  kind: "object",
5251
5415
  raw,
5252
5416
  ...synthetic ? {} : { properties: membersToProperties(typeNode.members, sourceFile) }
5253
5417
  };
5254
5418
  }
5255
- if (ts9.isTypeReferenceNode(typeNode)) {
5256
- const refName = ts9.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : "";
5419
+ if (ts10.isTypeReferenceNode(typeNode)) {
5420
+ const refName = ts10.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : "";
5257
5421
  if ((refName === "Array" || refName === "ReadonlyArray") && typeNode.typeArguments?.length === 1) {
5258
5422
  return { kind: "array", raw, elementType: recurse(typeNode.typeArguments[0]) };
5259
5423
  }
@@ -5262,7 +5426,7 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
5262
5426
  raw
5263
5427
  };
5264
5428
  }
5265
- if (ts9.isFunctionTypeNode(typeNode)) {
5429
+ if (ts10.isFunctionTypeNode(typeNode)) {
5266
5430
  if (synthetic)
5267
5431
  return { kind: "function", raw };
5268
5432
  return {
@@ -5282,15 +5446,15 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
5282
5446
  }
5283
5447
  return { kind: "unknown", raw };
5284
5448
  }
5285
- var _typePrinter = ts9.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
5286
- var _blankTypeSourceFile = ts9.createSourceFile("__bf_types__.ts", "", ts9.ScriptTarget.Latest);
5449
+ var _typePrinter = ts10.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
5450
+ var _blankTypeSourceFile = ts10.createSourceFile("__bf_types__.ts", "", ts10.ScriptTarget.Latest);
5287
5451
  function tsTypeToTypeInfo(type, checker) {
5288
- const node = checker.typeToTypeNode(type, undefined, ts9.NodeBuilderFlags.NoTruncation);
5452
+ const node = checker.typeToTypeNode(type, undefined, ts10.NodeBuilderFlags.NoTruncation);
5289
5453
  if (!node)
5290
5454
  return null;
5291
5455
  const rawOf = (n) => {
5292
5456
  try {
5293
- return _typePrinter.printNode(ts9.EmitHint.Unspecified, n, _blankTypeSourceFile);
5457
+ return _typePrinter.printNode(ts10.EmitHint.Unspecified, n, _blankTypeSourceFile);
5294
5458
  } catch {
5295
5459
  return "unknown";
5296
5460
  }
@@ -5301,16 +5465,16 @@ function isPascalCase(name) {
5301
5465
  return /^[A-Z][a-zA-Z0-9]*$/.test(name);
5302
5466
  }
5303
5467
  function isComponentFunction(node) {
5304
- return ts9.isFunctionDeclaration(node) && !!node.name && isPascalCase(node.name.text) && !!node.body;
5468
+ return ts10.isFunctionDeclaration(node) && !!node.name && isPascalCase(node.name.text) && !!node.body;
5305
5469
  }
5306
5470
  function isArrowComponentFunction(node) {
5307
- if (!ts9.isVariableDeclaration(node))
5471
+ if (!ts10.isVariableDeclaration(node))
5308
5472
  return false;
5309
- if (!ts9.isIdentifier(node.name))
5473
+ if (!ts10.isIdentifier(node.name))
5310
5474
  return false;
5311
5475
  if (!isPascalCase(node.name.text))
5312
5476
  return false;
5313
- if (!node.initializer || !ts9.isArrowFunction(node.initializer))
5477
+ if (!node.initializer || !ts10.isArrowFunction(node.initializer))
5314
5478
  return false;
5315
5479
  return true;
5316
5480
  }
@@ -5637,9 +5801,9 @@ function needsTypeBasedDetection(source) {
5637
5801
  }
5638
5802
  function findBrandPackageImportLoc(sourceFile, filePath) {
5639
5803
  for (const stmt of sourceFile.statements) {
5640
- if (!ts10.isImportDeclaration(stmt))
5804
+ if (!ts11.isImportDeclaration(stmt))
5641
5805
  continue;
5642
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
5806
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
5643
5807
  continue;
5644
5808
  if (!REACTIVE_BRAND_PACKAGES.includes(stmt.moduleSpecifier.text))
5645
5809
  continue;
@@ -5658,21 +5822,21 @@ function createProgramForFile(source, filePath) {
5658
5822
  try {
5659
5823
  const normalizedPath = path2.resolve(filePath);
5660
5824
  const compilerOptions = {
5661
- target: ts10.ScriptTarget.Latest,
5662
- module: ts10.ModuleKind.ESNext,
5663
- moduleResolution: ts10.ModuleResolutionKind.Bundler,
5664
- jsx: ts10.JsxEmit.ReactJSX,
5825
+ target: ts11.ScriptTarget.Latest,
5826
+ module: ts11.ModuleKind.ESNext,
5827
+ moduleResolution: ts11.ModuleResolutionKind.Bundler,
5828
+ jsx: ts11.JsxEmit.ReactJSX,
5665
5829
  strict: true,
5666
5830
  skipLibCheck: true,
5667
5831
  noEmit: true,
5668
5832
  baseUrl: path2.dirname(normalizedPath)
5669
5833
  };
5670
- const defaultHost = ts10.createCompilerHost(compilerOptions);
5834
+ const defaultHost = ts11.createCompilerHost(compilerOptions);
5671
5835
  const virtualHost = {
5672
5836
  ...defaultHost,
5673
5837
  getSourceFile(fileName, languageVersion) {
5674
5838
  if (path2.resolve(fileName) === normalizedPath) {
5675
- return ts10.createSourceFile(fileName, source, languageVersion, true, ts10.ScriptKind.TSX);
5839
+ return ts11.createSourceFile(fileName, source, languageVersion, true, ts11.ScriptKind.TSX);
5676
5840
  }
5677
5841
  return defaultHost.getSourceFile(fileName, languageVersion);
5678
5842
  },
@@ -5687,7 +5851,7 @@ function createProgramForFile(source, filePath) {
5687
5851
  return defaultHost.readFile(fileName);
5688
5852
  }
5689
5853
  };
5690
- const program = ts10.createProgram([normalizedPath], compilerOptions, virtualHost);
5854
+ const program = ts11.createProgram([normalizedPath], compilerOptions, virtualHost);
5691
5855
  const sourceFile = program.getSourceFile(normalizedPath);
5692
5856
  if (!sourceFile)
5693
5857
  return null;
@@ -5720,7 +5884,7 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
5720
5884
  }
5721
5885
  }
5722
5886
  if (!sourceFile) {
5723
- sourceFile = ts10.createSourceFile(filePath, source, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
5887
+ sourceFile = ts11.createSourceFile(filePath, source, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
5724
5888
  }
5725
5889
  if (!checker && needsTypeBasedDetection(source)) {
5726
5890
  const result = createProgramForFile(source, filePath);
@@ -5766,23 +5930,23 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
5766
5930
  function findDefaultExportedComponent(sourceFile) {
5767
5931
  let defaultExportName;
5768
5932
  function findDefaultExport(node) {
5769
- if (ts10.isExportAssignment(node) && !node.isExportEquals) {
5770
- if (ts10.isIdentifier(node.expression)) {
5933
+ if (ts11.isExportAssignment(node) && !node.isExportEquals) {
5934
+ if (ts11.isIdentifier(node.expression)) {
5771
5935
  defaultExportName = node.expression.text;
5772
5936
  }
5773
5937
  }
5774
- if (ts10.isFunctionDeclaration(node) && node.name && node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DefaultKeyword)) {
5938
+ if (ts11.isFunctionDeclaration(node) && node.name && node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DefaultKeyword)) {
5775
5939
  defaultExportName = node.name.text;
5776
5940
  }
5777
- ts10.forEachChild(node, findDefaultExport);
5941
+ ts11.forEachChild(node, findDefaultExport);
5778
5942
  }
5779
- ts10.forEachChild(sourceFile, findDefaultExport);
5943
+ ts11.forEachChild(sourceFile, findDefaultExport);
5780
5944
  return defaultExportName;
5781
5945
  }
5782
5946
  function collectNamedExports(sourceFile) {
5783
5947
  const exported = new Set;
5784
5948
  for (const stmt of sourceFile.statements) {
5785
- if (ts10.isExportDeclaration(stmt) && stmt.exportClause && ts10.isNamedExports(stmt.exportClause)) {
5949
+ if (ts11.isExportDeclaration(stmt) && stmt.exportClause && ts11.isNamedExports(stmt.exportClause)) {
5786
5950
  for (const spec of stmt.exportClause.elements) {
5787
5951
  const local = (spec.propertyName ?? spec.name).text;
5788
5952
  exported.add(local);
@@ -5792,22 +5956,22 @@ function collectNamedExports(sourceFile) {
5792
5956
  return exported;
5793
5957
  }
5794
5958
  function visit(node, ctx, targetComponentName, namedExports) {
5795
- if (ts10.isExpressionStatement(node) && ts10.isStringLiteral(node.expression)) {
5959
+ if (ts11.isExpressionStatement(node) && ts11.isStringLiteral(node.expression)) {
5796
5960
  if (node.expression.text === "use client" || node.expression.text === "'use client'") {
5797
5961
  ctx.hasUseClientDirective = true;
5798
5962
  }
5799
5963
  }
5800
- if (ts10.isImportDeclaration(node)) {
5964
+ if (ts11.isImportDeclaration(node)) {
5801
5965
  collectImport(node, ctx);
5802
5966
  }
5803
- if (ts10.isInterfaceDeclaration(node)) {
5967
+ if (ts11.isInterfaceDeclaration(node)) {
5804
5968
  collectInterfaceDefinition(node, ctx);
5805
5969
  }
5806
- if (ts10.isTypeAliasDeclaration(node)) {
5970
+ if (ts11.isTypeAliasDeclaration(node)) {
5807
5971
  collectTypeAliasDefinition(node, ctx);
5808
5972
  }
5809
- if (!ctx.hasUseClientDirective && ts10.isFunctionDeclaration(node) && node.name && node.body && isMultiReturnJsxFunctionBody(node.body)) {
5810
- const hasInlineExport = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
5973
+ if (!ctx.hasUseClientDirective && ts11.isFunctionDeclaration(node) && node.name && node.body && isMultiReturnJsxFunctionBody(node.body)) {
5974
+ const hasInlineExport = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
5811
5975
  const hasNamedExport = namedExports?.has(node.name.text) ?? false;
5812
5976
  if (!hasInlineExport && !hasNamedExport) {
5813
5977
  collectFunction(node, ctx, true, false);
@@ -5822,9 +5986,9 @@ function visit(node, ctx, targetComponentName, namedExports) {
5822
5986
  if (!ctx.componentName) {
5823
5987
  ctx.componentName = node.name.text;
5824
5988
  ctx.componentNode = node;
5825
- ctx.isExported = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
5989
+ ctx.isExported = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
5826
5990
  analyzeComponentBody(node, ctx);
5827
- if (node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DefaultKeyword)) {
5991
+ if (node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DefaultKeyword)) {
5828
5992
  ctx.hasDefaultExport = true;
5829
5993
  }
5830
5994
  }
@@ -5838,10 +6002,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
5838
6002
  ctx.componentName = node.name.text;
5839
6003
  ctx.componentNode = node.initializer;
5840
6004
  const parentStatement = node.parent;
5841
- if (ts10.isVariableDeclarationList(parentStatement)) {
6005
+ if (ts11.isVariableDeclarationList(parentStatement)) {
5842
6006
  const varStatement = parentStatement.parent;
5843
- if (ts10.isVariableStatement(varStatement)) {
5844
- ctx.isExported = varStatement.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6007
+ if (ts11.isVariableStatement(varStatement)) {
6008
+ ctx.isExported = varStatement.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
5845
6009
  }
5846
6010
  }
5847
6011
  analyzeComponentBody(node.initializer, ctx);
@@ -5853,10 +6017,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
5853
6017
  if (!ctx.componentNode) {
5854
6018
  collectAmbientGlobals(node, ctx);
5855
6019
  }
5856
- const isDeclareStatement = ts10.isVariableStatement(node) && (node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DeclareKeyword) ?? false);
5857
- if (ts10.isVariableStatement(node) && !ctx.componentNode && !isDeclareStatement) {
5858
- const isExported = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
5859
- const isLet = (node.declarationList.flags & ts10.NodeFlags.Let) !== 0;
6020
+ const isDeclareStatement = ts11.isVariableStatement(node) && (node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DeclareKeyword) ?? false);
6021
+ if (ts11.isVariableStatement(node) && !ctx.componentNode && !isDeclareStatement) {
6022
+ const isExported = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6023
+ const isLet = (node.declarationList.flags & ts11.NodeFlags.Let) !== 0;
5860
6024
  const isModuleClientDirective = hasLeadingClientDirectiveOnStatement(node, ctx.sourceFile);
5861
6025
  for (const decl of node.declarationList.declarations) {
5862
6026
  if (declarationIsReactiveFactoryCall(decl, ctx)) {
@@ -5867,19 +6031,19 @@ function visit(node, ctx, targetComponentName, namedExports) {
5867
6031
  }
5868
6032
  continue;
5869
6033
  }
5870
- if (ts10.isIdentifier(decl.name) && (decl.initializer || isLet) && !isArrowComponentFunction(decl)) {
6034
+ if (ts11.isIdentifier(decl.name) && (decl.initializer || isLet) && !isArrowComponentFunction(decl)) {
5871
6035
  collectConstant(decl, ctx, true, isLet ? "let" : "const", isExported);
5872
6036
  }
5873
6037
  }
5874
6038
  }
5875
- if (ts10.isFunctionDeclaration(node) && node.name && !isComponentFunction(node)) {
5876
- const isExported = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6039
+ if (ts11.isFunctionDeclaration(node) && node.name && !isComponentFunction(node)) {
6040
+ const isExported = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
5877
6041
  collectFunction(node, ctx, true, isExported);
5878
6042
  return;
5879
6043
  }
5880
- if (ts10.isExportDeclaration(node) && node.exportClause && ts10.isNamedExports(node.exportClause)) {
6044
+ if (ts11.isExportDeclaration(node) && node.exportClause && ts11.isNamedExports(node.exportClause)) {
5881
6045
  const isFromReexport = !!node.moduleSpecifier;
5882
- const sourceSpec = node.moduleSpecifier && ts10.isStringLiteral(node.moduleSpecifier) ? node.moduleSpecifier.text : null;
6046
+ const sourceSpec = node.moduleSpecifier && ts11.isStringLiteral(node.moduleSpecifier) ? node.moduleSpecifier.text : null;
5883
6047
  const exportSpecifiers = node.exportClause.elements.map((spec) => ({
5884
6048
  name: (spec.propertyName ?? spec.name).text,
5885
6049
  alias: spec.propertyName ? spec.name.text : null,
@@ -5907,24 +6071,24 @@ function visit(node, ctx, targetComponentName, namedExports) {
5907
6071
  }
5908
6072
  }
5909
6073
  }
5910
- if (ts10.isExportAssignment(node) && !node.isExportEquals) {
6074
+ if (ts11.isExportAssignment(node) && !node.isExportEquals) {
5911
6075
  const expr = node.expression;
5912
- if (ts10.isIdentifier(expr)) {
6076
+ if (ts11.isIdentifier(expr)) {
5913
6077
  if (ctx.componentName && expr.text === ctx.componentName) {
5914
6078
  ctx.hasDefaultExport = true;
5915
6079
  ctx.isExported = true;
5916
6080
  }
5917
6081
  }
5918
6082
  }
5919
- ts10.forEachChild(node, (child) => visit(child, ctx, targetComponentName, namedExports));
6083
+ ts11.forEachChild(node, (child) => visit(child, ctx, targetComponentName, namedExports));
5920
6084
  }
5921
6085
  function analyzeComponentBody(node, ctx) {
5922
6086
  if (node.parameters.length > 0) {
5923
6087
  extractProps(node.parameters[0], ctx);
5924
6088
  }
5925
- const body = ts10.isFunctionDeclaration(node) ? node.body : getArrowFunctionBody(node);
6089
+ const body = ts11.isFunctionDeclaration(node) ? node.body : getArrowFunctionBody(node);
5926
6090
  if (body) {
5927
- ctx.componentBodyBlock = ts10.isBlock(body) ? body : null;
6091
+ ctx.componentBodyBlock = ts11.isBlock(body) ? body : null;
5928
6092
  if (!ctx.componentBodyBlock) {
5929
6093
  ctx.jsxReturn = unwrapJsxTransparent(body);
5930
6094
  }
@@ -5934,14 +6098,14 @@ function analyzeComponentBody(node, ctx) {
5934
6098
  }
5935
6099
  }
5936
6100
  function getArrowFunctionBody(node) {
5937
- if (ts10.isBlock(node.body)) {
6101
+ if (ts11.isBlock(node.body)) {
5938
6102
  return node.body;
5939
6103
  }
5940
6104
  return node.body;
5941
6105
  }
5942
6106
  function visitComponentBody(node, ctx) {
5943
6107
  const isTopLevel = ctx.componentBodyBlock !== null && node.parent === ctx.componentBodyBlock;
5944
- if (ts10.isVariableStatement(node)) {
6108
+ if (ts11.isVariableStatement(node)) {
5945
6109
  for (const decl of node.declarationList.declarations) {
5946
6110
  if (isSignalDeclaration(decl, ctx)) {
5947
6111
  collectSignal(decl, ctx);
@@ -5964,16 +6128,16 @@ function visitComponentBody(node, ctx) {
5964
6128
  collectEffect(decl.initializer, ctx, decl.name.text);
5965
6129
  continue;
5966
6130
  }
5967
- if (ts10.isIdentifier(decl.name)) {
5968
- const isLet = (node.declarationList.flags & ts10.NodeFlags.Let) !== 0;
6131
+ if (ts11.isIdentifier(decl.name)) {
6132
+ const isLet = (node.declarationList.flags & ts11.NodeFlags.Let) !== 0;
5969
6133
  collectConstant(decl, ctx, false, isLet ? "let" : "const");
5970
- } else if (ts10.isObjectBindingPattern(decl.name) && decl.initializer && ts10.isIdentifier(decl.initializer) && ctx.propsObjectName === decl.initializer.text) {
5971
- const isLet = (node.declarationList.flags & ts10.NodeFlags.Let) !== 0;
6134
+ } else if (ts11.isObjectBindingPattern(decl.name) && decl.initializer && ts11.isIdentifier(decl.initializer) && ctx.propsObjectName === decl.initializer.text) {
6135
+ const isLet = (node.declarationList.flags & ts11.NodeFlags.Let) !== 0;
5972
6136
  collectConstant(decl, ctx, false, isLet ? "let" : "const");
5973
6137
  }
5974
6138
  }
5975
6139
  }
5976
- if (ts10.isExpressionStatement(node)) {
6140
+ if (ts11.isExpressionStatement(node)) {
5977
6141
  if (isEffectCall(node.expression, ctx)) {
5978
6142
  collectEffect(node.expression, ctx);
5979
6143
  return;
@@ -5987,10 +6151,10 @@ function visitComponentBody(node, ctx) {
5987
6151
  return;
5988
6152
  }
5989
6153
  }
5990
- if (ts10.isFunctionDeclaration(node) && node.name) {
6154
+ if (ts11.isFunctionDeclaration(node) && node.name) {
5991
6155
  collectFunction(node, ctx, false);
5992
6156
  }
5993
- if (ts10.isIfStatement(node)) {
6157
+ if (ts11.isIfStatement(node)) {
5994
6158
  const jsxReturn = findJsxReturnInBlock(node.thenStatement);
5995
6159
  if (jsxReturn) {
5996
6160
  const scopeVars = collectScopeVariables(node.thenStatement, ctx);
@@ -6009,8 +6173,8 @@ function visitComponentBody(node, ctx) {
6009
6173
  return;
6010
6174
  }
6011
6175
  }
6012
- 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)) {
6013
- if (ts10.isBlock(node)) {
6176
+ 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)) {
6177
+ if (ts11.isBlock(node)) {
6014
6178
  const returnedLocal = findBlockBodyReturnedJsxLocalName(node);
6015
6179
  if (returnedLocal) {
6016
6180
  ctx.errors.push(createError(ErrorCodes.RETURN_VALUE_NOT_JSX, getSourceLocation(node, ctx.sourceFile, ctx.filePath), {
@@ -6021,34 +6185,34 @@ function visitComponentBody(node, ctx) {
6021
6185
  collectInitStatement(node, ctx);
6022
6186
  return;
6023
6187
  }
6024
- if (ts10.isReturnStatement(node) && node.expression) {
6188
+ if (ts11.isReturnStatement(node) && node.expression) {
6025
6189
  ctx.jsxReturn = unwrapJsxTransparent(node.expression);
6026
6190
  }
6027
- ts10.forEachChild(node, (child) => {
6028
- if (ts10.isArrowFunction(child) || ts10.isFunctionExpression(child) || ts10.isFunctionDeclaration(child)) {
6191
+ ts11.forEachChild(node, (child) => {
6192
+ if (ts11.isArrowFunction(child) || ts11.isFunctionExpression(child) || ts11.isFunctionDeclaration(child)) {
6029
6193
  return;
6030
6194
  }
6031
6195
  visitComponentBody(child, ctx);
6032
6196
  });
6033
6197
  }
6034
6198
  function findJsxReturnInBlock(node) {
6035
- if (ts10.isBlock(node)) {
6199
+ if (ts11.isBlock(node)) {
6036
6200
  for (const stmt of node.statements) {
6037
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
6201
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
6038
6202
  const jsx = extractJsxFromExpression(stmt.expression);
6039
6203
  if (jsx)
6040
6204
  return jsx;
6041
6205
  }
6042
6206
  }
6043
6207
  }
6044
- if (ts10.isReturnStatement(node) && node.expression) {
6208
+ if (ts11.isReturnStatement(node) && node.expression) {
6045
6209
  return extractJsxFromExpression(node.expression);
6046
6210
  }
6047
6211
  return null;
6048
6212
  }
6049
6213
  function unwrapJsxTransparent(expr) {
6050
6214
  let current = expr;
6051
- while (ts10.isParenthesizedExpression(current) || ts10.isAsExpression(current) || ts10.isSatisfiesExpression(current) || ts10.isNonNullExpression(current) || ts10.isTypeAssertionExpression(current) || current.kind === ts10.SyntaxKind.PartiallyEmittedExpression) {
6215
+ while (ts11.isParenthesizedExpression(current) || ts11.isAsExpression(current) || ts11.isSatisfiesExpression(current) || ts11.isNonNullExpression(current) || ts11.isTypeAssertionExpression(current) || current.kind === ts11.SyntaxKind.PartiallyEmittedExpression) {
6052
6216
  current = current.expression;
6053
6217
  }
6054
6218
  return current;
@@ -6056,22 +6220,22 @@ function unwrapJsxTransparent(expr) {
6056
6220
  function findBlockBodyReturnedJsxLocalName(block) {
6057
6221
  const stmts = block.statements;
6058
6222
  const last = stmts[stmts.length - 1];
6059
- if (!last || !ts10.isReturnStatement(last) || !last.expression)
6223
+ if (!last || !ts11.isReturnStatement(last) || !last.expression)
6060
6224
  return null;
6061
6225
  const returned = unwrapJsxTransparent(last.expression);
6062
- if (!ts10.isIdentifier(returned))
6226
+ if (!ts11.isIdentifier(returned))
6063
6227
  return null;
6064
6228
  const name = returned.text;
6065
6229
  for (const stmt of stmts) {
6066
- if (!ts10.isVariableStatement(stmt))
6230
+ if (!ts11.isVariableStatement(stmt))
6067
6231
  continue;
6068
6232
  for (const decl of stmt.declarationList.declarations) {
6069
- if (!ts10.isIdentifier(decl.name) || decl.name.text !== name || !decl.initializer)
6233
+ if (!ts11.isIdentifier(decl.name) || decl.name.text !== name || !decl.initializer)
6070
6234
  continue;
6071
6235
  let init = decl.initializer;
6072
- while (ts10.isParenthesizedExpression(init))
6236
+ while (ts11.isParenthesizedExpression(init))
6073
6237
  init = init.expression;
6074
- if (ts10.isJsxElement(init) || ts10.isJsxSelfClosingElement(init) || ts10.isJsxFragment(init) || initializerShapeContainsJsx(init) || isMapLikeCallWithJsx(init)) {
6238
+ if (ts11.isJsxElement(init) || ts11.isJsxSelfClosingElement(init) || ts11.isJsxFragment(init) || initializerShapeContainsJsx(init) || isMapLikeCallWithJsx(init)) {
6075
6239
  return name;
6076
6240
  }
6077
6241
  }
@@ -6080,16 +6244,16 @@ function findBlockBodyReturnedJsxLocalName(block) {
6080
6244
  }
6081
6245
  function extractJsxFromExpression(expr) {
6082
6246
  const inner = unwrapJsxTransparent(expr);
6083
- if (ts10.isJsxElement(inner) || ts10.isJsxFragment(inner) || ts10.isJsxSelfClosingElement(inner)) {
6247
+ if (ts11.isJsxElement(inner) || ts11.isJsxFragment(inner) || ts11.isJsxSelfClosingElement(inner)) {
6084
6248
  return inner;
6085
6249
  }
6086
6250
  return null;
6087
6251
  }
6088
6252
  function collectScopeVariables(node, ctx) {
6089
6253
  const variables = [];
6090
- if (ts10.isBlock(node)) {
6254
+ if (ts11.isBlock(node)) {
6091
6255
  for (const stmt of node.statements) {
6092
- if (ts10.isVariableStatement(stmt)) {
6256
+ if (ts11.isVariableStatement(stmt)) {
6093
6257
  for (const decl of stmt.declarationList.declarations) {
6094
6258
  variables.push(decl);
6095
6259
  }
@@ -6101,13 +6265,13 @@ function collectScopeVariables(node, ctx) {
6101
6265
  function collectParamBindingNames(params) {
6102
6266
  const out = new Set;
6103
6267
  const addBindingNames = (name) => {
6104
- if (ts10.isIdentifier(name)) {
6268
+ if (ts11.isIdentifier(name)) {
6105
6269
  out.add(name.text);
6106
- } else if (ts10.isObjectBindingPattern(name)) {
6270
+ } else if (ts11.isObjectBindingPattern(name)) {
6107
6271
  name.elements.forEach((e) => addBindingNames(e.name));
6108
- } else if (ts10.isArrayBindingPattern(name)) {
6272
+ } else if (ts11.isArrayBindingPattern(name)) {
6109
6273
  name.elements.forEach((e) => {
6110
- if (!ts10.isOmittedExpression(e))
6274
+ if (!ts11.isOmittedExpression(e))
6111
6275
  addBindingNames(e.name);
6112
6276
  });
6113
6277
  }
@@ -6124,7 +6288,7 @@ function collectEnclosingBranchVars(node, ctx) {
6124
6288
  if (cr.ifStatement.thenStatement !== current)
6125
6289
  continue;
6126
6290
  for (const decl of cr.scopeVariables) {
6127
- if (!ts10.isIdentifier(decl.name) || !decl.initializer)
6291
+ if (!ts11.isIdentifier(decl.name) || !decl.initializer)
6128
6292
  continue;
6129
6293
  const varName = decl.name.text;
6130
6294
  if (result.has(varName))
@@ -6139,10 +6303,10 @@ function collectEnclosingBranchVars(node, ctx) {
6139
6303
  return result;
6140
6304
  }
6141
6305
  function collectBranchSignals(thenStatement, ctx, branchCondition) {
6142
- if (!ts10.isBlock(thenStatement))
6306
+ if (!ts11.isBlock(thenStatement))
6143
6307
  return;
6144
6308
  for (const stmt of thenStatement.statements) {
6145
- if (!ts10.isVariableStatement(stmt))
6309
+ if (!ts11.isVariableStatement(stmt))
6146
6310
  continue;
6147
6311
  for (const decl of stmt.declarationList.declarations) {
6148
6312
  if (!isSignalDeclaration(decl, ctx))
@@ -6168,13 +6332,13 @@ var ENV_SIGNAL_FACTORIES = {
6168
6332
  createSearchParams: "search"
6169
6333
  };
6170
6334
  function resolvePrimitiveKind(callExpr, ctx) {
6171
- if (ts10.isIdentifier(callExpr.expression)) {
6335
+ if (ts11.isIdentifier(callExpr.expression)) {
6172
6336
  const hit = PRIMITIVE_CANONICAL_NAMES[callExpr.expression.text];
6173
6337
  if (hit)
6174
6338
  return hit;
6175
6339
  return resolveCalleeViaChecker(callExpr.expression, ctx);
6176
6340
  }
6177
- if (ts10.isPropertyAccessExpression(callExpr.expression)) {
6341
+ if (ts11.isPropertyAccessExpression(callExpr.expression)) {
6178
6342
  const propName = callExpr.expression.name.text;
6179
6343
  const hit = PRIMITIVE_CANONICAL_NAMES[propName];
6180
6344
  if (!hit)
@@ -6201,7 +6365,7 @@ function resolveCanonicalClientExportName(ident, ctx) {
6201
6365
  if (!symbol)
6202
6366
  return null;
6203
6367
  let target = symbol;
6204
- if (symbol.flags & ts10.SymbolFlags.Alias) {
6368
+ if (symbol.flags & ts11.SymbolFlags.Alias) {
6205
6369
  try {
6206
6370
  target = ctx.checker.getAliasedSymbol(symbol);
6207
6371
  } catch {
@@ -6217,14 +6381,14 @@ function resolveCanonicalClientExportName(ident, ctx) {
6217
6381
  return null;
6218
6382
  }
6219
6383
  function resolveEnvSignalKey(callExpr, ctx) {
6220
- if (ts10.isIdentifier(callExpr.expression)) {
6384
+ if (ts11.isIdentifier(callExpr.expression)) {
6221
6385
  const key = ENV_SIGNAL_FACTORIES[callExpr.expression.text];
6222
6386
  if (key)
6223
6387
  return key;
6224
6388
  const canonical = resolveCanonicalClientExportName(callExpr.expression, ctx);
6225
6389
  return canonical ? ENV_SIGNAL_FACTORIES[canonical] ?? null : null;
6226
6390
  }
6227
- if (ts10.isPropertyAccessExpression(callExpr.expression)) {
6391
+ if (ts11.isPropertyAccessExpression(callExpr.expression)) {
6228
6392
  const key = ENV_SIGNAL_FACTORIES[callExpr.expression.name.text];
6229
6393
  if (key && isBarefootClientNamespace(callExpr.expression.expression, ctx))
6230
6394
  return key;
@@ -6232,7 +6396,7 @@ function resolveEnvSignalKey(callExpr, ctx) {
6232
6396
  return null;
6233
6397
  }
6234
6398
  function isBarefootClientNamespace(expr, ctx) {
6235
- if (!ts10.isIdentifier(expr))
6399
+ if (!ts11.isIdentifier(expr))
6236
6400
  return false;
6237
6401
  if (!ctx.checker)
6238
6402
  return false;
@@ -6245,22 +6409,22 @@ function isBarefootClientNamespace(expr, ctx) {
6245
6409
  if (!symbol)
6246
6410
  return false;
6247
6411
  for (const decl of symbol.declarations ?? []) {
6248
- if (!ts10.isNamespaceImport(decl))
6412
+ if (!ts11.isNamespaceImport(decl))
6249
6413
  continue;
6250
6414
  const importDecl = decl.parent.parent;
6251
- if (!ts10.isImportDeclaration(importDecl))
6415
+ if (!ts11.isImportDeclaration(importDecl))
6252
6416
  continue;
6253
6417
  const mod = importDecl.moduleSpecifier;
6254
- if (ts10.isStringLiteral(mod) && mod.text === "@barefootjs/client") {
6418
+ if (ts11.isStringLiteral(mod) && mod.text === "@barefootjs/client") {
6255
6419
  return true;
6256
6420
  }
6257
6421
  }
6258
6422
  return false;
6259
6423
  }
6260
6424
  function isSignalDeclaration(node, ctx) {
6261
- if (!ts10.isArrayBindingPattern(node.name))
6425
+ if (!ts11.isArrayBindingPattern(node.name))
6262
6426
  return false;
6263
- if (!node.initializer || !ts10.isCallExpression(node.initializer))
6427
+ if (!node.initializer || !ts11.isCallExpression(node.initializer))
6264
6428
  return false;
6265
6429
  return resolvePrimitiveKind(node.initializer, ctx) === "signal";
6266
6430
  }
@@ -6268,14 +6432,14 @@ function collectSignal(node, ctx) {
6268
6432
  const pattern = node.name;
6269
6433
  const callExpr = node.initializer;
6270
6434
  const elements = pattern.elements;
6271
- const getterElided = elements.length === 2 && ts10.isOmittedExpression(elements[0]);
6272
- if (elements.length < 1 || elements.length > 2 || !getterElided && (!ts10.isBindingElement(elements[0]) || !ts10.isIdentifier(elements[0].name))) {
6435
+ const getterElided = elements.length === 2 && ts11.isOmittedExpression(elements[0]);
6436
+ if (elements.length < 1 || elements.length > 2 || !getterElided && (!ts11.isBindingElement(elements[0]) || !ts11.isIdentifier(elements[0].name))) {
6273
6437
  return;
6274
6438
  }
6275
- if (elements.length === 2 && (!ts10.isBindingElement(elements[1]) || !ts10.isIdentifier(elements[1].name))) {
6439
+ if (elements.length === 2 && (!ts11.isBindingElement(elements[1]) || !ts11.isIdentifier(elements[1].name))) {
6276
6440
  return;
6277
6441
  }
6278
- const setter = elements.length === 2 && ts10.isBindingElement(elements[1]) && ts10.isIdentifier(elements[1].name) ? elements[1].name.text : null;
6442
+ const setter = elements.length === 2 && ts11.isBindingElement(elements[1]) && ts11.isIdentifier(elements[1].name) ? elements[1].name.text : null;
6279
6443
  if (getterElided && !setter)
6280
6444
  return;
6281
6445
  const getter = getterElided ? `__bfGet_${setter}` : elements[0].name.text;
@@ -6312,33 +6476,33 @@ function collectSignal(node, ctx) {
6312
6476
  });
6313
6477
  }
6314
6478
  function isSignalTupleDeclaration(node) {
6315
- if (!ts10.isIdentifier(node.name))
6479
+ if (!ts11.isIdentifier(node.name))
6316
6480
  return false;
6317
- if (!node.initializer || !ts10.isCallExpression(node.initializer))
6481
+ if (!node.initializer || !ts11.isCallExpression(node.initializer))
6318
6482
  return false;
6319
6483
  const callExpr = node.initializer;
6320
- return ts10.isIdentifier(callExpr.expression) && callExpr.expression.text === "createSignal";
6484
+ return ts11.isIdentifier(callExpr.expression) && callExpr.expression.text === "createSignal";
6321
6485
  }
6322
6486
  function isSignalIndexAccess(node, ctx) {
6323
- if (!ts10.isIdentifier(node.name))
6487
+ if (!ts11.isIdentifier(node.name))
6324
6488
  return null;
6325
- if (!node.initializer || !ts10.isElementAccessExpression(node.initializer))
6489
+ if (!node.initializer || !ts11.isElementAccessExpression(node.initializer))
6326
6490
  return null;
6327
6491
  const access = node.initializer;
6328
- if (!ts10.isNumericLiteral(access.argumentExpression))
6492
+ if (!ts11.isNumericLiteral(access.argumentExpression))
6329
6493
  return null;
6330
6494
  const indexValue = Number(access.argumentExpression.text);
6331
6495
  if (indexValue !== 0 && indexValue !== 1)
6332
6496
  return null;
6333
6497
  const index = indexValue;
6334
- if (ts10.isCallExpression(access.expression)) {
6498
+ if (ts11.isCallExpression(access.expression)) {
6335
6499
  const call = access.expression;
6336
- if (ts10.isIdentifier(call.expression) && call.expression.text === "createSignal") {
6500
+ if (ts11.isIdentifier(call.expression) && call.expression.text === "createSignal") {
6337
6501
  return { kind: "direct", index, callExpr: call };
6338
6502
  }
6339
6503
  return null;
6340
6504
  }
6341
- if (ts10.isIdentifier(access.expression)) {
6505
+ if (ts11.isIdentifier(access.expression)) {
6342
6506
  const tupleName = access.expression.text;
6343
6507
  if (ctx.signalTupleRefs.has(tupleName)) {
6344
6508
  return { kind: "tupleRef", index, tupleName };
@@ -6433,30 +6597,30 @@ function flushPendingSignalTuples(ctx) {
6433
6597
  ctx.signalTupleRefs.clear();
6434
6598
  }
6435
6599
  function isMemoDeclaration(node, ctx) {
6436
- if (!ts10.isIdentifier(node.name))
6600
+ if (!ts11.isIdentifier(node.name))
6437
6601
  return false;
6438
- if (!node.initializer || !ts10.isCallExpression(node.initializer))
6602
+ if (!node.initializer || !ts11.isCallExpression(node.initializer))
6439
6603
  return false;
6440
6604
  return resolvePrimitiveKind(node.initializer, ctx) === "memo";
6441
6605
  }
6442
6606
  function memoBodyIsTemplateLiteral(memoArrow) {
6443
6607
  let node = memoArrow;
6444
- while (node && ts10.isParenthesizedExpression(node))
6608
+ while (node && ts11.isParenthesizedExpression(node))
6445
6609
  node = node.expression;
6446
- if (!node || !ts10.isArrowFunction(node))
6610
+ if (!node || !ts11.isArrowFunction(node))
6447
6611
  return false;
6448
6612
  let body = node.body;
6449
- while (ts10.isParenthesizedExpression(body))
6613
+ while (ts11.isParenthesizedExpression(body))
6450
6614
  body = body.expression;
6451
- if (ts10.isBlock(body)) {
6452
- const ret = body.statements.find(ts10.isReturnStatement);
6615
+ if (ts11.isBlock(body)) {
6616
+ const ret = body.statements.find(ts11.isReturnStatement);
6453
6617
  if (!ret || !ret.expression)
6454
6618
  return false;
6455
6619
  body = ret.expression;
6456
- while (ts10.isParenthesizedExpression(body))
6620
+ while (ts11.isParenthesizedExpression(body))
6457
6621
  body = body.expression;
6458
6622
  }
6459
- return ts10.isTemplateExpression(body) || ts10.isNoSubstitutionTemplateLiteral(body);
6623
+ return ts11.isTemplateExpression(body) || ts11.isNoSubstitutionTemplateLiteral(body);
6460
6624
  }
6461
6625
  function collectMemo(node, ctx) {
6462
6626
  const name = node.name.text;
@@ -6473,7 +6637,7 @@ function collectMemo(node, ctx) {
6473
6637
  type = inferTypeFromValue(arrowBody);
6474
6638
  }
6475
6639
  }
6476
- if (ctx.checker && (type.kind === "unknown" || type.kind === "object") && callExpr.arguments[0] && (ts10.isArrowFunction(callExpr.arguments[0]) || ts10.isFunctionExpression(callExpr.arguments[0]))) {
6640
+ if (ctx.checker && (type.kind === "unknown" || type.kind === "object") && callExpr.arguments[0] && (ts11.isArrowFunction(callExpr.arguments[0]) || ts11.isFunctionExpression(callExpr.arguments[0]))) {
6477
6641
  const fnType = ctx.checker.getTypeAtLocation(callExpr.arguments[0]);
6478
6642
  const sig = fnType.getCallSignatures()[0];
6479
6643
  if (sig) {
@@ -6483,12 +6647,12 @@ function collectMemo(node, ctx) {
6483
6647
  }
6484
6648
  }
6485
6649
  const memoArrow = callExpr.arguments[0];
6486
- const parsedBody = memoArrow && ts10.isArrowFunction(memoArrow) && !ts10.isBlock(memoArrow.body) ? parseExpression(ctx.getJS(memoArrow.body)) : undefined;
6650
+ const parsedBody = memoArrow && ts11.isArrowFunction(memoArrow) && !ts11.isBlock(memoArrow.body) ? parseExpression(ctx.getJS(memoArrow.body)) : undefined;
6487
6651
  const parsed = parsedBody && parsedBody.kind !== "unsupported" && parsedBody.kind !== "object-literal" ? parsedBody : undefined;
6488
6652
  let arrowNode = memoArrow;
6489
- while (arrowNode && ts10.isParenthesizedExpression(arrowNode))
6653
+ while (arrowNode && ts11.isParenthesizedExpression(arrowNode))
6490
6654
  arrowNode = arrowNode.expression;
6491
- const blockBody = arrowNode && ts10.isArrowFunction(arrowNode) && ts10.isBlock(arrowNode.body) ? arrowNode.body : undefined;
6655
+ const blockBody = arrowNode && ts11.isArrowFunction(arrowNode) && ts11.isBlock(arrowNode.body) ? arrowNode.body : undefined;
6492
6656
  const parsedBlock = blockBody ? parseBlockBodyTolerant(blockBody, ctx.sourceFile, (node2) => ctx.getJS(node2)) : undefined;
6493
6657
  const parsedBlockComplete = parsedBlock && blockBody ? parsedBlock.length === blockBody.statements.length : undefined;
6494
6658
  let templateComputation;
@@ -6515,14 +6679,14 @@ function collectMemo(node, ctx) {
6515
6679
  });
6516
6680
  }
6517
6681
  function isEffectCall(node, ctx) {
6518
- if (!ts10.isCallExpression(node))
6682
+ if (!ts11.isCallExpression(node))
6519
6683
  return false;
6520
6684
  return resolvePrimitiveKind(node, ctx) === "effect";
6521
6685
  }
6522
6686
  function isEffectDisposerCapture(node, ctx) {
6523
- if (!ts10.isIdentifier(node.name))
6687
+ if (!ts11.isIdentifier(node.name))
6524
6688
  return false;
6525
- if (!node.initializer || !ts10.isCallExpression(node.initializer))
6689
+ if (!node.initializer || !ts11.isCallExpression(node.initializer))
6526
6690
  return false;
6527
6691
  return resolvePrimitiveKind(node.initializer, ctx) === "effect";
6528
6692
  }
@@ -6537,7 +6701,7 @@ function collectEffect(node, ctx, captureName) {
6537
6701
  });
6538
6702
  }
6539
6703
  function isOnMountCall(node, ctx) {
6540
- if (!ts10.isCallExpression(node))
6704
+ if (!ts11.isCallExpression(node))
6541
6705
  return false;
6542
6706
  return resolvePrimitiveKind(node, ctx) === "onMount";
6543
6707
  }
@@ -6572,19 +6736,19 @@ function leadsWithAsiHazard(body) {
6572
6736
  function extractAssignedIdentifiersFromNode(node) {
6573
6737
  const ids = new Set;
6574
6738
  function addFromTarget(target) {
6575
- if (ts10.isIdentifier(target)) {
6739
+ if (ts11.isIdentifier(target)) {
6576
6740
  ids.add(target.text);
6577
6741
  return;
6578
6742
  }
6579
- if (ts10.isParenthesizedExpression(target)) {
6743
+ if (ts11.isParenthesizedExpression(target)) {
6580
6744
  addFromTarget(target.expression);
6581
6745
  return;
6582
6746
  }
6583
- if (ts10.isArrayLiteralExpression(target)) {
6747
+ if (ts11.isArrayLiteralExpression(target)) {
6584
6748
  for (const el of target.elements) {
6585
- if (ts10.isOmittedExpression(el))
6749
+ if (ts11.isOmittedExpression(el))
6586
6750
  continue;
6587
- if (ts10.isSpreadElement(el)) {
6751
+ if (ts11.isSpreadElement(el)) {
6588
6752
  addFromTarget(el.expression);
6589
6753
  continue;
6590
6754
  }
@@ -6592,17 +6756,17 @@ function extractAssignedIdentifiersFromNode(node) {
6592
6756
  }
6593
6757
  return;
6594
6758
  }
6595
- if (ts10.isObjectLiteralExpression(target)) {
6759
+ if (ts11.isObjectLiteralExpression(target)) {
6596
6760
  for (const prop of target.properties) {
6597
- if (ts10.isShorthandPropertyAssignment(prop)) {
6761
+ if (ts11.isShorthandPropertyAssignment(prop)) {
6598
6762
  ids.add(prop.name.text);
6599
6763
  continue;
6600
6764
  }
6601
- if (ts10.isPropertyAssignment(prop)) {
6765
+ if (ts11.isPropertyAssignment(prop)) {
6602
6766
  addFromTarget(prop.initializer);
6603
6767
  continue;
6604
6768
  }
6605
- if (ts10.isSpreadAssignment(prop)) {
6769
+ if (ts11.isSpreadAssignment(prop)) {
6606
6770
  addFromTarget(prop.expression);
6607
6771
  continue;
6608
6772
  }
@@ -6611,21 +6775,21 @@ function extractAssignedIdentifiersFromNode(node) {
6611
6775
  }
6612
6776
  }
6613
6777
  function visit2(n) {
6614
- if (ts10.isArrowFunction(n) || ts10.isFunctionExpression(n) || ts10.isFunctionDeclaration(n) || ts10.isMethodDeclaration(n) || ts10.isGetAccessorDeclaration(n) || ts10.isSetAccessorDeclaration(n) || ts10.isConstructorDeclaration(n)) {
6778
+ if (ts11.isArrowFunction(n) || ts11.isFunctionExpression(n) || ts11.isFunctionDeclaration(n) || ts11.isMethodDeclaration(n) || ts11.isGetAccessorDeclaration(n) || ts11.isSetAccessorDeclaration(n) || ts11.isConstructorDeclaration(n)) {
6615
6779
  return;
6616
6780
  }
6617
- if (ts10.isBinaryExpression(n)) {
6781
+ if (ts11.isBinaryExpression(n)) {
6618
6782
  const op = n.operatorToken.kind;
6619
- 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) {
6783
+ 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) {
6620
6784
  addFromTarget(n.left);
6621
6785
  }
6622
6786
  }
6623
- if (ts10.isPrefixUnaryExpression(n) || ts10.isPostfixUnaryExpression(n)) {
6624
- if (n.operator === ts10.SyntaxKind.PlusPlusToken || n.operator === ts10.SyntaxKind.MinusMinusToken) {
6787
+ if (ts11.isPrefixUnaryExpression(n) || ts11.isPostfixUnaryExpression(n)) {
6788
+ if (n.operator === ts11.SyntaxKind.PlusPlusToken || n.operator === ts11.SyntaxKind.MinusMinusToken) {
6625
6789
  addFromTarget(n.operand);
6626
6790
  }
6627
6791
  }
6628
- ts10.forEachChild(n, visit2);
6792
+ ts11.forEachChild(n, visit2);
6629
6793
  }
6630
6794
  visit2(node);
6631
6795
  const localDecls = collectLocalDeclarations(node);
@@ -6636,30 +6800,30 @@ function extractAssignedIdentifiersFromNode(node) {
6636
6800
  function collectLocalDeclarations(root) {
6637
6801
  const names = new Set;
6638
6802
  function addBindingName(name) {
6639
- if (ts10.isIdentifier(name)) {
6803
+ if (ts11.isIdentifier(name)) {
6640
6804
  names.add(name.text);
6641
6805
  return;
6642
6806
  }
6643
- if (ts10.isArrayBindingPattern(name)) {
6807
+ if (ts11.isArrayBindingPattern(name)) {
6644
6808
  for (const el of name.elements) {
6645
- if (ts10.isBindingElement(el))
6809
+ if (ts11.isBindingElement(el))
6646
6810
  addBindingName(el.name);
6647
6811
  }
6648
6812
  return;
6649
6813
  }
6650
- if (ts10.isObjectBindingPattern(name)) {
6814
+ if (ts11.isObjectBindingPattern(name)) {
6651
6815
  for (const el of name.elements) {
6652
6816
  addBindingName(el.name);
6653
6817
  }
6654
6818
  }
6655
6819
  }
6656
6820
  function visit2(n) {
6657
- if (ts10.isArrowFunction(n) || ts10.isFunctionExpression(n) || ts10.isFunctionDeclaration(n))
6821
+ if (ts11.isArrowFunction(n) || ts11.isFunctionExpression(n) || ts11.isFunctionDeclaration(n))
6658
6822
  return;
6659
- if (ts10.isVariableDeclaration(n)) {
6823
+ if (ts11.isVariableDeclaration(n)) {
6660
6824
  addBindingName(n.name);
6661
6825
  }
6662
- ts10.forEachChild(n, visit2);
6826
+ ts11.forEachChild(n, visit2);
6663
6827
  }
6664
6828
  visit2(root);
6665
6829
  return names;
@@ -6686,6 +6850,7 @@ var CLIENT_EXPORTS = new Set([
6686
6850
  "isSSRPortal",
6687
6851
  "findSiblingSlot",
6688
6852
  "cleanupPortalPlaceholder",
6853
+ "trackPosition",
6689
6854
  "createSearchParams",
6690
6855
  "queryHref",
6691
6856
  "formatDate",
@@ -6693,35 +6858,35 @@ var CLIENT_EXPORTS = new Set([
6693
6858
  "Region"
6694
6859
  ]);
6695
6860
  function collectAmbientGlobals(node, ctx) {
6696
- if (ts10.isVariableStatement(node)) {
6697
- const isDeclare = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DeclareKeyword) ?? false;
6861
+ if (ts11.isVariableStatement(node)) {
6862
+ const isDeclare = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DeclareKeyword) ?? false;
6698
6863
  if (!isDeclare)
6699
6864
  return;
6700
6865
  for (const decl of node.declarationList.declarations) {
6701
- if (ts10.isIdentifier(decl.name))
6866
+ if (ts11.isIdentifier(decl.name))
6702
6867
  ctx.ambientGlobals.add(decl.name.text);
6703
6868
  }
6704
6869
  return;
6705
6870
  }
6706
- if (ts10.isFunctionDeclaration(node) && node.name) {
6707
- const isDeclare = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DeclareKeyword) ?? false;
6871
+ if (ts11.isFunctionDeclaration(node) && node.name) {
6872
+ const isDeclare = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DeclareKeyword) ?? false;
6708
6873
  if (isDeclare)
6709
6874
  ctx.ambientGlobals.add(node.name.text);
6710
6875
  return;
6711
6876
  }
6712
- if (ts10.isModuleDeclaration(node)) {
6713
- const isGlobalAugmentation = (node.flags & ts10.NodeFlags.GlobalAugmentation) !== 0;
6877
+ if (ts11.isModuleDeclaration(node)) {
6878
+ const isGlobalAugmentation = (node.flags & ts11.NodeFlags.GlobalAugmentation) !== 0;
6714
6879
  if (!isGlobalAugmentation)
6715
6880
  return;
6716
- if (!node.body || !ts10.isModuleBlock(node.body))
6881
+ if (!node.body || !ts11.isModuleBlock(node.body))
6717
6882
  return;
6718
6883
  for (const inner of node.body.statements) {
6719
- if (ts10.isVariableStatement(inner)) {
6884
+ if (ts11.isVariableStatement(inner)) {
6720
6885
  for (const decl of inner.declarationList.declarations) {
6721
- if (ts10.isIdentifier(decl.name))
6886
+ if (ts11.isIdentifier(decl.name))
6722
6887
  ctx.ambientGlobals.add(decl.name.text);
6723
6888
  }
6724
- } else if (ts10.isFunctionDeclaration(inner) && inner.name) {
6889
+ } else if (ts11.isFunctionDeclaration(inner) && inner.name) {
6725
6890
  ctx.ambientGlobals.add(inner.name.text);
6726
6891
  }
6727
6892
  }
@@ -6732,7 +6897,7 @@ function collectImport(node, ctx) {
6732
6897
  const specifiers = [];
6733
6898
  const isTypeOnly = !!node.importClause?.isTypeOnly;
6734
6899
  const loc = getSourceLocation(node, ctx.sourceFile, ctx.filePath);
6735
- if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings && ts10.isNamedImports(node.importClause.namedBindings)) {
6900
+ if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings && ts11.isNamedImports(node.importClause.namedBindings)) {
6736
6901
  const wrongImports = [];
6737
6902
  for (const element of node.importClause.namedBindings.elements) {
6738
6903
  const name = element.propertyName?.text ?? element.name.text;
@@ -6760,7 +6925,7 @@ function collectImport(node, ctx) {
6760
6925
  });
6761
6926
  }
6762
6927
  if (node.importClause.namedBindings) {
6763
- if (ts10.isNamedImports(node.importClause.namedBindings)) {
6928
+ if (ts11.isNamedImports(node.importClause.namedBindings)) {
6764
6929
  for (const element of node.importClause.namedBindings.elements) {
6765
6930
  specifiers.push({
6766
6931
  name: element.propertyName?.text ?? element.name.text,
@@ -6771,7 +6936,7 @@ function collectImport(node, ctx) {
6771
6936
  });
6772
6937
  }
6773
6938
  }
6774
- if (ts10.isNamespaceImport(node.importClause.namedBindings)) {
6939
+ if (ts11.isNamespaceImport(node.importClause.namedBindings)) {
6775
6940
  specifiers.push({
6776
6941
  name: node.importClause.namedBindings.name.text,
6777
6942
  alias: null,
@@ -6798,7 +6963,7 @@ function collectInterfaceDefinition(node, ctx) {
6798
6963
  });
6799
6964
  }
6800
6965
  function collectTypeAliasDefinition(node, ctx) {
6801
- const properties = ts10.isTypeLiteralNode(node.type) ? membersToProperties(node.type.members, ctx.sourceFile) : undefined;
6966
+ const properties = ts11.isTypeLiteralNode(node.type) ? membersToProperties(node.type.members, ctx.sourceFile) : undefined;
6802
6967
  ctx.typeDefinitions.push({
6803
6968
  kind: "type",
6804
6969
  name: node.name.text,
@@ -6811,20 +6976,20 @@ function extractSingleJsxReturn(body) {
6811
6976
  let jsxReturn = null;
6812
6977
  let returnCount = 0;
6813
6978
  function visit2(node) {
6814
- if (ts10.isFunctionDeclaration(node) || ts10.isFunctionExpression(node) || ts10.isArrowFunction(node))
6979
+ if (ts11.isFunctionDeclaration(node) || ts11.isFunctionExpression(node) || ts11.isArrowFunction(node))
6815
6980
  return;
6816
- if (ts10.isReturnStatement(node)) {
6981
+ if (ts11.isReturnStatement(node)) {
6817
6982
  returnCount++;
6818
6983
  if (node.expression) {
6819
6984
  const expr = unwrapJsxTransparent(node.expression);
6820
- if (ts10.isJsxElement(expr) || ts10.isJsxSelfClosingElement(expr) || ts10.isJsxFragment(expr)) {
6985
+ if (ts11.isJsxElement(expr) || ts11.isJsxSelfClosingElement(expr) || ts11.isJsxFragment(expr)) {
6821
6986
  jsxReturn = expr;
6822
6987
  }
6823
6988
  }
6824
6989
  }
6825
- ts10.forEachChild(node, visit2);
6990
+ ts11.forEachChild(node, visit2);
6826
6991
  }
6827
- ts10.forEachChild(body, visit2);
6992
+ ts11.forEachChild(body, visit2);
6828
6993
  if (returnCount !== 1)
6829
6994
  return null;
6830
6995
  return jsxReturn;
@@ -6841,9 +7006,9 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
6841
7006
  const stmts = body.statements;
6842
7007
  for (let i = 0;i < stmts.length; i++) {
6843
7008
  const stmt = stmts[i];
6844
- if (ts10.isIfStatement(stmt)) {
7009
+ if (ts11.isIfStatement(stmt)) {
6845
7010
  let current = stmt;
6846
- while (ts10.isIfStatement(current)) {
7011
+ while (ts11.isIfStatement(current)) {
6847
7012
  const ifStmt = current;
6848
7013
  if (!isDirectReturnBlock(ifStmt.thenStatement))
6849
7014
  return null;
@@ -6853,7 +7018,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
6853
7018
  return null;
6854
7019
  branches.push({ condition: ifStmt.expression, jsxReturn: jsxReturn ?? null });
6855
7020
  if (ifStmt.elseStatement) {
6856
- if (ts10.isIfStatement(ifStmt.elseStatement)) {
7021
+ if (ts11.isIfStatement(ifStmt.elseStatement)) {
6857
7022
  current = ifStmt.elseStatement;
6858
7023
  continue;
6859
7024
  }
@@ -6875,18 +7040,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
6875
7040
  }
6876
7041
  continue;
6877
7042
  }
6878
- if (ts10.isSwitchStatement(stmt)) {
7043
+ if (ts11.isSwitchStatement(stmt)) {
6879
7044
  if (branches.length > 0)
6880
7045
  return null;
6881
- if (!ts10.isIdentifier(stmt.expression) && !ts10.isPropertyAccessExpression(stmt.expression)) {
7046
+ if (!ts11.isIdentifier(stmt.expression) && !ts11.isPropertyAccessExpression(stmt.expression)) {
6882
7047
  return null;
6883
7048
  }
6884
- const hasDefault = stmt.caseBlock.clauses.some((c) => ts10.isDefaultClause(c));
7049
+ const hasDefault = stmt.caseBlock.clauses.some((c) => ts11.isDefaultClause(c));
6885
7050
  if (!hasDefault)
6886
7051
  return null;
6887
7052
  let pendingCases = [];
6888
7053
  for (const clause of stmt.caseBlock.clauses) {
6889
- if (ts10.isCaseClause(clause) && clause.statements.length === 0) {
7054
+ if (ts11.isCaseClause(clause) && clause.statements.length === 0) {
6890
7055
  pendingCases.push(clause.expression);
6891
7056
  continue;
6892
7057
  }
@@ -6896,7 +7061,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
6896
7061
  return null;
6897
7062
  if (!caseClauseIsDirectReturn(clause))
6898
7063
  return null;
6899
- if (ts10.isCaseClause(clause)) {
7064
+ if (ts11.isCaseClause(clause)) {
6900
7065
  branches.push({
6901
7066
  condition: clause.expression,
6902
7067
  jsxReturn: jsxReturn ?? null,
@@ -6917,18 +7082,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
6917
7082
  return null;
6918
7083
  return { branches, fallback, switchDiscriminant: stmt.expression, preamble };
6919
7084
  }
6920
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7085
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
6921
7086
  const expr = unwrapJsxTransparent(stmt.expression);
6922
- if (ts10.isJsxElement(expr) || ts10.isJsxSelfClosingElement(expr) || ts10.isJsxFragment(expr)) {
7087
+ if (ts11.isJsxElement(expr) || ts11.isJsxSelfClosingElement(expr) || ts11.isJsxFragment(expr)) {
6923
7088
  fallback = expr;
6924
- } else if (expr.kind === ts10.SyntaxKind.NullKeyword) {} else {
7089
+ } else if (expr.kind === ts11.SyntaxKind.NullKeyword) {} else {
6925
7090
  return null;
6926
7091
  }
6927
7092
  continue;
6928
7093
  }
6929
- if (ts10.isVariableStatement(stmt)) {
7094
+ if (ts11.isVariableStatement(stmt)) {
6930
7095
  const declFlags = stmt.declarationList.flags;
6931
- const isConstOrLet = (declFlags & ts10.NodeFlags.Const) !== 0 || (declFlags & ts10.NodeFlags.Let) !== 0;
7096
+ const isConstOrLet = (declFlags & ts11.NodeFlags.Const) !== 0 || (declFlags & ts11.NodeFlags.Let) !== 0;
6932
7097
  if (allowPreamble && isConstOrLet && branches.length === 0 && fallback === null) {
6933
7098
  preamble.push(stmt);
6934
7099
  continue;
@@ -6944,12 +7109,12 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
6944
7109
  return { branches, fallback, preamble };
6945
7110
  }
6946
7111
  function isDirectReturnBlock(node) {
6947
- if (ts10.isReturnStatement(node))
7112
+ if (ts11.isReturnStatement(node))
6948
7113
  return true;
6949
- if (ts10.isBlock(node)) {
7114
+ if (ts11.isBlock(node)) {
6950
7115
  let returnCount = 0;
6951
7116
  for (const stmt of node.statements) {
6952
- if (ts10.isReturnStatement(stmt)) {
7117
+ if (ts11.isReturnStatement(stmt)) {
6953
7118
  returnCount++;
6954
7119
  continue;
6955
7120
  }
@@ -6960,25 +7125,25 @@ function isDirectReturnBlock(node) {
6960
7125
  return false;
6961
7126
  }
6962
7127
  function findNullReturnInBlock(node) {
6963
- if (ts10.isBlock(node)) {
7128
+ if (ts11.isBlock(node)) {
6964
7129
  for (const stmt of node.statements) {
6965
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7130
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
6966
7131
  const expr = unwrapJsxTransparent(stmt.expression);
6967
- if (expr.kind === ts10.SyntaxKind.NullKeyword)
7132
+ if (expr.kind === ts11.SyntaxKind.NullKeyword)
6968
7133
  return true;
6969
7134
  }
6970
7135
  }
6971
7136
  }
6972
- if (ts10.isReturnStatement(node) && node.expression) {
7137
+ if (ts11.isReturnStatement(node) && node.expression) {
6973
7138
  const expr = unwrapJsxTransparent(node.expression);
6974
- if (expr.kind === ts10.SyntaxKind.NullKeyword)
7139
+ if (expr.kind === ts11.SyntaxKind.NullKeyword)
6975
7140
  return true;
6976
7141
  }
6977
7142
  return false;
6978
7143
  }
6979
7144
  function findJsxReturnInCaseClause(clause) {
6980
7145
  for (const stmt of clause.statements) {
6981
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7146
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
6982
7147
  return extractJsxFromExpression(stmt.expression);
6983
7148
  }
6984
7149
  }
@@ -6988,12 +7153,12 @@ function caseClauseIsDirectReturn(clause) {
6988
7153
  let returnCount = 0;
6989
7154
  let seenReturn = false;
6990
7155
  for (const stmt of clause.statements) {
6991
- if (ts10.isReturnStatement(stmt)) {
7156
+ if (ts11.isReturnStatement(stmt)) {
6992
7157
  returnCount++;
6993
7158
  seenReturn = true;
6994
7159
  continue;
6995
7160
  }
6996
- if (ts10.isBreakStatement(stmt)) {
7161
+ if (ts11.isBreakStatement(stmt)) {
6997
7162
  if (!seenReturn)
6998
7163
  return false;
6999
7164
  continue;
@@ -7004,9 +7169,9 @@ function caseClauseIsDirectReturn(clause) {
7004
7169
  }
7005
7170
  function findNullReturnInCaseClause(clause) {
7006
7171
  for (const stmt of clause.statements) {
7007
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7172
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
7008
7173
  const expr = unwrapJsxTransparent(stmt.expression);
7009
- if (expr.kind === ts10.SyntaxKind.NullKeyword)
7174
+ if (expr.kind === ts11.SyntaxKind.NullKeyword)
7010
7175
  return true;
7011
7176
  }
7012
7177
  }
@@ -7017,26 +7182,26 @@ function isMultiReturnJsxFunctionBody(body) {
7017
7182
  let hasJsxReturn = false;
7018
7183
  let allReturnsAreJsxOrNull = true;
7019
7184
  function visit2(node) {
7020
- if (ts10.isFunctionDeclaration(node) || ts10.isFunctionExpression(node) || ts10.isArrowFunction(node))
7185
+ if (ts11.isFunctionDeclaration(node) || ts11.isFunctionExpression(node) || ts11.isArrowFunction(node))
7021
7186
  return;
7022
- if (ts10.isReturnStatement(node)) {
7187
+ if (ts11.isReturnStatement(node)) {
7023
7188
  returnCount++;
7024
7189
  if (!node.expression) {
7025
7190
  allReturnsAreJsxOrNull = false;
7026
7191
  return;
7027
7192
  }
7028
7193
  const expr = unwrapJsxTransparent(node.expression);
7029
- const isJsx = ts10.isJsxElement(expr) || ts10.isJsxSelfClosingElement(expr) || ts10.isJsxFragment(expr);
7030
- const isNull = expr.kind === ts10.SyntaxKind.NullKeyword;
7194
+ const isJsx = ts11.isJsxElement(expr) || ts11.isJsxSelfClosingElement(expr) || ts11.isJsxFragment(expr);
7195
+ const isNull = expr.kind === ts11.SyntaxKind.NullKeyword;
7031
7196
  if (isJsx)
7032
7197
  hasJsxReturn = true;
7033
7198
  if (!isJsx && !isNull)
7034
7199
  allReturnsAreJsxOrNull = false;
7035
7200
  return;
7036
7201
  }
7037
- ts10.forEachChild(node, visit2);
7202
+ ts11.forEachChild(node, visit2);
7038
7203
  }
7039
- ts10.forEachChild(body, visit2);
7204
+ ts11.forEachChild(body, visit2);
7040
7205
  return returnCount > 1 && hasJsxReturn && allReturnsAreJsxOrNull;
7041
7206
  }
7042
7207
  function collectFunction(node, ctx, _isModule, isExported = false) {
@@ -7106,7 +7271,7 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
7106
7271
  }
7107
7272
  }
7108
7273
  }
7109
- const isAsync = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.AsyncKeyword) ?? false;
7274
+ const isAsync = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.AsyncKeyword) ?? false;
7110
7275
  const isGenerator = !!node.asteriskToken;
7111
7276
  ctx.localFunctions.push({
7112
7277
  name,
@@ -7127,10 +7292,10 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
7127
7292
  });
7128
7293
  }
7129
7294
  function extractValueBranches(node, ctx) {
7130
- if (ts10.isParenthesizedExpression(node)) {
7295
+ if (ts11.isParenthesizedExpression(node)) {
7131
7296
  return extractValueBranches(node.expression, ctx);
7132
7297
  }
7133
- if (ts10.isConditionalExpression(node)) {
7298
+ if (ts11.isConditionalExpression(node)) {
7134
7299
  return [
7135
7300
  ...extractValueBranches(node.whenTrue, ctx),
7136
7301
  ...extractValueBranches(node.whenFalse, ctx)
@@ -7142,46 +7307,46 @@ function extractFreeIdentifiersFromNode(node) {
7142
7307
  const ids = new Set;
7143
7308
  const boundNames = new Set;
7144
7309
  function addBindingNames(name, out) {
7145
- if (ts10.isIdentifier(name))
7310
+ if (ts11.isIdentifier(name))
7146
7311
  out.push(name.text);
7147
- else if (ts10.isObjectBindingPattern(name))
7312
+ else if (ts11.isObjectBindingPattern(name))
7148
7313
  name.elements.forEach((e) => addBindingNames(e.name, out));
7149
- else if (ts10.isArrayBindingPattern(name))
7314
+ else if (ts11.isArrayBindingPattern(name))
7150
7315
  name.elements.forEach((e) => {
7151
- if (!ts10.isOmittedExpression(e))
7316
+ if (!ts11.isOmittedExpression(e))
7152
7317
  addBindingNames(e.name, out);
7153
7318
  });
7154
7319
  }
7155
7320
  function visit2(n) {
7156
- if (ts10.isTypeNode(n))
7321
+ if (ts11.isTypeNode(n))
7157
7322
  return;
7158
- if (ts10.isIdentifier(n)) {
7323
+ if (ts11.isIdentifier(n)) {
7159
7324
  const parent = n.parent;
7160
- if (parent && ts10.isPropertyAccessExpression(parent) && parent.name === n)
7325
+ if (parent && ts11.isPropertyAccessExpression(parent) && parent.name === n)
7161
7326
  return;
7162
- if (parent && ts10.isPropertyAssignment(parent) && parent.name === n)
7327
+ if (parent && ts11.isPropertyAssignment(parent) && parent.name === n)
7163
7328
  return;
7164
- if (parent && ts10.isParameter(parent) && parent.name === n)
7329
+ if (parent && ts11.isParameter(parent) && parent.name === n)
7165
7330
  return;
7166
- if (parent && ts10.isVariableDeclaration(parent) && parent.name === n)
7331
+ if (parent && ts11.isVariableDeclaration(parent) && parent.name === n)
7167
7332
  return;
7168
7333
  if (boundNames.has(n.text))
7169
7334
  return;
7170
7335
  ids.add(n.text);
7171
7336
  return;
7172
7337
  }
7173
- if (ts10.isArrowFunction(n)) {
7338
+ if (ts11.isArrowFunction(n)) {
7174
7339
  const params = [];
7175
7340
  for (const p of n.parameters)
7176
7341
  addBindingNames(p.name, params);
7177
7342
  for (const name of params)
7178
7343
  boundNames.add(name);
7179
- ts10.forEachChild(n, visit2);
7344
+ ts11.forEachChild(n, visit2);
7180
7345
  for (const name of params)
7181
7346
  boundNames.delete(name);
7182
7347
  return;
7183
7348
  }
7184
- ts10.forEachChild(n, visit2);
7349
+ ts11.forEachChild(n, visit2);
7185
7350
  }
7186
7351
  visit2(node);
7187
7352
  return ids;
@@ -7190,29 +7355,29 @@ function extractFreeTypeIdentifiersFromNode(node) {
7190
7355
  const ids = new Set;
7191
7356
  const boundTypeParams = new Set;
7192
7357
  function rootName(name) {
7193
- return ts10.isQualifiedName(name) ? rootName(name.left) : name;
7358
+ return ts11.isQualifiedName(name) ? rootName(name.left) : name;
7194
7359
  }
7195
7360
  function visit2(n) {
7196
- if (ts10.isTypeReferenceNode(n)) {
7361
+ if (ts11.isTypeReferenceNode(n)) {
7197
7362
  const name = rootName(n.typeName).text;
7198
7363
  if (!boundTypeParams.has(name))
7199
7364
  ids.add(name);
7200
7365
  }
7201
- if (ts10.isTypeQueryNode(n)) {
7366
+ if (ts11.isTypeQueryNode(n)) {
7202
7367
  const name = rootName(n.exprName).text;
7203
7368
  if (!boundTypeParams.has(name))
7204
7369
  ids.add(name);
7205
7370
  }
7206
- if (ts10.isFunctionLike(n) && n.typeParameters && n.typeParameters.length > 0) {
7371
+ if (ts11.isFunctionLike(n) && n.typeParameters && n.typeParameters.length > 0) {
7207
7372
  const names = n.typeParameters.map((p) => p.name.text);
7208
7373
  for (const p of names)
7209
7374
  boundTypeParams.add(p);
7210
- ts10.forEachChild(n, visit2);
7375
+ ts11.forEachChild(n, visit2);
7211
7376
  for (const p of names)
7212
7377
  boundTypeParams.delete(p);
7213
7378
  return;
7214
7379
  }
7215
- ts10.forEachChild(n, visit2);
7380
+ ts11.forEachChild(n, visit2);
7216
7381
  }
7217
7382
  visit2(node);
7218
7383
  return ids;
@@ -7222,22 +7387,22 @@ function initializerShapeContainsJsx(node) {
7222
7387
  function visit2(n) {
7223
7388
  if (found)
7224
7389
  return;
7225
- if (ts10.isJsxElement(n) || ts10.isJsxSelfClosingElement(n) || ts10.isJsxFragment(n)) {
7390
+ if (ts11.isJsxElement(n) || ts11.isJsxSelfClosingElement(n) || ts11.isJsxFragment(n)) {
7226
7391
  found = true;
7227
7392
  return;
7228
7393
  }
7229
- if (ts10.isFunctionDeclaration(n) || ts10.isFunctionExpression(n) || ts10.isArrowFunction(n)) {
7394
+ if (ts11.isFunctionDeclaration(n) || ts11.isFunctionExpression(n) || ts11.isArrowFunction(n)) {
7230
7395
  return;
7231
7396
  }
7232
- ts10.forEachChild(n, visit2);
7397
+ ts11.forEachChild(n, visit2);
7233
7398
  }
7234
7399
  visit2(node);
7235
7400
  return found;
7236
7401
  }
7237
7402
  function isMapLikeCallWithJsx(node) {
7238
- if (!ts10.isCallExpression(node))
7403
+ if (!ts11.isCallExpression(node))
7239
7404
  return false;
7240
- if (!ts10.isPropertyAccessExpression(node.expression))
7405
+ if (!ts11.isPropertyAccessExpression(node.expression))
7241
7406
  return false;
7242
7407
  const method = node.expression.name.text;
7243
7408
  if (method !== "map" && method !== "flatMap")
@@ -7245,12 +7410,12 @@ function isMapLikeCallWithJsx(node) {
7245
7410
  const callback = node.arguments[0];
7246
7411
  if (!callback)
7247
7412
  return false;
7248
- if (!ts10.isArrowFunction(callback) && !ts10.isFunctionExpression(callback))
7413
+ if (!ts11.isArrowFunction(callback) && !ts11.isFunctionExpression(callback))
7249
7414
  return false;
7250
7415
  return containsJsxDeep(callback.body);
7251
7416
  }
7252
7417
  function containsJsxDeep(node) {
7253
- if (ts10.isJsxElement(node) || ts10.isJsxSelfClosingElement(node) || ts10.isJsxFragment(node))
7418
+ if (ts11.isJsxElement(node) || ts11.isJsxSelfClosingElement(node) || ts11.isJsxFragment(node))
7254
7419
  return true;
7255
7420
  let found = false;
7256
7421
  node.forEachChild((child) => {
@@ -7264,11 +7429,11 @@ function nodeContainsArrow(node) {
7264
7429
  function visit2(n) {
7265
7430
  if (found)
7266
7431
  return;
7267
- if (ts10.isArrowFunction(n) || ts10.isFunctionExpression(n)) {
7432
+ if (ts11.isArrowFunction(n) || ts11.isFunctionExpression(n)) {
7268
7433
  found = true;
7269
7434
  return;
7270
7435
  }
7271
- ts10.forEachChild(n, visit2);
7436
+ ts11.forEachChild(n, visit2);
7272
7437
  }
7273
7438
  visit2(node);
7274
7439
  return found;
@@ -7316,20 +7481,20 @@ function collectModuleScopeReactive(decl, ctx, isExported) {
7316
7481
  }));
7317
7482
  }
7318
7483
  function getSystemConstructKind(node) {
7319
- if (ts10.isCallExpression(node) && ts10.isIdentifier(node.expression) && node.expression.text === "createContext")
7484
+ if (ts11.isCallExpression(node) && ts11.isIdentifier(node.expression) && node.expression.text === "createContext")
7320
7485
  return "createContext";
7321
- if (ts10.isNewExpression(node) && ts10.isIdentifier(node.expression) && node.expression.text === "WeakMap")
7486
+ if (ts11.isNewExpression(node) && ts11.isIdentifier(node.expression) && node.expression.text === "WeakMap")
7322
7487
  return "weakMap";
7323
7488
  return;
7324
7489
  }
7325
7490
  function collectConstant(node, ctx, _isModule, declarationKind = "const", isExported = false) {
7326
- if (!_isModule && ts10.isObjectBindingPattern(node.name) && node.initializer && ts10.isIdentifier(node.initializer) && ctx.propsObjectName === node.initializer.text) {
7491
+ if (!_isModule && ts11.isObjectBindingPattern(node.name) && node.initializer && ts11.isIdentifier(node.initializer) && ctx.propsObjectName === node.initializer.text) {
7327
7492
  const propsName = node.initializer.text;
7328
7493
  for (const el of node.name.elements) {
7329
- if (!ts10.isBindingElement(el) || !ts10.isIdentifier(el.name) || el.dotDotDotToken)
7494
+ if (!ts11.isBindingElement(el) || !ts11.isIdentifier(el.name) || el.dotDotDotToken)
7330
7495
  continue;
7331
7496
  const localName = el.name.text;
7332
- const sourceKey = el.propertyName && ts10.isIdentifier(el.propertyName) ? el.propertyName.text : localName;
7497
+ const sourceKey = el.propertyName && ts11.isIdentifier(el.propertyName) ? el.propertyName.text : localName;
7333
7498
  const defaultValueExpr = el.initializer ? ctx.getJS(el.initializer) : undefined;
7334
7499
  const baseValue = `${propsName}.${sourceKey}`;
7335
7500
  const value2 = defaultValueExpr ? `${baseValue} ?? ${defaultValueExpr}` : baseValue;
@@ -7351,7 +7516,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7351
7516
  }
7352
7517
  return;
7353
7518
  }
7354
- if (!ts10.isIdentifier(node.name))
7519
+ if (!ts11.isIdentifier(node.name))
7355
7520
  return;
7356
7521
  if (isSignalDeclaration(node, ctx) || isMemoDeclaration(node, ctx))
7357
7522
  return;
@@ -7369,9 +7534,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7369
7534
  let isJsxFunction = false;
7370
7535
  if (node.initializer) {
7371
7536
  let init = node.initializer;
7372
- while (ts10.isParenthesizedExpression(init))
7537
+ while (ts11.isParenthesizedExpression(init))
7373
7538
  init = init.expression;
7374
- if (ts10.isJsxElement(init) || ts10.isJsxSelfClosingElement(init) || ts10.isJsxFragment(init)) {
7539
+ if (ts11.isJsxElement(init) || ts11.isJsxSelfClosingElement(init) || ts11.isJsxFragment(init)) {
7375
7540
  isJsx = true;
7376
7541
  ctx.jsxConstants.set(name, init);
7377
7542
  } else if (initializerShapeContainsJsx(init)) {
@@ -7379,9 +7544,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7379
7544
  } else if (isMapLikeCallWithJsx(init)) {
7380
7545
  ctx.inlineableJsxConsts.set(name, init);
7381
7546
  }
7382
- if (ts10.isArrowFunction(init)) {
7547
+ if (ts11.isArrowFunction(init)) {
7383
7548
  const arrowBody = init.body;
7384
- if (ts10.isBlock(arrowBody)) {
7549
+ if (ts11.isBlock(arrowBody)) {
7385
7550
  const jsxReturn = extractSingleJsxReturn(arrowBody);
7386
7551
  if (jsxReturn) {
7387
7552
  isJsxFunction = true;
@@ -7401,9 +7566,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7401
7566
  }
7402
7567
  } else {
7403
7568
  let body = arrowBody;
7404
- while (ts10.isParenthesizedExpression(body))
7569
+ while (ts11.isParenthesizedExpression(body))
7405
7570
  body = body.expression;
7406
- if (ts10.isJsxElement(body) || ts10.isJsxSelfClosingElement(body) || ts10.isJsxFragment(body)) {
7571
+ if (ts11.isJsxElement(body) || ts11.isJsxSelfClosingElement(body) || ts11.isJsxFragment(body)) {
7407
7572
  isJsxFunction = true;
7408
7573
  ctx.jsxFunctions.set(name, {
7409
7574
  jsxReturn: body,
@@ -7416,9 +7581,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7416
7581
  let valueBranches;
7417
7582
  if (node.initializer) {
7418
7583
  let inner = node.initializer;
7419
- while (ts10.isParenthesizedExpression(inner))
7584
+ while (ts11.isParenthesizedExpression(inner))
7420
7585
  inner = inner.expression;
7421
- if (ts10.isConditionalExpression(inner)) {
7586
+ if (ts11.isConditionalExpression(inner)) {
7422
7587
  valueBranches = extractValueBranches(node.initializer, ctx);
7423
7588
  }
7424
7589
  }
@@ -7496,7 +7661,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7496
7661
  function hasIgnoreDirective(node, sourceFile, ruleId) {
7497
7662
  const checkComments = (targetNode) => {
7498
7663
  const fullStart = targetNode.getFullStart();
7499
- const leadingComments = ts10.getLeadingCommentRanges(sourceFile.getFullText(), fullStart);
7664
+ const leadingComments = ts11.getLeadingCommentRanges(sourceFile.getFullText(), fullStart);
7500
7665
  if (!leadingComments)
7501
7666
  return false;
7502
7667
  for (const range of leadingComments) {
@@ -7509,10 +7674,10 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
7509
7674
  };
7510
7675
  if (checkComments(node))
7511
7676
  return true;
7512
- if (ts10.isArrowFunction(node)) {
7677
+ if (ts11.isArrowFunction(node)) {
7513
7678
  let current = node.parent;
7514
7679
  while (current) {
7515
- if (ts10.isVariableStatement(current)) {
7680
+ if (ts11.isVariableStatement(current)) {
7516
7681
  if (checkComments(current))
7517
7682
  return true;
7518
7683
  break;
@@ -7523,7 +7688,7 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
7523
7688
  return false;
7524
7689
  }
7525
7690
  function extractProps(param, ctx) {
7526
- if (ts10.isObjectBindingPattern(param.name)) {
7691
+ if (ts11.isObjectBindingPattern(param.name)) {
7527
7692
  const componentNode = ctx.componentNode;
7528
7693
  const ignored = !!(componentNode && hasIgnoreDirective(componentNode, ctx.sourceFile, "props-destructuring"));
7529
7694
  ctx.propsDestructuring = {
@@ -7532,14 +7697,14 @@ function extractProps(param, ctx) {
7532
7697
  };
7533
7698
  const memberTypes = param.type ? collectMemberTypes(param.type, ctx) : null;
7534
7699
  for (const element of param.name.elements) {
7535
- if (ts10.isBindingElement(element) && ts10.isIdentifier(element.name)) {
7700
+ if (ts11.isBindingElement(element) && ts11.isIdentifier(element.name)) {
7536
7701
  const localName = element.name.text;
7537
7702
  const defaultValue = element.initializer ? ctx.getJS(element.initializer) : undefined;
7538
7703
  if (element.dotDotDotToken) {
7539
7704
  ctx.restPropsName = localName;
7540
7705
  continue;
7541
7706
  }
7542
- const sourcePropName = element.propertyName && ts10.isIdentifier(element.propertyName) ? element.propertyName.text : localName;
7707
+ const sourcePropName = element.propertyName && ts11.isIdentifier(element.propertyName) ? element.propertyName.text : localName;
7543
7708
  const member = memberTypes?.get(sourcePropName);
7544
7709
  const resolvedType = member?.type ?? { kind: "unknown", raw: "unknown" };
7545
7710
  const defaultContainsArrow = element.initializer ? nodeContainsArrow(element.initializer) : false;
@@ -7563,7 +7728,7 @@ function extractProps(param, ctx) {
7563
7728
  }
7564
7729
  }
7565
7730
  }
7566
- if (ts10.isIdentifier(param.name)) {
7731
+ if (ts11.isIdentifier(param.name)) {
7567
7732
  ctx.propsObjectName = param.name.text;
7568
7733
  if (param.type) {
7569
7734
  extractPropsFromType(param.type, ctx);
@@ -7574,24 +7739,24 @@ function extractProps(param, ctx) {
7574
7739
  }
7575
7740
  }
7576
7741
  function collectTypeKeys(typeNode, ctx) {
7577
- if (ts10.isTypeLiteralNode(typeNode)) {
7742
+ if (ts11.isTypeLiteralNode(typeNode)) {
7578
7743
  return collectKeysFromMembers(typeNode.members, ctx);
7579
7744
  }
7580
- if (ts10.isTypeReferenceNode(typeNode)) {
7745
+ if (ts11.isTypeReferenceNode(typeNode)) {
7581
7746
  const typeName = typeNode.typeName.getText(ctx.sourceFile);
7582
7747
  const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
7583
7748
  if (!typeDecl)
7584
7749
  return null;
7585
- if (ts10.isInterfaceDeclaration(typeDecl)) {
7750
+ if (ts11.isInterfaceDeclaration(typeDecl)) {
7586
7751
  if (typeDecl.heritageClauses && typeDecl.heritageClauses.length > 0)
7587
7752
  return null;
7588
7753
  return collectKeysFromMembers(typeDecl.members, ctx);
7589
7754
  }
7590
- if (ts10.isTypeAliasDeclaration(typeDecl)) {
7591
- if (ts10.isTypeLiteralNode(typeDecl.type)) {
7755
+ if (ts11.isTypeAliasDeclaration(typeDecl)) {
7756
+ if (ts11.isTypeLiteralNode(typeDecl.type)) {
7592
7757
  return collectKeysFromMembers(typeDecl.type.members, ctx);
7593
7758
  }
7594
- if (ts10.isIntersectionTypeNode(typeDecl.type)) {
7759
+ if (ts11.isIntersectionTypeNode(typeDecl.type)) {
7595
7760
  return null;
7596
7761
  }
7597
7762
  }
@@ -7601,9 +7766,9 @@ function collectTypeKeys(typeNode, ctx) {
7601
7766
  function collectKeysFromMembers(members, ctx) {
7602
7767
  const keys = [];
7603
7768
  for (const member of members) {
7604
- if (ts10.isIndexSignatureDeclaration(member))
7769
+ if (ts11.isIndexSignatureDeclaration(member))
7605
7770
  return null;
7606
- if (ts10.isPropertySignature(member) && member.name) {
7771
+ if (ts11.isPropertySignature(member) && member.name) {
7607
7772
  keys.push(member.name.getText(ctx.sourceFile));
7608
7773
  }
7609
7774
  }
@@ -7627,7 +7792,7 @@ function collectMemberTypes(typeNode, ctx) {
7627
7792
  const fromMembers = (members) => {
7628
7793
  const map = new Map;
7629
7794
  for (const member of members) {
7630
- if (ts10.isPropertySignature(member) && member.name) {
7795
+ if (ts11.isPropertySignature(member) && member.name) {
7631
7796
  const info = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : null;
7632
7797
  map.set(member.name.getText(ctx.sourceFile), {
7633
7798
  type: info && isResolvableMemberType(info) ? info : null,
@@ -7637,35 +7802,35 @@ function collectMemberTypes(typeNode, ctx) {
7637
7802
  }
7638
7803
  return map;
7639
7804
  };
7640
- if (ts10.isTypeLiteralNode(typeNode)) {
7805
+ if (ts11.isTypeLiteralNode(typeNode)) {
7641
7806
  return fromMembers(typeNode.members);
7642
7807
  }
7643
- if (ts10.isTypeReferenceNode(typeNode)) {
7808
+ if (ts11.isTypeReferenceNode(typeNode)) {
7644
7809
  const typeName = typeNode.typeName.getText(ctx.sourceFile);
7645
7810
  const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
7646
7811
  if (!typeDecl)
7647
7812
  return null;
7648
- if (ts10.isInterfaceDeclaration(typeDecl)) {
7813
+ if (ts11.isInterfaceDeclaration(typeDecl)) {
7649
7814
  return fromMembers(typeDecl.members);
7650
7815
  }
7651
- if (ts10.isTypeAliasDeclaration(typeDecl) && ts10.isTypeLiteralNode(typeDecl.type)) {
7816
+ if (ts11.isTypeAliasDeclaration(typeDecl) && ts11.isTypeLiteralNode(typeDecl.type)) {
7652
7817
  return fromMembers(typeDecl.type.members);
7653
7818
  }
7654
7819
  }
7655
7820
  return null;
7656
7821
  }
7657
7822
  function extractPropsFromType(typeNode, ctx) {
7658
- if (ts10.isTypeLiteralNode(typeNode)) {
7823
+ if (ts11.isTypeLiteralNode(typeNode)) {
7659
7824
  extractPropsFromTypeMembers(typeNode.members, ctx);
7660
7825
  return;
7661
7826
  }
7662
- if (ts10.isTypeReferenceNode(typeNode)) {
7827
+ if (ts11.isTypeReferenceNode(typeNode)) {
7663
7828
  const typeName = typeNode.typeName.getText(ctx.sourceFile);
7664
7829
  const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
7665
7830
  if (typeDecl) {
7666
- if (ts10.isInterfaceDeclaration(typeDecl)) {
7831
+ if (ts11.isInterfaceDeclaration(typeDecl)) {
7667
7832
  extractPropsFromTypeMembers(typeDecl.members, ctx);
7668
- } else if (ts10.isTypeAliasDeclaration(typeDecl) && ts10.isTypeLiteralNode(typeDecl.type)) {
7833
+ } else if (ts11.isTypeAliasDeclaration(typeDecl) && ts11.isTypeLiteralNode(typeDecl.type)) {
7669
7834
  extractPropsFromTypeMembers(typeDecl.type.members, ctx);
7670
7835
  }
7671
7836
  }
@@ -7673,7 +7838,7 @@ function extractPropsFromType(typeNode, ctx) {
7673
7838
  }
7674
7839
  function extractPropsFromTypeMembers(members, ctx) {
7675
7840
  for (const member of members) {
7676
- if (ts10.isPropertySignature(member) && member.name) {
7841
+ if (ts11.isPropertySignature(member) && member.name) {
7677
7842
  const propName = member.name.getText(ctx.sourceFile);
7678
7843
  const isOptional = !!member.questionToken;
7679
7844
  const propType = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : { kind: "unknown", raw: "unknown" };
@@ -7689,17 +7854,17 @@ function extractPropsFromTypeMembers(members, ctx) {
7689
7854
  function findTypeDeclaration(typeName, sourceFile) {
7690
7855
  let result;
7691
7856
  function visit2(node) {
7692
- if (ts10.isInterfaceDeclaration(node) && node.name.text === typeName) {
7857
+ if (ts11.isInterfaceDeclaration(node) && node.name.text === typeName) {
7693
7858
  result = node;
7694
7859
  return;
7695
7860
  }
7696
- if (ts10.isTypeAliasDeclaration(node) && node.name.text === typeName) {
7861
+ if (ts11.isTypeAliasDeclaration(node) && node.name.text === typeName) {
7697
7862
  result = node;
7698
7863
  return;
7699
7864
  }
7700
- ts10.forEachChild(node, visit2);
7865
+ ts11.forEachChild(node, visit2);
7701
7866
  }
7702
- ts10.forEachChild(sourceFile, visit2);
7867
+ ts11.forEachChild(sourceFile, visit2);
7703
7868
  return result;
7704
7869
  }
7705
7870
  function inferTypeFromValue(value) {
@@ -7745,12 +7910,12 @@ function inferTypeFromValue(value) {
7745
7910
  }
7746
7911
  function collectCalledIdentifiers(code) {
7747
7912
  const called = new Set;
7748
- const sf = ts10.createSourceFile("__deps__.tsx", code, ts10.ScriptTarget.Latest, false, ts10.ScriptKind.TSX);
7913
+ const sf = ts11.createSourceFile("__deps__.tsx", code, ts11.ScriptTarget.Latest, false, ts11.ScriptKind.TSX);
7749
7914
  const visit2 = (node) => {
7750
- if (ts10.isCallExpression(node) && ts10.isIdentifier(node.expression)) {
7915
+ if (ts11.isCallExpression(node) && ts11.isIdentifier(node.expression)) {
7751
7916
  called.add(node.expression.text);
7752
7917
  }
7753
- ts10.forEachChild(node, visit2);
7918
+ ts11.forEachChild(node, visit2);
7754
7919
  };
7755
7920
  visit2(sf);
7756
7921
  return called;
@@ -7848,16 +8013,16 @@ function isResolvableComponentSource(source) {
7848
8013
  function collectJsxComponentTags(sourceFile) {
7849
8014
  const tags = new Set;
7850
8015
  function visit2(node) {
7851
- if (ts10.isJsxOpeningElement(node) || ts10.isJsxSelfClosingElement(node)) {
8016
+ if (ts11.isJsxOpeningElement(node) || ts11.isJsxSelfClosingElement(node)) {
7852
8017
  const tagName = node.tagName;
7853
- if (ts10.isIdentifier(tagName)) {
8018
+ if (ts11.isIdentifier(tagName)) {
7854
8019
  const first = tagName.text.charAt(0);
7855
8020
  if (first >= "A" && first <= "Z") {
7856
8021
  tags.add(tagName.text);
7857
8022
  }
7858
8023
  }
7859
8024
  }
7860
- ts10.forEachChild(node, visit2);
8025
+ ts11.forEachChild(node, visit2);
7861
8026
  }
7862
8027
  visit2(sourceFile);
7863
8028
  return tags;
@@ -7936,18 +8101,18 @@ function fileHasUseClientDirective(filePath) {
7936
8101
  } catch {
7937
8102
  return true;
7938
8103
  }
7939
- const sf = ts10.createSourceFile(filePath, content, ts10.ScriptTarget.Latest, false, ts10.ScriptKind.TSX);
8104
+ const sf = ts11.createSourceFile(filePath, content, ts11.ScriptTarget.Latest, false, ts11.ScriptKind.TSX);
7940
8105
  let found = false;
7941
8106
  function visit2(node) {
7942
8107
  if (found)
7943
8108
  return;
7944
- if (ts10.isExpressionStatement(node) && ts10.isStringLiteral(node.expression)) {
8109
+ if (ts11.isExpressionStatement(node) && ts11.isStringLiteral(node.expression)) {
7945
8110
  if (node.expression.text === "use client") {
7946
8111
  found = true;
7947
8112
  return;
7948
8113
  }
7949
8114
  }
7950
- ts10.forEachChild(node, visit2);
8115
+ ts11.forEachChild(node, visit2);
7951
8116
  }
7952
8117
  visit2(sf);
7953
8118
  return found;
@@ -8005,7 +8170,8 @@ var BROWSER_ONLY_CLIENT_APIS = new Set([
8005
8170
  "createPortal",
8006
8171
  "isSSRPortal",
8007
8172
  "findSiblingSlot",
8008
- "cleanupPortalPlaceholder"
8173
+ "cleanupPortalPlaceholder",
8174
+ "trackPosition"
8009
8175
  ]);
8010
8176
  function importsBrowserOnlyClientApi(ctx) {
8011
8177
  for (const imp of ctx.imports) {
@@ -8024,11 +8190,11 @@ function importsBrowserOnlyClientApi(ctx) {
8024
8190
  return false;
8025
8191
  }
8026
8192
  function listComponentFunctions(source, filePath) {
8027
- const sourceFile = ts10.createSourceFile(filePath, source, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
8193
+ const sourceFile = ts11.createSourceFile(filePath, source, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
8028
8194
  return listComponentFunctionsFromSourceFile(sourceFile);
8029
8195
  }
8030
8196
  function scanComponentFile(source, filePath) {
8031
- const sourceFile = ts10.createSourceFile(filePath, source, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
8197
+ const sourceFile = ts11.createSourceFile(filePath, source, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
8032
8198
  return {
8033
8199
  exports: listComponentFunctionsFromSourceFile(sourceFile),
8034
8200
  referencedComponents: [...collectJsxComponentTags(sourceFile)]
@@ -8036,11 +8202,11 @@ function scanComponentFile(source, filePath) {
8036
8202
  }
8037
8203
  function listComponentFunctionsFromSourceFile(sourceFile) {
8038
8204
  const componentNames = [];
8039
- const hasUseClient = sourceFile.statements.some((stmt) => ts10.isExpressionStatement(stmt) && ts10.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
8205
+ const hasUseClient = sourceFile.statements.some((stmt) => ts11.isExpressionStatement(stmt) && ts11.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
8040
8206
  const namedExports = collectNamedExports(sourceFile);
8041
8207
  function collectComponents(node) {
8042
8208
  if (isComponentFunction(node)) {
8043
- const hasInlineExport = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
8209
+ const hasInlineExport = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
8044
8210
  const hasNamedExport = namedExports.has(node.name.text);
8045
8211
  const isExported = hasInlineExport || hasNamedExport;
8046
8212
  if (!hasUseClient && !isExported && node.body && isMultiReturnJsxFunctionBody(node.body)) {} else {
@@ -8050,9 +8216,9 @@ function listComponentFunctionsFromSourceFile(sourceFile) {
8050
8216
  if (isArrowComponentFunction(node)) {
8051
8217
  componentNames.push(node.name.text);
8052
8218
  }
8053
- ts10.forEachChild(node, collectComponents);
8219
+ ts11.forEachChild(node, collectComponents);
8054
8220
  }
8055
- ts10.forEachChild(sourceFile, collectComponents);
8221
+ ts11.forEachChild(sourceFile, collectComponents);
8056
8222
  return componentNames;
8057
8223
  }
8058
8224
  var REACTIVE_PRIMITIVES = new Set([
@@ -8064,13 +8230,13 @@ var REACTIVE_PRIMITIVES = new Set([
8064
8230
  "onCleanup"
8065
8231
  ]);
8066
8232
  function prescanReactiveFactoriesInSource(source, filePath) {
8067
- const sourceFile = ts10.createSourceFile(filePath + ".prescan", source, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
8233
+ const sourceFile = ts11.createSourceFile(filePath + ".prescan", source, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
8068
8234
  const factories = new Map;
8069
8235
  const declined = new Map;
8070
8236
  const reactiveShaped = new Set;
8071
8237
  const cleanFactoryImports = new Set;
8072
8238
  function visitTop(node) {
8073
- if (ts10.isFunctionDeclaration(node) && node.name && node.body) {
8239
+ if (ts11.isFunctionDeclaration(node) && node.name && node.body) {
8074
8240
  const det = detectReactiveFactory(node, sourceFile, filePath);
8075
8241
  if (!det)
8076
8242
  return;
@@ -8087,7 +8253,7 @@ function prescanReactiveFactoriesInSource(source, filePath) {
8087
8253
  }
8088
8254
  }
8089
8255
  }
8090
- ts10.forEachChild(sourceFile, visitTop);
8256
+ ts11.forEachChild(sourceFile, visitTop);
8091
8257
  const result = { factories, declined, reactiveShaped, cleanFactoryImports, sourceFile };
8092
8258
  prescanImportedReactiveFactories(sourceFile, filePath, result);
8093
8259
  return result;
@@ -8104,15 +8270,15 @@ function toComponentRelativeSpecifier(resolvedAbs, componentFilePath) {
8104
8270
  function buildEntryImportIndex(sf, filePath) {
8105
8271
  const index = new Map;
8106
8272
  for (const stmt of sf.statements) {
8107
- if (!ts10.isImportDeclaration(stmt))
8273
+ if (!ts11.isImportDeclaration(stmt))
8108
8274
  continue;
8109
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
8275
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
8110
8276
  continue;
8111
8277
  const src = stmt.moduleSpecifier.text;
8112
8278
  const targetKey = src.startsWith("./") || src.startsWith("../") ? resolveRelativeImportToFile(src, filePath) ?? "unresolved:" + src : src;
8113
8279
  const wholeTypeOnly = stmt.importClause?.isTypeOnly === true;
8114
8280
  const namedBindings = stmt.importClause?.namedBindings;
8115
- if (namedBindings && ts10.isNamedImports(namedBindings)) {
8281
+ if (namedBindings && ts11.isNamedImports(namedBindings)) {
8116
8282
  for (const el of namedBindings.elements) {
8117
8283
  index.set(el.name.text, {
8118
8284
  targetKey,
@@ -8127,31 +8293,31 @@ function buildEntryImportIndex(sf, filePath) {
8127
8293
  function collectEntryBindingNames(sf) {
8128
8294
  const names = new Set;
8129
8295
  function visit2(node) {
8130
- if (ts10.isImportDeclaration(node) && node.importClause) {
8296
+ if (ts11.isImportDeclaration(node) && node.importClause) {
8131
8297
  if (node.importClause.name)
8132
8298
  names.add(node.importClause.name.text);
8133
8299
  const namedBindings = node.importClause.namedBindings;
8134
- if (namedBindings && ts10.isNamedImports(namedBindings)) {
8300
+ if (namedBindings && ts11.isNamedImports(namedBindings)) {
8135
8301
  for (const el of namedBindings.elements)
8136
8302
  names.add(el.name.text);
8137
8303
  }
8138
- if (namedBindings && ts10.isNamespaceImport(namedBindings)) {
8304
+ if (namedBindings && ts11.isNamespaceImport(namedBindings)) {
8139
8305
  names.add(namedBindings.name.text);
8140
8306
  }
8141
8307
  }
8142
- if (ts10.isVariableDeclaration(node)) {
8308
+ if (ts11.isVariableDeclaration(node)) {
8143
8309
  const out = [];
8144
8310
  addBindingNames(node.name, out);
8145
8311
  for (const n of out)
8146
8312
  names.add(n);
8147
8313
  }
8148
- if ((ts10.isFunctionDeclaration(node) || ts10.isClassDeclaration(node) || ts10.isEnumDeclaration(node)) && node.name) {
8314
+ if ((ts11.isFunctionDeclaration(node) || ts11.isClassDeclaration(node) || ts11.isEnumDeclaration(node)) && node.name) {
8149
8315
  names.add(node.name.text);
8150
8316
  }
8151
- if ((ts10.isTypeAliasDeclaration(node) || ts10.isInterfaceDeclaration(node)) && node.name) {
8317
+ if ((ts11.isTypeAliasDeclaration(node) || ts11.isInterfaceDeclaration(node)) && node.name) {
8152
8318
  names.add(node.name.text);
8153
8319
  }
8154
- if (ts10.isFunctionLike(node)) {
8320
+ if (ts11.isFunctionLike(node)) {
8155
8321
  for (const p of node.parameters) {
8156
8322
  const out = [];
8157
8323
  addBindingNames(p.name, out);
@@ -8159,7 +8325,7 @@ function collectEntryBindingNames(sf) {
8159
8325
  names.add(n);
8160
8326
  }
8161
8327
  }
8162
- ts10.forEachChild(node, visit2);
8328
+ ts11.forEachChild(node, visit2);
8163
8329
  }
8164
8330
  visit2(sf);
8165
8331
  return names;
@@ -8168,19 +8334,19 @@ var MAX_REEXPORT_HOPS = 1;
8168
8334
  function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8169
8335
  const candidateCallees = new Set;
8170
8336
  function collectCandidates(node) {
8171
- if (ts10.isVariableDeclaration(node) && (ts10.isArrayBindingPattern(node.name) || ts10.isObjectBindingPattern(node.name)) && node.initializer && ts10.isCallExpression(node.initializer) && ts10.isIdentifier(node.initializer.expression)) {
8337
+ if (ts11.isVariableDeclaration(node) && (ts11.isArrayBindingPattern(node.name) || ts11.isObjectBindingPattern(node.name)) && node.initializer && ts11.isCallExpression(node.initializer) && ts11.isIdentifier(node.initializer.expression)) {
8172
8338
  candidateCallees.add(node.initializer.expression.text);
8173
8339
  }
8174
- ts10.forEachChild(node, collectCandidates);
8340
+ ts11.forEachChild(node, collectCandidates);
8175
8341
  }
8176
8342
  collectCandidates(entrySourceFile);
8177
8343
  if (candidateCallees.size === 0)
8178
8344
  return;
8179
8345
  const importsToCheck = [];
8180
8346
  for (const stmt of entrySourceFile.statements) {
8181
- if (!ts10.isImportDeclaration(stmt))
8347
+ if (!ts11.isImportDeclaration(stmt))
8182
8348
  continue;
8183
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
8349
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
8184
8350
  continue;
8185
8351
  const src = stmt.moduleSpecifier.text;
8186
8352
  if (!src.startsWith("./") && !src.startsWith("../"))
@@ -8188,7 +8354,7 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8188
8354
  if (stmt.importClause?.isTypeOnly)
8189
8355
  continue;
8190
8356
  const namedBindings = stmt.importClause?.namedBindings;
8191
- if (!namedBindings || !ts10.isNamedImports(namedBindings))
8357
+ if (!namedBindings || !ts11.isNamedImports(namedBindings))
8192
8358
  continue;
8193
8359
  const specs = [];
8194
8360
  for (const el of namedBindings.elements) {
@@ -8226,14 +8392,14 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8226
8392
  helperCache.set(abs, "clean");
8227
8393
  return "clean";
8228
8394
  }
8229
- const sf = ts10.createSourceFile(abs + ".prescan", content, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
8395
+ const sf = ts11.createSourceFile(abs + ".prescan", content, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
8230
8396
  const localFns = new Map;
8231
8397
  const exportedFns = new Map;
8232
8398
  for (const stmt of sf.statements) {
8233
- if (ts10.isFunctionDeclaration(stmt) && stmt.name && stmt.body) {
8399
+ if (ts11.isFunctionDeclaration(stmt) && stmt.name && stmt.body) {
8234
8400
  localFns.set(stmt.name.text, stmt);
8235
- const hasExportModifier = stmt.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
8236
- const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DefaultKeyword) ?? false;
8401
+ const hasExportModifier = stmt.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
8402
+ const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DefaultKeyword) ?? false;
8237
8403
  if (hasExportModifier && !hasDefaultModifier) {
8238
8404
  exportedFns.set(stmt.name.text, stmt);
8239
8405
  }
@@ -8242,10 +8408,10 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8242
8408
  const reexports = new Map;
8243
8409
  let hasStarReexport = false;
8244
8410
  for (const stmt of sf.statements) {
8245
- if (!ts10.isExportDeclaration(stmt) || stmt.isTypeOnly)
8411
+ if (!ts11.isExportDeclaration(stmt) || stmt.isTypeOnly)
8246
8412
  continue;
8247
8413
  if (!stmt.moduleSpecifier) {
8248
- if (stmt.exportClause && ts10.isNamedExports(stmt.exportClause)) {
8414
+ if (stmt.exportClause && ts11.isNamedExports(stmt.exportClause)) {
8249
8415
  for (const el of stmt.exportClause.elements) {
8250
8416
  if (el.isTypeOnly)
8251
8417
  continue;
@@ -8256,9 +8422,9 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8256
8422
  }
8257
8423
  continue;
8258
8424
  }
8259
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
8425
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
8260
8426
  continue;
8261
- if (stmt.exportClause && ts10.isNamedExports(stmt.exportClause)) {
8427
+ if (stmt.exportClause && ts11.isNamedExports(stmt.exportClause)) {
8262
8428
  for (const el of stmt.exportClause.elements) {
8263
8429
  if (el.isTypeOnly)
8264
8430
  continue;
@@ -8408,7 +8574,7 @@ function collectHelperModuleValueBindings(sf) {
8408
8574
  const importedTypes = new Map;
8409
8575
  const imported = new Map;
8410
8576
  for (const stmt of sf.statements) {
8411
- if (ts10.isVariableStatement(stmt)) {
8577
+ if (ts11.isVariableStatement(stmt)) {
8412
8578
  const out = [];
8413
8579
  for (const decl of stmt.declarationList.declarations) {
8414
8580
  addBindingNames(decl.name, out);
@@ -8417,16 +8583,16 @@ function collectHelperModuleValueBindings(sf) {
8417
8583
  local.add(n);
8418
8584
  continue;
8419
8585
  }
8420
- if ((ts10.isFunctionDeclaration(stmt) || ts10.isClassDeclaration(stmt) || ts10.isEnumDeclaration(stmt)) && stmt.name) {
8586
+ if ((ts11.isFunctionDeclaration(stmt) || ts11.isClassDeclaration(stmt) || ts11.isEnumDeclaration(stmt)) && stmt.name) {
8421
8587
  local.add(stmt.name.text);
8422
8588
  continue;
8423
8589
  }
8424
- if ((ts10.isTypeAliasDeclaration(stmt) || ts10.isInterfaceDeclaration(stmt)) && stmt.name) {
8590
+ if ((ts11.isTypeAliasDeclaration(stmt) || ts11.isInterfaceDeclaration(stmt)) && stmt.name) {
8425
8591
  localTypes.add(stmt.name.text);
8426
8592
  continue;
8427
8593
  }
8428
- if (ts10.isImportDeclaration(stmt)) {
8429
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
8594
+ if (ts11.isImportDeclaration(stmt)) {
8595
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
8430
8596
  continue;
8431
8597
  const src = stmt.moduleSpecifier.text;
8432
8598
  if (src === "@barefootjs/client" || src === "@barefootjs/client/runtime")
@@ -8435,7 +8601,7 @@ function collectHelperModuleValueBindings(sf) {
8435
8601
  if (stmt.importClause?.name)
8436
8602
  (wholeTypeOnly ? localTypes : local).add(stmt.importClause.name.text);
8437
8603
  const namedBindings = stmt.importClause?.namedBindings;
8438
- if (namedBindings && ts10.isNamedImports(namedBindings)) {
8604
+ if (namedBindings && ts11.isNamedImports(namedBindings)) {
8439
8605
  for (const el of namedBindings.elements) {
8440
8606
  const entry = { source: src, exportedName: (el.propertyName ?? el.name).text };
8441
8607
  if (wholeTypeOnly || el.isTypeOnly)
@@ -8444,7 +8610,7 @@ function collectHelperModuleValueBindings(sf) {
8444
8610
  imported.set(el.name.text, entry);
8445
8611
  }
8446
8612
  }
8447
- if (namedBindings && ts10.isNamespaceImport(namedBindings)) {
8613
+ if (namedBindings && ts11.isNamespaceImport(namedBindings)) {
8448
8614
  (wholeTypeOnly ? localTypes : local).add(namedBindings.name.text);
8449
8615
  }
8450
8616
  }
@@ -8511,11 +8677,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
8511
8677
  function checkForReactive(n) {
8512
8678
  if (hasReactiveCall)
8513
8679
  return;
8514
- if (ts10.isCallExpression(n) && ts10.isIdentifier(n.expression) && REACTIVE_PRIMITIVES.has(n.expression.text)) {
8680
+ if (ts11.isCallExpression(n) && ts11.isIdentifier(n.expression) && REACTIVE_PRIMITIVES.has(n.expression.text)) {
8515
8681
  hasReactiveCall = true;
8516
8682
  return;
8517
8683
  }
8518
- ts10.forEachChild(n, checkForReactive);
8684
+ ts11.forEachChild(n, checkForReactive);
8519
8685
  }
8520
8686
  checkForReactive(node.body);
8521
8687
  if (!hasReactiveCall)
@@ -8523,29 +8689,29 @@ function detectReactiveFactory(node, sourceFile, filePath) {
8523
8689
  const loc = getSourceLocation(node, sourceFile, filePath);
8524
8690
  let totalReturnCount = 0;
8525
8691
  function countReturns(n) {
8526
- if (ts10.isFunctionLike(n))
8692
+ if (ts11.isFunctionLike(n))
8527
8693
  return;
8528
- if (ts10.isReturnStatement(n)) {
8694
+ if (ts11.isReturnStatement(n)) {
8529
8695
  totalReturnCount++;
8530
8696
  return;
8531
8697
  }
8532
- ts10.forEachChild(n, countReturns);
8698
+ ts11.forEachChild(n, countReturns);
8533
8699
  }
8534
- ts10.forEachChild(node.body, countReturns);
8700
+ ts11.forEachChild(node.body, countReturns);
8535
8701
  let returnExpr = null;
8536
8702
  let returnCount = 0;
8537
8703
  for (const stmt of node.body.statements) {
8538
- if (!ts10.isReturnStatement(stmt))
8704
+ if (!ts11.isReturnStatement(stmt))
8539
8705
  continue;
8540
8706
  returnCount++;
8541
8707
  if (!stmt.expression)
8542
8708
  return { kind: "reactive-shaped" };
8543
8709
  let expr = stmt.expression;
8544
- while (ts10.isParenthesizedExpression(expr))
8710
+ while (ts11.isParenthesizedExpression(expr))
8545
8711
  expr = expr.expression;
8546
- if (ts10.isAsExpression(expr))
8712
+ if (ts11.isAsExpression(expr))
8547
8713
  expr = expr.expression;
8548
- if (ts10.isTypeAssertionExpression(expr))
8714
+ if (ts11.isTypeAssertionExpression(expr))
8549
8715
  expr = expr.expression;
8550
8716
  returnExpr = expr;
8551
8717
  }
@@ -8553,18 +8719,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
8553
8719
  return { kind: "reactive-shaped" };
8554
8720
  const returnTupleIdentifiers = [];
8555
8721
  let returnKind;
8556
- if (ts10.isArrayLiteralExpression(returnExpr)) {
8722
+ if (ts11.isArrayLiteralExpression(returnExpr)) {
8557
8723
  returnKind = "tuple";
8558
8724
  for (const el of returnExpr.elements) {
8559
- if (!ts10.isIdentifier(el))
8725
+ if (!ts11.isIdentifier(el))
8560
8726
  return { kind: "reactive-shaped" };
8561
8727
  returnTupleIdentifiers.push(el.text);
8562
8728
  }
8563
8729
  if (returnTupleIdentifiers.length === 0)
8564
8730
  return { kind: "reactive-shaped" };
8565
- } else if (ts10.isObjectLiteralExpression(returnExpr)) {
8731
+ } else if (ts11.isObjectLiteralExpression(returnExpr)) {
8566
8732
  returnKind = "object";
8567
- const hasNonShorthand = returnExpr.properties.some((p) => !ts10.isShorthandPropertyAssignment(p));
8733
+ const hasNonShorthand = returnExpr.properties.some((p) => !ts11.isShorthandPropertyAssignment(p));
8568
8734
  if (hasNonShorthand) {
8569
8735
  return {
8570
8736
  kind: "declined",
@@ -8585,7 +8751,7 @@ function detectReactiveFactory(node, sourceFile, filePath) {
8585
8751
  }
8586
8752
  const params = [];
8587
8753
  for (const p of node.parameters) {
8588
- if (ts10.isIdentifier(p.name)) {
8754
+ if (ts11.isIdentifier(p.name)) {
8589
8755
  params.push(p.name.text);
8590
8756
  continue;
8591
8757
  }
@@ -8593,11 +8759,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
8593
8759
  }
8594
8760
  const localBindings = [];
8595
8761
  for (const stmt of node.body.statements) {
8596
- if (ts10.isVariableStatement(stmt)) {
8762
+ if (ts11.isVariableStatement(stmt)) {
8597
8763
  for (const decl of stmt.declarationList.declarations) {
8598
8764
  addBindingNames(decl.name, localBindings);
8599
8765
  }
8600
- } else if (ts10.isFunctionDeclaration(stmt) && stmt.name) {
8766
+ } else if (ts11.isFunctionDeclaration(stmt) && stmt.name) {
8601
8767
  localBindings.push(stmt.name.text);
8602
8768
  }
8603
8769
  }
@@ -8617,47 +8783,47 @@ function detectReactiveFactory(node, sourceFile, filePath) {
8617
8783
  if (!relevantNames.has(id.text))
8618
8784
  return;
8619
8785
  const p = id.parent;
8620
- if (ts10.isPropertyAccessExpression(p) && p.name === id)
8786
+ if (ts11.isPropertyAccessExpression(p) && p.name === id)
8621
8787
  return;
8622
- if (ts10.isPropertyAssignment(p) && p.name === id)
8788
+ if (ts11.isPropertyAssignment(p) && p.name === id)
8623
8789
  return;
8624
- if (ts10.isBindingElement(p) && p.propertyName === id)
8790
+ if (ts11.isBindingElement(p) && p.propertyName === id)
8625
8791
  return;
8626
- if ((ts10.isMethodDeclaration(p) || ts10.isGetAccessorDeclaration(p) || ts10.isSetAccessorDeclaration(p) || ts10.isPropertyDeclaration(p) || ts10.isEnumMember(p)) && p.name === id)
8792
+ if ((ts11.isMethodDeclaration(p) || ts11.isGetAccessorDeclaration(p) || ts11.isSetAccessorDeclaration(p) || ts11.isPropertyDeclaration(p) || ts11.isEnumMember(p)) && p.name === id)
8627
8793
  return;
8628
- if (ts10.isJsxAttribute(p) && p.name === id)
8794
+ if (ts11.isJsxAttribute(p) && p.name === id)
8629
8795
  return;
8630
- if (ts10.isLabeledStatement(p) && p.label === id || (ts10.isBreakStatement(p) || ts10.isContinueStatement(p)) && p.label === id)
8796
+ if (ts11.isLabeledStatement(p) && p.label === id || (ts11.isBreakStatement(p) || ts11.isContinueStatement(p)) && p.label === id)
8631
8797
  return;
8632
- if ((ts10.isJsxOpeningElement(p) || ts10.isJsxSelfClosingElement(p) || ts10.isJsxClosingElement(p)) && p.tagName === id && /^[a-z]/.test(id.text))
8798
+ if ((ts11.isJsxOpeningElement(p) || ts11.isJsxSelfClosingElement(p) || ts11.isJsxClosingElement(p)) && p.tagName === id && /^[a-z]/.test(id.text))
8633
8799
  return;
8634
- if (ts10.isShorthandPropertyAssignment(p) && p.name === id) {
8800
+ if (ts11.isShorthandPropertyAssignment(p) && p.name === id) {
8635
8801
  push(id, "shorthand");
8636
8802
  return;
8637
8803
  }
8638
- if (ts10.isBindingElement(p) && p.name === id && !p.propertyName && ts10.isObjectBindingPattern(p.parent)) {
8804
+ if (ts11.isBindingElement(p) && p.name === id && !p.propertyName && ts11.isObjectBindingPattern(p.parent)) {
8639
8805
  if (params.includes(id.text))
8640
8806
  shadowedParam = id.text;
8641
8807
  push(id, "shorthand");
8642
8808
  return;
8643
8809
  }
8644
- 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;
8810
+ 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;
8645
8811
  if (isDecl && params.includes(id.text))
8646
8812
  shadowedParam = id.text;
8647
8813
  push(id, "plain");
8648
8814
  }
8649
8815
  function visit2(n) {
8650
- if (ts10.isTypeNode(n) || ts10.isTypeParameterDeclaration(n) || ts10.isTypeAliasDeclaration(n) || ts10.isInterfaceDeclaration(n))
8816
+ if (ts11.isTypeNode(n) || ts11.isTypeParameterDeclaration(n) || ts11.isTypeAliasDeclaration(n) || ts11.isInterfaceDeclaration(n))
8651
8817
  return;
8652
- if (ts10.isIdentifier(n)) {
8818
+ if (ts11.isIdentifier(n)) {
8653
8819
  classify(n);
8654
8820
  return;
8655
8821
  }
8656
- ts10.forEachChild(n, visit2);
8822
+ ts11.forEachChild(n, visit2);
8657
8823
  }
8658
8824
  visit2(root);
8659
8825
  }
8660
- const keptStatements = node.body.statements.filter((s) => !ts10.isReturnStatement(s));
8826
+ const keptStatements = node.body.statements.filter((s) => !ts11.isReturnStatement(s));
8661
8827
  const pieces = [];
8662
8828
  let base = 0;
8663
8829
  for (const stmt of keptStatements) {
@@ -8705,18 +8871,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
8705
8871
  };
8706
8872
  }
8707
8873
  function addBindingNames(name, out) {
8708
- if (ts10.isIdentifier(name)) {
8874
+ if (ts11.isIdentifier(name)) {
8709
8875
  out.push(name.text);
8710
8876
  return;
8711
8877
  }
8712
- if (ts10.isObjectBindingPattern(name)) {
8878
+ if (ts11.isObjectBindingPattern(name)) {
8713
8879
  for (const el of name.elements)
8714
8880
  addBindingNames(el.name, out);
8715
8881
  return;
8716
8882
  }
8717
- if (ts10.isArrayBindingPattern(name)) {
8883
+ if (ts11.isArrayBindingPattern(name)) {
8718
8884
  for (const el of name.elements) {
8719
- if (ts10.isOmittedExpression(el))
8885
+ if (ts11.isOmittedExpression(el))
8720
8886
  continue;
8721
8887
  addBindingNames(el.name, out);
8722
8888
  }
@@ -8728,33 +8894,33 @@ function rewriteFactoryCallsInSource(source, prescan) {
8728
8894
  let callSiteIndex = 0;
8729
8895
  const inlinedFactories = new Set;
8730
8896
  function visitStmt(node, inComponent) {
8731
- if (ts10.isVariableStatement(node) && inComponent) {
8897
+ if (ts11.isVariableStatement(node) && inComponent) {
8732
8898
  for (const decl of node.declarationList.declarations) {
8733
8899
  maybeRewriteDecl(node, decl);
8734
8900
  }
8735
8901
  }
8736
- ts10.forEachChild(node, (child) => {
8737
- if (ts10.isFunctionDeclaration(child) && child.name && factories.has(child.name.text))
8902
+ ts11.forEachChild(node, (child) => {
8903
+ if (ts11.isFunctionDeclaration(child) && child.name && factories.has(child.name.text))
8738
8904
  return;
8739
8905
  visitStmt(child, inComponent || isPascalCaseComponentFn(child));
8740
8906
  });
8741
8907
  }
8742
8908
  function maybeRewriteDecl(stmt, decl) {
8743
- if (!decl.initializer || !ts10.isCallExpression(decl.initializer))
8909
+ if (!decl.initializer || !ts11.isCallExpression(decl.initializer))
8744
8910
  return;
8745
- if (!ts10.isIdentifier(decl.initializer.expression))
8911
+ if (!ts11.isIdentifier(decl.initializer.expression))
8746
8912
  return;
8747
8913
  const factoryName = decl.initializer.expression.text;
8748
8914
  const factory = factories.get(factoryName);
8749
8915
  if (!factory)
8750
8916
  return;
8751
- if (ts10.isArrayBindingPattern(decl.name)) {
8917
+ if (ts11.isArrayBindingPattern(decl.name)) {
8752
8918
  if (factory.returnKind !== "tuple")
8753
8919
  return;
8754
8920
  rewriteTupleDecl(stmt, decl.name, decl.initializer, factory);
8755
8921
  return;
8756
8922
  }
8757
- if (ts10.isObjectBindingPattern(decl.name)) {
8923
+ if (ts11.isObjectBindingPattern(decl.name)) {
8758
8924
  if (factory.returnKind !== "object")
8759
8925
  return;
8760
8926
  rewriteObjectDecl(stmt, decl.name, decl.initializer, factory);
@@ -8767,7 +8933,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
8767
8933
  return;
8768
8934
  const callerNames = [];
8769
8935
  for (const el of elements) {
8770
- if (ts10.isOmittedExpression(el) || !ts10.isIdentifier(el.name))
8936
+ if (ts11.isOmittedExpression(el) || !ts11.isIdentifier(el.name))
8771
8937
  return;
8772
8938
  callerNames.push(el.name.text);
8773
8939
  }
@@ -8789,7 +8955,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
8789
8955
  return;
8790
8956
  if (el.initializer)
8791
8957
  return;
8792
- if (!ts10.isIdentifier(el.name))
8958
+ if (!ts11.isIdentifier(el.name))
8793
8959
  return;
8794
8960
  if (!factory.returnTupleIdentifiers.includes(el.name.text))
8795
8961
  return;
@@ -8898,21 +9064,21 @@ function factoryImportInsertionOffset(sf) {
8898
9064
  let lastImportEnd = -1;
8899
9065
  let directiveEnd = -1;
8900
9066
  for (const stmt of sf.statements) {
8901
- if (ts10.isImportDeclaration(stmt)) {
9067
+ if (ts11.isImportDeclaration(stmt)) {
8902
9068
  lastImportEnd = stmt.getEnd();
8903
9069
  continue;
8904
9070
  }
8905
- if (directiveEnd === -1 && ts10.isExpressionStatement(stmt) && ts10.isStringLiteral(stmt.expression) && stmt.expression.text === "use client") {
9071
+ if (directiveEnd === -1 && ts11.isExpressionStatement(stmt) && ts11.isStringLiteral(stmt.expression) && stmt.expression.text === "use client") {
8906
9072
  directiveEnd = stmt.getEnd();
8907
9073
  }
8908
9074
  }
8909
9075
  return lastImportEnd >= 0 ? lastImportEnd : directiveEnd >= 0 ? directiveEnd : 0;
8910
9076
  }
8911
9077
  function isPascalCaseComponentFn(node) {
8912
- if (ts10.isFunctionDeclaration(node) && node.name) {
9078
+ if (ts11.isFunctionDeclaration(node) && node.name) {
8913
9079
  return /^[A-Z]/.test(node.name.text);
8914
9080
  }
8915
- if (ts10.isVariableDeclaration(node) && ts10.isIdentifier(node.name) && node.initializer && ts10.isArrowFunction(node.initializer)) {
9081
+ if (ts11.isVariableDeclaration(node) && ts11.isIdentifier(node.name) && node.initializer && ts11.isArrowFunction(node.initializer)) {
8916
9082
  return /^[A-Z]/.test(node.name.text);
8917
9083
  }
8918
9084
  return false;
@@ -8941,20 +9107,20 @@ function declinedFactoryErrorCode(code) {
8941
9107
  function validateReactiveFactoryCalls(ctx) {
8942
9108
  if (!ctx.componentNode)
8943
9109
  return;
8944
- const body = ts10.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : ts10.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
9110
+ const body = ts11.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : ts11.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
8945
9111
  if (!body)
8946
9112
  return;
8947
9113
  for (const stmt of body.statements) {
8948
- if (!ts10.isVariableStatement(stmt))
9114
+ if (!ts11.isVariableStatement(stmt))
8949
9115
  continue;
8950
9116
  for (const decl of stmt.declarationList.declarations) {
8951
- if (!decl.initializer || !ts10.isCallExpression(decl.initializer))
9117
+ if (!decl.initializer || !ts11.isCallExpression(decl.initializer))
8952
9118
  continue;
8953
- if (!ts10.isIdentifier(decl.initializer.expression))
9119
+ if (!ts11.isIdentifier(decl.initializer.expression))
8954
9120
  continue;
8955
9121
  const callee = decl.initializer.expression.text;
8956
9122
  const loc = getSourceLocation(stmt, ctx.sourceFile, ctx.filePath);
8957
- if (ts10.isArrayBindingPattern(decl.name)) {
9123
+ if (ts11.isArrayBindingPattern(decl.name)) {
8958
9124
  if (callee === "createSignal" || callee === "createMemo")
8959
9125
  continue;
8960
9126
  if (resolveEnvSignalKey(decl.initializer, ctx))
@@ -8981,7 +9147,7 @@ function validateReactiveFactoryCalls(ctx) {
8981
9147
  }));
8982
9148
  continue;
8983
9149
  }
8984
- if (ts10.isObjectBindingPattern(decl.name)) {
9150
+ if (ts11.isObjectBindingPattern(decl.name)) {
8985
9151
  validateObjectFactoryDestructure(ctx, decl.name, callee, loc);
8986
9152
  }
8987
9153
  }
@@ -8990,25 +9156,25 @@ function validateReactiveFactoryCalls(ctx) {
8990
9156
  function validateNamespaceQualifiedPrimitives(ctx) {
8991
9157
  if (!ctx.componentNode)
8992
9158
  return;
8993
- const body = ts10.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : ts10.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
9159
+ const body = ts11.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : ts11.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
8994
9160
  if (!body)
8995
9161
  return;
8996
9162
  for (const stmt of body.statements) {
8997
9163
  const calls = [];
8998
- if (ts10.isVariableStatement(stmt)) {
9164
+ if (ts11.isVariableStatement(stmt)) {
8999
9165
  for (const decl of stmt.declarationList.declarations) {
9000
9166
  let init = decl.initializer;
9001
- if (init && ts10.isElementAccessExpression(init))
9167
+ if (init && ts11.isElementAccessExpression(init))
9002
9168
  init = init.expression;
9003
- if (init && ts10.isCallExpression(init))
9169
+ if (init && ts11.isCallExpression(init))
9004
9170
  calls.push(init);
9005
9171
  }
9006
- } else if (ts10.isExpressionStatement(stmt) && ts10.isCallExpression(stmt.expression)) {
9172
+ } else if (ts11.isExpressionStatement(stmt) && ts11.isCallExpression(stmt.expression)) {
9007
9173
  calls.push(stmt.expression);
9008
9174
  }
9009
9175
  for (const call of calls) {
9010
9176
  const callee = call.expression;
9011
- if (!ts10.isPropertyAccessExpression(callee) || !ts10.isIdentifier(callee.expression))
9177
+ if (!ts11.isPropertyAccessExpression(callee) || !ts11.isIdentifier(callee.expression))
9012
9178
  continue;
9013
9179
  const primitive = callee.name.text;
9014
9180
  if (!(primitive in PRIMITIVE_CANONICAL_NAMES))
@@ -9041,11 +9207,11 @@ function isNamespaceNameShadowedAtComponentTopLevel(name, body, ctx) {
9041
9207
  if (ctx.propsParams.some((p) => p.name === name))
9042
9208
  return true;
9043
9209
  for (const stmt of body.statements) {
9044
- if (ts10.isFunctionDeclaration(stmt) && stmt.name?.text === name)
9210
+ if (ts11.isFunctionDeclaration(stmt) && stmt.name?.text === name)
9045
9211
  return true;
9046
- if (ts10.isVariableStatement(stmt)) {
9212
+ if (ts11.isVariableStatement(stmt)) {
9047
9213
  for (const decl of stmt.declarationList.declarations) {
9048
- if (ts10.isIdentifier(decl.name) && decl.name.text === name)
9214
+ if (ts11.isIdentifier(decl.name) && decl.name.text === name)
9049
9215
  return true;
9050
9216
  }
9051
9217
  }
@@ -9062,7 +9228,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
9062
9228
  }));
9063
9229
  return;
9064
9230
  }
9065
- const hasUnsupportedElement = pattern.elements.some((el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !ts10.isIdentifier(el.name));
9231
+ const hasUnsupportedElement = pattern.elements.some((el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !ts11.isIdentifier(el.name));
9066
9232
  if (hasUnsupportedElement) {
9067
9233
  ctx.errors.push(createError(ErrorCodes.REACTIVE_FACTORY_RENAME_UNSUPPORTED, loc, {
9068
9234
  severity: "error",
@@ -9070,7 +9236,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
9070
9236
  }));
9071
9237
  return;
9072
9238
  }
9073
- const unknown = pattern.elements.map((el) => ts10.isIdentifier(el.name) ? el.name.text : "").filter((name) => name && !factory.returnTupleIdentifiers.includes(name));
9239
+ const unknown = pattern.elements.map((el) => ts11.isIdentifier(el.name) ? el.name.text : "").filter((name) => name && !factory.returnTupleIdentifiers.includes(name));
9074
9240
  if (unknown.length > 0) {
9075
9241
  const label = unknown.length === 1 ? "property" : "properties";
9076
9242
  ctx.errors.push(createError(ErrorCodes.UNRECOGNIZED_REACTIVE_FACTORY, loc, {
@@ -9213,7 +9379,7 @@ function pickAttrMetaFromIR(src) {
9213
9379
  }
9214
9380
 
9215
9381
  // ../jsx/src/module-exports.ts
9216
- import ts11 from "typescript";
9382
+ import ts12 from "typescript";
9217
9383
  function generateModuleExports(ir, extraInlineExported = new Set, rewriteRelativeImport, options) {
9218
9384
  const lines = [];
9219
9385
  for (const constant of options?.skipValueDeclarations ? [] : ir.metadata.localConstants) {
@@ -9314,21 +9480,21 @@ function findAssignedNames(bodyText, candidates) {
9314
9480
  const assigned = new Set;
9315
9481
  if (candidates.size === 0)
9316
9482
  return assigned;
9317
- const sf = ts11.createSourceFile("bf-assignment-scan.tsx", bodyText, ts11.ScriptTarget.Latest, false, ts11.ScriptKind.TSX);
9483
+ const sf = ts12.createSourceFile("bf-assignment-scan.tsx", bodyText, ts12.ScriptTarget.Latest, false, ts12.ScriptKind.TSX);
9318
9484
  const record = (target) => {
9319
- if (ts11.isIdentifier(target) && candidates.has(target.text)) {
9485
+ if (ts12.isIdentifier(target) && candidates.has(target.text)) {
9320
9486
  assigned.add(target.text);
9321
9487
  }
9322
9488
  };
9323
9489
  const visit2 = (node) => {
9324
- if (ts11.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
9490
+ if (ts12.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
9325
9491
  record(node.left);
9326
- } else if ((ts11.isPrefixUnaryExpression(node) || ts11.isPostfixUnaryExpression(node)) && (node.operator === ts11.SyntaxKind.PlusPlusToken || node.operator === ts11.SyntaxKind.MinusMinusToken)) {
9492
+ } else if ((ts12.isPrefixUnaryExpression(node) || ts12.isPostfixUnaryExpression(node)) && (node.operator === ts12.SyntaxKind.PlusPlusToken || node.operator === ts12.SyntaxKind.MinusMinusToken)) {
9327
9493
  record(node.operand);
9328
9494
  }
9329
- ts11.forEachChild(node, visit2);
9495
+ ts12.forEachChild(node, visit2);
9330
9496
  };
9331
- ts11.forEachChild(sf, visit2);
9497
+ ts12.forEachChild(sf, visit2);
9332
9498
  return assigned;
9333
9499
  }
9334
9500
  function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
@@ -9351,7 +9517,7 @@ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNam
9351
9517
  return reachable;
9352
9518
  }
9353
9519
  function isAssignmentOperator(kind) {
9354
- return kind >= ts11.SyntaxKind.FirstAssignment && kind <= ts11.SyntaxKind.LastAssignment;
9520
+ return kind >= ts12.SyntaxKind.FirstAssignment && kind <= ts12.SyntaxKind.LastAssignment;
9355
9521
  }
9356
9522
 
9357
9523
  // ../jsx/src/builtins.ts
@@ -9374,102 +9540,6 @@ function stripClientBuiltinImports(imports) {
9374
9540
  return result;
9375
9541
  }
9376
9542
 
9377
- // ../jsx/src/reactivity-checker.ts
9378
- import ts12 from "typescript";
9379
- var REACTIVE_BRAND = "__reactive";
9380
- function queryType(checker, node) {
9381
- incrementCounter("typeCheckerQueries");
9382
- return checker.getTypeAtLocation(node);
9383
- }
9384
- function isReactiveType(type) {
9385
- return type.getProperty(REACTIVE_BRAND) !== undefined;
9386
- }
9387
- var NOT_REACTIVE = { isReactive: false, reason: { kind: "not-reactive" } };
9388
- function safeGetText(node) {
9389
- try {
9390
- return node.getText();
9391
- } catch {
9392
- return "";
9393
- }
9394
- }
9395
- function analyze(node, checker) {
9396
- if (ts12.isPropertyAccessExpression(node)) {
9397
- try {
9398
- const type = queryType(checker, node);
9399
- if (isReactiveType(type)) {
9400
- return {
9401
- isReactive: true,
9402
- reason: { kind: "brand", via: "property-access", nodeText: safeGetText(node) }
9403
- };
9404
- }
9405
- } catch {}
9406
- const sub = analyze(node.expression, checker);
9407
- if (sub.isReactive) {
9408
- return {
9409
- isReactive: true,
9410
- reason: {
9411
- kind: "child",
9412
- via: "property-access-object",
9413
- childText: safeGetText(node.expression),
9414
- childReason: sub.reason
9415
- }
9416
- };
9417
- }
9418
- return NOT_REACTIVE;
9419
- }
9420
- if (ts12.isIdentifier(node)) {
9421
- try {
9422
- const type = queryType(checker, node);
9423
- if (isReactiveType(type)) {
9424
- return {
9425
- isReactive: true,
9426
- reason: { kind: "brand", via: "identifier", nodeText: safeGetText(node) }
9427
- };
9428
- }
9429
- } catch {}
9430
- return NOT_REACTIVE;
9431
- }
9432
- if (ts12.isCallExpression(node)) {
9433
- try {
9434
- const calleeType = queryType(checker, node.expression);
9435
- if (isReactiveType(calleeType)) {
9436
- return {
9437
- isReactive: true,
9438
- reason: { kind: "brand", via: "callee", nodeText: safeGetText(node) }
9439
- };
9440
- }
9441
- } catch {}
9442
- }
9443
- let foundChild;
9444
- let foundChildText = "";
9445
- ts12.forEachChild(node, (child) => {
9446
- if (foundChild?.isReactive)
9447
- return;
9448
- const result = analyze(child, checker);
9449
- if (result.isReactive) {
9450
- foundChild = result;
9451
- foundChildText = safeGetText(child);
9452
- }
9453
- });
9454
- if (foundChild?.isReactive) {
9455
- return {
9456
- isReactive: true,
9457
- reason: {
9458
- kind: "child",
9459
- via: "sub-expression",
9460
- childText: foundChildText,
9461
- childReason: foundChild.reason
9462
- }
9463
- };
9464
- }
9465
- return NOT_REACTIVE;
9466
- }
9467
- var brandTypeReactivityAnalyzer = { analyze };
9468
- function containsReactiveExpression(node, checker) {
9469
- incrementCounter("reactivityChecks");
9470
- return brandTypeReactivityAnalyzer.analyze(node, checker).isReactive;
9471
- }
9472
-
9473
9543
  // ../jsx/src/free-refs.ts
9474
9544
  import ts13 from "typescript";
9475
9545
  var _bindingMapCache = new WeakMap;
@@ -10213,9 +10283,8 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
10213
10283
  function visit2(n, parent) {
10214
10284
  if (ts14.isIdentifier(n) && propDepsMap.has(n.text)) {
10215
10285
  const isObjectKey = parent && ts14.isPropertyAssignment(parent) && parent.name === n;
10216
- const isShorthand = parent && ts14.isShorthandPropertyAssignment(parent) && parent.name === n;
10217
10286
  const isAccessName = parent && ts14.isPropertyAccessExpression(parent) && parent.name === n;
10218
- if (!isObjectKey && !isShorthand && !isAccessName) {
10287
+ if (!isObjectKey && !isAccessName) {
10219
10288
  const deps = propDepsMap.get(n.text);
10220
10289
  if (deps && deps.size > 0) {
10221
10290
  if (!acc)
@@ -10693,8 +10762,7 @@ function lowerFormControlValueSsr(tagName, attrs, children) {
10693
10762
  children.push({
10694
10763
  type: "expression",
10695
10764
  expr,
10696
- templateExpr: `escapeText(${templateExpr ?? expr})`,
10697
- escapeInClientTemplate: true,
10765
+ templateExpr,
10698
10766
  typeInfo: null,
10699
10767
  reactive: false,
10700
10768
  slotId: null,
@@ -10705,26 +10773,76 @@ function lowerFormControlValueSsr(tagName, attrs, children) {
10705
10773
  }
10706
10774
  const selectedForLiteral = (optValue) => AttrValueOf.expression(`(${expr}) === ${JSON.stringify(optValue)}`, templateExpr !== undefined ? { templateExpr: `(${templateExpr}) === ${JSON.stringify(optValue)}` } : undefined);
10707
10775
  const selectedForExpr = (optExpr, optTemplateExpr) => AttrValueOf.expression(`(${expr}) === (${optExpr})`, templateExpr !== undefined || optTemplateExpr !== undefined ? { templateExpr: `(${templateExpr ?? expr}) === (${optTemplateExpr ?? optExpr})` } : undefined);
10776
+ const matchConditions = [];
10777
+ let optionSetIsDynamic = false;
10708
10778
  const distribute = (nodes) => {
10709
10779
  for (const n of nodes) {
10780
+ if (n.type === "text")
10781
+ continue;
10710
10782
  if (n.type === "element" && n.tag === "option") {
10711
- if (n.attrs.some((a) => a.name === "selected"))
10783
+ if (n.attrs.some((a) => a.name === "selected")) {
10784
+ optionSetIsDynamic = true;
10712
10785
  continue;
10786
+ }
10713
10787
  const optValue = n.attrs.find((a) => a.name === "value");
10714
- if (!optValue)
10788
+ if (!optValue) {
10789
+ optionSetIsDynamic = true;
10715
10790
  continue;
10791
+ }
10716
10792
  if (optValue.value.kind === "literal") {
10717
- n.attrs.push({ name: "selected", value: selectedForLiteral(optValue.value.value), loc: n.loc });
10793
+ const selected = selectedForLiteral(optValue.value.value);
10794
+ n.attrs.push({ name: "selected", value: selected, loc: n.loc });
10795
+ matchConditions.push(selected);
10718
10796
  } else if (optValue.value.kind === "expression") {
10719
10797
  const selected = selectedForExpr(optValue.value.expr, optValue.value.templateExpr);
10720
10798
  n.attrs.push({ name: "selected", value: selected, loc: n.loc });
10799
+ matchConditions.push(selected);
10800
+ } else {
10801
+ optionSetIsDynamic = true;
10721
10802
  }
10722
- } else if (n.type === "fragment" || n.type === "loop" || n.type === "element" && n.tag === "optgroup") {
10803
+ } else if (n.type === "fragment" || n.type === "element" && n.tag === "optgroup") {
10723
10804
  distribute(n.children);
10805
+ } else if (n.type === "loop") {
10806
+ optionSetIsDynamic = true;
10807
+ distribute(n.children);
10808
+ } else {
10809
+ optionSetIsDynamic = true;
10724
10810
  }
10725
10811
  }
10726
10812
  };
10727
10813
  distribute(children);
10814
+ if (optionSetIsDynamic || matchConditions.length === 0)
10815
+ return;
10816
+ if (isMultiSelection(attrs))
10817
+ return;
10818
+ const orExpr = matchConditions.map((c) => `(${c.expr})`).join(" || ");
10819
+ const orTemplateExpr = matchConditions.some((c) => c.templateExpr !== undefined) ? matchConditions.map((c) => `(${c.templateExpr ?? c.expr})`).join(" || ") : undefined;
10820
+ children.unshift({
10821
+ type: "element",
10822
+ tag: "option",
10823
+ attrs: [
10824
+ { name: "value", value: AttrValueOf.literal(""), loc: valueAttr.loc },
10825
+ { name: "disabled", value: AttrValueOf.booleanAttr(), loc: valueAttr.loc },
10826
+ { name: "hidden", value: AttrValueOf.booleanAttr(), loc: valueAttr.loc },
10827
+ {
10828
+ name: "selected",
10829
+ value: AttrValueOf.expression(`!(${orExpr})`, orTemplateExpr !== undefined ? { templateExpr: `!(${orTemplateExpr})` } : undefined),
10830
+ loc: valueAttr.loc
10831
+ }
10832
+ ],
10833
+ events: [],
10834
+ ref: null,
10835
+ children: [],
10836
+ slotId: null,
10837
+ needsScope: false,
10838
+ loc: valueAttr.loc
10839
+ });
10840
+ }
10841
+ function isMultiSelection(attrs) {
10842
+ if (attrs.some((a) => a.name === "multiple"))
10843
+ return true;
10844
+ const sizeAttr = attrs.find((a) => a.name === "size");
10845
+ return sizeAttr?.value.kind === "literal" && Number(sizeAttr.value.value) > 1;
10728
10846
  }
10729
10847
  function transformHtmlElement(node, ctx, tagName) {
10730
10848
  const { attrs, events, ref } = processAttributes(node.openingElement.attributes, ctx);
@@ -11098,7 +11216,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
11098
11216
  }
11099
11217
  const ir = transformJsxExpression(expr, ctx, isClientOnly);
11100
11218
  if (ir !== null) {
11101
- if ((isClientOnly || shouldAutoDeferReactiveBrand(expr, ctx)) && ir.type === "conditional") {
11219
+ if (ir.type === "conditional" && (isClientOnly || shouldAutoDeferReactiveBrand(expr, ctx))) {
11102
11220
  ir.clientOnly = true;
11103
11221
  if (!ir.slotId) {
11104
11222
  ir.slotId = generateSlotId(ctx);
@@ -14045,9 +14163,10 @@ function shouldAutoDeferReactiveBrand(expr, ctx) {
14045
14163
  const checker = ctx.analyzer.checker;
14046
14164
  if (!checker)
14047
14165
  return false;
14048
- if (!containsReactiveExpression(expr, checker))
14166
+ const leaves = collectReactiveBrandLeaves(expr, checker);
14167
+ if (leaves.length === 0)
14049
14168
  return false;
14050
- if (isSignalOrMemoReference(ctx.getJS(expr), ctx))
14169
+ if (leaves.some((leaf) => isSignalOrMemoReference(ctx.getJS(leaf), ctx)))
14051
14170
  return false;
14052
14171
  return true;
14053
14172
  }
@@ -14430,10 +14549,10 @@ function getControlledPropName(signal, propsParams, propsObjectName = null) {
14430
14549
  }
14431
14550
 
14432
14551
  // ../jsx/src/ir-to-client-js/reactivity.ts
14433
- function buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex) {
14552
+ function buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope) {
14434
14553
  if (!loopParam)
14435
14554
  return;
14436
- return BindingScope.EMPTY.enterLoopRow({
14555
+ return (parentScope ?? BindingScope.EMPTY).enterLoopRow({
14437
14556
  param: loopParam,
14438
14557
  paramBindings: loopParamBindings,
14439
14558
  index: loopIndex,
@@ -14507,16 +14626,22 @@ function needsEffectWrapperCore(expr, ctx, freeIdentifiers2, visitedConstants) {
14507
14626
  }
14508
14627
  return false;
14509
14628
  }
14510
- function classifyReactivity(expr, ctx, loopParam, loopParamBindings, freeIdentifiers2) {
14629
+ function classifyReactivity(expr, ctx, scope, freeIdentifiers2) {
14511
14630
  const has = (name) => freeIdentifiers2 ? freeIdentifiers2.has(name) : tokenContainsIdent(expr, name);
14512
- if (loopParamBindings && loopParamBindings.length > 0) {
14513
- for (const b of loopParamBindings) {
14514
- if (has(b.name)) {
14515
- return { kind: "loop-param", param: loopParam ?? b.name };
14631
+ if (scope) {
14632
+ let indexHit;
14633
+ for (const name of scope.valueBoundNames()) {
14634
+ if (!has(name))
14635
+ continue;
14636
+ const source = scope.lookup(name)?.binding.source;
14637
+ if (source === "index") {
14638
+ indexHit ??= name;
14639
+ continue;
14516
14640
  }
14641
+ return { kind: "loop-param", param: name };
14517
14642
  }
14518
- } else if (loopParam && has(loopParam)) {
14519
- return { kind: "loop-param", param: loopParam };
14643
+ if (indexHit)
14644
+ return { kind: "loop-index", param: indexHit };
14520
14645
  }
14521
14646
  if (needsEffectWrapper(expr, ctx, freeIdentifiers2)) {
14522
14647
  return { kind: "signal-or-memo-or-prop" };
@@ -14679,9 +14804,9 @@ function traverseForComponents(node, components, skipConditionals = false) {
14679
14804
  }
14680
14805
  });
14681
14806
  }
14682
- function collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex) {
14807
+ function collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex, parentScope) {
14683
14808
  const texts = [];
14684
- const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
14809
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope);
14685
14810
  walkIR(node, false, {
14686
14811
  ...stopAt("loop", "async", "ifStatement"),
14687
14812
  expression: ({ node: n, scope: insideConditional }) => {
@@ -14691,7 +14816,7 @@ function collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings,
14691
14816
  return;
14692
14817
  const originFreeIds = freeIdsFromRefs(n.origin?.freeRefs);
14693
14818
  const expanded = expandConstantForReactivity(n.expr, ctx, originFreeIds, scope);
14694
- const reactive = classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind !== "none" || decideWrapFromAstFlags(n).wrap;
14819
+ const reactive = classifyReactivity(expanded.expr, ctx, scope, expanded.freeIds).kind !== "none" || decideWrapFromAstFlags(n).wrap;
14695
14820
  if (!reactive)
14696
14821
  return;
14697
14822
  texts.push({
@@ -14714,9 +14839,9 @@ function anyNameIn(names, set) {
14714
14839
  return true;
14715
14840
  return false;
14716
14841
  }
14717
- function collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex) {
14842
+ function collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex, parentScope) {
14718
14843
  const attrs = [];
14719
- const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
14844
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope);
14720
14845
  traverseElements(node, (el) => {
14721
14846
  if (el.slotId) {
14722
14847
  for (const attr of el.attrs) {
@@ -14731,7 +14856,7 @@ function collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings,
14731
14856
  continue;
14732
14857
  const expanded = expandConstantForReactivity(valueStr, ctx, attr.freeIdentifiers, scope);
14733
14858
  const readsPreamble = preambleNames !== undefined && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
14734
- const reactive = classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind !== "none" || readsPreamble || attr.callsReactiveGetters || attr.hasFunctionCalls;
14859
+ const reactive = classifyReactivity(expanded.expr, ctx, scope, expanded.freeIds).kind !== "none" || readsPreamble || attr.callsReactiveGetters || attr.hasFunctionCalls;
14735
14860
  if (!attr.clientOnly && !reactive)
14736
14861
  continue;
14737
14862
  attrs.push({
@@ -15070,7 +15195,9 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
15070
15195
  const flat = options?.flatBranchMode === true;
15071
15196
  const fixedDepth = options?.templateDepth;
15072
15197
  const collectBindings = options?.collectItemBindings === true;
15073
- const initialScope = { parentSlotId: null, depth: 0, insideCond: false };
15198
+ const outerSpec = typeof outerLoopParam === "string" ? { param: outerLoopParam } : outerLoopParam;
15199
+ const outerScope = buildLoopRowScope(outerSpec?.param, outerSpec?.bindings, undefined, outerSpec?.index);
15200
+ const initialScope = { parentSlotId: null, depth: 0, insideCond: false, bindingScope: outerScope };
15074
15201
  for (const root of nodes) {
15075
15202
  walkIR(root, initialScope, {
15076
15203
  element: ({ node: el, scope, descend }) => {
@@ -15086,18 +15213,17 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
15086
15213
  },
15087
15214
  loop: ({ node: n, scope, descend }) => {
15088
15215
  const emitDepth = fixedDepth ?? scope.depth + 1;
15089
- const loopParamsForTemplate = outerLoopParam ? [outerLoopParam, { param: n.param, bindings: n.paramBindings }] : undefined;
15216
+ const loopParamsForTemplate = outerSpec ? [outerSpec, { param: n.param, bindings: n.paramBindings, index: n.index }] : undefined;
15090
15217
  const template = n.children.map((c) => irToPlaceholderTemplate(c, undefined, emitDepth, loopParamsForTemplate)).join("");
15091
- const refsOuter = outerLoopParam ? identifierPattern(outerLoopParam).test(n.array) : false;
15092
15218
  const bindings = emptyLoopChildBindings();
15093
15219
  const innerPreambleNames = preambleNamesOf(n);
15094
15220
  if (ctx) {
15095
15221
  for (const child of n.children) {
15096
- bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx, n.param, n.paramBindings, true, innerPreambleNames, n.index));
15097
- bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx, n.param, n.paramBindings, true, innerPreambleNames, n.index));
15222
+ bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx, n.param, n.paramBindings, true, innerPreambleNames, n.index, scope.bindingScope));
15223
+ bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx, n.param, n.paramBindings, true, innerPreambleNames, n.index, scope.bindingScope));
15098
15224
  bindings.refs.push(...collectLoopChildRefs(child));
15099
15225
  }
15100
- bindings.conditionals.push(...collectLoopChildConditionals({ type: "fragment", children: n.children, loc: n.loc }, ctx, siblingOffsets, n.param, n.paramBindings, innerPreambleNames, n.index));
15226
+ bindings.conditionals.push(...collectLoopChildConditionals({ type: "fragment", children: n.children, loc: n.loc }, ctx, siblingOffsets, n.param, n.paramBindings, innerPreambleNames, n.index, loopParamsForTemplate, scope.bindingScope));
15101
15227
  }
15102
15228
  let childComponents;
15103
15229
  if (collectBindings) {
@@ -15139,14 +15265,17 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
15139
15265
  containerSlotId: scope.parentSlotId,
15140
15266
  template,
15141
15267
  preamble: n.preamble,
15142
- refsOuterParam: refsOuter,
15143
15268
  childComponents,
15144
15269
  insideConditional: !flat && scope.insideCond ? true : undefined,
15145
15270
  offset: flat ? undefined : resolveLoopOffset(siblingOffsets.get(n)),
15146
15271
  bindings
15147
15272
  });
15148
15273
  if (!flat) {
15149
- descend({ ...scope, depth: scope.depth + 1 });
15274
+ descend({
15275
+ ...scope,
15276
+ depth: scope.depth + 1,
15277
+ bindingScope: buildLoopRowScope(n.param, n.paramBindings, innerPreambleNames, n.index, scope.bindingScope)
15278
+ });
15150
15279
  }
15151
15280
  }
15152
15281
  });
@@ -15155,7 +15284,7 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
15155
15284
  }
15156
15285
  function decideLoopRendering(loop, siblingOffsets, ctx) {
15157
15286
  const hasNestedComps = (loop.nestedComponents?.length ?? 0) > 0;
15158
- const innerLoops = collectInnerLoops(loop.children, siblingOffsets, loop.param, ctx);
15287
+ const innerLoops = collectInnerLoops(loop.children, siblingOffsets, { param: loop.param, bindings: loop.paramBindings, index: loop.index }, ctx);
15159
15288
  const hasInnerLoops = (innerLoops?.length ?? 0) > 0;
15160
15289
  const useElementReconciliation = !loop.childComponent && !loop.isStaticArray && (hasNestedComps || hasInnerLoops);
15161
15290
  return { useElementReconciliation, innerLoops };
@@ -15323,6 +15452,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
15323
15452
  }
15324
15453
  const { useElementReconciliation, innerLoops } = projectionInner ? { useElementReconciliation: false, innerLoops: undefined } : decideLoopRendering(l, siblingOffsets, ctx);
15325
15454
  let template = "";
15455
+ let templateIndexed;
15326
15456
  let staticItemTemplate;
15327
15457
  let skeletonTemplate;
15328
15458
  let skeletonPaths;
@@ -15334,6 +15464,10 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
15334
15464
  } else if (l.children[0] && !projectionInner) {
15335
15465
  const loopParamSpec = [{ param: l.param, bindings: l.paramBindings }];
15336
15466
  template = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, loopParamSpec) : irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, loopParamSpec);
15467
+ if (l.index) {
15468
+ const loopParamSpecIndexed = [{ param: l.param, bindings: l.paramBindings, index: l.index }];
15469
+ templateIndexed = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, loopParamSpecIndexed) : irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, loopParamSpecIndexed);
15470
+ }
15337
15471
  if (l.isStaticArray) {
15338
15472
  staticItemTemplate = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], resolveRestSpreadNames(ctx), 0) : irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx), 0);
15339
15473
  } else if (!useElementReconciliation && !l.bodyIsMultiRoot && !l.bodyIsItemConditional) {
@@ -15362,6 +15496,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
15362
15496
  iterationShape: l.iterationShape,
15363
15497
  objectIteration: l.objectIteration,
15364
15498
  template,
15499
+ templateIndexed,
15365
15500
  staticItemTemplate,
15366
15501
  skeletonTemplate,
15367
15502
  skeletonPaths,
@@ -15552,6 +15687,7 @@ function collectBranchLoops(node, ctx, siblingOffsets) {
15552
15687
  const projectionInner = n.method === "flatMap" && n.children.length === 1 && n.children[0].type === "loop" ? n.children[0] : undefined;
15553
15688
  const { useElementReconciliation, innerLoops: innerLoopsCollected } = projectionInner ? { useElementReconciliation: false, innerLoops: undefined } : decideLoopRendering(n, siblingOffsets, undefined);
15554
15689
  let childTemplate;
15690
+ let childTemplateIndexed;
15555
15691
  const branchLoopParamSpec = [{ param: n.param, bindings: n.paramBindings }];
15556
15692
  if (projectionInner) {
15557
15693
  childTemplate = "";
@@ -15560,6 +15696,10 @@ function collectBranchLoops(node, ctx, siblingOffsets) {
15560
15696
  } else {
15561
15697
  childTemplate = n.children.map((c) => irToHtmlTemplate(c, undefined, 0, branchLoopParamSpec)).join("");
15562
15698
  }
15699
+ if (n.index && !projectionInner) {
15700
+ const branchLoopParamSpecIndexed = [{ param: n.param, bindings: n.paramBindings, index: n.index }];
15701
+ childTemplateIndexed = useElementReconciliation && n.children[0] ? irToPlaceholderTemplate(n.children[0], restNames, 0, branchLoopParamSpecIndexed) : n.children.map((c) => irToHtmlTemplate(c, undefined, 0, branchLoopParamSpecIndexed)).join("");
15702
+ }
15563
15703
  const branchBindings = ctx && !projectionInner ? collectLoopChildBindings(n.children, ctx, siblingOffsets, n.param, n.paramBindings, preambleNamesOf(n), n.index) : emptyLoopChildBindings();
15564
15704
  loops.push({
15565
15705
  kind: "branch",
@@ -15575,6 +15715,7 @@ function collectBranchLoops(node, ctx, siblingOffsets) {
15575
15715
  iterationShape: n.iterationShape,
15576
15716
  objectIteration: n.objectIteration,
15577
15717
  template: childTemplate,
15718
+ templateIndexed: childTemplateIndexed,
15578
15719
  containerSlotId: containerSlot,
15579
15720
  preamble: n.preamble,
15580
15721
  preambleRegions: n.preambleRegions,
@@ -15657,19 +15798,10 @@ function collectLoopChildBindings(children, ctx, siblingOffsets, loopParam, loop
15657
15798
  }
15658
15799
  return bindings;
15659
15800
  }
15660
- function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex) {
15801
+ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex, loopParams, parentScope) {
15661
15802
  const conditionals = [];
15662
- const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
15663
- const refsAnyBindingViaFreeIds = (freeIds) => {
15664
- if (loopParamBindings && loopParamBindings.length > 0) {
15665
- for (const b of loopParamBindings) {
15666
- if (freeIds.has(b.name))
15667
- return true;
15668
- }
15669
- return false;
15670
- }
15671
- return loopParam ? freeIds.has(loopParam) : false;
15672
- };
15803
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope);
15804
+ const refsAnyBindingViaFreeIds = (freeIds) => scope !== undefined && anyNameIn(scope.valueBoundNames(), freeIds);
15673
15805
  walkIR(node, null, {
15674
15806
  ...stopAt("loop", "async", "ifStatement"),
15675
15807
  conditional: ({ node: n }) => {
@@ -15681,9 +15813,9 @@ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loop
15681
15813
  return;
15682
15814
  const expanded = expandConstantForReactivity(n.condition, ctx, sourceFreeIds, scope);
15683
15815
  const readsPreamble = preambleNames !== undefined && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
15684
- if (!readsPreamble && classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind === "none")
15816
+ if (!readsPreamble && classifyReactivity(expanded.expr, ctx, scope, expanded.freeIds).kind === "none")
15685
15817
  return;
15686
- const loopParamsForCond = loopParam ? [{ param: loopParam, bindings: loopParamBindings }] : undefined;
15818
+ const loopParamsForCond = loopParams ?? (loopParam ? [{ param: loopParam, bindings: loopParamBindings, index: loopIndex }] : undefined);
15687
15819
  const whenTrueHtml = irToHtmlTemplate(n.whenTrue, undefined, 0, loopParamsForCond, "__slots");
15688
15820
  const whenFalseHtml = irToHtmlTemplate(n.whenFalse, undefined, 0, loopParamsForCond, "__slots");
15689
15821
  conditionals.push({
@@ -15701,7 +15833,7 @@ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loop
15701
15833
  return conditionals;
15702
15834
  }
15703
15835
  function summarizeLoopChildBranch(node, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex) {
15704
- const inner = collectInnerLoops([node], siblingOffsets, loopParam, ctx, branchInnerLoopOptions);
15836
+ const inner = collectInnerLoops([node], siblingOffsets, loopParam ? { param: loopParam, bindings: loopParamBindings, index: loopIndex } : undefined, ctx, branchInnerLoopOptions);
15705
15837
  return {
15706
15838
  childComponents: collectConditionalBranchChildComponents(node),
15707
15839
  innerLoops: inner.length > 0 ? inner : undefined,
@@ -16267,6 +16399,7 @@ var RUNTIME_IMPORT_CANDIDATES = [
16267
16399
  "escapeAttr",
16268
16400
  "escapeText",
16269
16401
  "escapeTextOrNode",
16402
+ "escapeCommentText",
16270
16403
  "bfMarkup",
16271
16404
  "escapeTextOrMarkup",
16272
16405
  "markupOrEmpty",
@@ -17326,7 +17459,7 @@ function emitRegistrationAndHydration(lines, ctx, _ir, graph, inlinability) {
17326
17459
  const isCommentScope = isFragmentRoot || _ir.root.type === "component";
17327
17460
  const defParts = [`init: init${name}`];
17328
17461
  if (canGenerateStaticTemplate(_ir.root, propNamesForStaticCheck, inlinableConstants, unsafeLocalNames)) {
17329
- const markupSlotIds = new Set(ctx.dynamicElements.map((e) => e.slotId));
17462
+ const markupSlotIds = markupSlotIdsOf(ctx);
17330
17463
  const templateHtml = irToComponentTemplate(_ir.root, inlinableConstants, restSpreadNames, ctx.propsObjectName, markupSlotIds, ctx.restPropsName);
17331
17464
  if (templateHtml) {
17332
17465
  defParts.push(buildTemplateDefPart(ctx, templateHtml));
@@ -18326,12 +18459,12 @@ function nestedLoopIndexAlias(inner, syntheticIndexVar, paramHead, comps, events
18326
18459
  return null;
18327
18460
  return `const ${index} = ${syntheticIndexVar}`;
18328
18461
  }
18329
- function buildChildRefBindings(refs, loopParam, loopParamBindings) {
18462
+ function buildChildRefBindings(refs, loopParam, loopParamBindings, loopIndex) {
18330
18463
  if (refs.length === 0)
18331
18464
  return [];
18332
18465
  return refs.map((r) => ({
18333
18466
  childSlotId: r.childSlotId,
18334
- callback: wrapLoopParamAsAccessor(r.callback, loopParam, loopParamBindings)
18467
+ callback: wrapLoopParamAsAccessor(r.callback, loopParam, loopParamBindings, loopIndex)
18335
18468
  }));
18336
18469
  }
18337
18470
  function buildStaticChildRefBindings(refs) {
@@ -18364,17 +18497,17 @@ function destructureLoopParam(param, paramBindings) {
18364
18497
  }
18365
18498
  return { head: param, unwrap: "" };
18366
18499
  }
18367
- function buildPreambleRegionPlans(regions, loopParam, loopParamBindings) {
18500
+ function buildPreambleRegionPlans(regions, loopParam, loopParamBindings, loopIndex) {
18368
18501
  if (!regions || regions.length === 0)
18369
18502
  return [];
18370
18503
  return regions.map((r) => {
18371
- const wrapped = wrapLoopParamAsAccessor(r.expr, loopParam, loopParamBindings);
18372
- const valueExpr = r.joinArrayChild ? `Array.isArray(${wrapped}) ? ${wrapped}.join('') : (${wrapped} ?? '')` : `escapeText(${wrapped})`;
18504
+ const wrapped = wrapLoopParamAsAccessor(r.expr, loopParam, loopParamBindings, loopIndex);
18505
+ const valueExpr = spliceChildValue({ expr: r.expr, slotId: r.slotId, joinArrayChild: r.joinArrayChild }, wrapped, {});
18373
18506
  return { slotId: r.slotId, valueExpr };
18374
18507
  });
18375
18508
  }
18376
- function buildComponentPropsExpr2(comp, loopParam, loopParamBindings) {
18377
- const wrap = loopParam ? (expr) => wrapLoopParamAsAccessor(expr, loopParam, loopParamBindings) : (expr) => expr;
18509
+ function buildComponentPropsExpr2(comp, loopParam, loopParamBindings, loopIndex) {
18510
+ const wrap = loopParam ? (expr) => wrapLoopParamAsAccessor(expr, loopParam, loopParamBindings, loopIndex) : (expr) => expr;
18378
18511
  const entries = comp.props.map((p) => {
18379
18512
  if (p.isEventHandler) {
18380
18513
  const handlerExpr = attrValueToString(p.value) ?? "undefined";
@@ -18418,8 +18551,8 @@ function buildDepthLevels(innerLoops, nestedComps, childEvents) {
18418
18551
  loopInfo: loop
18419
18552
  }));
18420
18553
  }
18421
- function emitEventSetup(ls, indent, elVar, ev, loopParam, loopParamBindings, bodyIsMultiRoot = false) {
18422
- const handler = loopParam ? wrapLoopParamAsAccessor(ev.handler, loopParam, loopParamBindings) : ev.handler;
18554
+ function emitEventSetup(ls, indent, elVar, ev, loopParam, loopParamBindings, bodyIsMultiRoot = false, loopIndex) {
18555
+ const handler = loopParam ? wrapLoopParamAsAccessor(ev.handler, loopParam, loopParamBindings, loopIndex) : ev.handler;
18423
18556
  emitListenerBlock(ls, indent, elVar, ev.childSlotId, "__e", ev.eventName, handler, "dom", bodyIsMultiRoot);
18424
18557
  }
18425
18558
  function buildCompSelector(comp) {
@@ -18431,15 +18564,15 @@ function isTextOnlyConditional(node) {
18431
18564
  const checkNode = (n) => n.type === "text" || n.type === "expression" || n.type === "conditional" && isTextOnlyConditional(n);
18432
18565
  return checkNode(node.whenTrue) && checkNode(node.whenFalse);
18433
18566
  }
18434
- function emitComponentAndEventSetup(ls, indent, elVar, comps, events, loopParam, loopParamBindings, bodyIsMultiRoot = false) {
18435
- const wrap = loopParam ? (expr) => wrapLoopParamAsAccessor(expr, loopParam, loopParamBindings) : (expr) => expr;
18567
+ function emitComponentAndEventSetup(ls, indent, elVar, comps, events, loopParam, loopParamBindings, bodyIsMultiRoot = false, loopIndex) {
18568
+ const wrap = loopParam ? (expr) => wrapLoopParamAsAccessor(expr, loopParam, loopParamBindings, loopIndex) : (expr) => expr;
18436
18569
  const upsertFn = bodyIsMultiRoot ? "upsertChildItem" : "upsertChild";
18437
18570
  for (const comp of comps) {
18438
- const propsExpr = buildComponentPropsExpr2(comp, loopParam, loopParamBindings);
18571
+ const propsExpr = buildComponentPropsExpr2(comp, loopParam, loopParamBindings, loopIndex);
18439
18572
  const isTextOnly = comp.children?.length ? comp.children.every((c) => c.type === "expression" || c.type === "text" || isTextOnlyConditional(c)) : false;
18440
18573
  const rawChildrenExpr = isTextOnly ? irChildrenToJsExpr(comp.children) : null;
18441
18574
  const childrenFreeIds = isTextOnly && comp.children ? irChildrenFreeIds(comp.children) : undefined;
18442
- const childrenRefsLoop = loopParam != null && rawChildrenExpr != null && childrenFreeIds != null && exprRefsLoopBinding(childrenFreeIds, { param: loopParam, paramBindings: loopParamBindings });
18575
+ const childrenRefsLoop = loopParam != null && rawChildrenExpr != null && childrenFreeIds != null && (exprRefsLoopBinding(childrenFreeIds, { param: loopParam, paramBindings: loopParamBindings }) || !!loopIndex && childrenFreeIds.has(loopIndex));
18443
18576
  const slotIdLit = comp.slotId ? `'${comp.slotId}'` : "null";
18444
18577
  const keyProp = comp.props.find((p) => p.name === "key");
18445
18578
  const keyArg = keyProp ? `, ${wrap(attrValueToString(keyProp.value) ?? "undefined")}` : ", undefined";
@@ -18452,7 +18585,7 @@ function emitComponentAndEventSetup(ls, indent, elVar, comps, events, loopParam,
18452
18585
  }
18453
18586
  }
18454
18587
  for (const ev of events) {
18455
- emitEventSetup(ls, indent, elVar, ev, loopParam, loopParamBindings, bodyIsMultiRoot);
18588
+ emitEventSetup(ls, indent, elVar, ev, loopParam, loopParamBindings, bodyIsMultiRoot, loopIndex);
18456
18589
  }
18457
18590
  }
18458
18591
 
@@ -18823,6 +18956,7 @@ function buildBranchInnerLoopsPlan(args) {
18823
18956
  condSlotId,
18824
18957
  outerLoopParam,
18825
18958
  outerLoopParamBindings,
18959
+ outerLoopIndex,
18826
18960
  wrapOuter
18827
18961
  } = args;
18828
18962
  if (!innerLoops || innerLoops.length === 0)
@@ -18830,14 +18964,14 @@ function buildBranchInnerLoopsPlan(args) {
18830
18964
  const plan = [];
18831
18965
  for (let i = 0;i < innerLoops.length; i++) {
18832
18966
  const inner = innerLoops[i];
18833
- if (!inner.refsOuterParam || !inner.template)
18967
+ if (!inner.template)
18834
18968
  continue;
18835
- const wrapInner = (expr) => wrapLoopParamAsAccessor(expr, inner.param, inner.paramBindings);
18836
- const wrapBoth = (expr) => wrapLoopParamAsAccessor(wrapOuter(expr), inner.param, inner.paramBindings);
18969
+ const wrapInner = (expr) => wrapLoopParamAsAccessor(expr, inner.param, inner.paramBindings, inner.index);
18970
+ const wrapBoth = (expr) => wrapLoopParamAsAccessor(wrapOuter(expr), inner.param, inner.paramBindings, inner.index);
18837
18971
  const csl = inner.containerSlotId;
18838
18972
  const containerExpr = csl ? `(${scopeVar}.querySelector('[bf="${csl}"]') ?? ${scopeVar}.querySelector(\`[${BF_HOST}="\${__scopeId}"][${BF_AT}="${csl}"]\`) ?? ${scopeVar})` : `findCondContainer(${scopeVar}, '${condSlotId}')`;
18839
18973
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(inner.param, inner.paramBindings);
18840
- const wrappedKey = inner.key ? wrapLoopParamAsAccessor(inner.key, inner.param, inner.paramBindings) : null;
18974
+ const wrappedKey = inner.key ? wrapLoopParamAsAccessor(inner.key, inner.param, inner.paramBindings, inner.index) : null;
18841
18975
  const wrapIRNode = (node) => {
18842
18976
  if (node.type === "component") {
18843
18977
  return {
@@ -18893,18 +19027,20 @@ function buildBranchInnerLoopsPlan(args) {
18893
19027
  scopeVar: `__belbr_${i}`,
18894
19028
  wrap: wrapBoth,
18895
19029
  loopParam: inner.param,
18896
- loopParamBindings: inner.paramBindings
19030
+ loopParamBindings: inner.paramBindings,
19031
+ loopIndex: inner.index
18897
19032
  }),
18898
19033
  innerLoopParam: inner.param,
18899
19034
  innerLoopParamBindings: inner.paramBindings,
18900
19035
  outerLoopParam,
18901
- outerLoopParamBindings
19036
+ outerLoopParamBindings,
19037
+ outerLoopIndex
18902
19038
  });
18903
19039
  }
18904
19040
  return plan;
18905
19041
  }
18906
19042
  function buildLoopChildConditionalsPlan(args) {
18907
- const { conditionals, scopeVar, wrap, loopParam, loopParamBindings } = args;
19043
+ const { conditionals, scopeVar, wrap, loopParam, loopParamBindings, loopIndex } = args;
18908
19044
  if (!conditionals || conditionals.length === 0)
18909
19045
  return [];
18910
19046
  const plans = [];
@@ -18913,13 +19049,14 @@ function buildLoopChildConditionalsPlan(args) {
18913
19049
  slotId: cond.slotId,
18914
19050
  scopeVar,
18915
19051
  wrappedCondition: wrap(cond.condition),
18916
- whenTrueTemplateHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
18917
- whenFalseTemplateHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId),
19052
+ whenTrueTemplateHtml: addCondAttrToTemplate(cond.whenTrueHtml, cond.slotId),
19053
+ whenFalseTemplateHtml: addCondAttrToTemplate(cond.whenFalseHtml, cond.slotId),
18918
19054
  whenTrueArm: buildLoopChildArmPlan({
18919
19055
  branch: cond.whenTrue,
18920
19056
  wrap,
18921
19057
  loopParam,
18922
19058
  loopParamBindings,
19059
+ loopIndex,
18923
19060
  condId: cond.slotId
18924
19061
  }),
18925
19062
  whenFalseArm: buildLoopChildArmPlan({
@@ -18927,8 +19064,10 @@ function buildLoopChildConditionalsPlan(args) {
18927
19064
  wrap,
18928
19065
  loopParam,
18929
19066
  loopParamBindings,
19067
+ loopIndex,
18930
19068
  condId: cond.slotId
18931
- })
19069
+ }),
19070
+ ...cond.readsPreamble && { readsPreamble: true }
18932
19071
  });
18933
19072
  }
18934
19073
  return plans;
@@ -18952,7 +19091,8 @@ function buildArmAttrsPlan(attrs, wrap) {
18952
19091
  attrs: slotAttrs.map((attr) => ({
18953
19092
  attrName: attr.attrName,
18954
19093
  wrappedExpression: wrap(attr.expression),
18955
- meta: pickAttrMeta(attr)
19094
+ meta: pickAttrMeta(attr),
19095
+ ...attr.readsPreamble && { readsPreamble: true }
18956
19096
  }))
18957
19097
  });
18958
19098
  }
@@ -18967,7 +19107,7 @@ function buildArmTextsPlan(texts, wrap) {
18967
19107
  }));
18968
19108
  }
18969
19109
  function buildLoopChildArmPlan(args) {
18970
- const { branch, wrap, loopParam, loopParamBindings, condId } = args;
19110
+ const { branch, wrap, loopParam, loopParamBindings, loopIndex, condId } = args;
18971
19111
  return {
18972
19112
  events: buildBranchEventBindingsPlan({
18973
19113
  events: branch.events,
@@ -18983,6 +19123,7 @@ function buildLoopChildArmPlan(args) {
18983
19123
  condSlotId: condId,
18984
19124
  outerLoopParam: loopParam,
18985
19125
  outerLoopParamBindings: loopParamBindings,
19126
+ outerLoopIndex: loopIndex,
18986
19127
  wrapOuter: wrap
18987
19128
  }),
18988
19129
  nestedConditionals: buildLoopChildConditionalsPlan({
@@ -18990,7 +19131,8 @@ function buildLoopChildArmPlan(args) {
18990
19131
  scopeVar: "__branchScope",
18991
19132
  wrap,
18992
19133
  loopParam,
18993
- loopParamBindings
19134
+ loopParamBindings,
19135
+ loopIndex
18994
19136
  }),
18995
19137
  attrs: buildArmAttrsPlan(branch.reactiveAttrs, wrap),
18996
19138
  texts: buildArmTextsPlan(branch.reactiveTexts, wrap)
@@ -18999,8 +19141,8 @@ function buildLoopChildArmPlan(args) {
18999
19141
 
19000
19142
  // ../jsx/src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts
19001
19143
  function buildReactiveEffectsPlan(args) {
19002
- const { attrs, texts, conditionals, loopParam, loopParamBindings, profileComponentName } = args;
19003
- const wrap = (expr) => wrapLoopParamAsAccessor(expr, loopParam, loopParamBindings);
19144
+ const { attrs, texts, conditionals, loopParam, loopParamBindings, loopIndex, profileComponentName } = args;
19145
+ const wrap = (expr) => wrapLoopParamAsAccessor(expr, loopParam, loopParamBindings, loopIndex);
19004
19146
  const attrsBySlot = new Map;
19005
19147
  for (const attr of attrs) {
19006
19148
  let bucket = attrsBySlot.get(attr.childSlotId);
@@ -19032,10 +19174,10 @@ function buildReactiveEffectsPlan(args) {
19032
19174
  conditionalPlans.push({
19033
19175
  slotId: cond.slotId,
19034
19176
  wrappedCondition: wrap(cond.condition),
19035
- whenTrueTemplateHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
19036
- whenFalseTemplateHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId),
19037
- whenTrueArm: buildOuterArm(cond.whenTrue, wrap, loopParam, loopParamBindings, cond.slotId, profileComponentName),
19038
- whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, cond.slotId, profileComponentName),
19177
+ whenTrueTemplateHtml: addCondAttrToTemplate(cond.whenTrueHtml, cond.slotId),
19178
+ whenFalseTemplateHtml: addCondAttrToTemplate(cond.whenFalseHtml, cond.slotId),
19179
+ whenTrueArm: buildOuterArm(cond.whenTrue, wrap, loopParam, loopParamBindings, loopIndex, cond.slotId, profileComponentName),
19180
+ whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, loopIndex, cond.slotId, profileComponentName),
19039
19181
  ...cond.readsPreamble && { readsPreamble: true }
19040
19182
  });
19041
19183
  }
@@ -19047,7 +19189,7 @@ function buildReactiveEffectsPlan(args) {
19047
19189
  profileComponentName
19048
19190
  };
19049
19191
  }
19050
- function buildOuterArm(branch, wrap, loopParam, loopParamBindings, condSlotId, profileComponentName) {
19192
+ function buildOuterArm(branch, wrap, loopParam, loopParamBindings, loopIndex, condSlotId, profileComponentName) {
19051
19193
  return {
19052
19194
  events: buildBranchEventBindingsPlan({
19053
19195
  events: branch.events,
@@ -19064,6 +19206,7 @@ function buildOuterArm(branch, wrap, loopParam, loopParamBindings, condSlotId, p
19064
19206
  condSlotId,
19065
19207
  outerLoopParam: loopParam,
19066
19208
  outerLoopParamBindings: loopParamBindings,
19209
+ outerLoopIndex: loopIndex,
19067
19210
  wrapOuter: wrap
19068
19211
  }),
19069
19212
  nestedConditionals: buildLoopChildConditionalsPlan({
@@ -19071,7 +19214,8 @@ function buildOuterArm(branch, wrap, loopParam, loopParamBindings, condSlotId, p
19071
19214
  scopeVar: "__branchScope",
19072
19215
  wrap,
19073
19216
  loopParam,
19074
- loopParamBindings
19217
+ loopParamBindings,
19218
+ loopIndex
19075
19219
  }),
19076
19220
  attrs: buildArmAttrsPlan(branch.reactiveAttrs, wrap),
19077
19221
  texts: buildArmTextsPlan(branch.reactiveTexts, wrap)
@@ -19084,6 +19228,7 @@ function buildLoopReactiveEffectsPlan(elem, profileComponentName) {
19084
19228
  conditionals: elem.bindings.conditionals,
19085
19229
  loopParam: elem.param,
19086
19230
  loopParamBindings: elem.paramBindings,
19231
+ loopIndex: elem.index,
19087
19232
  profileComponentName
19088
19233
  });
19089
19234
  }
@@ -19110,8 +19255,8 @@ function wrapAttrValueExpression2(value, wrap) {
19110
19255
  }
19111
19256
  }
19112
19257
  function buildInnerLoopsPlan(args) {
19113
- const { levels, parentElVar, outerLoopParam, outerLoopParamBindings } = args;
19114
- const wrapOuter = outerLoopParam ? (expr) => wrapLoopParamAsAccessor(expr, outerLoopParam, outerLoopParamBindings) : (expr) => expr;
19258
+ const { levels, parentElVar, outerLoopParam, outerLoopParamBindings, outerLoopIndex } = args;
19259
+ const wrapOuter = outerLoopParam ? (expr) => wrapLoopParamAsAccessor(expr, outerLoopParam, outerLoopParamBindings, outerLoopIndex) : (expr) => expr;
19115
19260
  const plan = [];
19116
19261
  let i = 0;
19117
19262
  while (i < levels.length) {
@@ -19133,15 +19278,14 @@ function buildInnerLoopsPlan(args) {
19133
19278
  }
19134
19279
  const uidSuffix = `${inner.depth}_${i}`;
19135
19280
  const containerExpr = inner.containerSlotId ? `qsa(${parentElVar}, '[bf="${inner.containerSlotId}"]')` : parentElVar;
19136
- const refsParent = !!outerLoopParam && (inner.arrayFreeIdentifiers?.has(outerLoopParam) ?? false);
19137
- const useReactive = refsParent && !!inner.template;
19138
- const emit = useReactive ? buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings) : buildStaticEmit(inner, level, uidSuffix);
19139
- const arrayExpr = useReactive ? wrapOuter(inner.array) : inner.array;
19281
+ const emit = buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings, outerLoopIndex);
19282
+ const arrayExpr = wrapOuter(inner.array);
19140
19283
  const childLevelsPlan = childLevels.length > 0 ? buildInnerLoopsPlan({
19141
19284
  levels: childLevels,
19142
19285
  parentElVar: `__innerEl${uidSuffix}`,
19143
19286
  outerLoopParam: inner.param,
19144
- outerLoopParamBindings: inner.paramBindings
19287
+ outerLoopParamBindings: inner.paramBindings,
19288
+ outerLoopIndex: inner.index
19145
19289
  }) : [];
19146
19290
  plan.push({
19147
19291
  uidSuffix,
@@ -19155,17 +19299,18 @@ function buildInnerLoopsPlan(args) {
19155
19299
  emit,
19156
19300
  childLevels: childLevelsPlan,
19157
19301
  outerLoopParam,
19158
- outerLoopParamBindings
19302
+ outerLoopParamBindings,
19303
+ outerLoopIndex
19159
19304
  });
19160
19305
  i = j;
19161
19306
  }
19162
19307
  return plan;
19163
19308
  }
19164
- function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings) {
19165
- const wrapInner = (expr) => wrapLoopParamAsAccessor(expr, inner.param, inner.paramBindings);
19166
- const wrapBoth = (expr) => wrapLoopParamAsAccessor(wrapOuter(expr), inner.param, inner.paramBindings);
19309
+ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings, outerLoopIndex) {
19310
+ const wrapInner = (expr) => wrapLoopParamAsAccessor(expr, inner.param, inner.paramBindings, inner.index);
19311
+ const wrapBoth = (expr) => wrapLoopParamAsAccessor(wrapOuter(expr), inner.param, inner.paramBindings, inner.index);
19167
19312
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(inner.param, inner.paramBindings);
19168
- const wrappedKey = inner.key ? wrapLoopParamAsAccessor(inner.key, inner.param, inner.paramBindings) : null;
19313
+ const wrappedKey = inner.key ? wrapLoopParamAsAccessor(inner.key, inner.param, inner.paramBindings, inner.index) : null;
19169
19314
  const wrapIRNode = (node) => {
19170
19315
  if (node.type === "component") {
19171
19316
  return {
@@ -19196,11 +19341,11 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
19196
19341
  }));
19197
19342
  const reactiveTexts = inner.bindings.reactiveTexts.map((text) => ({
19198
19343
  slotId: text.slotId,
19199
- wrappedExpression: wrapLoopParamAsAccessor(wrapOuter(text.expression), inner.param, inner.paramBindings),
19344
+ wrappedExpression: wrapLoopParamAsAccessor(wrapOuter(text.expression), inner.param, inner.paramBindings, inner.index),
19200
19345
  insideConditional: !!text.insideConditional
19201
19346
  }));
19202
19347
  const reactiveAttrs = inner.bindings.reactiveAttrs.map((attr) => {
19203
- const wrapped = wrapLoopParamAsAccessor(wrapOuter(attr.expression), inner.param, inner.paramBindings);
19348
+ const wrapped = wrapLoopParamAsAccessor(wrapOuter(attr.expression), inner.param, inner.paramBindings, inner.index);
19204
19349
  return {
19205
19350
  slotId: attr.childSlotId,
19206
19351
  attrName: attr.attrName,
@@ -19216,21 +19361,22 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
19216
19361
  preludeStatements.push(paramUnwrap);
19217
19362
  if (inner.preamble) {
19218
19363
  const leafLoopParams = outerLoopParam ? [
19219
- { param: outerLoopParam, bindings: outerLoopParamBindings },
19220
- { param: inner.param, bindings: inner.paramBindings }
19221
- ] : [{ param: inner.param, bindings: inner.paramBindings }];
19364
+ { param: outerLoopParam, bindings: outerLoopParamBindings, index: outerLoopIndex },
19365
+ { param: inner.param, bindings: inner.paramBindings, index: inner.index }
19366
+ ] : [{ param: inner.param, bindings: inner.paramBindings, index: inner.index }];
19222
19367
  preludeStatements.push(renderPreamble(inner.preamble, {
19223
19368
  transformJs: (t) => wrapInner(wrapOuter(t)),
19224
19369
  renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, leafLoopParams, undefined)
19225
19370
  }));
19226
19371
  }
19227
- const childRefs = buildChildRefBindings(inner.bindings.refs, inner.param, inner.paramBindings);
19372
+ const childRefs = buildChildRefBindings(inner.bindings.refs, inner.param, inner.paramBindings, inner.index);
19228
19373
  const conditionals = buildLoopChildConditionalsPlan({
19229
19374
  conditionals: inner.bindings.conditionals,
19230
19375
  scopeVar: `__innerEl${uidSuffix}`,
19231
19376
  wrap: wrapBoth,
19232
19377
  loopParam: inner.param,
19233
- loopParamBindings: inner.paramBindings
19378
+ loopParamBindings: inner.paramBindings,
19379
+ loopIndex: inner.index
19234
19380
  });
19235
19381
  return {
19236
19382
  mode: "reactive",
@@ -19248,32 +19394,13 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
19248
19394
  childRefs
19249
19395
  };
19250
19396
  }
19251
- function buildStaticEmit(inner, level, uidSuffix) {
19252
- const preludeStatements = [];
19253
- const indexAlias = nestedLoopIndexAlias(inner, `__innerIdx${uidSuffix}`, inner.param, level.comps, level.events);
19254
- if (indexAlias)
19255
- preludeStatements.push(indexAlias);
19256
- if (inner.preamble) {
19257
- preludeStatements.push(renderPreamble(inner.preamble, {
19258
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, undefined, undefined)
19259
- }));
19260
- }
19261
- return {
19262
- mode: "static",
19263
- rawKey: inner.key ?? null,
19264
- preludeStatements,
19265
- components: level.comps,
19266
- events: level.events,
19267
- childRefs: buildStaticChildRefBindings(inner.bindings.refs)
19268
- };
19269
- }
19270
19397
 
19271
19398
  // ../jsx/src/ir-to-client-js/control-flow/plan/build-composite-loop.ts
19272
19399
  function buildTopLevelCompositePlan(elem, profileComponentName) {
19273
19400
  const nestedComps = elem.nestedComponents;
19274
19401
  const depthLevels = buildDepthLevels(elem.innerLoops ?? [], nestedComps, elem.bindings.events);
19275
19402
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(elem.param, elem.paramBindings);
19276
- const wrap = (expr) => wrapLoopParamAsAccessor(expr, elem.param, elem.paramBindings);
19403
+ const wrap = (expr) => wrapLoopParamAsAccessor(expr, elem.param, elem.paramBindings, elem.index);
19277
19404
  const outerCompsByDepth = nestedComps.filter((c) => !c.loopDepth || c.loopDepth === 0);
19278
19405
  return {
19279
19406
  kind: "composite",
@@ -19287,26 +19414,29 @@ function buildTopLevelCompositePlan(elem, profileComponentName) {
19287
19414
  indexParam: elem.index || "__idx",
19288
19415
  mapPreambleWrapped: elem.preamble ? renderPreamble(elem.preamble, {
19289
19416
  transformJs: wrap,
19290
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: elem.param, bindings: elem.paramBindings }], undefined)
19417
+ renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: elem.param, bindings: elem.paramBindings, index: elem.index }], undefined)
19291
19418
  }) : "",
19292
19419
  template: elem.template,
19293
19420
  outerComps: filterCondCompsOut(outerCompsByDepth, elem.bindings.conditionals),
19294
19421
  outerEvents: elem.bindings.events.filter((ev) => ev.nestedLoops.length === 0),
19295
- childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings),
19422
+ childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings, elem.index),
19296
19423
  innerLoops: buildInnerLoopsPlan({
19297
19424
  levels: depthLevels,
19298
19425
  parentElVar: "__el",
19299
19426
  outerLoopParam: elem.param,
19300
- outerLoopParamBindings: elem.paramBindings
19427
+ outerLoopParamBindings: elem.paramBindings,
19428
+ outerLoopIndex: elem.index
19301
19429
  }),
19302
19430
  loopParam: elem.param,
19303
19431
  loopParamBindings: elem.paramBindings,
19432
+ loopIndex: elem.index,
19304
19433
  reactiveEffects: hasReactive(elem) ? buildReactiveEffectsPlan({
19305
19434
  attrs: elem.bindings.reactiveAttrs,
19306
19435
  texts: elem.bindings.reactiveTexts,
19307
19436
  conditionals: elem.bindings.conditionals,
19308
19437
  loopParam: elem.param,
19309
19438
  loopParamBindings: elem.paramBindings,
19439
+ loopIndex: elem.index,
19310
19440
  profileComponentName
19311
19441
  }) : null,
19312
19442
  branchClearChildren: false,
@@ -19323,7 +19453,7 @@ function buildBranchCompositePlan(loop, cv, profileComponentName) {
19323
19453
  const childEvents = loop.bindings.events;
19324
19454
  const depthLevels = buildDepthLevels(innerLoops, nestedComps, childEvents);
19325
19455
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(loop.param, loop.paramBindings);
19326
- const wrap = (expr) => wrapLoopParamAsAccessor(expr, loop.param, loop.paramBindings);
19456
+ const wrap = (expr) => wrapLoopParamAsAccessor(expr, loop.param, loop.paramBindings, loop.index);
19327
19457
  const outerCompsByDepth = nestedComps.filter((c) => !c.loopDepth || c.loopDepth === 0);
19328
19458
  return {
19329
19459
  kind: "composite",
@@ -19337,26 +19467,29 @@ function buildBranchCompositePlan(loop, cv, profileComponentName) {
19337
19467
  indexParam: loop.index || "__idx",
19338
19468
  mapPreambleWrapped: loop.preamble ? renderPreamble(loop.preamble, {
19339
19469
  transformJs: wrap,
19340
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: loop.param, bindings: loop.paramBindings }], undefined)
19470
+ renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: loop.param, bindings: loop.paramBindings, index: loop.index }], undefined)
19341
19471
  }) : "",
19342
19472
  template: loop.template,
19343
19473
  outerComps: filterCondCompsOut(outerCompsByDepth, loop.bindings.conditionals),
19344
19474
  outerEvents: childEvents.filter((ev) => ev.nestedLoops.length === 0),
19345
- childRefs: buildChildRefBindings(loop.bindings.refs, loop.param, loop.paramBindings),
19475
+ childRefs: buildChildRefBindings(loop.bindings.refs, loop.param, loop.paramBindings, loop.index),
19346
19476
  innerLoops: buildInnerLoopsPlan({
19347
19477
  levels: depthLevels,
19348
19478
  parentElVar: "__el",
19349
19479
  outerLoopParam: loop.param,
19350
- outerLoopParamBindings: loop.paramBindings
19480
+ outerLoopParamBindings: loop.paramBindings,
19481
+ outerLoopIndex: loop.index
19351
19482
  }),
19352
19483
  loopParam: loop.param,
19353
19484
  loopParamBindings: loop.paramBindings,
19485
+ loopIndex: loop.index,
19354
19486
  reactiveEffects: hasReactiveBranch(loop) ? buildReactiveEffectsPlan({
19355
19487
  attrs: loop.bindings.reactiveAttrs,
19356
19488
  texts: loop.bindings.reactiveTexts,
19357
19489
  conditionals: loop.bindings.conditionals,
19358
19490
  loopParam: loop.param,
19359
19491
  loopParamBindings: loop.paramBindings,
19492
+ loopIndex: loop.index,
19360
19493
  profileComponentName
19361
19494
  }) : null,
19362
19495
  branchClearChildren: true,
@@ -19491,7 +19624,7 @@ function wiringOn(branch) {
19491
19624
  found.push("reactive text");
19492
19625
  return found;
19493
19626
  }
19494
- function analyzeLazyConditional(cond, indexParam, arms) {
19627
+ function analyzeLazyConditional(cond, arms) {
19495
19628
  for (const [label, branch] of [["true", cond.whenTrue], ["false", cond.whenFalse]]) {
19496
19629
  const wiring = wiringOn(branch);
19497
19630
  if (wiring.length > 0) {
@@ -19512,9 +19645,6 @@ function analyzeLazyConditional(cond, indexParam, arms) {
19512
19645
  if (!cond.conditionFreeIdentifiers) {
19513
19646
  return NO(`conditional on slot ${cond.slotId}: condition has no analyzable identifier set`);
19514
19647
  }
19515
- if (cond.conditionFreeIdentifiers.has(indexParam)) {
19516
- return NO(`conditional on slot ${cond.slotId}: condition reads the loop index parameter '${indexParam}'`);
19517
- }
19518
19648
  return {
19519
19649
  lazySafe: true,
19520
19650
  facts: {
@@ -19533,7 +19663,7 @@ var NO_PREAMBLE = {
19533
19663
  facts: { declaredNames: new Set, freeNames: new Set }
19534
19664
  };
19535
19665
  var NO2 = (reason) => ({ lazySafe: false, reason });
19536
- function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19666
+ function analyzeLazyPreamble(preamble, primableNames) {
19537
19667
  if (!preamble)
19538
19668
  return NO_PREAMBLE;
19539
19669
  if (preamble.builderNames.length > 0) {
@@ -19572,9 +19702,6 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19572
19702
  }
19573
19703
  }
19574
19704
  const readNames = extractFreeIdentifiersFromStatementText(text);
19575
- if (readNames.has(indexParam) && !declaredNames.has(indexParam)) {
19576
- return NO2(`map-callback preamble reads the loop index parameter '${indexParam}'`);
19577
- }
19578
19705
  const freeNames = new Set(readNames);
19579
19706
  for (const declared of declaredNames)
19580
19707
  freeNames.delete(declared);
@@ -19724,9 +19851,6 @@ function lazyRowEligibility(args) {
19724
19851
  if (shape.hasParamUnwrap)
19725
19852
  return NO3("destructured loop param without param bindings");
19726
19853
  for (const b of bindings) {
19727
- if (b.referencesIndex) {
19728
- return NO3(`binding on slot ${b.slotId} references the loop index parameter`);
19729
- }
19730
19854
  if (b.opaqueOuterNames.includes(UNKNOWN_IDENTIFIERS)) {
19731
19855
  return NO3(`binding on slot ${b.slotId} has no analyzable identifier set`);
19732
19856
  }
@@ -19811,6 +19935,7 @@ function classifyLazyBinding(args) {
19811
19935
  }
19812
19936
  if (name === indexParam) {
19813
19937
  referencesIndex = true;
19938
+ readsItem = true;
19814
19939
  return;
19815
19940
  }
19816
19941
  if (INERT_BINDING_GLOBALS.has(name))
@@ -19860,14 +19985,14 @@ function decideLazyRow(args) {
19860
19985
  for (const b of loop.paramBindings ?? [])
19861
19986
  rowLocalNames.add(b.name);
19862
19987
  const primableNames = new Set([...scope.signals.keys(), ...scope.memos]);
19863
- const preambleAnalysis = analyzeLazyPreamble(loop.preamble, args.indexParam, primableNames);
19988
+ const preambleAnalysis = analyzeLazyPreamble(loop.preamble, primableNames);
19864
19989
  const rawConditionals = loop.bindings.conditionals ?? [];
19865
19990
  const condFacts = [];
19866
19991
  let conditionalRefusal = null;
19867
19992
  for (const cond of rawConditionals) {
19868
- const verdict = analyzeLazyConditional(cond, args.indexParam, {
19869
- whenTrueHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
19870
- whenFalseHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId)
19993
+ const verdict = analyzeLazyConditional(cond, {
19994
+ whenTrueHtml: addCondAttrToTemplate(cond.whenTrueHtml, cond.slotId),
19995
+ whenFalseHtml: addCondAttrToTemplate(cond.whenFalseHtml, cond.slotId)
19871
19996
  });
19872
19997
  if (!verdict.lazySafe) {
19873
19998
  conditionalRefusal = verdict.reason;
@@ -20007,7 +20132,8 @@ function decideLazyRow(args) {
20007
20132
  preambleStatements: args.mapPreambleWrapped,
20008
20133
  itemNeedsPreamble: [...attrs, ...texts, ...conditionals].some((b) => b.readsItem && b.readsPreamble),
20009
20134
  outerNeedsPreamble: [...attrs, ...texts, ...conditionals].some((b) => b.readsOuter && b.readsPreamble),
20010
- conditionals
20135
+ conditionals,
20136
+ readsIndex: classified.some((c) => c.referencesIndex)
20011
20137
  },
20012
20138
  decision
20013
20139
  };
@@ -20058,6 +20184,43 @@ function loopSourceIdentifiers(loop, arrayExpr) {
20058
20184
  return names;
20059
20185
  }
20060
20186
 
20187
+ // ../jsx/src/ir-to-client-js/control-flow/plan/build-plain-row.ts
20188
+ function buildPlainRowCore(inputs) {
20189
+ const { loop, arrayExpr, callSite, flatMapLeafItem, anchored, scope } = inputs;
20190
+ const wrapItem = (expr) => wrapLoopParamAsAccessor(expr, loop.param, loop.paramBindings);
20191
+ const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(loop.param, loop.paramBindings);
20192
+ const indexParam = loop.index || "__idx";
20193
+ const mapPreambleWrapped = loop.preamble ? renderPreamble(loop.preamble, {
20194
+ transformJs: wrapItem,
20195
+ renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: loop.param, bindings: loop.paramBindings }], undefined)
20196
+ }) : "";
20197
+ const preambleRegions = buildPreambleRegionPlans(loop.preambleRegions, loop.param, loop.paramBindings, loop.index);
20198
+ const lazyRow = buildLazyRowPlan({
20199
+ loop,
20200
+ arrayExpr,
20201
+ indexParam,
20202
+ paramUnwrap,
20203
+ mapPreambleWrapped,
20204
+ preambleRegionCount: preambleRegions.length,
20205
+ callSite,
20206
+ flatMapLeafItem,
20207
+ anchored,
20208
+ scope
20209
+ }) ?? undefined;
20210
+ const mapPreambleWrappedFinal = !lazyRow && loop.index ? wrapIndexParamAsAccessor(mapPreambleWrapped, loop.index) : mapPreambleWrapped;
20211
+ const templateFinal = !lazyRow && loop.index ? loop.templateIndexed ?? loop.template : loop.template;
20212
+ return {
20213
+ indexParam,
20214
+ paramHead,
20215
+ paramUnwrap,
20216
+ preambleRegions,
20217
+ lazyRow,
20218
+ mapPreambleWrapped: mapPreambleWrappedFinal,
20219
+ template: templateFinal,
20220
+ wrapItem
20221
+ };
20222
+ }
20223
+
20061
20224
  // ../jsx/src/ir-to-client-js/control-flow/plan/build-branch-loop.ts
20062
20225
  function buildBranchLoopPlan(loop, profileComponentName, lazyScope) {
20063
20226
  const containerSlotId = loop.containerSlotId;
@@ -20072,16 +20235,18 @@ function buildBranchLoopPlan(loop, profileComponentName, lazyScope) {
20072
20235
  };
20073
20236
  return composite;
20074
20237
  }
20075
- const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(loop.param, loop.paramBindings);
20076
20238
  const hasReactiveEffects = loop.bindings.reactiveAttrs.length > 0 || loop.bindings.reactiveTexts.length > 0 || loop.bindings.conditionals.length > 0;
20077
20239
  const fm = loop.flatMapClient;
20078
20240
  const arrayExpr = fm ? `(${buildChainedArrayExpr(loop)}).flatMap(${fm.params} => ${fm.body})` : buildChainedArrayExpr(loop);
20079
- const indexParam = loop.index || "__idx";
20080
- const mapPreambleWrapped = loop.preamble ? renderPreamble(loop.preamble, {
20081
- transformJs: (t) => wrapLoopParamAsAccessor(t, loop.param, loop.paramBindings),
20082
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: loop.param, bindings: loop.paramBindings }], undefined)
20083
- }) : "";
20084
- const preambleRegions = buildPreambleRegionPlans(loop.preambleRegions, loop.param, loop.paramBindings);
20241
+ const core = buildPlainRowCore({
20242
+ loop,
20243
+ arrayExpr,
20244
+ callSite: "branch-plain",
20245
+ flatMapLeafItem: Boolean(fm),
20246
+ anchored: false,
20247
+ scope: lazyScope
20248
+ });
20249
+ const { paramHead, paramUnwrap, indexParam, preambleRegions, lazyRow } = core;
20085
20250
  const plan = {
20086
20251
  kind: "plain",
20087
20252
  rowConstruction: "string-template",
@@ -20094,30 +20259,20 @@ function buildBranchLoopPlan(loop, profileComponentName, lazyScope) {
20094
20259
  paramHead,
20095
20260
  paramUnwrap,
20096
20261
  indexParam,
20097
- mapPreambleWrapped,
20098
- lazyRow: buildLazyRowPlan({
20099
- loop,
20100
- arrayExpr,
20101
- indexParam,
20102
- paramUnwrap,
20103
- mapPreambleWrapped,
20104
- preambleRegionCount: preambleRegions.length,
20105
- callSite: "branch-plain",
20106
- flatMapLeafItem: Boolean(fm),
20107
- anchored: false,
20108
- scope: lazyScope
20109
- }) ?? undefined,
20110
- template: loop.template,
20262
+ mapPreambleWrapped: core.mapPreambleWrapped,
20263
+ lazyRow,
20264
+ template: core.template,
20111
20265
  reactiveEffects: hasReactiveEffects ? buildReactiveEffectsPlan({
20112
20266
  attrs: loop.bindings.reactiveAttrs,
20113
20267
  texts: loop.bindings.reactiveTexts,
20114
20268
  conditionals: loop.bindings.conditionals,
20115
20269
  loopParam: loop.param,
20116
20270
  loopParamBindings: loop.paramBindings,
20271
+ loopIndex: loop.index,
20117
20272
  profileComponentName
20118
20273
  }) : null,
20119
20274
  eventDelegation: buildBranchLoopDelegationPlan(loop, cv, profileComponentName),
20120
- childRefs: buildChildRefBindings(loop.bindings.refs, loop.param, loop.paramBindings),
20275
+ childRefs: buildChildRefBindings(loop.bindings.refs, loop.param, loop.paramBindings, loop.index),
20121
20276
  preambleRegions,
20122
20277
  bodyIsMultiRoot: loop.bodyIsMultiRoot ?? false,
20123
20278
  profileLoopId: profileComponentName ? `${profileComponentName}#binding:${containerSlotId}` : undefined
@@ -20242,6 +20397,24 @@ function emitAttrUpdate(target, attrName, expression, meta) {
20242
20397
  `{ const __v = ${expression}; if (__v != null) ${target}.setAttribute('${htmlName}', String(__v)); else ${target}.removeAttribute('${htmlName}') }`
20243
20398
  ];
20244
20399
  }
20400
+ var DEDUP_STORE_DECL = "const __l = []";
20401
+ function dedupGuard(ordinal) {
20402
+ return `!(${ordinal} in __l) || !Object.is(__l[${ordinal}], __x)`;
20403
+ }
20404
+ function emitDedupedAttrUpdate(target, attrName, expression, meta, ordinal, guard = dedupGuard(ordinal)) {
20405
+ const write = emitAttrUpdate(target, attrName, "__x", meta);
20406
+ const lines = [`{ const __x = ${expression}`];
20407
+ if (guard) {
20408
+ lines.push(`if (${guard}) {`);
20409
+ for (const stmt of write)
20410
+ lines.push(` ${stmt}`);
20411
+ lines.push(`}`);
20412
+ } else {
20413
+ lines.push(...write);
20414
+ }
20415
+ lines.push(`__l[${ordinal}] = __x }`);
20416
+ return lines;
20417
+ }
20245
20418
  function rewriteDestructuredPropsInExpr(expr, ctx) {
20246
20419
  if (ctx.propsObjectName)
20247
20420
  return expr;
@@ -20402,7 +20575,7 @@ function emitDynamicTextUpdates(lines, ctx) {
20402
20575
  const __textSlot = (normalElems[0] ?? conditionalElems[0])?.slotId;
20403
20576
  let writer = "";
20404
20577
  if (normalElems.length > 0) {
20405
- const slots = normalElems.map((elem) => ({ id: elem.slotId, kind: "markup", path: [] }));
20578
+ const slots = normalElems.map((elem) => ({ id: elem.slotId, kind: DYNAMIC_ELEMENT_WRITER_KIND, path: [] }));
20406
20579
  writer = claimWriterVarName(slots, varSlotId);
20407
20580
  lines.push(` const ${writer} = lazySlots(__scope, ${claimPlanLiteral(slots)})`);
20408
20581
  }
@@ -20456,16 +20629,18 @@ function emitReactiveAttributeUpdates(lines, ctx) {
20456
20629
  }
20457
20630
  for (const [slotId, attrs] of attrsBySlot) {
20458
20631
  const v = varSlotId(slotId);
20632
+ lines.push(` { ${DEDUP_STORE_DECL}`);
20459
20633
  lines.push(` createEffect(() => {`);
20460
20634
  lines.push(` if (_${v}) {`);
20635
+ let ordinal = 0;
20461
20636
  for (const attr of attrs) {
20462
20637
  const expression = rewriteDestructuredPropsInExpr(lower(attr.expression), ctx);
20463
- for (const stmt of emitAttrUpdate(`_${v}`, attr.attrName, expression, attr)) {
20638
+ for (const stmt of emitDedupedAttrUpdate(`_${v}`, attr.attrName, expression, attr, ordinal++)) {
20464
20639
  lines.push(` ${stmt}`);
20465
20640
  }
20466
20641
  }
20467
20642
  lines.push(` }`);
20468
- lines.push(` }${bindingIdArg(ctx, slotId)})`);
20643
+ lines.push(` }${bindingIdArg(ctx, slotId)}) }`);
20469
20644
  lines.push("");
20470
20645
  }
20471
20646
  }
@@ -20518,6 +20693,7 @@ function emitReactiveChildProps(lines, ctx) {
20518
20693
  if (ctx.reactiveChildProps.length > 0) {
20519
20694
  lines.push("");
20520
20695
  lines.push(` // Reactive child component props`);
20696
+ lines.push(` { ${DEDUP_STORE_DECL}`);
20521
20697
  lines.push(` createEffect(() => {`);
20522
20698
  const propsByComponent = new Map;
20523
20699
  for (const prop of ctx.reactiveChildProps) {
@@ -20527,6 +20703,7 @@ function emitReactiveChildProps(lines, ctx) {
20527
20703
  }
20528
20704
  propsByComponent.get(key).push(prop);
20529
20705
  }
20706
+ let ordinal = 0;
20530
20707
  for (const [, props] of propsByComponent) {
20531
20708
  const first = props[0];
20532
20709
  const isCommentRoot = first.slotId !== null && first.slotId === ctx.commentScopeRootSlotId;
@@ -20538,26 +20715,31 @@ function emitReactiveChildProps(lines, ctx) {
20538
20715
  }
20539
20716
  lines.push(` if (${varName}) {`);
20540
20717
  for (const prop of props) {
20541
- const stmts = toHTMLAttrName(prop.attrName) === "value" ? emitChildValueMirrorStatements(varName, prop.expression) : emitAttrUpdate(varName, prop.attrName, prop.expression, prop);
20718
+ const stmts = toHTMLAttrName(prop.attrName) === "value" ? emitChildValueMirrorStatements(varName, prop.expression) : emitDedupedAttrUpdate(varName, prop.attrName, prop.expression, prop, ordinal++);
20542
20719
  for (const stmt of stmts) {
20543
20720
  lines.push(` ${stmt}`);
20544
20721
  }
20545
20722
  }
20546
20723
  lines.push(` }`);
20547
20724
  }
20548
- lines.push(` }${bindingIdArg(ctx, ctx.reactiveChildProps[0]?.slotId ?? undefined)})`);
20725
+ lines.push(` }${bindingIdArg(ctx, ctx.reactiveChildProps[0]?.slotId ?? undefined)}) }`);
20549
20726
  }
20550
20727
  }
20551
20728
 
20552
20729
  // ../jsx/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts
20553
- function stringifyBranchReactiveAttrs(lines, plan, indent, pc) {
20730
+ function stringifyBranchReactiveAttrs(lines, plan, indent, pc, mapPreambleWrapped) {
20554
20731
  for (const slot of plan) {
20555
20732
  const varName = `__ra_${varSlotId(slot.slotId)}`;
20556
20733
  lines.push(`${indent}{ const ${varName} = qsa(__branchScope, '[bf="${slot.slotId}"]')`);
20734
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
20557
20735
  lines.push(`${indent}if (${varName}) {`);
20736
+ let ordinal = 0;
20558
20737
  for (const attr of slot.attrs) {
20559
20738
  lines.push(`${indent} __disposers.push(createDisposableEffect(() => {`);
20560
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta)) {
20739
+ if (attr.readsPreamble && mapPreambleWrapped) {
20740
+ lines.push(`${indent} ${mapPreambleWrapped}`);
20741
+ }
20742
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta, ordinal++)) {
20561
20743
  lines.push(`${indent} ${stmt}`);
20562
20744
  }
20563
20745
  lines.push(`${indent} }${profileBindingId(pc, slot.slotId)}))`);
@@ -20600,7 +20782,7 @@ function stringifyBranchInnerLoops(lines, plan, indent, pc) {
20600
20782
  lines.push(`${indent} __bel${uid}.setAttribute('${keyAttrName2(inner.keyDepth)}', String(${inner.wrappedKey}))`);
20601
20783
  }
20602
20784
  if (inner.legacyComponents.length > 0 || inner.legacyEvents.length > 0) {
20603
- emitComponentAndEventSetup(lines, `${indent} `, `__bel${uid}`, [...inner.legacyComponents], [...inner.legacyEvents], inner.outerLoopParam, inner.outerLoopParamBindings);
20785
+ emitComponentAndEventSetup(lines, `${indent} `, `__bel${uid}`, [...inner.legacyComponents], [...inner.legacyEvents], inner.outerLoopParam, inner.outerLoopParamBindings, false, inner.outerLoopIndex);
20604
20786
  }
20605
20787
  const conditionalTexts = inner.reactiveTexts.filter((t) => t.insideConditional);
20606
20788
  const plainTexts = inner.reactiveTexts.filter((t) => !t.insideConditional);
@@ -20617,32 +20799,35 @@ function stringifyBranchInnerLoops(lines, plan, indent, pc) {
20617
20799
  }
20618
20800
  }
20619
20801
  if (inner.nestedConditionals.length > 0) {
20620
- stringifyLoopChildConditionals(lines, inner.nestedConditionals, `${indent} `, pc);
20802
+ stringifyLoopChildConditionals(lines, inner.nestedConditionals, `${indent} `, pc, undefined);
20621
20803
  }
20622
20804
  lines.push(`${indent} return __bel${uid}`);
20623
20805
  lines.push(`${indent}}, '${inner.markerId}'${mapArrayKeyArgs(profileBindingId(pc, inner.slotId), !!inner.wrappedKey, inner.keyDepth)}) }`);
20624
20806
  }
20625
20807
  }
20626
- function stringifyLoopChildConditionals(lines, conditionals, indent, pc) {
20808
+ function stringifyLoopChildConditionals(lines, conditionals, indent, pc, mapPreambleWrapped) {
20627
20809
  for (const cond of conditionals) {
20628
- stringifyLoopChildConditional(lines, cond, indent, pc);
20810
+ stringifyLoopChildConditional(lines, cond, indent, pc, mapPreambleWrapped);
20629
20811
  }
20630
20812
  }
20631
- function stringifyLoopChildConditional(lines, cond, indent, pc) {
20813
+ function conditionGetterExpr(wrappedCondition, readsPreamble, mapPreambleWrapped) {
20814
+ return readsPreamble && mapPreambleWrapped ? `() => { ${mapPreambleWrapped}; return (${wrappedCondition}) }` : `() => ${wrappedCondition}`;
20815
+ }
20816
+ function stringifyLoopChildConditional(lines, cond, indent, pc, mapPreambleWrapped) {
20632
20817
  const armIndent = `${indent} `;
20633
- lines.push(`${indent}insert(${cond.scopeVar}, '${cond.slotId}', () => ${cond.wrappedCondition}, {`);
20818
+ lines.push(`${indent}insert(${cond.scopeVar}, '${cond.slotId}', ${conditionGetterExpr(cond.wrappedCondition, cond.readsPreamble, mapPreambleWrapped)}, {`);
20634
20819
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenTrueTemplateHtml}\`, slots: __slots } },`);
20635
20820
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
20636
- stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc);
20821
+ stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc, mapPreambleWrapped);
20637
20822
  lines.push(`${indent} }`);
20638
20823
  lines.push(`${indent}}, {`);
20639
20824
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenFalseTemplateHtml}\`, slots: __slots } },`);
20640
20825
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
20641
- stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc);
20826
+ stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc, mapPreambleWrapped);
20642
20827
  lines.push(`${indent} }`);
20643
20828
  lines.push(`${indent}}${profileBindingId(pc, cond.slotId)})`);
20644
20829
  }
20645
- function stringifyLoopChildArm(lines, arm, armIndent, pc) {
20830
+ function stringifyLoopChildArm(lines, arm, armIndent, pc, mapPreambleWrapped) {
20646
20831
  stringifyBranchEventBindings(lines, arm.events, armIndent);
20647
20832
  stringifyBranchChildComponentInits(lines, arm.childComponents, armIndent);
20648
20833
  stringifyBranchInnerLoops(lines, arm.innerLoops, armIndent, pc);
@@ -20650,10 +20835,10 @@ function stringifyLoopChildArm(lines, arm, armIndent, pc) {
20650
20835
  if (!hasDisposables)
20651
20836
  return;
20652
20837
  lines.push(`${armIndent}const __disposers = []`);
20653
- stringifyBranchReactiveAttrs(lines, arm.attrs, armIndent, pc);
20838
+ stringifyBranchReactiveAttrs(lines, arm.attrs, armIndent, pc, mapPreambleWrapped);
20654
20839
  for (const cond of arm.nestedConditionals) {
20655
20840
  lines.push(`${armIndent}__disposers.push(createDisposableEffect(() => {`);
20656
- stringifyLoopChildConditional(lines, cond, `${armIndent} `, pc);
20841
+ stringifyLoopChildConditional(lines, cond, `${armIndent} `, pc, mapPreambleWrapped);
20657
20842
  lines.push(`${armIndent}}))`);
20658
20843
  }
20659
20844
  if (arm.texts.length > 0) {
@@ -20692,13 +20877,15 @@ function emitAttrSlotsGranular(lines, indent, elVar, lookup, attrSlots, elementI
20692
20877
  const varName = `__ra_${varSlotId(slot.slotId)}`;
20693
20878
  const lookupExpr = attrLookupExpr(slot.slotId, varName, elVar, lookup, elementIndexBySlot);
20694
20879
  lines.push(`${indent}{ const ${varName} = ${lookupExpr}`);
20880
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
20695
20881
  lines.push(`${indent}if (${varName}) {`);
20882
+ let ordinal = 0;
20696
20883
  for (const attr of slot.attrs) {
20697
20884
  lines.push(`${indent} createEffect(() => {`);
20698
20885
  if (attr.readsPreamble && mapPreambleWrapped) {
20699
20886
  lines.push(`${indent} ${mapPreambleWrapped}`);
20700
20887
  }
20701
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta)) {
20888
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta, ordinal++)) {
20702
20889
  lines.push(`${indent} ${stmt}`);
20703
20890
  }
20704
20891
  lines.push(`${indent} }${bindingBfId(slot.slotId)})`);
@@ -20734,6 +20921,8 @@ function emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, oute
20734
20921
  const varName = `__ra_${varSlotId(slot.slotId)}`;
20735
20922
  lines.push(`${indent}const ${varName} = ${attrLookupExpr(slot.slotId, varName, elVar, lookup, elementIndexBySlot)}`);
20736
20923
  }
20924
+ if (attrSlots.length > 0)
20925
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
20737
20926
  const claimSlots = [
20738
20927
  ...outerTexts.map((t) => ({ id: t.slotId, kind: "text", path: [], pathExpr: textClaimPathExprs?.get(t.slotId) })),
20739
20928
  ...preambleRegions.map((r) => ({ id: r.slotId, kind: "markup", path: [] }))
@@ -20751,15 +20940,14 @@ function emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, oute
20751
20940
  if (mapPreambleWrapped && (preambleRegions.length > 0 || attrsReadPreamble(attrSlots))) {
20752
20941
  lines.push(`${indent} ${mapPreambleWrapped}`);
20753
20942
  }
20943
+ let ordinal = 0;
20754
20944
  for (const slot of attrSlots) {
20755
20945
  const varName = `__ra_${varSlotId(slot.slotId)}`;
20756
20946
  lines.push(`${indent} if (${varName}) {`);
20757
20947
  for (const attr of slot.attrs) {
20758
- lines.push(`${indent} {`);
20759
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta)) {
20760
- lines.push(`${indent} ${stmt}`);
20948
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta, ordinal++)) {
20949
+ lines.push(`${indent} ${stmt}`);
20761
20950
  }
20762
- lines.push(`${indent} }`);
20763
20951
  }
20764
20952
  lines.push(`${indent} }`);
20765
20953
  }
@@ -20788,16 +20976,16 @@ function emitOuterTexts(lines, indent, elVar, texts, bindingBfId, textClaimPathE
20788
20976
  }
20789
20977
  function emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped) {
20790
20978
  const armIndent = `${indent} `;
20791
- const conditionGetter = cond.readsPreamble && mapPreambleWrapped ? `() => { ${mapPreambleWrapped}; return (${cond.wrappedCondition}) }` : `() => ${cond.wrappedCondition}`;
20979
+ const conditionGetter = conditionGetterExpr(cond.wrappedCondition, cond.readsPreamble, mapPreambleWrapped);
20792
20980
  lines.push(`${indent}insert(${elVar}, '${cond.slotId}', ${conditionGetter}, {`);
20793
20981
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenTrueTemplateHtml}\`, slots: __slots } },`);
20794
20982
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
20795
- stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc);
20983
+ stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc, mapPreambleWrapped);
20796
20984
  lines.push(`${indent} }`);
20797
20985
  lines.push(`${indent}}, {`);
20798
20986
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenFalseTemplateHtml}\`, slots: __slots } },`);
20799
20987
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
20800
- stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc);
20988
+ stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc, mapPreambleWrapped);
20801
20989
  lines.push(`${indent} }`);
20802
20990
  lines.push(`${indent}}${profileBindingId(pc, cond.slotId)})`);
20803
20991
  }
@@ -20940,6 +21128,8 @@ function stringifyLazyRowLoop(lines, o) {
20940
21128
  lines.push(`${indent}${o.guardContainer ? `if (${o.containerVar}) ` : ""}${call}`);
20941
21129
  const b1 = `${indent} `;
20942
21130
  const b2 = `${indent} `;
21131
+ if (lazyRow.readsIndex)
21132
+ lines.push(`${b1}indexDriven: true,`);
20943
21133
  lines.push(`${b1}createRow: (__e, ${o.indexParam}) => {`);
20944
21134
  lines.push(`${b2}const ${paramHead} = () => __e.item`);
20945
21135
  if (lazyRow.preambleStatements)
@@ -20969,6 +21159,8 @@ function stringifyLazyRowLoop(lines, o) {
20969
21159
  } else {
20970
21160
  lines.push(`${b1}applyItem: (__e) => {`);
20971
21161
  lines.push(`${b2}const ${paramHead} = () => __e.item`);
21162
+ if (lazyRow.readsIndex)
21163
+ lines.push(`${b2}const ${o.indexParam} = __e.index`);
20972
21164
  lines.push(`${b2}const __r = __e.refs ?? (__e.refs = [])`);
20973
21165
  lines.push(`${b2}const __l = __e.last ?? (__e.last = [])`);
20974
21166
  if (lazyRow.itemNeedsPreamble && lazyRow.preambleStatements) {
@@ -20995,6 +21187,8 @@ function stringifyLazyRowLoop(lines, o) {
20995
21187
  lines.push(`${b2}${g}()`);
20996
21188
  lines.push(`${b2}for (const __e of __es) {`);
20997
21189
  lines.push(`${b3}const ${paramHead} = () => __e.item`);
21190
+ if (lazyRow.readsIndex)
21191
+ lines.push(`${b3}const ${o.indexParam} = __e.index`);
20998
21192
  lines.push(`${b3}const __r = __e.refs ?? (__e.refs = [])`);
20999
21193
  lines.push(`${b3}const __l = __e.last ?? (__e.last = [])`);
21000
21194
  if (lazyRow.outerNeedsPreamble && lazyRow.preambleStatements) {
@@ -21060,24 +21254,14 @@ function emitConditional(lines, ind, mid, c, mode) {
21060
21254
  lines.push(`${ind} __l[${c.ordinal}] = __x`);
21061
21255
  lines.push(`${ind}} }`);
21062
21256
  }
21063
- function dedupGuard(ordinal) {
21064
- return `!(${ordinal} in __l) || !Object.is(__l[${ordinal}], __x)`;
21065
- }
21066
21257
  function emitAttrBinding(lines, ind, a, mode) {
21067
21258
  const target = mode === "create" ? `__r[${a.refIndex}]` : elementAccess(a);
21259
+ const guard = mode === "create" ? null : mode === "item" ? dedupGuard(a.ordinal) : `__seed ? (${seedDiffersExpr("__t", a)}) : (${dedupGuard(a.ordinal)})`;
21068
21260
  lines.push(`${ind}{ const __t = ${target}`);
21069
21261
  lines.push(`${ind}if (__t) {`);
21070
- lines.push(`${ind} const __x = ${a.wrappedExpression}`);
21071
- const guard = mode === "create" ? null : mode === "item" ? dedupGuard(a.ordinal) : `__seed ? (${seedDiffersExpr("__t", a)}) : (${dedupGuard(a.ordinal)})`;
21072
- const writeIndent = guard ? `${ind} ` : `${ind} `;
21073
- if (guard)
21074
- lines.push(`${ind} if (${guard}) {`);
21075
- for (const stmt of emitAttrUpdate("__t", a.attrName, "__x", a.meta)) {
21076
- lines.push(`${writeIndent}${stmt}`);
21077
- }
21078
- if (guard)
21079
- lines.push(`${ind} }`);
21080
- lines.push(`${ind} __l[${a.ordinal}] = __x`);
21262
+ for (const stmt of emitDedupedAttrUpdate("__t", a.attrName, a.wrappedExpression, a.meta, a.ordinal, guard)) {
21263
+ lines.push(`${ind} ${stmt}`);
21264
+ }
21081
21265
  lines.push(`${ind}} }`);
21082
21266
  }
21083
21267
  function emitTextBinding(lines, ind, t, doorExpr, mode, rwDoor) {
@@ -21367,13 +21551,16 @@ function stringifyStaticLoop(lines, plan) {
21367
21551
  lines.push(` }`);
21368
21552
  }
21369
21553
  lines.push(` if (__iterEl) {`);
21554
+ if (attrsBySlot.length > 0)
21555
+ lines.push(` ${DEDUP_STORE_DECL}`);
21556
+ let ordinal = 0;
21370
21557
  for (const [slotId, attrs] of attrsBySlot) {
21371
21558
  const varName = `__t_${varSlotId(slotId)}`;
21372
21559
  lines.push(` const ${varName} = qsa(__iterEl, '[bf="${slotId}"]')`);
21373
21560
  lines.push(` if (${varName}) {`);
21374
21561
  for (const attr of attrs) {
21375
21562
  lines.push(` createEffect(() => {`);
21376
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.expression, attr)) {
21563
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.expression, attr, ordinal++)) {
21377
21564
  lines.push(` ${stmt}`);
21378
21565
  }
21379
21566
  lines.push(` }${profileBindingId(pc, slotId)})`);
@@ -21398,18 +21585,12 @@ function stringifyStaticLoop(lines, plan) {
21398
21585
  // ../jsx/src/ir-to-client-js/control-flow/stringify/inner-loop.ts
21399
21586
  function stringifyInnerLoops(lines, plan, indent, pc) {
21400
21587
  for (const inner of plan) {
21401
- if (inner.emit.mode === "reactive") {
21402
- emitReactive(lines, inner, indent, pc);
21403
- } else {
21404
- emitStatic(lines, inner, indent, pc);
21405
- }
21588
+ emitReactive(lines, inner, indent, pc);
21406
21589
  }
21407
21590
  }
21408
21591
  function emitReactive(lines, inner, indent, pc) {
21409
21592
  const uid = inner.uidSuffix;
21410
21593
  const emit = inner.emit;
21411
- if (emit.mode !== "reactive")
21412
- return;
21413
21594
  lines.push(`${indent}// Reactive inner loop: ${inner.arraySrc}`);
21414
21595
  lines.push(`${indent}{ const __ic${uid} = ${inner.containerExpr}`);
21415
21596
  lines.push(`${indent}if (__ic${uid}) mapArray(() => ${inner.arrayExpr} || [], __ic${uid}, ${emit.keyFn}, (${emit.paramHead}, __innerIdx${uid}, __existing) => {`);
@@ -21435,7 +21616,7 @@ function emitReactive(lines, inner, indent, pc) {
21435
21616
  lines.push(`${indent} __innerEl${uid}.setAttribute('${keyAttrName2(inner.keyDepth)}', String(${emit.wrappedKey}))`);
21436
21617
  }
21437
21618
  if (emit.components.length > 0 || emit.events.length > 0) {
21438
- emitComponentAndEventSetup(lines, `${indent} `, `__innerEl${uid}`, [...emit.components], [...emit.events], inner.outerLoopParam, inner.outerLoopParamBindings);
21619
+ emitComponentAndEventSetup(lines, `${indent} `, `__innerEl${uid}`, [...emit.components], [...emit.events], inner.outerLoopParam, inner.outerLoopParamBindings, false, inner.outerLoopIndex);
21439
21620
  }
21440
21621
  if (inner.childLevels.length > 0) {
21441
21622
  stringifyInnerLoops(lines, inner.childLevels, `${indent} `, pc);
@@ -21454,17 +21635,20 @@ function emitReactive(lines, inner, indent, pc) {
21454
21635
  lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}', String(${text.wrappedExpression})) }${profileBindingId(pc, text.slotId)})`);
21455
21636
  }
21456
21637
  }
21638
+ if (emit.reactiveAttrs.length > 0)
21639
+ lines.push(`${indent} ${DEDUP_STORE_DECL}`);
21640
+ let attrOrdinal = 0;
21457
21641
  for (const attr of emit.reactiveAttrs) {
21458
21642
  const targetVar = `__ta_${attr.slotId.replace(/[^a-zA-Z0-9]/g, "_")}`;
21459
21643
  lines.push(`${indent} { const ${targetVar} = qsa(__innerEl${uid}, '[bf="${attr.slotId}"]')`);
21460
21644
  lines.push(`${indent} if (${targetVar}) createEffect(() => {`);
21461
- for (const stmt of emitAttrUpdate(targetVar, attr.attrName, attr.wrappedExpression, attr.meta)) {
21645
+ for (const stmt of emitDedupedAttrUpdate(targetVar, attr.attrName, attr.wrappedExpression, attr.meta, attrOrdinal++)) {
21462
21646
  lines.push(`${indent} ${stmt}`);
21463
21647
  }
21464
21648
  lines.push(`${indent} }${profileBindingId(pc, attr.slotId)}) }`);
21465
21649
  }
21466
21650
  if (emit.conditionals.length > 0) {
21467
- stringifyLoopChildConditionals(lines, emit.conditionals, `${indent} `, pc);
21651
+ stringifyLoopChildConditionals(lines, emit.conditionals, `${indent} `, pc, undefined);
21468
21652
  }
21469
21653
  emitLoopChildRefs(lines, emit.childRefs, {
21470
21654
  indent: `${indent} `,
@@ -21474,33 +21658,6 @@ function emitReactive(lines, inner, indent, pc) {
21474
21658
  lines.push(`${indent} return __innerEl${uid}`);
21475
21659
  lines.push(`${indent}}, '${inner.markerId}'${mapArrayKeyArgs(profileBindingId(pc, inner.slotId), !!emit.wrappedKey, inner.keyDepth)}) }`);
21476
21660
  }
21477
- function emitStatic(lines, inner, indent, pc) {
21478
- const uid = inner.uidSuffix;
21479
- const emit = inner.emit;
21480
- if (emit.mode !== "static")
21481
- return;
21482
- lines.push(`${indent}// Initialize ${inner.arraySrc} loop components and events`);
21483
- lines.push(`${indent}{ const __ic${uid} = ${inner.containerExpr}`);
21484
- lines.push(`${indent}if (__ic${uid} && ${inner.arrayExpr}) ${inner.arrayExpr}.forEach((${inner.param}, __innerIdx${uid}) => {`);
21485
- lines.push(`${indent} const __innerEl${uid} = __ic${uid}.children[__innerIdx${uid}]`);
21486
- lines.push(`${indent} if (!__innerEl${uid}) return`);
21487
- for (const stmt of emit.preludeStatements) {
21488
- lines.push(`${indent} ${stmt}`);
21489
- }
21490
- if (emit.rawKey) {
21491
- lines.push(`${indent} __innerEl${uid}.setAttribute('${keyAttrName2(inner.keyDepth)}', String(${emit.rawKey}))`);
21492
- }
21493
- emitComponentAndEventSetup(lines, `${indent} `, `__innerEl${uid}`, [...emit.components], [...emit.events], inner.outerLoopParam, inner.outerLoopParamBindings);
21494
- if (inner.childLevels.length > 0) {
21495
- stringifyInnerLoops(lines, inner.childLevels, `${indent} `, pc);
21496
- }
21497
- emitLoopChildRefs(lines, emit.childRefs, {
21498
- indent: `${indent} `,
21499
- elVar: `__innerEl${uid}`,
21500
- bodyIsMultiRoot: false
21501
- });
21502
- lines.push(`${indent}}) }`);
21503
- }
21504
21661
 
21505
21662
  // ../jsx/src/ir-to-client-js/control-flow/stringify/composite-loop.ts
21506
21663
  function stringifyCompositeLoop(lines, plan) {
@@ -21519,6 +21676,7 @@ function stringifyCompositeLoop(lines, plan) {
21519
21676
  innerLoops,
21520
21677
  loopParam,
21521
21678
  loopParamBindings,
21679
+ loopIndex,
21522
21680
  reactiveEffects,
21523
21681
  childRefs,
21524
21682
  branchClearChildren,
@@ -21551,7 +21709,7 @@ function stringifyCompositeLoop(lines, plan) {
21551
21709
  singleRootLayout: "multiline",
21552
21710
  mountRow: true
21553
21711
  });
21554
- emitComponentAndEventSetup(lines, bodyIndent, "__el", compsArr, eventsArr, loopParam, loopParamBindings, bodyIsMultiRoot);
21712
+ emitComponentAndEventSetup(lines, bodyIndent, "__el", compsArr, eventsArr, loopParam, loopParamBindings, bodyIsMultiRoot, loopIndex);
21555
21713
  if (innerLoops.length > 0) {
21556
21714
  stringifyInnerLoops(lines, innerLoops, bodyIndent, pc);
21557
21715
  }
@@ -21928,10 +22086,12 @@ function emitArmBody(lines, body, mode, indent, profileComponentName) {
21928
22086
  const v = varSlotId(slotId);
21929
22087
  const elVar = `__ra_${v}`;
21930
22088
  lines.push(`${indent}{ const ${elVar} = qsa(__branchScope, '[bf="${slotId}"]')`);
22089
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
21931
22090
  lines.push(`${indent}if (${elVar}) {`);
22091
+ let ordinal = 0;
21932
22092
  for (const attr of attrs) {
21933
22093
  lines.push(`${indent} __disposers.push(createDisposableEffect(() => {`);
21934
- for (const stmt of emitAttrUpdate(elVar, attr.attrName, attr.expression, attr)) {
22094
+ for (const stmt of emitDedupedAttrUpdate(elVar, attr.attrName, attr.expression, attr, ordinal++)) {
21935
22095
  lines.push(`${indent} ${stmt}`);
21936
22096
  }
21937
22097
  lines.push(`${indent} }${bindingBfId(slotId)}))`);
@@ -21973,11 +22133,11 @@ function scopeRefToVar(ref) {
21973
22133
  // ../jsx/src/ir-to-client-js/control-flow/plan/build-component-loop.ts
21974
22134
  function buildComponentLoopPlan(elem, profileComponentName) {
21975
22135
  const { name } = elem.childComponent;
21976
- const propsExpr = buildComponentPropsExpr2(elem.childComponent, elem.param);
21977
- const keyExpr = wrapLoopParamAsAccessor(elem.key || "__idx", elem.param, elem.paramBindings);
22136
+ const propsExpr = buildComponentPropsExpr2(elem.childComponent, elem.param, undefined, elem.index);
22137
+ const keyExpr = wrapLoopParamAsAccessor(elem.key || "__idx", elem.param, elem.paramBindings, elem.index);
21978
22138
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(elem.param, elem.paramBindings);
21979
22139
  const mapPreambleWrapped = elem.preamble ? renderPreamble(elem.preamble, {
21980
- transformJs: (text) => wrapLoopParamAsAccessor(text, elem.param, elem.paramBindings),
22140
+ transformJs: (text) => wrapLoopParamAsAccessor(text, elem.param, elem.paramBindings, elem.index),
21981
22141
  renderLeaf: () => {
21982
22142
  internalInvariant(false, "component-root loop received a JSX-bearing preamble — Phase 1 should have refused it");
21983
22143
  }
@@ -21987,12 +22147,12 @@ function buildComponentLoopPlan(elem, profileComponentName) {
21987
22147
  const isTextOnly = comp.children?.length ? comp.children.every((c) => c.type === "expression" || c.type === "text" || isTextOnlyConditional(c)) : false;
21988
22148
  const rawChildrenExpr = isTextOnly ? irChildrenToJsExpr(comp.children) : null;
21989
22149
  const childrenFreeIds = isTextOnly && comp.children ? irChildrenFreeIds(comp.children) : undefined;
21990
- const childrenRefsLoop = rawChildrenExpr != null && childrenFreeIds != null && childrenFreeIds.has(elem.param);
22150
+ const childrenRefsLoop = rawChildrenExpr != null && childrenFreeIds != null && (childrenFreeIds.has(elem.param) || !!elem.index && childrenFreeIds.has(elem.index));
21991
22151
  return {
21992
22152
  componentName: comp.name,
21993
22153
  selector: buildCompSelector(comp),
21994
- propsExpr: buildComponentPropsExpr2(comp, elem.param),
21995
- childrenTextEffect: childrenRefsLoop ? { wrappedChildren: wrapLoopParamAsAccessor(rawChildrenExpr, elem.param, elem.paramBindings) } : null
22154
+ propsExpr: buildComponentPropsExpr2(comp, elem.param, undefined, elem.index),
22155
+ childrenTextEffect: childrenRefsLoop ? { wrappedChildren: wrapLoopParamAsAccessor(rawChildrenExpr, elem.param, elem.paramBindings, elem.index) } : null
21996
22156
  };
21997
22157
  });
21998
22158
  const hasChildConds = elem.bindings.conditionals.length > 0;
@@ -22011,7 +22171,7 @@ function buildComponentLoopPlan(elem, profileComponentName) {
22011
22171
  componentPropsExpr: propsExpr,
22012
22172
  keyExpr,
22013
22173
  nestedComps,
22014
- childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings),
22174
+ childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings, elem.index),
22015
22175
  profileLoopId: profileComponentName ? `${profileComponentName}#binding:${elem.slotId}` : undefined,
22016
22176
  childConditionalEffects: hasChildConds ? buildReactiveEffectsPlan({
22017
22177
  attrs: [],
@@ -22019,6 +22179,7 @@ function buildComponentLoopPlan(elem, profileComponentName) {
22019
22179
  conditionals: elem.bindings.conditionals,
22020
22180
  loopParam: elem.param,
22021
22181
  loopParamBindings: elem.paramBindings,
22182
+ loopIndex: elem.index,
22022
22183
  profileComponentName
22023
22184
  }) : null
22024
22185
  };
@@ -22042,8 +22203,6 @@ function buildLoopPlan(elem, opts) {
22042
22203
  return buildPlainLoopPlan(elem, opts.profileComponentName, opts.lazyScope);
22043
22204
  }
22044
22205
  function buildPlainLoopPlan(elem, profileComponentName, lazyScope) {
22045
- const wrap = (expr) => wrapLoopParamAsAccessor(expr, elem.param, elem.paramBindings);
22046
- const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(elem.param, elem.paramBindings);
22047
22206
  const hasReactive2 = elem.bindings.reactiveAttrs.length > 0 || elem.bindings.reactiveTexts.length > 0 || elem.bindings.conditionals.length > 0;
22048
22207
  if (elem.flatMapClient) {
22049
22208
  return {
@@ -22069,12 +22228,15 @@ function buildPlainLoopPlan(elem, profileComponentName, lazyScope) {
22069
22228
  };
22070
22229
  }
22071
22230
  const arrayExpr = buildChainedArrayExpr(elem);
22072
- const indexParam = elem.index || "__idx";
22073
- const mapPreambleWrapped = elem.preamble ? renderPreamble(elem.preamble, {
22074
- transformJs: wrap,
22075
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: elem.param, bindings: elem.paramBindings }], undefined)
22076
- }) : "";
22077
- const preambleRegions = buildPreambleRegionPlans(elem.preambleRegions, elem.param, elem.paramBindings);
22231
+ const core = buildPlainRowCore({
22232
+ loop: elem,
22233
+ arrayExpr,
22234
+ callSite: "plain",
22235
+ flatMapLeafItem: false,
22236
+ anchored: elem.bodyIsItemConditional ?? false,
22237
+ scope: lazyScope
22238
+ });
22239
+ const { paramHead, paramUnwrap, indexParam, preambleRegions, lazyRow, wrapItem: wrap } = core;
22078
22240
  return {
22079
22241
  kind: "plain",
22080
22242
  rowConstruction: "string-template",
@@ -22086,28 +22248,17 @@ function buildPlainLoopPlan(elem, profileComponentName, lazyScope) {
22086
22248
  paramHead,
22087
22249
  paramUnwrap,
22088
22250
  indexParam,
22089
- lazyRow: buildLazyRowPlan({
22090
- loop: elem,
22091
- arrayExpr,
22092
- indexParam,
22093
- paramUnwrap,
22094
- mapPreambleWrapped,
22095
- preambleRegionCount: preambleRegions.length,
22096
- callSite: "plain",
22097
- flatMapLeafItem: false,
22098
- anchored: elem.bodyIsItemConditional ?? false,
22099
- scope: lazyScope
22100
- }) ?? undefined,
22101
- mapPreambleWrapped,
22102
- template: elem.template,
22251
+ lazyRow,
22252
+ mapPreambleWrapped: core.mapPreambleWrapped,
22253
+ template: core.template,
22103
22254
  skeletonTemplate: elem.skeletonTemplate,
22104
22255
  skeletonPaths: elem.skeletonPaths,
22105
22256
  reactiveEffects: hasReactive2 ? buildLoopReactiveEffectsPlan(elem, profileComponentName) : null,
22106
- childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings),
22257
+ childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings, elem.index),
22107
22258
  preambleRegions,
22108
22259
  bodyIsMultiRoot: elem.bodyIsMultiRoot ?? false,
22109
22260
  anchored: elem.bodyIsItemConditional ?? false,
22110
- anchorKeyExpr: elem.key ? wrap(elem.key) : elem.index || "__idx"
22261
+ anchorKeyExpr: elem.key ? wrap(elem.key) : `${indexParam}()`
22111
22262
  };
22112
22263
  }
22113
22264
  function buildStaticLoopPlan(elem, unsafeLocalNames, profileComponentName) {
@@ -22149,7 +22300,7 @@ function buildStaticLoopMaterialize(elem, unsafeLocalNames) {
22149
22300
  return {
22150
22301
  itemTemplate: elem.staticItemTemplate,
22151
22302
  mapPreamble: elem.preamble ? renderPreamble(elem.preamble, {
22152
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: elem.param, bindings: elem.paramBindings }], undefined)
22303
+ renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: elem.param, bindings: elem.paramBindings, index: elem.index }], undefined)
22153
22304
  }) : "",
22154
22305
  bodyIsMultiRoot: elem.bodyIsMultiRoot ?? false
22155
22306
  };
@@ -22725,7 +22876,7 @@ function generateTemplateOnlyMount(ir, ctx) {
22725
22876
  const restSpreadNames = resolveRestSpreadNames(ctx);
22726
22877
  let templateHtml;
22727
22878
  if (canGenerateStaticTemplate(ir.root, propNamesForStaticCheck, inlinableConstants, unsafeLocalNames)) {
22728
- const markupSlotIds = new Set(ctx.dynamicElements.map((e) => e.slotId));
22879
+ const markupSlotIds = markupSlotIdsOf(ctx);
22729
22880
  templateHtml = irToComponentTemplate(ir.root, inlinableConstants, restSpreadNames, ctx.propsObjectName, markupSlotIds, ctx.restPropsName);
22730
22881
  }
22731
22882
  if (!templateHtml) {
@@ -23443,6 +23594,21 @@ function extractSsrDefaults(metadata) {
23443
23594
  }
23444
23595
  bindings[memo.name] = value;
23445
23596
  }
23597
+ {
23598
+ const getterNames = collectAliasableGetterNames(metadata.signals, metadata.memos);
23599
+ for (const [alias, origin] of resolveGetterAliases(metadata.localConstants ?? [], (n) => getterNames.has(n))) {
23600
+ if (alias in out)
23601
+ continue;
23602
+ out[alias] = out[origin];
23603
+ }
23604
+ }
23605
+ for (const [local, callerKey] of resolveBodyDestructuredPropAliases(metadata.localConstants ?? [], metadata.propsObjectName)) {
23606
+ if (local in out)
23607
+ continue;
23608
+ const origin = out[callerKey];
23609
+ if (origin)
23610
+ out[local] = origin;
23611
+ }
23446
23612
  if (metadata.propsObjectName !== null) {
23447
23613
  const referenced = new Set;
23448
23614
  for (const sig of metadata.signals) {