@barefootjs/jsx 0.31.3 → 0.31.5

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 (86) hide show
  1. package/dist/adapters/jsx-adapter.d.ts.map +1 -1
  2. package/dist/adapters/loop-bound-names.d.ts +18 -0
  3. package/dist/adapters/loop-bound-names.d.ts.map +1 -1
  4. package/dist/adapters/template-imports.d.ts +27 -15
  5. package/dist/adapters/template-imports.d.ts.map +1 -1
  6. package/dist/adapters/test-adapter.d.ts.map +1 -1
  7. package/dist/augment-inherited-props.d.ts +12 -2
  8. package/dist/augment-inherited-props.d.ts.map +1 -1
  9. package/dist/compiler.d.ts.map +1 -1
  10. package/dist/debug.d.ts.map +1 -1
  11. package/dist/free-refs.d.ts +11 -2
  12. package/dist/free-refs.d.ts.map +1 -1
  13. package/dist/identifier-pattern.d.ts +62 -0
  14. package/dist/identifier-pattern.d.ts.map +1 -0
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +968 -789
  18. package/dist/ir-to-client-js/collect-elements.d.ts +23 -2
  19. package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
  20. package/dist/ir-to-client-js/control-flow/plan/build-event-delegation.d.ts.map +1 -1
  21. package/dist/ir-to-client-js/control-flow/plan/build-reactive-effects.d.ts.map +1 -1
  22. package/dist/ir-to-client-js/control-flow/plan/reactive-effects.d.ts +7 -0
  23. package/dist/ir-to-client-js/control-flow/plan/reactive-effects.d.ts.map +1 -1
  24. package/dist/ir-to-client-js/control-flow/stringify/event-delegation.d.ts.map +1 -1
  25. package/dist/ir-to-client-js/csr-substitute.d.ts +12 -1
  26. package/dist/ir-to-client-js/csr-substitute.d.ts.map +1 -1
  27. package/dist/ir-to-client-js/html-template.d.ts +20 -12
  28. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  29. package/dist/ir-to-client-js/imports.d.ts.map +1 -1
  30. package/dist/ir-to-client-js/prop-handling.d.ts +25 -2
  31. package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
  32. package/dist/ir-to-client-js/reactivity.d.ts +46 -2
  33. package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
  34. package/dist/ir-to-client-js/rewrite-props-object.d.ts.map +1 -1
  35. package/dist/ir-to-client-js/types.d.ts +16 -0
  36. package/dist/ir-to-client-js/types.d.ts.map +1 -1
  37. package/dist/ir-to-client-js/utils.d.ts +15 -0
  38. package/dist/ir-to-client-js/utils.d.ts.map +1 -1
  39. package/dist/jsx-to-ir.d.ts.map +1 -1
  40. package/dist/module-exports.d.ts +64 -0
  41. package/dist/module-exports.d.ts.map +1 -1
  42. package/dist/relocate.d.ts.map +1 -1
  43. package/dist/scope/binding-scope.d.ts +1 -1
  44. package/dist/types.d.ts +41 -0
  45. package/dist/types.d.ts.map +1 -1
  46. package/package.json +2 -2
  47. package/src/__tests__/binding-scope-ratchet.test.ts +146 -21
  48. package/src/__tests__/component-type-parameters.test.ts +70 -0
  49. package/src/__tests__/csr-materialize-loop-preamble-shadow.test.ts +85 -0
  50. package/src/__tests__/csr-substitute-enclosing-scope.test.ts +77 -0
  51. package/src/__tests__/free-refs.test.ts +1 -1
  52. package/src/__tests__/identifier-pattern.test.ts +170 -0
  53. package/src/__tests__/loop-child-reactive-attr-const-shadow.test.ts +107 -0
  54. package/src/__tests__/mutable-binding-writers.test.ts +133 -0
  55. package/src/__tests__/preamble-conditional-reactivity.test.ts +191 -0
  56. package/src/__tests__/rewrite-dynamic-imports.test.ts +98 -0
  57. package/src/__tests__/signal-setter-updater-type.test.ts +81 -0
  58. package/src/adapters/jsx-adapter.ts +31 -4
  59. package/src/adapters/loop-bound-names.ts +18 -0
  60. package/src/adapters/template-imports.ts +93 -0
  61. package/src/adapters/test-adapter.ts +4 -1
  62. package/src/augment-inherited-props.ts +13 -1
  63. package/src/compiler.ts +18 -0
  64. package/src/debug.ts +38 -24
  65. package/src/free-refs.ts +14 -5
  66. package/src/identifier-pattern.ts +79 -0
  67. package/src/index.ts +1 -1
  68. package/src/ir-to-client-js/collect-elements.ts +60 -16
  69. package/src/ir-to-client-js/control-flow/plan/build-event-delegation.ts +2 -1
  70. package/src/ir-to-client-js/control-flow/plan/build-reactive-effects.ts +1 -0
  71. package/src/ir-to-client-js/control-flow/plan/reactive-effects.ts +7 -0
  72. package/src/ir-to-client-js/control-flow/stringify/event-delegation.ts +2 -1
  73. package/src/ir-to-client-js/control-flow/stringify/reactive-effects.ts +12 -2
  74. package/src/ir-to-client-js/csr-substitute.ts +19 -2
  75. package/src/ir-to-client-js/html-template.ts +42 -31
  76. package/src/ir-to-client-js/imports.ts +2 -1
  77. package/src/ir-to-client-js/prop-handling.ts +28 -1
  78. package/src/ir-to-client-js/reactivity.ts +58 -6
  79. package/src/ir-to-client-js/rewrite-props-object.ts +2 -1
  80. package/src/ir-to-client-js/types.ts +16 -0
  81. package/src/ir-to-client-js/utils.ts +24 -8
  82. package/src/jsx-to-ir.ts +135 -10
  83. package/src/module-exports.ts +140 -2
  84. package/src/relocate.ts +2 -1
  85. package/src/scope/binding-scope.ts +1 -1
  86. package/src/types.ts +41 -0
package/dist/index.js CHANGED
@@ -177,7 +177,7 @@ function findTopLevelTemplateLiterals(code) {
177
177
  }
178
178
 
179
179
  // src/compiler.ts
180
- import ts23 from "typescript";
180
+ import ts24 from "typescript";
181
181
 
182
182
  // src/analyzer.ts
183
183
  import ts9 from "typescript";
@@ -2332,6 +2332,24 @@ function templatePartsToJsExpr(parts, opts) {
2332
2332
  return result;
2333
2333
  }
2334
2334
 
2335
+ // src/identifier-pattern.ts
2336
+ function withUnicodeFlag(flags) {
2337
+ return flags.includes("u") ? flags : `${flags}u`;
2338
+ }
2339
+ function escapeIdentifierForRegex(name) {
2340
+ return name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2341
+ }
2342
+ var ID_BOUNDARY_BEFORE = "(?<![\\p{ID_Continue}$])";
2343
+ var ID_BOUNDARY_AFTER = "(?![\\p{ID_Continue}$])";
2344
+ function identifierPattern(name, flags = "") {
2345
+ const esc = escapeIdentifierForRegex(name);
2346
+ return new RegExp(`${ID_BOUNDARY_BEFORE}${esc}${ID_BOUNDARY_AFTER}`, withUnicodeFlag(flags));
2347
+ }
2348
+ function identifierCallPattern(name, flags = "") {
2349
+ const esc = escapeIdentifierForRegex(name);
2350
+ return new RegExp(`${ID_BOUNDARY_BEFORE}${esc}\\s*\\(`, withUnicodeFlag(flags));
2351
+ }
2352
+
2335
2353
  // src/ir-to-client-js/utils.ts
2336
2354
  import {
2337
2355
  BF_KEY as DATA_KEY,
@@ -2458,9 +2476,6 @@ function inferDefaultValue(type) {
2458
2476
  return "{}";
2459
2477
  return "undefined";
2460
2478
  }
2461
- function escapeRegExp(s) {
2462
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2463
- }
2464
2479
  function freeIdsFromRefs(refs) {
2465
2480
  const out = new Set;
2466
2481
  if (!refs)
@@ -2588,16 +2603,16 @@ function wrapLoopParamAsAccessor(expr, paramName, bindings) {
2588
2603
  if (bindings && bindings.length > 0) {
2589
2604
  return rewriteLoopBindingRefs(expr, bindings, "__bfItem()");
2590
2605
  }
2591
- const re = new RegExp(`\\b${escapeRegExp(paramName)}\\b(?!\\s*\\()(?!-)`, "g");
2592
- return replaceInExprContexts(expr, re, `${paramName}()`);
2606
+ const re = new RegExp(`${ID_BOUNDARY_BEFORE}${escapeIdentifierForRegex(paramName)}(?!\\s*\\()(?!-)${ID_BOUNDARY_AFTER}`, "gu");
2607
+ return replaceInExprContexts(expr, re, () => `${paramName}()`);
2593
2608
  }
2594
2609
  function rewriteLoopBindingRefs(expr, bindings, accessor) {
2595
2610
  const byName = new Map;
2596
2611
  for (const b of bindings)
2597
2612
  byName.set(b.name, b);
2598
2613
  const preprocessed = expandShorthandBindings(expr, new Set(byName.keys()));
2599
- const alt = bindings.map((b) => escapeRegExp(b.name)).join("|");
2600
- const re = new RegExp(`\\b(${alt})\\b`, "g");
2614
+ const alt = bindings.map((b) => escapeIdentifierForRegex(b.name)).join("|");
2615
+ const re = new RegExp(`${ID_BOUNDARY_BEFORE}(${alt})${ID_BOUNDARY_AFTER}`, "gu");
2601
2616
  return replaceInExprContexts(preprocessed, re, (_m, name) => renderLoopBindingAccess(byName.get(name), accessor));
2602
2617
  }
2603
2618
  function expandShorthandBindings(expr, bindingNames) {
@@ -2868,7 +2883,7 @@ function stopAt(...kinds) {
2868
2883
 
2869
2884
  // src/ir-to-client-js/csr-substitute.ts
2870
2885
  import ts4 from "typescript";
2871
- function csrSubstitute(value, env) {
2886
+ function csrSubstitute(value, env, enclosingScope) {
2872
2887
  if (!value || value.trim().length === 0) {
2873
2888
  return { rewritten: value, freeIdentifiers: new Set };
2874
2889
  }
@@ -2876,7 +2891,7 @@ function csrSubstitute(value, env) {
2876
2891
  let current = value;
2877
2892
  let lastFreeIdentifiers = new Set;
2878
2893
  for (let i = 0;i < maxIter; i++) {
2879
- const step = csrSubstituteOnce(current, env);
2894
+ const step = csrSubstituteOnce(current, env, enclosingScope);
2880
2895
  lastFreeIdentifiers = step.freeIdentifiers;
2881
2896
  if (step.rewritten === current)
2882
2897
  break;
@@ -2884,7 +2899,7 @@ function csrSubstitute(value, env) {
2884
2899
  }
2885
2900
  return { rewritten: current, freeIdentifiers: lastFreeIdentifiers };
2886
2901
  }
2887
- function csrSubstituteOnce(value, env) {
2902
+ function csrSubstituteOnce(value, env, enclosingScope) {
2888
2903
  if (!value || value.trim().length === 0) {
2889
2904
  return { rewritten: value, freeIdentifiers: new Set };
2890
2905
  }
@@ -2902,7 +2917,7 @@ function csrSubstituteOnce(value, env) {
2902
2917
  if (boundStack[i].has(name))
2903
2918
  return true;
2904
2919
  }
2905
- return false;
2920
+ return enclosingScope?.isBound(name) ?? false;
2906
2921
  };
2907
2922
  const recordSubstitution = (start, end, sub) => {
2908
2923
  splices.push({ start: start - OFFSET, end: end - OFFSET, text: `(${sub.replacement})` });
@@ -3090,6 +3105,83 @@ function derivesScopeFromSlot(comp) {
3090
3105
  return comp.slotId != null && comp.loopItemRoot !== true;
3091
3106
  }
3092
3107
 
3108
+ // src/scope/binding-scope.ts
3109
+ class BindingScope {
3110
+ frames;
3111
+ static EMPTY = new BindingScope([]);
3112
+ constructor(frames) {
3113
+ this.frames = frames;
3114
+ }
3115
+ enterLoopRow(loop) {
3116
+ const bindings = new Map;
3117
+ if (loop.paramBindings && loop.paramBindings.length > 0) {
3118
+ for (const b of loop.paramBindings)
3119
+ bindings.set(b.name, { source: "destructure" });
3120
+ } else {
3121
+ bindings.set(loop.param, { source: "item" });
3122
+ }
3123
+ if (loop.index != null)
3124
+ bindings.set(loop.index, { source: "index" });
3125
+ for (const name of loop.preamble?.declaredNames ?? [])
3126
+ bindings.set(name, { source: "preamble" });
3127
+ const frame = { kind: "loop-row", bindings };
3128
+ return new BindingScope([frame, ...this.frames]);
3129
+ }
3130
+ enterCallback(params) {
3131
+ const bindings = new Map;
3132
+ for (const name of params)
3133
+ bindings.set(name, { source: "param" });
3134
+ const frame = { kind: "callback", bindings };
3135
+ return new BindingScope([frame, ...this.frames]);
3136
+ }
3137
+ isBound(name) {
3138
+ for (const frame of this.frames) {
3139
+ if (frame.bindings.has(name))
3140
+ return true;
3141
+ }
3142
+ return false;
3143
+ }
3144
+ lookup(name) {
3145
+ for (let depth = 0;depth < this.frames.length; depth++) {
3146
+ const frame = this.frames[depth];
3147
+ const binding = frame.bindings.get(name);
3148
+ if (binding)
3149
+ return { depth, frame, binding };
3150
+ }
3151
+ return null;
3152
+ }
3153
+ boundNames() {
3154
+ if (this.boundNamesCache)
3155
+ return this.boundNamesCache;
3156
+ const names = new Set;
3157
+ for (const frame of this.frames) {
3158
+ for (const name of frame.bindings.keys())
3159
+ names.add(name);
3160
+ }
3161
+ this.boundNamesCache = names;
3162
+ return names;
3163
+ }
3164
+ boundNamesCache;
3165
+ valueBoundNamesCache;
3166
+ valueBoundNames() {
3167
+ if (this.valueBoundNamesCache)
3168
+ return this.valueBoundNamesCache;
3169
+ const names = new Set;
3170
+ for (const frame of this.frames) {
3171
+ for (const [name, binding] of frame.bindings) {
3172
+ if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
3173
+ names.add(name);
3174
+ }
3175
+ }
3176
+ }
3177
+ this.valueBoundNamesCache = names;
3178
+ return names;
3179
+ }
3180
+ asShadowPredicate() {
3181
+ return (name) => this.isBound(name);
3182
+ }
3183
+ }
3184
+
3093
3185
  // src/ir-to-client-js/html-template.ts
3094
3186
  function createStringProtector() {
3095
3187
  const strings = [];
@@ -4315,7 +4407,7 @@ function generateCsrTemplateWithOpts(node, opts) {
4315
4407
  const source = templateExpr ?? expr;
4316
4408
  if (!source)
4317
4409
  return source;
4318
- const { rewritten, freeIdentifiers: freeIdentifiers2 } = csrSubstitute(source, env);
4410
+ const { rewritten, freeIdentifiers: freeIdentifiers2 } = csrSubstitute(source, env, opts.scope);
4319
4411
  if (unsafeLocalNames && unsafeLocalNames.size > 0 && setIntersects(freeIdentifiers2, unsafeLocalNames)) {
4320
4412
  return UNSAFE_TEMPLATE_EXPR;
4321
4413
  }
@@ -4457,15 +4549,8 @@ function generateCsrTemplateWithOpts(node, opts) {
4457
4549
  return `\${renderChild('${nameForRegistryRef(node.name)}', ${propsExpr}${keyArg || (slotArg ? ", undefined" : "")}${slotArg})}`;
4458
4550
  }
4459
4551
  case "loop": {
4460
- const boundHere = new Set(opts.loopBoundNames ?? []);
4461
- if (node.paramBindings && node.paramBindings.length > 0) {
4462
- for (const b of node.paramBindings)
4463
- boundHere.add(b.name);
4464
- } else if (!node.param.startsWith("[") && !node.param.startsWith("{")) {
4465
- boundHere.add(node.param);
4466
- }
4467
- if (node.index)
4468
- boundHere.add(node.index);
4552
+ const childScope = (opts.scope ?? BindingScope.EMPTY).enterLoopRow(node);
4553
+ const boundHere = childScope.boundNames();
4469
4554
  const childEnv = {
4470
4555
  ...env,
4471
4556
  substitutions: new Map([...env.substitutions].filter(([name]) => !boundHere.has(name)))
@@ -4474,7 +4559,7 @@ function generateCsrTemplateWithOpts(node, opts) {
4474
4559
  ...opts,
4475
4560
  loopDepth: loopDepth + 1,
4476
4561
  inHoistedChildren: false,
4477
- loopBoundNames: boundHere,
4562
+ scope: childScope,
4478
4563
  csrEnv: childEnv
4479
4564
  });
4480
4565
  let childTemplate = node.children.map(recurseInLoopBody).join("");
@@ -9145,7 +9230,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
9145
9230
  }
9146
9231
 
9147
9232
  // src/jsx-to-ir.ts
9148
- import ts12 from "typescript";
9233
+ import ts13 from "typescript";
9149
9234
 
9150
9235
  // src/types.ts
9151
9236
  var SCOPE_FORBIDDEN = {
@@ -9251,6 +9336,7 @@ function pickAttrMetaFromIR(src) {
9251
9336
  }
9252
9337
 
9253
9338
  // src/module-exports.ts
9339
+ import ts10 from "typescript";
9254
9340
  function generateModuleExports(ir, extraInlineExported = new Set, rewriteRelativeImport, options) {
9255
9341
  const lines = [];
9256
9342
  for (const constant of options?.skipValueDeclarations ? [] : ir.metadata.localConstants) {
@@ -9330,7 +9416,7 @@ function findReachableNames(primaryRefs, declarations) {
9330
9416
  const reachable = new Set;
9331
9417
  const queue = [];
9332
9418
  for (const name of allNames) {
9333
- if (new RegExp(`\\b${name}\\b`).test(primaryRefs)) {
9419
+ if (identifierPattern(name).test(primaryRefs)) {
9334
9420
  reachable.add(name);
9335
9421
  queue.push(name);
9336
9422
  }
@@ -9339,7 +9425,7 @@ function findReachableNames(primaryRefs, declarations) {
9339
9425
  const current = queue.shift();
9340
9426
  const body = bodyMap.get(current) || "";
9341
9427
  for (const name of allNames) {
9342
- if (!reachable.has(name) && new RegExp(`\\b${name}\\b`).test(body)) {
9428
+ if (!reachable.has(name) && identifierPattern(name).test(body)) {
9343
9429
  reachable.add(name);
9344
9430
  queue.push(name);
9345
9431
  }
@@ -9347,6 +9433,49 @@ function findReachableNames(primaryRefs, declarations) {
9347
9433
  }
9348
9434
  return reachable;
9349
9435
  }
9436
+ function findAssignedNames(bodyText, candidates) {
9437
+ const assigned = new Set;
9438
+ if (candidates.size === 0)
9439
+ return assigned;
9440
+ const sf = ts10.createSourceFile("bf-assignment-scan.tsx", bodyText, ts10.ScriptTarget.Latest, false, ts10.ScriptKind.TSX);
9441
+ const record = (target) => {
9442
+ if (ts10.isIdentifier(target) && candidates.has(target.text)) {
9443
+ assigned.add(target.text);
9444
+ }
9445
+ };
9446
+ const visit2 = (node) => {
9447
+ if (ts10.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
9448
+ record(node.left);
9449
+ } else if ((ts10.isPrefixUnaryExpression(node) || ts10.isPostfixUnaryExpression(node)) && (node.operator === ts10.SyntaxKind.PlusPlusToken || node.operator === ts10.SyntaxKind.MinusMinusToken)) {
9450
+ record(node.operand);
9451
+ }
9452
+ ts10.forEachChild(node, visit2);
9453
+ };
9454
+ ts10.forEachChild(sf, visit2);
9455
+ return assigned;
9456
+ }
9457
+ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
9458
+ let reachable = findReachableNames(primaryRefs, declarations);
9459
+ if (mutableNames.size === 0)
9460
+ return reachable;
9461
+ let seedText = primaryRefs;
9462
+ for (let round = 0;round <= declarations.length; round++) {
9463
+ const survivingMutables = new Set([...reachable].filter((name) => mutableNames.has(name)));
9464
+ if (survivingMutables.size === 0)
9465
+ return reachable;
9466
+ const added = declarations.filter((d) => !reachable.has(d.name)).filter((d) => findAssignedNames(d.body, survivingMutables).size > 0).map((d) => d.name);
9467
+ if (added.length === 0)
9468
+ return reachable;
9469
+ seedText += `
9470
+ ` + added.join(`
9471
+ `);
9472
+ reachable = findReachableNames(seedText, declarations);
9473
+ }
9474
+ return reachable;
9475
+ }
9476
+ function isAssignmentOperator(kind) {
9477
+ return kind >= ts10.SyntaxKind.FirstAssignment && kind <= ts10.SyntaxKind.LastAssignment;
9478
+ }
9350
9479
  function extractFunctionParams(value) {
9351
9480
  const arrowMatch = value.match(/^(?:async\s*)?\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/);
9352
9481
  if (arrowMatch) {
@@ -9384,7 +9513,7 @@ function stripClientBuiltinImports(imports) {
9384
9513
  }
9385
9514
 
9386
9515
  // src/reactivity-checker.ts
9387
- import ts10 from "typescript";
9516
+ import ts11 from "typescript";
9388
9517
  var REACTIVE_BRAND = "__reactive";
9389
9518
  function queryType(checker, node) {
9390
9519
  incrementCounter("typeCheckerQueries");
@@ -9402,7 +9531,7 @@ function safeGetText(node) {
9402
9531
  }
9403
9532
  }
9404
9533
  function analyze(node, checker) {
9405
- if (ts10.isPropertyAccessExpression(node)) {
9534
+ if (ts11.isPropertyAccessExpression(node)) {
9406
9535
  try {
9407
9536
  const type = queryType(checker, node);
9408
9537
  if (isReactiveType(type)) {
@@ -9426,7 +9555,7 @@ function analyze(node, checker) {
9426
9555
  }
9427
9556
  return NOT_REACTIVE;
9428
9557
  }
9429
- if (ts10.isIdentifier(node)) {
9558
+ if (ts11.isIdentifier(node)) {
9430
9559
  try {
9431
9560
  const type = queryType(checker, node);
9432
9561
  if (isReactiveType(type)) {
@@ -9438,7 +9567,7 @@ function analyze(node, checker) {
9438
9567
  } catch {}
9439
9568
  return NOT_REACTIVE;
9440
9569
  }
9441
- if (ts10.isCallExpression(node)) {
9570
+ if (ts11.isCallExpression(node)) {
9442
9571
  try {
9443
9572
  const calleeType = queryType(checker, node.expression);
9444
9573
  if (isReactiveType(calleeType)) {
@@ -9451,7 +9580,7 @@ function analyze(node, checker) {
9451
9580
  }
9452
9581
  let foundChild;
9453
9582
  let foundChildText = "";
9454
- ts10.forEachChild(node, (child) => {
9583
+ ts11.forEachChild(node, (child) => {
9455
9584
  if (foundChild?.isReactive)
9456
9585
  return;
9457
9586
  const result = analyze(child, checker);
@@ -9480,7 +9609,7 @@ function containsReactiveExpression(node, checker) {
9480
9609
  }
9481
9610
 
9482
9611
  // src/free-refs.ts
9483
- import ts11 from "typescript";
9612
+ import ts12 from "typescript";
9484
9613
  var _bindingMapCache = new WeakMap;
9485
9614
  function buildBindingMap(env) {
9486
9615
  const cached = _bindingMapCache.get(env);
@@ -9518,8 +9647,8 @@ function buildBindingMap(env) {
9518
9647
  for (const m of env.memos) {
9519
9648
  map.set(m.name, "memo-getter");
9520
9649
  }
9521
- if (env.loopParams) {
9522
- for (const name of env.loopParams)
9650
+ if (env.loopValueBoundNames) {
9651
+ for (const name of env.loopValueBoundNames)
9523
9652
  map.set(name, "render-item");
9524
9653
  }
9525
9654
  _bindingMapCache.set(env, map);
@@ -9548,20 +9677,20 @@ function defaultBindingScope(kind) {
9548
9677
  function collectIdentifiers2(node) {
9549
9678
  const out = [];
9550
9679
  const visit2 = (n, parent) => {
9551
- if (ts11.isIdentifier(n)) {
9552
- if (parent && ts11.isPropertyAccessExpression(parent) && parent.name === n)
9680
+ if (ts12.isIdentifier(n)) {
9681
+ if (parent && ts12.isPropertyAccessExpression(parent) && parent.name === n)
9553
9682
  return;
9554
- if (parent && ts11.isPropertyAssignment(parent) && parent.name === n)
9683
+ if (parent && ts12.isPropertyAssignment(parent) && parent.name === n)
9555
9684
  return;
9556
- if (parent && (ts11.isJsxOpeningElement(parent) || ts11.isJsxClosingElement(parent) || ts11.isJsxSelfClosingElement(parent)) && parent.tagName === n) {
9685
+ if (parent && (ts12.isJsxOpeningElement(parent) || ts12.isJsxClosingElement(parent) || ts12.isJsxSelfClosingElement(parent)) && parent.tagName === n) {
9557
9686
  return;
9558
9687
  }
9559
- if (parent && ts11.isJsxAttribute(parent) && parent.name === n)
9688
+ if (parent && ts12.isJsxAttribute(parent) && parent.name === n)
9560
9689
  return;
9561
9690
  out.push(n);
9562
9691
  return;
9563
9692
  }
9564
- ts11.forEachChild(n, (child) => visit2(child, n));
9693
+ ts12.forEachChild(n, (child) => visit2(child, n));
9565
9694
  };
9566
9695
  visit2(node);
9567
9696
  return out;
@@ -9570,7 +9699,7 @@ function collectReactiveBrandRefs(node, checker) {
9570
9699
  const out = [];
9571
9700
  const seen = new Set;
9572
9701
  const visit2 = (n) => {
9573
- if (ts11.isPropertyAccessExpression(n)) {
9702
+ if (ts12.isPropertyAccessExpression(n)) {
9574
9703
  try {
9575
9704
  const type = checker.getTypeAtLocation(n);
9576
9705
  if (isReactiveType(type)) {
@@ -9588,7 +9717,7 @@ function collectReactiveBrandRefs(node, checker) {
9588
9717
  incrementCounter("freeRefsTypeLookupFailures");
9589
9718
  }
9590
9719
  }
9591
- ts11.forEachChild(n, visit2);
9720
+ ts12.forEachChild(n, visit2);
9592
9721
  };
9593
9722
  visit2(node);
9594
9723
  return out;
@@ -9598,14 +9727,14 @@ function resolveConstantInitializerRefs(c, env, visited) {
9598
9727
  return [];
9599
9728
  if (c.containsArrow)
9600
9729
  return [];
9601
- const sf = ts11.createSourceFile("__const_init.ts", `const __probe = (${c.value});`, ts11.ScriptTarget.Latest, true);
9730
+ const sf = ts12.createSourceFile("__const_init.ts", `const __probe = (${c.value});`, ts12.ScriptTarget.Latest, true);
9602
9731
  const stmt = sf.statements[0];
9603
- if (!stmt || !ts11.isVariableStatement(stmt))
9732
+ if (!stmt || !ts12.isVariableStatement(stmt))
9604
9733
  return [];
9605
9734
  const decl = stmt.declarationList.declarations[0];
9606
9735
  if (!decl || !decl.initializer)
9607
9736
  return [];
9608
- const expr = ts11.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
9737
+ const expr = ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
9609
9738
  return resolveFreeRefsInternal(expr, env, visited);
9610
9739
  }
9611
9740
  function resolveFreeRefsInternal(node, env, visited) {
@@ -9617,7 +9746,7 @@ function resolveFreeRefsInternal(node, env, visited) {
9617
9746
  const name = ident.text;
9618
9747
  if (env.propsObjectName === name) {
9619
9748
  const parent = ident.parent;
9620
- if (parent && ts11.isPropertyAccessExpression(parent) && parent.expression === ident && parent.name.text === "children") {
9749
+ if (parent && ts12.isPropertyAccessExpression(parent) && parent.expression === ident && parent.name.text === "children") {
9621
9750
  continue;
9622
9751
  }
9623
9752
  }
@@ -10022,85 +10151,6 @@ var toLocaleDatePlugin = {
10022
10151
 
10023
10152
  // src/jsx-to-ir.ts
10024
10153
  import { toHTMLAttrName, decodeEntities } from "@barefootjs/shared";
10025
-
10026
- // src/scope/binding-scope.ts
10027
- class BindingScope {
10028
- frames;
10029
- static EMPTY = new BindingScope([]);
10030
- constructor(frames) {
10031
- this.frames = frames;
10032
- }
10033
- enterLoopRow(loop) {
10034
- const bindings = new Map;
10035
- if (loop.paramBindings && loop.paramBindings.length > 0) {
10036
- for (const b of loop.paramBindings)
10037
- bindings.set(b.name, { source: "destructure" });
10038
- } else {
10039
- bindings.set(loop.param, { source: "item" });
10040
- }
10041
- if (loop.index != null)
10042
- bindings.set(loop.index, { source: "index" });
10043
- for (const name of loop.preamble?.declaredNames ?? [])
10044
- bindings.set(name, { source: "preamble" });
10045
- const frame = { kind: "loop-row", bindings };
10046
- return new BindingScope([frame, ...this.frames]);
10047
- }
10048
- enterCallback(params) {
10049
- const bindings = new Map;
10050
- for (const name of params)
10051
- bindings.set(name, { source: "param" });
10052
- const frame = { kind: "callback", bindings };
10053
- return new BindingScope([frame, ...this.frames]);
10054
- }
10055
- isBound(name) {
10056
- for (const frame of this.frames) {
10057
- if (frame.bindings.has(name))
10058
- return true;
10059
- }
10060
- return false;
10061
- }
10062
- lookup(name) {
10063
- for (let depth = 0;depth < this.frames.length; depth++) {
10064
- const frame = this.frames[depth];
10065
- const binding = frame.bindings.get(name);
10066
- if (binding)
10067
- return { depth, frame, binding };
10068
- }
10069
- return null;
10070
- }
10071
- boundNames() {
10072
- if (this.boundNamesCache)
10073
- return this.boundNamesCache;
10074
- const names = new Set;
10075
- for (const frame of this.frames) {
10076
- for (const name of frame.bindings.keys())
10077
- names.add(name);
10078
- }
10079
- this.boundNamesCache = names;
10080
- return names;
10081
- }
10082
- boundNamesCache;
10083
- valueBoundNamesCache;
10084
- valueBoundNames() {
10085
- if (this.valueBoundNamesCache)
10086
- return this.valueBoundNamesCache;
10087
- const names = new Set;
10088
- for (const frame of this.frames) {
10089
- for (const [name, binding] of frame.bindings) {
10090
- if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
10091
- names.add(name);
10092
- }
10093
- }
10094
- }
10095
- this.valueBoundNamesCache = names;
10096
- return names;
10097
- }
10098
- asShadowPredicate() {
10099
- return (name) => this.isBound(name);
10100
- }
10101
- }
10102
-
10103
- // src/jsx-to-ir.ts
10104
10154
  var CLIENT_DIRECTIVE_INTERIOR_RE2 = /^\s*@client\s*$/;
10105
10155
  var BLOCK_COMMENT_RE2 = /\/\*([\s\S]*?)\*\//g;
10106
10156
  function hasLeadingClientDirective(expr, sourceFile) {
@@ -10125,13 +10175,13 @@ function exprCallsReactiveGetters(expr, ctx) {
10125
10175
  function visit2(n) {
10126
10176
  if (found)
10127
10177
  return;
10128
- if (ts12.isCallExpression(n) && ts12.isIdentifier(n.expression)) {
10178
+ if (ts13.isCallExpression(n) && ts13.isIdentifier(n.expression)) {
10129
10179
  if (names.has(n.expression.text)) {
10130
10180
  found = true;
10131
10181
  return;
10132
10182
  }
10133
10183
  }
10134
- ts12.forEachChild(n, visit2);
10184
+ ts13.forEachChild(n, visit2);
10135
10185
  }
10136
10186
  visit2(expr);
10137
10187
  return found;
@@ -10158,11 +10208,11 @@ function exprReferencesModuleClientSignal(expr, ctx) {
10158
10208
  function visit2(n) {
10159
10209
  if (found)
10160
10210
  return;
10161
- if (ts12.isCallExpression(n) && ts12.isIdentifier(n.expression) && names.has(n.expression.text)) {
10211
+ if (ts13.isCallExpression(n) && ts13.isIdentifier(n.expression) && names.has(n.expression.text)) {
10162
10212
  found = true;
10163
10213
  return;
10164
10214
  }
10165
- ts12.forEachChild(n, visit2);
10215
+ ts13.forEachChild(n, visit2);
10166
10216
  }
10167
10217
  visit2(expr);
10168
10218
  return found;
@@ -10172,11 +10222,11 @@ function exprHasFunctionCalls(expr) {
10172
10222
  function visit2(n) {
10173
10223
  if (found)
10174
10224
  return;
10175
- if (ts12.isCallExpression(n)) {
10225
+ if (ts13.isCallExpression(n)) {
10176
10226
  found = true;
10177
10227
  return;
10178
10228
  }
10179
- ts12.forEachChild(n, visit2);
10229
+ ts13.forEachChild(n, visit2);
10180
10230
  }
10181
10231
  visit2(expr);
10182
10232
  return found;
@@ -10213,10 +10263,10 @@ function lowerDateCalls(text, expr, ctx) {
10213
10263
  return text;
10214
10264
  const candidates = [];
10215
10265
  function visit2(n) {
10216
- if (ts12.isCallExpression(n) && n.arguments.length === 0 && ts12.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
10266
+ if (ts13.isCallExpression(n) && n.arguments.length === 0 && ts13.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
10217
10267
  candidates.push(n);
10218
10268
  }
10219
- ts12.forEachChild(n, visit2);
10269
+ ts13.forEachChild(n, visit2);
10220
10270
  }
10221
10271
  visit2(expr);
10222
10272
  if (candidates.length === 0)
@@ -10241,10 +10291,10 @@ function lowerToLocaleDateCalls(text, expr, ctx) {
10241
10291
  return text;
10242
10292
  const candidates = [];
10243
10293
  function visit2(n) {
10244
- if (ts12.isCallExpression(n) && n.arguments.length === 2 && ts12.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
10294
+ if (ts13.isCallExpression(n) && n.arguments.length === 2 && ts13.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
10245
10295
  candidates.push(n);
10246
10296
  }
10247
- ts12.forEachChild(n, visit2);
10297
+ ts13.forEachChild(n, visit2);
10248
10298
  }
10249
10299
  visit2(expr);
10250
10300
  if (candidates.length === 0)
@@ -10298,10 +10348,10 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
10298
10348
  return;
10299
10349
  let acc;
10300
10350
  function visit2(n, parent) {
10301
- if (ts12.isIdentifier(n) && propDepsMap.has(n.text)) {
10302
- const isObjectKey = parent && ts12.isPropertyAssignment(parent) && parent.name === n;
10303
- const isShorthand = parent && ts12.isShorthandPropertyAssignment(parent) && parent.name === n;
10304
- const isAccessName = parent && ts12.isPropertyAccessExpression(parent) && parent.name === n;
10351
+ if (ts13.isIdentifier(n) && propDepsMap.has(n.text)) {
10352
+ const isObjectKey = parent && ts13.isPropertyAssignment(parent) && parent.name === n;
10353
+ const isShorthand = parent && ts13.isShorthandPropertyAssignment(parent) && parent.name === n;
10354
+ const isAccessName = parent && ts13.isPropertyAccessExpression(parent) && parent.name === n;
10305
10355
  if (!isObjectKey && !isShorthand && !isAccessName) {
10306
10356
  const deps = propDepsMap.get(n.text);
10307
10357
  if (deps && deps.size > 0) {
@@ -10312,7 +10362,7 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
10312
10362
  }
10313
10363
  }
10314
10364
  }
10315
- ts12.forEachChild(n, (child) => visit2(child, n));
10365
+ ts13.forEachChild(n, (child) => visit2(child, n));
10316
10366
  }
10317
10367
  visit2(node);
10318
10368
  return acc;
@@ -10363,17 +10413,17 @@ function createTransformContext(analyzer) {
10363
10413
  patterns: {
10364
10414
  signals: analyzer.signals.map((s) => ({
10365
10415
  getter: s.getter,
10366
- pattern: new RegExp(`\\b${s.getter}\\s*\\(`)
10416
+ pattern: identifierCallPattern(s.getter)
10367
10417
  })),
10368
10418
  memos: analyzer.memos.map((m) => ({
10369
10419
  name: m.name,
10370
- pattern: new RegExp(`\\b${m.name}\\s*\\(`)
10420
+ pattern: identifierCallPattern(m.name)
10371
10421
  })),
10372
- props: analyzer.propsParams.filter((p) => p.name !== "children").map((p) => ({ name: p.name, pattern: new RegExp(`\\b${p.name}\\b`) })),
10422
+ props: analyzer.propsParams.filter((p) => p.name !== "children").map((p) => ({ name: p.name, pattern: identifierPattern(p.name) })),
10373
10423
  constants: analyzer.localConstants.map((c) => ({
10374
10424
  name: c.name,
10375
10425
  value: c.value,
10376
- pattern: new RegExp(`\\b${c.name}\\b`)
10426
+ pattern: identifierPattern(c.name)
10377
10427
  }))
10378
10428
  },
10379
10429
  getJS(node) {
@@ -10388,21 +10438,21 @@ function createTransformContext(analyzer) {
10388
10438
  function buildComponentNamespaces(ctx) {
10389
10439
  const result = new Map;
10390
10440
  for (const stmt of ctx.sourceFile.statements) {
10391
- if (!ts12.isVariableStatement(stmt))
10441
+ if (!ts13.isVariableStatement(stmt))
10392
10442
  continue;
10393
10443
  for (const decl of stmt.declarationList.declarations) {
10394
- if (!decl.initializer || !ts12.isIdentifier(decl.name))
10444
+ if (!decl.initializer || !ts13.isIdentifier(decl.name))
10395
10445
  continue;
10396
10446
  let init = decl.initializer;
10397
- while (ts12.isParenthesizedExpression(init))
10447
+ while (ts13.isParenthesizedExpression(init))
10398
10448
  init = init.expression;
10399
- if (!ts12.isObjectLiteralExpression(init))
10449
+ if (!ts13.isObjectLiteralExpression(init))
10400
10450
  continue;
10401
10451
  const members = new Map;
10402
10452
  for (const prop of init.properties) {
10403
- if (ts12.isShorthandPropertyAssignment(prop)) {
10453
+ if (ts13.isShorthandPropertyAssignment(prop)) {
10404
10454
  members.set(prop.name.text, prop.name.text);
10405
- } else if (ts12.isPropertyAssignment(prop) && (ts12.isIdentifier(prop.name) || ts12.isStringLiteral(prop.name)) && ts12.isIdentifier(prop.initializer)) {
10455
+ } else if (ts13.isPropertyAssignment(prop) && (ts13.isIdentifier(prop.name) || ts13.isStringLiteral(prop.name)) && ts13.isIdentifier(prop.initializer)) {
10406
10456
  members.set(prop.name.text, prop.initializer.text);
10407
10457
  }
10408
10458
  }
@@ -10414,11 +10464,11 @@ function buildComponentNamespaces(ctx) {
10414
10464
  return result;
10415
10465
  }
10416
10466
  function resolveMemberExpressionTag(tagNode, ctx) {
10417
- if (!ts12.isPropertyAccessExpression(tagNode))
10467
+ if (!ts13.isPropertyAccessExpression(tagNode))
10418
10468
  return null;
10419
- if (!ts12.isIdentifier(tagNode.expression))
10469
+ if (!ts13.isIdentifier(tagNode.expression))
10420
10470
  return null;
10421
- if (!ts12.isIdentifier(tagNode.name))
10471
+ if (!ts13.isIdentifier(tagNode.name))
10422
10472
  return null;
10423
10473
  if (!ctx._componentNamespaces) {
10424
10474
  ctx._componentNamespaces = buildComponentNamespaces(ctx);
@@ -10451,7 +10501,7 @@ function makeBindingEnv(ctx) {
10451
10501
  localFunctions: a.localFunctions,
10452
10502
  imports: a.imports,
10453
10503
  ambientGlobals: a.ambientGlobals,
10454
- loopParams: boundNames,
10504
+ loopValueBoundNames: boundNames,
10455
10505
  checker: a.checker
10456
10506
  };
10457
10507
  ctx._bindingEnv = env;
@@ -10575,7 +10625,7 @@ function buildIRRoot(analyzer) {
10575
10625
  return null;
10576
10626
  const ctx = createTransformContext(analyzer);
10577
10627
  const jsxReturn = analyzer.jsxReturn;
10578
- if (ts12.isJsxElement(jsxReturn) || ts12.isJsxSelfClosingElement(jsxReturn) || ts12.isJsxFragment(jsxReturn)) {
10628
+ if (ts13.isJsxElement(jsxReturn) || ts13.isJsxSelfClosingElement(jsxReturn) || ts13.isJsxFragment(jsxReturn)) {
10579
10629
  const ir2 = transformNode(jsxReturn, ctx);
10580
10630
  if (ir2 && needsScopeWrapper(ir2)) {
10581
10631
  return wrapInScopeElement(ir2);
@@ -10631,22 +10681,22 @@ function wrapInScopeElement(node) {
10631
10681
  };
10632
10682
  }
10633
10683
  function transformNode(node, ctx) {
10634
- if (ts12.isJsxElement(node)) {
10684
+ if (ts13.isJsxElement(node)) {
10635
10685
  return transformJsxElement(node, ctx);
10636
10686
  }
10637
- if (ts12.isJsxSelfClosingElement(node)) {
10687
+ if (ts13.isJsxSelfClosingElement(node)) {
10638
10688
  return transformSelfClosingElement(node, ctx);
10639
10689
  }
10640
- if (ts12.isJsxFragment(node)) {
10690
+ if (ts13.isJsxFragment(node)) {
10641
10691
  return transformFragment(node, ctx);
10642
10692
  }
10643
- if (ts12.isJsxText(node)) {
10693
+ if (ts13.isJsxText(node)) {
10644
10694
  return transformText(node, ctx);
10645
10695
  }
10646
- if (ts12.isJsxExpression(node)) {
10696
+ if (ts13.isJsxExpression(node)) {
10647
10697
  return transformExpression(node, ctx);
10648
10698
  }
10649
- if (ts12.isConditionalExpression(node)) {
10699
+ if (ts13.isConditionalExpression(node)) {
10650
10700
  return transformConditional(node, ctx);
10651
10701
  }
10652
10702
  return null;
@@ -11003,7 +11053,7 @@ function transformSelfClosingComponent(node, ctx, name) {
11003
11053
  }
11004
11054
  function isTransparentFragment(node, ctx) {
11005
11055
  const children = node.children.filter((child2) => {
11006
- if (ts12.isJsxText(child2)) {
11056
+ if (ts13.isJsxText(child2)) {
11007
11057
  return child2.text.trim() !== "";
11008
11058
  }
11009
11059
  return true;
@@ -11011,7 +11061,7 @@ function isTransparentFragment(node, ctx) {
11011
11061
  if (children.length !== 1)
11012
11062
  return false;
11013
11063
  const child = children[0];
11014
- if (!ts12.isJsxExpression(child))
11064
+ if (!ts13.isJsxExpression(child))
11015
11065
  return false;
11016
11066
  if (!child.expression)
11017
11067
  return false;
@@ -11055,7 +11105,7 @@ function transformChildren(children, ctx) {
11055
11105
  const result = [];
11056
11106
  for (let i = 0;i < children.length; i++) {
11057
11107
  const child = children[i];
11058
- if (ts12.isJsxExpression(child) && !child.expression) {
11108
+ if (ts13.isJsxExpression(child) && !child.expression) {
11059
11109
  continue;
11060
11110
  }
11061
11111
  const transformed = transformNode(child, ctx);
@@ -11070,10 +11120,10 @@ function transformChildren(children, ctx) {
11070
11120
  }
11071
11121
  function isRenderNothingLiteral(expr, ctx) {
11072
11122
  let e = expr;
11073
- while (ts12.isParenthesizedExpression(e) || ts12.isAsExpression(e) || ts12.isSatisfiesExpression(e) || ts12.isNonNullExpression(e)) {
11123
+ while (ts13.isParenthesizedExpression(e) || ts13.isAsExpression(e) || ts13.isSatisfiesExpression(e) || ts13.isNonNullExpression(e)) {
11074
11124
  e = e.expression;
11075
11125
  }
11076
- return e.kind === ts12.SyntaxKind.NullKeyword || e.kind === ts12.SyntaxKind.TrueKeyword || e.kind === ts12.SyntaxKind.FalseKeyword || ts12.isIdentifier(e) && e.text === "undefined" && !isNameBound("undefined", makeBindingEnv(ctx));
11126
+ return e.kind === ts13.SyntaxKind.NullKeyword || e.kind === ts13.SyntaxKind.TrueKeyword || e.kind === ts13.SyntaxKind.FalseKeyword || ts13.isIdentifier(e) && e.text === "undefined" && !isNameBound("undefined", makeBindingEnv(ctx));
11077
11127
  }
11078
11128
  function transformText(node, ctx) {
11079
11129
  const text = node.text.replace(/\s+/g, " ");
@@ -11099,7 +11149,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
11099
11149
  return null;
11100
11150
  }
11101
11151
  checkBareSignalOrMemoIdentifier(expr, ctx);
11102
- if (ts12.isIdentifier(expr)) {
11152
+ if (ts13.isIdentifier(expr)) {
11103
11153
  const jsxNode = ctx.analyzer.jsxConstants.get(expr.text);
11104
11154
  if (jsxNode) {
11105
11155
  return transformNode(jsxNode, ctx);
@@ -11145,7 +11195,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
11145
11195
  };
11146
11196
  const reactive = isReactiveExpression(exprText, ctx, expr) || isReactiveOrigin(origin);
11147
11197
  const scopeValueNames = ctx.scope.valueBoundNames();
11148
- const refsLoopParam = scopeValueNames.size > 0 && Array.from(scopeValueNames).some((p) => new RegExp(`\\b${p}\\b`).test(exprText));
11198
+ const refsLoopParam = scopeValueNames.size > 0 && Array.from(scopeValueNames).some((p) => identifierPattern(p).test(exprText));
11149
11199
  const callsReactive = exprCallsReactiveGetters(expr, ctx);
11150
11200
  const hasCalls = exprHasFunctionCalls(expr);
11151
11201
  const needsSlot = reactive || isClientOnly || refsLoopParam || callsReactive || hasCalls;
@@ -11180,7 +11230,7 @@ function transformJsxFunctionCall(callExpr, jsxFunc, ctx, _isClientOnly) {
11180
11230
  const substitutedGetJS = (node) => {
11181
11231
  let text = baseGetJS(node);
11182
11232
  for (const [paramName, argExpr] of substitutions) {
11183
- text = text.replace(new RegExp(`\\b${paramName}\\b`, "g"), argExpr);
11233
+ text = text.replace(identifierPattern(paramName, "g"), () => argExpr);
11184
11234
  }
11185
11235
  return text;
11186
11236
  };
@@ -11222,7 +11272,7 @@ function transformMultiReturnJsxFunctionCall(callExpr, info, ctx) {
11222
11272
  const substitutedGetJS = (node) => {
11223
11273
  let text = baseGetJS(node);
11224
11274
  for (const [paramName, argExpr] of substitutions) {
11225
- text = text.replace(new RegExp(`\\b${paramName}\\b`, "g"), argExpr);
11275
+ text = text.replace(identifierPattern(paramName, "g"), () => argExpr);
11226
11276
  }
11227
11277
  return text;
11228
11278
  };
@@ -11378,38 +11428,38 @@ function transformLogicalAnd(node, ctx) {
11378
11428
  };
11379
11429
  }
11380
11430
  function containsJsxInExpression(node) {
11381
- if (ts12.isJsxElement(node) || ts12.isJsxSelfClosingElement(node) || ts12.isJsxFragment(node)) {
11431
+ if (ts13.isJsxElement(node) || ts13.isJsxSelfClosingElement(node) || ts13.isJsxFragment(node)) {
11382
11432
  return true;
11383
11433
  }
11384
- return ts12.forEachChild(node, containsJsxInExpression) ?? false;
11434
+ return ts13.forEachChild(node, containsJsxInExpression) ?? false;
11385
11435
  }
11386
11436
  function callsJsxHelper(node, ctx) {
11387
11437
  let found = false;
11388
11438
  const visit2 = (n) => {
11389
11439
  if (found)
11390
11440
  return;
11391
- if (ts12.isCallExpression(n) && ts12.isIdentifier(n.expression)) {
11441
+ if (ts13.isCallExpression(n) && ts13.isIdentifier(n.expression)) {
11392
11442
  const name = n.expression.text;
11393
11443
  if (ctx.analyzer.jsxFunctions.has(name) || ctx.analyzer.jsxMultiReturnFunctions.has(name)) {
11394
11444
  found = true;
11395
11445
  return;
11396
11446
  }
11397
11447
  }
11398
- ts12.forEachChild(n, visit2);
11448
+ ts13.forEachChild(n, visit2);
11399
11449
  };
11400
11450
  visit2(node);
11401
11451
  return found;
11402
11452
  }
11403
11453
  function containsAwaitExpression(node) {
11404
- if (ts12.isAwaitExpression(node))
11454
+ if (ts13.isAwaitExpression(node))
11405
11455
  return true;
11406
- if (ts12.isFunctionDeclaration(node) || ts12.isFunctionExpression(node) || ts12.isArrowFunction(node))
11456
+ if (ts13.isFunctionDeclaration(node) || ts13.isFunctionExpression(node) || ts13.isArrowFunction(node))
11407
11457
  return false;
11408
- return ts12.forEachChild(node, containsAwaitExpression) ?? false;
11458
+ return ts13.forEachChild(node, containsAwaitExpression) ?? false;
11409
11459
  }
11410
11460
  function transformNullishCoalescing(node, ctx) {
11411
11461
  const leftText = ctx.getJS(node.left);
11412
- const isNullish = node.operatorToken.kind === ts12.SyntaxKind.QuestionQuestionToken;
11462
+ const isNullish = node.operatorToken.kind === ts13.SyntaxKind.QuestionQuestionToken;
11413
11463
  const condition = isNullish ? `${leftText} != null` : leftText;
11414
11464
  const leftOrigin = {
11415
11465
  phase: "tick",
@@ -11455,36 +11505,36 @@ function transformNullishCoalescing(node, ctx) {
11455
11505
  }
11456
11506
  function assertNever2(expr) {
11457
11507
  const kind = expr?.kind;
11458
- throw new Error(`transformJsxExpression: unhandled ts.SyntaxKind ${kind !== undefined ? ts12.SyntaxKind[kind] : "unknown"} ` + `(kind=${kind}). Update spec/compiler.md Appendix A and the switch in jsx-to-ir.ts.`);
11508
+ throw new Error(`transformJsxExpression: unhandled ts.SyntaxKind ${kind !== undefined ? ts13.SyntaxKind[kind] : "unknown"} ` + `(kind=${kind}). Update spec/compiler.md Appendix A and the switch in jsx-to-ir.ts.`);
11459
11509
  }
11460
11510
  function transformJsxExpression(expr, ctx, isClientOnly = false) {
11461
11511
  const node = expr;
11462
11512
  switch (node.kind) {
11463
- case ts12.SyntaxKind.ParenthesizedExpression:
11464
- case ts12.SyntaxKind.AsExpression:
11465
- case ts12.SyntaxKind.SatisfiesExpression:
11466
- case ts12.SyntaxKind.NonNullExpression:
11467
- case ts12.SyntaxKind.TypeAssertionExpression:
11468
- case ts12.SyntaxKind.PartiallyEmittedExpression:
11513
+ case ts13.SyntaxKind.ParenthesizedExpression:
11514
+ case ts13.SyntaxKind.AsExpression:
11515
+ case ts13.SyntaxKind.SatisfiesExpression:
11516
+ case ts13.SyntaxKind.NonNullExpression:
11517
+ case ts13.SyntaxKind.TypeAssertionExpression:
11518
+ case ts13.SyntaxKind.PartiallyEmittedExpression:
11469
11519
  return transformJsxExpression(node.expression, ctx, isClientOnly);
11470
- case ts12.SyntaxKind.JsxElement:
11520
+ case ts13.SyntaxKind.JsxElement:
11471
11521
  return transformJsxElement(node, ctx);
11472
- case ts12.SyntaxKind.JsxFragment:
11522
+ case ts13.SyntaxKind.JsxFragment:
11473
11523
  return transformFragment(node, ctx);
11474
- case ts12.SyntaxKind.JsxSelfClosingElement:
11524
+ case ts13.SyntaxKind.JsxSelfClosingElement:
11475
11525
  return transformSelfClosingElement(node, ctx);
11476
- case ts12.SyntaxKind.ConditionalExpression:
11526
+ case ts13.SyntaxKind.ConditionalExpression:
11477
11527
  return transformConditional(node, ctx);
11478
- case ts12.SyntaxKind.BinaryExpression: {
11479
- if (node.operatorToken.kind === ts12.SyntaxKind.AmpersandAmpersandToken) {
11528
+ case ts13.SyntaxKind.BinaryExpression: {
11529
+ if (node.operatorToken.kind === ts13.SyntaxKind.AmpersandAmpersandToken) {
11480
11530
  return transformLogicalAnd(node, ctx);
11481
11531
  }
11482
- if ((node.operatorToken.kind === ts12.SyntaxKind.QuestionQuestionToken || node.operatorToken.kind === ts12.SyntaxKind.BarBarToken) && (containsJsxInExpression(node.right) || callsJsxHelper(node.right, ctx))) {
11532
+ if ((node.operatorToken.kind === ts13.SyntaxKind.QuestionQuestionToken || node.operatorToken.kind === ts13.SyntaxKind.BarBarToken) && (containsJsxInExpression(node.right) || callsJsxHelper(node.right, ctx))) {
11483
11533
  return transformNullishCoalescing(node, ctx);
11484
11534
  }
11485
11535
  return null;
11486
11536
  }
11487
- case ts12.SyntaxKind.CallExpression: {
11537
+ case ts13.SyntaxKind.CallExpression: {
11488
11538
  const mapMethod = getMapLikeMethod(node);
11489
11539
  if (mapMethod) {
11490
11540
  const mapResult = transformMapCall(node, ctx, isClientOnly, mapMethod);
@@ -11492,7 +11542,7 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
11492
11542
  return mapResult;
11493
11543
  }
11494
11544
  const callee = node.expression;
11495
- if (ts12.isIdentifier(callee)) {
11545
+ if (ts13.isIdentifier(callee)) {
11496
11546
  const jsxFunc = ctx.analyzer.jsxFunctions.get(callee.text);
11497
11547
  if (jsxFunc) {
11498
11548
  return transformJsxFunctionCall(node, jsxFunc, ctx, isClientOnly);
@@ -11504,39 +11554,39 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
11504
11554
  }
11505
11555
  return null;
11506
11556
  }
11507
- case ts12.SyntaxKind.Identifier:
11508
- case ts12.SyntaxKind.StringLiteral:
11509
- case ts12.SyntaxKind.NumericLiteral:
11510
- case ts12.SyntaxKind.BigIntLiteral:
11511
- case ts12.SyntaxKind.RegularExpressionLiteral:
11512
- case ts12.SyntaxKind.NoSubstitutionTemplateLiteral:
11513
- case ts12.SyntaxKind.TemplateExpression:
11514
- case ts12.SyntaxKind.TaggedTemplateExpression:
11515
- case ts12.SyntaxKind.TrueKeyword:
11516
- case ts12.SyntaxKind.FalseKeyword:
11517
- case ts12.SyntaxKind.NullKeyword:
11518
- case ts12.SyntaxKind.ThisKeyword:
11519
- case ts12.SyntaxKind.SuperKeyword:
11520
- case ts12.SyntaxKind.ImportKeyword:
11521
- case ts12.SyntaxKind.PropertyAccessExpression:
11522
- case ts12.SyntaxKind.ElementAccessExpression:
11523
- case ts12.SyntaxKind.PrefixUnaryExpression:
11524
- case ts12.SyntaxKind.PostfixUnaryExpression:
11525
- case ts12.SyntaxKind.TypeOfExpression:
11526
- case ts12.SyntaxKind.VoidExpression:
11527
- case ts12.SyntaxKind.DeleteExpression:
11528
- case ts12.SyntaxKind.NewExpression:
11529
- case ts12.SyntaxKind.ObjectLiteralExpression:
11530
- case ts12.SyntaxKind.ArrowFunction:
11531
- case ts12.SyntaxKind.FunctionExpression:
11532
- case ts12.SyntaxKind.ClassExpression:
11533
- case ts12.SyntaxKind.MetaProperty:
11534
- case ts12.SyntaxKind.ExpressionWithTypeArguments:
11535
- case ts12.SyntaxKind.CommaListExpression:
11536
- case ts12.SyntaxKind.SyntheticExpression:
11537
- case ts12.SyntaxKind.ArrayLiteralExpression:
11557
+ case ts13.SyntaxKind.Identifier:
11558
+ case ts13.SyntaxKind.StringLiteral:
11559
+ case ts13.SyntaxKind.NumericLiteral:
11560
+ case ts13.SyntaxKind.BigIntLiteral:
11561
+ case ts13.SyntaxKind.RegularExpressionLiteral:
11562
+ case ts13.SyntaxKind.NoSubstitutionTemplateLiteral:
11563
+ case ts13.SyntaxKind.TemplateExpression:
11564
+ case ts13.SyntaxKind.TaggedTemplateExpression:
11565
+ case ts13.SyntaxKind.TrueKeyword:
11566
+ case ts13.SyntaxKind.FalseKeyword:
11567
+ case ts13.SyntaxKind.NullKeyword:
11568
+ case ts13.SyntaxKind.ThisKeyword:
11569
+ case ts13.SyntaxKind.SuperKeyword:
11570
+ case ts13.SyntaxKind.ImportKeyword:
11571
+ case ts13.SyntaxKind.PropertyAccessExpression:
11572
+ case ts13.SyntaxKind.ElementAccessExpression:
11573
+ case ts13.SyntaxKind.PrefixUnaryExpression:
11574
+ case ts13.SyntaxKind.PostfixUnaryExpression:
11575
+ case ts13.SyntaxKind.TypeOfExpression:
11576
+ case ts13.SyntaxKind.VoidExpression:
11577
+ case ts13.SyntaxKind.DeleteExpression:
11578
+ case ts13.SyntaxKind.NewExpression:
11579
+ case ts13.SyntaxKind.ObjectLiteralExpression:
11580
+ case ts13.SyntaxKind.ArrowFunction:
11581
+ case ts13.SyntaxKind.FunctionExpression:
11582
+ case ts13.SyntaxKind.ClassExpression:
11583
+ case ts13.SyntaxKind.MetaProperty:
11584
+ case ts13.SyntaxKind.ExpressionWithTypeArguments:
11585
+ case ts13.SyntaxKind.CommaListExpression:
11586
+ case ts13.SyntaxKind.SyntheticExpression:
11587
+ case ts13.SyntaxKind.ArrayLiteralExpression:
11538
11588
  return null;
11539
- case ts12.SyntaxKind.AwaitExpression:
11589
+ case ts13.SyntaxKind.AwaitExpression:
11540
11590
  ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(node, ctx.sourceFile, ctx.filePath)));
11541
11591
  return {
11542
11592
  type: "expression",
@@ -11547,16 +11597,16 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
11547
11597
  loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
11548
11598
  origin: { phase: "tick", scope: "template", effect: "pure", freeRefs: [] }
11549
11599
  };
11550
- case ts12.SyntaxKind.YieldExpression:
11600
+ case ts13.SyntaxKind.YieldExpression:
11551
11601
  return null;
11552
- case ts12.SyntaxKind.SpreadElement:
11553
- case ts12.SyntaxKind.OmittedExpression:
11554
- case ts12.SyntaxKind.JsxExpression:
11555
- case ts12.SyntaxKind.JsxOpeningElement:
11556
- case ts12.SyntaxKind.JsxOpeningFragment:
11557
- case ts12.SyntaxKind.JsxClosingFragment:
11558
- case ts12.SyntaxKind.JsxAttributes:
11559
- case ts12.SyntaxKind.MissingDeclaration:
11602
+ case ts13.SyntaxKind.SpreadElement:
11603
+ case ts13.SyntaxKind.OmittedExpression:
11604
+ case ts13.SyntaxKind.JsxExpression:
11605
+ case ts13.SyntaxKind.JsxOpeningElement:
11606
+ case ts13.SyntaxKind.JsxOpeningFragment:
11607
+ case ts13.SyntaxKind.JsxClosingFragment:
11608
+ case ts13.SyntaxKind.JsxAttributes:
11609
+ case ts13.SyntaxKind.MissingDeclaration:
11560
11610
  return null;
11561
11611
  default:
11562
11612
  return assertNever2(node);
@@ -11593,7 +11643,7 @@ function transformConditionalBranch(node, ctx) {
11593
11643
  };
11594
11644
  }
11595
11645
  function getMapLikeMethod(node) {
11596
- if (!ts12.isPropertyAccessExpression(node.expression))
11646
+ if (!ts13.isPropertyAccessExpression(node.expression))
11597
11647
  return null;
11598
11648
  const name = node.expression.name.text;
11599
11649
  if (name === "map")
@@ -11603,9 +11653,9 @@ function getMapLikeMethod(node) {
11603
11653
  return null;
11604
11654
  }
11605
11655
  function isFilterCall(node) {
11606
- if (!ts12.isCallExpression(node))
11656
+ if (!ts13.isCallExpression(node))
11607
11657
  return null;
11608
- if (!ts12.isPropertyAccessExpression(node.expression))
11658
+ if (!ts13.isPropertyAccessExpression(node.expression))
11609
11659
  return null;
11610
11660
  if (node.expression.name.text !== "filter")
11611
11661
  return null;
@@ -11617,9 +11667,9 @@ function isFilterCall(node) {
11617
11667
  };
11618
11668
  }
11619
11669
  function isSortCall(node) {
11620
- if (!ts12.isCallExpression(node))
11670
+ if (!ts13.isCallExpression(node))
11621
11671
  return null;
11622
- if (!ts12.isPropertyAccessExpression(node.expression))
11672
+ if (!ts13.isPropertyAccessExpression(node.expression))
11623
11673
  return null;
11624
11674
  const methodName = node.expression.name.text;
11625
11675
  if (methodName !== "sort" && methodName !== "toSorted")
@@ -11633,9 +11683,9 @@ function isSortCall(node) {
11633
11683
  };
11634
11684
  }
11635
11685
  function isIteratorShapeCall(node) {
11636
- if (!ts12.isCallExpression(node))
11686
+ if (!ts13.isCallExpression(node))
11637
11687
  return null;
11638
- if (!ts12.isPropertyAccessExpression(node.expression))
11688
+ if (!ts13.isPropertyAccessExpression(node.expression))
11639
11689
  return null;
11640
11690
  if (node.arguments.length !== 0)
11641
11691
  return null;
@@ -11645,11 +11695,11 @@ function isIteratorShapeCall(node) {
11645
11695
  return { array: node.expression.expression, shape: name };
11646
11696
  }
11647
11697
  function isObjectIteratorCall(node) {
11648
- if (!ts12.isCallExpression(node))
11698
+ if (!ts13.isCallExpression(node))
11649
11699
  return null;
11650
- if (!ts12.isPropertyAccessExpression(node.expression))
11700
+ if (!ts13.isPropertyAccessExpression(node.expression))
11651
11701
  return null;
11652
- if (!ts12.isIdentifier(node.expression.expression))
11702
+ if (!ts13.isIdentifier(node.expression.expression))
11653
11703
  return null;
11654
11704
  if (node.expression.expression.text !== "Object")
11655
11705
  return null;
@@ -11674,7 +11724,7 @@ function extractSortComparator(callback, _method, ctx) {
11674
11724
  ` + `(reverse the operands for descending order).`
11675
11725
  });
11676
11726
  let resolvedNode = callback;
11677
- if (ts12.isIdentifier(callback)) {
11727
+ if (ts13.isIdentifier(callback)) {
11678
11728
  const resolved = resolveSortComparatorIdentifier(callback.text, ctx);
11679
11729
  if (!resolved) {
11680
11730
  return {
@@ -11684,7 +11734,7 @@ function extractSortComparator(callback, _method, ctx) {
11684
11734
  }
11685
11735
  resolvedNode = resolved;
11686
11736
  }
11687
- if (!ts12.isArrowFunction(resolvedNode) && !ts12.isFunctionExpression(resolvedNode)) {
11737
+ if (!ts13.isArrowFunction(resolvedNode) && !ts13.isFunctionExpression(resolvedNode)) {
11688
11738
  return {
11689
11739
  result: null,
11690
11740
  unsupportedReason: "Sort comparator must be an arrow function or function expression"
@@ -11711,11 +11761,11 @@ function resolveSortComparatorIdentifier(name, ctx) {
11711
11761
  return null;
11712
11762
  if (constInfo) {
11713
11763
  const ast = parseConstInitializer(constInfo);
11714
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11764
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11715
11765
  }
11716
11766
  if (fnInfo) {
11717
11767
  const ast = parseFunctionInfoAsExpr(fnInfo);
11718
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11768
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11719
11769
  }
11720
11770
  return null;
11721
11771
  }
@@ -11726,11 +11776,11 @@ function resolveCallbackMethodFunctionReferenceIdentifier(name, analyzer) {
11726
11776
  return null;
11727
11777
  if (constInfo) {
11728
11778
  const ast = parseConstInitializer(constInfo);
11729
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11779
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11730
11780
  }
11731
11781
  if (fnInfo) {
11732
11782
  const ast = parseFunctionInfoAsExpr(fnInfo);
11733
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11783
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11734
11784
  }
11735
11785
  return null;
11736
11786
  }
@@ -11786,13 +11836,13 @@ function resolveCallbackMethodFunctionReferences(expr, analyzer, bound = EMPTY_B
11786
11836
  return visit2(expr, bound);
11787
11837
  }
11788
11838
  function extractFilterPredicate(callback, ctx) {
11789
- if (!ts12.isArrowFunction(callback))
11839
+ if (!ts13.isArrowFunction(callback))
11790
11840
  return { result: null };
11791
11841
  if (callback.parameters.length < 1)
11792
11842
  return { result: null };
11793
11843
  const firstParam = callback.parameters[0];
11794
- if (!ts12.isIdentifier(firstParam.name)) {
11795
- if (ts12.isBlock(callback.body)) {
11844
+ if (!ts13.isIdentifier(firstParam.name)) {
11845
+ if (ts13.isBlock(callback.body)) {
11796
11846
  return {
11797
11847
  result: null,
11798
11848
  unsupportedReason: "Block body in a destructured filter param is not supported. Workaround: use an expression-body arrow, or add /* @client */."
@@ -11812,7 +11862,7 @@ function extractFilterPredicate(callback, ctx) {
11812
11862
  return { result: null };
11813
11863
  }
11814
11864
  const param = firstParam.name.getText(ctx.sourceFile);
11815
- if (ts12.isBlock(callback.body)) {
11865
+ if (ts13.isBlock(callback.body)) {
11816
11866
  const raw2 = ctx.getJS(callback.body);
11817
11867
  const statements = parseBlockBody(callback.body, ctx.sourceFile, (n) => ctx.getJS(n));
11818
11868
  if (!statements) {
@@ -11838,7 +11888,7 @@ function extractFilterPredicate(callback, ctx) {
11838
11888
  return { result: { param, predicate, raw } };
11839
11889
  }
11840
11890
  function extractLoopParamBindings(pattern) {
11841
- if (ts12.isIdentifier(pattern))
11891
+ if (ts13.isIdentifier(pattern))
11842
11892
  return null;
11843
11893
  const bindings = [];
11844
11894
  let unsupported = false;
@@ -11847,7 +11897,7 @@ function extractLoopParamBindings(pattern) {
11847
11897
  return false;
11848
11898
  for (let i = 0;i < key.length; ) {
11849
11899
  const cp = key.codePointAt(i);
11850
- const ok = i === 0 ? ts12.isIdentifierStart(cp, ts12.ScriptTarget.Latest) : ts12.isIdentifierPart(cp, ts12.ScriptTarget.Latest);
11900
+ const ok = i === 0 ? ts13.isIdentifierStart(cp, ts13.ScriptTarget.Latest) : ts13.isIdentifierPart(cp, ts13.ScriptTarget.Latest);
11851
11901
  if (!ok)
11852
11902
  return false;
11853
11903
  i += cp > 65535 ? 2 : 1;
@@ -11860,17 +11910,17 @@ function extractLoopParamBindings(pattern) {
11860
11910
  const walk = (p, prefix, segments) => {
11861
11911
  if (unsupported)
11862
11912
  return;
11863
- if (ts12.isArrayBindingPattern(p)) {
11913
+ if (ts13.isArrayBindingPattern(p)) {
11864
11914
  const elements2 = p.elements;
11865
11915
  for (let index = 0;index < elements2.length; index++) {
11866
11916
  if (unsupported)
11867
11917
  return;
11868
11918
  const el = elements2[index];
11869
- if (ts12.isOmittedExpression(el))
11919
+ if (ts13.isOmittedExpression(el))
11870
11920
  continue;
11871
11921
  if (el.dotDotDotToken) {
11872
11922
  internalInvariant(index === elements2.length - 1, "extractLoopParamBindings: array rest token in non-final position (parser should reject)");
11873
- internalInvariant(ts12.isIdentifier(el.name), "extractLoopParamBindings: array rest target is not an identifier (parser should reject)");
11923
+ internalInvariant(ts13.isIdentifier(el.name), "extractLoopParamBindings: array rest target is not an identifier (parser should reject)");
11874
11924
  bindings.push({
11875
11925
  name: el.name.text,
11876
11926
  path: prefix,
@@ -11881,7 +11931,7 @@ function extractLoopParamBindings(pattern) {
11881
11931
  }
11882
11932
  const path = `${prefix}[${index}]`;
11883
11933
  const nextSegments = [...segments, { kind: "index", index }];
11884
- if (ts12.isIdentifier(el.name)) {
11934
+ if (ts13.isIdentifier(el.name)) {
11885
11935
  bindings.push({ name: el.name.text, path, segments: nextSegments });
11886
11936
  } else {
11887
11937
  walk(el.name, path, nextSegments);
@@ -11897,7 +11947,7 @@ function extractLoopParamBindings(pattern) {
11897
11947
  const el = elements[i];
11898
11948
  if (el.dotDotDotToken) {
11899
11949
  internalInvariant(i === elements.length - 1, "extractLoopParamBindings: object rest token in non-final position (parser should reject)");
11900
- internalInvariant(ts12.isIdentifier(el.name), "extractLoopParamBindings: object rest target is not an identifier (parser should reject)");
11950
+ internalInvariant(ts13.isIdentifier(el.name), "extractLoopParamBindings: object rest target is not an identifier (parser should reject)");
11901
11951
  bindings.push({
11902
11952
  name: el.name.text,
11903
11953
  path: prefix,
@@ -11909,17 +11959,17 @@ function extractLoopParamBindings(pattern) {
11909
11959
  let keyText = null;
11910
11960
  if (el.propertyName) {
11911
11961
  const pn = el.propertyName;
11912
- if (ts12.isIdentifier(pn))
11962
+ if (ts13.isIdentifier(pn))
11913
11963
  keyText = pn.text;
11914
- else if (ts12.isStringLiteral(pn))
11964
+ else if (ts13.isStringLiteral(pn))
11915
11965
  keyText = pn.text;
11916
- else if (ts12.isNumericLiteral(pn))
11966
+ else if (ts13.isNumericLiteral(pn))
11917
11967
  keyText = pn.text;
11918
11968
  else {
11919
11969
  unsupported = true;
11920
11970
  return;
11921
11971
  }
11922
- } else if (ts12.isIdentifier(el.name)) {
11972
+ } else if (ts13.isIdentifier(el.name)) {
11923
11973
  keyText = el.name.text;
11924
11974
  } else {
11925
11975
  unsupported = true;
@@ -11929,14 +11979,14 @@ function extractLoopParamBindings(pattern) {
11929
11979
  collectedKeys.push({ key: keyText, isIdent: keyIsIdent });
11930
11980
  const path = appendDotAccess(prefix, keyText);
11931
11981
  const nextSegments = [...segments, { kind: "field", key: keyText, isIdent: keyIsIdent }];
11932
- if (ts12.isIdentifier(el.name)) {
11982
+ if (ts13.isIdentifier(el.name)) {
11933
11983
  bindings.push({ name: el.name.text, path, segments: nextSegments });
11934
11984
  } else {
11935
11985
  walk(el.name, path, nextSegments);
11936
11986
  }
11937
11987
  }
11938
11988
  };
11939
- if (ts12.isArrayBindingPattern(pattern) || ts12.isObjectBindingPattern(pattern)) {
11989
+ if (ts13.isArrayBindingPattern(pattern) || ts13.isObjectBindingPattern(pattern)) {
11940
11990
  walk(pattern, "", []);
11941
11991
  if (unsupported)
11942
11992
  return { unsupported: true };
@@ -11946,7 +11996,7 @@ function extractLoopParamBindings(pattern) {
11946
11996
  }
11947
11997
  function findKeyJsxAttribute(opening) {
11948
11998
  for (const prop of opening.attributes.properties) {
11949
- if (ts12.isJsxAttribute(prop) && prop.name.getText() === "key") {
11999
+ if (ts13.isJsxAttribute(prop) && prop.name.getText() === "key") {
11950
12000
  return prop;
11951
12001
  }
11952
12002
  }
@@ -11991,7 +12041,7 @@ function keyAttrValueToExpr(v) {
11991
12041
  function normalizeKeyExpr(expr) {
11992
12042
  let out = "";
11993
12043
  for (const tok of iterateJsTokens(expr)) {
11994
- if (tok.kind === ts12.SyntaxKind.WhitespaceTrivia || tok.kind === ts12.SyntaxKind.NewLineTrivia) {
12044
+ if (tok.kind === ts13.SyntaxKind.WhitespaceTrivia || tok.kind === ts13.SyntaxKind.NewLineTrivia) {
11995
12045
  continue;
11996
12046
  }
11997
12047
  out += expr.slice(tok.pos, tok.end);
@@ -12003,13 +12053,13 @@ function conditionalHasExplicitNullishBranch(cond) {
12003
12053
  }
12004
12054
  function branchHasExplicitNullish(branch) {
12005
12055
  let b = branch;
12006
- while (ts12.isParenthesizedExpression(b))
12056
+ while (ts13.isParenthesizedExpression(b))
12007
12057
  b = b.expression;
12008
- if (b.kind === ts12.SyntaxKind.NullKeyword)
12058
+ if (b.kind === ts13.SyntaxKind.NullKeyword)
12009
12059
  return true;
12010
- if (ts12.isIdentifier(b) && b.text === "undefined")
12060
+ if (ts13.isIdentifier(b) && b.text === "undefined")
12011
12061
  return true;
12012
- if (ts12.isConditionalExpression(b))
12062
+ if (ts13.isConditionalExpression(b))
12013
12063
  return conditionalHasExplicitNullishBranch(b);
12014
12064
  return false;
12015
12065
  }
@@ -12018,26 +12068,26 @@ function classifyKeyProblem(keyAttr, checker) {
12018
12068
  return "missing";
12019
12069
  if (!keyAttr.initializer)
12020
12070
  return "missing";
12021
- if (ts12.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
12071
+ if (ts13.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
12022
12072
  return "missing";
12023
12073
  }
12024
12074
  let expr;
12025
- if (ts12.isStringLiteral(keyAttr.initializer)) {
12075
+ if (ts13.isStringLiteral(keyAttr.initializer)) {
12026
12076
  return null;
12027
- } else if (ts12.isJsxExpression(keyAttr.initializer)) {
12077
+ } else if (ts13.isJsxExpression(keyAttr.initializer)) {
12028
12078
  expr = keyAttr.initializer.expression;
12029
12079
  }
12030
12080
  if (!expr)
12031
12081
  return null;
12032
- if (expr.kind === ts12.SyntaxKind.NullKeyword)
12082
+ if (expr.kind === ts13.SyntaxKind.NullKeyword)
12033
12083
  return null;
12034
- if (ts12.isIdentifier(expr) && expr.text === "undefined")
12084
+ if (ts13.isIdentifier(expr) && expr.text === "undefined")
12035
12085
  return null;
12036
- if (ts12.isConditionalExpression(expr) && conditionalHasExplicitNullishBranch(expr))
12086
+ if (ts13.isConditionalExpression(expr) && conditionalHasExplicitNullishBranch(expr))
12037
12087
  return null;
12038
12088
  if (checker) {
12039
12089
  const type = checker.getTypeAtLocation(expr);
12040
- const isNullable = type.isUnion() ? type.types.some((t) => (t.flags & (ts12.TypeFlags.Null | ts12.TypeFlags.Undefined | ts12.TypeFlags.Void)) !== 0) : (type.flags & (ts12.TypeFlags.Null | ts12.TypeFlags.Undefined | ts12.TypeFlags.Void)) !== 0;
12090
+ const isNullable = type.isUnion() ? type.types.some((t) => (t.flags & (ts13.TypeFlags.Null | ts13.TypeFlags.Undefined | ts13.TypeFlags.Void)) !== 0) : (type.flags & (ts13.TypeFlags.Null | ts13.TypeFlags.Undefined | ts13.TypeFlags.Void)) !== 0;
12041
12091
  if (isNullable)
12042
12092
  return "nullable-type";
12043
12093
  }
@@ -12063,81 +12113,81 @@ function checkLoopKey(callback, ctx, isNested) {
12063
12113
  ctx.analyzer.errors.push(createError(errorCode, getSourceLocation(locNode, ctx.sourceFile, ctx.filePath), { suggestion: { message: keyErrorSuggestion(problem) } }));
12064
12114
  }
12065
12115
  let body = callback.body;
12066
- if (ts12.isBlock(body)) {
12067
- const ret = body.statements.find((s) => ts12.isReturnStatement(s) && s.expression != null);
12116
+ if (ts13.isBlock(body)) {
12117
+ const ret = body.statements.find((s) => ts13.isReturnStatement(s) && s.expression != null);
12068
12118
  if (!ret?.expression)
12069
12119
  return;
12070
12120
  body = ret.expression;
12071
12121
  }
12072
- while (ts12.isParenthesizedExpression(body))
12122
+ while (ts13.isParenthesizedExpression(body))
12073
12123
  body = body.expression;
12074
12124
  function checkJsxOperand(node) {
12075
12125
  let n = node;
12076
- while (ts12.isParenthesizedExpression(n))
12126
+ while (ts13.isParenthesizedExpression(n))
12077
12127
  n = n.expression;
12078
- if (ts12.isJsxElement(n))
12128
+ if (ts13.isJsxElement(n))
12079
12129
  checkOpening(n.openingElement);
12080
- else if (ts12.isJsxSelfClosingElement(n))
12130
+ else if (ts13.isJsxSelfClosingElement(n))
12081
12131
  checkOpening(n);
12082
12132
  }
12083
- if (ts12.isConditionalExpression(body)) {
12133
+ if (ts13.isConditionalExpression(body)) {
12084
12134
  checkJsxOperand(body.whenTrue);
12085
12135
  checkJsxOperand(body.whenFalse);
12086
12136
  return;
12087
12137
  }
12088
- if (ts12.isBinaryExpression(body) && (body.operatorToken.kind === ts12.SyntaxKind.AmpersandAmpersandToken || body.operatorToken.kind === ts12.SyntaxKind.BarBarToken || body.operatorToken.kind === ts12.SyntaxKind.QuestionQuestionToken)) {
12138
+ if (ts13.isBinaryExpression(body) && (body.operatorToken.kind === ts13.SyntaxKind.AmpersandAmpersandToken || body.operatorToken.kind === ts13.SyntaxKind.BarBarToken || body.operatorToken.kind === ts13.SyntaxKind.QuestionQuestionToken)) {
12089
12139
  checkJsxOperand(body.left);
12090
12140
  checkJsxOperand(body.right);
12091
12141
  return;
12092
12142
  }
12093
- if (ts12.isJsxElement(body)) {
12143
+ if (ts13.isJsxElement(body)) {
12094
12144
  checkOpening(body.openingElement);
12095
12145
  return;
12096
12146
  }
12097
- if (ts12.isJsxSelfClosingElement(body)) {
12147
+ if (ts13.isJsxSelfClosingElement(body)) {
12098
12148
  checkOpening(body);
12099
12149
  return;
12100
12150
  }
12101
12151
  }
12102
12152
  function flatMapProjectionCall(body) {
12103
12153
  let expr;
12104
- if (ts12.isBlock(body)) {
12154
+ if (ts13.isBlock(body)) {
12105
12155
  const real = body.statements;
12106
- if (real.length !== 1 || !ts12.isReturnStatement(real[0]) || !real[0].expression)
12156
+ if (real.length !== 1 || !ts13.isReturnStatement(real[0]) || !real[0].expression)
12107
12157
  return null;
12108
12158
  expr = real[0].expression;
12109
12159
  } else {
12110
12160
  expr = body;
12111
12161
  }
12112
- while (ts12.isParenthesizedExpression(expr))
12162
+ while (ts13.isParenthesizedExpression(expr))
12113
12163
  expr = expr.expression;
12114
- if (!ts12.isCallExpression(expr))
12164
+ if (!ts13.isCallExpression(expr))
12115
12165
  return null;
12116
12166
  if (!getMapLikeMethod(expr))
12117
12167
  return null;
12118
12168
  const cb = expr.arguments[0];
12119
- if (!cb || !ts12.isArrowFunction(cb) && !ts12.isFunctionExpression(cb))
12169
+ if (!cb || !ts13.isArrowFunction(cb) && !ts13.isFunctionExpression(cb))
12120
12170
  return null;
12121
12171
  for (const p of cb.parameters) {
12122
- if (!ts12.isIdentifier(p.name))
12172
+ if (!ts13.isIdentifier(p.name))
12123
12173
  return null;
12124
12174
  }
12125
12175
  let innerBody = cb.body;
12126
- if (ts12.isBlock(innerBody)) {
12127
- const ret = innerBody.statements.find((s) => ts12.isReturnStatement(s) && s.expression != null);
12176
+ if (ts13.isBlock(innerBody)) {
12177
+ const ret = innerBody.statements.find((s) => ts13.isReturnStatement(s) && s.expression != null);
12128
12178
  if (innerBody.statements.length !== 1 || !ret?.expression)
12129
12179
  return null;
12130
12180
  innerBody = ret.expression;
12131
12181
  }
12132
- while (ts12.isParenthesizedExpression(innerBody))
12182
+ while (ts13.isParenthesizedExpression(innerBody))
12133
12183
  innerBody = innerBody.expression;
12134
12184
  const isElementish = (n) => {
12135
12185
  let m = n;
12136
- while (ts12.isParenthesizedExpression(m))
12186
+ while (ts13.isParenthesizedExpression(m))
12137
12187
  m = m.expression;
12138
- if (ts12.isJsxElement(m) || ts12.isJsxSelfClosingElement(m))
12188
+ if (ts13.isJsxElement(m) || ts13.isJsxSelfClosingElement(m))
12139
12189
  return leafIsWirelessElement(m);
12140
- if (ts12.isConditionalExpression(m))
12190
+ if (ts13.isConditionalExpression(m))
12141
12191
  return isElementish(m.whenTrue) && isElementish(m.whenFalse);
12142
12192
  return false;
12143
12193
  };
@@ -12150,19 +12200,19 @@ function leafIsWirelessElement(el) {
12150
12200
  const visit2 = (n) => {
12151
12201
  if (!ok)
12152
12202
  return;
12153
- if (ts12.isJsxOpeningElement(n) || ts12.isJsxSelfClosingElement(n)) {
12203
+ if (ts13.isJsxOpeningElement(n) || ts13.isJsxSelfClosingElement(n)) {
12154
12204
  const tagNode = n.tagName;
12155
- const isIntrinsic = ts12.isIdentifier(tagNode) ? !/^[A-Z]/.test(tagNode.text) : ts12.isJsxNamespacedName(tagNode);
12205
+ const isIntrinsic = ts13.isIdentifier(tagNode) ? !/^[A-Z]/.test(tagNode.text) : ts13.isJsxNamespacedName(tagNode);
12156
12206
  if (!isIntrinsic) {
12157
12207
  ok = false;
12158
12208
  return;
12159
12209
  }
12160
12210
  for (const attr of n.attributes.properties) {
12161
- if (ts12.isJsxSpreadAttribute(attr)) {
12211
+ if (ts13.isJsxSpreadAttribute(attr)) {
12162
12212
  ok = false;
12163
12213
  return;
12164
12214
  }
12165
- if (ts12.isJsxAttribute(attr)) {
12215
+ if (ts13.isJsxAttribute(attr)) {
12166
12216
  const name = attr.name.getText();
12167
12217
  if (/^on[A-Z]/.test(name)) {
12168
12218
  ok = false;
@@ -12171,11 +12221,11 @@ function leafIsWirelessElement(el) {
12171
12221
  }
12172
12222
  }
12173
12223
  }
12174
- if (ts12.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
12224
+ if (ts13.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
12175
12225
  ok = false;
12176
12226
  return;
12177
12227
  }
12178
- ts12.forEachChild(n, visit2);
12228
+ ts13.forEachChild(n, visit2);
12179
12229
  };
12180
12230
  visit2(el);
12181
12231
  return ok;
@@ -12355,7 +12405,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12355
12405
  let children = [];
12356
12406
  let paramBindings;
12357
12407
  let flatMapCallback;
12358
- if (ts12.isArrowFunction(callback)) {
12408
+ if (ts13.isArrowFunction(callback)) {
12359
12409
  if (callback.parameters.length > 0) {
12360
12410
  const firstParam = callback.parameters[0];
12361
12411
  param = firstParam.name.getText(ctx.sourceFile);
@@ -12363,9 +12413,9 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12363
12413
  paramType = firstParam.type.getText(ctx.sourceFile);
12364
12414
  }
12365
12415
  const isEntriesShape = iterationShape === "entries" || objectIteration === "entries";
12366
- if (isEntriesShape && ts12.isArrayBindingPattern(firstParam.name)) {
12367
- const elements = firstParam.name.elements.filter((el) => !ts12.isOmittedExpression(el));
12368
- if (elements.length === 2 && ts12.isBindingElement(elements[0]) && ts12.isIdentifier(elements[0].name) && ts12.isBindingElement(elements[1]) && ts12.isIdentifier(elements[1].name)) {
12416
+ if (isEntriesShape && ts13.isArrayBindingPattern(firstParam.name)) {
12417
+ const elements = firstParam.name.elements.filter((el) => !ts13.isOmittedExpression(el));
12418
+ if (elements.length === 2 && ts13.isBindingElement(elements[0]) && ts13.isIdentifier(elements[0].name) && ts13.isBindingElement(elements[1]) && ts13.isIdentifier(elements[1].name)) {
12369
12419
  index = elements[0].name.text;
12370
12420
  param = elements[1].name.text;
12371
12421
  } else {
@@ -12396,10 +12446,10 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12396
12446
  ctx.scope = ctx.scope.enterLoopRow({ param, index, paramBindings });
12397
12447
  ctx.loopDepth++;
12398
12448
  const tryTransformRenderableBody = (expr) => {
12399
- if (!ts12.isBinaryExpression(expr))
12449
+ if (!ts13.isBinaryExpression(expr))
12400
12450
  return;
12401
12451
  const op = expr.operatorToken.kind;
12402
- if (op !== ts12.SyntaxKind.AmpersandAmpersandToken && op !== ts12.SyntaxKind.BarBarToken && op !== ts12.SyntaxKind.QuestionQuestionToken) {
12452
+ if (op !== ts13.SyntaxKind.AmpersandAmpersandToken && op !== ts13.SyntaxKind.BarBarToken && op !== ts13.SyntaxKind.QuestionQuestionToken) {
12403
12453
  return;
12404
12454
  }
12405
12455
  if (!containsJsxInExpression(expr) && !callsJsxHelper(expr, ctx))
@@ -12409,33 +12459,33 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12409
12459
  children = [transformed];
12410
12460
  };
12411
12461
  const body = callback.body;
12412
- if (ts12.isJsxElement(body) || ts12.isJsxSelfClosingElement(body) || ts12.isJsxFragment(body)) {
12462
+ if (ts13.isJsxElement(body) || ts13.isJsxSelfClosingElement(body) || ts13.isJsxFragment(body)) {
12413
12463
  const transformed = transformNode(body, ctx);
12414
12464
  if (transformed) {
12415
12465
  children = [transformed];
12416
12466
  }
12417
- } else if (ts12.isConditionalExpression(body)) {
12467
+ } else if (ts13.isConditionalExpression(body)) {
12418
12468
  children = [transformConditional(body, ctx)];
12419
- } else if (ts12.isParenthesizedExpression(body)) {
12469
+ } else if (ts13.isParenthesizedExpression(body)) {
12420
12470
  let inner = body.expression;
12421
- while (ts12.isParenthesizedExpression(inner)) {
12471
+ while (ts13.isParenthesizedExpression(inner)) {
12422
12472
  inner = inner.expression;
12423
12473
  }
12424
- if (ts12.isJsxElement(inner) || ts12.isJsxSelfClosingElement(inner) || ts12.isJsxFragment(inner)) {
12474
+ if (ts13.isJsxElement(inner) || ts13.isJsxSelfClosingElement(inner) || ts13.isJsxFragment(inner)) {
12425
12475
  const transformed = transformNode(inner, ctx);
12426
12476
  if (transformed) {
12427
12477
  children = [transformed];
12428
12478
  }
12429
- } else if (ts12.isConditionalExpression(inner)) {
12479
+ } else if (ts13.isConditionalExpression(inner)) {
12430
12480
  children = [transformConditional(inner, ctx)];
12431
- } else if (method === "flatMap" && ts12.isArrayLiteralExpression(inner)) {
12481
+ } else if (method === "flatMap" && ts13.isArrayLiteralExpression(inner)) {
12432
12482
  children = transformArrayLiteralChildren(inner, ctx);
12433
12483
  } else {
12434
12484
  tryTransformRenderableBody(inner);
12435
12485
  }
12436
- } else if (method === "flatMap" && ts12.isArrayLiteralExpression(body)) {
12486
+ } else if (method === "flatMap" && ts13.isArrayLiteralExpression(body)) {
12437
12487
  children = transformArrayLiteralChildren(body, ctx);
12438
- } else if (ts12.isBlock(body)) {
12488
+ } else if (ts13.isBlock(body)) {
12439
12489
  const multiReturn = method !== "flatMap" ? extractMultiReturnJsxBranches(body, true) : null;
12440
12490
  if (multiReturn && multiReturn.branches.length > 0) {
12441
12491
  const loc = getSourceLocation(body, ctx.sourceFile, ctx.filePath);
@@ -12453,7 +12503,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12453
12503
  }
12454
12504
  }
12455
12505
  }
12456
- const returnStmt = children.length === 0 ? body.statements.find((s) => ts12.isReturnStatement(s) && s.expression != null) : undefined;
12506
+ const returnStmt = children.length === 0 ? body.statements.find((s) => ts13.isReturnStatement(s) && s.expression != null) : undefined;
12457
12507
  let rowScopeBeforePreamble = null;
12458
12508
  if (returnStmt) {
12459
12509
  const preambleNames = new Set;
@@ -12474,10 +12524,10 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12474
12524
  }
12475
12525
  if (returnStmt && returnStmt.expression) {
12476
12526
  let returnExpr = returnStmt.expression;
12477
- while (ts12.isParenthesizedExpression(returnExpr)) {
12527
+ while (ts13.isParenthesizedExpression(returnExpr)) {
12478
12528
  returnExpr = returnExpr.expression;
12479
12529
  }
12480
- if (ts12.isJsxElement(returnExpr) || ts12.isJsxSelfClosingElement(returnExpr) || ts12.isJsxFragment(returnExpr)) {
12530
+ if (ts13.isJsxElement(returnExpr) || ts13.isJsxSelfClosingElement(returnExpr) || ts13.isJsxFragment(returnExpr)) {
12481
12531
  const transformed = transformNode(returnExpr, ctx);
12482
12532
  if (transformed) {
12483
12533
  children = [transformed];
@@ -12559,7 +12609,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12559
12609
  }
12560
12610
  }
12561
12611
  }
12562
- if (method === "flatMap" && children.length === 0 && !flatMapCallback && !ts12.isBlock(body)) {
12612
+ if (method === "flatMap" && children.length === 0 && !flatMapCallback && !ts13.isBlock(body)) {
12563
12613
  flatMapCallback = buildFlatMapCallback(callback, body, ctx);
12564
12614
  }
12565
12615
  if (flatMapCallback)
@@ -12577,7 +12627,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12577
12627
  }
12578
12628
  if (children.length === 0 && !flatMapCallback) {
12579
12629
  const cb = node.arguments[0];
12580
- const cbBody = cb && (ts12.isArrowFunction(cb) || ts12.isFunctionExpression(cb)) ? cb.body : undefined;
12630
+ const cbBody = cb && (ts13.isArrowFunction(cb) || ts13.isFunctionExpression(cb)) ? cb.body : undefined;
12581
12631
  if (cbBody && containsJsxInExpression(cbBody) && ctx.analyzer.errors.length === diagCountAtEntry) {
12582
12632
  ctx.analyzer.errors.push(createError(ErrorCodes.UNSUPPORTED_JSX_PATTERN, getSourceLocation(cbBody, ctx.sourceFile, ctx.filePath), {
12583
12633
  message: `A .${method}() callback that builds JSX in this shape cannot be ` + "compiled — the JSX would leak verbatim into the client bundle. " + "Recognized bodies: a JSX element/fragment, a ternary or " + "&& / || / ?? expression, an array literal (flatMap), or a block " + "body whose return the compiler can lower.",
@@ -12588,7 +12638,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12588
12638
  }
12589
12639
  return null;
12590
12640
  }
12591
- if (ts12.isArrowFunction(node.arguments[0]) && children.length > 0) {
12641
+ if (ts13.isArrowFunction(node.arguments[0]) && children.length > 0) {
12592
12642
  checkLoopKey(node.arguments[0], ctx, isNested);
12593
12643
  }
12594
12644
  const itemConditional = children.length > 0 ? loopBodyItemConditional(children) : null;
@@ -12642,6 +12692,9 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12642
12692
  const preambleRegions = preamble && !isStaticArray ? collectPreambleRegions(children, new Set(preamble.declaredNames), ctx) : undefined;
12643
12693
  if (preamble && !isStaticArray) {
12644
12694
  markPreambleAttrSlots(children, new Set(preamble.declaredNames), ctx);
12695
+ if (preamble.reactiveNames && preamble.reactiveNames.length > 0) {
12696
+ markPreambleConditionalReactivity(children, new Set(preamble.reactiveNames), ctx);
12697
+ }
12645
12698
  }
12646
12699
  const nestedComponents = collectNestedComponents(children).filter((c) => c.name !== childComponent?.name);
12647
12700
  return {
@@ -12685,12 +12738,12 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12685
12738
  function transformArrayLiteralChildren(arrayLiteral, ctx) {
12686
12739
  const children = [];
12687
12740
  for (const element of arrayLiteral.elements) {
12688
- if (ts12.isSpreadElement(element))
12741
+ if (ts13.isSpreadElement(element))
12689
12742
  continue;
12690
12743
  let inner = element;
12691
- while (ts12.isParenthesizedExpression(inner))
12744
+ while (ts13.isParenthesizedExpression(inner))
12692
12745
  inner = inner.expression;
12693
- if (ts12.isJsxElement(inner) || ts12.isJsxSelfClosingElement(inner) || ts12.isJsxFragment(inner)) {
12746
+ if (ts13.isJsxElement(inner) || ts13.isJsxSelfClosingElement(inner) || ts13.isJsxFragment(inner)) {
12694
12747
  const transformed = transformNode(inner, ctx);
12695
12748
  if (transformed)
12696
12749
  children.push(transformed);
@@ -12699,7 +12752,7 @@ function transformArrayLiteralChildren(arrayLiteral, ctx) {
12699
12752
  return children;
12700
12753
  }
12701
12754
  function containsJsx(node) {
12702
- if (ts12.isJsxElement(node) || ts12.isJsxSelfClosingElement(node) || ts12.isJsxFragment(node))
12755
+ if (ts13.isJsxElement(node) || ts13.isJsxSelfClosingElement(node) || ts13.isJsxFragment(node))
12703
12756
  return true;
12704
12757
  let found = false;
12705
12758
  node.forEachChild((child) => {
@@ -12715,7 +12768,7 @@ function buildFlatMapCallback(callback, body, ctx) {
12715
12768
  const leafIrs = [];
12716
12769
  let refusalNode;
12717
12770
  const collectJsx = (n, underTemplate) => {
12718
- if (ts12.isJsxElement(n) || ts12.isJsxSelfClosingElement(n) || ts12.isJsxFragment(n)) {
12771
+ if (ts13.isJsxElement(n) || ts13.isJsxSelfClosingElement(n) || ts13.isJsxFragment(n)) {
12719
12772
  if (underTemplate)
12720
12773
  refusalNode ??= n;
12721
12774
  leafSpans.push({ start: n.getStart(ctx.sourceFile), end: n.getEnd() });
@@ -12723,7 +12776,7 @@ function buildFlatMapCallback(callback, body, ctx) {
12723
12776
  leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx.sourceFile, ctx.filePath) });
12724
12777
  return;
12725
12778
  }
12726
- const inTemplate = underTemplate || ts12.isTemplateExpression(n) || ts12.isTaggedTemplateExpression(n);
12779
+ const inTemplate = underTemplate || ts13.isTemplateExpression(n) || ts13.isTaggedTemplateExpression(n);
12727
12780
  n.forEachChild((c) => collectJsx(c, inTemplate));
12728
12781
  };
12729
12782
  collectJsx(body, false);
@@ -12899,6 +12952,33 @@ function markPreambleAttrSlots(nodes, declared, ctx) {
12899
12952
  };
12900
12953
  visit2(nodes);
12901
12954
  }
12955
+ function markPreambleConditionalReactivity(nodes, reactiveNames, ctx) {
12956
+ if (reactiveNames.size === 0)
12957
+ return;
12958
+ const visit2 = (list) => {
12959
+ for (const node of list) {
12960
+ switch (node.type) {
12961
+ case "element":
12962
+ case "fragment":
12963
+ visit2(node.children);
12964
+ break;
12965
+ case "conditional": {
12966
+ if (!node.reactive) {
12967
+ const refs = extractFreeIdentifiersFromText(node.condition);
12968
+ if ([...refs].some((r) => reactiveNames.has(r))) {
12969
+ node.reactive = true;
12970
+ if (!node.slotId)
12971
+ node.slotId = generateSlotId(ctx);
12972
+ }
12973
+ }
12974
+ visit2([node.whenTrue, ...node.whenFalse ? [node.whenFalse] : []]);
12975
+ break;
12976
+ }
12977
+ }
12978
+ }
12979
+ };
12980
+ visit2(nodes);
12981
+ }
12902
12982
  function attrValueText(value) {
12903
12983
  if (value.kind === "expression")
12904
12984
  return value.expr;
@@ -12914,24 +12994,46 @@ function attrValueText(value) {
12914
12994
  return out.join(" ");
12915
12995
  }
12916
12996
  function collectBindingNames2(name, out) {
12917
- if (ts12.isIdentifier(name)) {
12997
+ if (ts13.isIdentifier(name)) {
12918
12998
  out.add(name.text);
12919
12999
  return;
12920
13000
  }
12921
13001
  for (const el of name.elements) {
12922
- if (ts12.isBindingElement(el))
13002
+ if (ts13.isBindingElement(el))
12923
13003
  collectBindingNames2(el.name, out);
12924
13004
  }
12925
13005
  }
12926
13006
  function collectPreambleDeclaredNames(stmt, out) {
12927
- if (ts12.isVariableStatement(stmt)) {
13007
+ if (ts13.isVariableStatement(stmt)) {
12928
13008
  for (const decl of stmt.declarationList.declarations) {
12929
13009
  collectBindingNames2(decl.name, out);
12930
13010
  }
12931
- } else if (ts12.isFunctionDeclaration(stmt) && stmt.name) {
13011
+ } else if (ts13.isFunctionDeclaration(stmt) && stmt.name) {
12932
13012
  out.add(stmt.name.text);
12933
13013
  }
12934
13014
  }
13015
+ function computePreambleReactiveNames(statements, ctx) {
13016
+ const reactiveNames = new Set;
13017
+ for (const stmt of statements) {
13018
+ if (!ts13.isVariableStatement(stmt))
13019
+ continue;
13020
+ for (const decl of stmt.declarationList.declarations) {
13021
+ if (!decl.initializer)
13022
+ continue;
13023
+ const boundNames = new Set;
13024
+ collectBindingNames2(decl.name, boundNames);
13025
+ const initText = ctx.getJS(decl.initializer);
13026
+ const initFreeRefs = extractFreeIdentifiersFromNode(decl.initializer);
13027
+ const readsEarlierReactive = [...initFreeRefs].some((r) => reactiveNames.has(r));
13028
+ const isReactive = readsEarlierReactive || isReactiveExpression(initText, ctx, decl.initializer);
13029
+ if (isReactive) {
13030
+ for (const n of boundNames)
13031
+ reactiveNames.add(n);
13032
+ }
13033
+ }
13034
+ }
13035
+ return reactiveNames;
13036
+ }
12935
13037
  function preambleFromValueStatements(statements, ctx) {
12936
13038
  const segments = [];
12937
13039
  const typedParts = [];
@@ -12946,21 +13048,23 @@ function preambleFromValueStatements(statements, ctx) {
12946
13048
  typedParts.push(raw0.endsWith(";") ? raw0 : raw0 + ";");
12947
13049
  segments.push(tjs !== js ? { kind: "js", text: js, templateText: tjs } : { kind: "js", text: js });
12948
13050
  }
13051
+ const reactiveNames = computePreambleReactiveNames(statements, ctx);
12949
13052
  return {
12950
13053
  segments: trimPreambleSegments(segments),
12951
13054
  ssrText: tsxSourceText(typedParts.join(" ")),
12952
13055
  declaredNames: [...declared],
12953
13056
  builderNames: [],
12954
- declarations: neutralPreambleDeclarations(statements, ctx) ?? undefined
13057
+ declarations: neutralPreambleDeclarations(statements, ctx) ?? undefined,
13058
+ reactiveNames: reactiveNames.size > 0 ? [...reactiveNames] : undefined
12955
13059
  };
12956
13060
  }
12957
13061
  function neutralPreambleDeclarations(statements, ctx) {
12958
13062
  const out = [];
12959
13063
  for (const stmt of statements) {
12960
- if (!ts12.isVariableStatement(stmt))
13064
+ if (!ts13.isVariableStatement(stmt))
12961
13065
  return null;
12962
13066
  for (const decl of stmt.declarationList.declarations) {
12963
- if (!ts12.isIdentifier(decl.name))
13067
+ if (!ts13.isIdentifier(decl.name))
12964
13068
  return null;
12965
13069
  if (!decl.initializer)
12966
13070
  return null;
@@ -12993,11 +13097,11 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
12993
13097
  let refusalNode;
12994
13098
  const recordBuilderTarget = (leaf, stmt) => {
12995
13099
  for (let n = leaf.parent;n && n !== stmt.parent; n = n.parent) {
12996
- if (ts12.isCallExpression(n) && ts12.isPropertyAccessExpression(n.expression) && (n.expression.name.text === "push" || n.expression.name.text === "unshift") && ts12.isIdentifier(n.expression.expression)) {
13100
+ if (ts13.isCallExpression(n) && ts13.isPropertyAccessExpression(n.expression) && (n.expression.name.text === "push" || n.expression.name.text === "unshift") && ts13.isIdentifier(n.expression.expression)) {
12997
13101
  builders.add(n.expression.expression.text);
12998
13102
  return;
12999
13103
  }
13000
- if (ts12.isVariableDeclaration(n) && ts12.isIdentifier(n.name)) {
13104
+ if (ts13.isVariableDeclaration(n) && ts13.isIdentifier(n.name)) {
13001
13105
  builders.add(n.name.text);
13002
13106
  return;
13003
13107
  }
@@ -13010,7 +13114,7 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
13010
13114
  const leafSpans = [];
13011
13115
  const leafIrs = [];
13012
13116
  const collect = (n, underTemplate) => {
13013
- if (ts12.isJsxElement(n) || ts12.isJsxSelfClosingElement(n) || ts12.isJsxFragment(n)) {
13117
+ if (ts13.isJsxElement(n) || ts13.isJsxSelfClosingElement(n) || ts13.isJsxFragment(n)) {
13014
13118
  if (underTemplate)
13015
13119
  refusalNode ??= n;
13016
13120
  recordBuilderTarget(n, stmt);
@@ -13021,7 +13125,7 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
13021
13125
  leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx.sourceFile, ctx.filePath) });
13022
13126
  return;
13023
13127
  }
13024
- const inTemplate = underTemplate || ts12.isTemplateExpression(n) || ts12.isTaggedTemplateExpression(n);
13128
+ const inTemplate = underTemplate || ts13.isTemplateExpression(n) || ts13.isTaggedTemplateExpression(n);
13025
13129
  n.forEachChild((c) => collect(c, inTemplate));
13026
13130
  };
13027
13131
  collect(stmt, false);
@@ -13125,13 +13229,13 @@ function expandSpreadAttribute(attr, ctx) {
13125
13229
  }];
13126
13230
  }
13127
13231
  function attrFreeIdentifiers(attr) {
13128
- if (!attr.initializer || !ts12.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13232
+ if (!attr.initializer || !ts13.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13129
13233
  return;
13130
13234
  }
13131
13235
  return extractFreeIdentifiersFromNode(attr.initializer.expression);
13132
13236
  }
13133
13237
  function computeReactivityFlags(attr, ctx) {
13134
- if (!attr.initializer || !ts12.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13238
+ if (!attr.initializer || !ts13.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
13135
13239
  return {};
13136
13240
  }
13137
13241
  const expr = attr.initializer.expression;
@@ -13157,22 +13261,22 @@ function processAttributes(attributes, ctx) {
13157
13261
  const events = [];
13158
13262
  let ref = null;
13159
13263
  for (const attr of attributes.properties) {
13160
- if (ts12.isJsxSpreadAttribute(attr)) {
13264
+ if (ts13.isJsxSpreadAttribute(attr)) {
13161
13265
  attrs.push(...expandSpreadAttribute(attr, ctx));
13162
13266
  continue;
13163
13267
  }
13164
- if (!ts12.isJsxAttribute(attr))
13268
+ if (!ts13.isJsxAttribute(attr))
13165
13269
  continue;
13166
13270
  const rawName = attr.name.getText(ctx.sourceFile);
13167
13271
  if (rawName === "ref") {
13168
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13272
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13169
13273
  reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
13170
13274
  ref = ctx.getJS(attr.initializer.expression);
13171
13275
  }
13172
13276
  continue;
13173
13277
  }
13174
13278
  if (/^on[A-Z]/.test(rawName)) {
13175
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13279
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13176
13280
  const eventName = rawName.slice(2).toLowerCase();
13177
13281
  reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
13178
13282
  events.push({
@@ -13187,7 +13291,7 @@ function processAttributes(attributes, ctx) {
13187
13291
  const name = toHTMLAttrName(rawName);
13188
13292
  let value = getAttributeValue(attr, ctx);
13189
13293
  let clientOnly;
13190
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13294
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13191
13295
  if (value.kind === "expression" && value.templateExpr === undefined) {
13192
13296
  const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
13193
13297
  if (rewritten !== value.expr) {
@@ -13214,55 +13318,55 @@ function getAttributeValue(attr, ctx) {
13214
13318
  if (!attr.initializer) {
13215
13319
  return AttrValueOf.booleanAttr();
13216
13320
  }
13217
- if (ts12.isStringLiteral(attr.initializer)) {
13321
+ if (ts13.isStringLiteral(attr.initializer)) {
13218
13322
  return AttrValueOf.literal(decodeEntities(attr.initializer.text));
13219
13323
  }
13220
- if (ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13324
+ if (ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13221
13325
  let expr = attr.initializer.expression;
13222
- if (ts12.isIdentifier(expr)) {
13326
+ if (ts13.isIdentifier(expr)) {
13223
13327
  const branchInit = ctx._branchScopeVars?.get(expr.text);
13224
13328
  if (branchInit && !initializerShapeContainsJsx(branchInit)) {
13225
13329
  expr = branchInit;
13226
13330
  }
13227
13331
  }
13228
13332
  expr = tryDesugarInterleaveTaggedTemplate(expr, ctx);
13229
- if (ts12.isAwaitExpression(expr)) {
13333
+ if (ts13.isAwaitExpression(expr)) {
13230
13334
  ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(expr, ctx.sourceFile, ctx.filePath)));
13231
13335
  return AttrValueOf.expression("undefined");
13232
13336
  }
13233
13337
  checkBareSignalOrMemoIdentifier(expr, ctx);
13234
- if (attr.name.getText(ctx.sourceFile) === "style" && ts12.isObjectLiteralExpression(expr)) {
13338
+ if (attr.name.getText(ctx.sourceFile) === "style" && ts13.isObjectLiteralExpression(expr)) {
13235
13339
  const cssString = tryStaticStyleObjectToCss(expr);
13236
13340
  if (cssString !== null) {
13237
13341
  return AttrValueOf.literal(cssString);
13238
13342
  }
13239
13343
  }
13240
- if (ts12.isTemplateExpression(expr)) {
13344
+ if (ts13.isTemplateExpression(expr)) {
13241
13345
  const parts = parseTemplateLiteral(expr, ctx);
13242
13346
  if (parts.some((p) => p.type === "ternary" || p.type === "lookup")) {
13243
13347
  return AttrValueOf.template(parts);
13244
13348
  }
13245
13349
  }
13246
- if (ts12.isElementAccessExpression(expr) && !ts12.isStringLiteralLike(expr.argumentExpression) && !ts12.isNumericLiteral(expr.argumentExpression)) {
13350
+ if (ts13.isElementAccessExpression(expr) && !ts13.isStringLiteralLike(expr.argumentExpression) && !ts13.isNumericLiteral(expr.argumentExpression)) {
13247
13351
  const parts = tryResolveTemplateSpanFromConst(expr, ctx);
13248
13352
  if (parts) {
13249
13353
  return AttrValueOf.template(parts);
13250
13354
  }
13251
13355
  }
13252
- if (ts12.isIdentifier(expr)) {
13356
+ if (ts13.isIdentifier(expr)) {
13253
13357
  const resolved = tryResolveIdentifierAsTemplateLiteral(expr, ctx);
13254
13358
  if (resolved) {
13255
13359
  return AttrValueOf.template(resolved);
13256
13360
  }
13257
13361
  }
13258
- if (ts12.isConditionalExpression(expr)) {
13362
+ if (ts13.isConditionalExpression(expr)) {
13259
13363
  const ternary = parseTernary(expr, ctx);
13260
13364
  if (ternary) {
13261
13365
  return AttrValueOf.template([ternary]);
13262
13366
  }
13263
13367
  }
13264
- if (ts12.isBinaryExpression(expr) && expr.operatorToken.kind === ts12.SyntaxKind.BarBarToken) {
13265
- if (ts12.isIdentifier(expr.right) && expr.right.text === "undefined") {
13368
+ if (ts13.isBinaryExpression(expr) && expr.operatorToken.kind === ts13.SyntaxKind.BarBarToken) {
13369
+ if (ts13.isIdentifier(expr.right) && expr.right.text === "undefined") {
13266
13370
  const baseExpr = ctx.getJS(expr.left);
13267
13371
  return AttrValueOf.expression(baseExpr, { presenceOrUndefined: true });
13268
13372
  }
@@ -13275,11 +13379,11 @@ function getAttributeValue(attr, ctx) {
13275
13379
  function tryStaticStyleObjectToCss(expr) {
13276
13380
  const parts = [];
13277
13381
  for (const prop of expr.properties) {
13278
- if (!ts12.isPropertyAssignment(prop))
13382
+ if (!ts13.isPropertyAssignment(prop))
13279
13383
  return null;
13280
- if (!ts12.isIdentifier(prop.name) && !ts12.isStringLiteral(prop.name))
13384
+ if (!ts13.isIdentifier(prop.name) && !ts13.isStringLiteral(prop.name))
13281
13385
  return null;
13282
- if (!ts12.isStringLiteral(prop.initializer))
13386
+ if (!ts13.isStringLiteral(prop.initializer))
13283
13387
  return null;
13284
13388
  const key = cssKebabCase(prop.name.text);
13285
13389
  parts.push(`${key}:${prop.initializer.text}`);
@@ -13292,7 +13396,7 @@ function parseTemplateLiteral(expr, ctx) {
13292
13396
  parts.push({ type: "string", value: expr.head.text });
13293
13397
  }
13294
13398
  for (const span of expr.templateSpans) {
13295
- if (ts12.isConditionalExpression(span.expression)) {
13399
+ if (ts13.isConditionalExpression(span.expression)) {
13296
13400
  const ternary = parseTernary(span.expression, ctx);
13297
13401
  if (ternary) {
13298
13402
  parts.push(ternary);
@@ -13318,7 +13422,7 @@ function parseTemplateLiteral(expr, ctx) {
13318
13422
  return parts;
13319
13423
  }
13320
13424
  function tryResolveTemplateSpanFromConst(expr, ctx) {
13321
- if (ts12.isIdentifier(expr)) {
13425
+ if (ts13.isIdentifier(expr)) {
13322
13426
  if (ctx.scope.isBound(expr.text))
13323
13427
  return null;
13324
13428
  const constInfo = findLocalConst(expr.text, ctx.analyzer);
@@ -13327,13 +13431,13 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
13327
13431
  const ast = parseConstInitializer(constInfo);
13328
13432
  if (!ast)
13329
13433
  return null;
13330
- if (ts12.isStringLiteral(ast) || ts12.isNoSubstitutionTemplateLiteral(ast)) {
13434
+ if (ts13.isStringLiteral(ast) || ts13.isNoSubstitutionTemplateLiteral(ast)) {
13331
13435
  return [{ type: "string", value: ast.text }];
13332
13436
  }
13333
13437
  return null;
13334
13438
  }
13335
- if (ts12.isElementAccessExpression(expr)) {
13336
- if (!ts12.isIdentifier(expr.expression))
13439
+ if (ts13.isElementAccessExpression(expr)) {
13440
+ if (!ts13.isIdentifier(expr.expression))
13337
13441
  return null;
13338
13442
  if (ctx.scope.isBound(expr.expression.text))
13339
13443
  return null;
@@ -13341,17 +13445,17 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
13341
13445
  if (!constInfo)
13342
13446
  return null;
13343
13447
  const ast = parseConstInitializer(constInfo);
13344
- if (!ast || !ts12.isObjectLiteralExpression(ast))
13448
+ if (!ast || !ts13.isObjectLiteralExpression(ast))
13345
13449
  return null;
13346
13450
  const cases = {};
13347
13451
  for (const prop of ast.properties) {
13348
- if (!ts12.isPropertyAssignment(prop))
13452
+ if (!ts13.isPropertyAssignment(prop))
13349
13453
  return null;
13350
- const keyName = prop.name && (ts12.isStringLiteral(prop.name) || ts12.isIdentifier(prop.name)) ? prop.name.text : null;
13454
+ const keyName = prop.name && (ts13.isStringLiteral(prop.name) || ts13.isIdentifier(prop.name)) ? prop.name.text : null;
13351
13455
  if (!keyName)
13352
13456
  return null;
13353
13457
  const value = prop.initializer;
13354
- if (ts12.isStringLiteral(value) || ts12.isNoSubstitutionTemplateLiteral(value)) {
13458
+ if (ts13.isStringLiteral(value) || ts13.isNoSubstitutionTemplateLiteral(value)) {
13355
13459
  cases[keyName] = value.text;
13356
13460
  } else {
13357
13461
  return null;
@@ -13398,17 +13502,17 @@ function hasDynamicTagBinding(name, sourceFile) {
13398
13502
  const visit2 = (node) => {
13399
13503
  if (found)
13400
13504
  return;
13401
- if (ts12.isVariableDeclaration(node) && ts12.isIdentifier(node.name) && node.name.text === name && node.initializer) {
13505
+ if (ts13.isVariableDeclaration(node) && ts13.isIdentifier(node.name) && node.name.text === name && node.initializer) {
13402
13506
  let init = node.initializer;
13403
- while (ts12.isAsExpression(init) || ts12.isSatisfiesExpression(init) || ts12.isParenthesizedExpression(init) || ts12.isNonNullExpression(init)) {
13507
+ while (ts13.isAsExpression(init) || ts13.isSatisfiesExpression(init) || ts13.isParenthesizedExpression(init) || ts13.isNonNullExpression(init)) {
13404
13508
  init = init.expression;
13405
13509
  }
13406
- if (ts12.isPropertyAccessExpression(init) && init.name.text === "tag") {
13510
+ if (ts13.isPropertyAccessExpression(init) && init.name.text === "tag") {
13407
13511
  found = true;
13408
13512
  return;
13409
13513
  }
13410
13514
  }
13411
- ts12.forEachChild(node, visit2);
13515
+ ts13.forEachChild(node, visit2);
13412
13516
  };
13413
13517
  visit2(sourceFile);
13414
13518
  return found;
@@ -13422,13 +13526,13 @@ function tryResolveIdentifierAsTemplateLiteral(ident, ctx) {
13422
13526
  const ast = parseConstInitializer(constInfo);
13423
13527
  if (!ast)
13424
13528
  return null;
13425
- if (ts12.isNoSubstitutionTemplateLiteral(ast) || ts12.isStringLiteral(ast)) {
13529
+ if (ts13.isNoSubstitutionTemplateLiteral(ast) || ts13.isStringLiteral(ast)) {
13426
13530
  return [{ type: "string", value: ast.text }];
13427
13531
  }
13428
- if (ts12.isElementAccessExpression(ast) && !ts12.isStringLiteralLike(ast.argumentExpression) && !ts12.isNumericLiteral(ast.argumentExpression)) {
13532
+ if (ts13.isElementAccessExpression(ast) && !ts13.isStringLiteralLike(ast.argumentExpression) && !ts13.isNumericLiteral(ast.argumentExpression)) {
13429
13533
  return tryResolveTemplateSpanFromConst(ast, ctx);
13430
13534
  }
13431
- if (!ts12.isTemplateExpression(ast))
13535
+ if (!ts13.isTemplateExpression(ast))
13432
13536
  return null;
13433
13537
  let resolvedAny = false;
13434
13538
  const parts = [];
@@ -13466,14 +13570,14 @@ function parseConstInitializerImpl(c) {
13466
13570
  if (!c.value)
13467
13571
  return null;
13468
13572
  const wrapped = `const __bf_resolve__ = (${c.value})`;
13469
- const sf = ts12.createSourceFile("__bf_resolve.ts", wrapped, ts12.ScriptTarget.Latest, true, ts12.ScriptKind.TS);
13573
+ const sf = ts13.createSourceFile("__bf_resolve.ts", wrapped, ts13.ScriptTarget.Latest, true, ts13.ScriptKind.TS);
13470
13574
  const stmt = sf.statements[0];
13471
- if (!stmt || !ts12.isVariableStatement(stmt))
13575
+ if (!stmt || !ts13.isVariableStatement(stmt))
13472
13576
  return null;
13473
13577
  const decl = stmt.declarationList.declarations[0];
13474
13578
  if (!decl?.initializer)
13475
13579
  return null;
13476
- return ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13580
+ return ts13.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13477
13581
  }
13478
13582
  function astText(node) {
13479
13583
  return node.getText(node.getSourceFile());
@@ -13493,9 +13597,9 @@ function parseFunctionInfoAsExprImpl(fn) {
13493
13597
  const params = fn.typedParams !== undefined ? fn.typedParams : fn.params.map(formatParamWithType).join(", ");
13494
13598
  const body = fn.typedBody ?? fn.body;
13495
13599
  const wrapped = `const __bf_resolve_fn__ = function(${params}) ${body}`;
13496
- const sf = ts12.createSourceFile("__bf_resolve_fn.ts", wrapped, ts12.ScriptTarget.Latest, true, ts12.ScriptKind.TS);
13600
+ const sf = ts13.createSourceFile("__bf_resolve_fn.ts", wrapped, ts13.ScriptTarget.Latest, true, ts13.ScriptKind.TS);
13497
13601
  const stmt = sf.statements[0];
13498
- if (!stmt || !ts12.isVariableStatement(stmt))
13602
+ if (!stmt || !ts13.isVariableStatement(stmt))
13499
13603
  return null;
13500
13604
  const decl = stmt.declarationList.declarations[0];
13501
13605
  if (!decl?.initializer)
@@ -13503,9 +13607,9 @@ function parseFunctionInfoAsExprImpl(fn) {
13503
13607
  return decl.initializer;
13504
13608
  }
13505
13609
  function tryDesugarInterleaveTaggedTemplate(expr, ctx) {
13506
- if (!ts12.isTaggedTemplateExpression(expr))
13610
+ if (!ts13.isTaggedTemplateExpression(expr))
13507
13611
  return expr;
13508
- if (!ts12.isIdentifier(expr.tag))
13612
+ if (!ts13.isIdentifier(expr.tag))
13509
13613
  return expr;
13510
13614
  const resolvedTag = resolveInterleaveTagIdentifier(expr.tag.text, ctx);
13511
13615
  if (!resolvedTag)
@@ -13522,23 +13626,23 @@ function resolveInterleaveTagIdentifier(name, ctx) {
13522
13626
  return null;
13523
13627
  if (constInfo) {
13524
13628
  const ast = parseConstInitializer(constInfo);
13525
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
13629
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
13526
13630
  }
13527
13631
  if (fnInfo) {
13528
13632
  const ast = parseFunctionInfoAsExpr(fnInfo);
13529
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
13633
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
13530
13634
  }
13531
13635
  return null;
13532
13636
  }
13533
13637
  function isInterleaveTagFunction(fn) {
13534
- if (!ts12.isArrowFunction(fn) && !ts12.isFunctionExpression(fn))
13638
+ if (!ts13.isArrowFunction(fn) && !ts13.isFunctionExpression(fn))
13535
13639
  return false;
13536
13640
  if (fn.parameters.length !== 2)
13537
13641
  return false;
13538
13642
  const [partsParam, argsParam] = fn.parameters;
13539
- if (!ts12.isIdentifier(partsParam.name) || partsParam.dotDotDotToken)
13643
+ if (!ts13.isIdentifier(partsParam.name) || partsParam.dotDotDotToken)
13540
13644
  return false;
13541
- if (!ts12.isIdentifier(argsParam.name) || !argsParam.dotDotDotToken)
13645
+ if (!ts13.isIdentifier(argsParam.name) || !argsParam.dotDotDotToken)
13542
13646
  return false;
13543
13647
  const parsed = tsNodeToParsedExpr(fn);
13544
13648
  if (parsed.kind !== "arrow")
@@ -13595,7 +13699,7 @@ function isInterleaveSpanExpr(expr, i, argsName) {
13595
13699
  function buildUntaggedTemplateLiteral(node, ctx) {
13596
13700
  const template = node.template;
13597
13701
  let text;
13598
- if (ts12.isNoSubstitutionTemplateLiteral(template)) {
13702
+ if (ts13.isNoSubstitutionTemplateLiteral(template)) {
13599
13703
  text = "`" + (template.rawText ?? template.text) + "`";
13600
13704
  } else {
13601
13705
  let body = template.head.rawText ?? template.head.text;
@@ -13607,15 +13711,15 @@ function buildUntaggedTemplateLiteral(node, ctx) {
13607
13711
  text = "`" + body + "`";
13608
13712
  }
13609
13713
  const wrapped = `const __bf_resolve_tagged__ = (${text})`;
13610
- const sf = ts12.createSourceFile("__bf_resolve_tagged.tsx", wrapped, ts12.ScriptTarget.Latest, true, ts12.ScriptKind.TSX);
13714
+ const sf = ts13.createSourceFile("__bf_resolve_tagged.tsx", wrapped, ts13.ScriptTarget.Latest, true, ts13.ScriptKind.TSX);
13611
13715
  const stmt = sf.statements[0];
13612
- if (!stmt || !ts12.isVariableStatement(stmt))
13716
+ if (!stmt || !ts13.isVariableStatement(stmt))
13613
13717
  return null;
13614
13718
  const decl = stmt.declarationList.declarations[0];
13615
13719
  if (!decl?.initializer)
13616
13720
  return null;
13617
- const result = ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13618
- if (!ts12.isTemplateExpression(result) && !ts12.isNoSubstitutionTemplateLiteral(result))
13721
+ const result = ts13.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13722
+ if (!ts13.isTemplateExpression(result) && !ts13.isNoSubstitutionTemplateLiteral(result))
13619
13723
  return null;
13620
13724
  return result;
13621
13725
  }
@@ -13635,10 +13739,10 @@ function parseTernary(expr, ctx) {
13635
13739
  return null;
13636
13740
  }
13637
13741
  function getStringValue(node) {
13638
- if (ts12.isStringLiteral(node)) {
13742
+ if (ts13.isStringLiteral(node)) {
13639
13743
  return node.text;
13640
13744
  }
13641
- if (ts12.isNoSubstitutionTemplateLiteral(node)) {
13745
+ if (ts13.isNoSubstitutionTemplateLiteral(node)) {
13642
13746
  return node.text;
13643
13747
  }
13644
13748
  return null;
@@ -13646,19 +13750,19 @@ function getStringValue(node) {
13646
13750
  function processComponentProps(attributes, ctx) {
13647
13751
  const props = [];
13648
13752
  for (const attr of attributes.properties) {
13649
- if (ts12.isJsxSpreadAttribute(attr)) {
13753
+ if (ts13.isJsxSpreadAttribute(attr)) {
13650
13754
  props.push(...expandSpreadAttribute(attr, ctx));
13651
13755
  continue;
13652
13756
  }
13653
- if (!ts12.isJsxAttribute(attr))
13757
+ if (!ts13.isJsxAttribute(attr))
13654
13758
  continue;
13655
13759
  const name = attr.name.getText(ctx.sourceFile);
13656
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13760
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13657
13761
  let jsxExpr = attr.initializer.expression;
13658
- while (ts12.isParenthesizedExpression(jsxExpr)) {
13762
+ while (ts13.isParenthesizedExpression(jsxExpr)) {
13659
13763
  jsxExpr = jsxExpr.expression;
13660
13764
  }
13661
- if (ts12.isJsxElement(jsxExpr) || ts12.isJsxSelfClosingElement(jsxExpr) || ts12.isJsxFragment(jsxExpr)) {
13765
+ if (ts13.isJsxElement(jsxExpr) || ts13.isJsxSelfClosingElement(jsxExpr) || ts13.isJsxFragment(jsxExpr)) {
13662
13766
  const prevInsideComponentChildren = ctx.insideComponentChildren;
13663
13767
  ctx.insideComponentChildren = true;
13664
13768
  const irNode = transformNode(jsxExpr, ctx);
@@ -13685,7 +13789,7 @@ function processComponentProps(attributes, ctx) {
13685
13789
  value = AttrValueOf.booleanShorthand();
13686
13790
  }
13687
13791
  let clientOnly;
13688
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13792
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13689
13793
  if (value.kind === "expression" && value.templateExpr === undefined) {
13690
13794
  const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
13691
13795
  if (rewritten !== value.expr) {
@@ -13709,7 +13813,7 @@ function processComponentProps(attributes, ctx) {
13709
13813
  return props;
13710
13814
  }
13711
13815
  function checkBareSignalOrMemoIdentifier(expr, ctx) {
13712
- if (!ts12.isIdentifier(expr))
13816
+ if (!ts13.isIdentifier(expr))
13713
13817
  return;
13714
13818
  const name = expr.text;
13715
13819
  for (const signal of ctx.analyzer.signals) {
@@ -13740,12 +13844,12 @@ function checkBareSignalOrMemoIdentifier(expr, ctx) {
13740
13844
  function isArrayExprDirectPropRef(arrayExpr, ctx) {
13741
13845
  const propNames = new Set(ctx.patterns.props.map((p) => p.name));
13742
13846
  const propsObjName = ctx.analyzer.propsObjectName;
13743
- if (ts12.isIdentifier(arrayExpr)) {
13847
+ if (ts13.isIdentifier(arrayExpr)) {
13744
13848
  return propNames.has(arrayExpr.text);
13745
13849
  }
13746
- if (ts12.isPropertyAccessExpression(arrayExpr) && propsObjName) {
13850
+ if (ts13.isPropertyAccessExpression(arrayExpr) && propsObjName) {
13747
13851
  const obj = arrayExpr.expression;
13748
- if (ts12.isIdentifier(obj) && obj.text === propsObjName) {
13852
+ if (ts13.isIdentifier(obj) && obj.text === propsObjName) {
13749
13853
  return true;
13750
13854
  }
13751
13855
  }
@@ -13767,7 +13871,7 @@ function referencesLoopParam(expr, ctx) {
13767
13871
  if (boundNames.size === 0)
13768
13872
  return false;
13769
13873
  for (const p of boundNames) {
13770
- if (new RegExp(`\\b${p}\\b`).test(expr))
13874
+ if (identifierPattern(p).test(expr))
13771
13875
  return true;
13772
13876
  }
13773
13877
  return false;
@@ -13849,7 +13953,7 @@ function hasReactiveAttributes(attrs, ctx) {
13849
13953
  const scopeValueNames = ctx.scope.valueBoundNames();
13850
13954
  if (scopeValueNames.size > 0) {
13851
13955
  for (const p of scopeValueNames) {
13852
- if (new RegExp(`\\b${p}\\b`).test(valueToCheck))
13956
+ if (identifierPattern(p).test(valueToCheck))
13853
13957
  return true;
13854
13958
  }
13855
13959
  }
@@ -13940,7 +14044,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
13940
14044
  jsxBranchLocalNames.add(n);
13941
14045
  }
13942
14046
  for (const decl of condReturn.scopeVariables) {
13943
- if (ts12.isIdentifier(decl.name) && decl.initializer) {
14047
+ if (ts13.isIdentifier(decl.name) && decl.initializer) {
13944
14048
  branchScopeVars.set(decl.name.text, decl.initializer);
13945
14049
  if (initializerShapeContainsJsx(decl.initializer)) {
13946
14050
  jsxBranchLocalNames.add(decl.name.text);
@@ -14007,7 +14111,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
14007
14111
  }
14008
14112
  const scopeVariables = [];
14009
14113
  for (const decl of condReturn.scopeVariables) {
14010
- if (ts12.isIdentifier(decl.name) && decl.initializer) {
14114
+ if (ts13.isIdentifier(decl.name) && decl.initializer) {
14011
14115
  const init = ctx.getJS(decl.initializer);
14012
14116
  const typedInit = decl.initializer.getText(ctx.sourceFile);
14013
14117
  scopeVariables.push({
@@ -14055,18 +14159,22 @@ function buildIfStatementChain(analyzer, ctx, opts) {
14055
14159
  }
14056
14160
 
14057
14161
  // src/ir-to-client-js/prop-handling.ts
14058
- function expandDynamicPropValue(value, ctx) {
14162
+ function expandDynamicPropValue(value, ctx, scope) {
14059
14163
  const trimmedValue = value.trim();
14164
+ if (scope?.isBound(trimmedValue))
14165
+ return value;
14060
14166
  const constant = ctx.localConstants.find((c) => c.name === trimmedValue);
14061
14167
  if (constant && constant.value) {
14062
14168
  return constant.value;
14063
14169
  }
14064
14170
  return value;
14065
14171
  }
14066
- function expandConstantForReactivity(expr, ctx, originalFreeIds) {
14172
+ function expandConstantForReactivity(expr, ctx, originalFreeIds, scope) {
14067
14173
  if (ctx.propsObjectName)
14068
14174
  return { expr, freeIds: originalFreeIds };
14069
14175
  const trimmedValue = expr.trim();
14176
+ if (scope?.isBound(trimmedValue))
14177
+ return { expr, freeIds: originalFreeIds };
14070
14178
  const constant = ctx.localConstants.find((c) => c.name === trimmedValue);
14071
14179
  if (constant && constant.value) {
14072
14180
  return { expr: constant.value, freeIds: constant.freeIdentifiers };
@@ -14102,6 +14210,16 @@ function getControlledPropName(signal, propsParams, propsObjectName = null) {
14102
14210
  }
14103
14211
 
14104
14212
  // src/ir-to-client-js/reactivity.ts
14213
+ function buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex) {
14214
+ if (!loopParam)
14215
+ return;
14216
+ return BindingScope.EMPTY.enterLoopRow({
14217
+ param: loopParam,
14218
+ paramBindings: loopParamBindings,
14219
+ index: loopIndex,
14220
+ preamble: preambleNames && preambleNames.size > 0 ? { declaredNames: [...preambleNames] } : undefined
14221
+ });
14222
+ }
14105
14223
  function decideWrapFromAstFlags(node) {
14106
14224
  if (node.origin && isReactiveOrigin(node.origin)) {
14107
14225
  return { wrap: true, reason: "proven-reactive" };
@@ -14130,12 +14248,12 @@ function decideWrapForChildProp(expandedValue, ctx, prop) {
14130
14248
  }
14131
14249
  function needsEffectWrapper(expr, ctx, freeIdentifiers2) {
14132
14250
  for (const signal of ctx.signals) {
14133
- if (new RegExp(`\\b${signal.getter}\\s*\\(`).test(expr)) {
14251
+ if (identifierCallPattern(signal.getter).test(expr)) {
14134
14252
  return true;
14135
14253
  }
14136
14254
  }
14137
14255
  for (const memo of ctx.memos) {
14138
- if (new RegExp(`\\b${memo.name}\\s*\\(`).test(expr)) {
14256
+ if (identifierCallPattern(memo.name).test(expr)) {
14139
14257
  return true;
14140
14258
  }
14141
14259
  }
@@ -14325,8 +14443,9 @@ function traverseForComponents(node, components, skipConditionals = false) {
14325
14443
  }
14326
14444
  });
14327
14445
  }
14328
- function collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false) {
14446
+ function collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex) {
14329
14447
  const texts = [];
14448
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
14330
14449
  walkIR(node, false, {
14331
14450
  ...stopAt("loop", "async", "ifStatement"),
14332
14451
  expression: ({ node: n, scope: insideConditional }) => {
@@ -14335,7 +14454,7 @@ function collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings,
14335
14454
  if (n.preambleRegion)
14336
14455
  return;
14337
14456
  const originFreeIds = freeIdsFromRefs(n.origin?.freeRefs);
14338
- const expanded = expandConstantForReactivity(n.expr, ctx, originFreeIds);
14457
+ const expanded = expandConstantForReactivity(n.expr, ctx, originFreeIds, scope);
14339
14458
  const reactive = classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind !== "none" || decideWrapFromAstFlags(n).wrap;
14340
14459
  if (!reactive)
14341
14460
  return;
@@ -14359,8 +14478,9 @@ function anyNameIn(names, set) {
14359
14478
  return true;
14360
14479
  return false;
14361
14480
  }
14362
- function collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames) {
14481
+ function collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings, stopAtReactiveConditionals = false, preambleNames, loopIndex) {
14363
14482
  const attrs = [];
14483
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
14364
14484
  traverseElements(node, (el) => {
14365
14485
  if (el.slotId) {
14366
14486
  for (const attr of el.attrs) {
@@ -14373,7 +14493,7 @@ function collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings,
14373
14493
  const valueStr = attrValueToString(attr.value);
14374
14494
  if (!valueStr)
14375
14495
  continue;
14376
- const expanded = expandConstantForReactivity(valueStr, ctx, attr.freeIdentifiers);
14496
+ const expanded = expandConstantForReactivity(valueStr, ctx, attr.freeIdentifiers, scope);
14377
14497
  const readsPreamble = preambleNames !== undefined && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
14378
14498
  const reactive = classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind !== "none" || readsPreamble || attr.callsReactiveGetters || attr.hasFunctionCalls;
14379
14499
  if (!attr.clientOnly && !reactive)
@@ -14678,13 +14798,13 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
14678
14798
  const emitDepth = fixedDepth ?? scope.depth + 1;
14679
14799
  const loopParamsForTemplate = outerLoopParam ? [outerLoopParam, { param: n.param, bindings: n.paramBindings }] : undefined;
14680
14800
  const template = n.children.map((c) => irToPlaceholderTemplate(c, undefined, emitDepth, loopParamsForTemplate)).join("");
14681
- const refsOuter = outerLoopParam ? new RegExp(`\\b${outerLoopParam}\\b`).test(n.array) : false;
14801
+ const refsOuter = outerLoopParam ? identifierPattern(outerLoopParam).test(n.array) : false;
14682
14802
  const bindings = emptyLoopChildBindings();
14683
14803
  const innerPreambleNames = preambleNamesOf(n);
14684
14804
  if (ctx) {
14685
14805
  for (const child of n.children) {
14686
- bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx, n.param, n.paramBindings));
14687
- bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx, n.param, n.paramBindings, false, innerPreambleNames));
14806
+ bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx, n.param, n.paramBindings, false, innerPreambleNames, n.index));
14807
+ bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx, n.param, n.paramBindings, false, innerPreambleNames, n.index));
14688
14808
  bindings.refs.push(...collectLoopChildRefs(child));
14689
14809
  }
14690
14810
  }
@@ -14711,7 +14831,7 @@ function collectInnerLoops(nodes, siblingOffsets, outerLoopParam, ctx, options)
14711
14831
  bindings.events.push(...collectLoopChildEventsWithNesting(child));
14712
14832
  }
14713
14833
  if (ctx) {
14714
- bindings.conditionals.push(...collectLoopChildConditionals({ type: "fragment", children: n.children, loc: n.loc }, ctx, siblingOffsets, n.param, n.paramBindings));
14834
+ bindings.conditionals.push(...collectLoopChildConditionals({ type: "fragment", children: n.children, loc: n.loc }, ctx, siblingOffsets, n.param, n.paramBindings, innerPreambleNames, n.index));
14715
14835
  }
14716
14836
  }
14717
14837
  result.push({
@@ -14907,7 +15027,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
14907
15027
  return;
14908
15028
  const projectionInner = l.method === "flatMap" && l.children.length === 1 && l.children[0].type === "loop" ? l.children[0] : undefined;
14909
15029
  const childHandlers = [];
14910
- const bindings = projectionInner ? emptyLoopChildBindings() : collectLoopChildBindings(l.children, ctx, siblingOffsets, l.param, l.paramBindings, preambleNamesOf(l));
15030
+ const bindings = projectionInner ? emptyLoopChildBindings() : collectLoopChildBindings(l.children, ctx, siblingOffsets, l.param, l.paramBindings, preambleNamesOf(l), l.index);
14911
15031
  if (!projectionInner) {
14912
15032
  for (const child of l.children) {
14913
15033
  childHandlers.push(...collectEventHandlersFromIR(child));
@@ -15162,7 +15282,7 @@ function collectBranchLoops(node, ctx, siblingOffsets) {
15162
15282
  } else {
15163
15283
  childTemplate = n.children.map((c) => irToHtmlTemplate(c, undefined, 0, branchLoopParamSpec)).join("");
15164
15284
  }
15165
- const branchBindings = ctx && !projectionInner ? collectLoopChildBindings(n.children, ctx, siblingOffsets, n.param, n.paramBindings, preambleNamesOf(n)) : emptyLoopChildBindings();
15285
+ const branchBindings = ctx && !projectionInner ? collectLoopChildBindings(n.children, ctx, siblingOffsets, n.param, n.paramBindings, preambleNamesOf(n), n.index) : emptyLoopChildBindings();
15166
15286
  loops.push({
15167
15287
  kind: "branch",
15168
15288
  array: n.array,
@@ -15248,19 +15368,20 @@ function preambleNamesOf(loop) {
15248
15368
  const declared = loop.preamble?.declaredNames;
15249
15369
  return declared && declared.length > 0 ? new Set(declared) : undefined;
15250
15370
  }
15251
- function collectLoopChildBindings(children, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames) {
15371
+ function collectLoopChildBindings(children, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex) {
15252
15372
  const bindings = emptyLoopChildBindings();
15253
15373
  for (const child of children) {
15254
15374
  bindings.events.push(...collectLoopChildEventsWithNesting(child));
15255
- bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx, loopParam, loopParamBindings, true, preambleNames));
15256
- bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx, loopParam, loopParamBindings, true));
15375
+ bindings.reactiveAttrs.push(...collectLoopChildReactiveAttrs(child, ctx, loopParam, loopParamBindings, true, preambleNames, loopIndex));
15376
+ bindings.reactiveTexts.push(...collectLoopChildReactiveTexts(child, ctx, loopParam, loopParamBindings, true, preambleNames, loopIndex));
15257
15377
  bindings.refs.push(...collectLoopChildRefs(child));
15258
- bindings.conditionals.push(...collectLoopChildConditionals(child, ctx, siblingOffsets, loopParam, loopParamBindings));
15378
+ bindings.conditionals.push(...collectLoopChildConditionals(child, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex));
15259
15379
  }
15260
15380
  return bindings;
15261
15381
  }
15262
- function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loopParamBindings) {
15382
+ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex) {
15263
15383
  const conditionals = [];
15384
+ const scope = buildLoopRowScope(loopParam, loopParamBindings, preambleNames, loopIndex);
15264
15385
  const refsAnyBindingViaFreeIds = (freeIds) => {
15265
15386
  if (loopParamBindings && loopParamBindings.length > 0) {
15266
15387
  for (const b of loopParamBindings) {
@@ -15280,8 +15401,9 @@ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loop
15280
15401
  const refsLoopParamInSource = refsAnyBindingViaFreeIds(sourceFreeIds);
15281
15402
  if (!n.reactive && !refsLoopParamInSource)
15282
15403
  return;
15283
- const expanded = expandConstantForReactivity(n.condition, ctx, sourceFreeIds);
15284
- if (classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind === "none")
15404
+ const expanded = expandConstantForReactivity(n.condition, ctx, sourceFreeIds, scope);
15405
+ const readsPreamble = preambleNames !== undefined && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
15406
+ if (!readsPreamble && classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind === "none")
15285
15407
  return;
15286
15408
  const loopParamsForCond = loopParam ? [{ param: loopParam, bindings: loopParamBindings }] : undefined;
15287
15409
  const whenTrueHtml = irToHtmlTemplate(n.whenTrue, undefined, 0, loopParamsForCond, "__slots");
@@ -15291,23 +15413,24 @@ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loop
15291
15413
  condition: expanded.expr,
15292
15414
  whenTrueHtml,
15293
15415
  whenFalseHtml,
15294
- whenTrue: summarizeLoopChildBranch(n.whenTrue, ctx, siblingOffsets, loopParam, loopParamBindings),
15295
- whenFalse: summarizeLoopChildBranch(n.whenFalse, ctx, siblingOffsets, loopParam, loopParamBindings),
15296
- ...expanded.freeIds !== undefined && { conditionFreeIdentifiers: expanded.freeIds }
15416
+ whenTrue: summarizeLoopChildBranch(n.whenTrue, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex),
15417
+ whenFalse: summarizeLoopChildBranch(n.whenFalse, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex),
15418
+ ...expanded.freeIds !== undefined && { conditionFreeIdentifiers: expanded.freeIds },
15419
+ ...readsPreamble && { readsPreamble: true }
15297
15420
  });
15298
15421
  }
15299
15422
  });
15300
15423
  return conditionals;
15301
15424
  }
15302
- function summarizeLoopChildBranch(node, ctx, siblingOffsets, loopParam, loopParamBindings) {
15425
+ function summarizeLoopChildBranch(node, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex) {
15303
15426
  const inner = collectInnerLoops([node], siblingOffsets, loopParam, ctx, branchInnerLoopOptions);
15304
15427
  return {
15305
15428
  childComponents: collectConditionalBranchChildComponents(node),
15306
15429
  innerLoops: inner.length > 0 ? inner : undefined,
15307
- conditionals: collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loopParamBindings),
15430
+ conditionals: collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex),
15308
15431
  events: collectConditionalBranchEvents(node),
15309
- reactiveAttrs: collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings, true),
15310
- reactiveTexts: node.type === "expression" && node.hasFunctionCalls ? [] : collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings, true)
15432
+ reactiveAttrs: collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings, true, preambleNames, loopIndex),
15433
+ reactiveTexts: node.type === "expression" && node.hasFunctionCalls ? [] : collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings, true, preambleNames, loopIndex)
15311
15434
  };
15312
15435
  }
15313
15436
 
@@ -15669,7 +15792,7 @@ function graphDeclarationReferences(graph, kind, name) {
15669
15792
  }
15670
15793
 
15671
15794
  // src/ir-to-client-js/walk-prop-accesses.ts
15672
- import ts13 from "typescript";
15795
+ import ts14 from "typescript";
15673
15796
  function collectPropAccesses(source, propNames, out) {
15674
15797
  if (propNames.size === 0)
15675
15798
  return;
@@ -15683,7 +15806,7 @@ function collectPropAccesses(source, propNames, out) {
15683
15806
  if (!anyMentioned)
15684
15807
  return;
15685
15808
  for (const expr of normaliseExpressionParts(source)) {
15686
- const sourceFile = ts13.createSourceFile("p.ts", expr, ts13.ScriptTarget.Latest, false, ts13.ScriptKind.TS);
15809
+ const sourceFile = ts14.createSourceFile("p.ts", expr, ts14.ScriptTarget.Latest, false, ts14.ScriptKind.TS);
15687
15810
  visit2(sourceFile, propNames, out);
15688
15811
  }
15689
15812
  }
@@ -15693,15 +15816,15 @@ function normaliseExpressionParts(source) {
15693
15816
  return extractTemplateExpressions(source);
15694
15817
  }
15695
15818
  function visit2(node, propNames, out) {
15696
- if (ts13.isPropertyAccessExpression(node)) {
15819
+ if (ts14.isPropertyAccessExpression(node)) {
15697
15820
  recordIfPropAccess(node.expression, "property", propNames, out);
15698
- } else if (ts13.isElementAccessExpression(node)) {
15821
+ } else if (ts14.isElementAccessExpression(node)) {
15699
15822
  recordIfPropAccess(node.expression, "index", propNames, out);
15700
15823
  }
15701
- ts13.forEachChild(node, (child) => visit2(child, propNames, out));
15824
+ ts14.forEachChild(node, (child) => visit2(child, propNames, out));
15702
15825
  }
15703
15826
  function recordIfPropAccess(receiver, kind, propNames, out) {
15704
- if (!ts13.isIdentifier(receiver))
15827
+ if (!ts14.isIdentifier(receiver))
15705
15828
  return;
15706
15829
  const name = receiver.text;
15707
15830
  if (!propNames.has(name))
@@ -15754,56 +15877,56 @@ function propHasPropertyAccess(u) {
15754
15877
  }
15755
15878
 
15756
15879
  // src/value-references.ts
15757
- import ts14 from "typescript";
15880
+ import ts15 from "typescript";
15758
15881
  function isValueReferenceIdentifier(id) {
15759
15882
  const parent = id.parent;
15760
15883
  if (!parent)
15761
15884
  return false;
15762
- if (ts14.isPropertyAccessExpression(parent) && parent.name === id)
15885
+ if (ts15.isPropertyAccessExpression(parent) && parent.name === id)
15763
15886
  return false;
15764
- if (ts14.isPropertyAssignment(parent) && parent.name === id)
15887
+ if (ts15.isPropertyAssignment(parent) && parent.name === id)
15765
15888
  return false;
15766
- if ((ts14.isMethodDeclaration(parent) || ts14.isGetAccessorDeclaration(parent) || ts14.isSetAccessorDeclaration(parent)) && parent.name === id) {
15889
+ if ((ts15.isMethodDeclaration(parent) || ts15.isGetAccessorDeclaration(parent) || ts15.isSetAccessorDeclaration(parent)) && parent.name === id) {
15767
15890
  return false;
15768
15891
  }
15769
- if (ts14.isPropertyDeclaration(parent) && parent.name === id)
15892
+ if (ts15.isPropertyDeclaration(parent) && parent.name === id)
15770
15893
  return false;
15771
- if (ts14.isMetaProperty(parent) && parent.name === id)
15894
+ if (ts15.isMetaProperty(parent) && parent.name === id)
15772
15895
  return false;
15773
- if (ts14.isVariableDeclaration(parent) && parent.name === id)
15896
+ if (ts15.isVariableDeclaration(parent) && parent.name === id)
15774
15897
  return false;
15775
- if (ts14.isFunctionDeclaration(parent) && parent.name === id)
15898
+ if (ts15.isFunctionDeclaration(parent) && parent.name === id)
15776
15899
  return false;
15777
- if (ts14.isFunctionExpression(parent) && parent.name === id)
15900
+ if (ts15.isFunctionExpression(parent) && parent.name === id)
15778
15901
  return false;
15779
- if (ts14.isClassDeclaration(parent) && parent.name === id)
15902
+ if (ts15.isClassDeclaration(parent) && parent.name === id)
15780
15903
  return false;
15781
- if (ts14.isClassExpression(parent) && parent.name === id)
15904
+ if (ts15.isClassExpression(parent) && parent.name === id)
15782
15905
  return false;
15783
- if (ts14.isParameter(parent) && parent.name === id)
15906
+ if (ts15.isParameter(parent) && parent.name === id)
15784
15907
  return false;
15785
- if (ts14.isBindingElement(parent) && (parent.name === id || parent.propertyName === id))
15908
+ if (ts15.isBindingElement(parent) && (parent.name === id || parent.propertyName === id))
15786
15909
  return false;
15787
- if (ts14.isLabeledStatement(parent) && parent.label === id)
15910
+ if (ts15.isLabeledStatement(parent) && parent.label === id)
15788
15911
  return false;
15789
- if (ts14.isBreakOrContinueStatement(parent) && parent.label === id)
15912
+ if (ts15.isBreakOrContinueStatement(parent) && parent.label === id)
15790
15913
  return false;
15791
- if (ts14.isImportSpecifier(parent) && (parent.name === id || parent.propertyName === id))
15914
+ if (ts15.isImportSpecifier(parent) && (parent.name === id || parent.propertyName === id))
15792
15915
  return false;
15793
- if (ts14.isExportSpecifier(parent) && (parent.name === id || parent.propertyName === id))
15916
+ if (ts15.isExportSpecifier(parent) && (parent.name === id || parent.propertyName === id))
15794
15917
  return false;
15795
- if (ts14.isImportClause(parent) && parent.name === id)
15918
+ if (ts15.isImportClause(parent) && parent.name === id)
15796
15919
  return false;
15797
- if (ts14.isNamespaceImport(parent) && parent.name === id)
15920
+ if (ts15.isNamespaceImport(parent) && parent.name === id)
15798
15921
  return false;
15799
- if (ts14.isQualifiedName(parent) && parent.right === id)
15922
+ if (ts15.isQualifiedName(parent) && parent.right === id)
15800
15923
  return false;
15801
15924
  return true;
15802
15925
  }
15803
15926
  function collectValueReferencedNames(code) {
15804
15927
  let sourceFile;
15805
15928
  try {
15806
- sourceFile = ts14.createSourceFile("generated.js", code, ts14.ScriptTarget.Latest, true, ts14.ScriptKind.JS);
15929
+ sourceFile = ts15.createSourceFile("generated.js", code, ts15.ScriptTarget.Latest, true, ts15.ScriptKind.JS);
15807
15930
  } catch {
15808
15931
  return null;
15809
15932
  }
@@ -15812,10 +15935,10 @@ function collectValueReferencedNames(code) {
15812
15935
  return null;
15813
15936
  const names = new Set;
15814
15937
  function visit3(node) {
15815
- if (ts14.isIdentifier(node) && isValueReferenceIdentifier(node)) {
15938
+ if (ts15.isIdentifier(node) && isValueReferenceIdentifier(node)) {
15816
15939
  names.add(node.text);
15817
15940
  }
15818
- ts14.forEachChild(node, visit3);
15941
+ ts15.forEachChild(node, visit3);
15819
15942
  }
15820
15943
  visit3(sourceFile);
15821
15944
  return names;
@@ -15879,7 +16002,7 @@ var MODULE_CONSTANTS_PLACEHOLDER = "/* __MODULE_LEVEL_CONSTANTS__ */";
15879
16002
  function detectUsedImports(code) {
15880
16003
  const used = new Set;
15881
16004
  for (const name of RUNTIME_IMPORT_CANDIDATES) {
15882
- if (new RegExp(`\\b${name}\\s*\\(`).test(code)) {
16005
+ if (identifierCallPattern(name).test(code)) {
15883
16006
  used.add(name);
15884
16007
  }
15885
16008
  }
@@ -15983,7 +16106,7 @@ function collectComponentNames(node) {
15983
16106
  }
15984
16107
 
15985
16108
  // src/relocate.ts
15986
- import ts15 from "typescript";
16109
+ import ts16 from "typescript";
15987
16110
 
15988
16111
  // src/lowering-registry.ts
15989
16112
  var plugins = [];
@@ -16029,19 +16152,19 @@ function classify(name, env) {
16029
16152
  function collectFreeRefs(node) {
16030
16153
  const refs = new Map;
16031
16154
  function visit3(n, parent) {
16032
- if (ts15.isIdentifier(n)) {
16033
- if (parent && ts15.isPropertyAccessExpression(parent) && parent.name === n)
16155
+ if (ts16.isIdentifier(n)) {
16156
+ if (parent && ts16.isPropertyAccessExpression(parent) && parent.name === n)
16034
16157
  return;
16035
- if (parent && ts15.isPropertyAssignment(parent) && parent.name === n)
16158
+ if (parent && ts16.isPropertyAssignment(parent) && parent.name === n)
16036
16159
  return;
16037
- if (parent && ts15.isShorthandPropertyAssignment(parent) && parent.name === n)
16160
+ if (parent && ts16.isShorthandPropertyAssignment(parent) && parent.name === n)
16038
16161
  return;
16039
16162
  const list = refs.get(n.text) ?? [];
16040
16163
  list.push(n);
16041
16164
  refs.set(n.text, list);
16042
16165
  return;
16043
16166
  }
16044
- ts15.forEachChild(n, (child) => visit3(child, n));
16167
+ ts16.forEachChild(n, (child) => visit3(child, n));
16045
16168
  }
16046
16169
  visit3(node);
16047
16170
  return refs;
@@ -16145,11 +16268,11 @@ function isInlinableInTemplate(value, env) {
16145
16268
  return { ok: true, rewrittenValue: r.text, decisions: r.decisions };
16146
16269
  }
16147
16270
  function getCalleeIdentifierPath(callee) {
16148
- if (ts15.isParenthesizedExpression(callee))
16271
+ if (ts16.isParenthesizedExpression(callee))
16149
16272
  return getCalleeIdentifierPath(callee.expression);
16150
- if (ts15.isIdentifier(callee))
16273
+ if (ts16.isIdentifier(callee))
16151
16274
  return callee.text;
16152
- if (ts15.isPropertyAccessExpression(callee)) {
16275
+ if (ts16.isPropertyAccessExpression(callee)) {
16153
16276
  const left = getCalleeIdentifierPath(callee.expression);
16154
16277
  if (left === null)
16155
16278
  return null;
@@ -16158,11 +16281,11 @@ function getCalleeIdentifierPath(callee) {
16158
16281
  return null;
16159
16282
  }
16160
16283
  function getCalleeLeftmostIdentifier(callee) {
16161
- if (ts15.isParenthesizedExpression(callee))
16284
+ if (ts16.isParenthesizedExpression(callee))
16162
16285
  return getCalleeLeftmostIdentifier(callee.expression);
16163
- if (ts15.isIdentifier(callee))
16286
+ if (ts16.isIdentifier(callee))
16164
16287
  return callee.text;
16165
- if (ts15.isPropertyAccessExpression(callee)) {
16288
+ if (ts16.isPropertyAccessExpression(callee)) {
16166
16289
  return getCalleeLeftmostIdentifier(callee.expression);
16167
16290
  }
16168
16291
  return null;
@@ -16210,12 +16333,12 @@ function isCallAcceptedByAdapter(call, env) {
16210
16333
  }
16211
16334
  function parseExpressionNode(text) {
16212
16335
  try {
16213
- const sf = ts15.createSourceFile("__inline_check__.ts", `(${text});`, ts15.ScriptTarget.Latest, false, ts15.ScriptKind.TS);
16336
+ const sf = ts16.createSourceFile("__inline_check__.ts", `(${text});`, ts16.ScriptTarget.Latest, false, ts16.ScriptKind.TS);
16214
16337
  const stmt = sf.statements[0];
16215
- if (!stmt || !ts15.isExpressionStatement(stmt))
16338
+ if (!stmt || !ts16.isExpressionStatement(stmt))
16216
16339
  return null;
16217
16340
  const inner = stmt.expression;
16218
- return ts15.isParenthesizedExpression(inner) ? inner.expression : inner;
16341
+ return ts16.isParenthesizedExpression(inner) ? inner.expression : inner;
16219
16342
  } catch {
16220
16343
  return null;
16221
16344
  }
@@ -16232,8 +16355,8 @@ function hasCallWithBridgedArg(node, decisions, env) {
16232
16355
  function visit3(n) {
16233
16356
  if (found)
16234
16357
  return;
16235
- if (ts15.isCallExpression(n) || ts15.isNewExpression(n)) {
16236
- const accepted = ts15.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
16358
+ if (ts16.isCallExpression(n) || ts16.isNewExpression(n)) {
16359
+ const accepted = ts16.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
16237
16360
  if (!accepted) {
16238
16361
  const args = n.arguments;
16239
16362
  if (args) {
@@ -16246,7 +16369,7 @@ function hasCallWithBridgedArg(node, decisions, env) {
16246
16369
  }
16247
16370
  }
16248
16371
  }
16249
- ts15.forEachChild(n, visit3);
16372
+ ts16.forEachChild(n, visit3);
16250
16373
  }
16251
16374
  visit3(node);
16252
16375
  return found;
@@ -16256,13 +16379,13 @@ function hasZeroArgCall(node, env) {
16256
16379
  function visit3(n) {
16257
16380
  if (found)
16258
16381
  return;
16259
- if (ts15.isCallExpression(n) && n.arguments.length === 0) {
16382
+ if (ts16.isCallExpression(n) && n.arguments.length === 0) {
16260
16383
  if (!isCallAcceptedByAdapter(n, env)) {
16261
16384
  found = true;
16262
16385
  return;
16263
16386
  }
16264
16387
  }
16265
- ts15.forEachChild(n, visit3);
16388
+ ts16.forEachChild(n, visit3);
16266
16389
  }
16267
16390
  visit3(node);
16268
16391
  return found;
@@ -16272,25 +16395,25 @@ function containsAnyIdentifier(node, names) {
16272
16395
  function visit3(n) {
16273
16396
  if (found)
16274
16397
  return;
16275
- if (ts15.isPropertyAccessExpression(n)) {
16398
+ if (ts16.isPropertyAccessExpression(n)) {
16276
16399
  visit3(n.expression);
16277
16400
  return;
16278
16401
  }
16279
- if (ts15.isPropertyAssignment(n)) {
16402
+ if (ts16.isPropertyAssignment(n)) {
16280
16403
  visit3(n.initializer);
16281
16404
  return;
16282
16405
  }
16283
- if (ts15.isShorthandPropertyAssignment(n)) {
16284
- if (ts15.isIdentifier(n.name) && names.has(n.name.text)) {
16406
+ if (ts16.isShorthandPropertyAssignment(n)) {
16407
+ if (ts16.isIdentifier(n.name) && names.has(n.name.text)) {
16285
16408
  found = true;
16286
16409
  }
16287
16410
  return;
16288
16411
  }
16289
- if (ts15.isIdentifier(n) && names.has(n.text)) {
16412
+ if (ts16.isIdentifier(n) && names.has(n.text)) {
16290
16413
  found = true;
16291
16414
  return;
16292
16415
  }
16293
- ts15.forEachChild(n, visit3);
16416
+ ts16.forEachChild(n, visit3);
16294
16417
  }
16295
16418
  visit3(node);
16296
16419
  return found;
@@ -16298,7 +16421,7 @@ function containsAnyIdentifier(node, names) {
16298
16421
  function scanRefsByName(text, bindings) {
16299
16422
  const result = new Map;
16300
16423
  for (const name of bindings.keys()) {
16301
- const re = new RegExp(`\\b${name}\\b`);
16424
+ const re = identifierPattern(name);
16302
16425
  if (re.test(text))
16303
16426
  result.set(name, []);
16304
16427
  }
@@ -17593,23 +17716,23 @@ function resolveFinalImports(generatedCode, ir, localImportPrefixes) {
17593
17716
  }
17594
17717
 
17595
17718
  // src/ir-to-client-js/prune-unused-prop-extractions.ts
17596
- import ts16 from "typescript";
17719
+ import ts17 from "typescript";
17597
17720
  function propExtractionName(stmt) {
17598
- if (!ts16.isVariableStatement(stmt))
17721
+ if (!ts17.isVariableStatement(stmt))
17599
17722
  return null;
17600
17723
  const decls = stmt.declarationList.declarations;
17601
17724
  if (decls.length !== 1)
17602
17725
  return null;
17603
17726
  const decl = decls[0];
17604
- if (!ts16.isIdentifier(decl.name) || !decl.initializer)
17727
+ if (!ts17.isIdentifier(decl.name) || !decl.initializer)
17605
17728
  return null;
17606
17729
  let core = decl.initializer;
17607
- if (ts16.isBinaryExpression(core) && core.operatorToken.kind === ts16.SyntaxKind.QuestionQuestionToken) {
17730
+ if (ts17.isBinaryExpression(core) && core.operatorToken.kind === ts17.SyntaxKind.QuestionQuestionToken) {
17608
17731
  core = core.left;
17609
17732
  }
17610
- if (!ts16.isPropertyAccessExpression(core))
17733
+ if (!ts17.isPropertyAccessExpression(core))
17611
17734
  return null;
17612
- if (!ts16.isIdentifier(core.expression) || core.expression.text !== PROPS_PARAM)
17735
+ if (!ts17.isIdentifier(core.expression) || core.expression.text !== PROPS_PARAM)
17613
17736
  return null;
17614
17737
  if (core.name.text !== decl.name.text)
17615
17738
  return null;
@@ -17622,10 +17745,10 @@ function pruneUnusedPropExtractions(code) {
17622
17745
  console.warn("[barefootjs] pruneUnusedPropExtractions: generated code did not parse; skipping prune");
17623
17746
  return code;
17624
17747
  }
17625
- const sourceFile = ts16.createSourceFile("generated.js", code, ts16.ScriptTarget.Latest, false, ts16.ScriptKind.JS);
17748
+ const sourceFile = ts17.createSourceFile("generated.js", code, ts17.ScriptTarget.Latest, false, ts17.ScriptKind.JS);
17626
17749
  const spans = [];
17627
17750
  for (const stmt of sourceFile.statements) {
17628
- if (!ts16.isFunctionDeclaration(stmt) || !stmt.name?.text.startsWith("init") || !stmt.body)
17751
+ if (!ts17.isFunctionDeclaration(stmt) || !stmt.name?.text.startsWith("init") || !stmt.body)
17629
17752
  continue;
17630
17753
  for (const inner of stmt.body.statements) {
17631
17754
  const name = propExtractionName(inner);
@@ -18589,7 +18712,8 @@ function buildReactiveEffectsPlan(args) {
18589
18712
  whenTrueTemplateHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
18590
18713
  whenFalseTemplateHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId),
18591
18714
  whenTrueArm: buildOuterArm(cond.whenTrue, wrap, loopParam, loopParamBindings, profileComponentName),
18592
- whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, profileComponentName)
18715
+ whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, profileComponentName),
18716
+ ...cond.readsPreamble && { readsPreamble: true }
18593
18717
  });
18594
18718
  }
18595
18719
  }
@@ -18992,7 +19116,7 @@ function buildStaticArrayDelegationPlan(elem, profileComponentName) {
18992
19116
  function buildKeyedOrIndexLookup(args) {
18993
19117
  const hasBindings = (args.paramBindings?.length ?? 0) > 0;
18994
19118
  if (args.key !== null) {
18995
- const keyWithItem = hasBindings ? substituteLoopBindings(args.key, args.paramBindings, "item") : args.key.replace(new RegExp(`\\b${args.param}\\b`, "g"), "item");
19119
+ const keyWithItem = hasBindings ? substituteLoopBindings(args.key, args.paramBindings, "item") : args.key.replace(identifierPattern(args.param, "g"), "item");
18996
19120
  return {
18997
19121
  kind: "keyed",
18998
19122
  arrayExpr: args.array,
@@ -19070,7 +19194,7 @@ function analyzeLazyConditional(cond, indexParam, arms) {
19070
19194
  }
19071
19195
 
19072
19196
  // src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
19073
- import ts17 from "typescript";
19197
+ import ts18 from "typescript";
19074
19198
  var NO_PREAMBLE = {
19075
19199
  lazySafe: true,
19076
19200
  facts: { declaredNames: new Set, freeNames: new Set }
@@ -19090,12 +19214,12 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19090
19214
  if (text.trim().length === 0)
19091
19215
  return NO_PREAMBLE;
19092
19216
  const declaredNames = new Set;
19093
- const sf = ts17.createSourceFile("__lazy_preamble__.ts", text, ts17.ScriptTarget.Latest, true, ts17.ScriptKind.TS);
19217
+ const sf = ts18.createSourceFile("__lazy_preamble__.ts", text, ts18.ScriptTarget.Latest, true, ts18.ScriptKind.TS);
19094
19218
  for (const stmt of sf.statements) {
19095
- if (!ts17.isVariableStatement(stmt)) {
19096
- return NO2(`map-callback preamble has a non-declaration statement (${ts17.SyntaxKind[stmt.kind]})`);
19219
+ if (!ts18.isVariableStatement(stmt)) {
19220
+ return NO2(`map-callback preamble has a non-declaration statement (${ts18.SyntaxKind[stmt.kind]})`);
19097
19221
  }
19098
- const isConst = (stmt.declarationList.flags & ts17.NodeFlags.Const) !== 0;
19222
+ const isConst = (stmt.declarationList.flags & ts18.NodeFlags.Const) !== 0;
19099
19223
  if (!isConst)
19100
19224
  return NO2("map-callback preamble declares a mutable binding (let/var)");
19101
19225
  for (const decl of stmt.declarationList.declarations) {
@@ -19124,12 +19248,12 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19124
19248
  return { lazySafe: true, facts: { declaredNames, freeNames } };
19125
19249
  }
19126
19250
  function collectBindingNames3(name, out) {
19127
- if (ts17.isIdentifier(name)) {
19251
+ if (ts18.isIdentifier(name)) {
19128
19252
  out.add(name.text);
19129
19253
  return;
19130
19254
  }
19131
19255
  for (const element of name.elements) {
19132
- if (ts17.isOmittedExpression(element))
19256
+ if (ts18.isOmittedExpression(element))
19133
19257
  continue;
19134
19258
  collectBindingNames3(element.name, out);
19135
19259
  }
@@ -19139,56 +19263,56 @@ function findImpureNode(root, primableNames) {
19139
19263
  const visit3 = (node) => {
19140
19264
  if (found)
19141
19265
  return;
19142
- if (ts17.isCallExpression(node)) {
19266
+ if (ts18.isCallExpression(node)) {
19143
19267
  const callee = node.expression;
19144
- const isSignalRead = ts17.isIdentifier(callee) && primableNames.has(callee.text) && node.arguments.length === 0 && node.questionDotToken === undefined;
19268
+ const isSignalRead = ts18.isIdentifier(callee) && primableNames.has(callee.text) && node.arguments.length === 0 && node.questionDotToken === undefined;
19145
19269
  if (!isSignalRead) {
19146
19270
  found = `call to ${callee.getText(callee.getSourceFile())}`;
19147
19271
  return;
19148
19272
  }
19149
19273
  }
19150
- if (ts17.isNewExpression(node)) {
19274
+ if (ts18.isNewExpression(node)) {
19151
19275
  found = "new expression";
19152
19276
  return;
19153
19277
  }
19154
- if (ts17.isTaggedTemplateExpression(node)) {
19278
+ if (ts18.isTaggedTemplateExpression(node)) {
19155
19279
  found = "tagged template";
19156
19280
  return;
19157
19281
  }
19158
- if (ts17.isAwaitExpression(node)) {
19282
+ if (ts18.isAwaitExpression(node)) {
19159
19283
  found = "await";
19160
19284
  return;
19161
19285
  }
19162
- if (ts17.isYieldExpression(node)) {
19286
+ if (ts18.isYieldExpression(node)) {
19163
19287
  found = "yield";
19164
19288
  return;
19165
19289
  }
19166
- if (ts17.isPrefixUnaryExpression(node) || ts17.isPostfixUnaryExpression(node)) {
19290
+ if (ts18.isPrefixUnaryExpression(node) || ts18.isPostfixUnaryExpression(node)) {
19167
19291
  const op = node.operator;
19168
- if (op === ts17.SyntaxKind.PlusPlusToken || op === ts17.SyntaxKind.MinusMinusToken) {
19292
+ if (op === ts18.SyntaxKind.PlusPlusToken || op === ts18.SyntaxKind.MinusMinusToken) {
19169
19293
  found = "increment/decrement";
19170
19294
  return;
19171
19295
  }
19172
19296
  }
19173
- if (ts17.isDeleteExpression(node)) {
19297
+ if (ts18.isDeleteExpression(node)) {
19174
19298
  found = "delete";
19175
19299
  return;
19176
19300
  }
19177
- if (ts17.isFunctionExpression(node) || ts17.isArrowFunction(node) || ts17.isClassExpression(node)) {
19301
+ if (ts18.isFunctionExpression(node) || ts18.isArrowFunction(node) || ts18.isClassExpression(node)) {
19178
19302
  found = "function or class expression";
19179
19303
  return;
19180
19304
  }
19181
- if (ts17.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
19305
+ if (ts18.isBinaryExpression(node) && isAssignmentOperator2(node.operatorToken.kind)) {
19182
19306
  found = "assignment";
19183
19307
  return;
19184
19308
  }
19185
- ts17.forEachChild(node, visit3);
19309
+ ts18.forEachChild(node, visit3);
19186
19310
  };
19187
19311
  visit3(root);
19188
19312
  return found;
19189
19313
  }
19190
- function isAssignmentOperator(kind) {
19191
- return kind >= ts17.SyntaxKind.FirstAssignment && kind <= ts17.SyntaxKind.LastAssignment;
19314
+ function isAssignmentOperator2(kind) {
19315
+ return kind >= ts18.SyntaxKind.FirstAssignment && kind <= ts18.SyntaxKind.LastAssignment;
19192
19316
  }
19193
19317
 
19194
19318
  // src/ir-to-client-js/control-flow/plan/lazy-row-eligibility.ts
@@ -19718,7 +19842,7 @@ function buildArmBody(branch, options) {
19718
19842
  }
19719
19843
 
19720
19844
  // src/ir-to-client-js/emit-reactive.ts
19721
- import ts18 from "typescript";
19845
+ import ts19 from "typescript";
19722
19846
 
19723
19847
  // src/ir-to-client-js/control-flow/stringify/claim-plan.ts
19724
19848
  function slotSpecLiteral(slot) {
@@ -19822,20 +19946,20 @@ function lowerToLocaleCallsInReactiveExpr(expr, matcher) {
19822
19946
  return expr;
19823
19947
  let sourceFile;
19824
19948
  try {
19825
- sourceFile = ts18.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts18.ScriptTarget.Latest, true, ts18.ScriptKind.TS);
19949
+ sourceFile = ts19.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts19.ScriptTarget.Latest, true, ts19.ScriptKind.TS);
19826
19950
  } catch {
19827
19951
  return expr;
19828
19952
  }
19829
19953
  const stmt = sourceFile.statements[0];
19830
- if (!stmt || !ts18.isExpressionStatement(stmt))
19954
+ if (!stmt || !ts19.isExpressionStatement(stmt))
19831
19955
  return expr;
19832
- const root = ts18.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19956
+ const root = ts19.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19833
19957
  const candidates = [];
19834
19958
  const visit3 = (n) => {
19835
- if (ts18.isCallExpression(n) && n.arguments.length === 2 && ts18.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
19959
+ if (ts19.isCallExpression(n) && n.arguments.length === 2 && ts19.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
19836
19960
  candidates.push(n);
19837
19961
  }
19838
- ts18.forEachChild(n, visit3);
19962
+ ts19.forEachChild(n, visit3);
19839
19963
  };
19840
19964
  visit3(root);
19841
19965
  if (candidates.length === 0)
@@ -19871,20 +19995,20 @@ function lowerDateCallsInReactiveExpr(expr, matcher) {
19871
19995
  return expr;
19872
19996
  let sourceFile;
19873
19997
  try {
19874
- sourceFile = ts18.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts18.ScriptTarget.Latest, true, ts18.ScriptKind.TS);
19998
+ sourceFile = ts19.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts19.ScriptTarget.Latest, true, ts19.ScriptKind.TS);
19875
19999
  } catch {
19876
20000
  return expr;
19877
20001
  }
19878
20002
  const stmt = sourceFile.statements[0];
19879
- if (!stmt || !ts18.isExpressionStatement(stmt))
20003
+ if (!stmt || !ts19.isExpressionStatement(stmt))
19880
20004
  return expr;
19881
- const root = ts18.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20005
+ const root = ts19.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19882
20006
  const candidates = [];
19883
20007
  const visit3 = (n) => {
19884
- if (ts18.isCallExpression(n) && n.arguments.length === 0 && ts18.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
20008
+ if (ts19.isCallExpression(n) && n.arguments.length === 0 && ts19.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
19885
20009
  candidates.push(n);
19886
20010
  }
19887
- ts18.forEachChild(n, visit3);
20011
+ ts19.forEachChild(n, visit3);
19888
20012
  };
19889
20013
  visit3(root);
19890
20014
  if (candidates.length === 0)
@@ -20199,7 +20323,7 @@ function stringifyReactiveEffects(lines, plan, opts) {
20199
20323
  emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, outerTexts, elementIndexBySlot, textClaimPathExprs, preambleRegions, mapPreambleWrapped);
20200
20324
  }
20201
20325
  for (const cond of conditionals) {
20202
- emitOuterConditional(lines, indent, elVar, cond, pc);
20326
+ emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped);
20203
20327
  }
20204
20328
  }
20205
20329
  function emitAttrSlotsGranular(lines, indent, elVar, lookup, attrSlots, elementIndexBySlot, bindingBfId, mapPreambleWrapped) {
@@ -20301,9 +20425,10 @@ function emitOuterTexts(lines, indent, elVar, texts, bindingBfId, textClaimPathE
20301
20425
  lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', String(${text.wrappedExpression})) }${bindingBfId(text.slotId)})`);
20302
20426
  }
20303
20427
  }
20304
- function emitOuterConditional(lines, indent, elVar, cond, pc) {
20428
+ function emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped) {
20305
20429
  const armIndent = `${indent} `;
20306
- lines.push(`${indent}insert(${elVar}, '${cond.slotId}', () => ${cond.wrappedCondition}, {`);
20430
+ const conditionGetter = cond.readsPreamble && mapPreambleWrapped ? `() => { ${mapPreambleWrapped}; return (${cond.wrappedCondition}) }` : `() => ${cond.wrappedCondition}`;
20431
+ lines.push(`${indent}insert(${elVar}, '${cond.slotId}', ${conditionGetter}, {`);
20307
20432
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenTrueTemplateHtml}\`, slots: __slots } },`);
20308
20433
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
20309
20434
  stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc);
@@ -21198,7 +21323,7 @@ function emitKeyedLookup(ls, ev, handlerCall, lookup) {
21198
21323
  }
21199
21324
  for (const nested of ev.nestedLoops) {
21200
21325
  const rawKey = nested.key ?? "";
21201
- const innerKeyExpr = nested.paramBindings && nested.paramBindings.length > 0 ? substituteLoopBindings(rawKey, nested.paramBindings, "item") : rawKey.replace(new RegExp(`\\b${nested.param}\\b`, "g"), "item");
21326
+ const innerKeyExpr = nested.paramBindings && nested.paramBindings.length > 0 ? substituteLoopBindings(rawKey, nested.paramBindings, "item") : rawKey.replace(identifierPattern(nested.param, "g"), "item");
21202
21327
  const outerRef = hasBindings ? "__bfLoopItem" : param;
21203
21328
  ls.push(` const ${nested.param} = ${outerRef} && ${nested.array}.find(item => String(${innerKeyExpr}) === innerKey${nested.depth})`);
21204
21329
  }
@@ -21887,20 +22012,20 @@ var PHASES = [
21887
22012
  ];
21888
22013
 
21889
22014
  // src/ir-to-client-js/rewrite-props-object.ts
21890
- import ts19 from "typescript";
22015
+ import ts20 from "typescript";
21891
22016
  function rewritePropsObjectRef(code, propsObjectName) {
21892
22017
  const srcPropsName = propsObjectName ?? "props";
21893
22018
  if (srcPropsName === PROPS_PARAM)
21894
22019
  return code;
21895
- if (!new RegExp(`\\b${srcPropsName}\\b`).test(code))
22020
+ if (!identifierPattern(srcPropsName).test(code))
21896
22021
  return code;
21897
- const sourceFile = ts19.createSourceFile("init-body.ts", code, ts19.ScriptTarget.Latest, true, ts19.ScriptKind.TS);
22022
+ const sourceFile = ts20.createSourceFile("init-body.ts", code, ts20.ScriptTarget.Latest, true, ts20.ScriptKind.TS);
21898
22023
  const spans = [];
21899
22024
  function visit3(node) {
21900
- if (ts19.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
22025
+ if (ts20.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
21901
22026
  spans.push([node.getStart(sourceFile), node.getEnd()]);
21902
22027
  }
21903
- ts19.forEachChild(node, visit3);
22028
+ ts20.forEachChild(node, visit3);
21904
22029
  }
21905
22030
  visit3(sourceFile);
21906
22031
  if (spans.length === 0)
@@ -21916,17 +22041,17 @@ function shouldRewrite(node) {
21916
22041
  const parent = node.parent;
21917
22042
  if (!parent)
21918
22043
  return true;
21919
- if (ts19.isPropertyAccessExpression(parent) && parent.name === node)
22044
+ if (ts20.isPropertyAccessExpression(parent) && parent.name === node)
21920
22045
  return false;
21921
- if (ts19.isPropertyAssignment(parent) && parent.name === node)
22046
+ if (ts20.isPropertyAssignment(parent) && parent.name === node)
21922
22047
  return false;
21923
- if (ts19.isShorthandPropertyAssignment(parent) && parent.name === node)
22048
+ if (ts20.isShorthandPropertyAssignment(parent) && parent.name === node)
21924
22049
  return false;
21925
- if (ts19.isPropertySignature(parent) && parent.name === node)
22050
+ if (ts20.isPropertySignature(parent) && parent.name === node)
21926
22051
  return false;
21927
- if (ts19.isPropertyDeclaration(parent) && parent.name === node)
22052
+ if (ts20.isPropertyDeclaration(parent) && parent.name === node)
21928
22053
  return false;
21929
- if (ts19.isBindingElement(parent) && parent.name === node)
22054
+ if (ts20.isBindingElement(parent) && parent.name === node)
21930
22055
  return false;
21931
22056
  return true;
21932
22057
  }
@@ -22578,7 +22703,7 @@ function walkIR2(node, visitor) {
22578
22703
  }
22579
22704
 
22580
22705
  // src/preprocess-inline-jsx-callbacks.ts
22581
- import ts20 from "typescript";
22706
+ import ts21 from "typescript";
22582
22707
  var SYNTHETIC_PREFIX = "BFInlineJsxCallback";
22583
22708
  var MAX_FIXPOINT_ITERATIONS = 16;
22584
22709
  function preprocessInlineJsxCallbacks(source, filePath) {
@@ -22600,8 +22725,8 @@ function preprocessInlineJsxCallbacks(source, filePath) {
22600
22725
  return { source: current, errors, syntheticNames };
22601
22726
  }
22602
22727
  function runSinglePass(source, filePath, startingCounter) {
22603
- const sourceFile = ts20.createSourceFile(filePath, source, ts20.ScriptTarget.Latest, true, ts20.ScriptKind.TSX);
22604
- const hasUseClient = sourceFile.statements.some((stmt) => ts20.isExpressionStatement(stmt) && ts20.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
22728
+ const sourceFile = ts21.createSourceFile(filePath, source, ts21.ScriptTarget.Latest, true, ts21.ScriptKind.TSX);
22729
+ const hasUseClient = sourceFile.statements.some((stmt) => ts21.isExpressionStatement(stmt) && ts21.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
22605
22730
  if (!hasUseClient) {
22606
22731
  return { source, errors: [], syntheticNames: [], counterAfter: startingCounter };
22607
22732
  }
@@ -22623,22 +22748,22 @@ function runSinglePass(source, filePath, startingCounter) {
22623
22748
  }
22624
22749
  }
22625
22750
  function visit3(node) {
22626
- if (ts20.isJsxAttribute(node) && node.initializer && ts20.isJsxExpression(node.initializer) && node.initializer.expression) {
22751
+ if (ts21.isJsxAttribute(node) && node.initializer && ts21.isJsxExpression(node.initializer) && node.initializer.expression) {
22627
22752
  if (tryHandleArrowValue(node.initializer.expression)) {
22628
22753
  return;
22629
22754
  }
22630
22755
  }
22631
- if (ts20.isPropertyAssignment(node) && node.initializer) {
22756
+ if (ts21.isPropertyAssignment(node) && node.initializer) {
22632
22757
  if (tryHandleArrowValue(node.initializer))
22633
22758
  return;
22634
22759
  }
22635
- ts20.forEachChild(node, visit3);
22760
+ ts21.forEachChild(node, visit3);
22636
22761
  }
22637
22762
  function tryHandleArrowValue(initializer) {
22638
22763
  let expr = initializer;
22639
- while (ts20.isParenthesizedExpression(expr))
22764
+ while (ts21.isParenthesizedExpression(expr))
22640
22765
  expr = expr.expression;
22641
- if (ts20.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
22766
+ if (ts21.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
22642
22767
  return handleInlineArrow(expr);
22643
22768
  }
22644
22769
  return false;
@@ -22675,7 +22800,7 @@ function runSinglePass(source, filePath, startingCounter) {
22675
22800
  replacements.push({ start: arrowStart, end: arrowEnd, text: name });
22676
22801
  return true;
22677
22802
  }
22678
- ts20.forEachChild(sourceFile, visit3);
22803
+ ts21.forEachChild(sourceFile, visit3);
22679
22804
  if (replacements.length === 0) {
22680
22805
  return { source, errors, syntheticNames, counterAfter: counter };
22681
22806
  }
@@ -22698,11 +22823,11 @@ function errorMessageForCapture(captures) {
22698
22823
  return `Inline JSX-returning arrow function captures non-module identifier(s): ` + `${captures.sort().join(", ")}. ` + `Extract the callback into a top-level '\\'use client\\'' component (e.g. ` + `\`function MyNode(n) { return <div/> }\` then \`renderNode={MyNode}\`) ` + `or pass captured values via component props.`;
22699
22824
  }
22700
22825
  function arrowBodyContainsJsx(arrow) {
22701
- if (ts20.isBlock(arrow.body)) {
22826
+ if (ts21.isBlock(arrow.body)) {
22702
22827
  return blockReturnsJsx(arrow.body);
22703
22828
  }
22704
22829
  let body = arrow.body;
22705
- while (ts20.isParenthesizedExpression(body))
22830
+ while (ts21.isParenthesizedExpression(body))
22706
22831
  body = body.expression;
22707
22832
  return isJsxLike(body);
22708
22833
  }
@@ -22711,24 +22836,24 @@ function blockReturnsJsx(block) {
22711
22836
  function visit3(n) {
22712
22837
  if (found)
22713
22838
  return;
22714
- if (ts20.isReturnStatement(n) && n.expression) {
22839
+ if (ts21.isReturnStatement(n) && n.expression) {
22715
22840
  let e = n.expression;
22716
- while (ts20.isParenthesizedExpression(e))
22841
+ while (ts21.isParenthesizedExpression(e))
22717
22842
  e = e.expression;
22718
22843
  if (isJsxLike(e)) {
22719
22844
  found = true;
22720
22845
  return;
22721
22846
  }
22722
22847
  }
22723
- if (ts20.isArrowFunction(n) || ts20.isFunctionDeclaration(n) || ts20.isFunctionExpression(n))
22848
+ if (ts21.isArrowFunction(n) || ts21.isFunctionDeclaration(n) || ts21.isFunctionExpression(n))
22724
22849
  return;
22725
- ts20.forEachChild(n, visit3);
22850
+ ts21.forEachChild(n, visit3);
22726
22851
  }
22727
- ts20.forEachChild(block, visit3);
22852
+ ts21.forEachChild(block, visit3);
22728
22853
  return found;
22729
22854
  }
22730
22855
  function isJsxLike(expr) {
22731
- return ts20.isJsxElement(expr) || ts20.isJsxSelfClosingElement(expr) || ts20.isJsxFragment(expr);
22856
+ return ts21.isJsxElement(expr) || ts21.isJsxSelfClosingElement(expr) || ts21.isJsxFragment(expr);
22732
22857
  }
22733
22858
  function collectArrowParamNames(arrow) {
22734
22859
  const names = new Set;
@@ -22738,13 +22863,13 @@ function collectArrowParamNames(arrow) {
22738
22863
  }
22739
22864
  function collectBindingNames4(name, out) {
22740
22865
  const push = Array.isArray(out) ? (n) => out.push(n) : (n) => out.add(n);
22741
- if (ts20.isIdentifier(name)) {
22866
+ if (ts21.isIdentifier(name)) {
22742
22867
  push(name.text);
22743
- } else if (ts20.isObjectBindingPattern(name)) {
22868
+ } else if (ts21.isObjectBindingPattern(name)) {
22744
22869
  name.elements.forEach((el) => collectBindingNames4(el.name, out));
22745
- } else if (ts20.isArrayBindingPattern(name)) {
22870
+ } else if (ts21.isArrayBindingPattern(name)) {
22746
22871
  name.elements.forEach((el) => {
22747
- if (!ts20.isOmittedExpression(el))
22872
+ if (!ts21.isOmittedExpression(el))
22748
22873
  collectBindingNames4(el.name, out);
22749
22874
  });
22750
22875
  }
@@ -22771,48 +22896,48 @@ function collectFreeIdentifiers(arrow) {
22771
22896
  return bound.includes(name);
22772
22897
  }
22773
22898
  function visit3(node) {
22774
- if (ts20.isIdentifier(node)) {
22899
+ if (ts21.isIdentifier(node)) {
22775
22900
  const parent = node.parent;
22776
- if (parent && ts20.isPropertyAccessExpression(parent) && parent.name === node)
22901
+ if (parent && ts21.isPropertyAccessExpression(parent) && parent.name === node)
22777
22902
  return;
22778
- if (parent && ts20.isPropertyAssignment(parent) && parent.name === node)
22903
+ if (parent && ts21.isPropertyAssignment(parent) && parent.name === node)
22779
22904
  return;
22780
- if (parent && ts20.isPropertySignature(parent) && parent.name === node)
22905
+ if (parent && ts21.isPropertySignature(parent) && parent.name === node)
22781
22906
  return;
22782
- if (parent && ts20.isPropertyDeclaration(parent) && parent.name === node)
22907
+ if (parent && ts21.isPropertyDeclaration(parent) && parent.name === node)
22783
22908
  return;
22784
- if (parent && ts20.isMethodDeclaration(parent) && parent.name === node)
22909
+ if (parent && ts21.isMethodDeclaration(parent) && parent.name === node)
22785
22910
  return;
22786
- if (parent && ts20.isMethodSignature(parent) && parent.name === node)
22911
+ if (parent && ts21.isMethodSignature(parent) && parent.name === node)
22787
22912
  return;
22788
- if (parent && ts20.isGetAccessorDeclaration(parent) && parent.name === node)
22913
+ if (parent && ts21.isGetAccessorDeclaration(parent) && parent.name === node)
22789
22914
  return;
22790
- if (parent && ts20.isSetAccessorDeclaration(parent) && parent.name === node)
22915
+ if (parent && ts21.isSetAccessorDeclaration(parent) && parent.name === node)
22791
22916
  return;
22792
- if (parent && ts20.isEnumMember(parent) && parent.name === node)
22917
+ if (parent && ts21.isEnumMember(parent) && parent.name === node)
22793
22918
  return;
22794
- if (parent && ts20.isBindingElement(parent) && parent.propertyName === node)
22919
+ if (parent && ts21.isBindingElement(parent) && parent.propertyName === node)
22795
22920
  return;
22796
- if (parent && ts20.isShorthandPropertyAssignment(parent) && parent.name === node) {
22921
+ if (parent && ts21.isShorthandPropertyAssignment(parent) && parent.name === node) {
22797
22922
  if (!isBound(node.text))
22798
22923
  ids.add(node.text);
22799
22924
  return;
22800
22925
  }
22801
- if (parent && ts20.isParameter(parent) && parent.name === node)
22926
+ if (parent && ts21.isParameter(parent) && parent.name === node)
22802
22927
  return;
22803
- if (parent && ts20.isVariableDeclaration(parent) && parent.name === node)
22928
+ if (parent && ts21.isVariableDeclaration(parent) && parent.name === node)
22804
22929
  return;
22805
- if (parent && ts20.isFunctionDeclaration(parent) && parent.name === node)
22930
+ if (parent && ts21.isFunctionDeclaration(parent) && parent.name === node)
22806
22931
  return;
22807
- if (parent && ts20.isClassDeclaration(parent) && parent.name === node)
22932
+ if (parent && ts21.isClassDeclaration(parent) && parent.name === node)
22808
22933
  return;
22809
- if (parent && ts20.isJsxAttribute(parent) && parent.name === node)
22934
+ if (parent && ts21.isJsxAttribute(parent) && parent.name === node)
22810
22935
  return;
22811
- if (parent && ts20.isJsxOpeningElement(parent) && parent.tagName === node) {
22936
+ if (parent && ts21.isJsxOpeningElement(parent) && parent.tagName === node) {
22812
22937
  if (/^[a-z]/.test(node.text))
22813
22938
  return;
22814
22939
  }
22815
- if (parent && ts20.isJsxClosingElement(parent) && parent.tagName === node) {
22940
+ if (parent && ts21.isJsxClosingElement(parent) && parent.tagName === node) {
22816
22941
  if (/^[a-z]/.test(node.text))
22817
22942
  return;
22818
22943
  }
@@ -22821,43 +22946,43 @@ function collectFreeIdentifiers(arrow) {
22821
22946
  ids.add(node.text);
22822
22947
  return;
22823
22948
  }
22824
- if (ts20.isVariableDeclaration(node)) {
22949
+ if (ts21.isVariableDeclaration(node)) {
22825
22950
  const declared = pushBindings(node.name);
22826
22951
  if (node.initializer)
22827
22952
  visit3(node.initializer);
22828
22953
  return;
22829
22954
  }
22830
- if (ts20.isFunctionDeclaration(node)) {
22955
+ if (ts21.isFunctionDeclaration(node)) {
22831
22956
  if (node.name)
22832
22957
  bound.push(node.name.text);
22833
22958
  visitInsideNewScope(node);
22834
22959
  return;
22835
22960
  }
22836
- if (ts20.isClassDeclaration(node)) {
22961
+ if (ts21.isClassDeclaration(node)) {
22837
22962
  if (node.name)
22838
22963
  bound.push(node.name.text);
22839
- ts20.forEachChild(node, visit3);
22964
+ ts21.forEachChild(node, visit3);
22840
22965
  return;
22841
22966
  }
22842
- if (ts20.isArrowFunction(node) || ts20.isFunctionExpression(node)) {
22967
+ if (ts21.isArrowFunction(node) || ts21.isFunctionExpression(node)) {
22843
22968
  visitInsideNewScope(node);
22844
22969
  return;
22845
22970
  }
22846
- if (ts20.isCatchClause(node)) {
22971
+ if (ts21.isCatchClause(node)) {
22847
22972
  const before = bound.length;
22848
22973
  if (node.variableDeclaration)
22849
22974
  pushBindings(node.variableDeclaration.name);
22850
- ts20.forEachChild(node, visit3);
22975
+ ts21.forEachChild(node, visit3);
22851
22976
  popN(bound.length - before);
22852
22977
  return;
22853
22978
  }
22854
- if (ts20.isBlock(node)) {
22979
+ if (ts21.isBlock(node)) {
22855
22980
  const before = bound.length;
22856
- ts20.forEachChild(node, visit3);
22981
+ ts21.forEachChild(node, visit3);
22857
22982
  popN(bound.length - before);
22858
22983
  return;
22859
22984
  }
22860
- ts20.forEachChild(node, visit3);
22985
+ ts21.forEachChild(node, visit3);
22861
22986
  }
22862
22987
  function visitInsideNewScope(fn) {
22863
22988
  const before = bound.length;
@@ -22880,29 +23005,29 @@ function collectFreeIdentifiers(arrow) {
22880
23005
  function collectModuleScopeNames(sourceFile) {
22881
23006
  const names = new Set;
22882
23007
  for (const stmt of sourceFile.statements) {
22883
- if (ts20.isFunctionDeclaration(stmt) && stmt.name)
23008
+ if (ts21.isFunctionDeclaration(stmt) && stmt.name)
22884
23009
  names.add(stmt.name.text);
22885
- else if (ts20.isClassDeclaration(stmt) && stmt.name)
23010
+ else if (ts21.isClassDeclaration(stmt) && stmt.name)
22886
23011
  names.add(stmt.name.text);
22887
- else if (ts20.isVariableStatement(stmt)) {
23012
+ else if (ts21.isVariableStatement(stmt)) {
22888
23013
  for (const decl of stmt.declarationList.declarations)
22889
23014
  collectBindingNames4(decl.name, names);
22890
- } else if (ts20.isImportDeclaration(stmt) && stmt.importClause) {
23015
+ } else if (ts21.isImportDeclaration(stmt) && stmt.importClause) {
22891
23016
  const ic = stmt.importClause;
22892
23017
  if (ic.name)
22893
23018
  names.add(ic.name.text);
22894
23019
  if (ic.namedBindings) {
22895
- if (ts20.isNamespaceImport(ic.namedBindings))
23020
+ if (ts21.isNamespaceImport(ic.namedBindings))
22896
23021
  names.add(ic.namedBindings.name.text);
22897
23022
  else
22898
23023
  for (const e of ic.namedBindings.elements)
22899
23024
  names.add(e.name.text);
22900
23025
  }
22901
- } else if (ts20.isTypeAliasDeclaration(stmt))
23026
+ } else if (ts21.isTypeAliasDeclaration(stmt))
22902
23027
  names.add(stmt.name.text);
22903
- else if (ts20.isInterfaceDeclaration(stmt))
23028
+ else if (ts21.isInterfaceDeclaration(stmt))
22904
23029
  names.add(stmt.name.text);
22905
- else if (ts20.isEnumDeclaration(stmt))
23030
+ else if (ts21.isEnumDeclaration(stmt))
22906
23031
  names.add(stmt.name.text);
22907
23032
  }
22908
23033
  return names;
@@ -22910,7 +23035,7 @@ function collectModuleScopeNames(sourceFile) {
22910
23035
  function buildSyntheticDeclaration(name, arrow, sourceFile) {
22911
23036
  const paramsText = arrow.parameters.length === 0 ? "" : arrow.parameters.map((p) => p.getText(sourceFile)).join(", ");
22912
23037
  let bodyText;
22913
- if (ts20.isBlock(arrow.body)) {
23038
+ if (ts21.isBlock(arrow.body)) {
22914
23039
  bodyText = arrow.body.getText(sourceFile);
22915
23040
  } else {
22916
23041
  const expr = arrow.body.getText(sourceFile);
@@ -22920,7 +23045,7 @@ function buildSyntheticDeclaration(name, arrow, sourceFile) {
22920
23045
  }
22921
23046
 
22922
23047
  // src/ssr-defaults.ts
22923
- import ts21 from "typescript";
23048
+ import ts22 from "typescript";
22924
23049
  function deriveStashFromDefaults(defaults, props) {
22925
23050
  const extra = {};
22926
23051
  for (const [name, d] of Object.entries(defaults)) {
@@ -23016,11 +23141,11 @@ function collectPropRefs(expr, propsObjectName, out) {
23016
23141
  if (!node)
23017
23142
  return;
23018
23143
  const visit3 = (n) => {
23019
- if (ts21.isPropertyAccessExpression(n) && ts21.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts21.isIdentifier(n.name)) {
23144
+ if (ts22.isPropertyAccessExpression(n) && ts22.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts22.isIdentifier(n.name)) {
23020
23145
  out.add(n.name.text);
23021
23146
  return;
23022
23147
  }
23023
- ts21.forEachChild(n, visit3);
23148
+ ts22.forEachChild(n, visit3);
23024
23149
  };
23025
23150
  visit3(node);
23026
23151
  }
@@ -23041,23 +23166,23 @@ function tryStaticEval(expr, ctx) {
23041
23166
  }
23042
23167
  function evalStatementsForReturn(statements, ctx) {
23043
23168
  for (const stmt of statements) {
23044
- if (ts21.isVariableStatement(stmt)) {
23169
+ if (ts22.isVariableStatement(stmt)) {
23045
23170
  for (const d of stmt.declarationList.declarations) {
23046
- if (!ts21.isIdentifier(d.name) || !d.initializer)
23171
+ if (!ts22.isIdentifier(d.name) || !d.initializer)
23047
23172
  continue;
23048
23173
  const v = evalNode(d.initializer, ctx);
23049
23174
  if (v !== UNRESOLVED)
23050
23175
  ctx.bindings[d.name.text] = v;
23051
23176
  }
23052
- } else if (ts21.isReturnStatement(stmt)) {
23177
+ } else if (ts22.isReturnStatement(stmt)) {
23053
23178
  return stmt.expression ? evalNode(stmt.expression, ctx) : UNRESOLVED;
23054
- } else if (ts21.isIfStatement(stmt)) {
23179
+ } else if (ts22.isIfStatement(stmt)) {
23055
23180
  const cond = evalNode(stmt.expression, ctx);
23056
23181
  if (cond === UNRESOLVED)
23057
23182
  return UNRESOLVED;
23058
23183
  const branch = cond ? stmt.thenStatement : stmt.elseStatement;
23059
23184
  if (branch) {
23060
- const taken = evalStatementsForReturn(ts21.isBlock(branch) ? branch.statements : [branch], ctx);
23185
+ const taken = evalStatementsForReturn(ts22.isBlock(branch) ? branch.statements : [branch], ctx);
23061
23186
  if (taken !== NO_RETURN)
23062
23187
  return taken;
23063
23188
  }
@@ -23068,45 +23193,45 @@ function evalStatementsForReturn(statements, ctx) {
23068
23193
  return NO_RETURN;
23069
23194
  }
23070
23195
  function parseExpression2(expr) {
23071
- const sf = ts21.createSourceFile("__ssr_default__.ts", `(${expr})`, ts21.ScriptTarget.Latest, false, ts21.ScriptKind.TS);
23196
+ const sf = ts22.createSourceFile("__ssr_default__.ts", `(${expr})`, ts22.ScriptTarget.Latest, false, ts22.ScriptKind.TS);
23072
23197
  const stmt = sf.statements[0];
23073
- if (!stmt || !ts21.isExpressionStatement(stmt))
23198
+ if (!stmt || !ts22.isExpressionStatement(stmt))
23074
23199
  return null;
23075
- const inner = ts21.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
23200
+ const inner = ts22.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
23076
23201
  return inner;
23077
23202
  }
23078
23203
  function evalNode(node, ctx) {
23079
- if (ts21.isParenthesizedExpression(node))
23204
+ if (ts22.isParenthesizedExpression(node))
23080
23205
  return evalNode(node.expression, ctx);
23081
- if (ts21.isAsExpression(node))
23206
+ if (ts22.isAsExpression(node))
23082
23207
  return evalNode(node.expression, ctx);
23083
- if (ts21.isSatisfiesExpression(node))
23208
+ if (ts22.isSatisfiesExpression(node))
23084
23209
  return evalNode(node.expression, ctx);
23085
- if (ts21.isTypeAssertionExpression(node))
23210
+ if (ts22.isTypeAssertionExpression(node))
23086
23211
  return evalNode(node.expression, ctx);
23087
- if (ts21.isNonNullExpression(node))
23212
+ if (ts22.isNonNullExpression(node))
23088
23213
  return evalNode(node.expression, ctx);
23089
- if (ts21.isArrowFunction(node)) {
23214
+ if (ts22.isArrowFunction(node)) {
23090
23215
  if (node.parameters.length !== 0)
23091
23216
  return UNRESOLVED;
23092
- if (!ts21.isBlock(node.body))
23217
+ if (!ts22.isBlock(node.body))
23093
23218
  return evalNode(node.body, ctx);
23094
23219
  const localBindings = { ...ctx.bindings };
23095
23220
  const localCtx = { ...ctx, bindings: localBindings };
23096
23221
  const result = evalStatementsForReturn(node.body.statements, localCtx);
23097
23222
  return result === NO_RETURN ? UNRESOLVED : result;
23098
23223
  }
23099
- if (ts21.isNumericLiteral(node))
23224
+ if (ts22.isNumericLiteral(node))
23100
23225
  return Number(node.text);
23101
- if (ts21.isStringLiteralLike(node))
23226
+ if (ts22.isStringLiteralLike(node))
23102
23227
  return node.text;
23103
- if (node.kind === ts21.SyntaxKind.TrueKeyword)
23228
+ if (node.kind === ts22.SyntaxKind.TrueKeyword)
23104
23229
  return true;
23105
- if (node.kind === ts21.SyntaxKind.FalseKeyword)
23230
+ if (node.kind === ts22.SyntaxKind.FalseKeyword)
23106
23231
  return false;
23107
- if (node.kind === ts21.SyntaxKind.NullKeyword)
23232
+ if (node.kind === ts22.SyntaxKind.NullKeyword)
23108
23233
  return null;
23109
- if (ts21.isIdentifier(node)) {
23234
+ if (ts22.isIdentifier(node)) {
23110
23235
  if (node.text === "undefined")
23111
23236
  return;
23112
23237
  if (node.text in ctx.bindings)
@@ -23115,29 +23240,29 @@ function evalNode(node, ctx) {
23115
23240
  return;
23116
23241
  return UNRESOLVED;
23117
23242
  }
23118
- if (ts21.isPrefixUnaryExpression(node)) {
23243
+ if (ts22.isPrefixUnaryExpression(node)) {
23119
23244
  const arg = evalNode(node.operand, ctx);
23120
23245
  if (arg === UNRESOLVED)
23121
23246
  return UNRESOLVED;
23122
23247
  switch (node.operator) {
23123
- case ts21.SyntaxKind.MinusToken:
23248
+ case ts22.SyntaxKind.MinusToken:
23124
23249
  return typeof arg === "number" ? -arg : UNRESOLVED;
23125
- case ts21.SyntaxKind.PlusToken:
23250
+ case ts22.SyntaxKind.PlusToken:
23126
23251
  return typeof arg === "number" ? +arg : UNRESOLVED;
23127
- case ts21.SyntaxKind.ExclamationToken:
23252
+ case ts22.SyntaxKind.ExclamationToken:
23128
23253
  return !arg;
23129
23254
  }
23130
23255
  return UNRESOLVED;
23131
23256
  }
23132
- if (ts21.isObjectLiteralExpression(node)) {
23257
+ if (ts22.isObjectLiteralExpression(node)) {
23133
23258
  const obj = {};
23134
23259
  for (const prop of node.properties) {
23135
- if (!ts21.isPropertyAssignment(prop))
23260
+ if (!ts22.isPropertyAssignment(prop))
23136
23261
  return UNRESOLVED;
23137
23262
  let key;
23138
- if (ts21.isIdentifier(prop.name) || ts21.isStringLiteralLike(prop.name)) {
23263
+ if (ts22.isIdentifier(prop.name) || ts22.isStringLiteralLike(prop.name)) {
23139
23264
  key = prop.name.text;
23140
- } else if (ts21.isNumericLiteral(prop.name)) {
23265
+ } else if (ts22.isNumericLiteral(prop.name)) {
23141
23266
  key = prop.name.text;
23142
23267
  } else {
23143
23268
  return UNRESOLVED;
@@ -23149,10 +23274,10 @@ function evalNode(node, ctx) {
23149
23274
  }
23150
23275
  return obj;
23151
23276
  }
23152
- if (ts21.isArrayLiteralExpression(node)) {
23277
+ if (ts22.isArrayLiteralExpression(node)) {
23153
23278
  const arr = [];
23154
23279
  for (const elem of node.elements) {
23155
- if (ts21.isOmittedExpression(elem))
23280
+ if (ts22.isOmittedExpression(elem))
23156
23281
  return UNRESOLVED;
23157
23282
  const v = evalNode(elem, ctx);
23158
23283
  if (v === UNRESOLVED)
@@ -23161,7 +23286,7 @@ function evalNode(node, ctx) {
23161
23286
  }
23162
23287
  return arr;
23163
23288
  }
23164
- if (ts21.isElementAccessExpression(node)) {
23289
+ if (ts22.isElementAccessExpression(node)) {
23165
23290
  const base = evalNode(node.expression, ctx);
23166
23291
  if (base === undefined)
23167
23292
  return;
@@ -23175,17 +23300,17 @@ function evalNode(node, ctx) {
23175
23300
  const k = String(key);
23176
23301
  return Object.prototype.hasOwnProperty.call(base, k) ? base[k] : undefined;
23177
23302
  }
23178
- if (ts21.isPropertyAccessExpression(node)) {
23303
+ if (ts22.isPropertyAccessExpression(node)) {
23179
23304
  const baseResult = evalNode(node.expression, ctx);
23180
23305
  if (baseResult === undefined)
23181
23306
  return;
23182
23307
  return UNRESOLVED;
23183
23308
  }
23184
- if (ts21.isCallExpression(node)) {
23185
- if (node.arguments.length === 0 && ts21.isIdentifier(node.expression) && node.expression.text in ctx.bindings) {
23309
+ if (ts22.isCallExpression(node)) {
23310
+ if (node.arguments.length === 0 && ts22.isIdentifier(node.expression) && node.expression.text in ctx.bindings) {
23186
23311
  return ctx.bindings[node.expression.text];
23187
23312
  }
23188
- if (ts21.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
23313
+ if (ts22.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
23189
23314
  const recv = evalNode(node.expression.expression, ctx);
23190
23315
  if (Array.isArray(recv)) {
23191
23316
  let sep2 = ",";
@@ -23201,27 +23326,27 @@ function evalNode(node, ctx) {
23201
23326
  }
23202
23327
  return UNRESOLVED;
23203
23328
  }
23204
- if (ts21.isConditionalExpression(node)) {
23329
+ if (ts22.isConditionalExpression(node)) {
23205
23330
  const cond = evalNode(node.condition, ctx);
23206
23331
  if (cond === UNRESOLVED)
23207
23332
  return UNRESOLVED;
23208
23333
  return cond ? evalNode(node.whenTrue, ctx) : evalNode(node.whenFalse, ctx);
23209
23334
  }
23210
- if (ts21.isBinaryExpression(node)) {
23335
+ if (ts22.isBinaryExpression(node)) {
23211
23336
  const op = node.operatorToken.kind;
23212
- if (op === ts21.SyntaxKind.QuestionQuestionToken) {
23337
+ if (op === ts22.SyntaxKind.QuestionQuestionToken) {
23213
23338
  const l2 = evalNode(node.left, ctx);
23214
23339
  if (l2 !== UNRESOLVED && l2 !== null && l2 !== undefined)
23215
23340
  return l2;
23216
23341
  return evalNode(node.right, ctx);
23217
23342
  }
23218
- if (op === ts21.SyntaxKind.BarBarToken) {
23343
+ if (op === ts22.SyntaxKind.BarBarToken) {
23219
23344
  const l2 = evalNode(node.left, ctx);
23220
23345
  if (l2 !== UNRESOLVED && l2)
23221
23346
  return l2;
23222
23347
  return evalNode(node.right, ctx);
23223
23348
  }
23224
- if (op === ts21.SyntaxKind.AmpersandAmpersandToken) {
23349
+ if (op === ts22.SyntaxKind.AmpersandAmpersandToken) {
23225
23350
  const l2 = evalNode(node.left, ctx);
23226
23351
  if (l2 === UNRESOLVED)
23227
23352
  return UNRESOLVED;
@@ -23234,30 +23359,30 @@ function evalNode(node, ctx) {
23234
23359
  if (l === UNRESOLVED || r === UNRESOLVED)
23235
23360
  return UNRESOLVED;
23236
23361
  switch (op) {
23237
- case ts21.SyntaxKind.PlusToken:
23362
+ case ts22.SyntaxKind.PlusToken:
23238
23363
  if (typeof l === "string" || typeof r === "string")
23239
23364
  return `${l}${r}`;
23240
23365
  if (typeof l === "number" && typeof r === "number")
23241
23366
  return l + r;
23242
23367
  return UNRESOLVED;
23243
- case ts21.SyntaxKind.MinusToken:
23368
+ case ts22.SyntaxKind.MinusToken:
23244
23369
  return typeof l === "number" && typeof r === "number" ? l - r : UNRESOLVED;
23245
- case ts21.SyntaxKind.AsteriskToken:
23370
+ case ts22.SyntaxKind.AsteriskToken:
23246
23371
  return typeof l === "number" && typeof r === "number" ? l * r : UNRESOLVED;
23247
- case ts21.SyntaxKind.SlashToken:
23372
+ case ts22.SyntaxKind.SlashToken:
23248
23373
  return typeof l === "number" && typeof r === "number" && r !== 0 ? l / r : UNRESOLVED;
23249
- case ts21.SyntaxKind.PercentToken:
23374
+ case ts22.SyntaxKind.PercentToken:
23250
23375
  return typeof l === "number" && typeof r === "number" && r !== 0 ? l % r : UNRESOLVED;
23251
- case ts21.SyntaxKind.EqualsEqualsEqualsToken:
23252
- case ts21.SyntaxKind.EqualsEqualsToken:
23376
+ case ts22.SyntaxKind.EqualsEqualsEqualsToken:
23377
+ case ts22.SyntaxKind.EqualsEqualsToken:
23253
23378
  return l === r;
23254
- case ts21.SyntaxKind.ExclamationEqualsEqualsToken:
23255
- case ts21.SyntaxKind.ExclamationEqualsToken:
23379
+ case ts22.SyntaxKind.ExclamationEqualsEqualsToken:
23380
+ case ts22.SyntaxKind.ExclamationEqualsToken:
23256
23381
  return l !== r;
23257
23382
  }
23258
23383
  return UNRESOLVED;
23259
23384
  }
23260
- if (ts21.isTemplateExpression(node)) {
23385
+ if (ts22.isTemplateExpression(node)) {
23261
23386
  if (node.templateSpans.length === 0)
23262
23387
  return node.head.text;
23263
23388
  let acc = node.head.text;
@@ -23269,13 +23394,13 @@ function evalNode(node, ctx) {
23269
23394
  }
23270
23395
  return acc;
23271
23396
  }
23272
- if (ts21.isNoSubstitutionTemplateLiteral(node))
23397
+ if (ts22.isNoSubstitutionTemplateLiteral(node))
23273
23398
  return node.text;
23274
23399
  return UNRESOLVED;
23275
23400
  }
23276
23401
 
23277
23402
  // src/augment-inherited-props.ts
23278
- import ts22 from "typescript";
23403
+ import ts23 from "typescript";
23279
23404
  function collectContextConsumers(metadata) {
23280
23405
  const constants = metadata.localConstants ?? [];
23281
23406
  const contextDefaults = new Map;
@@ -23307,47 +23432,47 @@ function collectContextConsumers(metadata) {
23307
23432
  }
23308
23433
  function parseUseContextArg(source) {
23309
23434
  const expr = parseSingleExpression(source);
23310
- if (!expr || !ts22.isCallExpression(expr))
23435
+ if (!expr || !ts23.isCallExpression(expr))
23311
23436
  return null;
23312
- if (!ts22.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
23437
+ if (!ts23.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
23313
23438
  return null;
23314
23439
  if (expr.arguments.length !== 1)
23315
23440
  return null;
23316
23441
  const arg = expr.arguments[0];
23317
- return ts22.isIdentifier(arg) ? arg.text : null;
23442
+ return ts23.isIdentifier(arg) ? arg.text : null;
23318
23443
  }
23319
23444
  function parseCreateContextDefault(source) {
23320
23445
  const expr = parseSingleExpression(source);
23321
- if (!expr || !ts22.isCallExpression(expr))
23446
+ if (!expr || !ts23.isCallExpression(expr))
23322
23447
  return null;
23323
23448
  if (expr.arguments.length === 0)
23324
23449
  return null;
23325
23450
  const arg = expr.arguments[0];
23326
- if (ts22.isStringLiteral(arg) || ts22.isNoSubstitutionTemplateLiteral(arg))
23451
+ if (ts23.isStringLiteral(arg) || ts23.isNoSubstitutionTemplateLiteral(arg))
23327
23452
  return arg.text;
23328
- if (ts22.isNumericLiteral(arg))
23453
+ if (ts23.isNumericLiteral(arg))
23329
23454
  return Number(arg.text);
23330
- if (arg.kind === ts22.SyntaxKind.TrueKeyword)
23455
+ if (arg.kind === ts23.SyntaxKind.TrueKeyword)
23331
23456
  return true;
23332
- if (arg.kind === ts22.SyntaxKind.FalseKeyword)
23457
+ if (arg.kind === ts23.SyntaxKind.FalseKeyword)
23333
23458
  return false;
23334
23459
  return null;
23335
23460
  }
23336
23461
  function isObjectLiteralCreateContextDefault(source) {
23337
23462
  const expr = parseSingleExpression(source);
23338
- if (!expr || !ts22.isCallExpression(expr))
23463
+ if (!expr || !ts23.isCallExpression(expr))
23339
23464
  return false;
23340
23465
  if (expr.arguments.length === 0)
23341
23466
  return false;
23342
- return ts22.isObjectLiteralExpression(expr.arguments[0]);
23467
+ return ts23.isObjectLiteralExpression(expr.arguments[0]);
23343
23468
  }
23344
23469
  function parseSingleExpression(source) {
23345
- const sf = ts22.createSourceFile("__ctx.ts", `(${source})`, ts22.ScriptTarget.Latest, false);
23470
+ const sf = ts23.createSourceFile("__ctx.ts", `(${source})`, ts23.ScriptTarget.Latest, false);
23346
23471
  const stmt = sf.statements[0];
23347
- if (!stmt || !ts22.isExpressionStatement(stmt))
23472
+ if (!stmt || !ts23.isExpressionStatement(stmt))
23348
23473
  return null;
23349
23474
  let e = stmt.expression;
23350
- while (ts22.isParenthesizedExpression(e))
23475
+ while (ts23.isParenthesizedExpression(e))
23351
23476
  e = e.expression;
23352
23477
  return e;
23353
23478
  }
@@ -23372,25 +23497,25 @@ function augmentInheritedPropAccesses(ir) {
23372
23497
  const pinCoalesceLiterals = (s) => {
23373
23498
  if (!s || !s.includes(propsObj))
23374
23499
  return;
23375
- const sf = ts22.createSourceFile("__aug.ts", `(${s})`, ts22.ScriptTarget.Latest, false);
23500
+ const sf = ts23.createSourceFile("__aug.ts", `(${s})`, ts23.ScriptTarget.Latest, false);
23376
23501
  const visit3 = (n) => {
23377
- if (ts22.isBinaryExpression(n) && (n.operatorToken.kind === ts22.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts22.SyntaxKind.BarBarToken)) {
23502
+ if (ts23.isBinaryExpression(n) && (n.operatorToken.kind === ts23.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts23.SyntaxKind.BarBarToken)) {
23378
23503
  let left = n.left;
23379
- while (ts22.isParenthesizedExpression(left))
23504
+ while (ts23.isParenthesizedExpression(left))
23380
23505
  left = left.expression;
23381
- if (ts22.isPropertyAccessExpression(left) && ts22.isIdentifier(left.expression) && left.expression.text === propsObj) {
23506
+ if (ts23.isPropertyAccessExpression(left) && ts23.isIdentifier(left.expression) && left.expression.text === propsObj) {
23382
23507
  const name = left.name.text;
23383
23508
  let right = n.right;
23384
- while (ts22.isParenthesizedExpression(right))
23509
+ while (ts23.isParenthesizedExpression(right))
23385
23510
  right = right.expression;
23386
- if (ts22.isPrefixUnaryExpression(right))
23511
+ if (ts23.isPrefixUnaryExpression(right))
23387
23512
  right = right.operand;
23388
- const kind = ts22.isNumericLiteral(right) ? "number" : right.kind === ts22.SyntaxKind.TrueKeyword || right.kind === ts22.SyntaxKind.FalseKeyword ? "boolean" : ts22.isStringLiteralLike(right) ? "string" : null;
23513
+ const kind = ts23.isNumericLiteral(right) ? "number" : right.kind === ts23.SyntaxKind.TrueKeyword || right.kind === ts23.SyntaxKind.FalseKeyword ? "boolean" : ts23.isStringLiteralLike(right) ? "string" : null;
23389
23514
  if (kind && !coalesceLiteralTypes.has(name))
23390
23515
  coalesceLiteralTypes.set(name, kind);
23391
23516
  }
23392
23517
  }
23393
- ts22.forEachChild(n, visit3);
23518
+ ts23.forEachChild(n, visit3);
23394
23519
  };
23395
23520
  visit3(sf);
23396
23521
  };
@@ -23501,33 +23626,33 @@ function augmentInheritedPropAccesses(ir) {
23501
23626
  }
23502
23627
  }
23503
23628
  function parseStaticStringConst(source) {
23504
- const sf = ts22.createSourceFile("__const.ts", `const __x = (${source});`, ts22.ScriptTarget.Latest, false);
23629
+ const sf = ts23.createSourceFile("__const.ts", `const __x = (${source});`, ts23.ScriptTarget.Latest, false);
23505
23630
  const stmt = sf.statements[0];
23506
- if (!stmt || !ts22.isVariableStatement(stmt))
23631
+ if (!stmt || !ts23.isVariableStatement(stmt))
23507
23632
  return null;
23508
23633
  let init = stmt.declarationList.declarations[0]?.initializer;
23509
- while (init && ts22.isParenthesizedExpression(init))
23634
+ while (init && ts23.isParenthesizedExpression(init))
23510
23635
  init = init.expression;
23511
23636
  if (!init)
23512
23637
  return null;
23513
- if (ts22.isStringLiteral(init) || ts22.isNoSubstitutionTemplateLiteral(init)) {
23638
+ if (ts23.isStringLiteral(init) || ts23.isNoSubstitutionTemplateLiteral(init)) {
23514
23639
  return init.text;
23515
23640
  }
23516
23641
  return evalStringArrayJoin(source);
23517
23642
  }
23518
23643
  function evalTemplateOfStringConsts(source, resolved) {
23519
- const sf = ts22.createSourceFile("__const.ts", `const __x = (${source});`, ts22.ScriptTarget.Latest, false);
23644
+ const sf = ts23.createSourceFile("__const.ts", `const __x = (${source});`, ts23.ScriptTarget.Latest, false);
23520
23645
  const stmt = sf.statements[0];
23521
- if (!stmt || !ts22.isVariableStatement(stmt))
23646
+ if (!stmt || !ts23.isVariableStatement(stmt))
23522
23647
  return null;
23523
23648
  let init = stmt.declarationList.declarations[0]?.initializer;
23524
- while (init && ts22.isParenthesizedExpression(init))
23649
+ while (init && ts23.isParenthesizedExpression(init))
23525
23650
  init = init.expression;
23526
- if (!init || !ts22.isTemplateExpression(init))
23651
+ if (!init || !ts23.isTemplateExpression(init))
23527
23652
  return null;
23528
23653
  let out = init.head.text;
23529
23654
  for (const span of init.templateSpans) {
23530
- if (!ts22.isIdentifier(span.expression))
23655
+ if (!ts23.isIdentifier(span.expression))
23531
23656
  return null;
23532
23657
  const value = resolved.get(span.expression.text);
23533
23658
  if (value === undefined)
@@ -23554,34 +23679,36 @@ function collectModuleStringConsts(constants) {
23554
23679
  }
23555
23680
  return map;
23556
23681
  }
23557
- function lookupStaticRecordLiteral(objectName, key, constants) {
23682
+ function lookupStaticRecordLiteral(objectName, key, constants, isShadowed) {
23683
+ if (isShadowed(objectName))
23684
+ return null;
23558
23685
  const constInfo = (constants ?? []).find((c) => c.name === objectName && c.isModule);
23559
23686
  if (constInfo?.value === undefined)
23560
23687
  return null;
23561
- const sf = ts22.createSourceFile("__rec.ts", `(${constInfo.value})`, ts22.ScriptTarget.Latest, true);
23688
+ const sf = ts23.createSourceFile("__rec.ts", `(${constInfo.value})`, ts23.ScriptTarget.Latest, true);
23562
23689
  if (sf.statements.length !== 1)
23563
23690
  return null;
23564
23691
  const stmt = sf.statements[0];
23565
- if (!ts22.isExpressionStatement(stmt))
23692
+ if (!ts23.isExpressionStatement(stmt))
23566
23693
  return null;
23567
23694
  let parsed = stmt.expression;
23568
- while (ts22.isParenthesizedExpression(parsed))
23695
+ while (ts23.isParenthesizedExpression(parsed))
23569
23696
  parsed = parsed.expression;
23570
- if (!ts22.isObjectLiteralExpression(parsed))
23697
+ if (!ts23.isObjectLiteralExpression(parsed))
23571
23698
  return null;
23572
23699
  for (const prop of parsed.properties) {
23573
- if (!ts22.isPropertyAssignment(prop))
23700
+ if (!ts23.isPropertyAssignment(prop))
23574
23701
  continue;
23575
23702
  const name = prop.name;
23576
- const propKey = ts22.isIdentifier(name) || ts22.isStringLiteral(name) || ts22.isNoSubstitutionTemplateLiteral(name) ? name.text : null;
23703
+ const propKey = ts23.isIdentifier(name) || ts23.isStringLiteral(name) || ts23.isNoSubstitutionTemplateLiteral(name) ? name.text : null;
23577
23704
  if (propKey !== key)
23578
23705
  continue;
23579
23706
  let v = prop.initializer;
23580
- while (ts22.isParenthesizedExpression(v))
23707
+ while (ts23.isParenthesizedExpression(v))
23581
23708
  v = v.expression;
23582
- if (ts22.isNumericLiteral(v))
23709
+ if (ts23.isNumericLiteral(v))
23583
23710
  return { kind: "number", text: v.text };
23584
- if (ts22.isStringLiteral(v) || ts22.isNoSubstitutionTemplateLiteral(v)) {
23711
+ if (ts23.isStringLiteral(v) || ts23.isNoSubstitutionTemplateLiteral(v)) {
23585
23712
  return { kind: "string", text: v.text };
23586
23713
  }
23587
23714
  return null;
@@ -23589,28 +23716,28 @@ function lookupStaticRecordLiteral(objectName, key, constants) {
23589
23716
  return null;
23590
23717
  }
23591
23718
  function evalStringArrayJoin(source) {
23592
- const sf = ts22.createSourceFile("__join.ts", `const __x = (${source});`, ts22.ScriptTarget.Latest, false);
23719
+ const sf = ts23.createSourceFile("__join.ts", `const __x = (${source});`, ts23.ScriptTarget.Latest, false);
23593
23720
  const stmt = sf.statements[0];
23594
- if (!stmt || !ts22.isVariableStatement(stmt))
23721
+ if (!stmt || !ts23.isVariableStatement(stmt))
23595
23722
  return null;
23596
23723
  let node = stmt.declarationList.declarations[0]?.initializer;
23597
- while (node && ts22.isParenthesizedExpression(node))
23724
+ while (node && ts23.isParenthesizedExpression(node))
23598
23725
  node = node.expression;
23599
- if (!node || !ts22.isCallExpression(node))
23726
+ if (!node || !ts23.isCallExpression(node))
23600
23727
  return null;
23601
23728
  const callee = node.expression;
23602
- if (!ts22.isPropertyAccessExpression(callee))
23729
+ if (!ts23.isPropertyAccessExpression(callee))
23603
23730
  return null;
23604
23731
  if (callee.name.text !== "join")
23605
23732
  return null;
23606
23733
  let recv = callee.expression;
23607
- while (ts22.isParenthesizedExpression(recv))
23734
+ while (ts23.isParenthesizedExpression(recv))
23608
23735
  recv = recv.expression;
23609
- if (!ts22.isArrayLiteralExpression(recv))
23736
+ if (!ts23.isArrayLiteralExpression(recv))
23610
23737
  return null;
23611
23738
  const parts = [];
23612
23739
  for (const el of recv.elements) {
23613
- if (ts22.isStringLiteral(el) || ts22.isNoSubstitutionTemplateLiteral(el)) {
23740
+ if (ts23.isStringLiteral(el) || ts23.isNoSubstitutionTemplateLiteral(el)) {
23614
23741
  parts.push(el.text);
23615
23742
  } else {
23616
23743
  return null;
@@ -23619,7 +23746,7 @@ function evalStringArrayJoin(source) {
23619
23746
  let sep2 = ",";
23620
23747
  if (node.arguments.length >= 1) {
23621
23748
  const arg = node.arguments[0];
23622
- if (ts22.isStringLiteral(arg) || ts22.isNoSubstitutionTemplateLiteral(arg))
23749
+ if (ts23.isStringLiteral(arg) || ts23.isNoSubstitutionTemplateLiteral(arg))
23623
23750
  sep2 = arg.text;
23624
23751
  else
23625
23752
  return null;
@@ -23627,11 +23754,11 @@ function evalStringArrayJoin(source) {
23627
23754
  return parts.join(sep2);
23628
23755
  }
23629
23756
  function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
23630
- if (!ts22.isElementAccessExpression(val))
23757
+ if (!ts23.isElementAccessExpression(val))
23631
23758
  return null;
23632
23759
  const obj = val.expression;
23633
23760
  const arg = val.argumentExpression;
23634
- if (!ts22.isIdentifier(obj) || !ts22.isIdentifier(arg))
23761
+ if (!ts23.isIdentifier(obj) || !ts23.isIdentifier(arg))
23635
23762
  return null;
23636
23763
  let indexPropName;
23637
23764
  let defaultKey;
@@ -23647,35 +23774,35 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
23647
23774
  const constInfo = localConstants.find((c) => c.name === obj.text && c.isModule);
23648
23775
  if (constInfo?.value === undefined)
23649
23776
  return null;
23650
- const sf = ts22.createSourceFile("__rec.ts", `(${constInfo.value})`, ts22.ScriptTarget.Latest, true);
23777
+ const sf = ts23.createSourceFile("__rec.ts", `(${constInfo.value})`, ts23.ScriptTarget.Latest, true);
23651
23778
  if (sf.statements.length !== 1)
23652
23779
  return null;
23653
23780
  const stmt = sf.statements[0];
23654
- if (!ts22.isExpressionStatement(stmt))
23781
+ if (!ts23.isExpressionStatement(stmt))
23655
23782
  return null;
23656
23783
  let parsed = stmt.expression;
23657
- while (ts22.isParenthesizedExpression(parsed))
23784
+ while (ts23.isParenthesizedExpression(parsed))
23658
23785
  parsed = parsed.expression;
23659
- if (!ts22.isObjectLiteralExpression(parsed))
23786
+ if (!ts23.isObjectLiteralExpression(parsed))
23660
23787
  return null;
23661
23788
  const entries = [];
23662
23789
  for (const prop of parsed.properties) {
23663
- if (!ts22.isPropertyAssignment(prop))
23790
+ if (!ts23.isPropertyAssignment(prop))
23664
23791
  return null;
23665
23792
  let key;
23666
- if (ts22.isIdentifier(prop.name)) {
23793
+ if (ts23.isIdentifier(prop.name)) {
23667
23794
  key = prop.name.text;
23668
- } else if (ts22.isStringLiteral(prop.name) || ts22.isNoSubstitutionTemplateLiteral(prop.name)) {
23795
+ } else if (ts23.isStringLiteral(prop.name) || ts23.isNoSubstitutionTemplateLiteral(prop.name)) {
23669
23796
  key = prop.name.text;
23670
23797
  } else {
23671
23798
  return null;
23672
23799
  }
23673
23800
  let v = prop.initializer;
23674
- while (ts22.isParenthesizedExpression(v))
23801
+ while (ts23.isParenthesizedExpression(v))
23675
23802
  v = v.expression;
23676
- if (ts22.isNumericLiteral(v)) {
23803
+ if (ts23.isNumericLiteral(v)) {
23677
23804
  entries.push({ key, value: { kind: "number", text: v.text } });
23678
- } else if (ts22.isStringLiteral(v) || ts22.isNoSubstitutionTemplateLiteral(v)) {
23805
+ } else if (ts23.isStringLiteral(v) || ts23.isNoSubstitutionTemplateLiteral(v)) {
23679
23806
  entries.push({ key, value: { kind: "string", text: v.text } });
23680
23807
  } else {
23681
23808
  return null;
@@ -24018,13 +24145,13 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
24018
24145
  if (entries.some((e) => e.componentIR.metadata.isClientComponent)) {
24019
24146
  const topLevelNames = new Set;
24020
24147
  {
24021
- const sf = ts23.createSourceFile(filePath, source, ts23.ScriptTarget.Latest, true, ts23.ScriptKind.TSX);
24148
+ const sf = ts24.createSourceFile(filePath, source, ts24.ScriptTarget.Latest, true, ts24.ScriptKind.TSX);
24022
24149
  for (const stmt of sf.statements) {
24023
- if (ts23.isFunctionDeclaration(stmt) && stmt.name)
24150
+ if (ts24.isFunctionDeclaration(stmt) && stmt.name)
24024
24151
  topLevelNames.add(stmt.name.text);
24025
- else if (ts23.isVariableStatement(stmt)) {
24152
+ else if (ts24.isVariableStatement(stmt)) {
24026
24153
  for (const d of stmt.declarationList.declarations) {
24027
- if (ts23.isIdentifier(d.name))
24154
+ if (ts24.isIdentifier(d.name))
24028
24155
  topLevelNames.add(d.name.text);
24029
24156
  }
24030
24157
  }
@@ -24083,7 +24210,7 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
24083
24210
  const moduleStatementSeen = new Set;
24084
24211
  const moduleStatementsOrdered = [];
24085
24212
  const collectModuleStatements = (block) => {
24086
- const sf = ts23.createSourceFile("__bf_module_decls.tsx", block, ts23.ScriptTarget.Latest, false, ts23.ScriptKind.TSX);
24213
+ const sf = ts24.createSourceFile("__bf_module_decls.tsx", block, ts24.ScriptTarget.Latest, false, ts24.ScriptKind.TSX);
24087
24214
  for (const stmt of sf.statements) {
24088
24215
  const text = stmt.getText(sf);
24089
24216
  if (moduleStatementSeen.has(text))
@@ -24320,6 +24447,12 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
24320
24447
  }
24321
24448
  return { files, errors };
24322
24449
  }
24450
+ function componentTypeParametersText(componentNode, sourceFile) {
24451
+ const typeParameters = componentNode?.typeParameters;
24452
+ if (!typeParameters || typeParameters.length === 0)
24453
+ return null;
24454
+ return `<${typeParameters.map((p) => p.getText(sourceFile)).join(", ")}>`;
24455
+ }
24323
24456
  function buildMetadata(ctx) {
24324
24457
  const metadata = {
24325
24458
  componentName: ctx.componentName || "Unknown",
@@ -24328,6 +24461,7 @@ function buildMetadata(ctx) {
24328
24461
  isClientComponent: ctx.hasUseClientDirective,
24329
24462
  typeDefinitions: ctx.typeDefinitions,
24330
24463
  propsType: ctx.propsType,
24464
+ typeParameters: componentTypeParametersText(ctx.componentNode, ctx.sourceFile),
24331
24465
  propsParams: ctx.propsParams,
24332
24466
  propsObjectName: ctx.propsObjectName,
24333
24467
  restPropsName: ctx.restPropsName,
@@ -24518,7 +24652,7 @@ function compileJSX(source, filePath, options) {
24518
24652
  return { files, errors };
24519
24653
  }
24520
24654
  // src/shared-program.ts
24521
- import ts24 from "typescript";
24655
+ import ts25 from "typescript";
24522
24656
  function commonParent(paths) {
24523
24657
  if (paths.length === 0)
24524
24658
  return process.cwd();
@@ -24539,10 +24673,10 @@ function commonParent(paths) {
24539
24673
  function createProgramForCorpus(files, options = {}) {
24540
24674
  const baseUrl = options.baseUrl ?? commonParent(files);
24541
24675
  const compilerOptions = {
24542
- target: ts24.ScriptTarget.Latest,
24543
- module: ts24.ModuleKind.ESNext,
24544
- moduleResolution: ts24.ModuleResolutionKind.Bundler,
24545
- jsx: ts24.JsxEmit.ReactJSX,
24676
+ target: ts25.ScriptTarget.Latest,
24677
+ module: ts25.ModuleKind.ESNext,
24678
+ moduleResolution: ts25.ModuleResolutionKind.Bundler,
24679
+ jsx: ts25.JsxEmit.ReactJSX,
24546
24680
  strict: true,
24547
24681
  skipLibCheck: true,
24548
24682
  noEmit: true,
@@ -24552,7 +24686,7 @@ function createProgramForCorpus(files, options = {}) {
24552
24686
  ...options.compilerOptions
24553
24687
  };
24554
24688
  const absolute = files.map((f) => path_default.resolve(f));
24555
- return ts24.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
24689
+ return ts25.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
24556
24690
  }
24557
24691
  // src/adapters/interface.ts
24558
24692
  class BaseAdapter {
@@ -24607,7 +24741,7 @@ class JsxAdapter extends BaseAdapter {
24607
24741
  ...localFunctions.map((f) => ({ name: f.name, body: f.body })),
24608
24742
  ...localConstants.map((c) => ({ name: c.name, body: c.value }))
24609
24743
  ];
24610
- const reachable = findReachableNames(primaryRefText, declarations);
24744
+ const reachable = closeOverWritersOfMutableBindings(primaryRefText, declarations, new Set(ir.metadata.localConstants.filter((c) => (c.declarationKind ?? "const") !== "const").map((c) => c.name)));
24611
24745
  const reachableBodies = [...reachable].map((name) => {
24612
24746
  const func = localFunctions.find((f) => f.name === name);
24613
24747
  if (func)
@@ -24637,9 +24771,10 @@ class JsxAdapter extends BaseAdapter {
24637
24771
  lines.push(` const ${signal.getter} = () => ${initialValue}`);
24638
24772
  }
24639
24773
  if (signal.setter) {
24640
- const setterUsed = new RegExp(`\\b${signal.setter}\\b`).test(setterRefText);
24774
+ const setterUsed = identifierPattern(signal.setter).test(setterRefText);
24641
24775
  if (setterUsed) {
24642
- lines.push(` const ${signal.setter} = (..._args: any[]) => {}`);
24776
+ const setterType = preserveTypes && signal.type.kind !== "unknown" ? `(valueOrFn: ${signal.type.raw} | ((prev: ${signal.type.raw}) => ${signal.type.raw})) => void` : null;
24777
+ lines.push(setterType ? ` const ${signal.setter}: ${setterType} = () => {}` : ` const ${signal.setter} = (..._args: any[]) => {}`);
24643
24778
  }
24644
24779
  }
24645
24780
  }
@@ -24835,6 +24970,7 @@ class JsxAdapter extends BaseAdapter {
24835
24970
  }
24836
24971
 
24837
24972
  // src/adapters/template-imports.ts
24973
+ import ts26 from "typescript";
24838
24974
  var CLIENT_PACKAGE_SOURCES = new Set([
24839
24975
  "@barefootjs/client",
24840
24976
  "@barefootjs/client/runtime"
@@ -24881,6 +25017,44 @@ function rewriteImportsForTemplate(imports, shimSource, rewriteRelative) {
24881
25017
  function specKey(s) {
24882
25018
  return `${s.isDefault ? "d" : ""}${s.isNamespace ? "n" : ""}:${s.name}:${s.alias ?? ""}`;
24883
25019
  }
25020
+ function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
25021
+ if (!sourceText.includes("import"))
25022
+ return sourceText;
25023
+ const sf = ts26.createSourceFile("bf-template-fragment.tsx", sourceText, ts26.ScriptTarget.Latest, false, ts26.ScriptKind.TSX);
25024
+ const edits = [];
25025
+ const visit3 = (node) => {
25026
+ if (ts26.isCallExpression(node) && node.expression.kind === ts26.SyntaxKind.ImportKeyword && node.arguments.length > 0 && ts26.isStringLiteralLike(node.arguments[0])) {
25027
+ collect(node.arguments[0]);
25028
+ }
25029
+ if (ts26.isImportTypeNode(node) && ts26.isLiteralTypeNode(node.argument)) {
25030
+ const literal = node.argument.literal;
25031
+ if (ts26.isStringLiteralLike(literal))
25032
+ collect(literal);
25033
+ }
25034
+ ts26.forEachChild(node, visit3);
25035
+ };
25036
+ const collect = (literal) => {
25037
+ const specifier = literal.text;
25038
+ if (!specifier.startsWith("."))
25039
+ return;
25040
+ const next = rewriteRelative(specifier);
25041
+ if (next === specifier)
25042
+ return;
25043
+ edits.push({
25044
+ start: literal.getStart(sf),
25045
+ end: literal.getEnd(),
25046
+ text: `'${next}'`
25047
+ });
25048
+ };
25049
+ ts26.forEachChild(sf, visit3);
25050
+ if (edits.length === 0)
25051
+ return sourceText;
25052
+ let out = sourceText;
25053
+ for (const edit of edits.sort((a, b) => b.start - a.start)) {
25054
+ out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
25055
+ }
25056
+ return out;
25057
+ }
24884
25058
 
24885
25059
  // src/adapters/test-adapter.ts
24886
25060
  class TestAdapter extends JsxAdapter {
@@ -24973,7 +25147,8 @@ export default ${this.componentName}` : "";
24973
25147
  const noArgDefault = hasRequiredProps ? "" : ` = {} as ${propsTypeExpr}`;
24974
25148
  const lines = [];
24975
25149
  const exportPrefix = ir.metadata.isExported === false ? "" : "export ";
24976
- lines.push(`${exportPrefix}function ${name}(${fullPropsDestructure}${typeAnnotation}${noArgDefault}) {`);
25150
+ const typeParameters = ir.metadata.typeParameters ?? "";
25151
+ lines.push(`${exportPrefix}function ${name}${typeParameters}(${fullPropsDestructure}${typeAnnotation}${noArgDefault}) {`);
24977
25152
  if (hasClientInteractivity) {
24978
25153
  lines.push(` const __scopeId = (/_s\\d/.test(__bfScope || '') ? __bfScope : null) || __instanceId || \`${name}_\${Math.random().toString(36).slice(2, 8)}\``);
24979
25154
  } else {
@@ -25667,7 +25842,7 @@ function dangerousInnerHtmlDiagnostic(expr, loc, reason) {
25667
25842
  };
25668
25843
  }
25669
25844
  // src/combine-client-js.ts
25670
- import ts25 from "typescript";
25845
+ import ts27 from "typescript";
25671
25846
  var CHILD_PLACEHOLDER_RE = /import '\/\* @bf-child:(\w+) \*\/'/g;
25672
25847
  function combineParentChildClientJs(files) {
25673
25848
  const result = new Map;
@@ -25724,10 +25899,10 @@ function combineParentChildClientJs(files) {
25724
25899
  return result;
25725
25900
  }
25726
25901
  function parseAndMerge(content, importsBySource, otherImports, codeSections) {
25727
- const sourceFile = ts25.createSourceFile("combine.js", content, ts25.ScriptTarget.Latest, false, ts25.ScriptKind.JS);
25902
+ const sourceFile = ts27.createSourceFile("combine.js", content, ts27.ScriptTarget.Latest, false, ts27.ScriptKind.JS);
25728
25903
  const importSpans = [];
25729
25904
  for (const stmt of sourceFile.statements) {
25730
- if (!ts25.isImportDeclaration(stmt))
25905
+ if (!ts27.isImportDeclaration(stmt))
25731
25906
  continue;
25732
25907
  const start = stmt.getStart(sourceFile);
25733
25908
  const end = stmt.getEnd();
@@ -25737,8 +25912,8 @@ function parseAndMerge(content, importsBySource, otherImports, codeSections) {
25737
25912
  continue;
25738
25913
  const clause = stmt.importClause;
25739
25914
  const bindings = clause?.namedBindings;
25740
- const specifier = ts25.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
25741
- if (clause && !clause.name && bindings && ts25.isNamedImports(bindings)) {
25915
+ const specifier = ts27.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
25916
+ if (clause && !clause.name && bindings && ts27.isNamedImports(bindings)) {
25742
25917
  if (!importsBySource.has(specifier)) {
25743
25918
  importsBySource.set(specifier, new Set);
25744
25919
  }
@@ -25905,7 +26080,7 @@ function escapeRe(s) {
25905
26080
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
25906
26081
  }
25907
26082
  // src/debug.ts
25908
- import ts26 from "typescript";
26083
+ import ts28 from "typescript";
25909
26084
  function buildComponentGraph(source, filePath, componentName) {
25910
26085
  const ctx = analyzeComponent(source, filePath, componentName);
25911
26086
  if (!ctx.jsxReturn) {
@@ -25984,7 +26159,7 @@ function buildGraphFromIR(ir) {
25984
26159
  return propsObjectName ? exprReadsPropMember(expr, propsObjectName) : false;
25985
26160
  };
25986
26161
  const domBindings = [];
25987
- collectDomBindings(ir.root, domBindings, signalGetters, memoNames, undefined, new Set, exprReadsProp);
26162
+ collectDomBindings(ir.root, domBindings, signalGetters, memoNames, undefined, BindingScope.EMPTY, exprReadsProp);
25988
26163
  const signalConsumers = new Map;
25989
26164
  for (const s of meta.signals)
25990
26165
  signalConsumers.set(s.getter, []);
@@ -27010,15 +27185,22 @@ function inferWrapReasonForAttrLike(hasStringReactive, hasPropsRef, flags) {
27010
27185
  const decision = decideWrapFromAstFlags(flags);
27011
27186
  return decision.wrap ? decision.reason : undefined;
27012
27187
  }
27013
- function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag, loopParams = new Set, readsProp = () => false) {
27014
- const exprReadsLoopParam = (n) => loopParams.size > 0 && (n.origin?.freeRefs?.some((r) => loopParams.has(r.name)) ?? false);
27015
- const attrReadsLoopParam = (free) => loopParams.size > 0 && free !== undefined && [...loopParams].some((p) => free.has(p));
27188
+ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag, scope = BindingScope.EMPTY, readsProp = () => false) {
27189
+ const boundNames = scope.valueBoundNames();
27190
+ const setSomeIn = (names, other) => {
27191
+ for (const n of names)
27192
+ if (other.has(n))
27193
+ return true;
27194
+ return false;
27195
+ };
27196
+ const exprReadsLoopParam = (n) => boundNames.size > 0 && (n.origin?.freeRefs?.some((r) => boundNames.has(r.name)) ?? false);
27197
+ const attrReadsLoopParam = (free) => boundNames.size > 0 && free !== undefined && setSomeIn(boundNames, free);
27016
27198
  switch (node.type) {
27017
27199
  case "element": {
27018
27200
  for (const attr of node.attrs) {
27019
27201
  if (attr.value.kind !== "expression" && attr.value.kind !== "template" && attr.value.kind !== "spread")
27020
27202
  continue;
27021
- if (attr.name === "key" && loopParams.size > 0)
27203
+ if (attr.name === "key" && boundNames.size > 0)
27022
27204
  continue;
27023
27205
  const expr = attrValueToString2(attr.value);
27024
27206
  if (!expr)
@@ -27055,7 +27237,7 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27055
27237
  });
27056
27238
  }
27057
27239
  for (const child of node.children) {
27058
- collectDomBindings(child, bindings, signalGetters, memoNames, node.tag, loopParams, readsProp);
27240
+ collectDomBindings(child, bindings, signalGetters, memoNames, node.tag, scope, readsProp);
27059
27241
  }
27060
27242
  break;
27061
27243
  }
@@ -27082,7 +27264,7 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27082
27264
  }
27083
27265
  case "conditional": {
27084
27266
  const decision = decideWrapFromAstFlags(node);
27085
- const loopReactive = loopParams.size > 0 && (node.origin?.freeRefs?.some((r) => loopParams.has(r.name)) ?? false);
27267
+ const loopReactive = boundNames.size > 0 && (node.origin?.freeRefs?.some((r) => boundNames.has(r.name)) ?? false);
27086
27268
  if ((decision.wrap || loopReactive) && node.slotId) {
27087
27269
  const deps = extractReactiveDeps(node.condition, signalGetters, memoNames);
27088
27270
  bindings.push({
@@ -27098,14 +27280,14 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27098
27280
  jsxPreview: `{${truncateExpr(node.condition)} ? ... : ...}`
27099
27281
  });
27100
27282
  }
27101
- collectDomBindings(node.whenTrue, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27102
- collectDomBindings(node.whenFalse, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27283
+ collectDomBindings(node.whenTrue, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27284
+ collectDomBindings(node.whenFalse, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27103
27285
  break;
27104
27286
  }
27105
27287
  case "loop": {
27106
27288
  if (node.slotId) {
27107
27289
  const deps = extractReactiveDeps(node.array, signalGetters, memoNames);
27108
- const loopReactive = loopParams.size > 0 && node.arrayFreeIdentifiers !== undefined && [...loopParams].some((p) => node.arrayFreeIdentifiers.has(p));
27290
+ const loopReactive = boundNames.size > 0 && node.arrayFreeIdentifiers !== undefined && setSomeIn(boundNames, node.arrayFreeIdentifiers);
27109
27291
  const isReactive = deps.length > 0 || node.callsReactiveGetters === true || loopReactive;
27110
27292
  const isFallback = !isReactive && node.hasFunctionCalls === true;
27111
27293
  if (isReactive || isFallback) {
@@ -27124,13 +27306,9 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27124
27306
  });
27125
27307
  }
27126
27308
  }
27127
- const childLoopParams = new Set(loopParams);
27128
- for (const p of extractLoopParamNames(node.param, node))
27129
- childLoopParams.add(p);
27130
- if (node.index)
27131
- childLoopParams.add(node.index);
27309
+ const childScope = scope.enterLoopRow(node);
27132
27310
  for (const child of node.children) {
27133
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, childLoopParams, readsProp);
27311
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, childScope, readsProp);
27134
27312
  }
27135
27313
  break;
27136
27314
  }
@@ -27163,21 +27341,21 @@ function collectDomBindings(node, bindings, signalGetters, memoNames, parentTag,
27163
27341
  }
27164
27342
  }
27165
27343
  for (const child of node.children) {
27166
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27344
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27167
27345
  }
27168
27346
  break;
27169
27347
  }
27170
27348
  case "fragment":
27171
27349
  case "provider": {
27172
27350
  for (const child of node.children) {
27173
- collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27351
+ collectDomBindings(child, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27174
27352
  }
27175
27353
  break;
27176
27354
  }
27177
27355
  case "if-statement": {
27178
- collectDomBindings(node.consequent, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27356
+ collectDomBindings(node.consequent, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27179
27357
  if (node.alternate) {
27180
- collectDomBindings(node.alternate, bindings, signalGetters, memoNames, parentTag, loopParams, readsProp);
27358
+ collectDomBindings(node.alternate, bindings, signalGetters, memoNames, parentTag, scope, readsProp);
27181
27359
  }
27182
27360
  break;
27183
27361
  }
@@ -27190,7 +27368,7 @@ function truncateExpr(expr, max = 40) {
27190
27368
  function exprReadsPropMember(expr, propsObjectName) {
27191
27369
  let sf;
27192
27370
  try {
27193
- sf = ts26.createSourceFile("__attr.tsx", `(${expr})`, ts26.ScriptTarget.Latest, true, ts26.ScriptKind.TSX);
27371
+ sf = ts28.createSourceFile("__attr.tsx", `(${expr})`, ts28.ScriptTarget.Latest, true, ts28.ScriptKind.TSX);
27194
27372
  } catch {
27195
27373
  return false;
27196
27374
  }
@@ -27198,11 +27376,11 @@ function exprReadsPropMember(expr, propsObjectName) {
27198
27376
  const visit3 = (n) => {
27199
27377
  if (found)
27200
27378
  return;
27201
- if (ts26.isPropertyAccessExpression(n) && ts26.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
27379
+ if (ts28.isPropertyAccessExpression(n) && ts28.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
27202
27380
  found = true;
27203
27381
  return;
27204
27382
  }
27205
- ts26.forEachChild(n, visit3);
27383
+ ts28.forEachChild(n, visit3);
27206
27384
  };
27207
27385
  visit3(sf);
27208
27386
  return found;
@@ -27232,12 +27410,12 @@ function attrValueToString2(value) {
27232
27410
  function extractReactiveDeps(expr, signalGetters, memoNames) {
27233
27411
  const deps = [];
27234
27412
  for (const getter of signalGetters) {
27235
- if (new RegExp(`\\b${getter}\\s*\\(`).test(expr)) {
27413
+ if (identifierCallPattern(getter).test(expr)) {
27236
27414
  deps.push(getter);
27237
27415
  }
27238
27416
  }
27239
27417
  for (const memo of memoNames) {
27240
- if (new RegExp(`\\b${memo}\\s*\\(`).test(expr)) {
27418
+ if (identifierCallPattern(memo).test(expr)) {
27241
27419
  deps.push(memo);
27242
27420
  }
27243
27421
  }
@@ -27250,7 +27428,7 @@ function extractSetterRefs(expr, signalGetters) {
27250
27428
  refs.push(match[1]);
27251
27429
  }
27252
27430
  for (const getter of signalGetters) {
27253
- if (new RegExp(`\\b${getter}\\s*\\(`).test(expr)) {
27431
+ if (identifierCallPattern(getter).test(expr)) {
27254
27432
  refs.push(getter);
27255
27433
  }
27256
27434
  }
@@ -27272,7 +27450,7 @@ function findSourceFile2(meta) {
27272
27450
  return null;
27273
27451
  }
27274
27452
  // src/profiler.ts
27275
- import ts27 from "typescript";
27453
+ import ts29 from "typescript";
27276
27454
  var PROFILE_SCHEMA_VERSION = 1;
27277
27455
  var DEFAULT_FANOUT_THRESHOLD = 8;
27278
27456
  function buildStaticBudget(source, filePath, componentName, options = {}) {
@@ -27542,15 +27720,15 @@ function joinProfilerEvents(events, index) {
27542
27720
  return { joined, unattributed, diagnostics };
27543
27721
  }
27544
27722
  function findUninstrumentedEffects(source, filePath, instrumentedLines) {
27545
- const sf = ts27.createSourceFile(filePath, source, ts27.ScriptTarget.Latest, true, ts27.ScriptKind.TSX);
27723
+ const sf = ts29.createSourceFile(filePath, source, ts29.ScriptTarget.Latest, true, ts29.ScriptKind.TSX);
27546
27724
  const out = [];
27547
27725
  const visit3 = (node) => {
27548
- if (ts27.isCallExpression(node) && ts27.isIdentifier(node.expression) && node.expression.text === "createEffect") {
27726
+ if (ts29.isCallExpression(node) && ts29.isIdentifier(node.expression) && node.expression.text === "createEffect") {
27549
27727
  const line = sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;
27550
27728
  if (!instrumentedLines.has(line))
27551
27729
  out.push({ file: filePath, line });
27552
27730
  }
27553
- ts27.forEachChild(node, visit3);
27731
+ ts29.forEachChild(node, visit3);
27554
27732
  };
27555
27733
  visit3(sf);
27556
27734
  out.sort((a, b) => a.line - b.line);
@@ -27858,13 +28036,13 @@ function assessBatchSafety(args) {
27858
28036
  const signalGetters = new Set(args.graph.signals.map((s) => s.name));
27859
28037
  let sf;
27860
28038
  try {
27861
- sf = ts27.createSourceFile("__h.ts", `const __h = ${args.handler}`, ts27.ScriptTarget.Latest, true);
28039
+ sf = ts29.createSourceFile("__h.ts", `const __h = ${args.handler}`, ts29.ScriptTarget.Latest, true);
27862
28040
  } catch {
27863
28041
  return "unverified";
27864
28042
  }
27865
28043
  const calls = [];
27866
28044
  const visit3 = (node) => {
27867
- if (ts27.isCallExpression(node) && ts27.isIdentifier(node.expression)) {
28045
+ if (ts29.isCallExpression(node) && ts29.isIdentifier(node.expression)) {
27868
28046
  const name = node.expression.text;
27869
28047
  if (setters.has(name))
27870
28048
  calls.push({ pos: node.getStart(sf), kind: "write" });
@@ -27873,7 +28051,7 @@ function assessBatchSafety(args) {
27873
28051
  else if (!signalGetters.has(name) && !memoNames.has(name))
27874
28052
  calls.push({ pos: node.getStart(sf), kind: "risky" });
27875
28053
  }
27876
- ts27.forEachChild(node, visit3);
28054
+ ts29.forEachChild(node, visit3);
27877
28055
  };
27878
28056
  visit3(sf);
27879
28057
  calls.sort((a, b) => a.pos - b.pos);
@@ -28519,6 +28697,7 @@ export {
28519
28697
  serializeParsedExpr,
28520
28698
  searchParamsLocalNames,
28521
28699
  rewriteImportsForTemplate,
28700
+ rewriteDynamicImportsInSource,
28522
28701
  resolveStaticLoopSource,
28523
28702
  resolveSetters,
28524
28703
  resolveDangerousInnerHtml,