@barefootjs/jsx 0.35.0 → 0.35.2

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 (72) hide show
  1. package/dist/analyzer-context.d.ts.map +1 -1
  2. package/dist/index.js +731 -691
  3. package/dist/ir-to-client-js/collect-elements.d.ts +22 -2
  4. package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
  5. package/dist/ir-to-client-js/control-flow/plan/build-composite-loop.d.ts.map +1 -1
  6. package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts +14 -2
  7. package/dist/ir-to-client-js/control-flow/plan/build-inner-loop.d.ts.map +1 -1
  8. package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts.map +1 -1
  9. package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts +6 -1
  10. package/dist/ir-to-client-js/control-flow/plan/build-loop-child-arm.d.ts.map +1 -1
  11. package/dist/ir-to-client-js/control-flow/plan/build-plain-row.d.ts.map +1 -1
  12. package/dist/ir-to-client-js/control-flow/plan/build-reactive-effects.d.ts +3 -2
  13. package/dist/ir-to-client-js/control-flow/plan/build-reactive-effects.d.ts.map +1 -1
  14. package/dist/ir-to-client-js/control-flow/plan/inner-loop.d.ts +24 -44
  15. package/dist/ir-to-client-js/control-flow/plan/inner-loop.d.ts.map +1 -1
  16. package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts +14 -0
  17. package/dist/ir-to-client-js/control-flow/plan/loop-child-arm.d.ts.map +1 -1
  18. package/dist/ir-to-client-js/control-flow/stringify/inner-loop.d.ts +6 -14
  19. package/dist/ir-to-client-js/control-flow/stringify/inner-loop.d.ts.map +1 -1
  20. package/dist/ir-to-client-js/control-flow/stringify/lazy-row.d.ts +1 -3
  21. package/dist/ir-to-client-js/control-flow/stringify/lazy-row.d.ts.map +1 -1
  22. package/dist/ir-to-client-js/control-flow/stringify/loop-child-arm.d.ts +19 -3
  23. package/dist/ir-to-client-js/control-flow/stringify/loop-child-arm.d.ts.map +1 -1
  24. package/dist/ir-to-client-js/control-flow/stringify/loop.d.ts.map +1 -1
  25. package/dist/ir-to-client-js/control-flow/stringify/reactive-effects.d.ts +5 -1
  26. package/dist/ir-to-client-js/control-flow/stringify/reactive-effects.d.ts.map +1 -1
  27. package/dist/ir-to-client-js/emit-reactive.d.ts +54 -0
  28. package/dist/ir-to-client-js/emit-reactive.d.ts.map +1 -1
  29. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  30. package/dist/ir-to-client-js/reactivity.d.ts +62 -18
  31. package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
  32. package/dist/ir-to-client-js/types.d.ts +18 -2
  33. package/dist/ir-to-client-js/types.d.ts.map +1 -1
  34. package/dist/reactivity-checker.d.ts +18 -0
  35. package/dist/reactivity-checker.d.ts.map +1 -1
  36. package/package.json +2 -2
  37. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +128 -10
  38. package/src/__tests__/binding-scope-ratchet.test.ts +26 -3
  39. package/src/__tests__/child-prop-fallback-wrap.test.ts +4 -2
  40. package/src/__tests__/compiler-stress-1244.test.ts +8 -8
  41. package/src/__tests__/issue-2868-cond-arm-tag-collision.test.ts +185 -0
  42. package/src/__tests__/issue-2869-attr-dedup-guard.test.ts +141 -0
  43. package/src/__tests__/loop-index-reactivity.test.ts +208 -0
  44. package/src/__tests__/map-body-brand-checker.test.ts +176 -0
  45. package/src/__tests__/nested-loop-index-param.test.ts +27 -5
  46. package/src/__tests__/nested-loop-non-outer-reactivity.test.ts +177 -0
  47. package/src/__tests__/nested-loop-plain.test.ts +39 -25
  48. package/src/__tests__/nested-loop-reactive-attrs.test.ts +12 -4
  49. package/src/__tests__/preamble-branch-arm-rerun.test.ts +135 -0
  50. package/src/__tests__/style-css-var-reactive.test.ts +4 -1
  51. package/src/analyzer-context.ts +12 -10
  52. package/src/ir-to-client-js/collect-elements.ts +110 -32
  53. package/src/ir-to-client-js/control-flow/plan/build-composite-loop.ts +2 -0
  54. package/src/ir-to-client-js/control-flow/plan/build-inner-loop.ts +28 -51
  55. package/src/ir-to-client-js/control-flow/plan/build-lazy-row.ts +7 -2
  56. package/src/ir-to-client-js/control-flow/plan/build-loop-child-arm.ts +33 -6
  57. package/src/ir-to-client-js/control-flow/plan/build-plain-row.ts +7 -1
  58. package/src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts +18 -6
  59. package/src/ir-to-client-js/control-flow/plan/inner-loop.ts +24 -45
  60. package/src/ir-to-client-js/control-flow/plan/loop-child-arm.ts +14 -0
  61. package/src/ir-to-client-js/control-flow/stringify/inner-loop.ts +20 -66
  62. package/src/ir-to-client-js/control-flow/stringify/insert.ts +4 -2
  63. package/src/ir-to-client-js/control-flow/stringify/lazy-row.ts +12 -15
  64. package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +53 -11
  65. package/src/ir-to-client-js/control-flow/stringify/loop.ts +4 -2
  66. package/src/ir-to-client-js/control-flow/stringify/reactive-effects.ts +29 -18
  67. package/src/ir-to-client-js/emit-reactive.ts +88 -5
  68. package/src/ir-to-client-js/html-template.ts +9 -1
  69. package/src/ir-to-client-js/reactivity.ts +73 -27
  70. package/src/ir-to-client-js/types.ts +19 -3
  71. package/src/jsx-to-ir.ts +21 -4
  72. package/src/reactivity-checker.ts +60 -0
package/dist/index.js CHANGED
@@ -180,7 +180,7 @@ function findTopLevelTemplateLiterals(code) {
180
180
  import ts25 from "typescript";
181
181
 
182
182
  // src/analyzer.ts
183
- import ts10 from "typescript";
183
+ import ts11 from "typescript";
184
184
 
185
185
  // src/expression-parser.ts
186
186
  import ts2 from "typescript";
@@ -3966,7 +3966,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3966
3966
  case "expression":
3967
3967
  case "template":
3968
3968
  case "spread": {
3969
- const expr = attrValueToString(p.value, { useTemplate: true }) ?? "undefined";
3969
+ const expr = wrapExpr(attrValueToString(p.value, { useTemplate: true }) ?? "undefined");
3970
3970
  return `${quotePropName(p.name)}: ${expr}`;
3971
3971
  }
3972
3972
  }
@@ -5151,7 +5151,7 @@ function incrementCounter(key) {
5151
5151
  }
5152
5152
 
5153
5153
  // src/analyzer-context.ts
5154
- import ts9 from "typescript";
5154
+ import ts10 from "typescript";
5155
5155
 
5156
5156
  // src/strip-types.ts
5157
5157
  import ts8 from "typescript";
@@ -5368,6 +5368,140 @@ function findAngleBracketAfter(lastTypeArg, fullText) {
5368
5368
  return -1;
5369
5369
  }
5370
5370
 
5371
+ // src/reactivity-checker.ts
5372
+ import ts9 from "typescript";
5373
+ var REACTIVE_BRAND = "__reactive";
5374
+ function queryType(checker, node) {
5375
+ incrementCounter("typeCheckerQueries");
5376
+ return checker.getTypeAtLocation(node);
5377
+ }
5378
+ function isReactiveType(type) {
5379
+ return type.getProperty(REACTIVE_BRAND) !== undefined;
5380
+ }
5381
+ var NOT_REACTIVE = { isReactive: false, reason: { kind: "not-reactive" } };
5382
+ function safeGetText(node) {
5383
+ try {
5384
+ return node.getText();
5385
+ } catch {
5386
+ return "";
5387
+ }
5388
+ }
5389
+ function analyze(node, checker) {
5390
+ if (ts9.isPropertyAccessExpression(node)) {
5391
+ try {
5392
+ const type = queryType(checker, node);
5393
+ if (isReactiveType(type)) {
5394
+ return {
5395
+ isReactive: true,
5396
+ reason: { kind: "brand", via: "property-access", nodeText: safeGetText(node) }
5397
+ };
5398
+ }
5399
+ } catch {}
5400
+ const sub = analyze(node.expression, checker);
5401
+ if (sub.isReactive) {
5402
+ return {
5403
+ isReactive: true,
5404
+ reason: {
5405
+ kind: "child",
5406
+ via: "property-access-object",
5407
+ childText: safeGetText(node.expression),
5408
+ childReason: sub.reason
5409
+ }
5410
+ };
5411
+ }
5412
+ return NOT_REACTIVE;
5413
+ }
5414
+ if (ts9.isIdentifier(node)) {
5415
+ try {
5416
+ const type = queryType(checker, node);
5417
+ if (isReactiveType(type)) {
5418
+ return {
5419
+ isReactive: true,
5420
+ reason: { kind: "brand", via: "identifier", nodeText: safeGetText(node) }
5421
+ };
5422
+ }
5423
+ } catch {}
5424
+ return NOT_REACTIVE;
5425
+ }
5426
+ if (ts9.isCallExpression(node)) {
5427
+ try {
5428
+ const calleeType = queryType(checker, node.expression);
5429
+ if (isReactiveType(calleeType)) {
5430
+ return {
5431
+ isReactive: true,
5432
+ reason: { kind: "brand", via: "callee", nodeText: safeGetText(node) }
5433
+ };
5434
+ }
5435
+ } catch {}
5436
+ }
5437
+ let foundChild;
5438
+ let foundChildText = "";
5439
+ ts9.forEachChild(node, (child) => {
5440
+ if (foundChild?.isReactive)
5441
+ return;
5442
+ const result = analyze(child, checker);
5443
+ if (result.isReactive) {
5444
+ foundChild = result;
5445
+ foundChildText = safeGetText(child);
5446
+ }
5447
+ });
5448
+ if (foundChild?.isReactive) {
5449
+ return {
5450
+ isReactive: true,
5451
+ reason: {
5452
+ kind: "child",
5453
+ via: "sub-expression",
5454
+ childText: foundChildText,
5455
+ childReason: foundChild.reason
5456
+ }
5457
+ };
5458
+ }
5459
+ return NOT_REACTIVE;
5460
+ }
5461
+ var brandTypeReactivityAnalyzer = { analyze };
5462
+ function containsReactiveExpression(node, checker) {
5463
+ incrementCounter("reactivityChecks");
5464
+ return brandTypeReactivityAnalyzer.analyze(node, checker).isReactive;
5465
+ }
5466
+ function nodeContainsJsx(node) {
5467
+ if (ts9.isJsxElement(node) || ts9.isJsxSelfClosingElement(node) || ts9.isJsxFragment(node))
5468
+ return true;
5469
+ return ts9.forEachChild(node, nodeContainsJsx) ?? false;
5470
+ }
5471
+ function collectReactiveBrandLeaves(node, checker) {
5472
+ const leaves = [];
5473
+ const visit = (n) => {
5474
+ if (ts9.isPropertyAccessExpression(n)) {
5475
+ try {
5476
+ if (isReactiveType(queryType(checker, n))) {
5477
+ leaves.push(n);
5478
+ return;
5479
+ }
5480
+ } catch {}
5481
+ visit(n.expression);
5482
+ return;
5483
+ }
5484
+ if (ts9.isIdentifier(n)) {
5485
+ try {
5486
+ if (isReactiveType(queryType(checker, n)))
5487
+ leaves.push(n);
5488
+ } catch {}
5489
+ return;
5490
+ }
5491
+ if (ts9.isCallExpression(n)) {
5492
+ try {
5493
+ if (isReactiveType(queryType(checker, n.expression))) {
5494
+ leaves.push(nodeContainsJsx(n) ? n.expression : n);
5495
+ return;
5496
+ }
5497
+ } catch {}
5498
+ }
5499
+ ts9.forEachChild(n, visit);
5500
+ };
5501
+ visit(node);
5502
+ return leaves;
5503
+ }
5504
+
5371
5505
  // src/analyzer-context.ts
5372
5506
  function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
5373
5507
  return {
@@ -5419,7 +5553,7 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
5419
5553
  } catch {
5420
5554
  ownSourceFile = undefined;
5421
5555
  }
5422
- if (process.env.BF_ASSERT_NO_JSX_IN_GETJS === "1" && this.errors.length === 0 && nodeContainsJsx(node)) {
5556
+ if (process.env.BF_ASSERT_NO_JSX_IN_GETJS === "1" && !this.errors.some((e) => e.severity === "error") && nodeContainsJsx(node)) {
5423
5557
  throw new Error("getJS() called on a JSX-bearing node — raw JSX must never be spliced " + "into emitted output. Carry mixed content as structured segments " + "(MapCallbackPreamble / FlatMapCallback) instead.");
5424
5558
  }
5425
5559
  if (ownSourceFile && ownSourceFile !== sourceFile) {
@@ -5429,11 +5563,6 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
5429
5563
  }
5430
5564
  };
5431
5565
  }
5432
- function nodeContainsJsx(node) {
5433
- if (ts9.isJsxElement(node) || ts9.isJsxSelfClosingElement(node) || ts9.isJsxFragment(node))
5434
- return true;
5435
- return ts9.forEachChild(node, nodeContainsJsx) ?? false;
5436
- }
5437
5566
  function getSourceLocation(node, sourceFile, filePath) {
5438
5567
  const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());
5439
5568
  const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());
@@ -5450,20 +5579,20 @@ function getSourceLocation(node, sourceFile, filePath) {
5450
5579
  };
5451
5580
  }
5452
5581
  function membersToProperties(members, sourceFile) {
5453
- return members.filter(ts9.isPropertySignature).map((member) => ({
5582
+ return members.filter(ts10.isPropertySignature).map((member) => ({
5454
5583
  name: propertyNameText(member.name, sourceFile),
5455
5584
  type: typeNodeToTypeInfo(member.type, sourceFile) ?? {
5456
5585
  kind: "unknown",
5457
5586
  raw: "unknown"
5458
5587
  },
5459
5588
  optional: !!member.questionToken,
5460
- readonly: !!member.modifiers?.some((m) => m.kind === ts9.SyntaxKind.ReadonlyKeyword)
5589
+ readonly: !!member.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ReadonlyKeyword)
5461
5590
  }));
5462
5591
  }
5463
5592
  function propertyNameText(name, sourceFile) {
5464
5593
  if (!name)
5465
5594
  return "";
5466
- if (ts9.isStringLiteral(name) || ts9.isNumericLiteral(name))
5595
+ if (ts10.isStringLiteral(name) || ts10.isNumericLiteral(name))
5467
5596
  return name.text;
5468
5597
  return name.getText(sourceFile);
5469
5598
  }
@@ -5474,56 +5603,56 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
5474
5603
  const raw = rawOf ? rawOf(typeNode) : typeNode.getText(sourceFile);
5475
5604
  const recurse = (n) => typeNodeToTypeInfo(n, sourceFile, rawOf) ?? { kind: "unknown", raw: "unknown" };
5476
5605
  switch (typeNode.kind) {
5477
- case ts9.SyntaxKind.StringKeyword:
5606
+ case ts10.SyntaxKind.StringKeyword:
5478
5607
  return { kind: "primitive", raw, primitive: "string" };
5479
- case ts9.SyntaxKind.NumberKeyword:
5608
+ case ts10.SyntaxKind.NumberKeyword:
5480
5609
  return { kind: "primitive", raw, primitive: "number" };
5481
- case ts9.SyntaxKind.BooleanKeyword:
5610
+ case ts10.SyntaxKind.BooleanKeyword:
5482
5611
  return { kind: "primitive", raw, primitive: "boolean" };
5483
- case ts9.SyntaxKind.NullKeyword:
5612
+ case ts10.SyntaxKind.NullKeyword:
5484
5613
  return { kind: "primitive", raw, primitive: "null" };
5485
- case ts9.SyntaxKind.UndefinedKeyword:
5614
+ case ts10.SyntaxKind.UndefinedKeyword:
5486
5615
  return { kind: "primitive", raw, primitive: "undefined" };
5487
5616
  }
5488
- if (ts9.isArrayTypeNode(typeNode)) {
5617
+ if (ts10.isArrayTypeNode(typeNode)) {
5489
5618
  return { kind: "array", raw, elementType: recurse(typeNode.elementType) };
5490
5619
  }
5491
- if (ts9.isLiteralTypeNode(typeNode)) {
5620
+ if (ts10.isLiteralTypeNode(typeNode)) {
5492
5621
  const lit = typeNode.literal;
5493
- if (ts9.isStringLiteral(lit) || ts9.isNoSubstitutionTemplateLiteral(lit)) {
5622
+ if (ts10.isStringLiteral(lit) || ts10.isNoSubstitutionTemplateLiteral(lit)) {
5494
5623
  return { kind: "primitive", raw, primitive: "string", literalValue: lit.text };
5495
5624
  }
5496
- if (ts9.isNumericLiteral(lit)) {
5625
+ if (ts10.isNumericLiteral(lit)) {
5497
5626
  return { kind: "primitive", raw, primitive: "number", literalValue: lit.text };
5498
5627
  }
5499
- if (ts9.isPrefixUnaryExpression(lit) && lit.operator === ts9.SyntaxKind.MinusToken && ts9.isNumericLiteral(lit.operand)) {
5628
+ if (ts10.isPrefixUnaryExpression(lit) && lit.operator === ts10.SyntaxKind.MinusToken && ts10.isNumericLiteral(lit.operand)) {
5500
5629
  return { kind: "primitive", raw, primitive: "number", literalValue: `-${lit.operand.text}` };
5501
5630
  }
5502
- if (lit.kind === ts9.SyntaxKind.TrueKeyword || lit.kind === ts9.SyntaxKind.FalseKeyword) {
5631
+ if (lit.kind === ts10.SyntaxKind.TrueKeyword || lit.kind === ts10.SyntaxKind.FalseKeyword) {
5503
5632
  return {
5504
5633
  kind: "primitive",
5505
5634
  raw,
5506
5635
  primitive: "boolean",
5507
- literalValue: lit.kind === ts9.SyntaxKind.TrueKeyword ? "true" : "false"
5636
+ literalValue: lit.kind === ts10.SyntaxKind.TrueKeyword ? "true" : "false"
5508
5637
  };
5509
5638
  }
5510
- if (lit.kind === ts9.SyntaxKind.NullKeyword) {
5639
+ if (lit.kind === ts10.SyntaxKind.NullKeyword) {
5511
5640
  return { kind: "primitive", raw, primitive: "null" };
5512
5641
  }
5513
5642
  return { kind: "unknown", raw };
5514
5643
  }
5515
- if (ts9.isUnionTypeNode(typeNode)) {
5644
+ if (ts10.isUnionTypeNode(typeNode)) {
5516
5645
  return { kind: "union", raw, unionTypes: typeNode.types.map(recurse) };
5517
5646
  }
5518
- if (ts9.isTypeLiteralNode(typeNode)) {
5647
+ if (ts10.isTypeLiteralNode(typeNode)) {
5519
5648
  return {
5520
5649
  kind: "object",
5521
5650
  raw,
5522
5651
  ...synthetic ? {} : { properties: membersToProperties(typeNode.members, sourceFile) }
5523
5652
  };
5524
5653
  }
5525
- if (ts9.isTypeReferenceNode(typeNode)) {
5526
- const refName = ts9.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : "";
5654
+ if (ts10.isTypeReferenceNode(typeNode)) {
5655
+ const refName = ts10.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : "";
5527
5656
  if ((refName === "Array" || refName === "ReadonlyArray") && typeNode.typeArguments?.length === 1) {
5528
5657
  return { kind: "array", raw, elementType: recurse(typeNode.typeArguments[0]) };
5529
5658
  }
@@ -5532,7 +5661,7 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
5532
5661
  raw
5533
5662
  };
5534
5663
  }
5535
- if (ts9.isFunctionTypeNode(typeNode)) {
5664
+ if (ts10.isFunctionTypeNode(typeNode)) {
5536
5665
  if (synthetic)
5537
5666
  return { kind: "function", raw };
5538
5667
  return {
@@ -5552,15 +5681,15 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
5552
5681
  }
5553
5682
  return { kind: "unknown", raw };
5554
5683
  }
5555
- var _typePrinter = ts9.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
5556
- var _blankTypeSourceFile = ts9.createSourceFile("__bf_types__.ts", "", ts9.ScriptTarget.Latest);
5684
+ var _typePrinter = ts10.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
5685
+ var _blankTypeSourceFile = ts10.createSourceFile("__bf_types__.ts", "", ts10.ScriptTarget.Latest);
5557
5686
  function tsTypeToTypeInfo(type, checker) {
5558
- const node = checker.typeToTypeNode(type, undefined, ts9.NodeBuilderFlags.NoTruncation);
5687
+ const node = checker.typeToTypeNode(type, undefined, ts10.NodeBuilderFlags.NoTruncation);
5559
5688
  if (!node)
5560
5689
  return null;
5561
5690
  const rawOf = (n) => {
5562
5691
  try {
5563
- return _typePrinter.printNode(ts9.EmitHint.Unspecified, n, _blankTypeSourceFile);
5692
+ return _typePrinter.printNode(ts10.EmitHint.Unspecified, n, _blankTypeSourceFile);
5564
5693
  } catch {
5565
5694
  return "unknown";
5566
5695
  }
@@ -5571,16 +5700,16 @@ function isPascalCase(name) {
5571
5700
  return /^[A-Z][a-zA-Z0-9]*$/.test(name);
5572
5701
  }
5573
5702
  function isComponentFunction(node) {
5574
- return ts9.isFunctionDeclaration(node) && !!node.name && isPascalCase(node.name.text) && !!node.body;
5703
+ return ts10.isFunctionDeclaration(node) && !!node.name && isPascalCase(node.name.text) && !!node.body;
5575
5704
  }
5576
5705
  function isArrowComponentFunction(node) {
5577
- if (!ts9.isVariableDeclaration(node))
5706
+ if (!ts10.isVariableDeclaration(node))
5578
5707
  return false;
5579
- if (!ts9.isIdentifier(node.name))
5708
+ if (!ts10.isIdentifier(node.name))
5580
5709
  return false;
5581
5710
  if (!isPascalCase(node.name.text))
5582
5711
  return false;
5583
- if (!node.initializer || !ts9.isArrowFunction(node.initializer))
5712
+ if (!node.initializer || !ts10.isArrowFunction(node.initializer))
5584
5713
  return false;
5585
5714
  return true;
5586
5715
  }
@@ -6226,9 +6355,9 @@ function needsTypeBasedDetection(source) {
6226
6355
  }
6227
6356
  function findBrandPackageImportLoc(sourceFile, filePath) {
6228
6357
  for (const stmt of sourceFile.statements) {
6229
- if (!ts10.isImportDeclaration(stmt))
6358
+ if (!ts11.isImportDeclaration(stmt))
6230
6359
  continue;
6231
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
6360
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
6232
6361
  continue;
6233
6362
  if (!REACTIVE_BRAND_PACKAGES.includes(stmt.moduleSpecifier.text))
6234
6363
  continue;
@@ -6247,21 +6376,21 @@ function createProgramForFile(source, filePath) {
6247
6376
  try {
6248
6377
  const normalizedPath = path_default.resolve(filePath);
6249
6378
  const compilerOptions = {
6250
- target: ts10.ScriptTarget.Latest,
6251
- module: ts10.ModuleKind.ESNext,
6252
- moduleResolution: ts10.ModuleResolutionKind.Bundler,
6253
- jsx: ts10.JsxEmit.ReactJSX,
6379
+ target: ts11.ScriptTarget.Latest,
6380
+ module: ts11.ModuleKind.ESNext,
6381
+ moduleResolution: ts11.ModuleResolutionKind.Bundler,
6382
+ jsx: ts11.JsxEmit.ReactJSX,
6254
6383
  strict: true,
6255
6384
  skipLibCheck: true,
6256
6385
  noEmit: true,
6257
6386
  baseUrl: path_default.dirname(normalizedPath)
6258
6387
  };
6259
- const defaultHost = ts10.createCompilerHost(compilerOptions);
6388
+ const defaultHost = ts11.createCompilerHost(compilerOptions);
6260
6389
  const virtualHost = {
6261
6390
  ...defaultHost,
6262
6391
  getSourceFile(fileName, languageVersion) {
6263
6392
  if (path_default.resolve(fileName) === normalizedPath) {
6264
- return ts10.createSourceFile(fileName, source, languageVersion, true, ts10.ScriptKind.TSX);
6393
+ return ts11.createSourceFile(fileName, source, languageVersion, true, ts11.ScriptKind.TSX);
6265
6394
  }
6266
6395
  return defaultHost.getSourceFile(fileName, languageVersion);
6267
6396
  },
@@ -6276,7 +6405,7 @@ function createProgramForFile(source, filePath) {
6276
6405
  return defaultHost.readFile(fileName);
6277
6406
  }
6278
6407
  };
6279
- const program = ts10.createProgram([normalizedPath], compilerOptions, virtualHost);
6408
+ const program = ts11.createProgram([normalizedPath], compilerOptions, virtualHost);
6280
6409
  const sourceFile = program.getSourceFile(normalizedPath);
6281
6410
  if (!sourceFile)
6282
6411
  return null;
@@ -6309,7 +6438,7 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
6309
6438
  }
6310
6439
  }
6311
6440
  if (!sourceFile) {
6312
- sourceFile = ts10.createSourceFile(filePath, source, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
6441
+ sourceFile = ts11.createSourceFile(filePath, source, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
6313
6442
  }
6314
6443
  if (!checker && needsTypeBasedDetection(source)) {
6315
6444
  const result = createProgramForFile(source, filePath);
@@ -6355,23 +6484,23 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
6355
6484
  function findDefaultExportedComponent(sourceFile) {
6356
6485
  let defaultExportName;
6357
6486
  function findDefaultExport(node) {
6358
- if (ts10.isExportAssignment(node) && !node.isExportEquals) {
6359
- if (ts10.isIdentifier(node.expression)) {
6487
+ if (ts11.isExportAssignment(node) && !node.isExportEquals) {
6488
+ if (ts11.isIdentifier(node.expression)) {
6360
6489
  defaultExportName = node.expression.text;
6361
6490
  }
6362
6491
  }
6363
- if (ts10.isFunctionDeclaration(node) && node.name && node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DefaultKeyword)) {
6492
+ if (ts11.isFunctionDeclaration(node) && node.name && node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DefaultKeyword)) {
6364
6493
  defaultExportName = node.name.text;
6365
6494
  }
6366
- ts10.forEachChild(node, findDefaultExport);
6495
+ ts11.forEachChild(node, findDefaultExport);
6367
6496
  }
6368
- ts10.forEachChild(sourceFile, findDefaultExport);
6497
+ ts11.forEachChild(sourceFile, findDefaultExport);
6369
6498
  return defaultExportName;
6370
6499
  }
6371
6500
  function collectNamedExports(sourceFile) {
6372
6501
  const exported = new Set;
6373
6502
  for (const stmt of sourceFile.statements) {
6374
- if (ts10.isExportDeclaration(stmt) && stmt.exportClause && ts10.isNamedExports(stmt.exportClause)) {
6503
+ if (ts11.isExportDeclaration(stmt) && stmt.exportClause && ts11.isNamedExports(stmt.exportClause)) {
6375
6504
  for (const spec of stmt.exportClause.elements) {
6376
6505
  const local = (spec.propertyName ?? spec.name).text;
6377
6506
  exported.add(local);
@@ -6381,22 +6510,22 @@ function collectNamedExports(sourceFile) {
6381
6510
  return exported;
6382
6511
  }
6383
6512
  function visit(node, ctx, targetComponentName, namedExports) {
6384
- if (ts10.isExpressionStatement(node) && ts10.isStringLiteral(node.expression)) {
6513
+ if (ts11.isExpressionStatement(node) && ts11.isStringLiteral(node.expression)) {
6385
6514
  if (node.expression.text === "use client" || node.expression.text === "'use client'") {
6386
6515
  ctx.hasUseClientDirective = true;
6387
6516
  }
6388
6517
  }
6389
- if (ts10.isImportDeclaration(node)) {
6518
+ if (ts11.isImportDeclaration(node)) {
6390
6519
  collectImport(node, ctx);
6391
6520
  }
6392
- if (ts10.isInterfaceDeclaration(node)) {
6521
+ if (ts11.isInterfaceDeclaration(node)) {
6393
6522
  collectInterfaceDefinition(node, ctx);
6394
6523
  }
6395
- if (ts10.isTypeAliasDeclaration(node)) {
6524
+ if (ts11.isTypeAliasDeclaration(node)) {
6396
6525
  collectTypeAliasDefinition(node, ctx);
6397
6526
  }
6398
- if (!ctx.hasUseClientDirective && ts10.isFunctionDeclaration(node) && node.name && node.body && isMultiReturnJsxFunctionBody(node.body)) {
6399
- const hasInlineExport = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6527
+ if (!ctx.hasUseClientDirective && ts11.isFunctionDeclaration(node) && node.name && node.body && isMultiReturnJsxFunctionBody(node.body)) {
6528
+ const hasInlineExport = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6400
6529
  const hasNamedExport = namedExports?.has(node.name.text) ?? false;
6401
6530
  if (!hasInlineExport && !hasNamedExport) {
6402
6531
  collectFunction(node, ctx, true, false);
@@ -6411,9 +6540,9 @@ function visit(node, ctx, targetComponentName, namedExports) {
6411
6540
  if (!ctx.componentName) {
6412
6541
  ctx.componentName = node.name.text;
6413
6542
  ctx.componentNode = node;
6414
- ctx.isExported = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6543
+ ctx.isExported = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6415
6544
  analyzeComponentBody(node, ctx);
6416
- if (node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DefaultKeyword)) {
6545
+ if (node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DefaultKeyword)) {
6417
6546
  ctx.hasDefaultExport = true;
6418
6547
  }
6419
6548
  }
@@ -6427,10 +6556,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
6427
6556
  ctx.componentName = node.name.text;
6428
6557
  ctx.componentNode = node.initializer;
6429
6558
  const parentStatement = node.parent;
6430
- if (ts10.isVariableDeclarationList(parentStatement)) {
6559
+ if (ts11.isVariableDeclarationList(parentStatement)) {
6431
6560
  const varStatement = parentStatement.parent;
6432
- if (ts10.isVariableStatement(varStatement)) {
6433
- ctx.isExported = varStatement.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6561
+ if (ts11.isVariableStatement(varStatement)) {
6562
+ ctx.isExported = varStatement.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6434
6563
  }
6435
6564
  }
6436
6565
  analyzeComponentBody(node.initializer, ctx);
@@ -6442,10 +6571,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
6442
6571
  if (!ctx.componentNode) {
6443
6572
  collectAmbientGlobals(node, ctx);
6444
6573
  }
6445
- const isDeclareStatement = ts10.isVariableStatement(node) && (node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DeclareKeyword) ?? false);
6446
- if (ts10.isVariableStatement(node) && !ctx.componentNode && !isDeclareStatement) {
6447
- const isExported = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6448
- const isLet = (node.declarationList.flags & ts10.NodeFlags.Let) !== 0;
6574
+ const isDeclareStatement = ts11.isVariableStatement(node) && (node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DeclareKeyword) ?? false);
6575
+ if (ts11.isVariableStatement(node) && !ctx.componentNode && !isDeclareStatement) {
6576
+ const isExported = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6577
+ const isLet = (node.declarationList.flags & ts11.NodeFlags.Let) !== 0;
6449
6578
  const isModuleClientDirective = hasLeadingClientDirectiveOnStatement(node, ctx.sourceFile);
6450
6579
  for (const decl of node.declarationList.declarations) {
6451
6580
  if (declarationIsReactiveFactoryCall(decl, ctx)) {
@@ -6456,19 +6585,19 @@ function visit(node, ctx, targetComponentName, namedExports) {
6456
6585
  }
6457
6586
  continue;
6458
6587
  }
6459
- if (ts10.isIdentifier(decl.name) && (decl.initializer || isLet) && !isArrowComponentFunction(decl)) {
6588
+ if (ts11.isIdentifier(decl.name) && (decl.initializer || isLet) && !isArrowComponentFunction(decl)) {
6460
6589
  collectConstant(decl, ctx, true, isLet ? "let" : "const", isExported);
6461
6590
  }
6462
6591
  }
6463
6592
  }
6464
- if (ts10.isFunctionDeclaration(node) && node.name && !isComponentFunction(node)) {
6465
- const isExported = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
6593
+ if (ts11.isFunctionDeclaration(node) && node.name && !isComponentFunction(node)) {
6594
+ const isExported = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
6466
6595
  collectFunction(node, ctx, true, isExported);
6467
6596
  return;
6468
6597
  }
6469
- if (ts10.isExportDeclaration(node) && node.exportClause && ts10.isNamedExports(node.exportClause)) {
6598
+ if (ts11.isExportDeclaration(node) && node.exportClause && ts11.isNamedExports(node.exportClause)) {
6470
6599
  const isFromReexport = !!node.moduleSpecifier;
6471
- const sourceSpec = node.moduleSpecifier && ts10.isStringLiteral(node.moduleSpecifier) ? node.moduleSpecifier.text : null;
6600
+ const sourceSpec = node.moduleSpecifier && ts11.isStringLiteral(node.moduleSpecifier) ? node.moduleSpecifier.text : null;
6472
6601
  const exportSpecifiers = node.exportClause.elements.map((spec) => ({
6473
6602
  name: (spec.propertyName ?? spec.name).text,
6474
6603
  alias: spec.propertyName ? spec.name.text : null,
@@ -6496,24 +6625,24 @@ function visit(node, ctx, targetComponentName, namedExports) {
6496
6625
  }
6497
6626
  }
6498
6627
  }
6499
- if (ts10.isExportAssignment(node) && !node.isExportEquals) {
6628
+ if (ts11.isExportAssignment(node) && !node.isExportEquals) {
6500
6629
  const expr = node.expression;
6501
- if (ts10.isIdentifier(expr)) {
6630
+ if (ts11.isIdentifier(expr)) {
6502
6631
  if (ctx.componentName && expr.text === ctx.componentName) {
6503
6632
  ctx.hasDefaultExport = true;
6504
6633
  ctx.isExported = true;
6505
6634
  }
6506
6635
  }
6507
6636
  }
6508
- ts10.forEachChild(node, (child) => visit(child, ctx, targetComponentName, namedExports));
6637
+ ts11.forEachChild(node, (child) => visit(child, ctx, targetComponentName, namedExports));
6509
6638
  }
6510
6639
  function analyzeComponentBody(node, ctx) {
6511
6640
  if (node.parameters.length > 0) {
6512
6641
  extractProps(node.parameters[0], ctx);
6513
6642
  }
6514
- const body = ts10.isFunctionDeclaration(node) ? node.body : getArrowFunctionBody(node);
6643
+ const body = ts11.isFunctionDeclaration(node) ? node.body : getArrowFunctionBody(node);
6515
6644
  if (body) {
6516
- ctx.componentBodyBlock = ts10.isBlock(body) ? body : null;
6645
+ ctx.componentBodyBlock = ts11.isBlock(body) ? body : null;
6517
6646
  if (!ctx.componentBodyBlock) {
6518
6647
  ctx.jsxReturn = unwrapJsxTransparent(body);
6519
6648
  }
@@ -6523,14 +6652,14 @@ function analyzeComponentBody(node, ctx) {
6523
6652
  }
6524
6653
  }
6525
6654
  function getArrowFunctionBody(node) {
6526
- if (ts10.isBlock(node.body)) {
6655
+ if (ts11.isBlock(node.body)) {
6527
6656
  return node.body;
6528
6657
  }
6529
6658
  return node.body;
6530
6659
  }
6531
6660
  function visitComponentBody(node, ctx) {
6532
6661
  const isTopLevel = ctx.componentBodyBlock !== null && node.parent === ctx.componentBodyBlock;
6533
- if (ts10.isVariableStatement(node)) {
6662
+ if (ts11.isVariableStatement(node)) {
6534
6663
  for (const decl of node.declarationList.declarations) {
6535
6664
  if (isSignalDeclaration(decl, ctx)) {
6536
6665
  collectSignal(decl, ctx);
@@ -6553,16 +6682,16 @@ function visitComponentBody(node, ctx) {
6553
6682
  collectEffect(decl.initializer, ctx, decl.name.text);
6554
6683
  continue;
6555
6684
  }
6556
- if (ts10.isIdentifier(decl.name)) {
6557
- const isLet = (node.declarationList.flags & ts10.NodeFlags.Let) !== 0;
6685
+ if (ts11.isIdentifier(decl.name)) {
6686
+ const isLet = (node.declarationList.flags & ts11.NodeFlags.Let) !== 0;
6558
6687
  collectConstant(decl, ctx, false, isLet ? "let" : "const");
6559
- } else if (ts10.isObjectBindingPattern(decl.name) && decl.initializer && ts10.isIdentifier(decl.initializer) && ctx.propsObjectName === decl.initializer.text) {
6560
- const isLet = (node.declarationList.flags & ts10.NodeFlags.Let) !== 0;
6688
+ } else if (ts11.isObjectBindingPattern(decl.name) && decl.initializer && ts11.isIdentifier(decl.initializer) && ctx.propsObjectName === decl.initializer.text) {
6689
+ const isLet = (node.declarationList.flags & ts11.NodeFlags.Let) !== 0;
6561
6690
  collectConstant(decl, ctx, false, isLet ? "let" : "const");
6562
6691
  }
6563
6692
  }
6564
6693
  }
6565
- if (ts10.isExpressionStatement(node)) {
6694
+ if (ts11.isExpressionStatement(node)) {
6566
6695
  if (isEffectCall(node.expression, ctx)) {
6567
6696
  collectEffect(node.expression, ctx);
6568
6697
  return;
@@ -6576,10 +6705,10 @@ function visitComponentBody(node, ctx) {
6576
6705
  return;
6577
6706
  }
6578
6707
  }
6579
- if (ts10.isFunctionDeclaration(node) && node.name) {
6708
+ if (ts11.isFunctionDeclaration(node) && node.name) {
6580
6709
  collectFunction(node, ctx, false);
6581
6710
  }
6582
- if (ts10.isIfStatement(node)) {
6711
+ if (ts11.isIfStatement(node)) {
6583
6712
  const jsxReturn = findJsxReturnInBlock(node.thenStatement);
6584
6713
  if (jsxReturn) {
6585
6714
  const scopeVars = collectScopeVariables(node.thenStatement, ctx);
@@ -6598,8 +6727,8 @@ function visitComponentBody(node, ctx) {
6598
6727
  return;
6599
6728
  }
6600
6729
  }
6601
- 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)) {
6602
- if (ts10.isBlock(node)) {
6730
+ if (isTopLevel && (ts11.isTryStatement(node) || ts11.isSwitchStatement(node) || ts11.isForStatement(node) || ts11.isForInStatement(node) || ts11.isForOfStatement(node) || ts11.isWhileStatement(node) || ts11.isDoStatement(node) || ts11.isThrowStatement(node) || ts11.isBlock(node) && node.parent === ctx.componentBodyBlock)) {
6731
+ if (ts11.isBlock(node)) {
6603
6732
  const returnedLocal = findBlockBodyReturnedJsxLocalName(node);
6604
6733
  if (returnedLocal) {
6605
6734
  ctx.errors.push(createError(ErrorCodes.RETURN_VALUE_NOT_JSX, getSourceLocation(node, ctx.sourceFile, ctx.filePath), {
@@ -6610,34 +6739,34 @@ function visitComponentBody(node, ctx) {
6610
6739
  collectInitStatement(node, ctx);
6611
6740
  return;
6612
6741
  }
6613
- if (ts10.isReturnStatement(node) && node.expression) {
6742
+ if (ts11.isReturnStatement(node) && node.expression) {
6614
6743
  ctx.jsxReturn = unwrapJsxTransparent(node.expression);
6615
6744
  }
6616
- ts10.forEachChild(node, (child) => {
6617
- if (ts10.isArrowFunction(child) || ts10.isFunctionExpression(child) || ts10.isFunctionDeclaration(child)) {
6745
+ ts11.forEachChild(node, (child) => {
6746
+ if (ts11.isArrowFunction(child) || ts11.isFunctionExpression(child) || ts11.isFunctionDeclaration(child)) {
6618
6747
  return;
6619
6748
  }
6620
6749
  visitComponentBody(child, ctx);
6621
6750
  });
6622
6751
  }
6623
6752
  function findJsxReturnInBlock(node) {
6624
- if (ts10.isBlock(node)) {
6753
+ if (ts11.isBlock(node)) {
6625
6754
  for (const stmt of node.statements) {
6626
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
6755
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
6627
6756
  const jsx = extractJsxFromExpression(stmt.expression);
6628
6757
  if (jsx)
6629
6758
  return jsx;
6630
6759
  }
6631
6760
  }
6632
6761
  }
6633
- if (ts10.isReturnStatement(node) && node.expression) {
6762
+ if (ts11.isReturnStatement(node) && node.expression) {
6634
6763
  return extractJsxFromExpression(node.expression);
6635
6764
  }
6636
6765
  return null;
6637
6766
  }
6638
6767
  function unwrapJsxTransparent(expr) {
6639
6768
  let current = expr;
6640
- while (ts10.isParenthesizedExpression(current) || ts10.isAsExpression(current) || ts10.isSatisfiesExpression(current) || ts10.isNonNullExpression(current) || ts10.isTypeAssertionExpression(current) || current.kind === ts10.SyntaxKind.PartiallyEmittedExpression) {
6769
+ while (ts11.isParenthesizedExpression(current) || ts11.isAsExpression(current) || ts11.isSatisfiesExpression(current) || ts11.isNonNullExpression(current) || ts11.isTypeAssertionExpression(current) || current.kind === ts11.SyntaxKind.PartiallyEmittedExpression) {
6641
6770
  current = current.expression;
6642
6771
  }
6643
6772
  return current;
@@ -6645,22 +6774,22 @@ function unwrapJsxTransparent(expr) {
6645
6774
  function findBlockBodyReturnedJsxLocalName(block) {
6646
6775
  const stmts = block.statements;
6647
6776
  const last = stmts[stmts.length - 1];
6648
- if (!last || !ts10.isReturnStatement(last) || !last.expression)
6777
+ if (!last || !ts11.isReturnStatement(last) || !last.expression)
6649
6778
  return null;
6650
6779
  const returned = unwrapJsxTransparent(last.expression);
6651
- if (!ts10.isIdentifier(returned))
6780
+ if (!ts11.isIdentifier(returned))
6652
6781
  return null;
6653
6782
  const name = returned.text;
6654
6783
  for (const stmt of stmts) {
6655
- if (!ts10.isVariableStatement(stmt))
6784
+ if (!ts11.isVariableStatement(stmt))
6656
6785
  continue;
6657
6786
  for (const decl of stmt.declarationList.declarations) {
6658
- if (!ts10.isIdentifier(decl.name) || decl.name.text !== name || !decl.initializer)
6787
+ if (!ts11.isIdentifier(decl.name) || decl.name.text !== name || !decl.initializer)
6659
6788
  continue;
6660
6789
  let init = decl.initializer;
6661
- while (ts10.isParenthesizedExpression(init))
6790
+ while (ts11.isParenthesizedExpression(init))
6662
6791
  init = init.expression;
6663
- if (ts10.isJsxElement(init) || ts10.isJsxSelfClosingElement(init) || ts10.isJsxFragment(init) || initializerShapeContainsJsx(init) || isMapLikeCallWithJsx(init)) {
6792
+ if (ts11.isJsxElement(init) || ts11.isJsxSelfClosingElement(init) || ts11.isJsxFragment(init) || initializerShapeContainsJsx(init) || isMapLikeCallWithJsx(init)) {
6664
6793
  return name;
6665
6794
  }
6666
6795
  }
@@ -6669,16 +6798,16 @@ function findBlockBodyReturnedJsxLocalName(block) {
6669
6798
  }
6670
6799
  function extractJsxFromExpression(expr) {
6671
6800
  const inner = unwrapJsxTransparent(expr);
6672
- if (ts10.isJsxElement(inner) || ts10.isJsxFragment(inner) || ts10.isJsxSelfClosingElement(inner)) {
6801
+ if (ts11.isJsxElement(inner) || ts11.isJsxFragment(inner) || ts11.isJsxSelfClosingElement(inner)) {
6673
6802
  return inner;
6674
6803
  }
6675
6804
  return null;
6676
6805
  }
6677
6806
  function collectScopeVariables(node, ctx) {
6678
6807
  const variables = [];
6679
- if (ts10.isBlock(node)) {
6808
+ if (ts11.isBlock(node)) {
6680
6809
  for (const stmt of node.statements) {
6681
- if (ts10.isVariableStatement(stmt)) {
6810
+ if (ts11.isVariableStatement(stmt)) {
6682
6811
  for (const decl of stmt.declarationList.declarations) {
6683
6812
  variables.push(decl);
6684
6813
  }
@@ -6690,13 +6819,13 @@ function collectScopeVariables(node, ctx) {
6690
6819
  function collectParamBindingNames(params) {
6691
6820
  const out = new Set;
6692
6821
  const addBindingNames = (name) => {
6693
- if (ts10.isIdentifier(name)) {
6822
+ if (ts11.isIdentifier(name)) {
6694
6823
  out.add(name.text);
6695
- } else if (ts10.isObjectBindingPattern(name)) {
6824
+ } else if (ts11.isObjectBindingPattern(name)) {
6696
6825
  name.elements.forEach((e) => addBindingNames(e.name));
6697
- } else if (ts10.isArrayBindingPattern(name)) {
6826
+ } else if (ts11.isArrayBindingPattern(name)) {
6698
6827
  name.elements.forEach((e) => {
6699
- if (!ts10.isOmittedExpression(e))
6828
+ if (!ts11.isOmittedExpression(e))
6700
6829
  addBindingNames(e.name);
6701
6830
  });
6702
6831
  }
@@ -6713,7 +6842,7 @@ function collectEnclosingBranchVars(node, ctx) {
6713
6842
  if (cr.ifStatement.thenStatement !== current)
6714
6843
  continue;
6715
6844
  for (const decl of cr.scopeVariables) {
6716
- if (!ts10.isIdentifier(decl.name) || !decl.initializer)
6845
+ if (!ts11.isIdentifier(decl.name) || !decl.initializer)
6717
6846
  continue;
6718
6847
  const varName = decl.name.text;
6719
6848
  if (result.has(varName))
@@ -6728,10 +6857,10 @@ function collectEnclosingBranchVars(node, ctx) {
6728
6857
  return result;
6729
6858
  }
6730
6859
  function collectBranchSignals(thenStatement, ctx, branchCondition) {
6731
- if (!ts10.isBlock(thenStatement))
6860
+ if (!ts11.isBlock(thenStatement))
6732
6861
  return;
6733
6862
  for (const stmt of thenStatement.statements) {
6734
- if (!ts10.isVariableStatement(stmt))
6863
+ if (!ts11.isVariableStatement(stmt))
6735
6864
  continue;
6736
6865
  for (const decl of stmt.declarationList.declarations) {
6737
6866
  if (!isSignalDeclaration(decl, ctx))
@@ -6757,13 +6886,13 @@ var ENV_SIGNAL_FACTORIES = {
6757
6886
  createSearchParams: "search"
6758
6887
  };
6759
6888
  function resolvePrimitiveKind(callExpr, ctx) {
6760
- if (ts10.isIdentifier(callExpr.expression)) {
6889
+ if (ts11.isIdentifier(callExpr.expression)) {
6761
6890
  const hit = PRIMITIVE_CANONICAL_NAMES[callExpr.expression.text];
6762
6891
  if (hit)
6763
6892
  return hit;
6764
6893
  return resolveCalleeViaChecker(callExpr.expression, ctx);
6765
6894
  }
6766
- if (ts10.isPropertyAccessExpression(callExpr.expression)) {
6895
+ if (ts11.isPropertyAccessExpression(callExpr.expression)) {
6767
6896
  const propName = callExpr.expression.name.text;
6768
6897
  const hit = PRIMITIVE_CANONICAL_NAMES[propName];
6769
6898
  if (!hit)
@@ -6790,7 +6919,7 @@ function resolveCanonicalClientExportName(ident, ctx) {
6790
6919
  if (!symbol)
6791
6920
  return null;
6792
6921
  let target = symbol;
6793
- if (symbol.flags & ts10.SymbolFlags.Alias) {
6922
+ if (symbol.flags & ts11.SymbolFlags.Alias) {
6794
6923
  try {
6795
6924
  target = ctx.checker.getAliasedSymbol(symbol);
6796
6925
  } catch {
@@ -6806,14 +6935,14 @@ function resolveCanonicalClientExportName(ident, ctx) {
6806
6935
  return null;
6807
6936
  }
6808
6937
  function resolveEnvSignalKey(callExpr, ctx) {
6809
- if (ts10.isIdentifier(callExpr.expression)) {
6938
+ if (ts11.isIdentifier(callExpr.expression)) {
6810
6939
  const key = ENV_SIGNAL_FACTORIES[callExpr.expression.text];
6811
6940
  if (key)
6812
6941
  return key;
6813
6942
  const canonical = resolveCanonicalClientExportName(callExpr.expression, ctx);
6814
6943
  return canonical ? ENV_SIGNAL_FACTORIES[canonical] ?? null : null;
6815
6944
  }
6816
- if (ts10.isPropertyAccessExpression(callExpr.expression)) {
6945
+ if (ts11.isPropertyAccessExpression(callExpr.expression)) {
6817
6946
  const key = ENV_SIGNAL_FACTORIES[callExpr.expression.name.text];
6818
6947
  if (key && isBarefootClientNamespace(callExpr.expression.expression, ctx))
6819
6948
  return key;
@@ -6821,7 +6950,7 @@ function resolveEnvSignalKey(callExpr, ctx) {
6821
6950
  return null;
6822
6951
  }
6823
6952
  function isBarefootClientNamespace(expr, ctx) {
6824
- if (!ts10.isIdentifier(expr))
6953
+ if (!ts11.isIdentifier(expr))
6825
6954
  return false;
6826
6955
  if (!ctx.checker)
6827
6956
  return false;
@@ -6834,22 +6963,22 @@ function isBarefootClientNamespace(expr, ctx) {
6834
6963
  if (!symbol)
6835
6964
  return false;
6836
6965
  for (const decl of symbol.declarations ?? []) {
6837
- if (!ts10.isNamespaceImport(decl))
6966
+ if (!ts11.isNamespaceImport(decl))
6838
6967
  continue;
6839
6968
  const importDecl = decl.parent.parent;
6840
- if (!ts10.isImportDeclaration(importDecl))
6969
+ if (!ts11.isImportDeclaration(importDecl))
6841
6970
  continue;
6842
6971
  const mod = importDecl.moduleSpecifier;
6843
- if (ts10.isStringLiteral(mod) && mod.text === "@barefootjs/client") {
6972
+ if (ts11.isStringLiteral(mod) && mod.text === "@barefootjs/client") {
6844
6973
  return true;
6845
6974
  }
6846
6975
  }
6847
6976
  return false;
6848
6977
  }
6849
6978
  function isSignalDeclaration(node, ctx) {
6850
- if (!ts10.isArrayBindingPattern(node.name))
6979
+ if (!ts11.isArrayBindingPattern(node.name))
6851
6980
  return false;
6852
- if (!node.initializer || !ts10.isCallExpression(node.initializer))
6981
+ if (!node.initializer || !ts11.isCallExpression(node.initializer))
6853
6982
  return false;
6854
6983
  return resolvePrimitiveKind(node.initializer, ctx) === "signal";
6855
6984
  }
@@ -6857,14 +6986,14 @@ function collectSignal(node, ctx) {
6857
6986
  const pattern = node.name;
6858
6987
  const callExpr = node.initializer;
6859
6988
  const elements = pattern.elements;
6860
- const getterElided = elements.length === 2 && ts10.isOmittedExpression(elements[0]);
6861
- if (elements.length < 1 || elements.length > 2 || !getterElided && (!ts10.isBindingElement(elements[0]) || !ts10.isIdentifier(elements[0].name))) {
6989
+ const getterElided = elements.length === 2 && ts11.isOmittedExpression(elements[0]);
6990
+ if (elements.length < 1 || elements.length > 2 || !getterElided && (!ts11.isBindingElement(elements[0]) || !ts11.isIdentifier(elements[0].name))) {
6862
6991
  return;
6863
6992
  }
6864
- if (elements.length === 2 && (!ts10.isBindingElement(elements[1]) || !ts10.isIdentifier(elements[1].name))) {
6993
+ if (elements.length === 2 && (!ts11.isBindingElement(elements[1]) || !ts11.isIdentifier(elements[1].name))) {
6865
6994
  return;
6866
6995
  }
6867
- const setter = elements.length === 2 && ts10.isBindingElement(elements[1]) && ts10.isIdentifier(elements[1].name) ? elements[1].name.text : null;
6996
+ const setter = elements.length === 2 && ts11.isBindingElement(elements[1]) && ts11.isIdentifier(elements[1].name) ? elements[1].name.text : null;
6868
6997
  if (getterElided && !setter)
6869
6998
  return;
6870
6999
  const getter = getterElided ? `__bfGet_${setter}` : elements[0].name.text;
@@ -6901,33 +7030,33 @@ function collectSignal(node, ctx) {
6901
7030
  });
6902
7031
  }
6903
7032
  function isSignalTupleDeclaration(node) {
6904
- if (!ts10.isIdentifier(node.name))
7033
+ if (!ts11.isIdentifier(node.name))
6905
7034
  return false;
6906
- if (!node.initializer || !ts10.isCallExpression(node.initializer))
7035
+ if (!node.initializer || !ts11.isCallExpression(node.initializer))
6907
7036
  return false;
6908
7037
  const callExpr = node.initializer;
6909
- return ts10.isIdentifier(callExpr.expression) && callExpr.expression.text === "createSignal";
7038
+ return ts11.isIdentifier(callExpr.expression) && callExpr.expression.text === "createSignal";
6910
7039
  }
6911
7040
  function isSignalIndexAccess(node, ctx) {
6912
- if (!ts10.isIdentifier(node.name))
7041
+ if (!ts11.isIdentifier(node.name))
6913
7042
  return null;
6914
- if (!node.initializer || !ts10.isElementAccessExpression(node.initializer))
7043
+ if (!node.initializer || !ts11.isElementAccessExpression(node.initializer))
6915
7044
  return null;
6916
7045
  const access = node.initializer;
6917
- if (!ts10.isNumericLiteral(access.argumentExpression))
7046
+ if (!ts11.isNumericLiteral(access.argumentExpression))
6918
7047
  return null;
6919
7048
  const indexValue = Number(access.argumentExpression.text);
6920
7049
  if (indexValue !== 0 && indexValue !== 1)
6921
7050
  return null;
6922
7051
  const index = indexValue;
6923
- if (ts10.isCallExpression(access.expression)) {
7052
+ if (ts11.isCallExpression(access.expression)) {
6924
7053
  const call = access.expression;
6925
- if (ts10.isIdentifier(call.expression) && call.expression.text === "createSignal") {
7054
+ if (ts11.isIdentifier(call.expression) && call.expression.text === "createSignal") {
6926
7055
  return { kind: "direct", index, callExpr: call };
6927
7056
  }
6928
7057
  return null;
6929
7058
  }
6930
- if (ts10.isIdentifier(access.expression)) {
7059
+ if (ts11.isIdentifier(access.expression)) {
6931
7060
  const tupleName = access.expression.text;
6932
7061
  if (ctx.signalTupleRefs.has(tupleName)) {
6933
7062
  return { kind: "tupleRef", index, tupleName };
@@ -7022,30 +7151,30 @@ function flushPendingSignalTuples(ctx) {
7022
7151
  ctx.signalTupleRefs.clear();
7023
7152
  }
7024
7153
  function isMemoDeclaration(node, ctx) {
7025
- if (!ts10.isIdentifier(node.name))
7154
+ if (!ts11.isIdentifier(node.name))
7026
7155
  return false;
7027
- if (!node.initializer || !ts10.isCallExpression(node.initializer))
7156
+ if (!node.initializer || !ts11.isCallExpression(node.initializer))
7028
7157
  return false;
7029
7158
  return resolvePrimitiveKind(node.initializer, ctx) === "memo";
7030
7159
  }
7031
7160
  function memoBodyIsTemplateLiteral(memoArrow) {
7032
7161
  let node = memoArrow;
7033
- while (node && ts10.isParenthesizedExpression(node))
7162
+ while (node && ts11.isParenthesizedExpression(node))
7034
7163
  node = node.expression;
7035
- if (!node || !ts10.isArrowFunction(node))
7164
+ if (!node || !ts11.isArrowFunction(node))
7036
7165
  return false;
7037
7166
  let body = node.body;
7038
- while (ts10.isParenthesizedExpression(body))
7167
+ while (ts11.isParenthesizedExpression(body))
7039
7168
  body = body.expression;
7040
- if (ts10.isBlock(body)) {
7041
- const ret = body.statements.find(ts10.isReturnStatement);
7169
+ if (ts11.isBlock(body)) {
7170
+ const ret = body.statements.find(ts11.isReturnStatement);
7042
7171
  if (!ret || !ret.expression)
7043
7172
  return false;
7044
7173
  body = ret.expression;
7045
- while (ts10.isParenthesizedExpression(body))
7174
+ while (ts11.isParenthesizedExpression(body))
7046
7175
  body = body.expression;
7047
7176
  }
7048
- return ts10.isTemplateExpression(body) || ts10.isNoSubstitutionTemplateLiteral(body);
7177
+ return ts11.isTemplateExpression(body) || ts11.isNoSubstitutionTemplateLiteral(body);
7049
7178
  }
7050
7179
  function collectMemo(node, ctx) {
7051
7180
  const name = node.name.text;
@@ -7062,7 +7191,7 @@ function collectMemo(node, ctx) {
7062
7191
  type = inferTypeFromValue(arrowBody);
7063
7192
  }
7064
7193
  }
7065
- if (ctx.checker && (type.kind === "unknown" || type.kind === "object") && callExpr.arguments[0] && (ts10.isArrowFunction(callExpr.arguments[0]) || ts10.isFunctionExpression(callExpr.arguments[0]))) {
7194
+ if (ctx.checker && (type.kind === "unknown" || type.kind === "object") && callExpr.arguments[0] && (ts11.isArrowFunction(callExpr.arguments[0]) || ts11.isFunctionExpression(callExpr.arguments[0]))) {
7066
7195
  const fnType = ctx.checker.getTypeAtLocation(callExpr.arguments[0]);
7067
7196
  const sig = fnType.getCallSignatures()[0];
7068
7197
  if (sig) {
@@ -7072,12 +7201,12 @@ function collectMemo(node, ctx) {
7072
7201
  }
7073
7202
  }
7074
7203
  const memoArrow = callExpr.arguments[0];
7075
- const parsedBody = memoArrow && ts10.isArrowFunction(memoArrow) && !ts10.isBlock(memoArrow.body) ? parseExpression(ctx.getJS(memoArrow.body)) : undefined;
7204
+ const parsedBody = memoArrow && ts11.isArrowFunction(memoArrow) && !ts11.isBlock(memoArrow.body) ? parseExpression(ctx.getJS(memoArrow.body)) : undefined;
7076
7205
  const parsed = parsedBody && parsedBody.kind !== "unsupported" && parsedBody.kind !== "object-literal" ? parsedBody : undefined;
7077
7206
  let arrowNode = memoArrow;
7078
- while (arrowNode && ts10.isParenthesizedExpression(arrowNode))
7207
+ while (arrowNode && ts11.isParenthesizedExpression(arrowNode))
7079
7208
  arrowNode = arrowNode.expression;
7080
- const blockBody = arrowNode && ts10.isArrowFunction(arrowNode) && ts10.isBlock(arrowNode.body) ? arrowNode.body : undefined;
7209
+ const blockBody = arrowNode && ts11.isArrowFunction(arrowNode) && ts11.isBlock(arrowNode.body) ? arrowNode.body : undefined;
7081
7210
  const parsedBlock = blockBody ? parseBlockBodyTolerant(blockBody, ctx.sourceFile, (node2) => ctx.getJS(node2)) : undefined;
7082
7211
  const parsedBlockComplete = parsedBlock && blockBody ? parsedBlock.length === blockBody.statements.length : undefined;
7083
7212
  let templateComputation;
@@ -7104,14 +7233,14 @@ function collectMemo(node, ctx) {
7104
7233
  });
7105
7234
  }
7106
7235
  function isEffectCall(node, ctx) {
7107
- if (!ts10.isCallExpression(node))
7236
+ if (!ts11.isCallExpression(node))
7108
7237
  return false;
7109
7238
  return resolvePrimitiveKind(node, ctx) === "effect";
7110
7239
  }
7111
7240
  function isEffectDisposerCapture(node, ctx) {
7112
- if (!ts10.isIdentifier(node.name))
7241
+ if (!ts11.isIdentifier(node.name))
7113
7242
  return false;
7114
- if (!node.initializer || !ts10.isCallExpression(node.initializer))
7243
+ if (!node.initializer || !ts11.isCallExpression(node.initializer))
7115
7244
  return false;
7116
7245
  return resolvePrimitiveKind(node.initializer, ctx) === "effect";
7117
7246
  }
@@ -7126,7 +7255,7 @@ function collectEffect(node, ctx, captureName) {
7126
7255
  });
7127
7256
  }
7128
7257
  function isOnMountCall(node, ctx) {
7129
- if (!ts10.isCallExpression(node))
7258
+ if (!ts11.isCallExpression(node))
7130
7259
  return false;
7131
7260
  return resolvePrimitiveKind(node, ctx) === "onMount";
7132
7261
  }
@@ -7161,19 +7290,19 @@ function leadsWithAsiHazard(body) {
7161
7290
  function extractAssignedIdentifiersFromNode(node) {
7162
7291
  const ids = new Set;
7163
7292
  function addFromTarget(target) {
7164
- if (ts10.isIdentifier(target)) {
7293
+ if (ts11.isIdentifier(target)) {
7165
7294
  ids.add(target.text);
7166
7295
  return;
7167
7296
  }
7168
- if (ts10.isParenthesizedExpression(target)) {
7297
+ if (ts11.isParenthesizedExpression(target)) {
7169
7298
  addFromTarget(target.expression);
7170
7299
  return;
7171
7300
  }
7172
- if (ts10.isArrayLiteralExpression(target)) {
7301
+ if (ts11.isArrayLiteralExpression(target)) {
7173
7302
  for (const el of target.elements) {
7174
- if (ts10.isOmittedExpression(el))
7303
+ if (ts11.isOmittedExpression(el))
7175
7304
  continue;
7176
- if (ts10.isSpreadElement(el)) {
7305
+ if (ts11.isSpreadElement(el)) {
7177
7306
  addFromTarget(el.expression);
7178
7307
  continue;
7179
7308
  }
@@ -7181,17 +7310,17 @@ function extractAssignedIdentifiersFromNode(node) {
7181
7310
  }
7182
7311
  return;
7183
7312
  }
7184
- if (ts10.isObjectLiteralExpression(target)) {
7313
+ if (ts11.isObjectLiteralExpression(target)) {
7185
7314
  for (const prop of target.properties) {
7186
- if (ts10.isShorthandPropertyAssignment(prop)) {
7315
+ if (ts11.isShorthandPropertyAssignment(prop)) {
7187
7316
  ids.add(prop.name.text);
7188
7317
  continue;
7189
7318
  }
7190
- if (ts10.isPropertyAssignment(prop)) {
7319
+ if (ts11.isPropertyAssignment(prop)) {
7191
7320
  addFromTarget(prop.initializer);
7192
7321
  continue;
7193
7322
  }
7194
- if (ts10.isSpreadAssignment(prop)) {
7323
+ if (ts11.isSpreadAssignment(prop)) {
7195
7324
  addFromTarget(prop.expression);
7196
7325
  continue;
7197
7326
  }
@@ -7200,21 +7329,21 @@ function extractAssignedIdentifiersFromNode(node) {
7200
7329
  }
7201
7330
  }
7202
7331
  function visit2(n) {
7203
- if (ts10.isArrowFunction(n) || ts10.isFunctionExpression(n) || ts10.isFunctionDeclaration(n) || ts10.isMethodDeclaration(n) || ts10.isGetAccessorDeclaration(n) || ts10.isSetAccessorDeclaration(n) || ts10.isConstructorDeclaration(n)) {
7332
+ if (ts11.isArrowFunction(n) || ts11.isFunctionExpression(n) || ts11.isFunctionDeclaration(n) || ts11.isMethodDeclaration(n) || ts11.isGetAccessorDeclaration(n) || ts11.isSetAccessorDeclaration(n) || ts11.isConstructorDeclaration(n)) {
7204
7333
  return;
7205
7334
  }
7206
- if (ts10.isBinaryExpression(n)) {
7335
+ if (ts11.isBinaryExpression(n)) {
7207
7336
  const op = n.operatorToken.kind;
7208
- if (op === ts10.SyntaxKind.EqualsToken || op === ts10.SyntaxKind.PlusEqualsToken || op === ts10.SyntaxKind.MinusEqualsToken || op === ts10.SyntaxKind.AsteriskEqualsToken || op === ts10.SyntaxKind.SlashEqualsToken || op === ts10.SyntaxKind.PercentEqualsToken || op === ts10.SyntaxKind.AsteriskAsteriskEqualsToken || op === ts10.SyntaxKind.AmpersandEqualsToken || op === ts10.SyntaxKind.BarEqualsToken || op === ts10.SyntaxKind.CaretEqualsToken || op === ts10.SyntaxKind.LessThanLessThanEqualsToken || op === ts10.SyntaxKind.GreaterThanGreaterThanEqualsToken || op === ts10.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken || op === ts10.SyntaxKind.AmpersandAmpersandEqualsToken || op === ts10.SyntaxKind.BarBarEqualsToken || op === ts10.SyntaxKind.QuestionQuestionEqualsToken) {
7337
+ if (op === ts11.SyntaxKind.EqualsToken || op === ts11.SyntaxKind.PlusEqualsToken || op === ts11.SyntaxKind.MinusEqualsToken || op === ts11.SyntaxKind.AsteriskEqualsToken || op === ts11.SyntaxKind.SlashEqualsToken || op === ts11.SyntaxKind.PercentEqualsToken || op === ts11.SyntaxKind.AsteriskAsteriskEqualsToken || op === ts11.SyntaxKind.AmpersandEqualsToken || op === ts11.SyntaxKind.BarEqualsToken || op === ts11.SyntaxKind.CaretEqualsToken || op === ts11.SyntaxKind.LessThanLessThanEqualsToken || op === ts11.SyntaxKind.GreaterThanGreaterThanEqualsToken || op === ts11.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken || op === ts11.SyntaxKind.AmpersandAmpersandEqualsToken || op === ts11.SyntaxKind.BarBarEqualsToken || op === ts11.SyntaxKind.QuestionQuestionEqualsToken) {
7209
7338
  addFromTarget(n.left);
7210
7339
  }
7211
7340
  }
7212
- if (ts10.isPrefixUnaryExpression(n) || ts10.isPostfixUnaryExpression(n)) {
7213
- if (n.operator === ts10.SyntaxKind.PlusPlusToken || n.operator === ts10.SyntaxKind.MinusMinusToken) {
7341
+ if (ts11.isPrefixUnaryExpression(n) || ts11.isPostfixUnaryExpression(n)) {
7342
+ if (n.operator === ts11.SyntaxKind.PlusPlusToken || n.operator === ts11.SyntaxKind.MinusMinusToken) {
7214
7343
  addFromTarget(n.operand);
7215
7344
  }
7216
7345
  }
7217
- ts10.forEachChild(n, visit2);
7346
+ ts11.forEachChild(n, visit2);
7218
7347
  }
7219
7348
  visit2(node);
7220
7349
  const localDecls = collectLocalDeclarations(node);
@@ -7225,30 +7354,30 @@ function extractAssignedIdentifiersFromNode(node) {
7225
7354
  function collectLocalDeclarations(root) {
7226
7355
  const names = new Set;
7227
7356
  function addBindingName(name) {
7228
- if (ts10.isIdentifier(name)) {
7357
+ if (ts11.isIdentifier(name)) {
7229
7358
  names.add(name.text);
7230
7359
  return;
7231
7360
  }
7232
- if (ts10.isArrayBindingPattern(name)) {
7361
+ if (ts11.isArrayBindingPattern(name)) {
7233
7362
  for (const el of name.elements) {
7234
- if (ts10.isBindingElement(el))
7363
+ if (ts11.isBindingElement(el))
7235
7364
  addBindingName(el.name);
7236
7365
  }
7237
7366
  return;
7238
7367
  }
7239
- if (ts10.isObjectBindingPattern(name)) {
7368
+ if (ts11.isObjectBindingPattern(name)) {
7240
7369
  for (const el of name.elements) {
7241
7370
  addBindingName(el.name);
7242
7371
  }
7243
7372
  }
7244
7373
  }
7245
7374
  function visit2(n) {
7246
- if (ts10.isArrowFunction(n) || ts10.isFunctionExpression(n) || ts10.isFunctionDeclaration(n))
7375
+ if (ts11.isArrowFunction(n) || ts11.isFunctionExpression(n) || ts11.isFunctionDeclaration(n))
7247
7376
  return;
7248
- if (ts10.isVariableDeclaration(n)) {
7377
+ if (ts11.isVariableDeclaration(n)) {
7249
7378
  addBindingName(n.name);
7250
7379
  }
7251
- ts10.forEachChild(n, visit2);
7380
+ ts11.forEachChild(n, visit2);
7252
7381
  }
7253
7382
  visit2(root);
7254
7383
  return names;
@@ -7283,35 +7412,35 @@ var CLIENT_EXPORTS = new Set([
7283
7412
  "Region"
7284
7413
  ]);
7285
7414
  function collectAmbientGlobals(node, ctx) {
7286
- if (ts10.isVariableStatement(node)) {
7287
- const isDeclare = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DeclareKeyword) ?? false;
7415
+ if (ts11.isVariableStatement(node)) {
7416
+ const isDeclare = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DeclareKeyword) ?? false;
7288
7417
  if (!isDeclare)
7289
7418
  return;
7290
7419
  for (const decl of node.declarationList.declarations) {
7291
- if (ts10.isIdentifier(decl.name))
7420
+ if (ts11.isIdentifier(decl.name))
7292
7421
  ctx.ambientGlobals.add(decl.name.text);
7293
7422
  }
7294
7423
  return;
7295
7424
  }
7296
- if (ts10.isFunctionDeclaration(node) && node.name) {
7297
- const isDeclare = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DeclareKeyword) ?? false;
7425
+ if (ts11.isFunctionDeclaration(node) && node.name) {
7426
+ const isDeclare = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DeclareKeyword) ?? false;
7298
7427
  if (isDeclare)
7299
7428
  ctx.ambientGlobals.add(node.name.text);
7300
7429
  return;
7301
7430
  }
7302
- if (ts10.isModuleDeclaration(node)) {
7303
- const isGlobalAugmentation = (node.flags & ts10.NodeFlags.GlobalAugmentation) !== 0;
7431
+ if (ts11.isModuleDeclaration(node)) {
7432
+ const isGlobalAugmentation = (node.flags & ts11.NodeFlags.GlobalAugmentation) !== 0;
7304
7433
  if (!isGlobalAugmentation)
7305
7434
  return;
7306
- if (!node.body || !ts10.isModuleBlock(node.body))
7435
+ if (!node.body || !ts11.isModuleBlock(node.body))
7307
7436
  return;
7308
7437
  for (const inner of node.body.statements) {
7309
- if (ts10.isVariableStatement(inner)) {
7438
+ if (ts11.isVariableStatement(inner)) {
7310
7439
  for (const decl of inner.declarationList.declarations) {
7311
- if (ts10.isIdentifier(decl.name))
7440
+ if (ts11.isIdentifier(decl.name))
7312
7441
  ctx.ambientGlobals.add(decl.name.text);
7313
7442
  }
7314
- } else if (ts10.isFunctionDeclaration(inner) && inner.name) {
7443
+ } else if (ts11.isFunctionDeclaration(inner) && inner.name) {
7315
7444
  ctx.ambientGlobals.add(inner.name.text);
7316
7445
  }
7317
7446
  }
@@ -7322,7 +7451,7 @@ function collectImport(node, ctx) {
7322
7451
  const specifiers = [];
7323
7452
  const isTypeOnly = !!node.importClause?.isTypeOnly;
7324
7453
  const loc = getSourceLocation(node, ctx.sourceFile, ctx.filePath);
7325
- if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings && ts10.isNamedImports(node.importClause.namedBindings)) {
7454
+ if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings && ts11.isNamedImports(node.importClause.namedBindings)) {
7326
7455
  const wrongImports = [];
7327
7456
  for (const element of node.importClause.namedBindings.elements) {
7328
7457
  const name = element.propertyName?.text ?? element.name.text;
@@ -7350,7 +7479,7 @@ function collectImport(node, ctx) {
7350
7479
  });
7351
7480
  }
7352
7481
  if (node.importClause.namedBindings) {
7353
- if (ts10.isNamedImports(node.importClause.namedBindings)) {
7482
+ if (ts11.isNamedImports(node.importClause.namedBindings)) {
7354
7483
  for (const element of node.importClause.namedBindings.elements) {
7355
7484
  specifiers.push({
7356
7485
  name: element.propertyName?.text ?? element.name.text,
@@ -7361,7 +7490,7 @@ function collectImport(node, ctx) {
7361
7490
  });
7362
7491
  }
7363
7492
  }
7364
- if (ts10.isNamespaceImport(node.importClause.namedBindings)) {
7493
+ if (ts11.isNamespaceImport(node.importClause.namedBindings)) {
7365
7494
  specifiers.push({
7366
7495
  name: node.importClause.namedBindings.name.text,
7367
7496
  alias: null,
@@ -7388,7 +7517,7 @@ function collectInterfaceDefinition(node, ctx) {
7388
7517
  });
7389
7518
  }
7390
7519
  function collectTypeAliasDefinition(node, ctx) {
7391
- const properties = ts10.isTypeLiteralNode(node.type) ? membersToProperties(node.type.members, ctx.sourceFile) : undefined;
7520
+ const properties = ts11.isTypeLiteralNode(node.type) ? membersToProperties(node.type.members, ctx.sourceFile) : undefined;
7392
7521
  ctx.typeDefinitions.push({
7393
7522
  kind: "type",
7394
7523
  name: node.name.text,
@@ -7401,20 +7530,20 @@ function extractSingleJsxReturn(body) {
7401
7530
  let jsxReturn = null;
7402
7531
  let returnCount = 0;
7403
7532
  function visit2(node) {
7404
- if (ts10.isFunctionDeclaration(node) || ts10.isFunctionExpression(node) || ts10.isArrowFunction(node))
7533
+ if (ts11.isFunctionDeclaration(node) || ts11.isFunctionExpression(node) || ts11.isArrowFunction(node))
7405
7534
  return;
7406
- if (ts10.isReturnStatement(node)) {
7535
+ if (ts11.isReturnStatement(node)) {
7407
7536
  returnCount++;
7408
7537
  if (node.expression) {
7409
7538
  const expr = unwrapJsxTransparent(node.expression);
7410
- if (ts10.isJsxElement(expr) || ts10.isJsxSelfClosingElement(expr) || ts10.isJsxFragment(expr)) {
7539
+ if (ts11.isJsxElement(expr) || ts11.isJsxSelfClosingElement(expr) || ts11.isJsxFragment(expr)) {
7411
7540
  jsxReturn = expr;
7412
7541
  }
7413
7542
  }
7414
7543
  }
7415
- ts10.forEachChild(node, visit2);
7544
+ ts11.forEachChild(node, visit2);
7416
7545
  }
7417
- ts10.forEachChild(body, visit2);
7546
+ ts11.forEachChild(body, visit2);
7418
7547
  if (returnCount !== 1)
7419
7548
  return null;
7420
7549
  return jsxReturn;
@@ -7431,9 +7560,9 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
7431
7560
  const stmts = body.statements;
7432
7561
  for (let i = 0;i < stmts.length; i++) {
7433
7562
  const stmt = stmts[i];
7434
- if (ts10.isIfStatement(stmt)) {
7563
+ if (ts11.isIfStatement(stmt)) {
7435
7564
  let current = stmt;
7436
- while (ts10.isIfStatement(current)) {
7565
+ while (ts11.isIfStatement(current)) {
7437
7566
  const ifStmt = current;
7438
7567
  if (!isDirectReturnBlock(ifStmt.thenStatement))
7439
7568
  return null;
@@ -7443,7 +7572,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
7443
7572
  return null;
7444
7573
  branches.push({ condition: ifStmt.expression, jsxReturn: jsxReturn ?? null });
7445
7574
  if (ifStmt.elseStatement) {
7446
- if (ts10.isIfStatement(ifStmt.elseStatement)) {
7575
+ if (ts11.isIfStatement(ifStmt.elseStatement)) {
7447
7576
  current = ifStmt.elseStatement;
7448
7577
  continue;
7449
7578
  }
@@ -7465,18 +7594,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
7465
7594
  }
7466
7595
  continue;
7467
7596
  }
7468
- if (ts10.isSwitchStatement(stmt)) {
7597
+ if (ts11.isSwitchStatement(stmt)) {
7469
7598
  if (branches.length > 0)
7470
7599
  return null;
7471
- if (!ts10.isIdentifier(stmt.expression) && !ts10.isPropertyAccessExpression(stmt.expression)) {
7600
+ if (!ts11.isIdentifier(stmt.expression) && !ts11.isPropertyAccessExpression(stmt.expression)) {
7472
7601
  return null;
7473
7602
  }
7474
- const hasDefault = stmt.caseBlock.clauses.some((c) => ts10.isDefaultClause(c));
7603
+ const hasDefault = stmt.caseBlock.clauses.some((c) => ts11.isDefaultClause(c));
7475
7604
  if (!hasDefault)
7476
7605
  return null;
7477
7606
  let pendingCases = [];
7478
7607
  for (const clause of stmt.caseBlock.clauses) {
7479
- if (ts10.isCaseClause(clause) && clause.statements.length === 0) {
7608
+ if (ts11.isCaseClause(clause) && clause.statements.length === 0) {
7480
7609
  pendingCases.push(clause.expression);
7481
7610
  continue;
7482
7611
  }
@@ -7486,7 +7615,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
7486
7615
  return null;
7487
7616
  if (!caseClauseIsDirectReturn(clause))
7488
7617
  return null;
7489
- if (ts10.isCaseClause(clause)) {
7618
+ if (ts11.isCaseClause(clause)) {
7490
7619
  branches.push({
7491
7620
  condition: clause.expression,
7492
7621
  jsxReturn: jsxReturn ?? null,
@@ -7507,18 +7636,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
7507
7636
  return null;
7508
7637
  return { branches, fallback, switchDiscriminant: stmt.expression, preamble };
7509
7638
  }
7510
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7639
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
7511
7640
  const expr = unwrapJsxTransparent(stmt.expression);
7512
- if (ts10.isJsxElement(expr) || ts10.isJsxSelfClosingElement(expr) || ts10.isJsxFragment(expr)) {
7641
+ if (ts11.isJsxElement(expr) || ts11.isJsxSelfClosingElement(expr) || ts11.isJsxFragment(expr)) {
7513
7642
  fallback = expr;
7514
- } else if (expr.kind === ts10.SyntaxKind.NullKeyword) {} else {
7643
+ } else if (expr.kind === ts11.SyntaxKind.NullKeyword) {} else {
7515
7644
  return null;
7516
7645
  }
7517
7646
  continue;
7518
7647
  }
7519
- if (ts10.isVariableStatement(stmt)) {
7648
+ if (ts11.isVariableStatement(stmt)) {
7520
7649
  const declFlags = stmt.declarationList.flags;
7521
- const isConstOrLet = (declFlags & ts10.NodeFlags.Const) !== 0 || (declFlags & ts10.NodeFlags.Let) !== 0;
7650
+ const isConstOrLet = (declFlags & ts11.NodeFlags.Const) !== 0 || (declFlags & ts11.NodeFlags.Let) !== 0;
7522
7651
  if (allowPreamble && isConstOrLet && branches.length === 0 && fallback === null) {
7523
7652
  preamble.push(stmt);
7524
7653
  continue;
@@ -7534,12 +7663,12 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
7534
7663
  return { branches, fallback, preamble };
7535
7664
  }
7536
7665
  function isDirectReturnBlock(node) {
7537
- if (ts10.isReturnStatement(node))
7666
+ if (ts11.isReturnStatement(node))
7538
7667
  return true;
7539
- if (ts10.isBlock(node)) {
7668
+ if (ts11.isBlock(node)) {
7540
7669
  let returnCount = 0;
7541
7670
  for (const stmt of node.statements) {
7542
- if (ts10.isReturnStatement(stmt)) {
7671
+ if (ts11.isReturnStatement(stmt)) {
7543
7672
  returnCount++;
7544
7673
  continue;
7545
7674
  }
@@ -7550,25 +7679,25 @@ function isDirectReturnBlock(node) {
7550
7679
  return false;
7551
7680
  }
7552
7681
  function findNullReturnInBlock(node) {
7553
- if (ts10.isBlock(node)) {
7682
+ if (ts11.isBlock(node)) {
7554
7683
  for (const stmt of node.statements) {
7555
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7684
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
7556
7685
  const expr = unwrapJsxTransparent(stmt.expression);
7557
- if (expr.kind === ts10.SyntaxKind.NullKeyword)
7686
+ if (expr.kind === ts11.SyntaxKind.NullKeyword)
7558
7687
  return true;
7559
7688
  }
7560
7689
  }
7561
7690
  }
7562
- if (ts10.isReturnStatement(node) && node.expression) {
7691
+ if (ts11.isReturnStatement(node) && node.expression) {
7563
7692
  const expr = unwrapJsxTransparent(node.expression);
7564
- if (expr.kind === ts10.SyntaxKind.NullKeyword)
7693
+ if (expr.kind === ts11.SyntaxKind.NullKeyword)
7565
7694
  return true;
7566
7695
  }
7567
7696
  return false;
7568
7697
  }
7569
7698
  function findJsxReturnInCaseClause(clause) {
7570
7699
  for (const stmt of clause.statements) {
7571
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7700
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
7572
7701
  return extractJsxFromExpression(stmt.expression);
7573
7702
  }
7574
7703
  }
@@ -7578,12 +7707,12 @@ function caseClauseIsDirectReturn(clause) {
7578
7707
  let returnCount = 0;
7579
7708
  let seenReturn = false;
7580
7709
  for (const stmt of clause.statements) {
7581
- if (ts10.isReturnStatement(stmt)) {
7710
+ if (ts11.isReturnStatement(stmt)) {
7582
7711
  returnCount++;
7583
7712
  seenReturn = true;
7584
7713
  continue;
7585
7714
  }
7586
- if (ts10.isBreakStatement(stmt)) {
7715
+ if (ts11.isBreakStatement(stmt)) {
7587
7716
  if (!seenReturn)
7588
7717
  return false;
7589
7718
  continue;
@@ -7594,9 +7723,9 @@ function caseClauseIsDirectReturn(clause) {
7594
7723
  }
7595
7724
  function findNullReturnInCaseClause(clause) {
7596
7725
  for (const stmt of clause.statements) {
7597
- if (ts10.isReturnStatement(stmt) && stmt.expression) {
7726
+ if (ts11.isReturnStatement(stmt) && stmt.expression) {
7598
7727
  const expr = unwrapJsxTransparent(stmt.expression);
7599
- if (expr.kind === ts10.SyntaxKind.NullKeyword)
7728
+ if (expr.kind === ts11.SyntaxKind.NullKeyword)
7600
7729
  return true;
7601
7730
  }
7602
7731
  }
@@ -7607,26 +7736,26 @@ function isMultiReturnJsxFunctionBody(body) {
7607
7736
  let hasJsxReturn = false;
7608
7737
  let allReturnsAreJsxOrNull = true;
7609
7738
  function visit2(node) {
7610
- if (ts10.isFunctionDeclaration(node) || ts10.isFunctionExpression(node) || ts10.isArrowFunction(node))
7739
+ if (ts11.isFunctionDeclaration(node) || ts11.isFunctionExpression(node) || ts11.isArrowFunction(node))
7611
7740
  return;
7612
- if (ts10.isReturnStatement(node)) {
7741
+ if (ts11.isReturnStatement(node)) {
7613
7742
  returnCount++;
7614
7743
  if (!node.expression) {
7615
7744
  allReturnsAreJsxOrNull = false;
7616
7745
  return;
7617
7746
  }
7618
7747
  const expr = unwrapJsxTransparent(node.expression);
7619
- const isJsx = ts10.isJsxElement(expr) || ts10.isJsxSelfClosingElement(expr) || ts10.isJsxFragment(expr);
7620
- const isNull = expr.kind === ts10.SyntaxKind.NullKeyword;
7748
+ const isJsx = ts11.isJsxElement(expr) || ts11.isJsxSelfClosingElement(expr) || ts11.isJsxFragment(expr);
7749
+ const isNull = expr.kind === ts11.SyntaxKind.NullKeyword;
7621
7750
  if (isJsx)
7622
7751
  hasJsxReturn = true;
7623
7752
  if (!isJsx && !isNull)
7624
7753
  allReturnsAreJsxOrNull = false;
7625
7754
  return;
7626
7755
  }
7627
- ts10.forEachChild(node, visit2);
7756
+ ts11.forEachChild(node, visit2);
7628
7757
  }
7629
- ts10.forEachChild(body, visit2);
7758
+ ts11.forEachChild(body, visit2);
7630
7759
  return returnCount > 1 && hasJsxReturn && allReturnsAreJsxOrNull;
7631
7760
  }
7632
7761
  function collectFunction(node, ctx, _isModule, isExported = false) {
@@ -7696,7 +7825,7 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
7696
7825
  }
7697
7826
  }
7698
7827
  }
7699
- const isAsync = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.AsyncKeyword) ?? false;
7828
+ const isAsync = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.AsyncKeyword) ?? false;
7700
7829
  const isGenerator = !!node.asteriskToken;
7701
7830
  ctx.localFunctions.push({
7702
7831
  name,
@@ -7717,10 +7846,10 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
7717
7846
  });
7718
7847
  }
7719
7848
  function extractValueBranches(node, ctx) {
7720
- if (ts10.isParenthesizedExpression(node)) {
7849
+ if (ts11.isParenthesizedExpression(node)) {
7721
7850
  return extractValueBranches(node.expression, ctx);
7722
7851
  }
7723
- if (ts10.isConditionalExpression(node)) {
7852
+ if (ts11.isConditionalExpression(node)) {
7724
7853
  return [
7725
7854
  ...extractValueBranches(node.whenTrue, ctx),
7726
7855
  ...extractValueBranches(node.whenFalse, ctx)
@@ -7732,46 +7861,46 @@ function extractFreeIdentifiersFromNode(node) {
7732
7861
  const ids = new Set;
7733
7862
  const boundNames = new Set;
7734
7863
  function addBindingNames(name, out) {
7735
- if (ts10.isIdentifier(name))
7864
+ if (ts11.isIdentifier(name))
7736
7865
  out.push(name.text);
7737
- else if (ts10.isObjectBindingPattern(name))
7866
+ else if (ts11.isObjectBindingPattern(name))
7738
7867
  name.elements.forEach((e) => addBindingNames(e.name, out));
7739
- else if (ts10.isArrayBindingPattern(name))
7868
+ else if (ts11.isArrayBindingPattern(name))
7740
7869
  name.elements.forEach((e) => {
7741
- if (!ts10.isOmittedExpression(e))
7870
+ if (!ts11.isOmittedExpression(e))
7742
7871
  addBindingNames(e.name, out);
7743
7872
  });
7744
7873
  }
7745
7874
  function visit2(n) {
7746
- if (ts10.isTypeNode(n))
7875
+ if (ts11.isTypeNode(n))
7747
7876
  return;
7748
- if (ts10.isIdentifier(n)) {
7877
+ if (ts11.isIdentifier(n)) {
7749
7878
  const parent = n.parent;
7750
- if (parent && ts10.isPropertyAccessExpression(parent) && parent.name === n)
7879
+ if (parent && ts11.isPropertyAccessExpression(parent) && parent.name === n)
7751
7880
  return;
7752
- if (parent && ts10.isPropertyAssignment(parent) && parent.name === n)
7881
+ if (parent && ts11.isPropertyAssignment(parent) && parent.name === n)
7753
7882
  return;
7754
- if (parent && ts10.isParameter(parent) && parent.name === n)
7883
+ if (parent && ts11.isParameter(parent) && parent.name === n)
7755
7884
  return;
7756
- if (parent && ts10.isVariableDeclaration(parent) && parent.name === n)
7885
+ if (parent && ts11.isVariableDeclaration(parent) && parent.name === n)
7757
7886
  return;
7758
7887
  if (boundNames.has(n.text))
7759
7888
  return;
7760
7889
  ids.add(n.text);
7761
7890
  return;
7762
7891
  }
7763
- if (ts10.isArrowFunction(n)) {
7892
+ if (ts11.isArrowFunction(n)) {
7764
7893
  const params = [];
7765
7894
  for (const p of n.parameters)
7766
7895
  addBindingNames(p.name, params);
7767
7896
  for (const name of params)
7768
7897
  boundNames.add(name);
7769
- ts10.forEachChild(n, visit2);
7898
+ ts11.forEachChild(n, visit2);
7770
7899
  for (const name of params)
7771
7900
  boundNames.delete(name);
7772
7901
  return;
7773
7902
  }
7774
- ts10.forEachChild(n, visit2);
7903
+ ts11.forEachChild(n, visit2);
7775
7904
  }
7776
7905
  visit2(node);
7777
7906
  return ids;
@@ -7780,29 +7909,29 @@ function extractFreeTypeIdentifiersFromNode(node) {
7780
7909
  const ids = new Set;
7781
7910
  const boundTypeParams = new Set;
7782
7911
  function rootName(name) {
7783
- return ts10.isQualifiedName(name) ? rootName(name.left) : name;
7912
+ return ts11.isQualifiedName(name) ? rootName(name.left) : name;
7784
7913
  }
7785
7914
  function visit2(n) {
7786
- if (ts10.isTypeReferenceNode(n)) {
7915
+ if (ts11.isTypeReferenceNode(n)) {
7787
7916
  const name = rootName(n.typeName).text;
7788
7917
  if (!boundTypeParams.has(name))
7789
7918
  ids.add(name);
7790
7919
  }
7791
- if (ts10.isTypeQueryNode(n)) {
7920
+ if (ts11.isTypeQueryNode(n)) {
7792
7921
  const name = rootName(n.exprName).text;
7793
7922
  if (!boundTypeParams.has(name))
7794
7923
  ids.add(name);
7795
7924
  }
7796
- if (ts10.isFunctionLike(n) && n.typeParameters && n.typeParameters.length > 0) {
7925
+ if (ts11.isFunctionLike(n) && n.typeParameters && n.typeParameters.length > 0) {
7797
7926
  const names = n.typeParameters.map((p) => p.name.text);
7798
7927
  for (const p of names)
7799
7928
  boundTypeParams.add(p);
7800
- ts10.forEachChild(n, visit2);
7929
+ ts11.forEachChild(n, visit2);
7801
7930
  for (const p of names)
7802
7931
  boundTypeParams.delete(p);
7803
7932
  return;
7804
7933
  }
7805
- ts10.forEachChild(n, visit2);
7934
+ ts11.forEachChild(n, visit2);
7806
7935
  }
7807
7936
  visit2(node);
7808
7937
  return ids;
@@ -7812,22 +7941,22 @@ function initializerShapeContainsJsx(node) {
7812
7941
  function visit2(n) {
7813
7942
  if (found)
7814
7943
  return;
7815
- if (ts10.isJsxElement(n) || ts10.isJsxSelfClosingElement(n) || ts10.isJsxFragment(n)) {
7944
+ if (ts11.isJsxElement(n) || ts11.isJsxSelfClosingElement(n) || ts11.isJsxFragment(n)) {
7816
7945
  found = true;
7817
7946
  return;
7818
7947
  }
7819
- if (ts10.isFunctionDeclaration(n) || ts10.isFunctionExpression(n) || ts10.isArrowFunction(n)) {
7948
+ if (ts11.isFunctionDeclaration(n) || ts11.isFunctionExpression(n) || ts11.isArrowFunction(n)) {
7820
7949
  return;
7821
7950
  }
7822
- ts10.forEachChild(n, visit2);
7951
+ ts11.forEachChild(n, visit2);
7823
7952
  }
7824
7953
  visit2(node);
7825
7954
  return found;
7826
7955
  }
7827
7956
  function isMapLikeCallWithJsx(node) {
7828
- if (!ts10.isCallExpression(node))
7957
+ if (!ts11.isCallExpression(node))
7829
7958
  return false;
7830
- if (!ts10.isPropertyAccessExpression(node.expression))
7959
+ if (!ts11.isPropertyAccessExpression(node.expression))
7831
7960
  return false;
7832
7961
  const method = node.expression.name.text;
7833
7962
  if (method !== "map" && method !== "flatMap")
@@ -7835,12 +7964,12 @@ function isMapLikeCallWithJsx(node) {
7835
7964
  const callback = node.arguments[0];
7836
7965
  if (!callback)
7837
7966
  return false;
7838
- if (!ts10.isArrowFunction(callback) && !ts10.isFunctionExpression(callback))
7967
+ if (!ts11.isArrowFunction(callback) && !ts11.isFunctionExpression(callback))
7839
7968
  return false;
7840
7969
  return containsJsxDeep(callback.body);
7841
7970
  }
7842
7971
  function containsJsxDeep(node) {
7843
- if (ts10.isJsxElement(node) || ts10.isJsxSelfClosingElement(node) || ts10.isJsxFragment(node))
7972
+ if (ts11.isJsxElement(node) || ts11.isJsxSelfClosingElement(node) || ts11.isJsxFragment(node))
7844
7973
  return true;
7845
7974
  let found = false;
7846
7975
  node.forEachChild((child) => {
@@ -7854,11 +7983,11 @@ function nodeContainsArrow(node) {
7854
7983
  function visit2(n) {
7855
7984
  if (found)
7856
7985
  return;
7857
- if (ts10.isArrowFunction(n) || ts10.isFunctionExpression(n)) {
7986
+ if (ts11.isArrowFunction(n) || ts11.isFunctionExpression(n)) {
7858
7987
  found = true;
7859
7988
  return;
7860
7989
  }
7861
- ts10.forEachChild(n, visit2);
7990
+ ts11.forEachChild(n, visit2);
7862
7991
  }
7863
7992
  visit2(node);
7864
7993
  return found;
@@ -7906,20 +8035,20 @@ function collectModuleScopeReactive(decl, ctx, isExported) {
7906
8035
  }));
7907
8036
  }
7908
8037
  function getSystemConstructKind(node) {
7909
- if (ts10.isCallExpression(node) && ts10.isIdentifier(node.expression) && node.expression.text === "createContext")
8038
+ if (ts11.isCallExpression(node) && ts11.isIdentifier(node.expression) && node.expression.text === "createContext")
7910
8039
  return "createContext";
7911
- if (ts10.isNewExpression(node) && ts10.isIdentifier(node.expression) && node.expression.text === "WeakMap")
8040
+ if (ts11.isNewExpression(node) && ts11.isIdentifier(node.expression) && node.expression.text === "WeakMap")
7912
8041
  return "weakMap";
7913
8042
  return;
7914
8043
  }
7915
8044
  function collectConstant(node, ctx, _isModule, declarationKind = "const", isExported = false) {
7916
- if (!_isModule && ts10.isObjectBindingPattern(node.name) && node.initializer && ts10.isIdentifier(node.initializer) && ctx.propsObjectName === node.initializer.text) {
8045
+ if (!_isModule && ts11.isObjectBindingPattern(node.name) && node.initializer && ts11.isIdentifier(node.initializer) && ctx.propsObjectName === node.initializer.text) {
7917
8046
  const propsName = node.initializer.text;
7918
8047
  for (const el of node.name.elements) {
7919
- if (!ts10.isBindingElement(el) || !ts10.isIdentifier(el.name) || el.dotDotDotToken)
8048
+ if (!ts11.isBindingElement(el) || !ts11.isIdentifier(el.name) || el.dotDotDotToken)
7920
8049
  continue;
7921
8050
  const localName = el.name.text;
7922
- const sourceKey = el.propertyName && ts10.isIdentifier(el.propertyName) ? el.propertyName.text : localName;
8051
+ const sourceKey = el.propertyName && ts11.isIdentifier(el.propertyName) ? el.propertyName.text : localName;
7923
8052
  const defaultValueExpr = el.initializer ? ctx.getJS(el.initializer) : undefined;
7924
8053
  const baseValue = `${propsName}.${sourceKey}`;
7925
8054
  const value2 = defaultValueExpr ? `${baseValue} ?? ${defaultValueExpr}` : baseValue;
@@ -7941,7 +8070,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7941
8070
  }
7942
8071
  return;
7943
8072
  }
7944
- if (!ts10.isIdentifier(node.name))
8073
+ if (!ts11.isIdentifier(node.name))
7945
8074
  return;
7946
8075
  if (isSignalDeclaration(node, ctx) || isMemoDeclaration(node, ctx))
7947
8076
  return;
@@ -7959,9 +8088,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7959
8088
  let isJsxFunction = false;
7960
8089
  if (node.initializer) {
7961
8090
  let init = node.initializer;
7962
- while (ts10.isParenthesizedExpression(init))
8091
+ while (ts11.isParenthesizedExpression(init))
7963
8092
  init = init.expression;
7964
- if (ts10.isJsxElement(init) || ts10.isJsxSelfClosingElement(init) || ts10.isJsxFragment(init)) {
8093
+ if (ts11.isJsxElement(init) || ts11.isJsxSelfClosingElement(init) || ts11.isJsxFragment(init)) {
7965
8094
  isJsx = true;
7966
8095
  ctx.jsxConstants.set(name, init);
7967
8096
  } else if (initializerShapeContainsJsx(init)) {
@@ -7969,9 +8098,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7969
8098
  } else if (isMapLikeCallWithJsx(init)) {
7970
8099
  ctx.inlineableJsxConsts.set(name, init);
7971
8100
  }
7972
- if (ts10.isArrowFunction(init)) {
8101
+ if (ts11.isArrowFunction(init)) {
7973
8102
  const arrowBody = init.body;
7974
- if (ts10.isBlock(arrowBody)) {
8103
+ if (ts11.isBlock(arrowBody)) {
7975
8104
  const jsxReturn = extractSingleJsxReturn(arrowBody);
7976
8105
  if (jsxReturn) {
7977
8106
  isJsxFunction = true;
@@ -7991,9 +8120,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
7991
8120
  }
7992
8121
  } else {
7993
8122
  let body = arrowBody;
7994
- while (ts10.isParenthesizedExpression(body))
8123
+ while (ts11.isParenthesizedExpression(body))
7995
8124
  body = body.expression;
7996
- if (ts10.isJsxElement(body) || ts10.isJsxSelfClosingElement(body) || ts10.isJsxFragment(body)) {
8125
+ if (ts11.isJsxElement(body) || ts11.isJsxSelfClosingElement(body) || ts11.isJsxFragment(body)) {
7997
8126
  isJsxFunction = true;
7998
8127
  ctx.jsxFunctions.set(name, {
7999
8128
  jsxReturn: body,
@@ -8006,9 +8135,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
8006
8135
  let valueBranches;
8007
8136
  if (node.initializer) {
8008
8137
  let inner = node.initializer;
8009
- while (ts10.isParenthesizedExpression(inner))
8138
+ while (ts11.isParenthesizedExpression(inner))
8010
8139
  inner = inner.expression;
8011
- if (ts10.isConditionalExpression(inner)) {
8140
+ if (ts11.isConditionalExpression(inner)) {
8012
8141
  valueBranches = extractValueBranches(node.initializer, ctx);
8013
8142
  }
8014
8143
  }
@@ -8086,7 +8215,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
8086
8215
  function hasIgnoreDirective(node, sourceFile, ruleId) {
8087
8216
  const checkComments = (targetNode) => {
8088
8217
  const fullStart = targetNode.getFullStart();
8089
- const leadingComments = ts10.getLeadingCommentRanges(sourceFile.getFullText(), fullStart);
8218
+ const leadingComments = ts11.getLeadingCommentRanges(sourceFile.getFullText(), fullStart);
8090
8219
  if (!leadingComments)
8091
8220
  return false;
8092
8221
  for (const range of leadingComments) {
@@ -8099,10 +8228,10 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
8099
8228
  };
8100
8229
  if (checkComments(node))
8101
8230
  return true;
8102
- if (ts10.isArrowFunction(node)) {
8231
+ if (ts11.isArrowFunction(node)) {
8103
8232
  let current = node.parent;
8104
8233
  while (current) {
8105
- if (ts10.isVariableStatement(current)) {
8234
+ if (ts11.isVariableStatement(current)) {
8106
8235
  if (checkComments(current))
8107
8236
  return true;
8108
8237
  break;
@@ -8113,7 +8242,7 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
8113
8242
  return false;
8114
8243
  }
8115
8244
  function extractProps(param, ctx) {
8116
- if (ts10.isObjectBindingPattern(param.name)) {
8245
+ if (ts11.isObjectBindingPattern(param.name)) {
8117
8246
  const componentNode = ctx.componentNode;
8118
8247
  const ignored = !!(componentNode && hasIgnoreDirective(componentNode, ctx.sourceFile, "props-destructuring"));
8119
8248
  ctx.propsDestructuring = {
@@ -8122,14 +8251,14 @@ function extractProps(param, ctx) {
8122
8251
  };
8123
8252
  const memberTypes = param.type ? collectMemberTypes(param.type, ctx) : null;
8124
8253
  for (const element of param.name.elements) {
8125
- if (ts10.isBindingElement(element) && ts10.isIdentifier(element.name)) {
8254
+ if (ts11.isBindingElement(element) && ts11.isIdentifier(element.name)) {
8126
8255
  const localName = element.name.text;
8127
8256
  const defaultValue = element.initializer ? ctx.getJS(element.initializer) : undefined;
8128
8257
  if (element.dotDotDotToken) {
8129
8258
  ctx.restPropsName = localName;
8130
8259
  continue;
8131
8260
  }
8132
- const sourcePropName = element.propertyName && ts10.isIdentifier(element.propertyName) ? element.propertyName.text : localName;
8261
+ const sourcePropName = element.propertyName && ts11.isIdentifier(element.propertyName) ? element.propertyName.text : localName;
8133
8262
  const member = memberTypes?.get(sourcePropName);
8134
8263
  const resolvedType = member?.type ?? { kind: "unknown", raw: "unknown" };
8135
8264
  const defaultContainsArrow = element.initializer ? nodeContainsArrow(element.initializer) : false;
@@ -8153,7 +8282,7 @@ function extractProps(param, ctx) {
8153
8282
  }
8154
8283
  }
8155
8284
  }
8156
- if (ts10.isIdentifier(param.name)) {
8285
+ if (ts11.isIdentifier(param.name)) {
8157
8286
  ctx.propsObjectName = param.name.text;
8158
8287
  if (param.type) {
8159
8288
  extractPropsFromType(param.type, ctx);
@@ -8164,24 +8293,24 @@ function extractProps(param, ctx) {
8164
8293
  }
8165
8294
  }
8166
8295
  function collectTypeKeys(typeNode, ctx) {
8167
- if (ts10.isTypeLiteralNode(typeNode)) {
8296
+ if (ts11.isTypeLiteralNode(typeNode)) {
8168
8297
  return collectKeysFromMembers(typeNode.members, ctx);
8169
8298
  }
8170
- if (ts10.isTypeReferenceNode(typeNode)) {
8299
+ if (ts11.isTypeReferenceNode(typeNode)) {
8171
8300
  const typeName = typeNode.typeName.getText(ctx.sourceFile);
8172
8301
  const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
8173
8302
  if (!typeDecl)
8174
8303
  return null;
8175
- if (ts10.isInterfaceDeclaration(typeDecl)) {
8304
+ if (ts11.isInterfaceDeclaration(typeDecl)) {
8176
8305
  if (typeDecl.heritageClauses && typeDecl.heritageClauses.length > 0)
8177
8306
  return null;
8178
8307
  return collectKeysFromMembers(typeDecl.members, ctx);
8179
8308
  }
8180
- if (ts10.isTypeAliasDeclaration(typeDecl)) {
8181
- if (ts10.isTypeLiteralNode(typeDecl.type)) {
8309
+ if (ts11.isTypeAliasDeclaration(typeDecl)) {
8310
+ if (ts11.isTypeLiteralNode(typeDecl.type)) {
8182
8311
  return collectKeysFromMembers(typeDecl.type.members, ctx);
8183
8312
  }
8184
- if (ts10.isIntersectionTypeNode(typeDecl.type)) {
8313
+ if (ts11.isIntersectionTypeNode(typeDecl.type)) {
8185
8314
  return null;
8186
8315
  }
8187
8316
  }
@@ -8191,9 +8320,9 @@ function collectTypeKeys(typeNode, ctx) {
8191
8320
  function collectKeysFromMembers(members, ctx) {
8192
8321
  const keys = [];
8193
8322
  for (const member of members) {
8194
- if (ts10.isIndexSignatureDeclaration(member))
8323
+ if (ts11.isIndexSignatureDeclaration(member))
8195
8324
  return null;
8196
- if (ts10.isPropertySignature(member) && member.name) {
8325
+ if (ts11.isPropertySignature(member) && member.name) {
8197
8326
  keys.push(member.name.getText(ctx.sourceFile));
8198
8327
  }
8199
8328
  }
@@ -8217,7 +8346,7 @@ function collectMemberTypes(typeNode, ctx) {
8217
8346
  const fromMembers = (members) => {
8218
8347
  const map = new Map;
8219
8348
  for (const member of members) {
8220
- if (ts10.isPropertySignature(member) && member.name) {
8349
+ if (ts11.isPropertySignature(member) && member.name) {
8221
8350
  const info = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : null;
8222
8351
  map.set(member.name.getText(ctx.sourceFile), {
8223
8352
  type: info && isResolvableMemberType(info) ? info : null,
@@ -8227,35 +8356,35 @@ function collectMemberTypes(typeNode, ctx) {
8227
8356
  }
8228
8357
  return map;
8229
8358
  };
8230
- if (ts10.isTypeLiteralNode(typeNode)) {
8359
+ if (ts11.isTypeLiteralNode(typeNode)) {
8231
8360
  return fromMembers(typeNode.members);
8232
8361
  }
8233
- if (ts10.isTypeReferenceNode(typeNode)) {
8362
+ if (ts11.isTypeReferenceNode(typeNode)) {
8234
8363
  const typeName = typeNode.typeName.getText(ctx.sourceFile);
8235
8364
  const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
8236
8365
  if (!typeDecl)
8237
8366
  return null;
8238
- if (ts10.isInterfaceDeclaration(typeDecl)) {
8367
+ if (ts11.isInterfaceDeclaration(typeDecl)) {
8239
8368
  return fromMembers(typeDecl.members);
8240
8369
  }
8241
- if (ts10.isTypeAliasDeclaration(typeDecl) && ts10.isTypeLiteralNode(typeDecl.type)) {
8370
+ if (ts11.isTypeAliasDeclaration(typeDecl) && ts11.isTypeLiteralNode(typeDecl.type)) {
8242
8371
  return fromMembers(typeDecl.type.members);
8243
8372
  }
8244
8373
  }
8245
8374
  return null;
8246
8375
  }
8247
8376
  function extractPropsFromType(typeNode, ctx) {
8248
- if (ts10.isTypeLiteralNode(typeNode)) {
8377
+ if (ts11.isTypeLiteralNode(typeNode)) {
8249
8378
  extractPropsFromTypeMembers(typeNode.members, ctx);
8250
8379
  return;
8251
8380
  }
8252
- if (ts10.isTypeReferenceNode(typeNode)) {
8381
+ if (ts11.isTypeReferenceNode(typeNode)) {
8253
8382
  const typeName = typeNode.typeName.getText(ctx.sourceFile);
8254
8383
  const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
8255
8384
  if (typeDecl) {
8256
- if (ts10.isInterfaceDeclaration(typeDecl)) {
8385
+ if (ts11.isInterfaceDeclaration(typeDecl)) {
8257
8386
  extractPropsFromTypeMembers(typeDecl.members, ctx);
8258
- } else if (ts10.isTypeAliasDeclaration(typeDecl) && ts10.isTypeLiteralNode(typeDecl.type)) {
8387
+ } else if (ts11.isTypeAliasDeclaration(typeDecl) && ts11.isTypeLiteralNode(typeDecl.type)) {
8259
8388
  extractPropsFromTypeMembers(typeDecl.type.members, ctx);
8260
8389
  }
8261
8390
  }
@@ -8263,7 +8392,7 @@ function extractPropsFromType(typeNode, ctx) {
8263
8392
  }
8264
8393
  function extractPropsFromTypeMembers(members, ctx) {
8265
8394
  for (const member of members) {
8266
- if (ts10.isPropertySignature(member) && member.name) {
8395
+ if (ts11.isPropertySignature(member) && member.name) {
8267
8396
  const propName = member.name.getText(ctx.sourceFile);
8268
8397
  const isOptional = !!member.questionToken;
8269
8398
  const propType = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : { kind: "unknown", raw: "unknown" };
@@ -8279,17 +8408,17 @@ function extractPropsFromTypeMembers(members, ctx) {
8279
8408
  function findTypeDeclaration(typeName, sourceFile) {
8280
8409
  let result;
8281
8410
  function visit2(node) {
8282
- if (ts10.isInterfaceDeclaration(node) && node.name.text === typeName) {
8411
+ if (ts11.isInterfaceDeclaration(node) && node.name.text === typeName) {
8283
8412
  result = node;
8284
8413
  return;
8285
8414
  }
8286
- if (ts10.isTypeAliasDeclaration(node) && node.name.text === typeName) {
8415
+ if (ts11.isTypeAliasDeclaration(node) && node.name.text === typeName) {
8287
8416
  result = node;
8288
8417
  return;
8289
8418
  }
8290
- ts10.forEachChild(node, visit2);
8419
+ ts11.forEachChild(node, visit2);
8291
8420
  }
8292
- ts10.forEachChild(sourceFile, visit2);
8421
+ ts11.forEachChild(sourceFile, visit2);
8293
8422
  return result;
8294
8423
  }
8295
8424
  function inferTypeFromValue(value) {
@@ -8335,12 +8464,12 @@ function inferTypeFromValue(value) {
8335
8464
  }
8336
8465
  function collectCalledIdentifiers(code) {
8337
8466
  const called = new Set;
8338
- const sf = ts10.createSourceFile("__deps__.tsx", code, ts10.ScriptTarget.Latest, false, ts10.ScriptKind.TSX);
8467
+ const sf = ts11.createSourceFile("__deps__.tsx", code, ts11.ScriptTarget.Latest, false, ts11.ScriptKind.TSX);
8339
8468
  const visit2 = (node) => {
8340
- if (ts10.isCallExpression(node) && ts10.isIdentifier(node.expression)) {
8469
+ if (ts11.isCallExpression(node) && ts11.isIdentifier(node.expression)) {
8341
8470
  called.add(node.expression.text);
8342
8471
  }
8343
- ts10.forEachChild(node, visit2);
8472
+ ts11.forEachChild(node, visit2);
8344
8473
  };
8345
8474
  visit2(sf);
8346
8475
  return called;
@@ -8438,16 +8567,16 @@ function isResolvableComponentSource(source) {
8438
8567
  function collectJsxComponentTags(sourceFile) {
8439
8568
  const tags = new Set;
8440
8569
  function visit2(node) {
8441
- if (ts10.isJsxOpeningElement(node) || ts10.isJsxSelfClosingElement(node)) {
8570
+ if (ts11.isJsxOpeningElement(node) || ts11.isJsxSelfClosingElement(node)) {
8442
8571
  const tagName = node.tagName;
8443
- if (ts10.isIdentifier(tagName)) {
8572
+ if (ts11.isIdentifier(tagName)) {
8444
8573
  const first = tagName.text.charAt(0);
8445
8574
  if (first >= "A" && first <= "Z") {
8446
8575
  tags.add(tagName.text);
8447
8576
  }
8448
8577
  }
8449
8578
  }
8450
- ts10.forEachChild(node, visit2);
8579
+ ts11.forEachChild(node, visit2);
8451
8580
  }
8452
8581
  visit2(sourceFile);
8453
8582
  return tags;
@@ -8526,18 +8655,18 @@ function fileHasUseClientDirective(filePath) {
8526
8655
  } catch {
8527
8656
  return true;
8528
8657
  }
8529
- const sf = ts10.createSourceFile(filePath, content, ts10.ScriptTarget.Latest, false, ts10.ScriptKind.TSX);
8658
+ const sf = ts11.createSourceFile(filePath, content, ts11.ScriptTarget.Latest, false, ts11.ScriptKind.TSX);
8530
8659
  let found = false;
8531
8660
  function visit2(node) {
8532
8661
  if (found)
8533
8662
  return;
8534
- if (ts10.isExpressionStatement(node) && ts10.isStringLiteral(node.expression)) {
8663
+ if (ts11.isExpressionStatement(node) && ts11.isStringLiteral(node.expression)) {
8535
8664
  if (node.expression.text === "use client") {
8536
8665
  found = true;
8537
8666
  return;
8538
8667
  }
8539
8668
  }
8540
- ts10.forEachChild(node, visit2);
8669
+ ts11.forEachChild(node, visit2);
8541
8670
  }
8542
8671
  visit2(sf);
8543
8672
  return found;
@@ -8615,11 +8744,11 @@ function importsBrowserOnlyClientApi(ctx) {
8615
8744
  return false;
8616
8745
  }
8617
8746
  function listComponentFunctions(source, filePath) {
8618
- const sourceFile = ts10.createSourceFile(filePath, source, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
8747
+ const sourceFile = ts11.createSourceFile(filePath, source, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
8619
8748
  return listComponentFunctionsFromSourceFile(sourceFile);
8620
8749
  }
8621
8750
  function scanComponentFile(source, filePath) {
8622
- const sourceFile = ts10.createSourceFile(filePath, source, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
8751
+ const sourceFile = ts11.createSourceFile(filePath, source, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
8623
8752
  return {
8624
8753
  exports: listComponentFunctionsFromSourceFile(sourceFile),
8625
8754
  referencedComponents: [...collectJsxComponentTags(sourceFile)]
@@ -8627,11 +8756,11 @@ function scanComponentFile(source, filePath) {
8627
8756
  }
8628
8757
  function listComponentFunctionsFromSourceFile(sourceFile) {
8629
8758
  const componentNames = [];
8630
- const hasUseClient = sourceFile.statements.some((stmt) => ts10.isExpressionStatement(stmt) && ts10.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
8759
+ const hasUseClient = sourceFile.statements.some((stmt) => ts11.isExpressionStatement(stmt) && ts11.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
8631
8760
  const namedExports = collectNamedExports(sourceFile);
8632
8761
  function collectComponents(node) {
8633
8762
  if (isComponentFunction(node)) {
8634
- const hasInlineExport = node.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
8763
+ const hasInlineExport = node.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
8635
8764
  const hasNamedExport = namedExports.has(node.name.text);
8636
8765
  const isExported = hasInlineExport || hasNamedExport;
8637
8766
  if (!hasUseClient && !isExported && node.body && isMultiReturnJsxFunctionBody(node.body)) {} else {
@@ -8641,9 +8770,9 @@ function listComponentFunctionsFromSourceFile(sourceFile) {
8641
8770
  if (isArrowComponentFunction(node)) {
8642
8771
  componentNames.push(node.name.text);
8643
8772
  }
8644
- ts10.forEachChild(node, collectComponents);
8773
+ ts11.forEachChild(node, collectComponents);
8645
8774
  }
8646
- ts10.forEachChild(sourceFile, collectComponents);
8775
+ ts11.forEachChild(sourceFile, collectComponents);
8647
8776
  return componentNames;
8648
8777
  }
8649
8778
  var REACTIVE_PRIMITIVES = new Set([
@@ -8655,13 +8784,13 @@ var REACTIVE_PRIMITIVES = new Set([
8655
8784
  "onCleanup"
8656
8785
  ]);
8657
8786
  function prescanReactiveFactoriesInSource(source, filePath) {
8658
- const sourceFile = ts10.createSourceFile(filePath + ".prescan", source, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
8787
+ const sourceFile = ts11.createSourceFile(filePath + ".prescan", source, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
8659
8788
  const factories = new Map;
8660
8789
  const declined = new Map;
8661
8790
  const reactiveShaped = new Set;
8662
8791
  const cleanFactoryImports = new Set;
8663
8792
  function visitTop(node) {
8664
- if (ts10.isFunctionDeclaration(node) && node.name && node.body) {
8793
+ if (ts11.isFunctionDeclaration(node) && node.name && node.body) {
8665
8794
  const det = detectReactiveFactory(node, sourceFile, filePath);
8666
8795
  if (!det)
8667
8796
  return;
@@ -8678,7 +8807,7 @@ function prescanReactiveFactoriesInSource(source, filePath) {
8678
8807
  }
8679
8808
  }
8680
8809
  }
8681
- ts10.forEachChild(sourceFile, visitTop);
8810
+ ts11.forEachChild(sourceFile, visitTop);
8682
8811
  const result = { factories, declined, reactiveShaped, cleanFactoryImports, sourceFile };
8683
8812
  prescanImportedReactiveFactories(sourceFile, filePath, result);
8684
8813
  return result;
@@ -8695,15 +8824,15 @@ function toComponentRelativeSpecifier(resolvedAbs, componentFilePath) {
8695
8824
  function buildEntryImportIndex(sf, filePath) {
8696
8825
  const index = new Map;
8697
8826
  for (const stmt of sf.statements) {
8698
- if (!ts10.isImportDeclaration(stmt))
8827
+ if (!ts11.isImportDeclaration(stmt))
8699
8828
  continue;
8700
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
8829
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
8701
8830
  continue;
8702
8831
  const src = stmt.moduleSpecifier.text;
8703
8832
  const targetKey = src.startsWith("./") || src.startsWith("../") ? resolveRelativeImportToFile(src, filePath) ?? "unresolved:" + src : src;
8704
8833
  const wholeTypeOnly = stmt.importClause?.isTypeOnly === true;
8705
8834
  const namedBindings = stmt.importClause?.namedBindings;
8706
- if (namedBindings && ts10.isNamedImports(namedBindings)) {
8835
+ if (namedBindings && ts11.isNamedImports(namedBindings)) {
8707
8836
  for (const el of namedBindings.elements) {
8708
8837
  index.set(el.name.text, {
8709
8838
  targetKey,
@@ -8718,31 +8847,31 @@ function buildEntryImportIndex(sf, filePath) {
8718
8847
  function collectEntryBindingNames(sf) {
8719
8848
  const names = new Set;
8720
8849
  function visit2(node) {
8721
- if (ts10.isImportDeclaration(node) && node.importClause) {
8850
+ if (ts11.isImportDeclaration(node) && node.importClause) {
8722
8851
  if (node.importClause.name)
8723
8852
  names.add(node.importClause.name.text);
8724
8853
  const namedBindings = node.importClause.namedBindings;
8725
- if (namedBindings && ts10.isNamedImports(namedBindings)) {
8854
+ if (namedBindings && ts11.isNamedImports(namedBindings)) {
8726
8855
  for (const el of namedBindings.elements)
8727
8856
  names.add(el.name.text);
8728
8857
  }
8729
- if (namedBindings && ts10.isNamespaceImport(namedBindings)) {
8858
+ if (namedBindings && ts11.isNamespaceImport(namedBindings)) {
8730
8859
  names.add(namedBindings.name.text);
8731
8860
  }
8732
8861
  }
8733
- if (ts10.isVariableDeclaration(node)) {
8862
+ if (ts11.isVariableDeclaration(node)) {
8734
8863
  const out = [];
8735
8864
  addBindingNames(node.name, out);
8736
8865
  for (const n of out)
8737
8866
  names.add(n);
8738
8867
  }
8739
- if ((ts10.isFunctionDeclaration(node) || ts10.isClassDeclaration(node) || ts10.isEnumDeclaration(node)) && node.name) {
8868
+ if ((ts11.isFunctionDeclaration(node) || ts11.isClassDeclaration(node) || ts11.isEnumDeclaration(node)) && node.name) {
8740
8869
  names.add(node.name.text);
8741
8870
  }
8742
- if ((ts10.isTypeAliasDeclaration(node) || ts10.isInterfaceDeclaration(node)) && node.name) {
8871
+ if ((ts11.isTypeAliasDeclaration(node) || ts11.isInterfaceDeclaration(node)) && node.name) {
8743
8872
  names.add(node.name.text);
8744
8873
  }
8745
- if (ts10.isFunctionLike(node)) {
8874
+ if (ts11.isFunctionLike(node)) {
8746
8875
  for (const p of node.parameters) {
8747
8876
  const out = [];
8748
8877
  addBindingNames(p.name, out);
@@ -8750,7 +8879,7 @@ function collectEntryBindingNames(sf) {
8750
8879
  names.add(n);
8751
8880
  }
8752
8881
  }
8753
- ts10.forEachChild(node, visit2);
8882
+ ts11.forEachChild(node, visit2);
8754
8883
  }
8755
8884
  visit2(sf);
8756
8885
  return names;
@@ -8759,19 +8888,19 @@ var MAX_REEXPORT_HOPS = 1;
8759
8888
  function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8760
8889
  const candidateCallees = new Set;
8761
8890
  function collectCandidates(node) {
8762
- if (ts10.isVariableDeclaration(node) && (ts10.isArrayBindingPattern(node.name) || ts10.isObjectBindingPattern(node.name)) && node.initializer && ts10.isCallExpression(node.initializer) && ts10.isIdentifier(node.initializer.expression)) {
8891
+ if (ts11.isVariableDeclaration(node) && (ts11.isArrayBindingPattern(node.name) || ts11.isObjectBindingPattern(node.name)) && node.initializer && ts11.isCallExpression(node.initializer) && ts11.isIdentifier(node.initializer.expression)) {
8763
8892
  candidateCallees.add(node.initializer.expression.text);
8764
8893
  }
8765
- ts10.forEachChild(node, collectCandidates);
8894
+ ts11.forEachChild(node, collectCandidates);
8766
8895
  }
8767
8896
  collectCandidates(entrySourceFile);
8768
8897
  if (candidateCallees.size === 0)
8769
8898
  return;
8770
8899
  const importsToCheck = [];
8771
8900
  for (const stmt of entrySourceFile.statements) {
8772
- if (!ts10.isImportDeclaration(stmt))
8901
+ if (!ts11.isImportDeclaration(stmt))
8773
8902
  continue;
8774
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
8903
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
8775
8904
  continue;
8776
8905
  const src = stmt.moduleSpecifier.text;
8777
8906
  if (!src.startsWith("./") && !src.startsWith("../"))
@@ -8779,7 +8908,7 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8779
8908
  if (stmt.importClause?.isTypeOnly)
8780
8909
  continue;
8781
8910
  const namedBindings = stmt.importClause?.namedBindings;
8782
- if (!namedBindings || !ts10.isNamedImports(namedBindings))
8911
+ if (!namedBindings || !ts11.isNamedImports(namedBindings))
8783
8912
  continue;
8784
8913
  const specs = [];
8785
8914
  for (const el of namedBindings.elements) {
@@ -8817,14 +8946,14 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8817
8946
  helperCache.set(abs, "clean");
8818
8947
  return "clean";
8819
8948
  }
8820
- const sf = ts10.createSourceFile(abs + ".prescan", content, ts10.ScriptTarget.Latest, true, ts10.ScriptKind.TSX);
8949
+ const sf = ts11.createSourceFile(abs + ".prescan", content, ts11.ScriptTarget.Latest, true, ts11.ScriptKind.TSX);
8821
8950
  const localFns = new Map;
8822
8951
  const exportedFns = new Map;
8823
8952
  for (const stmt of sf.statements) {
8824
- if (ts10.isFunctionDeclaration(stmt) && stmt.name && stmt.body) {
8953
+ if (ts11.isFunctionDeclaration(stmt) && stmt.name && stmt.body) {
8825
8954
  localFns.set(stmt.name.text, stmt);
8826
- const hasExportModifier = stmt.modifiers?.some((m) => m.kind === ts10.SyntaxKind.ExportKeyword) ?? false;
8827
- const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind === ts10.SyntaxKind.DefaultKeyword) ?? false;
8955
+ const hasExportModifier = stmt.modifiers?.some((m) => m.kind === ts11.SyntaxKind.ExportKeyword) ?? false;
8956
+ const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind === ts11.SyntaxKind.DefaultKeyword) ?? false;
8828
8957
  if (hasExportModifier && !hasDefaultModifier) {
8829
8958
  exportedFns.set(stmt.name.text, stmt);
8830
8959
  }
@@ -8833,10 +8962,10 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8833
8962
  const reexports = new Map;
8834
8963
  let hasStarReexport = false;
8835
8964
  for (const stmt of sf.statements) {
8836
- if (!ts10.isExportDeclaration(stmt) || stmt.isTypeOnly)
8965
+ if (!ts11.isExportDeclaration(stmt) || stmt.isTypeOnly)
8837
8966
  continue;
8838
8967
  if (!stmt.moduleSpecifier) {
8839
- if (stmt.exportClause && ts10.isNamedExports(stmt.exportClause)) {
8968
+ if (stmt.exportClause && ts11.isNamedExports(stmt.exportClause)) {
8840
8969
  for (const el of stmt.exportClause.elements) {
8841
8970
  if (el.isTypeOnly)
8842
8971
  continue;
@@ -8847,9 +8976,9 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
8847
8976
  }
8848
8977
  continue;
8849
8978
  }
8850
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
8979
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
8851
8980
  continue;
8852
- if (stmt.exportClause && ts10.isNamedExports(stmt.exportClause)) {
8981
+ if (stmt.exportClause && ts11.isNamedExports(stmt.exportClause)) {
8853
8982
  for (const el of stmt.exportClause.elements) {
8854
8983
  if (el.isTypeOnly)
8855
8984
  continue;
@@ -8999,7 +9128,7 @@ function collectHelperModuleValueBindings(sf) {
8999
9128
  const importedTypes = new Map;
9000
9129
  const imported = new Map;
9001
9130
  for (const stmt of sf.statements) {
9002
- if (ts10.isVariableStatement(stmt)) {
9131
+ if (ts11.isVariableStatement(stmt)) {
9003
9132
  const out = [];
9004
9133
  for (const decl of stmt.declarationList.declarations) {
9005
9134
  addBindingNames(decl.name, out);
@@ -9008,16 +9137,16 @@ function collectHelperModuleValueBindings(sf) {
9008
9137
  local.add(n);
9009
9138
  continue;
9010
9139
  }
9011
- if ((ts10.isFunctionDeclaration(stmt) || ts10.isClassDeclaration(stmt) || ts10.isEnumDeclaration(stmt)) && stmt.name) {
9140
+ if ((ts11.isFunctionDeclaration(stmt) || ts11.isClassDeclaration(stmt) || ts11.isEnumDeclaration(stmt)) && stmt.name) {
9012
9141
  local.add(stmt.name.text);
9013
9142
  continue;
9014
9143
  }
9015
- if ((ts10.isTypeAliasDeclaration(stmt) || ts10.isInterfaceDeclaration(stmt)) && stmt.name) {
9144
+ if ((ts11.isTypeAliasDeclaration(stmt) || ts11.isInterfaceDeclaration(stmt)) && stmt.name) {
9016
9145
  localTypes.add(stmt.name.text);
9017
9146
  continue;
9018
9147
  }
9019
- if (ts10.isImportDeclaration(stmt)) {
9020
- if (!ts10.isStringLiteral(stmt.moduleSpecifier))
9148
+ if (ts11.isImportDeclaration(stmt)) {
9149
+ if (!ts11.isStringLiteral(stmt.moduleSpecifier))
9021
9150
  continue;
9022
9151
  const src = stmt.moduleSpecifier.text;
9023
9152
  if (src === "@barefootjs/client" || src === "@barefootjs/client/runtime")
@@ -9026,7 +9155,7 @@ function collectHelperModuleValueBindings(sf) {
9026
9155
  if (stmt.importClause?.name)
9027
9156
  (wholeTypeOnly ? localTypes : local).add(stmt.importClause.name.text);
9028
9157
  const namedBindings = stmt.importClause?.namedBindings;
9029
- if (namedBindings && ts10.isNamedImports(namedBindings)) {
9158
+ if (namedBindings && ts11.isNamedImports(namedBindings)) {
9030
9159
  for (const el of namedBindings.elements) {
9031
9160
  const entry = { source: src, exportedName: (el.propertyName ?? el.name).text };
9032
9161
  if (wholeTypeOnly || el.isTypeOnly)
@@ -9035,7 +9164,7 @@ function collectHelperModuleValueBindings(sf) {
9035
9164
  imported.set(el.name.text, entry);
9036
9165
  }
9037
9166
  }
9038
- if (namedBindings && ts10.isNamespaceImport(namedBindings)) {
9167
+ if (namedBindings && ts11.isNamespaceImport(namedBindings)) {
9039
9168
  (wholeTypeOnly ? localTypes : local).add(namedBindings.name.text);
9040
9169
  }
9041
9170
  }
@@ -9102,11 +9231,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9102
9231
  function checkForReactive(n) {
9103
9232
  if (hasReactiveCall)
9104
9233
  return;
9105
- if (ts10.isCallExpression(n) && ts10.isIdentifier(n.expression) && REACTIVE_PRIMITIVES.has(n.expression.text)) {
9234
+ if (ts11.isCallExpression(n) && ts11.isIdentifier(n.expression) && REACTIVE_PRIMITIVES.has(n.expression.text)) {
9106
9235
  hasReactiveCall = true;
9107
9236
  return;
9108
9237
  }
9109
- ts10.forEachChild(n, checkForReactive);
9238
+ ts11.forEachChild(n, checkForReactive);
9110
9239
  }
9111
9240
  checkForReactive(node.body);
9112
9241
  if (!hasReactiveCall)
@@ -9114,29 +9243,29 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9114
9243
  const loc = getSourceLocation(node, sourceFile, filePath);
9115
9244
  let totalReturnCount = 0;
9116
9245
  function countReturns(n) {
9117
- if (ts10.isFunctionLike(n))
9246
+ if (ts11.isFunctionLike(n))
9118
9247
  return;
9119
- if (ts10.isReturnStatement(n)) {
9248
+ if (ts11.isReturnStatement(n)) {
9120
9249
  totalReturnCount++;
9121
9250
  return;
9122
9251
  }
9123
- ts10.forEachChild(n, countReturns);
9252
+ ts11.forEachChild(n, countReturns);
9124
9253
  }
9125
- ts10.forEachChild(node.body, countReturns);
9254
+ ts11.forEachChild(node.body, countReturns);
9126
9255
  let returnExpr = null;
9127
9256
  let returnCount = 0;
9128
9257
  for (const stmt of node.body.statements) {
9129
- if (!ts10.isReturnStatement(stmt))
9258
+ if (!ts11.isReturnStatement(stmt))
9130
9259
  continue;
9131
9260
  returnCount++;
9132
9261
  if (!stmt.expression)
9133
9262
  return { kind: "reactive-shaped" };
9134
9263
  let expr = stmt.expression;
9135
- while (ts10.isParenthesizedExpression(expr))
9264
+ while (ts11.isParenthesizedExpression(expr))
9136
9265
  expr = expr.expression;
9137
- if (ts10.isAsExpression(expr))
9266
+ if (ts11.isAsExpression(expr))
9138
9267
  expr = expr.expression;
9139
- if (ts10.isTypeAssertionExpression(expr))
9268
+ if (ts11.isTypeAssertionExpression(expr))
9140
9269
  expr = expr.expression;
9141
9270
  returnExpr = expr;
9142
9271
  }
@@ -9144,18 +9273,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9144
9273
  return { kind: "reactive-shaped" };
9145
9274
  const returnTupleIdentifiers = [];
9146
9275
  let returnKind;
9147
- if (ts10.isArrayLiteralExpression(returnExpr)) {
9276
+ if (ts11.isArrayLiteralExpression(returnExpr)) {
9148
9277
  returnKind = "tuple";
9149
9278
  for (const el of returnExpr.elements) {
9150
- if (!ts10.isIdentifier(el))
9279
+ if (!ts11.isIdentifier(el))
9151
9280
  return { kind: "reactive-shaped" };
9152
9281
  returnTupleIdentifiers.push(el.text);
9153
9282
  }
9154
9283
  if (returnTupleIdentifiers.length === 0)
9155
9284
  return { kind: "reactive-shaped" };
9156
- } else if (ts10.isObjectLiteralExpression(returnExpr)) {
9285
+ } else if (ts11.isObjectLiteralExpression(returnExpr)) {
9157
9286
  returnKind = "object";
9158
- const hasNonShorthand = returnExpr.properties.some((p) => !ts10.isShorthandPropertyAssignment(p));
9287
+ const hasNonShorthand = returnExpr.properties.some((p) => !ts11.isShorthandPropertyAssignment(p));
9159
9288
  if (hasNonShorthand) {
9160
9289
  return {
9161
9290
  kind: "declined",
@@ -9176,7 +9305,7 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9176
9305
  }
9177
9306
  const params = [];
9178
9307
  for (const p of node.parameters) {
9179
- if (ts10.isIdentifier(p.name)) {
9308
+ if (ts11.isIdentifier(p.name)) {
9180
9309
  params.push(p.name.text);
9181
9310
  continue;
9182
9311
  }
@@ -9184,11 +9313,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9184
9313
  }
9185
9314
  const localBindings = [];
9186
9315
  for (const stmt of node.body.statements) {
9187
- if (ts10.isVariableStatement(stmt)) {
9316
+ if (ts11.isVariableStatement(stmt)) {
9188
9317
  for (const decl of stmt.declarationList.declarations) {
9189
9318
  addBindingNames(decl.name, localBindings);
9190
9319
  }
9191
- } else if (ts10.isFunctionDeclaration(stmt) && stmt.name) {
9320
+ } else if (ts11.isFunctionDeclaration(stmt) && stmt.name) {
9192
9321
  localBindings.push(stmt.name.text);
9193
9322
  }
9194
9323
  }
@@ -9208,47 +9337,47 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9208
9337
  if (!relevantNames.has(id.text))
9209
9338
  return;
9210
9339
  const p = id.parent;
9211
- if (ts10.isPropertyAccessExpression(p) && p.name === id)
9340
+ if (ts11.isPropertyAccessExpression(p) && p.name === id)
9212
9341
  return;
9213
- if (ts10.isPropertyAssignment(p) && p.name === id)
9342
+ if (ts11.isPropertyAssignment(p) && p.name === id)
9214
9343
  return;
9215
- if (ts10.isBindingElement(p) && p.propertyName === id)
9344
+ if (ts11.isBindingElement(p) && p.propertyName === id)
9216
9345
  return;
9217
- if ((ts10.isMethodDeclaration(p) || ts10.isGetAccessorDeclaration(p) || ts10.isSetAccessorDeclaration(p) || ts10.isPropertyDeclaration(p) || ts10.isEnumMember(p)) && p.name === id)
9346
+ if ((ts11.isMethodDeclaration(p) || ts11.isGetAccessorDeclaration(p) || ts11.isSetAccessorDeclaration(p) || ts11.isPropertyDeclaration(p) || ts11.isEnumMember(p)) && p.name === id)
9218
9347
  return;
9219
- if (ts10.isJsxAttribute(p) && p.name === id)
9348
+ if (ts11.isJsxAttribute(p) && p.name === id)
9220
9349
  return;
9221
- if (ts10.isLabeledStatement(p) && p.label === id || (ts10.isBreakStatement(p) || ts10.isContinueStatement(p)) && p.label === id)
9350
+ if (ts11.isLabeledStatement(p) && p.label === id || (ts11.isBreakStatement(p) || ts11.isContinueStatement(p)) && p.label === id)
9222
9351
  return;
9223
- if ((ts10.isJsxOpeningElement(p) || ts10.isJsxSelfClosingElement(p) || ts10.isJsxClosingElement(p)) && p.tagName === id && /^[a-z]/.test(id.text))
9352
+ if ((ts11.isJsxOpeningElement(p) || ts11.isJsxSelfClosingElement(p) || ts11.isJsxClosingElement(p)) && p.tagName === id && /^[a-z]/.test(id.text))
9224
9353
  return;
9225
- if (ts10.isShorthandPropertyAssignment(p) && p.name === id) {
9354
+ if (ts11.isShorthandPropertyAssignment(p) && p.name === id) {
9226
9355
  push(id, "shorthand");
9227
9356
  return;
9228
9357
  }
9229
- if (ts10.isBindingElement(p) && p.name === id && !p.propertyName && ts10.isObjectBindingPattern(p.parent)) {
9358
+ if (ts11.isBindingElement(p) && p.name === id && !p.propertyName && ts11.isObjectBindingPattern(p.parent)) {
9230
9359
  if (params.includes(id.text))
9231
9360
  shadowedParam = id.text;
9232
9361
  push(id, "shorthand");
9233
9362
  return;
9234
9363
  }
9235
- const isDecl = (ts10.isVariableDeclaration(p) || ts10.isParameter(p) || ts10.isBindingElement(p) || ts10.isFunctionDeclaration(p) || ts10.isFunctionExpression(p) || ts10.isClassDeclaration(p) || ts10.isClassExpression(p)) && p.name === id;
9364
+ const isDecl = (ts11.isVariableDeclaration(p) || ts11.isParameter(p) || ts11.isBindingElement(p) || ts11.isFunctionDeclaration(p) || ts11.isFunctionExpression(p) || ts11.isClassDeclaration(p) || ts11.isClassExpression(p)) && p.name === id;
9236
9365
  if (isDecl && params.includes(id.text))
9237
9366
  shadowedParam = id.text;
9238
9367
  push(id, "plain");
9239
9368
  }
9240
9369
  function visit2(n) {
9241
- if (ts10.isTypeNode(n) || ts10.isTypeParameterDeclaration(n) || ts10.isTypeAliasDeclaration(n) || ts10.isInterfaceDeclaration(n))
9370
+ if (ts11.isTypeNode(n) || ts11.isTypeParameterDeclaration(n) || ts11.isTypeAliasDeclaration(n) || ts11.isInterfaceDeclaration(n))
9242
9371
  return;
9243
- if (ts10.isIdentifier(n)) {
9372
+ if (ts11.isIdentifier(n)) {
9244
9373
  classify(n);
9245
9374
  return;
9246
9375
  }
9247
- ts10.forEachChild(n, visit2);
9376
+ ts11.forEachChild(n, visit2);
9248
9377
  }
9249
9378
  visit2(root);
9250
9379
  }
9251
- const keptStatements = node.body.statements.filter((s) => !ts10.isReturnStatement(s));
9380
+ const keptStatements = node.body.statements.filter((s) => !ts11.isReturnStatement(s));
9252
9381
  const pieces = [];
9253
9382
  let base = 0;
9254
9383
  for (const stmt of keptStatements) {
@@ -9296,18 +9425,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
9296
9425
  };
9297
9426
  }
9298
9427
  function addBindingNames(name, out) {
9299
- if (ts10.isIdentifier(name)) {
9428
+ if (ts11.isIdentifier(name)) {
9300
9429
  out.push(name.text);
9301
9430
  return;
9302
9431
  }
9303
- if (ts10.isObjectBindingPattern(name)) {
9432
+ if (ts11.isObjectBindingPattern(name)) {
9304
9433
  for (const el of name.elements)
9305
9434
  addBindingNames(el.name, out);
9306
9435
  return;
9307
9436
  }
9308
- if (ts10.isArrayBindingPattern(name)) {
9437
+ if (ts11.isArrayBindingPattern(name)) {
9309
9438
  for (const el of name.elements) {
9310
- if (ts10.isOmittedExpression(el))
9439
+ if (ts11.isOmittedExpression(el))
9311
9440
  continue;
9312
9441
  addBindingNames(el.name, out);
9313
9442
  }
@@ -9319,33 +9448,33 @@ function rewriteFactoryCallsInSource(source, prescan) {
9319
9448
  let callSiteIndex = 0;
9320
9449
  const inlinedFactories = new Set;
9321
9450
  function visitStmt(node, inComponent) {
9322
- if (ts10.isVariableStatement(node) && inComponent) {
9451
+ if (ts11.isVariableStatement(node) && inComponent) {
9323
9452
  for (const decl of node.declarationList.declarations) {
9324
9453
  maybeRewriteDecl(node, decl);
9325
9454
  }
9326
9455
  }
9327
- ts10.forEachChild(node, (child) => {
9328
- if (ts10.isFunctionDeclaration(child) && child.name && factories.has(child.name.text))
9456
+ ts11.forEachChild(node, (child) => {
9457
+ if (ts11.isFunctionDeclaration(child) && child.name && factories.has(child.name.text))
9329
9458
  return;
9330
9459
  visitStmt(child, inComponent || isPascalCaseComponentFn(child));
9331
9460
  });
9332
9461
  }
9333
9462
  function maybeRewriteDecl(stmt, decl) {
9334
- if (!decl.initializer || !ts10.isCallExpression(decl.initializer))
9463
+ if (!decl.initializer || !ts11.isCallExpression(decl.initializer))
9335
9464
  return;
9336
- if (!ts10.isIdentifier(decl.initializer.expression))
9465
+ if (!ts11.isIdentifier(decl.initializer.expression))
9337
9466
  return;
9338
9467
  const factoryName = decl.initializer.expression.text;
9339
9468
  const factory = factories.get(factoryName);
9340
9469
  if (!factory)
9341
9470
  return;
9342
- if (ts10.isArrayBindingPattern(decl.name)) {
9471
+ if (ts11.isArrayBindingPattern(decl.name)) {
9343
9472
  if (factory.returnKind !== "tuple")
9344
9473
  return;
9345
9474
  rewriteTupleDecl(stmt, decl.name, decl.initializer, factory);
9346
9475
  return;
9347
9476
  }
9348
- if (ts10.isObjectBindingPattern(decl.name)) {
9477
+ if (ts11.isObjectBindingPattern(decl.name)) {
9349
9478
  if (factory.returnKind !== "object")
9350
9479
  return;
9351
9480
  rewriteObjectDecl(stmt, decl.name, decl.initializer, factory);
@@ -9358,7 +9487,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
9358
9487
  return;
9359
9488
  const callerNames = [];
9360
9489
  for (const el of elements) {
9361
- if (ts10.isOmittedExpression(el) || !ts10.isIdentifier(el.name))
9490
+ if (ts11.isOmittedExpression(el) || !ts11.isIdentifier(el.name))
9362
9491
  return;
9363
9492
  callerNames.push(el.name.text);
9364
9493
  }
@@ -9380,7 +9509,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
9380
9509
  return;
9381
9510
  if (el.initializer)
9382
9511
  return;
9383
- if (!ts10.isIdentifier(el.name))
9512
+ if (!ts11.isIdentifier(el.name))
9384
9513
  return;
9385
9514
  if (!factory.returnTupleIdentifiers.includes(el.name.text))
9386
9515
  return;
@@ -9489,21 +9618,21 @@ function factoryImportInsertionOffset(sf) {
9489
9618
  let lastImportEnd = -1;
9490
9619
  let directiveEnd = -1;
9491
9620
  for (const stmt of sf.statements) {
9492
- if (ts10.isImportDeclaration(stmt)) {
9621
+ if (ts11.isImportDeclaration(stmt)) {
9493
9622
  lastImportEnd = stmt.getEnd();
9494
9623
  continue;
9495
9624
  }
9496
- if (directiveEnd === -1 && ts10.isExpressionStatement(stmt) && ts10.isStringLiteral(stmt.expression) && stmt.expression.text === "use client") {
9625
+ if (directiveEnd === -1 && ts11.isExpressionStatement(stmt) && ts11.isStringLiteral(stmt.expression) && stmt.expression.text === "use client") {
9497
9626
  directiveEnd = stmt.getEnd();
9498
9627
  }
9499
9628
  }
9500
9629
  return lastImportEnd >= 0 ? lastImportEnd : directiveEnd >= 0 ? directiveEnd : 0;
9501
9630
  }
9502
9631
  function isPascalCaseComponentFn(node) {
9503
- if (ts10.isFunctionDeclaration(node) && node.name) {
9632
+ if (ts11.isFunctionDeclaration(node) && node.name) {
9504
9633
  return /^[A-Z]/.test(node.name.text);
9505
9634
  }
9506
- if (ts10.isVariableDeclaration(node) && ts10.isIdentifier(node.name) && node.initializer && ts10.isArrowFunction(node.initializer)) {
9635
+ if (ts11.isVariableDeclaration(node) && ts11.isIdentifier(node.name) && node.initializer && ts11.isArrowFunction(node.initializer)) {
9507
9636
  return /^[A-Z]/.test(node.name.text);
9508
9637
  }
9509
9638
  return false;
@@ -9532,20 +9661,20 @@ function declinedFactoryErrorCode(code) {
9532
9661
  function validateReactiveFactoryCalls(ctx) {
9533
9662
  if (!ctx.componentNode)
9534
9663
  return;
9535
- const body = ts10.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : ts10.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
9664
+ const body = ts11.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : ts11.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
9536
9665
  if (!body)
9537
9666
  return;
9538
9667
  for (const stmt of body.statements) {
9539
- if (!ts10.isVariableStatement(stmt))
9668
+ if (!ts11.isVariableStatement(stmt))
9540
9669
  continue;
9541
9670
  for (const decl of stmt.declarationList.declarations) {
9542
- if (!decl.initializer || !ts10.isCallExpression(decl.initializer))
9671
+ if (!decl.initializer || !ts11.isCallExpression(decl.initializer))
9543
9672
  continue;
9544
- if (!ts10.isIdentifier(decl.initializer.expression))
9673
+ if (!ts11.isIdentifier(decl.initializer.expression))
9545
9674
  continue;
9546
9675
  const callee = decl.initializer.expression.text;
9547
9676
  const loc = getSourceLocation(stmt, ctx.sourceFile, ctx.filePath);
9548
- if (ts10.isArrayBindingPattern(decl.name)) {
9677
+ if (ts11.isArrayBindingPattern(decl.name)) {
9549
9678
  if (callee === "createSignal" || callee === "createMemo")
9550
9679
  continue;
9551
9680
  if (resolveEnvSignalKey(decl.initializer, ctx))
@@ -9572,7 +9701,7 @@ function validateReactiveFactoryCalls(ctx) {
9572
9701
  }));
9573
9702
  continue;
9574
9703
  }
9575
- if (ts10.isObjectBindingPattern(decl.name)) {
9704
+ if (ts11.isObjectBindingPattern(decl.name)) {
9576
9705
  validateObjectFactoryDestructure(ctx, decl.name, callee, loc);
9577
9706
  }
9578
9707
  }
@@ -9581,25 +9710,25 @@ function validateReactiveFactoryCalls(ctx) {
9581
9710
  function validateNamespaceQualifiedPrimitives(ctx) {
9582
9711
  if (!ctx.componentNode)
9583
9712
  return;
9584
- const body = ts10.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : ts10.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
9713
+ const body = ts11.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : ts11.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
9585
9714
  if (!body)
9586
9715
  return;
9587
9716
  for (const stmt of body.statements) {
9588
9717
  const calls = [];
9589
- if (ts10.isVariableStatement(stmt)) {
9718
+ if (ts11.isVariableStatement(stmt)) {
9590
9719
  for (const decl of stmt.declarationList.declarations) {
9591
9720
  let init = decl.initializer;
9592
- if (init && ts10.isElementAccessExpression(init))
9721
+ if (init && ts11.isElementAccessExpression(init))
9593
9722
  init = init.expression;
9594
- if (init && ts10.isCallExpression(init))
9723
+ if (init && ts11.isCallExpression(init))
9595
9724
  calls.push(init);
9596
9725
  }
9597
- } else if (ts10.isExpressionStatement(stmt) && ts10.isCallExpression(stmt.expression)) {
9726
+ } else if (ts11.isExpressionStatement(stmt) && ts11.isCallExpression(stmt.expression)) {
9598
9727
  calls.push(stmt.expression);
9599
9728
  }
9600
9729
  for (const call of calls) {
9601
9730
  const callee = call.expression;
9602
- if (!ts10.isPropertyAccessExpression(callee) || !ts10.isIdentifier(callee.expression))
9731
+ if (!ts11.isPropertyAccessExpression(callee) || !ts11.isIdentifier(callee.expression))
9603
9732
  continue;
9604
9733
  const primitive = callee.name.text;
9605
9734
  if (!(primitive in PRIMITIVE_CANONICAL_NAMES))
@@ -9632,11 +9761,11 @@ function isNamespaceNameShadowedAtComponentTopLevel(name, body, ctx) {
9632
9761
  if (ctx.propsParams.some((p) => p.name === name))
9633
9762
  return true;
9634
9763
  for (const stmt of body.statements) {
9635
- if (ts10.isFunctionDeclaration(stmt) && stmt.name?.text === name)
9764
+ if (ts11.isFunctionDeclaration(stmt) && stmt.name?.text === name)
9636
9765
  return true;
9637
- if (ts10.isVariableStatement(stmt)) {
9766
+ if (ts11.isVariableStatement(stmt)) {
9638
9767
  for (const decl of stmt.declarationList.declarations) {
9639
- if (ts10.isIdentifier(decl.name) && decl.name.text === name)
9768
+ if (ts11.isIdentifier(decl.name) && decl.name.text === name)
9640
9769
  return true;
9641
9770
  }
9642
9771
  }
@@ -9653,7 +9782,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
9653
9782
  }));
9654
9783
  return;
9655
9784
  }
9656
- const hasUnsupportedElement = pattern.elements.some((el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !ts10.isIdentifier(el.name));
9785
+ const hasUnsupportedElement = pattern.elements.some((el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !ts11.isIdentifier(el.name));
9657
9786
  if (hasUnsupportedElement) {
9658
9787
  ctx.errors.push(createError(ErrorCodes.REACTIVE_FACTORY_RENAME_UNSUPPORTED, loc, {
9659
9788
  severity: "error",
@@ -9661,7 +9790,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
9661
9790
  }));
9662
9791
  return;
9663
9792
  }
9664
- const unknown = pattern.elements.map((el) => ts10.isIdentifier(el.name) ? el.name.text : "").filter((name) => name && !factory.returnTupleIdentifiers.includes(name));
9793
+ const unknown = pattern.elements.map((el) => ts11.isIdentifier(el.name) ? el.name.text : "").filter((name) => name && !factory.returnTupleIdentifiers.includes(name));
9665
9794
  if (unknown.length > 0) {
9666
9795
  const label = unknown.length === 1 ? "property" : "properties";
9667
9796
  ctx.errors.push(createError(ErrorCodes.UNRECOGNIZED_REACTIVE_FACTORY, loc, {
@@ -9816,7 +9945,7 @@ var ESCAPE_SSR_COST = {
9816
9945
  };
9817
9946
 
9818
9947
  // src/module-exports.ts
9819
- import ts11 from "typescript";
9948
+ import ts12 from "typescript";
9820
9949
  function generateModuleExports(ir, extraInlineExported = new Set, rewriteRelativeImport, options) {
9821
9950
  const lines = [];
9822
9951
  for (const constant of options?.skipValueDeclarations ? [] : ir.metadata.localConstants) {
@@ -9917,21 +10046,21 @@ function findAssignedNames(bodyText, candidates) {
9917
10046
  const assigned = new Set;
9918
10047
  if (candidates.size === 0)
9919
10048
  return assigned;
9920
- const sf = ts11.createSourceFile("bf-assignment-scan.tsx", bodyText, ts11.ScriptTarget.Latest, false, ts11.ScriptKind.TSX);
10049
+ const sf = ts12.createSourceFile("bf-assignment-scan.tsx", bodyText, ts12.ScriptTarget.Latest, false, ts12.ScriptKind.TSX);
9921
10050
  const record = (target) => {
9922
- if (ts11.isIdentifier(target) && candidates.has(target.text)) {
10051
+ if (ts12.isIdentifier(target) && candidates.has(target.text)) {
9923
10052
  assigned.add(target.text);
9924
10053
  }
9925
10054
  };
9926
10055
  const visit2 = (node) => {
9927
- if (ts11.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
10056
+ if (ts12.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
9928
10057
  record(node.left);
9929
- } else if ((ts11.isPrefixUnaryExpression(node) || ts11.isPostfixUnaryExpression(node)) && (node.operator === ts11.SyntaxKind.PlusPlusToken || node.operator === ts11.SyntaxKind.MinusMinusToken)) {
10058
+ } else if ((ts12.isPrefixUnaryExpression(node) || ts12.isPostfixUnaryExpression(node)) && (node.operator === ts12.SyntaxKind.PlusPlusToken || node.operator === ts12.SyntaxKind.MinusMinusToken)) {
9930
10059
  record(node.operand);
9931
10060
  }
9932
- ts11.forEachChild(node, visit2);
10061
+ ts12.forEachChild(node, visit2);
9933
10062
  };
9934
- ts11.forEachChild(sf, visit2);
10063
+ ts12.forEachChild(sf, visit2);
9935
10064
  return assigned;
9936
10065
  }
9937
10066
  function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
@@ -9954,7 +10083,7 @@ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNam
9954
10083
  return reachable;
9955
10084
  }
9956
10085
  function isAssignmentOperator(kind) {
9957
- return kind >= ts11.SyntaxKind.FirstAssignment && kind <= ts11.SyntaxKind.LastAssignment;
10086
+ return kind >= ts12.SyntaxKind.FirstAssignment && kind <= ts12.SyntaxKind.LastAssignment;
9958
10087
  }
9959
10088
  function extractFunctionParams(value) {
9960
10089
  const arrowMatch = value.match(/^(?:async\s*)?\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/);
@@ -9992,102 +10121,6 @@ function stripClientBuiltinImports(imports) {
9992
10121
  return result;
9993
10122
  }
9994
10123
 
9995
- // src/reactivity-checker.ts
9996
- import ts12 from "typescript";
9997
- var REACTIVE_BRAND = "__reactive";
9998
- function queryType(checker, node) {
9999
- incrementCounter("typeCheckerQueries");
10000
- return checker.getTypeAtLocation(node);
10001
- }
10002
- function isReactiveType(type) {
10003
- return type.getProperty(REACTIVE_BRAND) !== undefined;
10004
- }
10005
- var NOT_REACTIVE = { isReactive: false, reason: { kind: "not-reactive" } };
10006
- function safeGetText(node) {
10007
- try {
10008
- return node.getText();
10009
- } catch {
10010
- return "";
10011
- }
10012
- }
10013
- function analyze(node, checker) {
10014
- if (ts12.isPropertyAccessExpression(node)) {
10015
- try {
10016
- const type = queryType(checker, node);
10017
- if (isReactiveType(type)) {
10018
- return {
10019
- isReactive: true,
10020
- reason: { kind: "brand", via: "property-access", nodeText: safeGetText(node) }
10021
- };
10022
- }
10023
- } catch {}
10024
- const sub = analyze(node.expression, checker);
10025
- if (sub.isReactive) {
10026
- return {
10027
- isReactive: true,
10028
- reason: {
10029
- kind: "child",
10030
- via: "property-access-object",
10031
- childText: safeGetText(node.expression),
10032
- childReason: sub.reason
10033
- }
10034
- };
10035
- }
10036
- return NOT_REACTIVE;
10037
- }
10038
- if (ts12.isIdentifier(node)) {
10039
- try {
10040
- const type = queryType(checker, node);
10041
- if (isReactiveType(type)) {
10042
- return {
10043
- isReactive: true,
10044
- reason: { kind: "brand", via: "identifier", nodeText: safeGetText(node) }
10045
- };
10046
- }
10047
- } catch {}
10048
- return NOT_REACTIVE;
10049
- }
10050
- if (ts12.isCallExpression(node)) {
10051
- try {
10052
- const calleeType = queryType(checker, node.expression);
10053
- if (isReactiveType(calleeType)) {
10054
- return {
10055
- isReactive: true,
10056
- reason: { kind: "brand", via: "callee", nodeText: safeGetText(node) }
10057
- };
10058
- }
10059
- } catch {}
10060
- }
10061
- let foundChild;
10062
- let foundChildText = "";
10063
- ts12.forEachChild(node, (child) => {
10064
- if (foundChild?.isReactive)
10065
- return;
10066
- const result = analyze(child, checker);
10067
- if (result.isReactive) {
10068
- foundChild = result;
10069
- foundChildText = safeGetText(child);
10070
- }
10071
- });
10072
- if (foundChild?.isReactive) {
10073
- return {
10074
- isReactive: true,
10075
- reason: {
10076
- kind: "child",
10077
- via: "sub-expression",
10078
- childText: foundChildText,
10079
- childReason: foundChild.reason
10080
- }
10081
- };
10082
- }
10083
- return NOT_REACTIVE;
10084
- }
10085
- var brandTypeReactivityAnalyzer = { analyze };
10086
- function containsReactiveExpression(node, checker) {
10087
- incrementCounter("reactivityChecks");
10088
- return brandTypeReactivityAnalyzer.analyze(node, checker).isReactive;
10089
- }
10090
-
10091
10124
  // src/free-refs.ts
10092
10125
  import ts13 from "typescript";
10093
10126
  var _bindingMapCache = new WeakMap;
@@ -11765,7 +11798,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
11765
11798
  }
11766
11799
  const ir = transformJsxExpression(expr, ctx, isClientOnly);
11767
11800
  if (ir !== null) {
11768
- if ((isClientOnly || shouldAutoDeferReactiveBrand(expr, ctx)) && ir.type === "conditional") {
11801
+ if (ir.type === "conditional" && (isClientOnly || shouldAutoDeferReactiveBrand(expr, ctx))) {
11769
11802
  ir.clientOnly = true;
11770
11803
  if (!ir.slotId) {
11771
11804
  ir.slotId = generateSlotId(ctx);
@@ -14712,9 +14745,10 @@ function shouldAutoDeferReactiveBrand(expr, ctx) {
14712
14745
  const checker = ctx.analyzer.checker;
14713
14746
  if (!checker)
14714
14747
  return false;
14715
- if (!containsReactiveExpression(expr, checker))
14748
+ const leaves = collectReactiveBrandLeaves(expr, checker);
14749
+ if (leaves.length === 0)
14716
14750
  return false;
14717
- if (isSignalOrMemoReference(ctx.getJS(expr), ctx))
14751
+ if (leaves.some((leaf) => isSignalOrMemoReference(ctx.getJS(leaf), ctx)))
14718
14752
  return false;
14719
14753
  return true;
14720
14754
  }
@@ -15097,10 +15131,10 @@ function getControlledPropName(signal, propsParams, propsObjectName = null) {
15097
15131
  }
15098
15132
 
15099
15133
  // src/ir-to-client-js/reactivity.ts
15100
- function buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex) {
15134
+ function buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope) {
15101
15135
  if (!loopParam)
15102
15136
  return;
15103
- return BindingScope.EMPTY.enterLoopRow({
15137
+ return (parentScope ?? BindingScope.EMPTY).enterLoopRow({
15104
15138
  param: loopParam,
15105
15139
  paramBindings: loopParamBindings,
15106
15140
  index: loopIndex,
@@ -15174,16 +15208,22 @@ function needsEffectWrapperCore(expr, ctx, freeIdentifiers2, visitedConstants) {
15174
15208
  }
15175
15209
  return false;
15176
15210
  }
15177
- function classifyReactivity(expr, ctx, loopParam, loopParamBindings, freeIdentifiers2) {
15211
+ function classifyReactivity(expr, ctx, scope, freeIdentifiers2) {
15178
15212
  const has = (name) => freeIdentifiers2 ? freeIdentifiers2.has(name) : tokenContainsIdent(expr, name);
15179
- if (loopParamBindings && loopParamBindings.length > 0) {
15180
- for (const b of loopParamBindings) {
15181
- if (has(b.name)) {
15182
- return { kind: "loop-param", param: loopParam ?? b.name };
15213
+ if (scope) {
15214
+ let indexHit;
15215
+ for (const name of scope.valueBoundNames()) {
15216
+ if (!has(name))
15217
+ continue;
15218
+ const source = scope.lookup(name)?.binding.source;
15219
+ if (source === "index") {
15220
+ indexHit ??= name;
15221
+ continue;
15183
15222
  }
15223
+ return { kind: "loop-param", param: name };
15184
15224
  }
15185
- } else if (loopParam && has(loopParam)) {
15186
- return { kind: "loop-param", param: loopParam };
15225
+ if (indexHit)
15226
+ return { kind: "loop-index", param: indexHit };
15187
15227
  }
15188
15228
  if (needsEffectWrapper(expr, ctx, freeIdentifiers2)) {
15189
15229
  return { kind: "signal-or-memo-or-prop" };
@@ -15346,9 +15386,9 @@ function traverseForComponents(node, components, skipConditionals = false) {
15346
15386
  }
15347
15387
  });
15348
15388
  }
15349
- function collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex) {
15389
+ function collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex, parentScope) {
15350
15390
  const texts = [];
15351
- const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
15391
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope);
15352
15392
  walkIR(node, false, {
15353
15393
  ...stopAt("loop", "async", "ifStatement"),
15354
15394
  expression: ({ node: n, scope: insideConditional }) => {
@@ -15358,7 +15398,7 @@ function collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings,
15358
15398
  return;
15359
15399
  const originFreeIds = freeIdsFromRefs(n.origin?.freeRefs);
15360
15400
  const expanded = expandConstantForReactivity(n.expr, ctx, originFreeIds, scope);
15361
- const reactive = classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind !== "none" || decideWrapFromAstFlags(n).wrap;
15401
+ const reactive = classifyReactivity(expanded.expr, ctx, scope, expanded.freeIds).kind !== "none" || decideWrapFromAstFlags(n).wrap;
15362
15402
  if (!reactive)
15363
15403
  return;
15364
15404
  texts.push({
@@ -15381,9 +15421,9 @@ function anyNameIn(names, set) {
15381
15421
  return true;
15382
15422
  return false;
15383
15423
  }
15384
- function collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex) {
15424
+ function collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex, parentScope) {
15385
15425
  const attrs = [];
15386
- const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
15426
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope);
15387
15427
  traverseElements(node, (el) => {
15388
15428
  if (el.slotId) {
15389
15429
  for (const attr of el.attrs) {
@@ -15398,7 +15438,7 @@ function collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings,
15398
15438
  continue;
15399
15439
  const expanded = expandConstantForReactivity(valueStr, ctx, attr.freeIdentifiers, scope);
15400
15440
  const readsPreamble = preambleNames !== undefined && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
15401
- const reactive = classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind !== "none" || readsPreamble || attr.callsReactiveGetters || attr.hasFunctionCalls;
15441
+ const reactive = classifyReactivity(expanded.expr, ctx, scope, expanded.freeIds).kind !== "none" || readsPreamble || attr.callsReactiveGetters || attr.hasFunctionCalls;
15402
15442
  if (!attr.clientOnly && !reactive)
15403
15443
  continue;
15404
15444
  attrs.push({
@@ -15738,7 +15778,9 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
15738
15778
  const flat = options?.flatBranchMode === true;
15739
15779
  const fixedDepth = options?.templateDepth;
15740
15780
  const collectBindings = options?.collectItemBindings === true;
15741
- const initialScope = { parentSlotId: null, depth: 0, insideCond: false };
15781
+ const outerSpec = typeof outerLoopParam === "string" ? { param: outerLoopParam } : outerLoopParam;
15782
+ const outerScope = buildLoopRowScope(outerSpec?.param, outerSpec?.bindings, undefined, outerSpec?.index);
15783
+ const initialScope = { parentSlotId: null, depth: 0, insideCond: false, bindingScope: outerScope };
15742
15784
  for (const root of nodes) {
15743
15785
  walkIR(root, initialScope, {
15744
15786
  element: ({ node: el, scope, descend }) => {
@@ -15754,18 +15796,17 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
15754
15796
  },
15755
15797
  loop: ({ node: n, scope, descend }) => {
15756
15798
  const emitDepth = fixedDepth ?? scope.depth + 1;
15757
- const loopParamsForTemplate = outerLoopParam ? [outerLoopParam, { param: n.param, bindings: n.paramBindings, index: n.index }] : undefined;
15799
+ const loopParamsForTemplate = outerSpec ? [outerSpec, { param: n.param, bindings: n.paramBindings, index: n.index }] : undefined;
15758
15800
  const template = n.children.map((c) => irToPlaceholderTemplate(c, undefined, emitDepth, loopParamsForTemplate)).join("");
15759
- const refsOuter = outerLoopParam ? identifierPattern(outerLoopParam).test(n.array) : false;
15760
15801
  const bindings = emptyLoopChildBindings();
15761
15802
  const innerPreambleNames = preambleNamesOf(n);
15762
15803
  if (ctx) {
15763
15804
  for (const child of n.children) {
15764
- bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx, n.param, n.paramBindings, true, innerPreambleNames, n.index));
15765
- bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx, n.param, n.paramBindings, true, innerPreambleNames, n.index));
15805
+ bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx, n.param, n.paramBindings, true, innerPreambleNames, n.index, scope.bindingScope));
15806
+ bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx, n.param, n.paramBindings, true, innerPreambleNames, n.index, scope.bindingScope));
15766
15807
  bindings.refs.push(...collectLoopChildRefs(child));
15767
15808
  }
15768
- bindings.conditionals.push(...collectLoopChildConditionals({ type: "fragment", children: n.children, loc: n.loc }, ctx, siblingOffsets, n.param, n.paramBindings, innerPreambleNames, n.index));
15809
+ bindings.conditionals.push(...collectLoopChildConditionals({ type: "fragment", children: n.children, loc: n.loc }, ctx, siblingOffsets, n.param, n.paramBindings, innerPreambleNames, n.index, loopParamsForTemplate, scope.bindingScope));
15769
15810
  }
15770
15811
  let childComponents;
15771
15812
  if (collectBindings) {
@@ -15807,14 +15848,17 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
15807
15848
  containerSlotId: scope.parentSlotId,
15808
15849
  template,
15809
15850
  preamble: n.preamble,
15810
- refsOuterParam: refsOuter,
15811
15851
  childComponents,
15812
15852
  insideConditional: !flat && scope.insideCond ? true : undefined,
15813
15853
  offset: flat ? undefined : resolveLoopOffset(siblingOffsets.get(n)),
15814
15854
  bindings
15815
15855
  });
15816
15856
  if (!flat) {
15817
- descend({ ...scope, depth: scope.depth + 1 });
15857
+ descend({
15858
+ ...scope,
15859
+ depth: scope.depth + 1,
15860
+ bindingScope: buildLoopRowScope(n.param, n.paramBindings, innerPreambleNames, n.index, scope.bindingScope)
15861
+ });
15818
15862
  }
15819
15863
  }
15820
15864
  });
@@ -15823,7 +15867,7 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
15823
15867
  }
15824
15868
  function decideLoopRendering(loop, siblingOffsets, ctx) {
15825
15869
  const hasNestedComps = (loop.nestedComponents?.length ?? 0) > 0;
15826
- const innerLoops = collectInnerLoops(loop.children, siblingOffsets, loop.param, ctx);
15870
+ const innerLoops = collectInnerLoops(loop.children, siblingOffsets, { param: loop.param, bindings: loop.paramBindings, index: loop.index }, ctx);
15827
15871
  const hasInnerLoops = (innerLoops?.length ?? 0) > 0;
15828
15872
  const useElementReconciliation = !loop.childComponent && !loop.isStaticArray && (hasNestedComps || hasInnerLoops);
15829
15873
  return { useElementReconciliation, innerLoops };
@@ -15991,6 +16035,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
15991
16035
  }
15992
16036
  const { useElementReconciliation, innerLoops } = projectionInner ? { useElementReconciliation: false, innerLoops: undefined } : decideLoopRendering(l, siblingOffsets, ctx);
15993
16037
  let template = "";
16038
+ let templateIndexed;
15994
16039
  let staticItemTemplate;
15995
16040
  let skeletonTemplate;
15996
16041
  let skeletonPaths;
@@ -16002,6 +16047,10 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
16002
16047
  } else if (l.children[0] && !projectionInner) {
16003
16048
  const loopParamSpec = [{ param: l.param, bindings: l.paramBindings }];
16004
16049
  template = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, loopParamSpec) : irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, loopParamSpec);
16050
+ if (l.index) {
16051
+ const loopParamSpecIndexed = [{ param: l.param, bindings: l.paramBindings, index: l.index }];
16052
+ templateIndexed = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, loopParamSpecIndexed) : irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, loopParamSpecIndexed);
16053
+ }
16005
16054
  if (l.isStaticArray) {
16006
16055
  staticItemTemplate = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], resolveRestSpreadNames(ctx), 0) : irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx), 0);
16007
16056
  } else if (!useElementReconciliation && !l.bodyIsMultiRoot && !l.bodyIsItemConditional) {
@@ -16030,6 +16079,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
16030
16079
  iterationShape: l.iterationShape,
16031
16080
  objectIteration: l.objectIteration,
16032
16081
  template,
16082
+ templateIndexed,
16033
16083
  staticItemTemplate,
16034
16084
  skeletonTemplate,
16035
16085
  skeletonPaths,
@@ -16220,6 +16270,7 @@ function collectBranchLoops(node, ctx, siblingOffsets) {
16220
16270
  const projectionInner = n.method === "flatMap" && n.children.length === 1 && n.children[0].type === "loop" ? n.children[0] : undefined;
16221
16271
  const { useElementReconciliation, innerLoops: innerLoopsCollected } = projectionInner ? { useElementReconciliation: false, innerLoops: undefined } : decideLoopRendering(n, siblingOffsets, undefined);
16222
16272
  let childTemplate;
16273
+ let childTemplateIndexed;
16223
16274
  const branchLoopParamSpec = [{ param: n.param, bindings: n.paramBindings }];
16224
16275
  if (projectionInner) {
16225
16276
  childTemplate = "";
@@ -16228,6 +16279,10 @@ function collectBranchLoops(node, ctx, siblingOffsets) {
16228
16279
  } else {
16229
16280
  childTemplate = n.children.map((c) => irToHtmlTemplate(c, undefined, 0, branchLoopParamSpec)).join("");
16230
16281
  }
16282
+ if (n.index && !projectionInner) {
16283
+ const branchLoopParamSpecIndexed = [{ param: n.param, bindings: n.paramBindings, index: n.index }];
16284
+ childTemplateIndexed = useElementReconciliation && n.children[0] ? irToPlaceholderTemplate(n.children[0], restNames, 0, branchLoopParamSpecIndexed) : n.children.map((c) => irToHtmlTemplate(c, undefined, 0, branchLoopParamSpecIndexed)).join("");
16285
+ }
16231
16286
  const branchBindings = ctx && !projectionInner ? collectLoopChildBindings(n.children, ctx, siblingOffsets, n.param, n.paramBindings, preambleNamesOf(n), n.index) : emptyLoopChildBindings();
16232
16287
  loops.push({
16233
16288
  kind: "branch",
@@ -16243,6 +16298,7 @@ function collectBranchLoops(node, ctx, siblingOffsets) {
16243
16298
  iterationShape: n.iterationShape,
16244
16299
  objectIteration: n.objectIteration,
16245
16300
  template: childTemplate,
16301
+ templateIndexed: childTemplateIndexed,
16246
16302
  containerSlotId: containerSlot,
16247
16303
  preamble: n.preamble,
16248
16304
  preambleRegions: n.preambleRegions,
@@ -16325,19 +16381,10 @@ function collectLoopChildBindings(children, ctx, siblingOffsets, loopParam, loop
16325
16381
  }
16326
16382
  return bindings;
16327
16383
  }
16328
- function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex) {
16384
+ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex, loopParams, parentScope) {
16329
16385
  const conditionals = [];
16330
- const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
16331
- const refsAnyBindingViaFreeIds = (freeIds) => {
16332
- if (loopParamBindings && loopParamBindings.length > 0) {
16333
- for (const b of loopParamBindings) {
16334
- if (freeIds.has(b.name))
16335
- return true;
16336
- }
16337
- return false;
16338
- }
16339
- return loopParam ? freeIds.has(loopParam) : false;
16340
- };
16386
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex, parentScope);
16387
+ const refsAnyBindingViaFreeIds = (freeIds) => scope !== undefined && anyNameIn(scope.valueBoundNames(), freeIds);
16341
16388
  walkIR(node, null, {
16342
16389
  ...stopAt("loop", "async", "ifStatement"),
16343
16390
  conditional: ({ node: n }) => {
@@ -16349,9 +16396,9 @@ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loop
16349
16396
  return;
16350
16397
  const expanded = expandConstantForReactivity(n.condition, ctx, sourceFreeIds, scope);
16351
16398
  const readsPreamble = preambleNames !== undefined && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
16352
- if (!readsPreamble && classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind === "none")
16399
+ if (!readsPreamble && classifyReactivity(expanded.expr, ctx, scope, expanded.freeIds).kind === "none")
16353
16400
  return;
16354
- const loopParamsForCond = loopParam ? [{ param: loopParam, bindings: loopParamBindings, index: loopIndex }] : undefined;
16401
+ const loopParamsForCond = loopParams ?? (loopParam ? [{ param: loopParam, bindings: loopParamBindings, index: loopIndex }] : undefined);
16355
16402
  const whenTrueHtml = irToHtmlTemplate(n.whenTrue, undefined, 0, loopParamsForCond, "__slots");
16356
16403
  const whenFalseHtml = irToHtmlTemplate(n.whenFalse, undefined, 0, loopParamsForCond, "__slots");
16357
16404
  conditionals.push({
@@ -16369,7 +16416,7 @@ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loop
16369
16416
  return conditionals;
16370
16417
  }
16371
16418
  function summarizeLoopChildBranch(node, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex) {
16372
- const inner = collectInnerLoops([node], siblingOffsets, loopParam, ctx, branchInnerLoopOptions);
16419
+ const inner = collectInnerLoops([node], siblingOffsets, loopParam ? { param: loopParam, bindings: loopParamBindings, index: loopIndex } : undefined, ctx, branchInnerLoopOptions);
16373
16420
  return {
16374
16421
  childComponents: collectConditionalBranchChildComponents(node),
16375
16422
  innerLoops: inner.length > 0 ? inner : undefined,
@@ -19518,6 +19565,7 @@ function buildBranchInnerLoopsPlan(args) {
19518
19565
  condSlotId,
19519
19566
  outerLoopParam,
19520
19567
  outerLoopParamBindings,
19568
+ outerLoopIndex,
19521
19569
  wrapOuter
19522
19570
  } = args;
19523
19571
  if (!innerLoops || innerLoops.length === 0)
@@ -19525,7 +19573,7 @@ function buildBranchInnerLoopsPlan(args) {
19525
19573
  const plan = [];
19526
19574
  for (let i = 0;i < innerLoops.length; i++) {
19527
19575
  const inner = innerLoops[i];
19528
- if (!inner.refsOuterParam || !inner.template)
19576
+ if (!inner.template)
19529
19577
  continue;
19530
19578
  const wrapInner = (expr) => wrapLoopParamAsAccessor(expr, inner.param, inner.paramBindings, inner.index);
19531
19579
  const wrapBoth = (expr) => wrapLoopParamAsAccessor(wrapOuter(expr), inner.param, inner.paramBindings, inner.index);
@@ -19588,18 +19636,20 @@ function buildBranchInnerLoopsPlan(args) {
19588
19636
  scopeVar: `__belbr_${i}`,
19589
19637
  wrap: wrapBoth,
19590
19638
  loopParam: inner.param,
19591
- loopParamBindings: inner.paramBindings
19639
+ loopParamBindings: inner.paramBindings,
19640
+ loopIndex: inner.index
19592
19641
  }),
19593
19642
  innerLoopParam: inner.param,
19594
19643
  innerLoopParamBindings: inner.paramBindings,
19595
19644
  outerLoopParam,
19596
- outerLoopParamBindings
19645
+ outerLoopParamBindings,
19646
+ outerLoopIndex
19597
19647
  });
19598
19648
  }
19599
19649
  return plan;
19600
19650
  }
19601
19651
  function buildLoopChildConditionalsPlan(args) {
19602
- const { conditionals, scopeVar, wrap, loopParam, loopParamBindings } = args;
19652
+ const { conditionals, scopeVar, wrap, loopParam, loopParamBindings, loopIndex } = args;
19603
19653
  if (!conditionals || conditionals.length === 0)
19604
19654
  return [];
19605
19655
  const plans = [];
@@ -19608,13 +19658,14 @@ function buildLoopChildConditionalsPlan(args) {
19608
19658
  slotId: cond.slotId,
19609
19659
  scopeVar,
19610
19660
  wrappedCondition: wrap(cond.condition),
19611
- whenTrueTemplateHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
19612
- whenFalseTemplateHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId),
19661
+ whenTrueTemplateHtml: addCondAttrToTemplate(cond.whenTrueHtml, cond.slotId),
19662
+ whenFalseTemplateHtml: addCondAttrToTemplate(cond.whenFalseHtml, cond.slotId),
19613
19663
  whenTrueArm: buildLoopChildArmPlan({
19614
19664
  branch: cond.whenTrue,
19615
19665
  wrap,
19616
19666
  loopParam,
19617
19667
  loopParamBindings,
19668
+ loopIndex,
19618
19669
  condId: cond.slotId
19619
19670
  }),
19620
19671
  whenFalseArm: buildLoopChildArmPlan({
@@ -19622,8 +19673,10 @@ function buildLoopChildConditionalsPlan(args) {
19622
19673
  wrap,
19623
19674
  loopParam,
19624
19675
  loopParamBindings,
19676
+ loopIndex,
19625
19677
  condId: cond.slotId
19626
- })
19678
+ }),
19679
+ ...cond.readsPreamble && { readsPreamble: true }
19627
19680
  });
19628
19681
  }
19629
19682
  return plans;
@@ -19647,7 +19700,8 @@ function buildArmAttrsPlan(attrs, wrap) {
19647
19700
  attrs: slotAttrs.map((attr) => ({
19648
19701
  attrName: attr.attrName,
19649
19702
  wrappedExpression: wrap(attr.expression),
19650
- meta: pickAttrMeta(attr)
19703
+ meta: pickAttrMeta(attr),
19704
+ ...attr.readsPreamble && { readsPreamble: true }
19651
19705
  }))
19652
19706
  });
19653
19707
  }
@@ -19662,7 +19716,7 @@ function buildArmTextsPlan(texts, wrap) {
19662
19716
  }));
19663
19717
  }
19664
19718
  function buildLoopChildArmPlan(args) {
19665
- const { branch, wrap, loopParam, loopParamBindings, condId } = args;
19719
+ const { branch, wrap, loopParam, loopParamBindings, loopIndex, condId } = args;
19666
19720
  return {
19667
19721
  events: buildBranchEventBindingsPlan({
19668
19722
  events: branch.events,
@@ -19678,6 +19732,7 @@ function buildLoopChildArmPlan(args) {
19678
19732
  condSlotId: condId,
19679
19733
  outerLoopParam: loopParam,
19680
19734
  outerLoopParamBindings: loopParamBindings,
19735
+ outerLoopIndex: loopIndex,
19681
19736
  wrapOuter: wrap
19682
19737
  }),
19683
19738
  nestedConditionals: buildLoopChildConditionalsPlan({
@@ -19685,7 +19740,8 @@ function buildLoopChildArmPlan(args) {
19685
19740
  scopeVar: "__branchScope",
19686
19741
  wrap,
19687
19742
  loopParam,
19688
- loopParamBindings
19743
+ loopParamBindings,
19744
+ loopIndex
19689
19745
  }),
19690
19746
  attrs: buildArmAttrsPlan(branch.reactiveAttrs, wrap),
19691
19747
  texts: buildArmTextsPlan(branch.reactiveTexts, wrap)
@@ -19727,10 +19783,10 @@ function buildReactiveEffectsPlan(args) {
19727
19783
  conditionalPlans.push({
19728
19784
  slotId: cond.slotId,
19729
19785
  wrappedCondition: wrap(cond.condition),
19730
- whenTrueTemplateHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
19731
- whenFalseTemplateHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId),
19732
- whenTrueArm: buildOuterArm(cond.whenTrue, wrap, loopParam, loopParamBindings, cond.slotId, profileComponentName),
19733
- whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, cond.slotId, profileComponentName),
19786
+ whenTrueTemplateHtml: addCondAttrToTemplate(cond.whenTrueHtml, cond.slotId),
19787
+ whenFalseTemplateHtml: addCondAttrToTemplate(cond.whenFalseHtml, cond.slotId),
19788
+ whenTrueArm: buildOuterArm(cond.whenTrue, wrap, loopParam, loopParamBindings, loopIndex, cond.slotId, profileComponentName),
19789
+ whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, loopIndex, cond.slotId, profileComponentName),
19734
19790
  ...cond.readsPreamble && { readsPreamble: true }
19735
19791
  });
19736
19792
  }
@@ -19742,7 +19798,7 @@ function buildReactiveEffectsPlan(args) {
19742
19798
  profileComponentName
19743
19799
  };
19744
19800
  }
19745
- function buildOuterArm(branch, wrap, loopParam, loopParamBindings, condSlotId, profileComponentName) {
19801
+ function buildOuterArm(branch, wrap, loopParam, loopParamBindings, loopIndex, condSlotId, profileComponentName) {
19746
19802
  return {
19747
19803
  events: buildBranchEventBindingsPlan({
19748
19804
  events: branch.events,
@@ -19759,6 +19815,7 @@ function buildOuterArm(branch, wrap, loopParam, loopParamBindings, condSlotId, p
19759
19815
  condSlotId,
19760
19816
  outerLoopParam: loopParam,
19761
19817
  outerLoopParamBindings: loopParamBindings,
19818
+ outerLoopIndex: loopIndex,
19762
19819
  wrapOuter: wrap
19763
19820
  }),
19764
19821
  nestedConditionals: buildLoopChildConditionalsPlan({
@@ -19766,7 +19823,8 @@ function buildOuterArm(branch, wrap, loopParam, loopParamBindings, condSlotId, p
19766
19823
  scopeVar: "__branchScope",
19767
19824
  wrap,
19768
19825
  loopParam,
19769
- loopParamBindings
19826
+ loopParamBindings,
19827
+ loopIndex
19770
19828
  }),
19771
19829
  attrs: buildArmAttrsPlan(branch.reactiveAttrs, wrap),
19772
19830
  texts: buildArmTextsPlan(branch.reactiveTexts, wrap)
@@ -19806,8 +19864,8 @@ function wrapAttrValueExpression2(value, wrap) {
19806
19864
  }
19807
19865
  }
19808
19866
  function buildInnerLoopsPlan(args) {
19809
- const { levels, parentElVar, outerLoopParam, outerLoopParamBindings } = args;
19810
- const wrapOuter = outerLoopParam ? (expr) => wrapLoopParamAsAccessor(expr, outerLoopParam, outerLoopParamBindings) : (expr) => expr;
19867
+ const { levels, parentElVar, outerLoopParam, outerLoopParamBindings, outerLoopIndex } = args;
19868
+ const wrapOuter = outerLoopParam ? (expr) => wrapLoopParamAsAccessor(expr, outerLoopParam, outerLoopParamBindings, outerLoopIndex) : (expr) => expr;
19811
19869
  const plan = [];
19812
19870
  let i = 0;
19813
19871
  while (i < levels.length) {
@@ -19829,15 +19887,14 @@ function buildInnerLoopsPlan(args) {
19829
19887
  }
19830
19888
  const uidSuffix = `${inner.depth}_${i}`;
19831
19889
  const containerExpr = inner.containerSlotId ? `qsa(${parentElVar}, '[bf="${inner.containerSlotId}"]')` : parentElVar;
19832
- const refsParent = !!outerLoopParam && (inner.arrayFreeIdentifiers?.has(outerLoopParam) ?? false);
19833
- const useReactive = refsParent && !!inner.template;
19834
- const emit = useReactive ? buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings) : buildStaticEmit(inner, level, uidSuffix);
19835
- const arrayExpr = useReactive ? wrapOuter(inner.array) : inner.array;
19890
+ const emit = buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings, outerLoopIndex);
19891
+ const arrayExpr = wrapOuter(inner.array);
19836
19892
  const childLevelsPlan = childLevels.length > 0 ? buildInnerLoopsPlan({
19837
19893
  levels: childLevels,
19838
19894
  parentElVar: `__innerEl${uidSuffix}`,
19839
19895
  outerLoopParam: inner.param,
19840
- outerLoopParamBindings: inner.paramBindings
19896
+ outerLoopParamBindings: inner.paramBindings,
19897
+ outerLoopIndex: inner.index
19841
19898
  }) : [];
19842
19899
  plan.push({
19843
19900
  uidSuffix,
@@ -19851,13 +19908,14 @@ function buildInnerLoopsPlan(args) {
19851
19908
  emit,
19852
19909
  childLevels: childLevelsPlan,
19853
19910
  outerLoopParam,
19854
- outerLoopParamBindings
19911
+ outerLoopParamBindings,
19912
+ outerLoopIndex
19855
19913
  });
19856
19914
  i = j;
19857
19915
  }
19858
19916
  return plan;
19859
19917
  }
19860
- function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings) {
19918
+ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, outerLoopParamBindings, outerLoopIndex) {
19861
19919
  const wrapInner = (expr) => wrapLoopParamAsAccessor(expr, inner.param, inner.paramBindings, inner.index);
19862
19920
  const wrapBoth = (expr) => wrapLoopParamAsAccessor(wrapOuter(expr), inner.param, inner.paramBindings, inner.index);
19863
19921
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(inner.param, inner.paramBindings);
@@ -19912,7 +19970,7 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
19912
19970
  preludeStatements.push(paramUnwrap);
19913
19971
  if (inner.preamble) {
19914
19972
  const leafLoopParams = outerLoopParam ? [
19915
- { param: outerLoopParam, bindings: outerLoopParamBindings },
19973
+ { param: outerLoopParam, bindings: outerLoopParamBindings, index: outerLoopIndex },
19916
19974
  { param: inner.param, bindings: inner.paramBindings, index: inner.index }
19917
19975
  ] : [{ param: inner.param, bindings: inner.paramBindings, index: inner.index }];
19918
19976
  preludeStatements.push(renderPreamble(inner.preamble, {
@@ -19926,7 +19984,8 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
19926
19984
  scopeVar: `__innerEl${uidSuffix}`,
19927
19985
  wrap: wrapBoth,
19928
19986
  loopParam: inner.param,
19929
- loopParamBindings: inner.paramBindings
19987
+ loopParamBindings: inner.paramBindings,
19988
+ loopIndex: inner.index
19930
19989
  });
19931
19990
  return {
19932
19991
  mode: "reactive",
@@ -19944,25 +20003,6 @@ function buildReactiveEmit(inner, level, wrapOuter, uidSuffix, outerLoopParam, o
19944
20003
  childRefs
19945
20004
  };
19946
20005
  }
19947
- function buildStaticEmit(inner, level, uidSuffix) {
19948
- const preludeStatements = [];
19949
- const indexAlias = nestedLoopIndexAlias(inner, `__innerIdx${uidSuffix}`, inner.param, level.comps, level.events);
19950
- if (indexAlias)
19951
- preludeStatements.push(indexAlias);
19952
- if (inner.preamble) {
19953
- preludeStatements.push(renderPreamble(inner.preamble, {
19954
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, undefined, undefined)
19955
- }));
19956
- }
19957
- return {
19958
- mode: "static",
19959
- rawKey: inner.key ?? null,
19960
- preludeStatements,
19961
- components: level.comps,
19962
- events: level.events,
19963
- childRefs: buildStaticChildRefBindings(inner.bindings.refs)
19964
- };
19965
- }
19966
20006
 
19967
20007
  // src/ir-to-client-js/control-flow/plan/build-composite-loop.ts
19968
20008
  function buildTopLevelCompositePlan(elem, profileComponentName) {
@@ -19993,7 +20033,8 @@ function buildTopLevelCompositePlan(elem, profileComponentName) {
19993
20033
  levels: depthLevels,
19994
20034
  parentElVar: "__el",
19995
20035
  outerLoopParam: elem.param,
19996
- outerLoopParamBindings: elem.paramBindings
20036
+ outerLoopParamBindings: elem.paramBindings,
20037
+ outerLoopIndex: elem.index
19997
20038
  }),
19998
20039
  loopParam: elem.param,
19999
20040
  loopParamBindings: elem.paramBindings,
@@ -20045,7 +20086,8 @@ function buildBranchCompositePlan(loop, cv, profileComponentName) {
20045
20086
  levels: depthLevels,
20046
20087
  parentElVar: "__el",
20047
20088
  outerLoopParam: loop.param,
20048
- outerLoopParamBindings: loop.paramBindings
20089
+ outerLoopParamBindings: loop.paramBindings,
20090
+ outerLoopIndex: loop.index
20049
20091
  }),
20050
20092
  loopParam: loop.param,
20051
20093
  loopParamBindings: loop.paramBindings,
@@ -20558,8 +20600,8 @@ function decideLazyRow(args) {
20558
20600
  let conditionalRefusal = null;
20559
20601
  for (const cond of rawConditionals) {
20560
20602
  const verdict = analyzeLazyConditional(cond, {
20561
- whenTrueHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
20562
- whenFalseHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId)
20603
+ whenTrueHtml: addCondAttrToTemplate(cond.whenTrueHtml, cond.slotId),
20604
+ whenFalseHtml: addCondAttrToTemplate(cond.whenFalseHtml, cond.slotId)
20563
20605
  });
20564
20606
  if (!verdict.lazySafe) {
20565
20607
  conditionalRefusal = verdict.reason;
@@ -20775,7 +20817,7 @@ function buildPlainRowCore(inputs) {
20775
20817
  scope
20776
20818
  }) ?? undefined;
20777
20819
  const mapPreambleWrappedFinal = !lazyRow && loop.index ? wrapIndexParamAsAccessor(mapPreambleWrapped, loop.index) : mapPreambleWrapped;
20778
- const templateFinal = !lazyRow && loop.index ? wrapIndexParamAsAccessor(loop.template, loop.index) : loop.template;
20820
+ const templateFinal = !lazyRow && loop.index ? loop.templateIndexed ?? loop.template : loop.template;
20779
20821
  return {
20780
20822
  indexParam,
20781
20823
  paramHead,
@@ -20964,6 +21006,24 @@ function emitAttrUpdate(target, attrName, expression, meta) {
20964
21006
  `{ const __v = ${expression}; if (__v != null) ${target}.setAttribute('${htmlName}', String(__v)); else ${target}.removeAttribute('${htmlName}') }`
20965
21007
  ];
20966
21008
  }
21009
+ var DEDUP_STORE_DECL = "const __l = []";
21010
+ function dedupGuard(ordinal) {
21011
+ return `!(${ordinal} in __l) || !Object.is(__l[${ordinal}], __x)`;
21012
+ }
21013
+ function emitDedupedAttrUpdate(target, attrName, expression, meta, ordinal, guard = dedupGuard(ordinal)) {
21014
+ const write = emitAttrUpdate(target, attrName, "__x", meta);
21015
+ const lines = [`{ const __x = ${expression}`];
21016
+ if (guard) {
21017
+ lines.push(`if (${guard}) {`);
21018
+ for (const stmt of write)
21019
+ lines.push(` ${stmt}`);
21020
+ lines.push(`}`);
21021
+ } else {
21022
+ lines.push(...write);
21023
+ }
21024
+ lines.push(`__l[${ordinal}] = __x }`);
21025
+ return lines;
21026
+ }
20967
21027
  function rewriteDestructuredPropsInExpr(expr, ctx) {
20968
21028
  if (ctx.propsObjectName)
20969
21029
  return expr;
@@ -21178,16 +21238,18 @@ function emitReactiveAttributeUpdates(lines, ctx) {
21178
21238
  }
21179
21239
  for (const [slotId, attrs] of attrsBySlot) {
21180
21240
  const v = varSlotId(slotId);
21241
+ lines.push(` { ${DEDUP_STORE_DECL}`);
21181
21242
  lines.push(` createEffect(() => {`);
21182
21243
  lines.push(` if (_${v}) {`);
21244
+ let ordinal = 0;
21183
21245
  for (const attr of attrs) {
21184
21246
  const expression = rewriteDestructuredPropsInExpr(lower(attr.expression), ctx);
21185
- for (const stmt of emitAttrUpdate(`_${v}`, attr.attrName, expression, attr)) {
21247
+ for (const stmt of emitDedupedAttrUpdate(`_${v}`, attr.attrName, expression, attr, ordinal++)) {
21186
21248
  lines.push(` ${stmt}`);
21187
21249
  }
21188
21250
  }
21189
21251
  lines.push(` }`);
21190
- lines.push(` }${bindingIdArg(ctx, slotId)})`);
21252
+ lines.push(` }${bindingIdArg(ctx, slotId)}) }`);
21191
21253
  lines.push("");
21192
21254
  }
21193
21255
  }
@@ -21240,6 +21302,7 @@ function emitReactiveChildProps(lines, ctx) {
21240
21302
  if (ctx.reactiveChildProps.length > 0) {
21241
21303
  lines.push("");
21242
21304
  lines.push(` // Reactive child component props`);
21305
+ lines.push(` { ${DEDUP_STORE_DECL}`);
21243
21306
  lines.push(` createEffect(() => {`);
21244
21307
  const propsByComponent = new Map;
21245
21308
  for (const prop of ctx.reactiveChildProps) {
@@ -21249,6 +21312,7 @@ function emitReactiveChildProps(lines, ctx) {
21249
21312
  }
21250
21313
  propsByComponent.get(key).push(prop);
21251
21314
  }
21315
+ let ordinal = 0;
21252
21316
  for (const [, props] of propsByComponent) {
21253
21317
  const first = props[0];
21254
21318
  const isCommentRoot = first.slotId !== null && first.slotId === ctx.commentScopeRootSlotId;
@@ -21260,26 +21324,31 @@ function emitReactiveChildProps(lines, ctx) {
21260
21324
  }
21261
21325
  lines.push(` if (${varName}) {`);
21262
21326
  for (const prop of props) {
21263
- const stmts = toHtmlAttrName(prop.attrName) === "value" ? emitChildValueMirrorStatements(varName, prop.expression) : emitAttrUpdate(varName, prop.attrName, prop.expression, prop);
21327
+ const stmts = toHtmlAttrName(prop.attrName) === "value" ? emitChildValueMirrorStatements(varName, prop.expression) : emitDedupedAttrUpdate(varName, prop.attrName, prop.expression, prop, ordinal++);
21264
21328
  for (const stmt of stmts) {
21265
21329
  lines.push(` ${stmt}`);
21266
21330
  }
21267
21331
  }
21268
21332
  lines.push(` }`);
21269
21333
  }
21270
- lines.push(` }${bindingIdArg(ctx, ctx.reactiveChildProps[0]?.slotId ?? undefined)})`);
21334
+ lines.push(` }${bindingIdArg(ctx, ctx.reactiveChildProps[0]?.slotId ?? undefined)}) }`);
21271
21335
  }
21272
21336
  }
21273
21337
 
21274
21338
  // src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts
21275
- function stringifyBranchReactiveAttrs(lines, plan, indent, pc) {
21339
+ function stringifyBranchReactiveAttrs(lines, plan, indent, pc, mapPreambleWrapped) {
21276
21340
  for (const slot of plan) {
21277
21341
  const varName = `__ra_${varSlotId(slot.slotId)}`;
21278
21342
  lines.push(`${indent}{ const ${varName} = qsa(__branchScope, '[bf="${slot.slotId}"]')`);
21343
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
21279
21344
  lines.push(`${indent}if (${varName}) {`);
21345
+ let ordinal = 0;
21280
21346
  for (const attr of slot.attrs) {
21281
21347
  lines.push(`${indent} __disposers.push(createDisposableEffect(() => {`);
21282
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta)) {
21348
+ if (attr.readsPreamble && mapPreambleWrapped) {
21349
+ lines.push(`${indent} ${mapPreambleWrapped}`);
21350
+ }
21351
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta, ordinal++)) {
21283
21352
  lines.push(`${indent} ${stmt}`);
21284
21353
  }
21285
21354
  lines.push(`${indent} }${profileBindingId(pc, slot.slotId)}))`);
@@ -21322,7 +21391,7 @@ function stringifyBranchInnerLoops(lines, plan, indent, pc) {
21322
21391
  lines.push(`${indent} __bel${uid}.setAttribute('${keyAttrName(inner.keyDepth)}', String(${inner.wrappedKey}))`);
21323
21392
  }
21324
21393
  if (inner.legacyComponents.length > 0 || inner.legacyEvents.length > 0) {
21325
- emitComponentAndEventSetup(lines, `${indent} `, `__bel${uid}`, [...inner.legacyComponents], [...inner.legacyEvents], inner.outerLoopParam, inner.outerLoopParamBindings);
21394
+ emitComponentAndEventSetup(lines, `${indent} `, `__bel${uid}`, [...inner.legacyComponents], [...inner.legacyEvents], inner.outerLoopParam, inner.outerLoopParamBindings, false, inner.outerLoopIndex);
21326
21395
  }
21327
21396
  const conditionalTexts = inner.reactiveTexts.filter((t) => t.insideConditional);
21328
21397
  const plainTexts = inner.reactiveTexts.filter((t) => !t.insideConditional);
@@ -21339,32 +21408,35 @@ function stringifyBranchInnerLoops(lines, plan, indent, pc) {
21339
21408
  }
21340
21409
  }
21341
21410
  if (inner.nestedConditionals.length > 0) {
21342
- stringifyLoopChildConditionals(lines, inner.nestedConditionals, `${indent} `, pc);
21411
+ stringifyLoopChildConditionals(lines, inner.nestedConditionals, `${indent} `, pc, undefined);
21343
21412
  }
21344
21413
  lines.push(`${indent} return __bel${uid}`);
21345
21414
  lines.push(`${indent}}, '${inner.markerId}'${mapArrayKeyArgs(profileBindingId(pc, inner.slotId), !!inner.wrappedKey, inner.keyDepth)}) }`);
21346
21415
  }
21347
21416
  }
21348
- function stringifyLoopChildConditionals(lines, conditionals, indent, pc) {
21417
+ function stringifyLoopChildConditionals(lines, conditionals, indent, pc, mapPreambleWrapped) {
21349
21418
  for (const cond of conditionals) {
21350
- stringifyLoopChildConditional(lines, cond, indent, pc);
21419
+ stringifyLoopChildConditional(lines, cond, indent, pc, mapPreambleWrapped);
21351
21420
  }
21352
21421
  }
21353
- function stringifyLoopChildConditional(lines, cond, indent, pc) {
21422
+ function conditionGetterExpr(wrappedCondition, readsPreamble, mapPreambleWrapped) {
21423
+ return readsPreamble && mapPreambleWrapped ? `() => { ${mapPreambleWrapped}; return (${wrappedCondition}) }` : `() => ${wrappedCondition}`;
21424
+ }
21425
+ function stringifyLoopChildConditional(lines, cond, indent, pc, mapPreambleWrapped) {
21354
21426
  const armIndent = `${indent} `;
21355
- lines.push(`${indent}insert(${cond.scopeVar}, '${cond.slotId}', () => ${cond.wrappedCondition}, {`);
21427
+ lines.push(`${indent}insert(${cond.scopeVar}, '${cond.slotId}', ${conditionGetterExpr(cond.wrappedCondition, cond.readsPreamble, mapPreambleWrapped)}, {`);
21356
21428
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenTrueTemplateHtml}\`, slots: __slots } },`);
21357
21429
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
21358
- stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc);
21430
+ stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc, mapPreambleWrapped);
21359
21431
  lines.push(`${indent} }`);
21360
21432
  lines.push(`${indent}}, {`);
21361
21433
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenFalseTemplateHtml}\`, slots: __slots } },`);
21362
21434
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
21363
- stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc);
21435
+ stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc, mapPreambleWrapped);
21364
21436
  lines.push(`${indent} }`);
21365
21437
  lines.push(`${indent}}${profileBindingId(pc, cond.slotId)})`);
21366
21438
  }
21367
- function stringifyLoopChildArm(lines, arm, armIndent, pc) {
21439
+ function stringifyLoopChildArm(lines, arm, armIndent, pc, mapPreambleWrapped) {
21368
21440
  stringifyBranchEventBindings(lines, arm.events, armIndent);
21369
21441
  stringifyBranchChildComponentInits(lines, arm.childComponents, armIndent);
21370
21442
  stringifyBranchInnerLoops(lines, arm.innerLoops, armIndent, pc);
@@ -21372,10 +21444,10 @@ function stringifyLoopChildArm(lines, arm, armIndent, pc) {
21372
21444
  if (!hasDisposables)
21373
21445
  return;
21374
21446
  lines.push(`${armIndent}const __disposers = []`);
21375
- stringifyBranchReactiveAttrs(lines, arm.attrs, armIndent, pc);
21447
+ stringifyBranchReactiveAttrs(lines, arm.attrs, armIndent, pc, mapPreambleWrapped);
21376
21448
  for (const cond of arm.nestedConditionals) {
21377
21449
  lines.push(`${armIndent}__disposers.push(createDisposableEffect(() => {`);
21378
- stringifyLoopChildConditional(lines, cond, `${armIndent} `, pc);
21450
+ stringifyLoopChildConditional(lines, cond, `${armIndent} `, pc, mapPreambleWrapped);
21379
21451
  lines.push(`${armIndent}}))`);
21380
21452
  }
21381
21453
  if (arm.texts.length > 0) {
@@ -21414,13 +21486,15 @@ function emitAttrSlotsGranular(lines, indent, elVar, lookup, attrSlots, elementI
21414
21486
  const varName = `__ra_${varSlotId(slot.slotId)}`;
21415
21487
  const lookupExpr = attrLookupExpr(slot.slotId, varName, elVar, lookup, elementIndexBySlot);
21416
21488
  lines.push(`${indent}{ const ${varName} = ${lookupExpr}`);
21489
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
21417
21490
  lines.push(`${indent}if (${varName}) {`);
21491
+ let ordinal = 0;
21418
21492
  for (const attr of slot.attrs) {
21419
21493
  lines.push(`${indent} createEffect(() => {`);
21420
21494
  if (attr.readsPreamble && mapPreambleWrapped) {
21421
21495
  lines.push(`${indent} ${mapPreambleWrapped}`);
21422
21496
  }
21423
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta)) {
21497
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta, ordinal++)) {
21424
21498
  lines.push(`${indent} ${stmt}`);
21425
21499
  }
21426
21500
  lines.push(`${indent} }${bindingBfId(slot.slotId)})`);
@@ -21456,6 +21530,8 @@ function emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, oute
21456
21530
  const varName = `__ra_${varSlotId(slot.slotId)}`;
21457
21531
  lines.push(`${indent}const ${varName} = ${attrLookupExpr(slot.slotId, varName, elVar, lookup, elementIndexBySlot)}`);
21458
21532
  }
21533
+ if (attrSlots.length > 0)
21534
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
21459
21535
  const claimSlots = [
21460
21536
  ...outerTexts.map((t) => ({ id: t.slotId, kind: "text", path: [], pathExpr: textClaimPathExprs?.get(t.slotId) })),
21461
21537
  ...preambleRegions.map((r) => ({ id: r.slotId, kind: "markup", path: [] }))
@@ -21473,15 +21549,14 @@ function emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, oute
21473
21549
  if (mapPreambleWrapped && (preambleRegions.length > 0 || attrsReadPreamble(attrSlots))) {
21474
21550
  lines.push(`${indent} ${mapPreambleWrapped}`);
21475
21551
  }
21552
+ let ordinal = 0;
21476
21553
  for (const slot of attrSlots) {
21477
21554
  const varName = `__ra_${varSlotId(slot.slotId)}`;
21478
21555
  lines.push(`${indent} if (${varName}) {`);
21479
21556
  for (const attr of slot.attrs) {
21480
- lines.push(`${indent} {`);
21481
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta)) {
21482
- lines.push(`${indent} ${stmt}`);
21557
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.wrappedExpression, attr.meta, ordinal++)) {
21558
+ lines.push(`${indent} ${stmt}`);
21483
21559
  }
21484
- lines.push(`${indent} }`);
21485
21560
  }
21486
21561
  lines.push(`${indent} }`);
21487
21562
  }
@@ -21510,16 +21585,16 @@ function emitOuterTexts(lines, indent, elVar, texts, bindingBfId, textClaimPathE
21510
21585
  }
21511
21586
  function emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped) {
21512
21587
  const armIndent = `${indent} `;
21513
- const conditionGetter = cond.readsPreamble && mapPreambleWrapped ? `() => { ${mapPreambleWrapped}; return (${cond.wrappedCondition}) }` : `() => ${cond.wrappedCondition}`;
21588
+ const conditionGetter = conditionGetterExpr(cond.wrappedCondition, cond.readsPreamble, mapPreambleWrapped);
21514
21589
  lines.push(`${indent}insert(${elVar}, '${cond.slotId}', ${conditionGetter}, {`);
21515
21590
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenTrueTemplateHtml}\`, slots: __slots } },`);
21516
21591
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
21517
- stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc);
21592
+ stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc, mapPreambleWrapped);
21518
21593
  lines.push(`${indent} }`);
21519
21594
  lines.push(`${indent}}, {`);
21520
21595
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenFalseTemplateHtml}\`, slots: __slots } },`);
21521
21596
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
21522
- stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc);
21597
+ stringifyLoopChildArm(lines, cond.whenFalseArm, armIndent, pc, mapPreambleWrapped);
21523
21598
  lines.push(`${indent} }`);
21524
21599
  lines.push(`${indent}}${profileBindingId(pc, cond.slotId)})`);
21525
21600
  }
@@ -21788,24 +21863,14 @@ function emitConditional(lines, ind, mid, c, mode) {
21788
21863
  lines.push(`${ind} __l[${c.ordinal}] = __x`);
21789
21864
  lines.push(`${ind}} }`);
21790
21865
  }
21791
- function dedupGuard(ordinal) {
21792
- return `!(${ordinal} in __l) || !Object.is(__l[${ordinal}], __x)`;
21793
- }
21794
21866
  function emitAttrBinding(lines, ind, a, mode) {
21795
21867
  const target = mode === "create" ? `__r[${a.refIndex}]` : elementAccess(a);
21868
+ const guard = mode === "create" ? null : mode === "item" ? dedupGuard(a.ordinal) : `__seed ? (${seedDiffersExpr("__t", a)}) : (${dedupGuard(a.ordinal)})`;
21796
21869
  lines.push(`${ind}{ const __t = ${target}`);
21797
21870
  lines.push(`${ind}if (__t) {`);
21798
- lines.push(`${ind} const __x = ${a.wrappedExpression}`);
21799
- const guard = mode === "create" ? null : mode === "item" ? dedupGuard(a.ordinal) : `__seed ? (${seedDiffersExpr("__t", a)}) : (${dedupGuard(a.ordinal)})`;
21800
- const writeIndent = guard ? `${ind} ` : `${ind} `;
21801
- if (guard)
21802
- lines.push(`${ind} if (${guard}) {`);
21803
- for (const stmt of emitAttrUpdate("__t", a.attrName, "__x", a.meta)) {
21804
- lines.push(`${writeIndent}${stmt}`);
21805
- }
21806
- if (guard)
21807
- lines.push(`${ind} }`);
21808
- lines.push(`${ind} __l[${a.ordinal}] = __x`);
21871
+ for (const stmt of emitDedupedAttrUpdate("__t", a.attrName, a.wrappedExpression, a.meta, a.ordinal, guard)) {
21872
+ lines.push(`${ind} ${stmt}`);
21873
+ }
21809
21874
  lines.push(`${ind}} }`);
21810
21875
  }
21811
21876
  function emitTextBinding(lines, ind, t, doorExpr, mode, rwDoor) {
@@ -22095,13 +22160,16 @@ function stringifyStaticLoop(lines, plan) {
22095
22160
  lines.push(` }`);
22096
22161
  }
22097
22162
  lines.push(` if (__iterEl) {`);
22163
+ if (attrsBySlot.length > 0)
22164
+ lines.push(` ${DEDUP_STORE_DECL}`);
22165
+ let ordinal = 0;
22098
22166
  for (const [slotId, attrs] of attrsBySlot) {
22099
22167
  const varName = `__t_${varSlotId(slotId)}`;
22100
22168
  lines.push(` const ${varName} = qsa(__iterEl, '[bf="${slotId}"]')`);
22101
22169
  lines.push(` if (${varName}) {`);
22102
22170
  for (const attr of attrs) {
22103
22171
  lines.push(` createEffect(() => {`);
22104
- for (const stmt of emitAttrUpdate(varName, attr.attrName, attr.expression, attr)) {
22172
+ for (const stmt of emitDedupedAttrUpdate(varName, attr.attrName, attr.expression, attr, ordinal++)) {
22105
22173
  lines.push(` ${stmt}`);
22106
22174
  }
22107
22175
  lines.push(` }${profileBindingId(pc, slotId)})`);
@@ -22126,18 +22194,12 @@ function stringifyStaticLoop(lines, plan) {
22126
22194
  // src/ir-to-client-js/control-flow/stringify/inner-loop.ts
22127
22195
  function stringifyInnerLoops(lines, plan, indent, pc) {
22128
22196
  for (const inner of plan) {
22129
- if (inner.emit.mode === "reactive") {
22130
- emitReactive(lines, inner, indent, pc);
22131
- } else {
22132
- emitStatic(lines, inner, indent, pc);
22133
- }
22197
+ emitReactive(lines, inner, indent, pc);
22134
22198
  }
22135
22199
  }
22136
22200
  function emitReactive(lines, inner, indent, pc) {
22137
22201
  const uid = inner.uidSuffix;
22138
22202
  const emit = inner.emit;
22139
- if (emit.mode !== "reactive")
22140
- return;
22141
22203
  lines.push(`${indent}// Reactive inner loop: ${inner.arraySrc}`);
22142
22204
  lines.push(`${indent}{ const __ic${uid} = ${inner.containerExpr}`);
22143
22205
  lines.push(`${indent}if (__ic${uid}) mapArray(() => ${inner.arrayExpr} || [], __ic${uid}, ${emit.keyFn}, (${emit.paramHead}, __innerIdx${uid}, __existing) => {`);
@@ -22163,7 +22225,7 @@ function emitReactive(lines, inner, indent, pc) {
22163
22225
  lines.push(`${indent} __innerEl${uid}.setAttribute('${keyAttrName(inner.keyDepth)}', String(${emit.wrappedKey}))`);
22164
22226
  }
22165
22227
  if (emit.components.length > 0 || emit.events.length > 0) {
22166
- emitComponentAndEventSetup(lines, `${indent} `, `__innerEl${uid}`, [...emit.components], [...emit.events], inner.outerLoopParam, inner.outerLoopParamBindings);
22228
+ emitComponentAndEventSetup(lines, `${indent} `, `__innerEl${uid}`, [...emit.components], [...emit.events], inner.outerLoopParam, inner.outerLoopParamBindings, false, inner.outerLoopIndex);
22167
22229
  }
22168
22230
  if (inner.childLevels.length > 0) {
22169
22231
  stringifyInnerLoops(lines, inner.childLevels, `${indent} `, pc);
@@ -22182,17 +22244,20 @@ function emitReactive(lines, inner, indent, pc) {
22182
22244
  lines.push(`${indent} createEffect(() => { ${writer}('${text.slotId}', String(${text.wrappedExpression})) }${profileBindingId(pc, text.slotId)})`);
22183
22245
  }
22184
22246
  }
22247
+ if (emit.reactiveAttrs.length > 0)
22248
+ lines.push(`${indent} ${DEDUP_STORE_DECL}`);
22249
+ let attrOrdinal = 0;
22185
22250
  for (const attr of emit.reactiveAttrs) {
22186
22251
  const targetVar = `__ta_${attr.slotId.replace(/[^a-zA-Z0-9]/g, "_")}`;
22187
22252
  lines.push(`${indent} { const ${targetVar} = qsa(__innerEl${uid}, '[bf="${attr.slotId}"]')`);
22188
22253
  lines.push(`${indent} if (${targetVar}) createEffect(() => {`);
22189
- for (const stmt of emitAttrUpdate(targetVar, attr.attrName, attr.wrappedExpression, attr.meta)) {
22254
+ for (const stmt of emitDedupedAttrUpdate(targetVar, attr.attrName, attr.wrappedExpression, attr.meta, attrOrdinal++)) {
22190
22255
  lines.push(`${indent} ${stmt}`);
22191
22256
  }
22192
22257
  lines.push(`${indent} }${profileBindingId(pc, attr.slotId)}) }`);
22193
22258
  }
22194
22259
  if (emit.conditionals.length > 0) {
22195
- stringifyLoopChildConditionals(lines, emit.conditionals, `${indent} `, pc);
22260
+ stringifyLoopChildConditionals(lines, emit.conditionals, `${indent} `, pc, undefined);
22196
22261
  }
22197
22262
  emitLoopChildRefs(lines, emit.childRefs, {
22198
22263
  indent: `${indent} `,
@@ -22202,33 +22267,6 @@ function emitReactive(lines, inner, indent, pc) {
22202
22267
  lines.push(`${indent} return __innerEl${uid}`);
22203
22268
  lines.push(`${indent}}, '${inner.markerId}'${mapArrayKeyArgs(profileBindingId(pc, inner.slotId), !!emit.wrappedKey, inner.keyDepth)}) }`);
22204
22269
  }
22205
- function emitStatic(lines, inner, indent, pc) {
22206
- const uid = inner.uidSuffix;
22207
- const emit = inner.emit;
22208
- if (emit.mode !== "static")
22209
- return;
22210
- lines.push(`${indent}// Initialize ${inner.arraySrc} loop components and events`);
22211
- lines.push(`${indent}{ const __ic${uid} = ${inner.containerExpr}`);
22212
- lines.push(`${indent}if (__ic${uid} && ${inner.arrayExpr}) ${inner.arrayExpr}.forEach((${inner.param}, __innerIdx${uid}) => {`);
22213
- lines.push(`${indent} const __innerEl${uid} = __ic${uid}.children[__innerIdx${uid}]`);
22214
- lines.push(`${indent} if (!__innerEl${uid}) return`);
22215
- for (const stmt of emit.preludeStatements) {
22216
- lines.push(`${indent} ${stmt}`);
22217
- }
22218
- if (emit.rawKey) {
22219
- lines.push(`${indent} __innerEl${uid}.setAttribute('${keyAttrName(inner.keyDepth)}', String(${emit.rawKey}))`);
22220
- }
22221
- emitComponentAndEventSetup(lines, `${indent} `, `__innerEl${uid}`, [...emit.components], [...emit.events], inner.outerLoopParam, inner.outerLoopParamBindings);
22222
- if (inner.childLevels.length > 0) {
22223
- stringifyInnerLoops(lines, inner.childLevels, `${indent} `, pc);
22224
- }
22225
- emitLoopChildRefs(lines, emit.childRefs, {
22226
- indent: `${indent} `,
22227
- elVar: `__innerEl${uid}`,
22228
- bodyIsMultiRoot: false
22229
- });
22230
- lines.push(`${indent}}) }`);
22231
- }
22232
22270
 
22233
22271
  // src/ir-to-client-js/control-flow/stringify/composite-loop.ts
22234
22272
  function stringifyCompositeLoop(lines, plan) {
@@ -22657,10 +22695,12 @@ function emitArmBody(lines, body, mode, indent, profileComponentName) {
22657
22695
  const v = varSlotId(slotId);
22658
22696
  const elVar = `__ra_${v}`;
22659
22697
  lines.push(`${indent}{ const ${elVar} = qsa(__branchScope, '[bf="${slotId}"]')`);
22698
+ lines.push(`${indent}${DEDUP_STORE_DECL}`);
22660
22699
  lines.push(`${indent}if (${elVar}) {`);
22700
+ let ordinal = 0;
22661
22701
  for (const attr of attrs) {
22662
22702
  lines.push(`${indent} __disposers.push(createDisposableEffect(() => {`);
22663
- for (const stmt of emitAttrUpdate(elVar, attr.attrName, attr.expression, attr)) {
22703
+ for (const stmt of emitDedupedAttrUpdate(elVar, attr.attrName, attr.expression, attr, ordinal++)) {
22664
22704
  lines.push(`${indent} ${stmt}`);
22665
22705
  }
22666
22706
  lines.push(`${indent} }${bindingBfId(slotId)}))`);