@barefootjs/vite 0.31.4 → 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.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { mkdir as mkdir2, readFile as readFile2, rm, writeFile as writeFile2 } f
3
3
  import { relative as relative2, resolve as resolve7, sep as sep3 } from "node:path";
4
4
 
5
5
  // ../jsx/src/compiler.ts
6
- import ts23 from "typescript";
6
+ import ts24 from "typescript";
7
7
 
8
8
  // ../jsx/src/analyzer.ts
9
9
  import ts9 from "typescript";
@@ -8661,7 +8661,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
8661
8661
  }
8662
8662
 
8663
8663
  // ../jsx/src/jsx-to-ir.ts
8664
- import ts12 from "typescript";
8664
+ import ts13 from "typescript";
8665
8665
 
8666
8666
  // ../jsx/src/types.ts
8667
8667
  var SCOPE_FORBIDDEN = {
@@ -8760,6 +8760,7 @@ function pickAttrMetaFromIR(src) {
8760
8760
  }
8761
8761
 
8762
8762
  // ../jsx/src/module-exports.ts
8763
+ import ts10 from "typescript";
8763
8764
  function generateModuleExports(ir, extraInlineExported = new Set, rewriteRelativeImport, options) {
8764
8765
  const lines = [];
8765
8766
  for (const constant of options?.skipValueDeclarations ? [] : ir.metadata.localConstants) {
@@ -8856,6 +8857,49 @@ function findReachableNames(primaryRefs, declarations) {
8856
8857
  }
8857
8858
  return reachable;
8858
8859
  }
8860
+ function findAssignedNames(bodyText, candidates) {
8861
+ const assigned = new Set;
8862
+ if (candidates.size === 0)
8863
+ return assigned;
8864
+ const sf = ts10.createSourceFile("bf-assignment-scan.tsx", bodyText, ts10.ScriptTarget.Latest, false, ts10.ScriptKind.TSX);
8865
+ const record = (target) => {
8866
+ if (ts10.isIdentifier(target) && candidates.has(target.text)) {
8867
+ assigned.add(target.text);
8868
+ }
8869
+ };
8870
+ const visit2 = (node) => {
8871
+ if (ts10.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
8872
+ record(node.left);
8873
+ } else if ((ts10.isPrefixUnaryExpression(node) || ts10.isPostfixUnaryExpression(node)) && (node.operator === ts10.SyntaxKind.PlusPlusToken || node.operator === ts10.SyntaxKind.MinusMinusToken)) {
8874
+ record(node.operand);
8875
+ }
8876
+ ts10.forEachChild(node, visit2);
8877
+ };
8878
+ ts10.forEachChild(sf, visit2);
8879
+ return assigned;
8880
+ }
8881
+ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
8882
+ let reachable = findReachableNames(primaryRefs, declarations);
8883
+ if (mutableNames.size === 0)
8884
+ return reachable;
8885
+ let seedText = primaryRefs;
8886
+ for (let round = 0;round <= declarations.length; round++) {
8887
+ const survivingMutables = new Set([...reachable].filter((name) => mutableNames.has(name)));
8888
+ if (survivingMutables.size === 0)
8889
+ return reachable;
8890
+ const added = declarations.filter((d) => !reachable.has(d.name)).filter((d) => findAssignedNames(d.body, survivingMutables).size > 0).map((d) => d.name);
8891
+ if (added.length === 0)
8892
+ return reachable;
8893
+ seedText += `
8894
+ ` + added.join(`
8895
+ `);
8896
+ reachable = findReachableNames(seedText, declarations);
8897
+ }
8898
+ return reachable;
8899
+ }
8900
+ function isAssignmentOperator(kind) {
8901
+ return kind >= ts10.SyntaxKind.FirstAssignment && kind <= ts10.SyntaxKind.LastAssignment;
8902
+ }
8859
8903
 
8860
8904
  // ../jsx/src/builtins.ts
8861
8905
  var CLIENT_BUILTIN_SOURCE = "@barefootjs/client";
@@ -8878,7 +8922,7 @@ function stripClientBuiltinImports(imports) {
8878
8922
  }
8879
8923
 
8880
8924
  // ../jsx/src/reactivity-checker.ts
8881
- import ts10 from "typescript";
8925
+ import ts11 from "typescript";
8882
8926
  var REACTIVE_BRAND = "__reactive";
8883
8927
  function queryType(checker, node) {
8884
8928
  incrementCounter("typeCheckerQueries");
@@ -8896,7 +8940,7 @@ function safeGetText(node) {
8896
8940
  }
8897
8941
  }
8898
8942
  function analyze(node, checker) {
8899
- if (ts10.isPropertyAccessExpression(node)) {
8943
+ if (ts11.isPropertyAccessExpression(node)) {
8900
8944
  try {
8901
8945
  const type = queryType(checker, node);
8902
8946
  if (isReactiveType(type)) {
@@ -8920,7 +8964,7 @@ function analyze(node, checker) {
8920
8964
  }
8921
8965
  return NOT_REACTIVE;
8922
8966
  }
8923
- if (ts10.isIdentifier(node)) {
8967
+ if (ts11.isIdentifier(node)) {
8924
8968
  try {
8925
8969
  const type = queryType(checker, node);
8926
8970
  if (isReactiveType(type)) {
@@ -8932,7 +8976,7 @@ function analyze(node, checker) {
8932
8976
  } catch {}
8933
8977
  return NOT_REACTIVE;
8934
8978
  }
8935
- if (ts10.isCallExpression(node)) {
8979
+ if (ts11.isCallExpression(node)) {
8936
8980
  try {
8937
8981
  const calleeType = queryType(checker, node.expression);
8938
8982
  if (isReactiveType(calleeType)) {
@@ -8945,7 +8989,7 @@ function analyze(node, checker) {
8945
8989
  }
8946
8990
  let foundChild;
8947
8991
  let foundChildText = "";
8948
- ts10.forEachChild(node, (child) => {
8992
+ ts11.forEachChild(node, (child) => {
8949
8993
  if (foundChild?.isReactive)
8950
8994
  return;
8951
8995
  const result = analyze(child, checker);
@@ -8974,7 +9018,7 @@ function containsReactiveExpression(node, checker) {
8974
9018
  }
8975
9019
 
8976
9020
  // ../jsx/src/free-refs.ts
8977
- import ts11 from "typescript";
9021
+ import ts12 from "typescript";
8978
9022
  var _bindingMapCache = new WeakMap;
8979
9023
  function buildBindingMap(env) {
8980
9024
  const cached = _bindingMapCache.get(env);
@@ -9012,8 +9056,8 @@ function buildBindingMap(env) {
9012
9056
  for (const m of env.memos) {
9013
9057
  map.set(m.name, "memo-getter");
9014
9058
  }
9015
- if (env.loopParams) {
9016
- for (const name of env.loopParams)
9059
+ if (env.loopValueBoundNames) {
9060
+ for (const name of env.loopValueBoundNames)
9017
9061
  map.set(name, "render-item");
9018
9062
  }
9019
9063
  _bindingMapCache.set(env, map);
@@ -9042,20 +9086,20 @@ function defaultBindingScope(kind) {
9042
9086
  function collectIdentifiers2(node) {
9043
9087
  const out = [];
9044
9088
  const visit2 = (n, parent) => {
9045
- if (ts11.isIdentifier(n)) {
9046
- if (parent && ts11.isPropertyAccessExpression(parent) && parent.name === n)
9089
+ if (ts12.isIdentifier(n)) {
9090
+ if (parent && ts12.isPropertyAccessExpression(parent) && parent.name === n)
9047
9091
  return;
9048
- if (parent && ts11.isPropertyAssignment(parent) && parent.name === n)
9092
+ if (parent && ts12.isPropertyAssignment(parent) && parent.name === n)
9049
9093
  return;
9050
- if (parent && (ts11.isJsxOpeningElement(parent) || ts11.isJsxClosingElement(parent) || ts11.isJsxSelfClosingElement(parent)) && parent.tagName === n) {
9094
+ if (parent && (ts12.isJsxOpeningElement(parent) || ts12.isJsxClosingElement(parent) || ts12.isJsxSelfClosingElement(parent)) && parent.tagName === n) {
9051
9095
  return;
9052
9096
  }
9053
- if (parent && ts11.isJsxAttribute(parent) && parent.name === n)
9097
+ if (parent && ts12.isJsxAttribute(parent) && parent.name === n)
9054
9098
  return;
9055
9099
  out.push(n);
9056
9100
  return;
9057
9101
  }
9058
- ts11.forEachChild(n, (child) => visit2(child, n));
9102
+ ts12.forEachChild(n, (child) => visit2(child, n));
9059
9103
  };
9060
9104
  visit2(node);
9061
9105
  return out;
@@ -9064,7 +9108,7 @@ function collectReactiveBrandRefs(node, checker) {
9064
9108
  const out = [];
9065
9109
  const seen = new Set;
9066
9110
  const visit2 = (n) => {
9067
- if (ts11.isPropertyAccessExpression(n)) {
9111
+ if (ts12.isPropertyAccessExpression(n)) {
9068
9112
  try {
9069
9113
  const type = checker.getTypeAtLocation(n);
9070
9114
  if (isReactiveType(type)) {
@@ -9082,7 +9126,7 @@ function collectReactiveBrandRefs(node, checker) {
9082
9126
  incrementCounter("freeRefsTypeLookupFailures");
9083
9127
  }
9084
9128
  }
9085
- ts11.forEachChild(n, visit2);
9129
+ ts12.forEachChild(n, visit2);
9086
9130
  };
9087
9131
  visit2(node);
9088
9132
  return out;
@@ -9092,14 +9136,14 @@ function resolveConstantInitializerRefs(c, env, visited) {
9092
9136
  return [];
9093
9137
  if (c.containsArrow)
9094
9138
  return [];
9095
- const sf = ts11.createSourceFile("__const_init.ts", `const __probe = (${c.value});`, ts11.ScriptTarget.Latest, true);
9139
+ const sf = ts12.createSourceFile("__const_init.ts", `const __probe = (${c.value});`, ts12.ScriptTarget.Latest, true);
9096
9140
  const stmt = sf.statements[0];
9097
- if (!stmt || !ts11.isVariableStatement(stmt))
9141
+ if (!stmt || !ts12.isVariableStatement(stmt))
9098
9142
  return [];
9099
9143
  const decl = stmt.declarationList.declarations[0];
9100
9144
  if (!decl || !decl.initializer)
9101
9145
  return [];
9102
- const expr = ts11.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
9146
+ const expr = ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
9103
9147
  return resolveFreeRefsInternal(expr, env, visited);
9104
9148
  }
9105
9149
  function resolveFreeRefsInternal(node, env, visited) {
@@ -9111,7 +9155,7 @@ function resolveFreeRefsInternal(node, env, visited) {
9111
9155
  const name = ident.text;
9112
9156
  if (env.propsObjectName === name) {
9113
9157
  const parent = ident.parent;
9114
- if (parent && ts11.isPropertyAccessExpression(parent) && parent.expression === ident && parent.name.text === "children") {
9158
+ if (parent && ts12.isPropertyAccessExpression(parent) && parent.expression === ident && parent.name.text === "children") {
9115
9159
  continue;
9116
9160
  }
9117
9161
  }
@@ -9539,13 +9583,13 @@ function exprCallsReactiveGetters(expr, ctx) {
9539
9583
  function visit2(n) {
9540
9584
  if (found)
9541
9585
  return;
9542
- if (ts12.isCallExpression(n) && ts12.isIdentifier(n.expression)) {
9586
+ if (ts13.isCallExpression(n) && ts13.isIdentifier(n.expression)) {
9543
9587
  if (names.has(n.expression.text)) {
9544
9588
  found = true;
9545
9589
  return;
9546
9590
  }
9547
9591
  }
9548
- ts12.forEachChild(n, visit2);
9592
+ ts13.forEachChild(n, visit2);
9549
9593
  }
9550
9594
  visit2(expr);
9551
9595
  return found;
@@ -9572,11 +9616,11 @@ function exprReferencesModuleClientSignal(expr, ctx) {
9572
9616
  function visit2(n) {
9573
9617
  if (found)
9574
9618
  return;
9575
- if (ts12.isCallExpression(n) && ts12.isIdentifier(n.expression) && names.has(n.expression.text)) {
9619
+ if (ts13.isCallExpression(n) && ts13.isIdentifier(n.expression) && names.has(n.expression.text)) {
9576
9620
  found = true;
9577
9621
  return;
9578
9622
  }
9579
- ts12.forEachChild(n, visit2);
9623
+ ts13.forEachChild(n, visit2);
9580
9624
  }
9581
9625
  visit2(expr);
9582
9626
  return found;
@@ -9586,11 +9630,11 @@ function exprHasFunctionCalls(expr) {
9586
9630
  function visit2(n) {
9587
9631
  if (found)
9588
9632
  return;
9589
- if (ts12.isCallExpression(n)) {
9633
+ if (ts13.isCallExpression(n)) {
9590
9634
  found = true;
9591
9635
  return;
9592
9636
  }
9593
- ts12.forEachChild(n, visit2);
9637
+ ts13.forEachChild(n, visit2);
9594
9638
  }
9595
9639
  visit2(expr);
9596
9640
  return found;
@@ -9627,10 +9671,10 @@ function lowerDateCalls(text, expr, ctx) {
9627
9671
  return text;
9628
9672
  const candidates = [];
9629
9673
  function visit2(n) {
9630
- if (ts12.isCallExpression(n) && n.arguments.length === 0 && ts12.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
9674
+ if (ts13.isCallExpression(n) && n.arguments.length === 0 && ts13.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
9631
9675
  candidates.push(n);
9632
9676
  }
9633
- ts12.forEachChild(n, visit2);
9677
+ ts13.forEachChild(n, visit2);
9634
9678
  }
9635
9679
  visit2(expr);
9636
9680
  if (candidates.length === 0)
@@ -9655,10 +9699,10 @@ function lowerToLocaleDateCalls(text, expr, ctx) {
9655
9699
  return text;
9656
9700
  const candidates = [];
9657
9701
  function visit2(n) {
9658
- if (ts12.isCallExpression(n) && n.arguments.length === 2 && ts12.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
9702
+ if (ts13.isCallExpression(n) && n.arguments.length === 2 && ts13.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
9659
9703
  candidates.push(n);
9660
9704
  }
9661
- ts12.forEachChild(n, visit2);
9705
+ ts13.forEachChild(n, visit2);
9662
9706
  }
9663
9707
  visit2(expr);
9664
9708
  if (candidates.length === 0)
@@ -9712,10 +9756,10 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
9712
9756
  return;
9713
9757
  let acc;
9714
9758
  function visit2(n, parent) {
9715
- if (ts12.isIdentifier(n) && propDepsMap.has(n.text)) {
9716
- const isObjectKey = parent && ts12.isPropertyAssignment(parent) && parent.name === n;
9717
- const isShorthand = parent && ts12.isShorthandPropertyAssignment(parent) && parent.name === n;
9718
- const isAccessName = parent && ts12.isPropertyAccessExpression(parent) && parent.name === n;
9759
+ if (ts13.isIdentifier(n) && propDepsMap.has(n.text)) {
9760
+ const isObjectKey = parent && ts13.isPropertyAssignment(parent) && parent.name === n;
9761
+ const isShorthand = parent && ts13.isShorthandPropertyAssignment(parent) && parent.name === n;
9762
+ const isAccessName = parent && ts13.isPropertyAccessExpression(parent) && parent.name === n;
9719
9763
  if (!isObjectKey && !isShorthand && !isAccessName) {
9720
9764
  const deps = propDepsMap.get(n.text);
9721
9765
  if (deps && deps.size > 0) {
@@ -9726,7 +9770,7 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
9726
9770
  }
9727
9771
  }
9728
9772
  }
9729
- ts12.forEachChild(n, (child) => visit2(child, n));
9773
+ ts13.forEachChild(n, (child) => visit2(child, n));
9730
9774
  }
9731
9775
  visit2(node);
9732
9776
  return acc;
@@ -9802,21 +9846,21 @@ function createTransformContext(analyzer) {
9802
9846
  function buildComponentNamespaces(ctx) {
9803
9847
  const result = new Map;
9804
9848
  for (const stmt of ctx.sourceFile.statements) {
9805
- if (!ts12.isVariableStatement(stmt))
9849
+ if (!ts13.isVariableStatement(stmt))
9806
9850
  continue;
9807
9851
  for (const decl of stmt.declarationList.declarations) {
9808
- if (!decl.initializer || !ts12.isIdentifier(decl.name))
9852
+ if (!decl.initializer || !ts13.isIdentifier(decl.name))
9809
9853
  continue;
9810
9854
  let init = decl.initializer;
9811
- while (ts12.isParenthesizedExpression(init))
9855
+ while (ts13.isParenthesizedExpression(init))
9812
9856
  init = init.expression;
9813
- if (!ts12.isObjectLiteralExpression(init))
9857
+ if (!ts13.isObjectLiteralExpression(init))
9814
9858
  continue;
9815
9859
  const members = new Map;
9816
9860
  for (const prop of init.properties) {
9817
- if (ts12.isShorthandPropertyAssignment(prop)) {
9861
+ if (ts13.isShorthandPropertyAssignment(prop)) {
9818
9862
  members.set(prop.name.text, prop.name.text);
9819
- } else if (ts12.isPropertyAssignment(prop) && (ts12.isIdentifier(prop.name) || ts12.isStringLiteral(prop.name)) && ts12.isIdentifier(prop.initializer)) {
9863
+ } else if (ts13.isPropertyAssignment(prop) && (ts13.isIdentifier(prop.name) || ts13.isStringLiteral(prop.name)) && ts13.isIdentifier(prop.initializer)) {
9820
9864
  members.set(prop.name.text, prop.initializer.text);
9821
9865
  }
9822
9866
  }
@@ -9828,11 +9872,11 @@ function buildComponentNamespaces(ctx) {
9828
9872
  return result;
9829
9873
  }
9830
9874
  function resolveMemberExpressionTag(tagNode, ctx) {
9831
- if (!ts12.isPropertyAccessExpression(tagNode))
9875
+ if (!ts13.isPropertyAccessExpression(tagNode))
9832
9876
  return null;
9833
- if (!ts12.isIdentifier(tagNode.expression))
9877
+ if (!ts13.isIdentifier(tagNode.expression))
9834
9878
  return null;
9835
- if (!ts12.isIdentifier(tagNode.name))
9879
+ if (!ts13.isIdentifier(tagNode.name))
9836
9880
  return null;
9837
9881
  if (!ctx._componentNamespaces) {
9838
9882
  ctx._componentNamespaces = buildComponentNamespaces(ctx);
@@ -9865,7 +9909,7 @@ function makeBindingEnv(ctx) {
9865
9909
  localFunctions: a.localFunctions,
9866
9910
  imports: a.imports,
9867
9911
  ambientGlobals: a.ambientGlobals,
9868
- loopParams: boundNames,
9912
+ loopValueBoundNames: boundNames,
9869
9913
  checker: a.checker
9870
9914
  };
9871
9915
  ctx._bindingEnv = env;
@@ -9989,7 +10033,7 @@ function buildIRRoot(analyzer) {
9989
10033
  return null;
9990
10034
  const ctx = createTransformContext(analyzer);
9991
10035
  const jsxReturn = analyzer.jsxReturn;
9992
- if (ts12.isJsxElement(jsxReturn) || ts12.isJsxSelfClosingElement(jsxReturn) || ts12.isJsxFragment(jsxReturn)) {
10036
+ if (ts13.isJsxElement(jsxReturn) || ts13.isJsxSelfClosingElement(jsxReturn) || ts13.isJsxFragment(jsxReturn)) {
9993
10037
  const ir2 = transformNode(jsxReturn, ctx);
9994
10038
  if (ir2 && needsScopeWrapper(ir2)) {
9995
10039
  return wrapInScopeElement(ir2);
@@ -10045,22 +10089,22 @@ function wrapInScopeElement(node) {
10045
10089
  };
10046
10090
  }
10047
10091
  function transformNode(node, ctx) {
10048
- if (ts12.isJsxElement(node)) {
10092
+ if (ts13.isJsxElement(node)) {
10049
10093
  return transformJsxElement(node, ctx);
10050
10094
  }
10051
- if (ts12.isJsxSelfClosingElement(node)) {
10095
+ if (ts13.isJsxSelfClosingElement(node)) {
10052
10096
  return transformSelfClosingElement(node, ctx);
10053
10097
  }
10054
- if (ts12.isJsxFragment(node)) {
10098
+ if (ts13.isJsxFragment(node)) {
10055
10099
  return transformFragment(node, ctx);
10056
10100
  }
10057
- if (ts12.isJsxText(node)) {
10101
+ if (ts13.isJsxText(node)) {
10058
10102
  return transformText(node, ctx);
10059
10103
  }
10060
- if (ts12.isJsxExpression(node)) {
10104
+ if (ts13.isJsxExpression(node)) {
10061
10105
  return transformExpression(node, ctx);
10062
10106
  }
10063
- if (ts12.isConditionalExpression(node)) {
10107
+ if (ts13.isConditionalExpression(node)) {
10064
10108
  return transformConditional(node, ctx);
10065
10109
  }
10066
10110
  return null;
@@ -10417,7 +10461,7 @@ function transformSelfClosingComponent(node, ctx, name) {
10417
10461
  }
10418
10462
  function isTransparentFragment(node, ctx) {
10419
10463
  const children = node.children.filter((child2) => {
10420
- if (ts12.isJsxText(child2)) {
10464
+ if (ts13.isJsxText(child2)) {
10421
10465
  return child2.text.trim() !== "";
10422
10466
  }
10423
10467
  return true;
@@ -10425,7 +10469,7 @@ function isTransparentFragment(node, ctx) {
10425
10469
  if (children.length !== 1)
10426
10470
  return false;
10427
10471
  const child = children[0];
10428
- if (!ts12.isJsxExpression(child))
10472
+ if (!ts13.isJsxExpression(child))
10429
10473
  return false;
10430
10474
  if (!child.expression)
10431
10475
  return false;
@@ -10469,7 +10513,7 @@ function transformChildren(children, ctx) {
10469
10513
  const result = [];
10470
10514
  for (let i = 0;i < children.length; i++) {
10471
10515
  const child = children[i];
10472
- if (ts12.isJsxExpression(child) && !child.expression) {
10516
+ if (ts13.isJsxExpression(child) && !child.expression) {
10473
10517
  continue;
10474
10518
  }
10475
10519
  const transformed = transformNode(child, ctx);
@@ -10484,10 +10528,10 @@ function transformChildren(children, ctx) {
10484
10528
  }
10485
10529
  function isRenderNothingLiteral(expr, ctx) {
10486
10530
  let e = expr;
10487
- while (ts12.isParenthesizedExpression(e) || ts12.isAsExpression(e) || ts12.isSatisfiesExpression(e) || ts12.isNonNullExpression(e)) {
10531
+ while (ts13.isParenthesizedExpression(e) || ts13.isAsExpression(e) || ts13.isSatisfiesExpression(e) || ts13.isNonNullExpression(e)) {
10488
10532
  e = e.expression;
10489
10533
  }
10490
- 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));
10534
+ 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));
10491
10535
  }
10492
10536
  function transformText(node, ctx) {
10493
10537
  const text = node.text.replace(/\s+/g, " ");
@@ -10513,7 +10557,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
10513
10557
  return null;
10514
10558
  }
10515
10559
  checkBareSignalOrMemoIdentifier(expr, ctx);
10516
- if (ts12.isIdentifier(expr)) {
10560
+ if (ts13.isIdentifier(expr)) {
10517
10561
  const jsxNode = ctx.analyzer.jsxConstants.get(expr.text);
10518
10562
  if (jsxNode) {
10519
10563
  return transformNode(jsxNode, ctx);
@@ -10792,38 +10836,38 @@ function transformLogicalAnd(node, ctx) {
10792
10836
  };
10793
10837
  }
10794
10838
  function containsJsxInExpression(node) {
10795
- if (ts12.isJsxElement(node) || ts12.isJsxSelfClosingElement(node) || ts12.isJsxFragment(node)) {
10839
+ if (ts13.isJsxElement(node) || ts13.isJsxSelfClosingElement(node) || ts13.isJsxFragment(node)) {
10796
10840
  return true;
10797
10841
  }
10798
- return ts12.forEachChild(node, containsJsxInExpression) ?? false;
10842
+ return ts13.forEachChild(node, containsJsxInExpression) ?? false;
10799
10843
  }
10800
10844
  function callsJsxHelper(node, ctx) {
10801
10845
  let found = false;
10802
10846
  const visit2 = (n) => {
10803
10847
  if (found)
10804
10848
  return;
10805
- if (ts12.isCallExpression(n) && ts12.isIdentifier(n.expression)) {
10849
+ if (ts13.isCallExpression(n) && ts13.isIdentifier(n.expression)) {
10806
10850
  const name = n.expression.text;
10807
10851
  if (ctx.analyzer.jsxFunctions.has(name) || ctx.analyzer.jsxMultiReturnFunctions.has(name)) {
10808
10852
  found = true;
10809
10853
  return;
10810
10854
  }
10811
10855
  }
10812
- ts12.forEachChild(n, visit2);
10856
+ ts13.forEachChild(n, visit2);
10813
10857
  };
10814
10858
  visit2(node);
10815
10859
  return found;
10816
10860
  }
10817
10861
  function containsAwaitExpression(node) {
10818
- if (ts12.isAwaitExpression(node))
10862
+ if (ts13.isAwaitExpression(node))
10819
10863
  return true;
10820
- if (ts12.isFunctionDeclaration(node) || ts12.isFunctionExpression(node) || ts12.isArrowFunction(node))
10864
+ if (ts13.isFunctionDeclaration(node) || ts13.isFunctionExpression(node) || ts13.isArrowFunction(node))
10821
10865
  return false;
10822
- return ts12.forEachChild(node, containsAwaitExpression) ?? false;
10866
+ return ts13.forEachChild(node, containsAwaitExpression) ?? false;
10823
10867
  }
10824
10868
  function transformNullishCoalescing(node, ctx) {
10825
10869
  const leftText = ctx.getJS(node.left);
10826
- const isNullish = node.operatorToken.kind === ts12.SyntaxKind.QuestionQuestionToken;
10870
+ const isNullish = node.operatorToken.kind === ts13.SyntaxKind.QuestionQuestionToken;
10827
10871
  const condition = isNullish ? `${leftText} != null` : leftText;
10828
10872
  const leftOrigin = {
10829
10873
  phase: "tick",
@@ -10869,36 +10913,36 @@ function transformNullishCoalescing(node, ctx) {
10869
10913
  }
10870
10914
  function assertNever2(expr) {
10871
10915
  const kind = expr?.kind;
10872
- 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.`);
10916
+ 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.`);
10873
10917
  }
10874
10918
  function transformJsxExpression(expr, ctx, isClientOnly = false) {
10875
10919
  const node = expr;
10876
10920
  switch (node.kind) {
10877
- case ts12.SyntaxKind.ParenthesizedExpression:
10878
- case ts12.SyntaxKind.AsExpression:
10879
- case ts12.SyntaxKind.SatisfiesExpression:
10880
- case ts12.SyntaxKind.NonNullExpression:
10881
- case ts12.SyntaxKind.TypeAssertionExpression:
10882
- case ts12.SyntaxKind.PartiallyEmittedExpression:
10921
+ case ts13.SyntaxKind.ParenthesizedExpression:
10922
+ case ts13.SyntaxKind.AsExpression:
10923
+ case ts13.SyntaxKind.SatisfiesExpression:
10924
+ case ts13.SyntaxKind.NonNullExpression:
10925
+ case ts13.SyntaxKind.TypeAssertionExpression:
10926
+ case ts13.SyntaxKind.PartiallyEmittedExpression:
10883
10927
  return transformJsxExpression(node.expression, ctx, isClientOnly);
10884
- case ts12.SyntaxKind.JsxElement:
10928
+ case ts13.SyntaxKind.JsxElement:
10885
10929
  return transformJsxElement(node, ctx);
10886
- case ts12.SyntaxKind.JsxFragment:
10930
+ case ts13.SyntaxKind.JsxFragment:
10887
10931
  return transformFragment(node, ctx);
10888
- case ts12.SyntaxKind.JsxSelfClosingElement:
10932
+ case ts13.SyntaxKind.JsxSelfClosingElement:
10889
10933
  return transformSelfClosingElement(node, ctx);
10890
- case ts12.SyntaxKind.ConditionalExpression:
10934
+ case ts13.SyntaxKind.ConditionalExpression:
10891
10935
  return transformConditional(node, ctx);
10892
- case ts12.SyntaxKind.BinaryExpression: {
10893
- if (node.operatorToken.kind === ts12.SyntaxKind.AmpersandAmpersandToken) {
10936
+ case ts13.SyntaxKind.BinaryExpression: {
10937
+ if (node.operatorToken.kind === ts13.SyntaxKind.AmpersandAmpersandToken) {
10894
10938
  return transformLogicalAnd(node, ctx);
10895
10939
  }
10896
- if ((node.operatorToken.kind === ts12.SyntaxKind.QuestionQuestionToken || node.operatorToken.kind === ts12.SyntaxKind.BarBarToken) && (containsJsxInExpression(node.right) || callsJsxHelper(node.right, ctx))) {
10940
+ if ((node.operatorToken.kind === ts13.SyntaxKind.QuestionQuestionToken || node.operatorToken.kind === ts13.SyntaxKind.BarBarToken) && (containsJsxInExpression(node.right) || callsJsxHelper(node.right, ctx))) {
10897
10941
  return transformNullishCoalescing(node, ctx);
10898
10942
  }
10899
10943
  return null;
10900
10944
  }
10901
- case ts12.SyntaxKind.CallExpression: {
10945
+ case ts13.SyntaxKind.CallExpression: {
10902
10946
  const mapMethod = getMapLikeMethod(node);
10903
10947
  if (mapMethod) {
10904
10948
  const mapResult = transformMapCall(node, ctx, isClientOnly, mapMethod);
@@ -10906,7 +10950,7 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
10906
10950
  return mapResult;
10907
10951
  }
10908
10952
  const callee = node.expression;
10909
- if (ts12.isIdentifier(callee)) {
10953
+ if (ts13.isIdentifier(callee)) {
10910
10954
  const jsxFunc = ctx.analyzer.jsxFunctions.get(callee.text);
10911
10955
  if (jsxFunc) {
10912
10956
  return transformJsxFunctionCall(node, jsxFunc, ctx, isClientOnly);
@@ -10918,39 +10962,39 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
10918
10962
  }
10919
10963
  return null;
10920
10964
  }
10921
- case ts12.SyntaxKind.Identifier:
10922
- case ts12.SyntaxKind.StringLiteral:
10923
- case ts12.SyntaxKind.NumericLiteral:
10924
- case ts12.SyntaxKind.BigIntLiteral:
10925
- case ts12.SyntaxKind.RegularExpressionLiteral:
10926
- case ts12.SyntaxKind.NoSubstitutionTemplateLiteral:
10927
- case ts12.SyntaxKind.TemplateExpression:
10928
- case ts12.SyntaxKind.TaggedTemplateExpression:
10929
- case ts12.SyntaxKind.TrueKeyword:
10930
- case ts12.SyntaxKind.FalseKeyword:
10931
- case ts12.SyntaxKind.NullKeyword:
10932
- case ts12.SyntaxKind.ThisKeyword:
10933
- case ts12.SyntaxKind.SuperKeyword:
10934
- case ts12.SyntaxKind.ImportKeyword:
10935
- case ts12.SyntaxKind.PropertyAccessExpression:
10936
- case ts12.SyntaxKind.ElementAccessExpression:
10937
- case ts12.SyntaxKind.PrefixUnaryExpression:
10938
- case ts12.SyntaxKind.PostfixUnaryExpression:
10939
- case ts12.SyntaxKind.TypeOfExpression:
10940
- case ts12.SyntaxKind.VoidExpression:
10941
- case ts12.SyntaxKind.DeleteExpression:
10942
- case ts12.SyntaxKind.NewExpression:
10943
- case ts12.SyntaxKind.ObjectLiteralExpression:
10944
- case ts12.SyntaxKind.ArrowFunction:
10945
- case ts12.SyntaxKind.FunctionExpression:
10946
- case ts12.SyntaxKind.ClassExpression:
10947
- case ts12.SyntaxKind.MetaProperty:
10948
- case ts12.SyntaxKind.ExpressionWithTypeArguments:
10949
- case ts12.SyntaxKind.CommaListExpression:
10950
- case ts12.SyntaxKind.SyntheticExpression:
10951
- case ts12.SyntaxKind.ArrayLiteralExpression:
10965
+ case ts13.SyntaxKind.Identifier:
10966
+ case ts13.SyntaxKind.StringLiteral:
10967
+ case ts13.SyntaxKind.NumericLiteral:
10968
+ case ts13.SyntaxKind.BigIntLiteral:
10969
+ case ts13.SyntaxKind.RegularExpressionLiteral:
10970
+ case ts13.SyntaxKind.NoSubstitutionTemplateLiteral:
10971
+ case ts13.SyntaxKind.TemplateExpression:
10972
+ case ts13.SyntaxKind.TaggedTemplateExpression:
10973
+ case ts13.SyntaxKind.TrueKeyword:
10974
+ case ts13.SyntaxKind.FalseKeyword:
10975
+ case ts13.SyntaxKind.NullKeyword:
10976
+ case ts13.SyntaxKind.ThisKeyword:
10977
+ case ts13.SyntaxKind.SuperKeyword:
10978
+ case ts13.SyntaxKind.ImportKeyword:
10979
+ case ts13.SyntaxKind.PropertyAccessExpression:
10980
+ case ts13.SyntaxKind.ElementAccessExpression:
10981
+ case ts13.SyntaxKind.PrefixUnaryExpression:
10982
+ case ts13.SyntaxKind.PostfixUnaryExpression:
10983
+ case ts13.SyntaxKind.TypeOfExpression:
10984
+ case ts13.SyntaxKind.VoidExpression:
10985
+ case ts13.SyntaxKind.DeleteExpression:
10986
+ case ts13.SyntaxKind.NewExpression:
10987
+ case ts13.SyntaxKind.ObjectLiteralExpression:
10988
+ case ts13.SyntaxKind.ArrowFunction:
10989
+ case ts13.SyntaxKind.FunctionExpression:
10990
+ case ts13.SyntaxKind.ClassExpression:
10991
+ case ts13.SyntaxKind.MetaProperty:
10992
+ case ts13.SyntaxKind.ExpressionWithTypeArguments:
10993
+ case ts13.SyntaxKind.CommaListExpression:
10994
+ case ts13.SyntaxKind.SyntheticExpression:
10995
+ case ts13.SyntaxKind.ArrayLiteralExpression:
10952
10996
  return null;
10953
- case ts12.SyntaxKind.AwaitExpression:
10997
+ case ts13.SyntaxKind.AwaitExpression:
10954
10998
  ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(node, ctx.sourceFile, ctx.filePath)));
10955
10999
  return {
10956
11000
  type: "expression",
@@ -10961,16 +11005,16 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
10961
11005
  loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
10962
11006
  origin: { phase: "tick", scope: "template", effect: "pure", freeRefs: [] }
10963
11007
  };
10964
- case ts12.SyntaxKind.YieldExpression:
11008
+ case ts13.SyntaxKind.YieldExpression:
10965
11009
  return null;
10966
- case ts12.SyntaxKind.SpreadElement:
10967
- case ts12.SyntaxKind.OmittedExpression:
10968
- case ts12.SyntaxKind.JsxExpression:
10969
- case ts12.SyntaxKind.JsxOpeningElement:
10970
- case ts12.SyntaxKind.JsxOpeningFragment:
10971
- case ts12.SyntaxKind.JsxClosingFragment:
10972
- case ts12.SyntaxKind.JsxAttributes:
10973
- case ts12.SyntaxKind.MissingDeclaration:
11010
+ case ts13.SyntaxKind.SpreadElement:
11011
+ case ts13.SyntaxKind.OmittedExpression:
11012
+ case ts13.SyntaxKind.JsxExpression:
11013
+ case ts13.SyntaxKind.JsxOpeningElement:
11014
+ case ts13.SyntaxKind.JsxOpeningFragment:
11015
+ case ts13.SyntaxKind.JsxClosingFragment:
11016
+ case ts13.SyntaxKind.JsxAttributes:
11017
+ case ts13.SyntaxKind.MissingDeclaration:
10974
11018
  return null;
10975
11019
  default:
10976
11020
  return assertNever2(node);
@@ -11007,7 +11051,7 @@ function transformConditionalBranch(node, ctx) {
11007
11051
  };
11008
11052
  }
11009
11053
  function getMapLikeMethod(node) {
11010
- if (!ts12.isPropertyAccessExpression(node.expression))
11054
+ if (!ts13.isPropertyAccessExpression(node.expression))
11011
11055
  return null;
11012
11056
  const name = node.expression.name.text;
11013
11057
  if (name === "map")
@@ -11017,9 +11061,9 @@ function getMapLikeMethod(node) {
11017
11061
  return null;
11018
11062
  }
11019
11063
  function isFilterCall(node) {
11020
- if (!ts12.isCallExpression(node))
11064
+ if (!ts13.isCallExpression(node))
11021
11065
  return null;
11022
- if (!ts12.isPropertyAccessExpression(node.expression))
11066
+ if (!ts13.isPropertyAccessExpression(node.expression))
11023
11067
  return null;
11024
11068
  if (node.expression.name.text !== "filter")
11025
11069
  return null;
@@ -11031,9 +11075,9 @@ function isFilterCall(node) {
11031
11075
  };
11032
11076
  }
11033
11077
  function isSortCall(node) {
11034
- if (!ts12.isCallExpression(node))
11078
+ if (!ts13.isCallExpression(node))
11035
11079
  return null;
11036
- if (!ts12.isPropertyAccessExpression(node.expression))
11080
+ if (!ts13.isPropertyAccessExpression(node.expression))
11037
11081
  return null;
11038
11082
  const methodName = node.expression.name.text;
11039
11083
  if (methodName !== "sort" && methodName !== "toSorted")
@@ -11047,9 +11091,9 @@ function isSortCall(node) {
11047
11091
  };
11048
11092
  }
11049
11093
  function isIteratorShapeCall(node) {
11050
- if (!ts12.isCallExpression(node))
11094
+ if (!ts13.isCallExpression(node))
11051
11095
  return null;
11052
- if (!ts12.isPropertyAccessExpression(node.expression))
11096
+ if (!ts13.isPropertyAccessExpression(node.expression))
11053
11097
  return null;
11054
11098
  if (node.arguments.length !== 0)
11055
11099
  return null;
@@ -11059,11 +11103,11 @@ function isIteratorShapeCall(node) {
11059
11103
  return { array: node.expression.expression, shape: name };
11060
11104
  }
11061
11105
  function isObjectIteratorCall(node) {
11062
- if (!ts12.isCallExpression(node))
11106
+ if (!ts13.isCallExpression(node))
11063
11107
  return null;
11064
- if (!ts12.isPropertyAccessExpression(node.expression))
11108
+ if (!ts13.isPropertyAccessExpression(node.expression))
11065
11109
  return null;
11066
- if (!ts12.isIdentifier(node.expression.expression))
11110
+ if (!ts13.isIdentifier(node.expression.expression))
11067
11111
  return null;
11068
11112
  if (node.expression.expression.text !== "Object")
11069
11113
  return null;
@@ -11088,7 +11132,7 @@ function extractSortComparator(callback, _method, ctx) {
11088
11132
  ` + `(reverse the operands for descending order).`
11089
11133
  });
11090
11134
  let resolvedNode = callback;
11091
- if (ts12.isIdentifier(callback)) {
11135
+ if (ts13.isIdentifier(callback)) {
11092
11136
  const resolved = resolveSortComparatorIdentifier(callback.text, ctx);
11093
11137
  if (!resolved) {
11094
11138
  return {
@@ -11098,7 +11142,7 @@ function extractSortComparator(callback, _method, ctx) {
11098
11142
  }
11099
11143
  resolvedNode = resolved;
11100
11144
  }
11101
- if (!ts12.isArrowFunction(resolvedNode) && !ts12.isFunctionExpression(resolvedNode)) {
11145
+ if (!ts13.isArrowFunction(resolvedNode) && !ts13.isFunctionExpression(resolvedNode)) {
11102
11146
  return {
11103
11147
  result: null,
11104
11148
  unsupportedReason: "Sort comparator must be an arrow function or function expression"
@@ -11125,11 +11169,11 @@ function resolveSortComparatorIdentifier(name, ctx) {
11125
11169
  return null;
11126
11170
  if (constInfo) {
11127
11171
  const ast = parseConstInitializer(constInfo);
11128
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11172
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11129
11173
  }
11130
11174
  if (fnInfo) {
11131
11175
  const ast = parseFunctionInfoAsExpr(fnInfo);
11132
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11176
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11133
11177
  }
11134
11178
  return null;
11135
11179
  }
@@ -11140,11 +11184,11 @@ function resolveCallbackMethodFunctionReferenceIdentifier(name, analyzer) {
11140
11184
  return null;
11141
11185
  if (constInfo) {
11142
11186
  const ast = parseConstInitializer(constInfo);
11143
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11187
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11144
11188
  }
11145
11189
  if (fnInfo) {
11146
11190
  const ast = parseFunctionInfoAsExpr(fnInfo);
11147
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
11191
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
11148
11192
  }
11149
11193
  return null;
11150
11194
  }
@@ -11200,13 +11244,13 @@ function resolveCallbackMethodFunctionReferences(expr, analyzer, bound = EMPTY_B
11200
11244
  return visit2(expr, bound);
11201
11245
  }
11202
11246
  function extractFilterPredicate(callback, ctx) {
11203
- if (!ts12.isArrowFunction(callback))
11247
+ if (!ts13.isArrowFunction(callback))
11204
11248
  return { result: null };
11205
11249
  if (callback.parameters.length < 1)
11206
11250
  return { result: null };
11207
11251
  const firstParam = callback.parameters[0];
11208
- if (!ts12.isIdentifier(firstParam.name)) {
11209
- if (ts12.isBlock(callback.body)) {
11252
+ if (!ts13.isIdentifier(firstParam.name)) {
11253
+ if (ts13.isBlock(callback.body)) {
11210
11254
  return {
11211
11255
  result: null,
11212
11256
  unsupportedReason: "Block body in a destructured filter param is not supported. Workaround: use an expression-body arrow, or add /* @client */."
@@ -11226,7 +11270,7 @@ function extractFilterPredicate(callback, ctx) {
11226
11270
  return { result: null };
11227
11271
  }
11228
11272
  const param = firstParam.name.getText(ctx.sourceFile);
11229
- if (ts12.isBlock(callback.body)) {
11273
+ if (ts13.isBlock(callback.body)) {
11230
11274
  const raw2 = ctx.getJS(callback.body);
11231
11275
  const statements = parseBlockBody(callback.body, ctx.sourceFile, (n) => ctx.getJS(n));
11232
11276
  if (!statements) {
@@ -11252,7 +11296,7 @@ function extractFilterPredicate(callback, ctx) {
11252
11296
  return { result: { param, predicate, raw } };
11253
11297
  }
11254
11298
  function extractLoopParamBindings(pattern) {
11255
- if (ts12.isIdentifier(pattern))
11299
+ if (ts13.isIdentifier(pattern))
11256
11300
  return null;
11257
11301
  const bindings = [];
11258
11302
  let unsupported = false;
@@ -11261,7 +11305,7 @@ function extractLoopParamBindings(pattern) {
11261
11305
  return false;
11262
11306
  for (let i = 0;i < key.length; ) {
11263
11307
  const cp = key.codePointAt(i);
11264
- const ok = i === 0 ? ts12.isIdentifierStart(cp, ts12.ScriptTarget.Latest) : ts12.isIdentifierPart(cp, ts12.ScriptTarget.Latest);
11308
+ const ok = i === 0 ? ts13.isIdentifierStart(cp, ts13.ScriptTarget.Latest) : ts13.isIdentifierPart(cp, ts13.ScriptTarget.Latest);
11265
11309
  if (!ok)
11266
11310
  return false;
11267
11311
  i += cp > 65535 ? 2 : 1;
@@ -11274,17 +11318,17 @@ function extractLoopParamBindings(pattern) {
11274
11318
  const walk = (p, prefix, segments) => {
11275
11319
  if (unsupported)
11276
11320
  return;
11277
- if (ts12.isArrayBindingPattern(p)) {
11321
+ if (ts13.isArrayBindingPattern(p)) {
11278
11322
  const elements2 = p.elements;
11279
11323
  for (let index = 0;index < elements2.length; index++) {
11280
11324
  if (unsupported)
11281
11325
  return;
11282
11326
  const el = elements2[index];
11283
- if (ts12.isOmittedExpression(el))
11327
+ if (ts13.isOmittedExpression(el))
11284
11328
  continue;
11285
11329
  if (el.dotDotDotToken) {
11286
11330
  internalInvariant(index === elements2.length - 1, "extractLoopParamBindings: array rest token in non-final position (parser should reject)");
11287
- internalInvariant(ts12.isIdentifier(el.name), "extractLoopParamBindings: array rest target is not an identifier (parser should reject)");
11331
+ internalInvariant(ts13.isIdentifier(el.name), "extractLoopParamBindings: array rest target is not an identifier (parser should reject)");
11288
11332
  bindings.push({
11289
11333
  name: el.name.text,
11290
11334
  path: prefix,
@@ -11295,7 +11339,7 @@ function extractLoopParamBindings(pattern) {
11295
11339
  }
11296
11340
  const path3 = `${prefix}[${index}]`;
11297
11341
  const nextSegments = [...segments, { kind: "index", index }];
11298
- if (ts12.isIdentifier(el.name)) {
11342
+ if (ts13.isIdentifier(el.name)) {
11299
11343
  bindings.push({ name: el.name.text, path: path3, segments: nextSegments });
11300
11344
  } else {
11301
11345
  walk(el.name, path3, nextSegments);
@@ -11311,7 +11355,7 @@ function extractLoopParamBindings(pattern) {
11311
11355
  const el = elements[i];
11312
11356
  if (el.dotDotDotToken) {
11313
11357
  internalInvariant(i === elements.length - 1, "extractLoopParamBindings: object rest token in non-final position (parser should reject)");
11314
- internalInvariant(ts12.isIdentifier(el.name), "extractLoopParamBindings: object rest target is not an identifier (parser should reject)");
11358
+ internalInvariant(ts13.isIdentifier(el.name), "extractLoopParamBindings: object rest target is not an identifier (parser should reject)");
11315
11359
  bindings.push({
11316
11360
  name: el.name.text,
11317
11361
  path: prefix,
@@ -11323,17 +11367,17 @@ function extractLoopParamBindings(pattern) {
11323
11367
  let keyText = null;
11324
11368
  if (el.propertyName) {
11325
11369
  const pn = el.propertyName;
11326
- if (ts12.isIdentifier(pn))
11370
+ if (ts13.isIdentifier(pn))
11327
11371
  keyText = pn.text;
11328
- else if (ts12.isStringLiteral(pn))
11372
+ else if (ts13.isStringLiteral(pn))
11329
11373
  keyText = pn.text;
11330
- else if (ts12.isNumericLiteral(pn))
11374
+ else if (ts13.isNumericLiteral(pn))
11331
11375
  keyText = pn.text;
11332
11376
  else {
11333
11377
  unsupported = true;
11334
11378
  return;
11335
11379
  }
11336
- } else if (ts12.isIdentifier(el.name)) {
11380
+ } else if (ts13.isIdentifier(el.name)) {
11337
11381
  keyText = el.name.text;
11338
11382
  } else {
11339
11383
  unsupported = true;
@@ -11343,14 +11387,14 @@ function extractLoopParamBindings(pattern) {
11343
11387
  collectedKeys.push({ key: keyText, isIdent: keyIsIdent });
11344
11388
  const path3 = appendDotAccess(prefix, keyText);
11345
11389
  const nextSegments = [...segments, { kind: "field", key: keyText, isIdent: keyIsIdent }];
11346
- if (ts12.isIdentifier(el.name)) {
11390
+ if (ts13.isIdentifier(el.name)) {
11347
11391
  bindings.push({ name: el.name.text, path: path3, segments: nextSegments });
11348
11392
  } else {
11349
11393
  walk(el.name, path3, nextSegments);
11350
11394
  }
11351
11395
  }
11352
11396
  };
11353
- if (ts12.isArrayBindingPattern(pattern) || ts12.isObjectBindingPattern(pattern)) {
11397
+ if (ts13.isArrayBindingPattern(pattern) || ts13.isObjectBindingPattern(pattern)) {
11354
11398
  walk(pattern, "", []);
11355
11399
  if (unsupported)
11356
11400
  return { unsupported: true };
@@ -11360,7 +11404,7 @@ function extractLoopParamBindings(pattern) {
11360
11404
  }
11361
11405
  function findKeyJsxAttribute(opening) {
11362
11406
  for (const prop of opening.attributes.properties) {
11363
- if (ts12.isJsxAttribute(prop) && prop.name.getText() === "key") {
11407
+ if (ts13.isJsxAttribute(prop) && prop.name.getText() === "key") {
11364
11408
  return prop;
11365
11409
  }
11366
11410
  }
@@ -11405,7 +11449,7 @@ function keyAttrValueToExpr(v) {
11405
11449
  function normalizeKeyExpr(expr) {
11406
11450
  let out = "";
11407
11451
  for (const tok of iterateJsTokens(expr)) {
11408
- if (tok.kind === ts12.SyntaxKind.WhitespaceTrivia || tok.kind === ts12.SyntaxKind.NewLineTrivia) {
11452
+ if (tok.kind === ts13.SyntaxKind.WhitespaceTrivia || tok.kind === ts13.SyntaxKind.NewLineTrivia) {
11409
11453
  continue;
11410
11454
  }
11411
11455
  out += expr.slice(tok.pos, tok.end);
@@ -11417,13 +11461,13 @@ function conditionalHasExplicitNullishBranch(cond) {
11417
11461
  }
11418
11462
  function branchHasExplicitNullish(branch) {
11419
11463
  let b = branch;
11420
- while (ts12.isParenthesizedExpression(b))
11464
+ while (ts13.isParenthesizedExpression(b))
11421
11465
  b = b.expression;
11422
- if (b.kind === ts12.SyntaxKind.NullKeyword)
11466
+ if (b.kind === ts13.SyntaxKind.NullKeyword)
11423
11467
  return true;
11424
- if (ts12.isIdentifier(b) && b.text === "undefined")
11468
+ if (ts13.isIdentifier(b) && b.text === "undefined")
11425
11469
  return true;
11426
- if (ts12.isConditionalExpression(b))
11470
+ if (ts13.isConditionalExpression(b))
11427
11471
  return conditionalHasExplicitNullishBranch(b);
11428
11472
  return false;
11429
11473
  }
@@ -11432,26 +11476,26 @@ function classifyKeyProblem(keyAttr, checker) {
11432
11476
  return "missing";
11433
11477
  if (!keyAttr.initializer)
11434
11478
  return "missing";
11435
- if (ts12.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
11479
+ if (ts13.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
11436
11480
  return "missing";
11437
11481
  }
11438
11482
  let expr;
11439
- if (ts12.isStringLiteral(keyAttr.initializer)) {
11483
+ if (ts13.isStringLiteral(keyAttr.initializer)) {
11440
11484
  return null;
11441
- } else if (ts12.isJsxExpression(keyAttr.initializer)) {
11485
+ } else if (ts13.isJsxExpression(keyAttr.initializer)) {
11442
11486
  expr = keyAttr.initializer.expression;
11443
11487
  }
11444
11488
  if (!expr)
11445
11489
  return null;
11446
- if (expr.kind === ts12.SyntaxKind.NullKeyword)
11490
+ if (expr.kind === ts13.SyntaxKind.NullKeyword)
11447
11491
  return null;
11448
- if (ts12.isIdentifier(expr) && expr.text === "undefined")
11492
+ if (ts13.isIdentifier(expr) && expr.text === "undefined")
11449
11493
  return null;
11450
- if (ts12.isConditionalExpression(expr) && conditionalHasExplicitNullishBranch(expr))
11494
+ if (ts13.isConditionalExpression(expr) && conditionalHasExplicitNullishBranch(expr))
11451
11495
  return null;
11452
11496
  if (checker) {
11453
11497
  const type = checker.getTypeAtLocation(expr);
11454
- 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;
11498
+ 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;
11455
11499
  if (isNullable)
11456
11500
  return "nullable-type";
11457
11501
  }
@@ -11477,81 +11521,81 @@ function checkLoopKey(callback, ctx, isNested) {
11477
11521
  ctx.analyzer.errors.push(createError(errorCode, getSourceLocation(locNode, ctx.sourceFile, ctx.filePath), { suggestion: { message: keyErrorSuggestion(problem) } }));
11478
11522
  }
11479
11523
  let body = callback.body;
11480
- if (ts12.isBlock(body)) {
11481
- const ret = body.statements.find((s) => ts12.isReturnStatement(s) && s.expression != null);
11524
+ if (ts13.isBlock(body)) {
11525
+ const ret = body.statements.find((s) => ts13.isReturnStatement(s) && s.expression != null);
11482
11526
  if (!ret?.expression)
11483
11527
  return;
11484
11528
  body = ret.expression;
11485
11529
  }
11486
- while (ts12.isParenthesizedExpression(body))
11530
+ while (ts13.isParenthesizedExpression(body))
11487
11531
  body = body.expression;
11488
11532
  function checkJsxOperand(node) {
11489
11533
  let n = node;
11490
- while (ts12.isParenthesizedExpression(n))
11534
+ while (ts13.isParenthesizedExpression(n))
11491
11535
  n = n.expression;
11492
- if (ts12.isJsxElement(n))
11536
+ if (ts13.isJsxElement(n))
11493
11537
  checkOpening(n.openingElement);
11494
- else if (ts12.isJsxSelfClosingElement(n))
11538
+ else if (ts13.isJsxSelfClosingElement(n))
11495
11539
  checkOpening(n);
11496
11540
  }
11497
- if (ts12.isConditionalExpression(body)) {
11541
+ if (ts13.isConditionalExpression(body)) {
11498
11542
  checkJsxOperand(body.whenTrue);
11499
11543
  checkJsxOperand(body.whenFalse);
11500
11544
  return;
11501
11545
  }
11502
- if (ts12.isBinaryExpression(body) && (body.operatorToken.kind === ts12.SyntaxKind.AmpersandAmpersandToken || body.operatorToken.kind === ts12.SyntaxKind.BarBarToken || body.operatorToken.kind === ts12.SyntaxKind.QuestionQuestionToken)) {
11546
+ if (ts13.isBinaryExpression(body) && (body.operatorToken.kind === ts13.SyntaxKind.AmpersandAmpersandToken || body.operatorToken.kind === ts13.SyntaxKind.BarBarToken || body.operatorToken.kind === ts13.SyntaxKind.QuestionQuestionToken)) {
11503
11547
  checkJsxOperand(body.left);
11504
11548
  checkJsxOperand(body.right);
11505
11549
  return;
11506
11550
  }
11507
- if (ts12.isJsxElement(body)) {
11551
+ if (ts13.isJsxElement(body)) {
11508
11552
  checkOpening(body.openingElement);
11509
11553
  return;
11510
11554
  }
11511
- if (ts12.isJsxSelfClosingElement(body)) {
11555
+ if (ts13.isJsxSelfClosingElement(body)) {
11512
11556
  checkOpening(body);
11513
11557
  return;
11514
11558
  }
11515
11559
  }
11516
11560
  function flatMapProjectionCall(body) {
11517
11561
  let expr;
11518
- if (ts12.isBlock(body)) {
11562
+ if (ts13.isBlock(body)) {
11519
11563
  const real = body.statements;
11520
- if (real.length !== 1 || !ts12.isReturnStatement(real[0]) || !real[0].expression)
11564
+ if (real.length !== 1 || !ts13.isReturnStatement(real[0]) || !real[0].expression)
11521
11565
  return null;
11522
11566
  expr = real[0].expression;
11523
11567
  } else {
11524
11568
  expr = body;
11525
11569
  }
11526
- while (ts12.isParenthesizedExpression(expr))
11570
+ while (ts13.isParenthesizedExpression(expr))
11527
11571
  expr = expr.expression;
11528
- if (!ts12.isCallExpression(expr))
11572
+ if (!ts13.isCallExpression(expr))
11529
11573
  return null;
11530
11574
  if (!getMapLikeMethod(expr))
11531
11575
  return null;
11532
11576
  const cb = expr.arguments[0];
11533
- if (!cb || !ts12.isArrowFunction(cb) && !ts12.isFunctionExpression(cb))
11577
+ if (!cb || !ts13.isArrowFunction(cb) && !ts13.isFunctionExpression(cb))
11534
11578
  return null;
11535
11579
  for (const p of cb.parameters) {
11536
- if (!ts12.isIdentifier(p.name))
11580
+ if (!ts13.isIdentifier(p.name))
11537
11581
  return null;
11538
11582
  }
11539
11583
  let innerBody = cb.body;
11540
- if (ts12.isBlock(innerBody)) {
11541
- const ret = innerBody.statements.find((s) => ts12.isReturnStatement(s) && s.expression != null);
11584
+ if (ts13.isBlock(innerBody)) {
11585
+ const ret = innerBody.statements.find((s) => ts13.isReturnStatement(s) && s.expression != null);
11542
11586
  if (innerBody.statements.length !== 1 || !ret?.expression)
11543
11587
  return null;
11544
11588
  innerBody = ret.expression;
11545
11589
  }
11546
- while (ts12.isParenthesizedExpression(innerBody))
11590
+ while (ts13.isParenthesizedExpression(innerBody))
11547
11591
  innerBody = innerBody.expression;
11548
11592
  const isElementish = (n) => {
11549
11593
  let m = n;
11550
- while (ts12.isParenthesizedExpression(m))
11594
+ while (ts13.isParenthesizedExpression(m))
11551
11595
  m = m.expression;
11552
- if (ts12.isJsxElement(m) || ts12.isJsxSelfClosingElement(m))
11596
+ if (ts13.isJsxElement(m) || ts13.isJsxSelfClosingElement(m))
11553
11597
  return leafIsWirelessElement(m);
11554
- if (ts12.isConditionalExpression(m))
11598
+ if (ts13.isConditionalExpression(m))
11555
11599
  return isElementish(m.whenTrue) && isElementish(m.whenFalse);
11556
11600
  return false;
11557
11601
  };
@@ -11564,19 +11608,19 @@ function leafIsWirelessElement(el) {
11564
11608
  const visit2 = (n) => {
11565
11609
  if (!ok)
11566
11610
  return;
11567
- if (ts12.isJsxOpeningElement(n) || ts12.isJsxSelfClosingElement(n)) {
11611
+ if (ts13.isJsxOpeningElement(n) || ts13.isJsxSelfClosingElement(n)) {
11568
11612
  const tagNode = n.tagName;
11569
- const isIntrinsic = ts12.isIdentifier(tagNode) ? !/^[A-Z]/.test(tagNode.text) : ts12.isJsxNamespacedName(tagNode);
11613
+ const isIntrinsic = ts13.isIdentifier(tagNode) ? !/^[A-Z]/.test(tagNode.text) : ts13.isJsxNamespacedName(tagNode);
11570
11614
  if (!isIntrinsic) {
11571
11615
  ok = false;
11572
11616
  return;
11573
11617
  }
11574
11618
  for (const attr of n.attributes.properties) {
11575
- if (ts12.isJsxSpreadAttribute(attr)) {
11619
+ if (ts13.isJsxSpreadAttribute(attr)) {
11576
11620
  ok = false;
11577
11621
  return;
11578
11622
  }
11579
- if (ts12.isJsxAttribute(attr)) {
11623
+ if (ts13.isJsxAttribute(attr)) {
11580
11624
  const name = attr.name.getText();
11581
11625
  if (/^on[A-Z]/.test(name)) {
11582
11626
  ok = false;
@@ -11585,11 +11629,11 @@ function leafIsWirelessElement(el) {
11585
11629
  }
11586
11630
  }
11587
11631
  }
11588
- if (ts12.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
11632
+ if (ts13.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
11589
11633
  ok = false;
11590
11634
  return;
11591
11635
  }
11592
- ts12.forEachChild(n, visit2);
11636
+ ts13.forEachChild(n, visit2);
11593
11637
  };
11594
11638
  visit2(el);
11595
11639
  return ok;
@@ -11769,7 +11813,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
11769
11813
  let children = [];
11770
11814
  let paramBindings;
11771
11815
  let flatMapCallback;
11772
- if (ts12.isArrowFunction(callback)) {
11816
+ if (ts13.isArrowFunction(callback)) {
11773
11817
  if (callback.parameters.length > 0) {
11774
11818
  const firstParam = callback.parameters[0];
11775
11819
  param = firstParam.name.getText(ctx.sourceFile);
@@ -11777,9 +11821,9 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
11777
11821
  paramType = firstParam.type.getText(ctx.sourceFile);
11778
11822
  }
11779
11823
  const isEntriesShape = iterationShape === "entries" || objectIteration === "entries";
11780
- if (isEntriesShape && ts12.isArrayBindingPattern(firstParam.name)) {
11781
- const elements = firstParam.name.elements.filter((el) => !ts12.isOmittedExpression(el));
11782
- if (elements.length === 2 && ts12.isBindingElement(elements[0]) && ts12.isIdentifier(elements[0].name) && ts12.isBindingElement(elements[1]) && ts12.isIdentifier(elements[1].name)) {
11824
+ if (isEntriesShape && ts13.isArrayBindingPattern(firstParam.name)) {
11825
+ const elements = firstParam.name.elements.filter((el) => !ts13.isOmittedExpression(el));
11826
+ if (elements.length === 2 && ts13.isBindingElement(elements[0]) && ts13.isIdentifier(elements[0].name) && ts13.isBindingElement(elements[1]) && ts13.isIdentifier(elements[1].name)) {
11783
11827
  index = elements[0].name.text;
11784
11828
  param = elements[1].name.text;
11785
11829
  } else {
@@ -11810,10 +11854,10 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
11810
11854
  ctx.scope = ctx.scope.enterLoopRow({ param, index, paramBindings });
11811
11855
  ctx.loopDepth++;
11812
11856
  const tryTransformRenderableBody = (expr) => {
11813
- if (!ts12.isBinaryExpression(expr))
11857
+ if (!ts13.isBinaryExpression(expr))
11814
11858
  return;
11815
11859
  const op = expr.operatorToken.kind;
11816
- if (op !== ts12.SyntaxKind.AmpersandAmpersandToken && op !== ts12.SyntaxKind.BarBarToken && op !== ts12.SyntaxKind.QuestionQuestionToken) {
11860
+ if (op !== ts13.SyntaxKind.AmpersandAmpersandToken && op !== ts13.SyntaxKind.BarBarToken && op !== ts13.SyntaxKind.QuestionQuestionToken) {
11817
11861
  return;
11818
11862
  }
11819
11863
  if (!containsJsxInExpression(expr) && !callsJsxHelper(expr, ctx))
@@ -11823,33 +11867,33 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
11823
11867
  children = [transformed];
11824
11868
  };
11825
11869
  const body = callback.body;
11826
- if (ts12.isJsxElement(body) || ts12.isJsxSelfClosingElement(body) || ts12.isJsxFragment(body)) {
11870
+ if (ts13.isJsxElement(body) || ts13.isJsxSelfClosingElement(body) || ts13.isJsxFragment(body)) {
11827
11871
  const transformed = transformNode(body, ctx);
11828
11872
  if (transformed) {
11829
11873
  children = [transformed];
11830
11874
  }
11831
- } else if (ts12.isConditionalExpression(body)) {
11875
+ } else if (ts13.isConditionalExpression(body)) {
11832
11876
  children = [transformConditional(body, ctx)];
11833
- } else if (ts12.isParenthesizedExpression(body)) {
11877
+ } else if (ts13.isParenthesizedExpression(body)) {
11834
11878
  let inner = body.expression;
11835
- while (ts12.isParenthesizedExpression(inner)) {
11879
+ while (ts13.isParenthesizedExpression(inner)) {
11836
11880
  inner = inner.expression;
11837
11881
  }
11838
- if (ts12.isJsxElement(inner) || ts12.isJsxSelfClosingElement(inner) || ts12.isJsxFragment(inner)) {
11882
+ if (ts13.isJsxElement(inner) || ts13.isJsxSelfClosingElement(inner) || ts13.isJsxFragment(inner)) {
11839
11883
  const transformed = transformNode(inner, ctx);
11840
11884
  if (transformed) {
11841
11885
  children = [transformed];
11842
11886
  }
11843
- } else if (ts12.isConditionalExpression(inner)) {
11887
+ } else if (ts13.isConditionalExpression(inner)) {
11844
11888
  children = [transformConditional(inner, ctx)];
11845
- } else if (method === "flatMap" && ts12.isArrayLiteralExpression(inner)) {
11889
+ } else if (method === "flatMap" && ts13.isArrayLiteralExpression(inner)) {
11846
11890
  children = transformArrayLiteralChildren(inner, ctx);
11847
11891
  } else {
11848
11892
  tryTransformRenderableBody(inner);
11849
11893
  }
11850
- } else if (method === "flatMap" && ts12.isArrayLiteralExpression(body)) {
11894
+ } else if (method === "flatMap" && ts13.isArrayLiteralExpression(body)) {
11851
11895
  children = transformArrayLiteralChildren(body, ctx);
11852
- } else if (ts12.isBlock(body)) {
11896
+ } else if (ts13.isBlock(body)) {
11853
11897
  const multiReturn = method !== "flatMap" ? extractMultiReturnJsxBranches(body, true) : null;
11854
11898
  if (multiReturn && multiReturn.branches.length > 0) {
11855
11899
  const loc = getSourceLocation(body, ctx.sourceFile, ctx.filePath);
@@ -11867,7 +11911,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
11867
11911
  }
11868
11912
  }
11869
11913
  }
11870
- const returnStmt = children.length === 0 ? body.statements.find((s) => ts12.isReturnStatement(s) && s.expression != null) : undefined;
11914
+ const returnStmt = children.length === 0 ? body.statements.find((s) => ts13.isReturnStatement(s) && s.expression != null) : undefined;
11871
11915
  let rowScopeBeforePreamble = null;
11872
11916
  if (returnStmt) {
11873
11917
  const preambleNames = new Set;
@@ -11888,10 +11932,10 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
11888
11932
  }
11889
11933
  if (returnStmt && returnStmt.expression) {
11890
11934
  let returnExpr = returnStmt.expression;
11891
- while (ts12.isParenthesizedExpression(returnExpr)) {
11935
+ while (ts13.isParenthesizedExpression(returnExpr)) {
11892
11936
  returnExpr = returnExpr.expression;
11893
11937
  }
11894
- if (ts12.isJsxElement(returnExpr) || ts12.isJsxSelfClosingElement(returnExpr) || ts12.isJsxFragment(returnExpr)) {
11938
+ if (ts13.isJsxElement(returnExpr) || ts13.isJsxSelfClosingElement(returnExpr) || ts13.isJsxFragment(returnExpr)) {
11895
11939
  const transformed = transformNode(returnExpr, ctx);
11896
11940
  if (transformed) {
11897
11941
  children = [transformed];
@@ -11973,7 +12017,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
11973
12017
  }
11974
12018
  }
11975
12019
  }
11976
- if (method === "flatMap" && children.length === 0 && !flatMapCallback && !ts12.isBlock(body)) {
12020
+ if (method === "flatMap" && children.length === 0 && !flatMapCallback && !ts13.isBlock(body)) {
11977
12021
  flatMapCallback = buildFlatMapCallback(callback, body, ctx);
11978
12022
  }
11979
12023
  if (flatMapCallback)
@@ -11991,7 +12035,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
11991
12035
  }
11992
12036
  if (children.length === 0 && !flatMapCallback) {
11993
12037
  const cb = node.arguments[0];
11994
- const cbBody = cb && (ts12.isArrowFunction(cb) || ts12.isFunctionExpression(cb)) ? cb.body : undefined;
12038
+ const cbBody = cb && (ts13.isArrowFunction(cb) || ts13.isFunctionExpression(cb)) ? cb.body : undefined;
11995
12039
  if (cbBody && containsJsxInExpression(cbBody) && ctx.analyzer.errors.length === diagCountAtEntry) {
11996
12040
  ctx.analyzer.errors.push(createError(ErrorCodes.UNSUPPORTED_JSX_PATTERN, getSourceLocation(cbBody, ctx.sourceFile, ctx.filePath), {
11997
12041
  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.",
@@ -12002,7 +12046,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12002
12046
  }
12003
12047
  return null;
12004
12048
  }
12005
- if (ts12.isArrowFunction(node.arguments[0]) && children.length > 0) {
12049
+ if (ts13.isArrowFunction(node.arguments[0]) && children.length > 0) {
12006
12050
  checkLoopKey(node.arguments[0], ctx, isNested);
12007
12051
  }
12008
12052
  const itemConditional = children.length > 0 ? loopBodyItemConditional(children) : null;
@@ -12056,6 +12100,9 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12056
12100
  const preambleRegions = preamble && !isStaticArray ? collectPreambleRegions(children, new Set(preamble.declaredNames), ctx) : undefined;
12057
12101
  if (preamble && !isStaticArray) {
12058
12102
  markPreambleAttrSlots(children, new Set(preamble.declaredNames), ctx);
12103
+ if (preamble.reactiveNames && preamble.reactiveNames.length > 0) {
12104
+ markPreambleConditionalReactivity(children, new Set(preamble.reactiveNames), ctx);
12105
+ }
12059
12106
  }
12060
12107
  const nestedComponents = collectNestedComponents(children).filter((c) => c.name !== childComponent?.name);
12061
12108
  return {
@@ -12099,12 +12146,12 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12099
12146
  function transformArrayLiteralChildren(arrayLiteral, ctx) {
12100
12147
  const children = [];
12101
12148
  for (const element of arrayLiteral.elements) {
12102
- if (ts12.isSpreadElement(element))
12149
+ if (ts13.isSpreadElement(element))
12103
12150
  continue;
12104
12151
  let inner = element;
12105
- while (ts12.isParenthesizedExpression(inner))
12152
+ while (ts13.isParenthesizedExpression(inner))
12106
12153
  inner = inner.expression;
12107
- if (ts12.isJsxElement(inner) || ts12.isJsxSelfClosingElement(inner) || ts12.isJsxFragment(inner)) {
12154
+ if (ts13.isJsxElement(inner) || ts13.isJsxSelfClosingElement(inner) || ts13.isJsxFragment(inner)) {
12108
12155
  const transformed = transformNode(inner, ctx);
12109
12156
  if (transformed)
12110
12157
  children.push(transformed);
@@ -12113,7 +12160,7 @@ function transformArrayLiteralChildren(arrayLiteral, ctx) {
12113
12160
  return children;
12114
12161
  }
12115
12162
  function containsJsx(node) {
12116
- if (ts12.isJsxElement(node) || ts12.isJsxSelfClosingElement(node) || ts12.isJsxFragment(node))
12163
+ if (ts13.isJsxElement(node) || ts13.isJsxSelfClosingElement(node) || ts13.isJsxFragment(node))
12117
12164
  return true;
12118
12165
  let found = false;
12119
12166
  node.forEachChild((child) => {
@@ -12129,7 +12176,7 @@ function buildFlatMapCallback(callback, body, ctx) {
12129
12176
  const leafIrs = [];
12130
12177
  let refusalNode;
12131
12178
  const collectJsx = (n, underTemplate) => {
12132
- if (ts12.isJsxElement(n) || ts12.isJsxSelfClosingElement(n) || ts12.isJsxFragment(n)) {
12179
+ if (ts13.isJsxElement(n) || ts13.isJsxSelfClosingElement(n) || ts13.isJsxFragment(n)) {
12133
12180
  if (underTemplate)
12134
12181
  refusalNode ??= n;
12135
12182
  leafSpans.push({ start: n.getStart(ctx.sourceFile), end: n.getEnd() });
@@ -12137,7 +12184,7 @@ function buildFlatMapCallback(callback, body, ctx) {
12137
12184
  leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx.sourceFile, ctx.filePath) });
12138
12185
  return;
12139
12186
  }
12140
- const inTemplate = underTemplate || ts12.isTemplateExpression(n) || ts12.isTaggedTemplateExpression(n);
12187
+ const inTemplate = underTemplate || ts13.isTemplateExpression(n) || ts13.isTaggedTemplateExpression(n);
12141
12188
  n.forEachChild((c) => collectJsx(c, inTemplate));
12142
12189
  };
12143
12190
  collectJsx(body, false);
@@ -12313,6 +12360,33 @@ function markPreambleAttrSlots(nodes, declared, ctx) {
12313
12360
  };
12314
12361
  visit2(nodes);
12315
12362
  }
12363
+ function markPreambleConditionalReactivity(nodes, reactiveNames, ctx) {
12364
+ if (reactiveNames.size === 0)
12365
+ return;
12366
+ const visit2 = (list) => {
12367
+ for (const node of list) {
12368
+ switch (node.type) {
12369
+ case "element":
12370
+ case "fragment":
12371
+ visit2(node.children);
12372
+ break;
12373
+ case "conditional": {
12374
+ if (!node.reactive) {
12375
+ const refs = extractFreeIdentifiersFromText(node.condition);
12376
+ if ([...refs].some((r) => reactiveNames.has(r))) {
12377
+ node.reactive = true;
12378
+ if (!node.slotId)
12379
+ node.slotId = generateSlotId(ctx);
12380
+ }
12381
+ }
12382
+ visit2([node.whenTrue, ...node.whenFalse ? [node.whenFalse] : []]);
12383
+ break;
12384
+ }
12385
+ }
12386
+ }
12387
+ };
12388
+ visit2(nodes);
12389
+ }
12316
12390
  function attrValueText(value) {
12317
12391
  if (value.kind === "expression")
12318
12392
  return value.expr;
@@ -12328,24 +12402,46 @@ function attrValueText(value) {
12328
12402
  return out.join(" ");
12329
12403
  }
12330
12404
  function collectBindingNames2(name, out) {
12331
- if (ts12.isIdentifier(name)) {
12405
+ if (ts13.isIdentifier(name)) {
12332
12406
  out.add(name.text);
12333
12407
  return;
12334
12408
  }
12335
12409
  for (const el of name.elements) {
12336
- if (ts12.isBindingElement(el))
12410
+ if (ts13.isBindingElement(el))
12337
12411
  collectBindingNames2(el.name, out);
12338
12412
  }
12339
12413
  }
12340
12414
  function collectPreambleDeclaredNames(stmt, out) {
12341
- if (ts12.isVariableStatement(stmt)) {
12415
+ if (ts13.isVariableStatement(stmt)) {
12342
12416
  for (const decl of stmt.declarationList.declarations) {
12343
12417
  collectBindingNames2(decl.name, out);
12344
12418
  }
12345
- } else if (ts12.isFunctionDeclaration(stmt) && stmt.name) {
12419
+ } else if (ts13.isFunctionDeclaration(stmt) && stmt.name) {
12346
12420
  out.add(stmt.name.text);
12347
12421
  }
12348
12422
  }
12423
+ function computePreambleReactiveNames(statements, ctx) {
12424
+ const reactiveNames = new Set;
12425
+ for (const stmt of statements) {
12426
+ if (!ts13.isVariableStatement(stmt))
12427
+ continue;
12428
+ for (const decl of stmt.declarationList.declarations) {
12429
+ if (!decl.initializer)
12430
+ continue;
12431
+ const boundNames = new Set;
12432
+ collectBindingNames2(decl.name, boundNames);
12433
+ const initText = ctx.getJS(decl.initializer);
12434
+ const initFreeRefs = extractFreeIdentifiersFromNode(decl.initializer);
12435
+ const readsEarlierReactive = [...initFreeRefs].some((r) => reactiveNames.has(r));
12436
+ const isReactive = readsEarlierReactive || isReactiveExpression(initText, ctx, decl.initializer);
12437
+ if (isReactive) {
12438
+ for (const n of boundNames)
12439
+ reactiveNames.add(n);
12440
+ }
12441
+ }
12442
+ }
12443
+ return reactiveNames;
12444
+ }
12349
12445
  function preambleFromValueStatements(statements, ctx) {
12350
12446
  const segments = [];
12351
12447
  const typedParts = [];
@@ -12360,21 +12456,23 @@ function preambleFromValueStatements(statements, ctx) {
12360
12456
  typedParts.push(raw0.endsWith(";") ? raw0 : raw0 + ";");
12361
12457
  segments.push(tjs !== js ? { kind: "js", text: js, templateText: tjs } : { kind: "js", text: js });
12362
12458
  }
12459
+ const reactiveNames = computePreambleReactiveNames(statements, ctx);
12363
12460
  return {
12364
12461
  segments: trimPreambleSegments(segments),
12365
12462
  ssrText: tsxSourceText(typedParts.join(" ")),
12366
12463
  declaredNames: [...declared],
12367
12464
  builderNames: [],
12368
- declarations: neutralPreambleDeclarations(statements, ctx) ?? undefined
12465
+ declarations: neutralPreambleDeclarations(statements, ctx) ?? undefined,
12466
+ reactiveNames: reactiveNames.size > 0 ? [...reactiveNames] : undefined
12369
12467
  };
12370
12468
  }
12371
12469
  function neutralPreambleDeclarations(statements, ctx) {
12372
12470
  const out = [];
12373
12471
  for (const stmt of statements) {
12374
- if (!ts12.isVariableStatement(stmt))
12472
+ if (!ts13.isVariableStatement(stmt))
12375
12473
  return null;
12376
12474
  for (const decl of stmt.declarationList.declarations) {
12377
- if (!ts12.isIdentifier(decl.name))
12475
+ if (!ts13.isIdentifier(decl.name))
12378
12476
  return null;
12379
12477
  if (!decl.initializer)
12380
12478
  return null;
@@ -12407,11 +12505,11 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
12407
12505
  let refusalNode;
12408
12506
  const recordBuilderTarget = (leaf, stmt) => {
12409
12507
  for (let n = leaf.parent;n && n !== stmt.parent; n = n.parent) {
12410
- if (ts12.isCallExpression(n) && ts12.isPropertyAccessExpression(n.expression) && (n.expression.name.text === "push" || n.expression.name.text === "unshift") && ts12.isIdentifier(n.expression.expression)) {
12508
+ if (ts13.isCallExpression(n) && ts13.isPropertyAccessExpression(n.expression) && (n.expression.name.text === "push" || n.expression.name.text === "unshift") && ts13.isIdentifier(n.expression.expression)) {
12411
12509
  builders.add(n.expression.expression.text);
12412
12510
  return;
12413
12511
  }
12414
- if (ts12.isVariableDeclaration(n) && ts12.isIdentifier(n.name)) {
12512
+ if (ts13.isVariableDeclaration(n) && ts13.isIdentifier(n.name)) {
12415
12513
  builders.add(n.name.text);
12416
12514
  return;
12417
12515
  }
@@ -12424,7 +12522,7 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
12424
12522
  const leafSpans = [];
12425
12523
  const leafIrs = [];
12426
12524
  const collect = (n, underTemplate) => {
12427
- if (ts12.isJsxElement(n) || ts12.isJsxSelfClosingElement(n) || ts12.isJsxFragment(n)) {
12525
+ if (ts13.isJsxElement(n) || ts13.isJsxSelfClosingElement(n) || ts13.isJsxFragment(n)) {
12428
12526
  if (underTemplate)
12429
12527
  refusalNode ??= n;
12430
12528
  recordBuilderTarget(n, stmt);
@@ -12435,7 +12533,7 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
12435
12533
  leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx.sourceFile, ctx.filePath) });
12436
12534
  return;
12437
12535
  }
12438
- const inTemplate = underTemplate || ts12.isTemplateExpression(n) || ts12.isTaggedTemplateExpression(n);
12536
+ const inTemplate = underTemplate || ts13.isTemplateExpression(n) || ts13.isTaggedTemplateExpression(n);
12439
12537
  n.forEachChild((c) => collect(c, inTemplate));
12440
12538
  };
12441
12539
  collect(stmt, false);
@@ -12539,13 +12637,13 @@ function expandSpreadAttribute(attr, ctx) {
12539
12637
  }];
12540
12638
  }
12541
12639
  function attrFreeIdentifiers(attr) {
12542
- if (!attr.initializer || !ts12.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
12640
+ if (!attr.initializer || !ts13.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
12543
12641
  return;
12544
12642
  }
12545
12643
  return extractFreeIdentifiersFromNode(attr.initializer.expression);
12546
12644
  }
12547
12645
  function computeReactivityFlags(attr, ctx) {
12548
- if (!attr.initializer || !ts12.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
12646
+ if (!attr.initializer || !ts13.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
12549
12647
  return {};
12550
12648
  }
12551
12649
  const expr = attr.initializer.expression;
@@ -12571,22 +12669,22 @@ function processAttributes(attributes, ctx) {
12571
12669
  const events = [];
12572
12670
  let ref = null;
12573
12671
  for (const attr of attributes.properties) {
12574
- if (ts12.isJsxSpreadAttribute(attr)) {
12672
+ if (ts13.isJsxSpreadAttribute(attr)) {
12575
12673
  attrs.push(...expandSpreadAttribute(attr, ctx));
12576
12674
  continue;
12577
12675
  }
12578
- if (!ts12.isJsxAttribute(attr))
12676
+ if (!ts13.isJsxAttribute(attr))
12579
12677
  continue;
12580
12678
  const rawName = attr.name.getText(ctx.sourceFile);
12581
12679
  if (rawName === "ref") {
12582
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
12680
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
12583
12681
  reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
12584
12682
  ref = ctx.getJS(attr.initializer.expression);
12585
12683
  }
12586
12684
  continue;
12587
12685
  }
12588
12686
  if (/^on[A-Z]/.test(rawName)) {
12589
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
12687
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
12590
12688
  const eventName = rawName.slice(2).toLowerCase();
12591
12689
  reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
12592
12690
  events.push({
@@ -12601,7 +12699,7 @@ function processAttributes(attributes, ctx) {
12601
12699
  const name = toHTMLAttrName(rawName);
12602
12700
  let value = getAttributeValue(attr, ctx);
12603
12701
  let clientOnly;
12604
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
12702
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
12605
12703
  if (value.kind === "expression" && value.templateExpr === undefined) {
12606
12704
  const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
12607
12705
  if (rewritten !== value.expr) {
@@ -12628,55 +12726,55 @@ function getAttributeValue(attr, ctx) {
12628
12726
  if (!attr.initializer) {
12629
12727
  return AttrValueOf.booleanAttr();
12630
12728
  }
12631
- if (ts12.isStringLiteral(attr.initializer)) {
12729
+ if (ts13.isStringLiteral(attr.initializer)) {
12632
12730
  return AttrValueOf.literal(decodeEntities(attr.initializer.text));
12633
12731
  }
12634
- if (ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
12732
+ if (ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
12635
12733
  let expr = attr.initializer.expression;
12636
- if (ts12.isIdentifier(expr)) {
12734
+ if (ts13.isIdentifier(expr)) {
12637
12735
  const branchInit = ctx._branchScopeVars?.get(expr.text);
12638
12736
  if (branchInit && !initializerShapeContainsJsx(branchInit)) {
12639
12737
  expr = branchInit;
12640
12738
  }
12641
12739
  }
12642
12740
  expr = tryDesugarInterleaveTaggedTemplate(expr, ctx);
12643
- if (ts12.isAwaitExpression(expr)) {
12741
+ if (ts13.isAwaitExpression(expr)) {
12644
12742
  ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(expr, ctx.sourceFile, ctx.filePath)));
12645
12743
  return AttrValueOf.expression("undefined");
12646
12744
  }
12647
12745
  checkBareSignalOrMemoIdentifier(expr, ctx);
12648
- if (attr.name.getText(ctx.sourceFile) === "style" && ts12.isObjectLiteralExpression(expr)) {
12746
+ if (attr.name.getText(ctx.sourceFile) === "style" && ts13.isObjectLiteralExpression(expr)) {
12649
12747
  const cssString = tryStaticStyleObjectToCss(expr);
12650
12748
  if (cssString !== null) {
12651
12749
  return AttrValueOf.literal(cssString);
12652
12750
  }
12653
12751
  }
12654
- if (ts12.isTemplateExpression(expr)) {
12752
+ if (ts13.isTemplateExpression(expr)) {
12655
12753
  const parts = parseTemplateLiteral(expr, ctx);
12656
12754
  if (parts.some((p) => p.type === "ternary" || p.type === "lookup")) {
12657
12755
  return AttrValueOf.template(parts);
12658
12756
  }
12659
12757
  }
12660
- if (ts12.isElementAccessExpression(expr) && !ts12.isStringLiteralLike(expr.argumentExpression) && !ts12.isNumericLiteral(expr.argumentExpression)) {
12758
+ if (ts13.isElementAccessExpression(expr) && !ts13.isStringLiteralLike(expr.argumentExpression) && !ts13.isNumericLiteral(expr.argumentExpression)) {
12661
12759
  const parts = tryResolveTemplateSpanFromConst(expr, ctx);
12662
12760
  if (parts) {
12663
12761
  return AttrValueOf.template(parts);
12664
12762
  }
12665
12763
  }
12666
- if (ts12.isIdentifier(expr)) {
12764
+ if (ts13.isIdentifier(expr)) {
12667
12765
  const resolved = tryResolveIdentifierAsTemplateLiteral(expr, ctx);
12668
12766
  if (resolved) {
12669
12767
  return AttrValueOf.template(resolved);
12670
12768
  }
12671
12769
  }
12672
- if (ts12.isConditionalExpression(expr)) {
12770
+ if (ts13.isConditionalExpression(expr)) {
12673
12771
  const ternary = parseTernary(expr, ctx);
12674
12772
  if (ternary) {
12675
12773
  return AttrValueOf.template([ternary]);
12676
12774
  }
12677
12775
  }
12678
- if (ts12.isBinaryExpression(expr) && expr.operatorToken.kind === ts12.SyntaxKind.BarBarToken) {
12679
- if (ts12.isIdentifier(expr.right) && expr.right.text === "undefined") {
12776
+ if (ts13.isBinaryExpression(expr) && expr.operatorToken.kind === ts13.SyntaxKind.BarBarToken) {
12777
+ if (ts13.isIdentifier(expr.right) && expr.right.text === "undefined") {
12680
12778
  const baseExpr = ctx.getJS(expr.left);
12681
12779
  return AttrValueOf.expression(baseExpr, { presenceOrUndefined: true });
12682
12780
  }
@@ -12689,11 +12787,11 @@ function getAttributeValue(attr, ctx) {
12689
12787
  function tryStaticStyleObjectToCss(expr) {
12690
12788
  const parts = [];
12691
12789
  for (const prop of expr.properties) {
12692
- if (!ts12.isPropertyAssignment(prop))
12790
+ if (!ts13.isPropertyAssignment(prop))
12693
12791
  return null;
12694
- if (!ts12.isIdentifier(prop.name) && !ts12.isStringLiteral(prop.name))
12792
+ if (!ts13.isIdentifier(prop.name) && !ts13.isStringLiteral(prop.name))
12695
12793
  return null;
12696
- if (!ts12.isStringLiteral(prop.initializer))
12794
+ if (!ts13.isStringLiteral(prop.initializer))
12697
12795
  return null;
12698
12796
  const key = cssKebabCase(prop.name.text);
12699
12797
  parts.push(`${key}:${prop.initializer.text}`);
@@ -12706,7 +12804,7 @@ function parseTemplateLiteral(expr, ctx) {
12706
12804
  parts.push({ type: "string", value: expr.head.text });
12707
12805
  }
12708
12806
  for (const span of expr.templateSpans) {
12709
- if (ts12.isConditionalExpression(span.expression)) {
12807
+ if (ts13.isConditionalExpression(span.expression)) {
12710
12808
  const ternary = parseTernary(span.expression, ctx);
12711
12809
  if (ternary) {
12712
12810
  parts.push(ternary);
@@ -12732,7 +12830,7 @@ function parseTemplateLiteral(expr, ctx) {
12732
12830
  return parts;
12733
12831
  }
12734
12832
  function tryResolveTemplateSpanFromConst(expr, ctx) {
12735
- if (ts12.isIdentifier(expr)) {
12833
+ if (ts13.isIdentifier(expr)) {
12736
12834
  if (ctx.scope.isBound(expr.text))
12737
12835
  return null;
12738
12836
  const constInfo = findLocalConst(expr.text, ctx.analyzer);
@@ -12741,13 +12839,13 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
12741
12839
  const ast = parseConstInitializer(constInfo);
12742
12840
  if (!ast)
12743
12841
  return null;
12744
- if (ts12.isStringLiteral(ast) || ts12.isNoSubstitutionTemplateLiteral(ast)) {
12842
+ if (ts13.isStringLiteral(ast) || ts13.isNoSubstitutionTemplateLiteral(ast)) {
12745
12843
  return [{ type: "string", value: ast.text }];
12746
12844
  }
12747
12845
  return null;
12748
12846
  }
12749
- if (ts12.isElementAccessExpression(expr)) {
12750
- if (!ts12.isIdentifier(expr.expression))
12847
+ if (ts13.isElementAccessExpression(expr)) {
12848
+ if (!ts13.isIdentifier(expr.expression))
12751
12849
  return null;
12752
12850
  if (ctx.scope.isBound(expr.expression.text))
12753
12851
  return null;
@@ -12755,17 +12853,17 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
12755
12853
  if (!constInfo)
12756
12854
  return null;
12757
12855
  const ast = parseConstInitializer(constInfo);
12758
- if (!ast || !ts12.isObjectLiteralExpression(ast))
12856
+ if (!ast || !ts13.isObjectLiteralExpression(ast))
12759
12857
  return null;
12760
12858
  const cases = {};
12761
12859
  for (const prop of ast.properties) {
12762
- if (!ts12.isPropertyAssignment(prop))
12860
+ if (!ts13.isPropertyAssignment(prop))
12763
12861
  return null;
12764
- const keyName = prop.name && (ts12.isStringLiteral(prop.name) || ts12.isIdentifier(prop.name)) ? prop.name.text : null;
12862
+ const keyName = prop.name && (ts13.isStringLiteral(prop.name) || ts13.isIdentifier(prop.name)) ? prop.name.text : null;
12765
12863
  if (!keyName)
12766
12864
  return null;
12767
12865
  const value = prop.initializer;
12768
- if (ts12.isStringLiteral(value) || ts12.isNoSubstitutionTemplateLiteral(value)) {
12866
+ if (ts13.isStringLiteral(value) || ts13.isNoSubstitutionTemplateLiteral(value)) {
12769
12867
  cases[keyName] = value.text;
12770
12868
  } else {
12771
12869
  return null;
@@ -12812,17 +12910,17 @@ function hasDynamicTagBinding(name, sourceFile) {
12812
12910
  const visit2 = (node) => {
12813
12911
  if (found)
12814
12912
  return;
12815
- if (ts12.isVariableDeclaration(node) && ts12.isIdentifier(node.name) && node.name.text === name && node.initializer) {
12913
+ if (ts13.isVariableDeclaration(node) && ts13.isIdentifier(node.name) && node.name.text === name && node.initializer) {
12816
12914
  let init = node.initializer;
12817
- while (ts12.isAsExpression(init) || ts12.isSatisfiesExpression(init) || ts12.isParenthesizedExpression(init) || ts12.isNonNullExpression(init)) {
12915
+ while (ts13.isAsExpression(init) || ts13.isSatisfiesExpression(init) || ts13.isParenthesizedExpression(init) || ts13.isNonNullExpression(init)) {
12818
12916
  init = init.expression;
12819
12917
  }
12820
- if (ts12.isPropertyAccessExpression(init) && init.name.text === "tag") {
12918
+ if (ts13.isPropertyAccessExpression(init) && init.name.text === "tag") {
12821
12919
  found = true;
12822
12920
  return;
12823
12921
  }
12824
12922
  }
12825
- ts12.forEachChild(node, visit2);
12923
+ ts13.forEachChild(node, visit2);
12826
12924
  };
12827
12925
  visit2(sourceFile);
12828
12926
  return found;
@@ -12836,13 +12934,13 @@ function tryResolveIdentifierAsTemplateLiteral(ident, ctx) {
12836
12934
  const ast = parseConstInitializer(constInfo);
12837
12935
  if (!ast)
12838
12936
  return null;
12839
- if (ts12.isNoSubstitutionTemplateLiteral(ast) || ts12.isStringLiteral(ast)) {
12937
+ if (ts13.isNoSubstitutionTemplateLiteral(ast) || ts13.isStringLiteral(ast)) {
12840
12938
  return [{ type: "string", value: ast.text }];
12841
12939
  }
12842
- if (ts12.isElementAccessExpression(ast) && !ts12.isStringLiteralLike(ast.argumentExpression) && !ts12.isNumericLiteral(ast.argumentExpression)) {
12940
+ if (ts13.isElementAccessExpression(ast) && !ts13.isStringLiteralLike(ast.argumentExpression) && !ts13.isNumericLiteral(ast.argumentExpression)) {
12843
12941
  return tryResolveTemplateSpanFromConst(ast, ctx);
12844
12942
  }
12845
- if (!ts12.isTemplateExpression(ast))
12943
+ if (!ts13.isTemplateExpression(ast))
12846
12944
  return null;
12847
12945
  let resolvedAny = false;
12848
12946
  const parts = [];
@@ -12880,14 +12978,14 @@ function parseConstInitializerImpl(c) {
12880
12978
  if (!c.value)
12881
12979
  return null;
12882
12980
  const wrapped = `const __bf_resolve__ = (${c.value})`;
12883
- const sf = ts12.createSourceFile("__bf_resolve.ts", wrapped, ts12.ScriptTarget.Latest, true, ts12.ScriptKind.TS);
12981
+ const sf = ts13.createSourceFile("__bf_resolve.ts", wrapped, ts13.ScriptTarget.Latest, true, ts13.ScriptKind.TS);
12884
12982
  const stmt = sf.statements[0];
12885
- if (!stmt || !ts12.isVariableStatement(stmt))
12983
+ if (!stmt || !ts13.isVariableStatement(stmt))
12886
12984
  return null;
12887
12985
  const decl = stmt.declarationList.declarations[0];
12888
12986
  if (!decl?.initializer)
12889
12987
  return null;
12890
- return ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
12988
+ return ts13.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
12891
12989
  }
12892
12990
  function astText(node) {
12893
12991
  return node.getText(node.getSourceFile());
@@ -12907,9 +13005,9 @@ function parseFunctionInfoAsExprImpl(fn) {
12907
13005
  const params = fn.typedParams !== undefined ? fn.typedParams : fn.params.map(formatParamWithType).join(", ");
12908
13006
  const body = fn.typedBody ?? fn.body;
12909
13007
  const wrapped = `const __bf_resolve_fn__ = function(${params}) ${body}`;
12910
- const sf = ts12.createSourceFile("__bf_resolve_fn.ts", wrapped, ts12.ScriptTarget.Latest, true, ts12.ScriptKind.TS);
13008
+ const sf = ts13.createSourceFile("__bf_resolve_fn.ts", wrapped, ts13.ScriptTarget.Latest, true, ts13.ScriptKind.TS);
12911
13009
  const stmt = sf.statements[0];
12912
- if (!stmt || !ts12.isVariableStatement(stmt))
13010
+ if (!stmt || !ts13.isVariableStatement(stmt))
12913
13011
  return null;
12914
13012
  const decl = stmt.declarationList.declarations[0];
12915
13013
  if (!decl?.initializer)
@@ -12917,9 +13015,9 @@ function parseFunctionInfoAsExprImpl(fn) {
12917
13015
  return decl.initializer;
12918
13016
  }
12919
13017
  function tryDesugarInterleaveTaggedTemplate(expr, ctx) {
12920
- if (!ts12.isTaggedTemplateExpression(expr))
13018
+ if (!ts13.isTaggedTemplateExpression(expr))
12921
13019
  return expr;
12922
- if (!ts12.isIdentifier(expr.tag))
13020
+ if (!ts13.isIdentifier(expr.tag))
12923
13021
  return expr;
12924
13022
  const resolvedTag = resolveInterleaveTagIdentifier(expr.tag.text, ctx);
12925
13023
  if (!resolvedTag)
@@ -12936,23 +13034,23 @@ function resolveInterleaveTagIdentifier(name, ctx) {
12936
13034
  return null;
12937
13035
  if (constInfo) {
12938
13036
  const ast = parseConstInitializer(constInfo);
12939
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
13037
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
12940
13038
  }
12941
13039
  if (fnInfo) {
12942
13040
  const ast = parseFunctionInfoAsExpr(fnInfo);
12943
- return ast && (ts12.isArrowFunction(ast) || ts12.isFunctionExpression(ast)) ? ast : null;
13041
+ return ast && (ts13.isArrowFunction(ast) || ts13.isFunctionExpression(ast)) ? ast : null;
12944
13042
  }
12945
13043
  return null;
12946
13044
  }
12947
13045
  function isInterleaveTagFunction(fn) {
12948
- if (!ts12.isArrowFunction(fn) && !ts12.isFunctionExpression(fn))
13046
+ if (!ts13.isArrowFunction(fn) && !ts13.isFunctionExpression(fn))
12949
13047
  return false;
12950
13048
  if (fn.parameters.length !== 2)
12951
13049
  return false;
12952
13050
  const [partsParam, argsParam] = fn.parameters;
12953
- if (!ts12.isIdentifier(partsParam.name) || partsParam.dotDotDotToken)
13051
+ if (!ts13.isIdentifier(partsParam.name) || partsParam.dotDotDotToken)
12954
13052
  return false;
12955
- if (!ts12.isIdentifier(argsParam.name) || !argsParam.dotDotDotToken)
13053
+ if (!ts13.isIdentifier(argsParam.name) || !argsParam.dotDotDotToken)
12956
13054
  return false;
12957
13055
  const parsed = tsNodeToParsedExpr(fn);
12958
13056
  if (parsed.kind !== "arrow")
@@ -13009,7 +13107,7 @@ function isInterleaveSpanExpr(expr, i, argsName) {
13009
13107
  function buildUntaggedTemplateLiteral(node, ctx) {
13010
13108
  const template = node.template;
13011
13109
  let text;
13012
- if (ts12.isNoSubstitutionTemplateLiteral(template)) {
13110
+ if (ts13.isNoSubstitutionTemplateLiteral(template)) {
13013
13111
  text = "`" + (template.rawText ?? template.text) + "`";
13014
13112
  } else {
13015
13113
  let body = template.head.rawText ?? template.head.text;
@@ -13021,15 +13119,15 @@ function buildUntaggedTemplateLiteral(node, ctx) {
13021
13119
  text = "`" + body + "`";
13022
13120
  }
13023
13121
  const wrapped = `const __bf_resolve_tagged__ = (${text})`;
13024
- const sf = ts12.createSourceFile("__bf_resolve_tagged.tsx", wrapped, ts12.ScriptTarget.Latest, true, ts12.ScriptKind.TSX);
13122
+ const sf = ts13.createSourceFile("__bf_resolve_tagged.tsx", wrapped, ts13.ScriptTarget.Latest, true, ts13.ScriptKind.TSX);
13025
13123
  const stmt = sf.statements[0];
13026
- if (!stmt || !ts12.isVariableStatement(stmt))
13124
+ if (!stmt || !ts13.isVariableStatement(stmt))
13027
13125
  return null;
13028
13126
  const decl = stmt.declarationList.declarations[0];
13029
13127
  if (!decl?.initializer)
13030
13128
  return null;
13031
- const result = ts12.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13032
- if (!ts12.isTemplateExpression(result) && !ts12.isNoSubstitutionTemplateLiteral(result))
13129
+ const result = ts13.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
13130
+ if (!ts13.isTemplateExpression(result) && !ts13.isNoSubstitutionTemplateLiteral(result))
13033
13131
  return null;
13034
13132
  return result;
13035
13133
  }
@@ -13049,10 +13147,10 @@ function parseTernary(expr, ctx) {
13049
13147
  return null;
13050
13148
  }
13051
13149
  function getStringValue(node) {
13052
- if (ts12.isStringLiteral(node)) {
13150
+ if (ts13.isStringLiteral(node)) {
13053
13151
  return node.text;
13054
13152
  }
13055
- if (ts12.isNoSubstitutionTemplateLiteral(node)) {
13153
+ if (ts13.isNoSubstitutionTemplateLiteral(node)) {
13056
13154
  return node.text;
13057
13155
  }
13058
13156
  return null;
@@ -13060,19 +13158,19 @@ function getStringValue(node) {
13060
13158
  function processComponentProps(attributes, ctx) {
13061
13159
  const props = [];
13062
13160
  for (const attr of attributes.properties) {
13063
- if (ts12.isJsxSpreadAttribute(attr)) {
13161
+ if (ts13.isJsxSpreadAttribute(attr)) {
13064
13162
  props.push(...expandSpreadAttribute(attr, ctx));
13065
13163
  continue;
13066
13164
  }
13067
- if (!ts12.isJsxAttribute(attr))
13165
+ if (!ts13.isJsxAttribute(attr))
13068
13166
  continue;
13069
13167
  const name = attr.name.getText(ctx.sourceFile);
13070
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13168
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13071
13169
  let jsxExpr = attr.initializer.expression;
13072
- while (ts12.isParenthesizedExpression(jsxExpr)) {
13170
+ while (ts13.isParenthesizedExpression(jsxExpr)) {
13073
13171
  jsxExpr = jsxExpr.expression;
13074
13172
  }
13075
- if (ts12.isJsxElement(jsxExpr) || ts12.isJsxSelfClosingElement(jsxExpr) || ts12.isJsxFragment(jsxExpr)) {
13173
+ if (ts13.isJsxElement(jsxExpr) || ts13.isJsxSelfClosingElement(jsxExpr) || ts13.isJsxFragment(jsxExpr)) {
13076
13174
  const prevInsideComponentChildren = ctx.insideComponentChildren;
13077
13175
  ctx.insideComponentChildren = true;
13078
13176
  const irNode = transformNode(jsxExpr, ctx);
@@ -13099,7 +13197,7 @@ function processComponentProps(attributes, ctx) {
13099
13197
  value = AttrValueOf.booleanShorthand();
13100
13198
  }
13101
13199
  let clientOnly;
13102
- if (attr.initializer && ts12.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13200
+ if (attr.initializer && ts13.isJsxExpression(attr.initializer) && attr.initializer.expression) {
13103
13201
  if (value.kind === "expression" && value.templateExpr === undefined) {
13104
13202
  const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
13105
13203
  if (rewritten !== value.expr) {
@@ -13123,7 +13221,7 @@ function processComponentProps(attributes, ctx) {
13123
13221
  return props;
13124
13222
  }
13125
13223
  function checkBareSignalOrMemoIdentifier(expr, ctx) {
13126
- if (!ts12.isIdentifier(expr))
13224
+ if (!ts13.isIdentifier(expr))
13127
13225
  return;
13128
13226
  const name = expr.text;
13129
13227
  for (const signal of ctx.analyzer.signals) {
@@ -13154,12 +13252,12 @@ function checkBareSignalOrMemoIdentifier(expr, ctx) {
13154
13252
  function isArrayExprDirectPropRef(arrayExpr, ctx) {
13155
13253
  const propNames = new Set(ctx.patterns.props.map((p) => p.name));
13156
13254
  const propsObjName = ctx.analyzer.propsObjectName;
13157
- if (ts12.isIdentifier(arrayExpr)) {
13255
+ if (ts13.isIdentifier(arrayExpr)) {
13158
13256
  return propNames.has(arrayExpr.text);
13159
13257
  }
13160
- if (ts12.isPropertyAccessExpression(arrayExpr) && propsObjName) {
13258
+ if (ts13.isPropertyAccessExpression(arrayExpr) && propsObjName) {
13161
13259
  const obj = arrayExpr.expression;
13162
- if (ts12.isIdentifier(obj) && obj.text === propsObjName) {
13260
+ if (ts13.isIdentifier(obj) && obj.text === propsObjName) {
13163
13261
  return true;
13164
13262
  }
13165
13263
  }
@@ -13354,7 +13452,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
13354
13452
  jsxBranchLocalNames.add(n);
13355
13453
  }
13356
13454
  for (const decl of condReturn.scopeVariables) {
13357
- if (ts12.isIdentifier(decl.name) && decl.initializer) {
13455
+ if (ts13.isIdentifier(decl.name) && decl.initializer) {
13358
13456
  branchScopeVars.set(decl.name.text, decl.initializer);
13359
13457
  if (initializerShapeContainsJsx(decl.initializer)) {
13360
13458
  jsxBranchLocalNames.add(decl.name.text);
@@ -13421,7 +13519,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
13421
13519
  }
13422
13520
  const scopeVariables = [];
13423
13521
  for (const decl of condReturn.scopeVariables) {
13424
- if (ts12.isIdentifier(decl.name) && decl.initializer) {
13522
+ if (ts13.isIdentifier(decl.name) && decl.initializer) {
13425
13523
  const init = ctx.getJS(decl.initializer);
13426
13524
  const typedInit = decl.initializer.getText(ctx.sourceFile);
13427
13525
  scopeVariables.push({
@@ -14712,7 +14810,8 @@ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loop
14712
14810
  if (!n.reactive && !refsLoopParamInSource)
14713
14811
  return;
14714
14812
  const expanded = expandConstantForReactivity(n.condition, ctx, sourceFreeIds, scope);
14715
- if (classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind === "none")
14813
+ const readsPreamble = preambleNames !== undefined && preambleNames.size > 0 && anyNameIn(expanded.freeIds ?? extractFreeIdentifiersFromText(expanded.expr), preambleNames);
14814
+ if (!readsPreamble && classifyReactivity(expanded.expr, ctx, loopParam, loopParamBindings, expanded.freeIds).kind === "none")
14716
14815
  return;
14717
14816
  const loopParamsForCond = loopParam ? [{ param: loopParam, bindings: loopParamBindings }] : undefined;
14718
14817
  const whenTrueHtml = irToHtmlTemplate(n.whenTrue, undefined, 0, loopParamsForCond, "__slots");
@@ -14724,7 +14823,8 @@ function collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loop
14724
14823
  whenFalseHtml,
14725
14824
  whenTrue: summarizeLoopChildBranch(n.whenTrue, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex),
14726
14825
  whenFalse: summarizeLoopChildBranch(n.whenFalse, ctx, siblingOffsets, loopParam, loopParamBindings, preambleNames, loopIndex),
14727
- ...expanded.freeIds !== undefined && { conditionFreeIdentifiers: expanded.freeIds }
14826
+ ...expanded.freeIds !== undefined && { conditionFreeIdentifiers: expanded.freeIds },
14827
+ ...readsPreamble && { readsPreamble: true }
14728
14828
  });
14729
14829
  }
14730
14830
  });
@@ -15100,7 +15200,7 @@ function graphDeclarationReferences(graph, kind, name) {
15100
15200
  }
15101
15201
 
15102
15202
  // ../jsx/src/ir-to-client-js/walk-prop-accesses.ts
15103
- import ts13 from "typescript";
15203
+ import ts14 from "typescript";
15104
15204
  function collectPropAccesses(source, propNames, out) {
15105
15205
  if (propNames.size === 0)
15106
15206
  return;
@@ -15114,7 +15214,7 @@ function collectPropAccesses(source, propNames, out) {
15114
15214
  if (!anyMentioned)
15115
15215
  return;
15116
15216
  for (const expr of normaliseExpressionParts(source)) {
15117
- const sourceFile = ts13.createSourceFile("p.ts", expr, ts13.ScriptTarget.Latest, false, ts13.ScriptKind.TS);
15217
+ const sourceFile = ts14.createSourceFile("p.ts", expr, ts14.ScriptTarget.Latest, false, ts14.ScriptKind.TS);
15118
15218
  visit2(sourceFile, propNames, out);
15119
15219
  }
15120
15220
  }
@@ -15124,15 +15224,15 @@ function normaliseExpressionParts(source) {
15124
15224
  return extractTemplateExpressions(source);
15125
15225
  }
15126
15226
  function visit2(node, propNames, out) {
15127
- if (ts13.isPropertyAccessExpression(node)) {
15227
+ if (ts14.isPropertyAccessExpression(node)) {
15128
15228
  recordIfPropAccess(node.expression, "property", propNames, out);
15129
- } else if (ts13.isElementAccessExpression(node)) {
15229
+ } else if (ts14.isElementAccessExpression(node)) {
15130
15230
  recordIfPropAccess(node.expression, "index", propNames, out);
15131
15231
  }
15132
- ts13.forEachChild(node, (child) => visit2(child, propNames, out));
15232
+ ts14.forEachChild(node, (child) => visit2(child, propNames, out));
15133
15233
  }
15134
15234
  function recordIfPropAccess(receiver, kind, propNames, out) {
15135
- if (!ts13.isIdentifier(receiver))
15235
+ if (!ts14.isIdentifier(receiver))
15136
15236
  return;
15137
15237
  const name = receiver.text;
15138
15238
  if (!propNames.has(name))
@@ -15185,56 +15285,56 @@ function propHasPropertyAccess(u) {
15185
15285
  }
15186
15286
 
15187
15287
  // ../jsx/src/value-references.ts
15188
- import ts14 from "typescript";
15288
+ import ts15 from "typescript";
15189
15289
  function isValueReferenceIdentifier(id) {
15190
15290
  const parent = id.parent;
15191
15291
  if (!parent)
15192
15292
  return false;
15193
- if (ts14.isPropertyAccessExpression(parent) && parent.name === id)
15293
+ if (ts15.isPropertyAccessExpression(parent) && parent.name === id)
15194
15294
  return false;
15195
- if (ts14.isPropertyAssignment(parent) && parent.name === id)
15295
+ if (ts15.isPropertyAssignment(parent) && parent.name === id)
15196
15296
  return false;
15197
- if ((ts14.isMethodDeclaration(parent) || ts14.isGetAccessorDeclaration(parent) || ts14.isSetAccessorDeclaration(parent)) && parent.name === id) {
15297
+ if ((ts15.isMethodDeclaration(parent) || ts15.isGetAccessorDeclaration(parent) || ts15.isSetAccessorDeclaration(parent)) && parent.name === id) {
15198
15298
  return false;
15199
15299
  }
15200
- if (ts14.isPropertyDeclaration(parent) && parent.name === id)
15300
+ if (ts15.isPropertyDeclaration(parent) && parent.name === id)
15201
15301
  return false;
15202
- if (ts14.isMetaProperty(parent) && parent.name === id)
15302
+ if (ts15.isMetaProperty(parent) && parent.name === id)
15203
15303
  return false;
15204
- if (ts14.isVariableDeclaration(parent) && parent.name === id)
15304
+ if (ts15.isVariableDeclaration(parent) && parent.name === id)
15205
15305
  return false;
15206
- if (ts14.isFunctionDeclaration(parent) && parent.name === id)
15306
+ if (ts15.isFunctionDeclaration(parent) && parent.name === id)
15207
15307
  return false;
15208
- if (ts14.isFunctionExpression(parent) && parent.name === id)
15308
+ if (ts15.isFunctionExpression(parent) && parent.name === id)
15209
15309
  return false;
15210
- if (ts14.isClassDeclaration(parent) && parent.name === id)
15310
+ if (ts15.isClassDeclaration(parent) && parent.name === id)
15211
15311
  return false;
15212
- if (ts14.isClassExpression(parent) && parent.name === id)
15312
+ if (ts15.isClassExpression(parent) && parent.name === id)
15213
15313
  return false;
15214
- if (ts14.isParameter(parent) && parent.name === id)
15314
+ if (ts15.isParameter(parent) && parent.name === id)
15215
15315
  return false;
15216
- if (ts14.isBindingElement(parent) && (parent.name === id || parent.propertyName === id))
15316
+ if (ts15.isBindingElement(parent) && (parent.name === id || parent.propertyName === id))
15217
15317
  return false;
15218
- if (ts14.isLabeledStatement(parent) && parent.label === id)
15318
+ if (ts15.isLabeledStatement(parent) && parent.label === id)
15219
15319
  return false;
15220
- if (ts14.isBreakOrContinueStatement(parent) && parent.label === id)
15320
+ if (ts15.isBreakOrContinueStatement(parent) && parent.label === id)
15221
15321
  return false;
15222
- if (ts14.isImportSpecifier(parent) && (parent.name === id || parent.propertyName === id))
15322
+ if (ts15.isImportSpecifier(parent) && (parent.name === id || parent.propertyName === id))
15223
15323
  return false;
15224
- if (ts14.isExportSpecifier(parent) && (parent.name === id || parent.propertyName === id))
15324
+ if (ts15.isExportSpecifier(parent) && (parent.name === id || parent.propertyName === id))
15225
15325
  return false;
15226
- if (ts14.isImportClause(parent) && parent.name === id)
15326
+ if (ts15.isImportClause(parent) && parent.name === id)
15227
15327
  return false;
15228
- if (ts14.isNamespaceImport(parent) && parent.name === id)
15328
+ if (ts15.isNamespaceImport(parent) && parent.name === id)
15229
15329
  return false;
15230
- if (ts14.isQualifiedName(parent) && parent.right === id)
15330
+ if (ts15.isQualifiedName(parent) && parent.right === id)
15231
15331
  return false;
15232
15332
  return true;
15233
15333
  }
15234
15334
  function collectValueReferencedNames(code) {
15235
15335
  let sourceFile;
15236
15336
  try {
15237
- sourceFile = ts14.createSourceFile("generated.js", code, ts14.ScriptTarget.Latest, true, ts14.ScriptKind.JS);
15337
+ sourceFile = ts15.createSourceFile("generated.js", code, ts15.ScriptTarget.Latest, true, ts15.ScriptKind.JS);
15238
15338
  } catch {
15239
15339
  return null;
15240
15340
  }
@@ -15243,10 +15343,10 @@ function collectValueReferencedNames(code) {
15243
15343
  return null;
15244
15344
  const names = new Set;
15245
15345
  function visit3(node) {
15246
- if (ts14.isIdentifier(node) && isValueReferenceIdentifier(node)) {
15346
+ if (ts15.isIdentifier(node) && isValueReferenceIdentifier(node)) {
15247
15347
  names.add(node.text);
15248
15348
  }
15249
- ts14.forEachChild(node, visit3);
15349
+ ts15.forEachChild(node, visit3);
15250
15350
  }
15251
15351
  visit3(sourceFile);
15252
15352
  return names;
@@ -15414,7 +15514,7 @@ function collectComponentNames(node) {
15414
15514
  }
15415
15515
 
15416
15516
  // ../jsx/src/relocate.ts
15417
- import ts15 from "typescript";
15517
+ import ts16 from "typescript";
15418
15518
 
15419
15519
  // ../jsx/src/lowering-registry.ts
15420
15520
  var plugins = [];
@@ -15442,19 +15542,19 @@ function classify(name, env) {
15442
15542
  function collectFreeRefs(node) {
15443
15543
  const refs = new Map;
15444
15544
  function visit3(n, parent) {
15445
- if (ts15.isIdentifier(n)) {
15446
- if (parent && ts15.isPropertyAccessExpression(parent) && parent.name === n)
15545
+ if (ts16.isIdentifier(n)) {
15546
+ if (parent && ts16.isPropertyAccessExpression(parent) && parent.name === n)
15447
15547
  return;
15448
- if (parent && ts15.isPropertyAssignment(parent) && parent.name === n)
15548
+ if (parent && ts16.isPropertyAssignment(parent) && parent.name === n)
15449
15549
  return;
15450
- if (parent && ts15.isShorthandPropertyAssignment(parent) && parent.name === n)
15550
+ if (parent && ts16.isShorthandPropertyAssignment(parent) && parent.name === n)
15451
15551
  return;
15452
15552
  const list = refs.get(n.text) ?? [];
15453
15553
  list.push(n);
15454
15554
  refs.set(n.text, list);
15455
15555
  return;
15456
15556
  }
15457
- ts15.forEachChild(n, (child) => visit3(child, n));
15557
+ ts16.forEachChild(n, (child) => visit3(child, n));
15458
15558
  }
15459
15559
  visit3(node);
15460
15560
  return refs;
@@ -15558,11 +15658,11 @@ function isInlinableInTemplate(value, env) {
15558
15658
  return { ok: true, rewrittenValue: r.text, decisions: r.decisions };
15559
15659
  }
15560
15660
  function getCalleeIdentifierPath(callee) {
15561
- if (ts15.isParenthesizedExpression(callee))
15661
+ if (ts16.isParenthesizedExpression(callee))
15562
15662
  return getCalleeIdentifierPath(callee.expression);
15563
- if (ts15.isIdentifier(callee))
15663
+ if (ts16.isIdentifier(callee))
15564
15664
  return callee.text;
15565
- if (ts15.isPropertyAccessExpression(callee)) {
15665
+ if (ts16.isPropertyAccessExpression(callee)) {
15566
15666
  const left = getCalleeIdentifierPath(callee.expression);
15567
15667
  if (left === null)
15568
15668
  return null;
@@ -15571,11 +15671,11 @@ function getCalleeIdentifierPath(callee) {
15571
15671
  return null;
15572
15672
  }
15573
15673
  function getCalleeLeftmostIdentifier(callee) {
15574
- if (ts15.isParenthesizedExpression(callee))
15674
+ if (ts16.isParenthesizedExpression(callee))
15575
15675
  return getCalleeLeftmostIdentifier(callee.expression);
15576
- if (ts15.isIdentifier(callee))
15676
+ if (ts16.isIdentifier(callee))
15577
15677
  return callee.text;
15578
- if (ts15.isPropertyAccessExpression(callee)) {
15678
+ if (ts16.isPropertyAccessExpression(callee)) {
15579
15679
  return getCalleeLeftmostIdentifier(callee.expression);
15580
15680
  }
15581
15681
  return null;
@@ -15623,12 +15723,12 @@ function isCallAcceptedByAdapter(call, env) {
15623
15723
  }
15624
15724
  function parseExpressionNode(text) {
15625
15725
  try {
15626
- const sf = ts15.createSourceFile("__inline_check__.ts", `(${text});`, ts15.ScriptTarget.Latest, false, ts15.ScriptKind.TS);
15726
+ const sf = ts16.createSourceFile("__inline_check__.ts", `(${text});`, ts16.ScriptTarget.Latest, false, ts16.ScriptKind.TS);
15627
15727
  const stmt = sf.statements[0];
15628
- if (!stmt || !ts15.isExpressionStatement(stmt))
15728
+ if (!stmt || !ts16.isExpressionStatement(stmt))
15629
15729
  return null;
15630
15730
  const inner = stmt.expression;
15631
- return ts15.isParenthesizedExpression(inner) ? inner.expression : inner;
15731
+ return ts16.isParenthesizedExpression(inner) ? inner.expression : inner;
15632
15732
  } catch {
15633
15733
  return null;
15634
15734
  }
@@ -15645,8 +15745,8 @@ function hasCallWithBridgedArg(node, decisions, env) {
15645
15745
  function visit3(n) {
15646
15746
  if (found)
15647
15747
  return;
15648
- if (ts15.isCallExpression(n) || ts15.isNewExpression(n)) {
15649
- const accepted = ts15.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
15748
+ if (ts16.isCallExpression(n) || ts16.isNewExpression(n)) {
15749
+ const accepted = ts16.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
15650
15750
  if (!accepted) {
15651
15751
  const args = n.arguments;
15652
15752
  if (args) {
@@ -15659,7 +15759,7 @@ function hasCallWithBridgedArg(node, decisions, env) {
15659
15759
  }
15660
15760
  }
15661
15761
  }
15662
- ts15.forEachChild(n, visit3);
15762
+ ts16.forEachChild(n, visit3);
15663
15763
  }
15664
15764
  visit3(node);
15665
15765
  return found;
@@ -15669,13 +15769,13 @@ function hasZeroArgCall(node, env) {
15669
15769
  function visit3(n) {
15670
15770
  if (found)
15671
15771
  return;
15672
- if (ts15.isCallExpression(n) && n.arguments.length === 0) {
15772
+ if (ts16.isCallExpression(n) && n.arguments.length === 0) {
15673
15773
  if (!isCallAcceptedByAdapter(n, env)) {
15674
15774
  found = true;
15675
15775
  return;
15676
15776
  }
15677
15777
  }
15678
- ts15.forEachChild(n, visit3);
15778
+ ts16.forEachChild(n, visit3);
15679
15779
  }
15680
15780
  visit3(node);
15681
15781
  return found;
@@ -15685,25 +15785,25 @@ function containsAnyIdentifier(node, names) {
15685
15785
  function visit3(n) {
15686
15786
  if (found)
15687
15787
  return;
15688
- if (ts15.isPropertyAccessExpression(n)) {
15788
+ if (ts16.isPropertyAccessExpression(n)) {
15689
15789
  visit3(n.expression);
15690
15790
  return;
15691
15791
  }
15692
- if (ts15.isPropertyAssignment(n)) {
15792
+ if (ts16.isPropertyAssignment(n)) {
15693
15793
  visit3(n.initializer);
15694
15794
  return;
15695
15795
  }
15696
- if (ts15.isShorthandPropertyAssignment(n)) {
15697
- if (ts15.isIdentifier(n.name) && names.has(n.name.text)) {
15796
+ if (ts16.isShorthandPropertyAssignment(n)) {
15797
+ if (ts16.isIdentifier(n.name) && names.has(n.name.text)) {
15698
15798
  found = true;
15699
15799
  }
15700
15800
  return;
15701
15801
  }
15702
- if (ts15.isIdentifier(n) && names.has(n.text)) {
15802
+ if (ts16.isIdentifier(n) && names.has(n.text)) {
15703
15803
  found = true;
15704
15804
  return;
15705
15805
  }
15706
- ts15.forEachChild(n, visit3);
15806
+ ts16.forEachChild(n, visit3);
15707
15807
  }
15708
15808
  visit3(node);
15709
15809
  return found;
@@ -16982,23 +17082,23 @@ function resolveFinalImports(generatedCode, ir, localImportPrefixes) {
16982
17082
  }
16983
17083
 
16984
17084
  // ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
16985
- import ts16 from "typescript";
17085
+ import ts17 from "typescript";
16986
17086
  function propExtractionName(stmt) {
16987
- if (!ts16.isVariableStatement(stmt))
17087
+ if (!ts17.isVariableStatement(stmt))
16988
17088
  return null;
16989
17089
  const decls = stmt.declarationList.declarations;
16990
17090
  if (decls.length !== 1)
16991
17091
  return null;
16992
17092
  const decl = decls[0];
16993
- if (!ts16.isIdentifier(decl.name) || !decl.initializer)
17093
+ if (!ts17.isIdentifier(decl.name) || !decl.initializer)
16994
17094
  return null;
16995
17095
  let core = decl.initializer;
16996
- if (ts16.isBinaryExpression(core) && core.operatorToken.kind === ts16.SyntaxKind.QuestionQuestionToken) {
17096
+ if (ts17.isBinaryExpression(core) && core.operatorToken.kind === ts17.SyntaxKind.QuestionQuestionToken) {
16997
17097
  core = core.left;
16998
17098
  }
16999
- if (!ts16.isPropertyAccessExpression(core))
17099
+ if (!ts17.isPropertyAccessExpression(core))
17000
17100
  return null;
17001
- if (!ts16.isIdentifier(core.expression) || core.expression.text !== PROPS_PARAM)
17101
+ if (!ts17.isIdentifier(core.expression) || core.expression.text !== PROPS_PARAM)
17002
17102
  return null;
17003
17103
  if (core.name.text !== decl.name.text)
17004
17104
  return null;
@@ -17011,10 +17111,10 @@ function pruneUnusedPropExtractions(code) {
17011
17111
  console.warn("[barefootjs] pruneUnusedPropExtractions: generated code did not parse; skipping prune");
17012
17112
  return code;
17013
17113
  }
17014
- const sourceFile = ts16.createSourceFile("generated.js", code, ts16.ScriptTarget.Latest, false, ts16.ScriptKind.JS);
17114
+ const sourceFile = ts17.createSourceFile("generated.js", code, ts17.ScriptTarget.Latest, false, ts17.ScriptKind.JS);
17015
17115
  const spans = [];
17016
17116
  for (const stmt of sourceFile.statements) {
17017
- if (!ts16.isFunctionDeclaration(stmt) || !stmt.name?.text.startsWith("init") || !stmt.body)
17117
+ if (!ts17.isFunctionDeclaration(stmt) || !stmt.name?.text.startsWith("init") || !stmt.body)
17018
17118
  continue;
17019
17119
  for (const inner of stmt.body.statements) {
17020
17120
  const name = propExtractionName(inner);
@@ -17976,7 +18076,8 @@ function buildReactiveEffectsPlan(args) {
17976
18076
  whenTrueTemplateHtml: addCondAttrToTemplate(wrap(cond.whenTrueHtml), cond.slotId),
17977
18077
  whenFalseTemplateHtml: addCondAttrToTemplate(wrap(cond.whenFalseHtml), cond.slotId),
17978
18078
  whenTrueArm: buildOuterArm(cond.whenTrue, wrap, loopParam, loopParamBindings, profileComponentName),
17979
- whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, profileComponentName)
18079
+ whenFalseArm: buildOuterArm(cond.whenFalse, wrap, loopParam, loopParamBindings, profileComponentName),
18080
+ ...cond.readsPreamble && { readsPreamble: true }
17980
18081
  });
17981
18082
  }
17982
18083
  }
@@ -18457,7 +18558,7 @@ function analyzeLazyConditional(cond, indexParam, arms) {
18457
18558
  }
18458
18559
 
18459
18560
  // ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
18460
- import ts17 from "typescript";
18561
+ import ts18 from "typescript";
18461
18562
  var NO_PREAMBLE = {
18462
18563
  lazySafe: true,
18463
18564
  facts: { declaredNames: new Set, freeNames: new Set }
@@ -18477,12 +18578,12 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
18477
18578
  if (text.trim().length === 0)
18478
18579
  return NO_PREAMBLE;
18479
18580
  const declaredNames = new Set;
18480
- const sf = ts17.createSourceFile("__lazy_preamble__.ts", text, ts17.ScriptTarget.Latest, true, ts17.ScriptKind.TS);
18581
+ const sf = ts18.createSourceFile("__lazy_preamble__.ts", text, ts18.ScriptTarget.Latest, true, ts18.ScriptKind.TS);
18481
18582
  for (const stmt of sf.statements) {
18482
- if (!ts17.isVariableStatement(stmt)) {
18483
- return NO2(`map-callback preamble has a non-declaration statement (${ts17.SyntaxKind[stmt.kind]})`);
18583
+ if (!ts18.isVariableStatement(stmt)) {
18584
+ return NO2(`map-callback preamble has a non-declaration statement (${ts18.SyntaxKind[stmt.kind]})`);
18484
18585
  }
18485
- const isConst = (stmt.declarationList.flags & ts17.NodeFlags.Const) !== 0;
18586
+ const isConst = (stmt.declarationList.flags & ts18.NodeFlags.Const) !== 0;
18486
18587
  if (!isConst)
18487
18588
  return NO2("map-callback preamble declares a mutable binding (let/var)");
18488
18589
  for (const decl of stmt.declarationList.declarations) {
@@ -18511,12 +18612,12 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
18511
18612
  return { lazySafe: true, facts: { declaredNames, freeNames } };
18512
18613
  }
18513
18614
  function collectBindingNames3(name, out) {
18514
- if (ts17.isIdentifier(name)) {
18615
+ if (ts18.isIdentifier(name)) {
18515
18616
  out.add(name.text);
18516
18617
  return;
18517
18618
  }
18518
18619
  for (const element of name.elements) {
18519
- if (ts17.isOmittedExpression(element))
18620
+ if (ts18.isOmittedExpression(element))
18520
18621
  continue;
18521
18622
  collectBindingNames3(element.name, out);
18522
18623
  }
@@ -18526,56 +18627,56 @@ function findImpureNode(root, primableNames) {
18526
18627
  const visit3 = (node) => {
18527
18628
  if (found)
18528
18629
  return;
18529
- if (ts17.isCallExpression(node)) {
18630
+ if (ts18.isCallExpression(node)) {
18530
18631
  const callee = node.expression;
18531
- const isSignalRead = ts17.isIdentifier(callee) && primableNames.has(callee.text) && node.arguments.length === 0 && node.questionDotToken === undefined;
18632
+ const isSignalRead = ts18.isIdentifier(callee) && primableNames.has(callee.text) && node.arguments.length === 0 && node.questionDotToken === undefined;
18532
18633
  if (!isSignalRead) {
18533
18634
  found = `call to ${callee.getText(callee.getSourceFile())}`;
18534
18635
  return;
18535
18636
  }
18536
18637
  }
18537
- if (ts17.isNewExpression(node)) {
18638
+ if (ts18.isNewExpression(node)) {
18538
18639
  found = "new expression";
18539
18640
  return;
18540
18641
  }
18541
- if (ts17.isTaggedTemplateExpression(node)) {
18642
+ if (ts18.isTaggedTemplateExpression(node)) {
18542
18643
  found = "tagged template";
18543
18644
  return;
18544
18645
  }
18545
- if (ts17.isAwaitExpression(node)) {
18646
+ if (ts18.isAwaitExpression(node)) {
18546
18647
  found = "await";
18547
18648
  return;
18548
18649
  }
18549
- if (ts17.isYieldExpression(node)) {
18650
+ if (ts18.isYieldExpression(node)) {
18550
18651
  found = "yield";
18551
18652
  return;
18552
18653
  }
18553
- if (ts17.isPrefixUnaryExpression(node) || ts17.isPostfixUnaryExpression(node)) {
18654
+ if (ts18.isPrefixUnaryExpression(node) || ts18.isPostfixUnaryExpression(node)) {
18554
18655
  const op = node.operator;
18555
- if (op === ts17.SyntaxKind.PlusPlusToken || op === ts17.SyntaxKind.MinusMinusToken) {
18656
+ if (op === ts18.SyntaxKind.PlusPlusToken || op === ts18.SyntaxKind.MinusMinusToken) {
18556
18657
  found = "increment/decrement";
18557
18658
  return;
18558
18659
  }
18559
18660
  }
18560
- if (ts17.isDeleteExpression(node)) {
18661
+ if (ts18.isDeleteExpression(node)) {
18561
18662
  found = "delete";
18562
18663
  return;
18563
18664
  }
18564
- if (ts17.isFunctionExpression(node) || ts17.isArrowFunction(node) || ts17.isClassExpression(node)) {
18665
+ if (ts18.isFunctionExpression(node) || ts18.isArrowFunction(node) || ts18.isClassExpression(node)) {
18565
18666
  found = "function or class expression";
18566
18667
  return;
18567
18668
  }
18568
- if (ts17.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
18669
+ if (ts18.isBinaryExpression(node) && isAssignmentOperator2(node.operatorToken.kind)) {
18569
18670
  found = "assignment";
18570
18671
  return;
18571
18672
  }
18572
- ts17.forEachChild(node, visit3);
18673
+ ts18.forEachChild(node, visit3);
18573
18674
  };
18574
18675
  visit3(root);
18575
18676
  return found;
18576
18677
  }
18577
- function isAssignmentOperator(kind) {
18578
- return kind >= ts17.SyntaxKind.FirstAssignment && kind <= ts17.SyntaxKind.LastAssignment;
18678
+ function isAssignmentOperator2(kind) {
18679
+ return kind >= ts18.SyntaxKind.FirstAssignment && kind <= ts18.SyntaxKind.LastAssignment;
18579
18680
  }
18580
18681
 
18581
18682
  // ../jsx/src/ir-to-client-js/control-flow/plan/lazy-row-eligibility.ts
@@ -19105,7 +19206,7 @@ function buildArmBody(branch, options) {
19105
19206
  }
19106
19207
 
19107
19208
  // ../jsx/src/ir-to-client-js/emit-reactive.ts
19108
- import ts18 from "typescript";
19209
+ import ts19 from "typescript";
19109
19210
 
19110
19211
  // ../jsx/src/ir-to-client-js/control-flow/stringify/claim-plan.ts
19111
19212
  function slotSpecLiteral(slot) {
@@ -19209,20 +19310,20 @@ function lowerToLocaleCallsInReactiveExpr(expr, matcher) {
19209
19310
  return expr;
19210
19311
  let sourceFile;
19211
19312
  try {
19212
- sourceFile = ts18.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts18.ScriptTarget.Latest, true, ts18.ScriptKind.TS);
19313
+ sourceFile = ts19.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts19.ScriptTarget.Latest, true, ts19.ScriptKind.TS);
19213
19314
  } catch {
19214
19315
  return expr;
19215
19316
  }
19216
19317
  const stmt = sourceFile.statements[0];
19217
- if (!stmt || !ts18.isExpressionStatement(stmt))
19318
+ if (!stmt || !ts19.isExpressionStatement(stmt))
19218
19319
  return expr;
19219
- const root = ts18.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19320
+ const root = ts19.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19220
19321
  const candidates = [];
19221
19322
  const visit3 = (n) => {
19222
- if (ts18.isCallExpression(n) && n.arguments.length === 2 && ts18.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
19323
+ if (ts19.isCallExpression(n) && n.arguments.length === 2 && ts19.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
19223
19324
  candidates.push(n);
19224
19325
  }
19225
- ts18.forEachChild(n, visit3);
19326
+ ts19.forEachChild(n, visit3);
19226
19327
  };
19227
19328
  visit3(root);
19228
19329
  if (candidates.length === 0)
@@ -19258,20 +19359,20 @@ function lowerDateCallsInReactiveExpr(expr, matcher) {
19258
19359
  return expr;
19259
19360
  let sourceFile;
19260
19361
  try {
19261
- sourceFile = ts18.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts18.ScriptTarget.Latest, true, ts18.ScriptKind.TS);
19362
+ sourceFile = ts19.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts19.ScriptTarget.Latest, true, ts19.ScriptKind.TS);
19262
19363
  } catch {
19263
19364
  return expr;
19264
19365
  }
19265
19366
  const stmt = sourceFile.statements[0];
19266
- if (!stmt || !ts18.isExpressionStatement(stmt))
19367
+ if (!stmt || !ts19.isExpressionStatement(stmt))
19267
19368
  return expr;
19268
- const root = ts18.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19369
+ const root = ts19.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19269
19370
  const candidates = [];
19270
19371
  const visit3 = (n) => {
19271
- if (ts18.isCallExpression(n) && n.arguments.length === 0 && ts18.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
19372
+ if (ts19.isCallExpression(n) && n.arguments.length === 0 && ts19.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
19272
19373
  candidates.push(n);
19273
19374
  }
19274
- ts18.forEachChild(n, visit3);
19375
+ ts19.forEachChild(n, visit3);
19275
19376
  };
19276
19377
  visit3(root);
19277
19378
  if (candidates.length === 0)
@@ -19586,7 +19687,7 @@ function stringifyReactiveEffects(lines, plan, opts) {
19586
19687
  emitConsolidatedRowEffect(lines, indent, elVar, lookup, attrSlots, outerTexts, elementIndexBySlot, textClaimPathExprs, preambleRegions, mapPreambleWrapped);
19587
19688
  }
19588
19689
  for (const cond of conditionals) {
19589
- emitOuterConditional(lines, indent, elVar, cond, pc);
19690
+ emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped);
19590
19691
  }
19591
19692
  }
19592
19693
  function emitAttrSlotsGranular(lines, indent, elVar, lookup, attrSlots, elementIndexBySlot, bindingBfId, mapPreambleWrapped) {
@@ -19688,9 +19789,10 @@ function emitOuterTexts(lines, indent, elVar, texts, bindingBfId, textClaimPathE
19688
19789
  lines.push(`${indent}createEffect(() => { ${writer}('${text.slotId}', String(${text.wrappedExpression})) }${bindingBfId(text.slotId)})`);
19689
19790
  }
19690
19791
  }
19691
- function emitOuterConditional(lines, indent, elVar, cond, pc) {
19792
+ function emitOuterConditional(lines, indent, elVar, cond, pc, mapPreambleWrapped) {
19692
19793
  const armIndent = `${indent} `;
19693
- lines.push(`${indent}insert(${elVar}, '${cond.slotId}', () => ${cond.wrappedCondition}, {`);
19794
+ const conditionGetter = cond.readsPreamble && mapPreambleWrapped ? `() => { ${mapPreambleWrapped}; return (${cond.wrappedCondition}) }` : `() => ${cond.wrappedCondition}`;
19795
+ lines.push(`${indent}insert(${elVar}, '${cond.slotId}', ${conditionGetter}, {`);
19694
19796
  lines.push(`${indent} template: () => { const __slots = []; return { html: \`${cond.whenTrueTemplateHtml}\`, slots: __slots } },`);
19695
19797
  lines.push(`${indent} bindEvents: (__branchScope, { isFirstRun: __bfFirstRun = false } = {}) => {`);
19696
19798
  stringifyLoopChildArm(lines, cond.whenTrueArm, armIndent, pc);
@@ -21274,20 +21376,20 @@ var PHASES = [
21274
21376
  ];
21275
21377
 
21276
21378
  // ../jsx/src/ir-to-client-js/rewrite-props-object.ts
21277
- import ts19 from "typescript";
21379
+ import ts20 from "typescript";
21278
21380
  function rewritePropsObjectRef(code, propsObjectName) {
21279
21381
  const srcPropsName = propsObjectName ?? "props";
21280
21382
  if (srcPropsName === PROPS_PARAM)
21281
21383
  return code;
21282
21384
  if (!identifierPattern(srcPropsName).test(code))
21283
21385
  return code;
21284
- const sourceFile = ts19.createSourceFile("init-body.ts", code, ts19.ScriptTarget.Latest, true, ts19.ScriptKind.TS);
21386
+ const sourceFile = ts20.createSourceFile("init-body.ts", code, ts20.ScriptTarget.Latest, true, ts20.ScriptKind.TS);
21285
21387
  const spans = [];
21286
21388
  function visit3(node) {
21287
- if (ts19.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
21389
+ if (ts20.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
21288
21390
  spans.push([node.getStart(sourceFile), node.getEnd()]);
21289
21391
  }
21290
- ts19.forEachChild(node, visit3);
21392
+ ts20.forEachChild(node, visit3);
21291
21393
  }
21292
21394
  visit3(sourceFile);
21293
21395
  if (spans.length === 0)
@@ -21303,17 +21405,17 @@ function shouldRewrite(node) {
21303
21405
  const parent = node.parent;
21304
21406
  if (!parent)
21305
21407
  return true;
21306
- if (ts19.isPropertyAccessExpression(parent) && parent.name === node)
21408
+ if (ts20.isPropertyAccessExpression(parent) && parent.name === node)
21307
21409
  return false;
21308
- if (ts19.isPropertyAssignment(parent) && parent.name === node)
21410
+ if (ts20.isPropertyAssignment(parent) && parent.name === node)
21309
21411
  return false;
21310
- if (ts19.isShorthandPropertyAssignment(parent) && parent.name === node)
21412
+ if (ts20.isShorthandPropertyAssignment(parent) && parent.name === node)
21311
21413
  return false;
21312
- if (ts19.isPropertySignature(parent) && parent.name === node)
21414
+ if (ts20.isPropertySignature(parent) && parent.name === node)
21313
21415
  return false;
21314
- if (ts19.isPropertyDeclaration(parent) && parent.name === node)
21416
+ if (ts20.isPropertyDeclaration(parent) && parent.name === node)
21315
21417
  return false;
21316
- if (ts19.isBindingElement(parent) && parent.name === node)
21418
+ if (ts20.isBindingElement(parent) && parent.name === node)
21317
21419
  return false;
21318
21420
  return true;
21319
21421
  }
@@ -21964,7 +22066,7 @@ function walkIR2(node, visitor) {
21964
22066
  }
21965
22067
 
21966
22068
  // ../jsx/src/preprocess-inline-jsx-callbacks.ts
21967
- import ts20 from "typescript";
22069
+ import ts21 from "typescript";
21968
22070
  var SYNTHETIC_PREFIX = "BFInlineJsxCallback";
21969
22071
  var MAX_FIXPOINT_ITERATIONS = 16;
21970
22072
  function preprocessInlineJsxCallbacks(source, filePath) {
@@ -21986,8 +22088,8 @@ function preprocessInlineJsxCallbacks(source, filePath) {
21986
22088
  return { source: current, errors, syntheticNames };
21987
22089
  }
21988
22090
  function runSinglePass(source, filePath, startingCounter) {
21989
- const sourceFile = ts20.createSourceFile(filePath, source, ts20.ScriptTarget.Latest, true, ts20.ScriptKind.TSX);
21990
- const hasUseClient = sourceFile.statements.some((stmt) => ts20.isExpressionStatement(stmt) && ts20.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
22091
+ const sourceFile = ts21.createSourceFile(filePath, source, ts21.ScriptTarget.Latest, true, ts21.ScriptKind.TSX);
22092
+ const hasUseClient = sourceFile.statements.some((stmt) => ts21.isExpressionStatement(stmt) && ts21.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
21991
22093
  if (!hasUseClient) {
21992
22094
  return { source, errors: [], syntheticNames: [], counterAfter: startingCounter };
21993
22095
  }
@@ -22009,22 +22111,22 @@ function runSinglePass(source, filePath, startingCounter) {
22009
22111
  }
22010
22112
  }
22011
22113
  function visit3(node) {
22012
- if (ts20.isJsxAttribute(node) && node.initializer && ts20.isJsxExpression(node.initializer) && node.initializer.expression) {
22114
+ if (ts21.isJsxAttribute(node) && node.initializer && ts21.isJsxExpression(node.initializer) && node.initializer.expression) {
22013
22115
  if (tryHandleArrowValue(node.initializer.expression)) {
22014
22116
  return;
22015
22117
  }
22016
22118
  }
22017
- if (ts20.isPropertyAssignment(node) && node.initializer) {
22119
+ if (ts21.isPropertyAssignment(node) && node.initializer) {
22018
22120
  if (tryHandleArrowValue(node.initializer))
22019
22121
  return;
22020
22122
  }
22021
- ts20.forEachChild(node, visit3);
22123
+ ts21.forEachChild(node, visit3);
22022
22124
  }
22023
22125
  function tryHandleArrowValue(initializer) {
22024
22126
  let expr = initializer;
22025
- while (ts20.isParenthesizedExpression(expr))
22127
+ while (ts21.isParenthesizedExpression(expr))
22026
22128
  expr = expr.expression;
22027
- if (ts20.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
22129
+ if (ts21.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
22028
22130
  return handleInlineArrow(expr);
22029
22131
  }
22030
22132
  return false;
@@ -22061,7 +22163,7 @@ function runSinglePass(source, filePath, startingCounter) {
22061
22163
  replacements.push({ start: arrowStart, end: arrowEnd, text: name });
22062
22164
  return true;
22063
22165
  }
22064
- ts20.forEachChild(sourceFile, visit3);
22166
+ ts21.forEachChild(sourceFile, visit3);
22065
22167
  if (replacements.length === 0) {
22066
22168
  return { source, errors, syntheticNames, counterAfter: counter };
22067
22169
  }
@@ -22084,11 +22186,11 @@ function errorMessageForCapture(captures) {
22084
22186
  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.`;
22085
22187
  }
22086
22188
  function arrowBodyContainsJsx(arrow) {
22087
- if (ts20.isBlock(arrow.body)) {
22189
+ if (ts21.isBlock(arrow.body)) {
22088
22190
  return blockReturnsJsx(arrow.body);
22089
22191
  }
22090
22192
  let body = arrow.body;
22091
- while (ts20.isParenthesizedExpression(body))
22193
+ while (ts21.isParenthesizedExpression(body))
22092
22194
  body = body.expression;
22093
22195
  return isJsxLike(body);
22094
22196
  }
@@ -22097,24 +22199,24 @@ function blockReturnsJsx(block) {
22097
22199
  function visit3(n) {
22098
22200
  if (found)
22099
22201
  return;
22100
- if (ts20.isReturnStatement(n) && n.expression) {
22202
+ if (ts21.isReturnStatement(n) && n.expression) {
22101
22203
  let e = n.expression;
22102
- while (ts20.isParenthesizedExpression(e))
22204
+ while (ts21.isParenthesizedExpression(e))
22103
22205
  e = e.expression;
22104
22206
  if (isJsxLike(e)) {
22105
22207
  found = true;
22106
22208
  return;
22107
22209
  }
22108
22210
  }
22109
- if (ts20.isArrowFunction(n) || ts20.isFunctionDeclaration(n) || ts20.isFunctionExpression(n))
22211
+ if (ts21.isArrowFunction(n) || ts21.isFunctionDeclaration(n) || ts21.isFunctionExpression(n))
22110
22212
  return;
22111
- ts20.forEachChild(n, visit3);
22213
+ ts21.forEachChild(n, visit3);
22112
22214
  }
22113
- ts20.forEachChild(block, visit3);
22215
+ ts21.forEachChild(block, visit3);
22114
22216
  return found;
22115
22217
  }
22116
22218
  function isJsxLike(expr) {
22117
- return ts20.isJsxElement(expr) || ts20.isJsxSelfClosingElement(expr) || ts20.isJsxFragment(expr);
22219
+ return ts21.isJsxElement(expr) || ts21.isJsxSelfClosingElement(expr) || ts21.isJsxFragment(expr);
22118
22220
  }
22119
22221
  function collectArrowParamNames(arrow) {
22120
22222
  const names = new Set;
@@ -22124,13 +22226,13 @@ function collectArrowParamNames(arrow) {
22124
22226
  }
22125
22227
  function collectBindingNames4(name, out) {
22126
22228
  const push = Array.isArray(out) ? (n) => out.push(n) : (n) => out.add(n);
22127
- if (ts20.isIdentifier(name)) {
22229
+ if (ts21.isIdentifier(name)) {
22128
22230
  push(name.text);
22129
- } else if (ts20.isObjectBindingPattern(name)) {
22231
+ } else if (ts21.isObjectBindingPattern(name)) {
22130
22232
  name.elements.forEach((el) => collectBindingNames4(el.name, out));
22131
- } else if (ts20.isArrayBindingPattern(name)) {
22233
+ } else if (ts21.isArrayBindingPattern(name)) {
22132
22234
  name.elements.forEach((el) => {
22133
- if (!ts20.isOmittedExpression(el))
22235
+ if (!ts21.isOmittedExpression(el))
22134
22236
  collectBindingNames4(el.name, out);
22135
22237
  });
22136
22238
  }
@@ -22157,48 +22259,48 @@ function collectFreeIdentifiers(arrow) {
22157
22259
  return bound.includes(name);
22158
22260
  }
22159
22261
  function visit3(node) {
22160
- if (ts20.isIdentifier(node)) {
22262
+ if (ts21.isIdentifier(node)) {
22161
22263
  const parent = node.parent;
22162
- if (parent && ts20.isPropertyAccessExpression(parent) && parent.name === node)
22264
+ if (parent && ts21.isPropertyAccessExpression(parent) && parent.name === node)
22163
22265
  return;
22164
- if (parent && ts20.isPropertyAssignment(parent) && parent.name === node)
22266
+ if (parent && ts21.isPropertyAssignment(parent) && parent.name === node)
22165
22267
  return;
22166
- if (parent && ts20.isPropertySignature(parent) && parent.name === node)
22268
+ if (parent && ts21.isPropertySignature(parent) && parent.name === node)
22167
22269
  return;
22168
- if (parent && ts20.isPropertyDeclaration(parent) && parent.name === node)
22270
+ if (parent && ts21.isPropertyDeclaration(parent) && parent.name === node)
22169
22271
  return;
22170
- if (parent && ts20.isMethodDeclaration(parent) && parent.name === node)
22272
+ if (parent && ts21.isMethodDeclaration(parent) && parent.name === node)
22171
22273
  return;
22172
- if (parent && ts20.isMethodSignature(parent) && parent.name === node)
22274
+ if (parent && ts21.isMethodSignature(parent) && parent.name === node)
22173
22275
  return;
22174
- if (parent && ts20.isGetAccessorDeclaration(parent) && parent.name === node)
22276
+ if (parent && ts21.isGetAccessorDeclaration(parent) && parent.name === node)
22175
22277
  return;
22176
- if (parent && ts20.isSetAccessorDeclaration(parent) && parent.name === node)
22278
+ if (parent && ts21.isSetAccessorDeclaration(parent) && parent.name === node)
22177
22279
  return;
22178
- if (parent && ts20.isEnumMember(parent) && parent.name === node)
22280
+ if (parent && ts21.isEnumMember(parent) && parent.name === node)
22179
22281
  return;
22180
- if (parent && ts20.isBindingElement(parent) && parent.propertyName === node)
22282
+ if (parent && ts21.isBindingElement(parent) && parent.propertyName === node)
22181
22283
  return;
22182
- if (parent && ts20.isShorthandPropertyAssignment(parent) && parent.name === node) {
22284
+ if (parent && ts21.isShorthandPropertyAssignment(parent) && parent.name === node) {
22183
22285
  if (!isBound(node.text))
22184
22286
  ids.add(node.text);
22185
22287
  return;
22186
22288
  }
22187
- if (parent && ts20.isParameter(parent) && parent.name === node)
22289
+ if (parent && ts21.isParameter(parent) && parent.name === node)
22188
22290
  return;
22189
- if (parent && ts20.isVariableDeclaration(parent) && parent.name === node)
22291
+ if (parent && ts21.isVariableDeclaration(parent) && parent.name === node)
22190
22292
  return;
22191
- if (parent && ts20.isFunctionDeclaration(parent) && parent.name === node)
22293
+ if (parent && ts21.isFunctionDeclaration(parent) && parent.name === node)
22192
22294
  return;
22193
- if (parent && ts20.isClassDeclaration(parent) && parent.name === node)
22295
+ if (parent && ts21.isClassDeclaration(parent) && parent.name === node)
22194
22296
  return;
22195
- if (parent && ts20.isJsxAttribute(parent) && parent.name === node)
22297
+ if (parent && ts21.isJsxAttribute(parent) && parent.name === node)
22196
22298
  return;
22197
- if (parent && ts20.isJsxOpeningElement(parent) && parent.tagName === node) {
22299
+ if (parent && ts21.isJsxOpeningElement(parent) && parent.tagName === node) {
22198
22300
  if (/^[a-z]/.test(node.text))
22199
22301
  return;
22200
22302
  }
22201
- if (parent && ts20.isJsxClosingElement(parent) && parent.tagName === node) {
22303
+ if (parent && ts21.isJsxClosingElement(parent) && parent.tagName === node) {
22202
22304
  if (/^[a-z]/.test(node.text))
22203
22305
  return;
22204
22306
  }
@@ -22207,43 +22309,43 @@ function collectFreeIdentifiers(arrow) {
22207
22309
  ids.add(node.text);
22208
22310
  return;
22209
22311
  }
22210
- if (ts20.isVariableDeclaration(node)) {
22312
+ if (ts21.isVariableDeclaration(node)) {
22211
22313
  const declared = pushBindings(node.name);
22212
22314
  if (node.initializer)
22213
22315
  visit3(node.initializer);
22214
22316
  return;
22215
22317
  }
22216
- if (ts20.isFunctionDeclaration(node)) {
22318
+ if (ts21.isFunctionDeclaration(node)) {
22217
22319
  if (node.name)
22218
22320
  bound.push(node.name.text);
22219
22321
  visitInsideNewScope(node);
22220
22322
  return;
22221
22323
  }
22222
- if (ts20.isClassDeclaration(node)) {
22324
+ if (ts21.isClassDeclaration(node)) {
22223
22325
  if (node.name)
22224
22326
  bound.push(node.name.text);
22225
- ts20.forEachChild(node, visit3);
22327
+ ts21.forEachChild(node, visit3);
22226
22328
  return;
22227
22329
  }
22228
- if (ts20.isArrowFunction(node) || ts20.isFunctionExpression(node)) {
22330
+ if (ts21.isArrowFunction(node) || ts21.isFunctionExpression(node)) {
22229
22331
  visitInsideNewScope(node);
22230
22332
  return;
22231
22333
  }
22232
- if (ts20.isCatchClause(node)) {
22334
+ if (ts21.isCatchClause(node)) {
22233
22335
  const before = bound.length;
22234
22336
  if (node.variableDeclaration)
22235
22337
  pushBindings(node.variableDeclaration.name);
22236
- ts20.forEachChild(node, visit3);
22338
+ ts21.forEachChild(node, visit3);
22237
22339
  popN(bound.length - before);
22238
22340
  return;
22239
22341
  }
22240
- if (ts20.isBlock(node)) {
22342
+ if (ts21.isBlock(node)) {
22241
22343
  const before = bound.length;
22242
- ts20.forEachChild(node, visit3);
22344
+ ts21.forEachChild(node, visit3);
22243
22345
  popN(bound.length - before);
22244
22346
  return;
22245
22347
  }
22246
- ts20.forEachChild(node, visit3);
22348
+ ts21.forEachChild(node, visit3);
22247
22349
  }
22248
22350
  function visitInsideNewScope(fn) {
22249
22351
  const before = bound.length;
@@ -22266,29 +22368,29 @@ function collectFreeIdentifiers(arrow) {
22266
22368
  function collectModuleScopeNames(sourceFile) {
22267
22369
  const names = new Set;
22268
22370
  for (const stmt of sourceFile.statements) {
22269
- if (ts20.isFunctionDeclaration(stmt) && stmt.name)
22371
+ if (ts21.isFunctionDeclaration(stmt) && stmt.name)
22270
22372
  names.add(stmt.name.text);
22271
- else if (ts20.isClassDeclaration(stmt) && stmt.name)
22373
+ else if (ts21.isClassDeclaration(stmt) && stmt.name)
22272
22374
  names.add(stmt.name.text);
22273
- else if (ts20.isVariableStatement(stmt)) {
22375
+ else if (ts21.isVariableStatement(stmt)) {
22274
22376
  for (const decl of stmt.declarationList.declarations)
22275
22377
  collectBindingNames4(decl.name, names);
22276
- } else if (ts20.isImportDeclaration(stmt) && stmt.importClause) {
22378
+ } else if (ts21.isImportDeclaration(stmt) && stmt.importClause) {
22277
22379
  const ic = stmt.importClause;
22278
22380
  if (ic.name)
22279
22381
  names.add(ic.name.text);
22280
22382
  if (ic.namedBindings) {
22281
- if (ts20.isNamespaceImport(ic.namedBindings))
22383
+ if (ts21.isNamespaceImport(ic.namedBindings))
22282
22384
  names.add(ic.namedBindings.name.text);
22283
22385
  else
22284
22386
  for (const e of ic.namedBindings.elements)
22285
22387
  names.add(e.name.text);
22286
22388
  }
22287
- } else if (ts20.isTypeAliasDeclaration(stmt))
22389
+ } else if (ts21.isTypeAliasDeclaration(stmt))
22288
22390
  names.add(stmt.name.text);
22289
- else if (ts20.isInterfaceDeclaration(stmt))
22391
+ else if (ts21.isInterfaceDeclaration(stmt))
22290
22392
  names.add(stmt.name.text);
22291
- else if (ts20.isEnumDeclaration(stmt))
22393
+ else if (ts21.isEnumDeclaration(stmt))
22292
22394
  names.add(stmt.name.text);
22293
22395
  }
22294
22396
  return names;
@@ -22296,7 +22398,7 @@ function collectModuleScopeNames(sourceFile) {
22296
22398
  function buildSyntheticDeclaration(name, arrow, sourceFile) {
22297
22399
  const paramsText = arrow.parameters.length === 0 ? "" : arrow.parameters.map((p) => p.getText(sourceFile)).join(", ");
22298
22400
  let bodyText;
22299
- if (ts20.isBlock(arrow.body)) {
22401
+ if (ts21.isBlock(arrow.body)) {
22300
22402
  bodyText = arrow.body.getText(sourceFile);
22301
22403
  } else {
22302
22404
  const expr = arrow.body.getText(sourceFile);
@@ -22306,7 +22408,7 @@ function buildSyntheticDeclaration(name, arrow, sourceFile) {
22306
22408
  }
22307
22409
 
22308
22410
  // ../jsx/src/ssr-defaults.ts
22309
- import ts21 from "typescript";
22411
+ import ts22 from "typescript";
22310
22412
  var UNRESOLVED = Symbol("unresolved");
22311
22413
  var NO_RETURN = Symbol("no-return");
22312
22414
  function extractSsrDefaults(metadata) {
@@ -22383,11 +22485,11 @@ function collectPropRefs(expr, propsObjectName, out) {
22383
22485
  if (!node)
22384
22486
  return;
22385
22487
  const visit3 = (n) => {
22386
- if (ts21.isPropertyAccessExpression(n) && ts21.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts21.isIdentifier(n.name)) {
22488
+ if (ts22.isPropertyAccessExpression(n) && ts22.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts22.isIdentifier(n.name)) {
22387
22489
  out.add(n.name.text);
22388
22490
  return;
22389
22491
  }
22390
- ts21.forEachChild(n, visit3);
22492
+ ts22.forEachChild(n, visit3);
22391
22493
  };
22392
22494
  visit3(node);
22393
22495
  }
@@ -22408,23 +22510,23 @@ function tryStaticEval(expr, ctx) {
22408
22510
  }
22409
22511
  function evalStatementsForReturn(statements, ctx) {
22410
22512
  for (const stmt of statements) {
22411
- if (ts21.isVariableStatement(stmt)) {
22513
+ if (ts22.isVariableStatement(stmt)) {
22412
22514
  for (const d of stmt.declarationList.declarations) {
22413
- if (!ts21.isIdentifier(d.name) || !d.initializer)
22515
+ if (!ts22.isIdentifier(d.name) || !d.initializer)
22414
22516
  continue;
22415
22517
  const v = evalNode(d.initializer, ctx);
22416
22518
  if (v !== UNRESOLVED)
22417
22519
  ctx.bindings[d.name.text] = v;
22418
22520
  }
22419
- } else if (ts21.isReturnStatement(stmt)) {
22521
+ } else if (ts22.isReturnStatement(stmt)) {
22420
22522
  return stmt.expression ? evalNode(stmt.expression, ctx) : UNRESOLVED;
22421
- } else if (ts21.isIfStatement(stmt)) {
22523
+ } else if (ts22.isIfStatement(stmt)) {
22422
22524
  const cond = evalNode(stmt.expression, ctx);
22423
22525
  if (cond === UNRESOLVED)
22424
22526
  return UNRESOLVED;
22425
22527
  const branch = cond ? stmt.thenStatement : stmt.elseStatement;
22426
22528
  if (branch) {
22427
- const taken = evalStatementsForReturn(ts21.isBlock(branch) ? branch.statements : [branch], ctx);
22529
+ const taken = evalStatementsForReturn(ts22.isBlock(branch) ? branch.statements : [branch], ctx);
22428
22530
  if (taken !== NO_RETURN)
22429
22531
  return taken;
22430
22532
  }
@@ -22435,45 +22537,45 @@ function evalStatementsForReturn(statements, ctx) {
22435
22537
  return NO_RETURN;
22436
22538
  }
22437
22539
  function parseExpression2(expr) {
22438
- const sf = ts21.createSourceFile("__ssr_default__.ts", `(${expr})`, ts21.ScriptTarget.Latest, false, ts21.ScriptKind.TS);
22540
+ const sf = ts22.createSourceFile("__ssr_default__.ts", `(${expr})`, ts22.ScriptTarget.Latest, false, ts22.ScriptKind.TS);
22439
22541
  const stmt = sf.statements[0];
22440
- if (!stmt || !ts21.isExpressionStatement(stmt))
22542
+ if (!stmt || !ts22.isExpressionStatement(stmt))
22441
22543
  return null;
22442
- const inner = ts21.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
22544
+ const inner = ts22.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
22443
22545
  return inner;
22444
22546
  }
22445
22547
  function evalNode(node, ctx) {
22446
- if (ts21.isParenthesizedExpression(node))
22548
+ if (ts22.isParenthesizedExpression(node))
22447
22549
  return evalNode(node.expression, ctx);
22448
- if (ts21.isAsExpression(node))
22550
+ if (ts22.isAsExpression(node))
22449
22551
  return evalNode(node.expression, ctx);
22450
- if (ts21.isSatisfiesExpression(node))
22552
+ if (ts22.isSatisfiesExpression(node))
22451
22553
  return evalNode(node.expression, ctx);
22452
- if (ts21.isTypeAssertionExpression(node))
22554
+ if (ts22.isTypeAssertionExpression(node))
22453
22555
  return evalNode(node.expression, ctx);
22454
- if (ts21.isNonNullExpression(node))
22556
+ if (ts22.isNonNullExpression(node))
22455
22557
  return evalNode(node.expression, ctx);
22456
- if (ts21.isArrowFunction(node)) {
22558
+ if (ts22.isArrowFunction(node)) {
22457
22559
  if (node.parameters.length !== 0)
22458
22560
  return UNRESOLVED;
22459
- if (!ts21.isBlock(node.body))
22561
+ if (!ts22.isBlock(node.body))
22460
22562
  return evalNode(node.body, ctx);
22461
22563
  const localBindings = { ...ctx.bindings };
22462
22564
  const localCtx = { ...ctx, bindings: localBindings };
22463
22565
  const result = evalStatementsForReturn(node.body.statements, localCtx);
22464
22566
  return result === NO_RETURN ? UNRESOLVED : result;
22465
22567
  }
22466
- if (ts21.isNumericLiteral(node))
22568
+ if (ts22.isNumericLiteral(node))
22467
22569
  return Number(node.text);
22468
- if (ts21.isStringLiteralLike(node))
22570
+ if (ts22.isStringLiteralLike(node))
22469
22571
  return node.text;
22470
- if (node.kind === ts21.SyntaxKind.TrueKeyword)
22572
+ if (node.kind === ts22.SyntaxKind.TrueKeyword)
22471
22573
  return true;
22472
- if (node.kind === ts21.SyntaxKind.FalseKeyword)
22574
+ if (node.kind === ts22.SyntaxKind.FalseKeyword)
22473
22575
  return false;
22474
- if (node.kind === ts21.SyntaxKind.NullKeyword)
22576
+ if (node.kind === ts22.SyntaxKind.NullKeyword)
22475
22577
  return null;
22476
- if (ts21.isIdentifier(node)) {
22578
+ if (ts22.isIdentifier(node)) {
22477
22579
  if (node.text === "undefined")
22478
22580
  return;
22479
22581
  if (node.text in ctx.bindings)
@@ -22482,29 +22584,29 @@ function evalNode(node, ctx) {
22482
22584
  return;
22483
22585
  return UNRESOLVED;
22484
22586
  }
22485
- if (ts21.isPrefixUnaryExpression(node)) {
22587
+ if (ts22.isPrefixUnaryExpression(node)) {
22486
22588
  const arg = evalNode(node.operand, ctx);
22487
22589
  if (arg === UNRESOLVED)
22488
22590
  return UNRESOLVED;
22489
22591
  switch (node.operator) {
22490
- case ts21.SyntaxKind.MinusToken:
22592
+ case ts22.SyntaxKind.MinusToken:
22491
22593
  return typeof arg === "number" ? -arg : UNRESOLVED;
22492
- case ts21.SyntaxKind.PlusToken:
22594
+ case ts22.SyntaxKind.PlusToken:
22493
22595
  return typeof arg === "number" ? +arg : UNRESOLVED;
22494
- case ts21.SyntaxKind.ExclamationToken:
22596
+ case ts22.SyntaxKind.ExclamationToken:
22495
22597
  return !arg;
22496
22598
  }
22497
22599
  return UNRESOLVED;
22498
22600
  }
22499
- if (ts21.isObjectLiteralExpression(node)) {
22601
+ if (ts22.isObjectLiteralExpression(node)) {
22500
22602
  const obj = {};
22501
22603
  for (const prop of node.properties) {
22502
- if (!ts21.isPropertyAssignment(prop))
22604
+ if (!ts22.isPropertyAssignment(prop))
22503
22605
  return UNRESOLVED;
22504
22606
  let key;
22505
- if (ts21.isIdentifier(prop.name) || ts21.isStringLiteralLike(prop.name)) {
22607
+ if (ts22.isIdentifier(prop.name) || ts22.isStringLiteralLike(prop.name)) {
22506
22608
  key = prop.name.text;
22507
- } else if (ts21.isNumericLiteral(prop.name)) {
22609
+ } else if (ts22.isNumericLiteral(prop.name)) {
22508
22610
  key = prop.name.text;
22509
22611
  } else {
22510
22612
  return UNRESOLVED;
@@ -22516,10 +22618,10 @@ function evalNode(node, ctx) {
22516
22618
  }
22517
22619
  return obj;
22518
22620
  }
22519
- if (ts21.isArrayLiteralExpression(node)) {
22621
+ if (ts22.isArrayLiteralExpression(node)) {
22520
22622
  const arr = [];
22521
22623
  for (const elem of node.elements) {
22522
- if (ts21.isOmittedExpression(elem))
22624
+ if (ts22.isOmittedExpression(elem))
22523
22625
  return UNRESOLVED;
22524
22626
  const v = evalNode(elem, ctx);
22525
22627
  if (v === UNRESOLVED)
@@ -22528,7 +22630,7 @@ function evalNode(node, ctx) {
22528
22630
  }
22529
22631
  return arr;
22530
22632
  }
22531
- if (ts21.isElementAccessExpression(node)) {
22633
+ if (ts22.isElementAccessExpression(node)) {
22532
22634
  const base = evalNode(node.expression, ctx);
22533
22635
  if (base === undefined)
22534
22636
  return;
@@ -22542,17 +22644,17 @@ function evalNode(node, ctx) {
22542
22644
  const k = String(key);
22543
22645
  return Object.prototype.hasOwnProperty.call(base, k) ? base[k] : undefined;
22544
22646
  }
22545
- if (ts21.isPropertyAccessExpression(node)) {
22647
+ if (ts22.isPropertyAccessExpression(node)) {
22546
22648
  const baseResult = evalNode(node.expression, ctx);
22547
22649
  if (baseResult === undefined)
22548
22650
  return;
22549
22651
  return UNRESOLVED;
22550
22652
  }
22551
- if (ts21.isCallExpression(node)) {
22552
- if (node.arguments.length === 0 && ts21.isIdentifier(node.expression) && node.expression.text in ctx.bindings) {
22653
+ if (ts22.isCallExpression(node)) {
22654
+ if (node.arguments.length === 0 && ts22.isIdentifier(node.expression) && node.expression.text in ctx.bindings) {
22553
22655
  return ctx.bindings[node.expression.text];
22554
22656
  }
22555
- if (ts21.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
22657
+ if (ts22.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
22556
22658
  const recv = evalNode(node.expression.expression, ctx);
22557
22659
  if (Array.isArray(recv)) {
22558
22660
  let sep = ",";
@@ -22568,27 +22670,27 @@ function evalNode(node, ctx) {
22568
22670
  }
22569
22671
  return UNRESOLVED;
22570
22672
  }
22571
- if (ts21.isConditionalExpression(node)) {
22673
+ if (ts22.isConditionalExpression(node)) {
22572
22674
  const cond = evalNode(node.condition, ctx);
22573
22675
  if (cond === UNRESOLVED)
22574
22676
  return UNRESOLVED;
22575
22677
  return cond ? evalNode(node.whenTrue, ctx) : evalNode(node.whenFalse, ctx);
22576
22678
  }
22577
- if (ts21.isBinaryExpression(node)) {
22679
+ if (ts22.isBinaryExpression(node)) {
22578
22680
  const op = node.operatorToken.kind;
22579
- if (op === ts21.SyntaxKind.QuestionQuestionToken) {
22681
+ if (op === ts22.SyntaxKind.QuestionQuestionToken) {
22580
22682
  const l2 = evalNode(node.left, ctx);
22581
22683
  if (l2 !== UNRESOLVED && l2 !== null && l2 !== undefined)
22582
22684
  return l2;
22583
22685
  return evalNode(node.right, ctx);
22584
22686
  }
22585
- if (op === ts21.SyntaxKind.BarBarToken) {
22687
+ if (op === ts22.SyntaxKind.BarBarToken) {
22586
22688
  const l2 = evalNode(node.left, ctx);
22587
22689
  if (l2 !== UNRESOLVED && l2)
22588
22690
  return l2;
22589
22691
  return evalNode(node.right, ctx);
22590
22692
  }
22591
- if (op === ts21.SyntaxKind.AmpersandAmpersandToken) {
22693
+ if (op === ts22.SyntaxKind.AmpersandAmpersandToken) {
22592
22694
  const l2 = evalNode(node.left, ctx);
22593
22695
  if (l2 === UNRESOLVED)
22594
22696
  return UNRESOLVED;
@@ -22601,30 +22703,30 @@ function evalNode(node, ctx) {
22601
22703
  if (l === UNRESOLVED || r === UNRESOLVED)
22602
22704
  return UNRESOLVED;
22603
22705
  switch (op) {
22604
- case ts21.SyntaxKind.PlusToken:
22706
+ case ts22.SyntaxKind.PlusToken:
22605
22707
  if (typeof l === "string" || typeof r === "string")
22606
22708
  return `${l}${r}`;
22607
22709
  if (typeof l === "number" && typeof r === "number")
22608
22710
  return l + r;
22609
22711
  return UNRESOLVED;
22610
- case ts21.SyntaxKind.MinusToken:
22712
+ case ts22.SyntaxKind.MinusToken:
22611
22713
  return typeof l === "number" && typeof r === "number" ? l - r : UNRESOLVED;
22612
- case ts21.SyntaxKind.AsteriskToken:
22714
+ case ts22.SyntaxKind.AsteriskToken:
22613
22715
  return typeof l === "number" && typeof r === "number" ? l * r : UNRESOLVED;
22614
- case ts21.SyntaxKind.SlashToken:
22716
+ case ts22.SyntaxKind.SlashToken:
22615
22717
  return typeof l === "number" && typeof r === "number" && r !== 0 ? l / r : UNRESOLVED;
22616
- case ts21.SyntaxKind.PercentToken:
22718
+ case ts22.SyntaxKind.PercentToken:
22617
22719
  return typeof l === "number" && typeof r === "number" && r !== 0 ? l % r : UNRESOLVED;
22618
- case ts21.SyntaxKind.EqualsEqualsEqualsToken:
22619
- case ts21.SyntaxKind.EqualsEqualsToken:
22720
+ case ts22.SyntaxKind.EqualsEqualsEqualsToken:
22721
+ case ts22.SyntaxKind.EqualsEqualsToken:
22620
22722
  return l === r;
22621
- case ts21.SyntaxKind.ExclamationEqualsEqualsToken:
22622
- case ts21.SyntaxKind.ExclamationEqualsToken:
22723
+ case ts22.SyntaxKind.ExclamationEqualsEqualsToken:
22724
+ case ts22.SyntaxKind.ExclamationEqualsToken:
22623
22725
  return l !== r;
22624
22726
  }
22625
22727
  return UNRESOLVED;
22626
22728
  }
22627
- if (ts21.isTemplateExpression(node)) {
22729
+ if (ts22.isTemplateExpression(node)) {
22628
22730
  if (node.templateSpans.length === 0)
22629
22731
  return node.head.text;
22630
22732
  let acc = node.head.text;
@@ -22636,41 +22738,41 @@ function evalNode(node, ctx) {
22636
22738
  }
22637
22739
  return acc;
22638
22740
  }
22639
- if (ts21.isNoSubstitutionTemplateLiteral(node))
22741
+ if (ts22.isNoSubstitutionTemplateLiteral(node))
22640
22742
  return node.text;
22641
22743
  return UNRESOLVED;
22642
22744
  }
22643
22745
 
22644
22746
  // ../jsx/src/augment-inherited-props.ts
22645
- import ts22 from "typescript";
22747
+ import ts23 from "typescript";
22646
22748
  function parseStaticStringConst(source) {
22647
- const sf = ts22.createSourceFile("__const.ts", `const __x = (${source});`, ts22.ScriptTarget.Latest, false);
22749
+ const sf = ts23.createSourceFile("__const.ts", `const __x = (${source});`, ts23.ScriptTarget.Latest, false);
22648
22750
  const stmt = sf.statements[0];
22649
- if (!stmt || !ts22.isVariableStatement(stmt))
22751
+ if (!stmt || !ts23.isVariableStatement(stmt))
22650
22752
  return null;
22651
22753
  let init = stmt.declarationList.declarations[0]?.initializer;
22652
- while (init && ts22.isParenthesizedExpression(init))
22754
+ while (init && ts23.isParenthesizedExpression(init))
22653
22755
  init = init.expression;
22654
22756
  if (!init)
22655
22757
  return null;
22656
- if (ts22.isStringLiteral(init) || ts22.isNoSubstitutionTemplateLiteral(init)) {
22758
+ if (ts23.isStringLiteral(init) || ts23.isNoSubstitutionTemplateLiteral(init)) {
22657
22759
  return init.text;
22658
22760
  }
22659
22761
  return evalStringArrayJoin(source);
22660
22762
  }
22661
22763
  function evalTemplateOfStringConsts(source, resolved) {
22662
- const sf = ts22.createSourceFile("__const.ts", `const __x = (${source});`, ts22.ScriptTarget.Latest, false);
22764
+ const sf = ts23.createSourceFile("__const.ts", `const __x = (${source});`, ts23.ScriptTarget.Latest, false);
22663
22765
  const stmt = sf.statements[0];
22664
- if (!stmt || !ts22.isVariableStatement(stmt))
22766
+ if (!stmt || !ts23.isVariableStatement(stmt))
22665
22767
  return null;
22666
22768
  let init = stmt.declarationList.declarations[0]?.initializer;
22667
- while (init && ts22.isParenthesizedExpression(init))
22769
+ while (init && ts23.isParenthesizedExpression(init))
22668
22770
  init = init.expression;
22669
- if (!init || !ts22.isTemplateExpression(init))
22771
+ if (!init || !ts23.isTemplateExpression(init))
22670
22772
  return null;
22671
22773
  let out = init.head.text;
22672
22774
  for (const span of init.templateSpans) {
22673
- if (!ts22.isIdentifier(span.expression))
22775
+ if (!ts23.isIdentifier(span.expression))
22674
22776
  return null;
22675
22777
  const value = resolved.get(span.expression.text);
22676
22778
  if (value === undefined)
@@ -22698,28 +22800,28 @@ function collectModuleStringConsts(constants) {
22698
22800
  return map;
22699
22801
  }
22700
22802
  function evalStringArrayJoin(source) {
22701
- const sf = ts22.createSourceFile("__join.ts", `const __x = (${source});`, ts22.ScriptTarget.Latest, false);
22803
+ const sf = ts23.createSourceFile("__join.ts", `const __x = (${source});`, ts23.ScriptTarget.Latest, false);
22702
22804
  const stmt = sf.statements[0];
22703
- if (!stmt || !ts22.isVariableStatement(stmt))
22805
+ if (!stmt || !ts23.isVariableStatement(stmt))
22704
22806
  return null;
22705
22807
  let node = stmt.declarationList.declarations[0]?.initializer;
22706
- while (node && ts22.isParenthesizedExpression(node))
22808
+ while (node && ts23.isParenthesizedExpression(node))
22707
22809
  node = node.expression;
22708
- if (!node || !ts22.isCallExpression(node))
22810
+ if (!node || !ts23.isCallExpression(node))
22709
22811
  return null;
22710
22812
  const callee = node.expression;
22711
- if (!ts22.isPropertyAccessExpression(callee))
22813
+ if (!ts23.isPropertyAccessExpression(callee))
22712
22814
  return null;
22713
22815
  if (callee.name.text !== "join")
22714
22816
  return null;
22715
22817
  let recv = callee.expression;
22716
- while (ts22.isParenthesizedExpression(recv))
22818
+ while (ts23.isParenthesizedExpression(recv))
22717
22819
  recv = recv.expression;
22718
- if (!ts22.isArrayLiteralExpression(recv))
22820
+ if (!ts23.isArrayLiteralExpression(recv))
22719
22821
  return null;
22720
22822
  const parts = [];
22721
22823
  for (const el of recv.elements) {
22722
- if (ts22.isStringLiteral(el) || ts22.isNoSubstitutionTemplateLiteral(el)) {
22824
+ if (ts23.isStringLiteral(el) || ts23.isNoSubstitutionTemplateLiteral(el)) {
22723
22825
  parts.push(el.text);
22724
22826
  } else {
22725
22827
  return null;
@@ -22728,7 +22830,7 @@ function evalStringArrayJoin(source) {
22728
22830
  let sep = ",";
22729
22831
  if (node.arguments.length >= 1) {
22730
22832
  const arg = node.arguments[0];
22731
- if (ts22.isStringLiteral(arg) || ts22.isNoSubstitutionTemplateLiteral(arg))
22833
+ if (ts23.isStringLiteral(arg) || ts23.isNoSubstitutionTemplateLiteral(arg))
22732
22834
  sep = arg.text;
22733
22835
  else
22734
22836
  return null;
@@ -23070,13 +23172,13 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
23070
23172
  if (entries.some((e) => e.componentIR.metadata.isClientComponent)) {
23071
23173
  const topLevelNames = new Set;
23072
23174
  {
23073
- const sf = ts23.createSourceFile(filePath, source, ts23.ScriptTarget.Latest, true, ts23.ScriptKind.TSX);
23175
+ const sf = ts24.createSourceFile(filePath, source, ts24.ScriptTarget.Latest, true, ts24.ScriptKind.TSX);
23074
23176
  for (const stmt of sf.statements) {
23075
- if (ts23.isFunctionDeclaration(stmt) && stmt.name)
23177
+ if (ts24.isFunctionDeclaration(stmt) && stmt.name)
23076
23178
  topLevelNames.add(stmt.name.text);
23077
- else if (ts23.isVariableStatement(stmt)) {
23179
+ else if (ts24.isVariableStatement(stmt)) {
23078
23180
  for (const d of stmt.declarationList.declarations) {
23079
- if (ts23.isIdentifier(d.name))
23181
+ if (ts24.isIdentifier(d.name))
23080
23182
  topLevelNames.add(d.name.text);
23081
23183
  }
23082
23184
  }
@@ -23135,7 +23237,7 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
23135
23237
  const moduleStatementSeen = new Set;
23136
23238
  const moduleStatementsOrdered = [];
23137
23239
  const collectModuleStatements = (block) => {
23138
- const sf = ts23.createSourceFile("__bf_module_decls.tsx", block, ts23.ScriptTarget.Latest, false, ts23.ScriptKind.TSX);
23240
+ const sf = ts24.createSourceFile("__bf_module_decls.tsx", block, ts24.ScriptTarget.Latest, false, ts24.ScriptKind.TSX);
23139
23241
  for (const stmt of sf.statements) {
23140
23242
  const text = stmt.getText(sf);
23141
23243
  if (moduleStatementSeen.has(text))
@@ -23372,6 +23474,12 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
23372
23474
  }
23373
23475
  return { files, errors };
23374
23476
  }
23477
+ function componentTypeParametersText(componentNode, sourceFile) {
23478
+ const typeParameters = componentNode?.typeParameters;
23479
+ if (!typeParameters || typeParameters.length === 0)
23480
+ return null;
23481
+ return `<${typeParameters.map((p) => p.getText(sourceFile)).join(", ")}>`;
23482
+ }
23375
23483
  function buildMetadata(ctx) {
23376
23484
  const metadata = {
23377
23485
  componentName: ctx.componentName || "Unknown",
@@ -23380,6 +23488,7 @@ function buildMetadata(ctx) {
23380
23488
  isClientComponent: ctx.hasUseClientDirective,
23381
23489
  typeDefinitions: ctx.typeDefinitions,
23382
23490
  propsType: ctx.propsType,
23491
+ typeParameters: componentTypeParametersText(ctx.componentNode, ctx.sourceFile),
23383
23492
  propsParams: ctx.propsParams,
23384
23493
  propsObjectName: ctx.propsObjectName,
23385
23494
  restPropsName: ctx.restPropsName,
@@ -23570,7 +23679,7 @@ function compileJSX(source, filePath, options) {
23570
23679
  return { files, errors };
23571
23680
  }
23572
23681
  // ../jsx/src/shared-program.ts
23573
- import ts24 from "typescript";
23682
+ import ts25 from "typescript";
23574
23683
  import path3 from "node:path";
23575
23684
  function commonParent(paths) {
23576
23685
  if (paths.length === 0)
@@ -23592,10 +23701,10 @@ function commonParent(paths) {
23592
23701
  function createProgramForCorpus(files, options = {}) {
23593
23702
  const baseUrl = options.baseUrl ?? commonParent(files);
23594
23703
  const compilerOptions = {
23595
- target: ts24.ScriptTarget.Latest,
23596
- module: ts24.ModuleKind.ESNext,
23597
- moduleResolution: ts24.ModuleResolutionKind.Bundler,
23598
- jsx: ts24.JsxEmit.ReactJSX,
23704
+ target: ts25.ScriptTarget.Latest,
23705
+ module: ts25.ModuleKind.ESNext,
23706
+ moduleResolution: ts25.ModuleResolutionKind.Bundler,
23707
+ jsx: ts25.JsxEmit.ReactJSX,
23599
23708
  strict: true,
23600
23709
  skipLibCheck: true,
23601
23710
  noEmit: true,
@@ -23605,7 +23714,7 @@ function createProgramForCorpus(files, options = {}) {
23605
23714
  ...options.compilerOptions
23606
23715
  };
23607
23716
  const absolute = files.map((f) => path3.resolve(f));
23608
- return ts24.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
23717
+ return ts25.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
23609
23718
  }
23610
23719
  // ../jsx/src/adapters/interface.ts
23611
23720
  class BaseAdapter {
@@ -23659,7 +23768,7 @@ class JsxAdapter extends BaseAdapter {
23659
23768
  ...localFunctions.map((f) => ({ name: f.name, body: f.body })),
23660
23769
  ...localConstants.map((c) => ({ name: c.name, body: c.value }))
23661
23770
  ];
23662
- const reachable = findReachableNames(primaryRefText, declarations);
23771
+ const reachable = closeOverWritersOfMutableBindings(primaryRefText, declarations, new Set(ir.metadata.localConstants.filter((c) => (c.declarationKind ?? "const") !== "const").map((c) => c.name)));
23663
23772
  const reachableBodies = [...reachable].map((name) => {
23664
23773
  const func = localFunctions.find((f) => f.name === name);
23665
23774
  if (func)
@@ -23691,7 +23800,8 @@ class JsxAdapter extends BaseAdapter {
23691
23800
  if (signal.setter) {
23692
23801
  const setterUsed = identifierPattern(signal.setter).test(setterRefText);
23693
23802
  if (setterUsed) {
23694
- lines.push(` const ${signal.setter} = (..._args: any[]) => {}`);
23803
+ const setterType = preserveTypes && signal.type.kind !== "unknown" ? `(valueOrFn: ${signal.type.raw} | ((prev: ${signal.type.raw}) => ${signal.type.raw})) => void` : null;
23804
+ lines.push(setterType ? ` const ${signal.setter}: ${setterType} = () => {}` : ` const ${signal.setter} = (..._args: any[]) => {}`);
23695
23805
  }
23696
23806
  }
23697
23807
  }
@@ -23887,7 +23997,7 @@ class JsxAdapter extends BaseAdapter {
23887
23997
  }
23888
23998
 
23889
23999
  // ../jsx/src/adapters/template-imports.ts
23890
- import ts25 from "typescript";
24000
+ import ts26 from "typescript";
23891
24001
  var CLIENT_PACKAGE_SOURCES = new Set([
23892
24002
  "@barefootjs/client",
23893
24003
  "@barefootjs/client/runtime"
@@ -24026,7 +24136,8 @@ export default ${this.componentName}` : "";
24026
24136
  const noArgDefault = hasRequiredProps ? "" : ` = {} as ${propsTypeExpr}`;
24027
24137
  const lines = [];
24028
24138
  const exportPrefix = ir.metadata.isExported === false ? "" : "export ";
24029
- lines.push(`${exportPrefix}function ${name}(${fullPropsDestructure}${typeAnnotation}${noArgDefault}) {`);
24139
+ const typeParameters = ir.metadata.typeParameters ?? "";
24140
+ lines.push(`${exportPrefix}function ${name}${typeParameters}(${fullPropsDestructure}${typeAnnotation}${noArgDefault}) {`);
24030
24141
  if (hasClientInteractivity) {
24031
24142
  lines.push(` const __scopeId = (/_s\\d/.test(__bfScope || '') ? __bfScope : null) || __instanceId || \`${name}_\${Math.random().toString(36).slice(2, 8)}\``);
24032
24143
  } else {
@@ -24277,11 +24388,11 @@ function registerBuiltinLoweringPlugins() {
24277
24388
  registerLoweringPlugin(plugin);
24278
24389
  }
24279
24390
  // ../jsx/src/combine-client-js.ts
24280
- import ts26 from "typescript";
24281
- // ../jsx/src/debug.ts
24282
24391
  import ts27 from "typescript";
24283
- // ../jsx/src/profiler.ts
24392
+ // ../jsx/src/debug.ts
24284
24393
  import ts28 from "typescript";
24394
+ // ../jsx/src/profiler.ts
24395
+ import ts29 from "typescript";
24285
24396
 
24286
24397
  // ../jsx/src/index.ts
24287
24398
  registerBuiltinLoweringPlugins();