@barefootjs/jsx 0.28.0 → 0.29.0

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
@@ -5367,6 +5367,7 @@ var ErrorCodes = {
5367
5367
  SHARED_PROGRAM_REQUIRED: "BF050",
5368
5368
  WRONG_PACKAGE_IMPORT: "BF051",
5369
5369
  BUILTIN_REQUIRES_IMPORT: "BF054",
5370
+ INLINED_IMPORT_MISSING_EXPORT: "BF055",
5370
5371
  UNDECLARED_INIT_STATEMENT_REFERENCE: "BF052",
5371
5372
  STRIPPED_CLIENT_IMPORT_REFERENCED: "BF053",
5372
5373
  STAGE_REACTIVE_IN_TEMPLATE: "BF060",
@@ -5397,6 +5398,7 @@ var errorMessages = {
5397
5398
  [ErrorCodes.BUILTIN_REQUIRES_IMPORT]: "Built-in <Async> / <Region> must be imported from '@barefootjs/client'. " + "The compiler recognises these tags by their import (not by tag name), " + "so an unimported tag with this name is treated as an undeclared component.",
5398
5399
  [ErrorCodes.UNDECLARED_INIT_STATEMENT_REFERENCE]: "Init statement references an undeclared identifier. Declare it at module scope, inside the component, or import it — otherwise ESM strict mode throws ReferenceError at runtime.",
5399
5400
  [ErrorCodes.STRIPPED_CLIENT_IMPORT_REFERENCED]: "Import was stripped from the client bundle but its binding is still referenced. Client components ('use client' .tsx) are not callable as plain functions from imperative .ts modules — render them as JSX from a 'use client' parent instead. If the flagged name is a local shadow rather than the stripped import, please file an issue.",
5401
+ [ErrorCodes.INLINED_IMPORT_MISSING_EXPORT]: "An inlined relative import requests a name the target module does not export. The client bundle would throw ReferenceError at load.",
5400
5402
  [ErrorCodes.STAGE_REACTIVE_IN_TEMPLATE]: "Reactive binding (signal getter or memo) referenced from template scope. The template lambda runs at module scope without the reactive context, so the value cannot be evaluated at SSR. Wrap the JSX expression in /* @client */ to defer it to hydrate, or restructure so the template uses a prop or static value.",
5401
5403
  [ErrorCodes.STAGE_INIT_LOCAL_IN_TEMPLATE]: "Init-scope local referenced from template scope. The template lambda runs at module scope (via render() / renderChild()) and cannot reach init-body locals. Wrap the JSX expression in /* @client */, or lift the value to a prop or module-scope const.",
5402
5404
  [ErrorCodes.STAGE_AWAIT_IN_TEMPLATE]: "AwaitExpression in template scope. The generated template and init functions are synchronous — a bare `await` produces a SyntaxError at parse time. Move the await into the component body (before the return) or into an onMount/effect callback, and pass the resolved value to JSX.",
@@ -7931,6 +7933,8 @@ function importsBrowserOnlyClientApi(ctx) {
7931
7933
  if (imp.isTypeOnly)
7932
7934
  continue;
7933
7935
  for (const spec of imp.specifiers) {
7936
+ if (spec.isTypeOnly)
7937
+ continue;
7934
7938
  const importedName = spec.name;
7935
7939
  if (BROWSER_ONLY_CLIENT_APIS.has(importedName))
7936
7940
  return true;
@@ -14042,7 +14046,7 @@ function emitTemplateCloneLines(template, indent) {
14042
14046
  ];
14043
14047
  }
14044
14048
  function emitLoopItemElementSetup(lines, opts) {
14045
- const { template, bodyIsMultiRoot, indent, singleRootLayout } = opts;
14049
+ const { template, bodyIsMultiRoot, indent, singleRootLayout, mountRow } = opts;
14046
14050
  const innerIndent = indent + " ";
14047
14051
  if (bodyIsMultiRoot) {
14048
14052
  lines.push(`${indent}let __el, __extras`);
@@ -14053,18 +14057,21 @@ function emitLoopItemElementSetup(lines, opts) {
14053
14057
  lines.push(ln);
14054
14058
  }
14055
14059
  lines.push(`${innerIndent}__el.__bfExtras = __extras`);
14060
+ if (mountRow)
14061
+ lines.push(`${innerIndent}mountRowRoot(__el)`);
14056
14062
  lines.push(`${indent}}`);
14057
14063
  return;
14058
14064
  }
14059
14065
  if (singleRootLayout === "inline") {
14060
14066
  const cloneExpr = emitTemplateCloneInline(template);
14061
- lines.push(`${indent}const __el = __existing ?? (() => { ${cloneExpr} })()`);
14067
+ const clone = `__existing ?? (() => { ${cloneExpr} })()`;
14068
+ lines.push(`${indent}const __el = ${mountRow ? `__existing ?? mountRowRoot((() => { ${cloneExpr} })())` : clone}`);
14062
14069
  return;
14063
14070
  }
14064
- lines.push(`${indent}const __el = __existing ?? (() => {`);
14071
+ lines.push(`${indent}const __el = __existing ?? ${mountRow ? "mountRowRoot(" : ""}(() => {`);
14065
14072
  for (const ln of emitTemplateCloneLines(template, innerIndent))
14066
14073
  lines.push(ln);
14067
- lines.push(`${indent}})()`);
14074
+ lines.push(`${indent}})()${mountRow ? ")" : ""}`);
14068
14075
  }
14069
14076
  function emitMultiRootTemplateCloneLines(template, indent, varEl, varExtras) {
14070
14077
  const isSvg = multiRootTemplateNeedsSvgWrap(template);
@@ -15279,6 +15286,74 @@ function propHasPropertyAccess(u) {
15279
15286
  return u.accessKinds.has("property") || u.accessKinds.has("index");
15280
15287
  }
15281
15288
 
15289
+ // src/value-references.ts
15290
+ import ts13 from "typescript";
15291
+ function isValueReferenceIdentifier(id) {
15292
+ const parent = id.parent;
15293
+ if (!parent)
15294
+ return false;
15295
+ if (ts13.isPropertyAccessExpression(parent) && parent.name === id)
15296
+ return false;
15297
+ if (ts13.isPropertyAssignment(parent) && parent.name === id)
15298
+ return false;
15299
+ if ((ts13.isMethodDeclaration(parent) || ts13.isGetAccessorDeclaration(parent) || ts13.isSetAccessorDeclaration(parent)) && parent.name === id) {
15300
+ return false;
15301
+ }
15302
+ if (ts13.isPropertyDeclaration(parent) && parent.name === id)
15303
+ return false;
15304
+ if (ts13.isMetaProperty(parent) && parent.name === id)
15305
+ return false;
15306
+ if (ts13.isVariableDeclaration(parent) && parent.name === id)
15307
+ return false;
15308
+ if (ts13.isFunctionDeclaration(parent) && parent.name === id)
15309
+ return false;
15310
+ if (ts13.isFunctionExpression(parent) && parent.name === id)
15311
+ return false;
15312
+ if (ts13.isClassDeclaration(parent) && parent.name === id)
15313
+ return false;
15314
+ if (ts13.isClassExpression(parent) && parent.name === id)
15315
+ return false;
15316
+ if (ts13.isParameter(parent) && parent.name === id)
15317
+ return false;
15318
+ if (ts13.isBindingElement(parent) && (parent.name === id || parent.propertyName === id))
15319
+ return false;
15320
+ if (ts13.isLabeledStatement(parent) && parent.label === id)
15321
+ return false;
15322
+ if (ts13.isBreakOrContinueStatement(parent) && parent.label === id)
15323
+ return false;
15324
+ if (ts13.isImportSpecifier(parent) && (parent.name === id || parent.propertyName === id))
15325
+ return false;
15326
+ if (ts13.isExportSpecifier(parent) && (parent.name === id || parent.propertyName === id))
15327
+ return false;
15328
+ if (ts13.isImportClause(parent) && parent.name === id)
15329
+ return false;
15330
+ if (ts13.isNamespaceImport(parent) && parent.name === id)
15331
+ return false;
15332
+ if (ts13.isQualifiedName(parent) && parent.right === id)
15333
+ return false;
15334
+ return true;
15335
+ }
15336
+ function collectValueReferencedNames(code) {
15337
+ let sourceFile;
15338
+ try {
15339
+ sourceFile = ts13.createSourceFile("generated.js", code, ts13.ScriptTarget.Latest, true, ts13.ScriptKind.JS);
15340
+ } catch {
15341
+ return null;
15342
+ }
15343
+ const diagnostics = sourceFile.parseDiagnostics;
15344
+ if (diagnostics && diagnostics.length > 0)
15345
+ return null;
15346
+ const names = new Set;
15347
+ function visit3(node) {
15348
+ if (ts13.isIdentifier(node) && isValueReferenceIdentifier(node)) {
15349
+ names.add(node.text);
15350
+ }
15351
+ ts13.forEachChild(node, visit3);
15352
+ }
15353
+ visit3(sourceFile);
15354
+ return names;
15355
+ }
15356
+
15282
15357
  // src/ir-to-client-js/imports.ts
15283
15358
  var RUNTIME_IMPORT_CANDIDATES = [
15284
15359
  "createSignal",
@@ -15301,6 +15376,7 @@ var RUNTIME_IMPORT_CANDIDATES = [
15301
15376
  "registerTemplate",
15302
15377
  "initChild",
15303
15378
  "upsertChild",
15379
+ "mountRowRoot",
15304
15380
  "createPortal",
15305
15381
  "provideContext",
15306
15382
  "createContext",
@@ -15357,7 +15433,7 @@ function collectUserDomImports(ir) {
15357
15433
  for (const imp of ir.metadata.imports) {
15358
15434
  if (runtimeSources.has(imp.source) && !imp.isTypeOnly) {
15359
15435
  for (const spec of imp.specifiers) {
15360
- if (!spec.isDefault && !spec.isNamespace) {
15436
+ if (!spec.isDefault && !spec.isNamespace && !spec.isTypeOnly) {
15361
15437
  if (isClientBuiltinName(spec.name))
15362
15438
  continue;
15363
15439
  userImports.push(spec.alias ? `${spec.name} as ${spec.alias}` : spec.name);
@@ -15367,9 +15443,22 @@ function collectUserDomImports(ir) {
15367
15443
  }
15368
15444
  return userImports;
15369
15445
  }
15446
+ function makeValueUsageTest(generatedCode) {
15447
+ let referenced;
15448
+ return (localName) => {
15449
+ if (referenced === undefined) {
15450
+ referenced = collectValueReferencedNames(generatedCode);
15451
+ }
15452
+ if (referenced !== null) {
15453
+ return referenced.has(localName);
15454
+ }
15455
+ return generatedCode.includes(localName);
15456
+ };
15457
+ }
15370
15458
  function collectExternalImports(ir, generatedCode, localImportPrefixes) {
15371
15459
  const componentNames = collectComponentNames(ir.root);
15372
15460
  const importLines = [];
15461
+ const isUsedAsValue = makeValueUsageTest(generatedCode);
15373
15462
  for (const imp of ir.metadata.imports) {
15374
15463
  if (imp.isTypeOnly)
15375
15464
  continue;
@@ -15383,10 +15472,12 @@ function collectExternalImports(ir, generatedCode, localImportPrefixes) {
15383
15472
  }
15384
15473
  const usedSpecs = [];
15385
15474
  for (const spec of imp.specifiers) {
15475
+ if (spec.isTypeOnly)
15476
+ continue;
15386
15477
  const localName = spec.alias || spec.name;
15387
15478
  if (componentNames.has(localName))
15388
15479
  continue;
15389
- if (new RegExp(`\\b${localName}\\b`).test(generatedCode)) {
15480
+ if (isUsedAsValue(localName)) {
15390
15481
  usedSpecs.push(spec.alias ? `${spec.name} as ${spec.alias}` : spec.name);
15391
15482
  }
15392
15483
  }
@@ -15425,7 +15516,7 @@ function collectComponentNames(node) {
15425
15516
  }
15426
15517
 
15427
15518
  // src/relocate.ts
15428
- import ts13 from "typescript";
15519
+ import ts14 from "typescript";
15429
15520
 
15430
15521
  // src/lowering-registry.ts
15431
15522
  var plugins = [];
@@ -15471,19 +15562,19 @@ function classify(name, env) {
15471
15562
  function collectFreeRefs(node) {
15472
15563
  const refs = new Map;
15473
15564
  function visit3(n, parent) {
15474
- if (ts13.isIdentifier(n)) {
15475
- if (parent && ts13.isPropertyAccessExpression(parent) && parent.name === n)
15565
+ if (ts14.isIdentifier(n)) {
15566
+ if (parent && ts14.isPropertyAccessExpression(parent) && parent.name === n)
15476
15567
  return;
15477
- if (parent && ts13.isPropertyAssignment(parent) && parent.name === n)
15568
+ if (parent && ts14.isPropertyAssignment(parent) && parent.name === n)
15478
15569
  return;
15479
- if (parent && ts13.isShorthandPropertyAssignment(parent) && parent.name === n)
15570
+ if (parent && ts14.isShorthandPropertyAssignment(parent) && parent.name === n)
15480
15571
  return;
15481
15572
  const list = refs.get(n.text) ?? [];
15482
15573
  list.push(n);
15483
15574
  refs.set(n.text, list);
15484
15575
  return;
15485
15576
  }
15486
- ts13.forEachChild(n, (child) => visit3(child, n));
15577
+ ts14.forEachChild(n, (child) => visit3(child, n));
15487
15578
  }
15488
15579
  visit3(node);
15489
15580
  return refs;
@@ -15586,11 +15677,11 @@ function isInlinableInTemplate(value, env) {
15586
15677
  return { ok: true, rewrittenValue: r.text, decisions: r.decisions };
15587
15678
  }
15588
15679
  function getCalleeIdentifierPath(callee) {
15589
- if (ts13.isParenthesizedExpression(callee))
15680
+ if (ts14.isParenthesizedExpression(callee))
15590
15681
  return getCalleeIdentifierPath(callee.expression);
15591
- if (ts13.isIdentifier(callee))
15682
+ if (ts14.isIdentifier(callee))
15592
15683
  return callee.text;
15593
- if (ts13.isPropertyAccessExpression(callee)) {
15684
+ if (ts14.isPropertyAccessExpression(callee)) {
15594
15685
  const left = getCalleeIdentifierPath(callee.expression);
15595
15686
  if (left === null)
15596
15687
  return null;
@@ -15599,11 +15690,11 @@ function getCalleeIdentifierPath(callee) {
15599
15690
  return null;
15600
15691
  }
15601
15692
  function getCalleeLeftmostIdentifier(callee) {
15602
- if (ts13.isParenthesizedExpression(callee))
15693
+ if (ts14.isParenthesizedExpression(callee))
15603
15694
  return getCalleeLeftmostIdentifier(callee.expression);
15604
- if (ts13.isIdentifier(callee))
15695
+ if (ts14.isIdentifier(callee))
15605
15696
  return callee.text;
15606
- if (ts13.isPropertyAccessExpression(callee)) {
15697
+ if (ts14.isPropertyAccessExpression(callee)) {
15607
15698
  return getCalleeLeftmostIdentifier(callee.expression);
15608
15699
  }
15609
15700
  return null;
@@ -15651,12 +15742,12 @@ function isCallAcceptedByAdapter(call, env) {
15651
15742
  }
15652
15743
  function parseExpressionNode(text) {
15653
15744
  try {
15654
- const sf = ts13.createSourceFile("__inline_check__.ts", `(${text});`, ts13.ScriptTarget.Latest, false, ts13.ScriptKind.TS);
15745
+ const sf = ts14.createSourceFile("__inline_check__.ts", `(${text});`, ts14.ScriptTarget.Latest, false, ts14.ScriptKind.TS);
15655
15746
  const stmt = sf.statements[0];
15656
- if (!stmt || !ts13.isExpressionStatement(stmt))
15747
+ if (!stmt || !ts14.isExpressionStatement(stmt))
15657
15748
  return null;
15658
15749
  const inner = stmt.expression;
15659
- return ts13.isParenthesizedExpression(inner) ? inner.expression : inner;
15750
+ return ts14.isParenthesizedExpression(inner) ? inner.expression : inner;
15660
15751
  } catch {
15661
15752
  return null;
15662
15753
  }
@@ -15673,8 +15764,8 @@ function hasCallWithBridgedArg(node, decisions, env) {
15673
15764
  function visit3(n) {
15674
15765
  if (found)
15675
15766
  return;
15676
- if (ts13.isCallExpression(n) || ts13.isNewExpression(n)) {
15677
- const accepted = ts13.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
15767
+ if (ts14.isCallExpression(n) || ts14.isNewExpression(n)) {
15768
+ const accepted = ts14.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
15678
15769
  if (!accepted) {
15679
15770
  const args = n.arguments;
15680
15771
  if (args) {
@@ -15687,7 +15778,7 @@ function hasCallWithBridgedArg(node, decisions, env) {
15687
15778
  }
15688
15779
  }
15689
15780
  }
15690
- ts13.forEachChild(n, visit3);
15781
+ ts14.forEachChild(n, visit3);
15691
15782
  }
15692
15783
  visit3(node);
15693
15784
  return found;
@@ -15697,13 +15788,13 @@ function hasZeroArgCall(node, env) {
15697
15788
  function visit3(n) {
15698
15789
  if (found)
15699
15790
  return;
15700
- if (ts13.isCallExpression(n) && n.arguments.length === 0) {
15791
+ if (ts14.isCallExpression(n) && n.arguments.length === 0) {
15701
15792
  if (!isCallAcceptedByAdapter(n, env)) {
15702
15793
  found = true;
15703
15794
  return;
15704
15795
  }
15705
15796
  }
15706
- ts13.forEachChild(n, visit3);
15797
+ ts14.forEachChild(n, visit3);
15707
15798
  }
15708
15799
  visit3(node);
15709
15800
  return found;
@@ -15713,25 +15804,25 @@ function containsAnyIdentifier(node, names) {
15713
15804
  function visit3(n) {
15714
15805
  if (found)
15715
15806
  return;
15716
- if (ts13.isPropertyAccessExpression(n)) {
15807
+ if (ts14.isPropertyAccessExpression(n)) {
15717
15808
  visit3(n.expression);
15718
15809
  return;
15719
15810
  }
15720
- if (ts13.isPropertyAssignment(n)) {
15811
+ if (ts14.isPropertyAssignment(n)) {
15721
15812
  visit3(n.initializer);
15722
15813
  return;
15723
15814
  }
15724
- if (ts13.isShorthandPropertyAssignment(n)) {
15725
- if (ts13.isIdentifier(n.name) && names.has(n.name.text)) {
15815
+ if (ts14.isShorthandPropertyAssignment(n)) {
15816
+ if (ts14.isIdentifier(n.name) && names.has(n.name.text)) {
15726
15817
  found = true;
15727
15818
  }
15728
15819
  return;
15729
15820
  }
15730
- if (ts13.isIdentifier(n) && names.has(n.text)) {
15821
+ if (ts14.isIdentifier(n) && names.has(n.text)) {
15731
15822
  found = true;
15732
15823
  return;
15733
15824
  }
15734
- ts13.forEachChild(n, visit3);
15825
+ ts14.forEachChild(n, visit3);
15735
15826
  }
15736
15827
  visit3(node);
15737
15828
  return found;
@@ -18854,7 +18945,7 @@ function buildArmBody(branch, options) {
18854
18945
  }
18855
18946
 
18856
18947
  // src/ir-to-client-js/emit-reactive.ts
18857
- import ts14 from "typescript";
18948
+ import ts15 from "typescript";
18858
18949
 
18859
18950
  // src/ir-to-client-js/control-flow/stringify/claim-plan.ts
18860
18951
  function slotSpecLiteral(slot) {
@@ -18957,20 +19048,20 @@ function lowerToLocaleCallsInReactiveExpr(expr, matcher) {
18957
19048
  return expr;
18958
19049
  let sourceFile;
18959
19050
  try {
18960
- sourceFile = ts14.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts14.ScriptTarget.Latest, true, ts14.ScriptKind.TS);
19051
+ sourceFile = ts15.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts15.ScriptTarget.Latest, true, ts15.ScriptKind.TS);
18961
19052
  } catch {
18962
19053
  return expr;
18963
19054
  }
18964
19055
  const stmt = sourceFile.statements[0];
18965
- if (!stmt || !ts14.isExpressionStatement(stmt))
19056
+ if (!stmt || !ts15.isExpressionStatement(stmt))
18966
19057
  return expr;
18967
- const root = ts14.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19058
+ const root = ts15.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
18968
19059
  const candidates = [];
18969
19060
  const visit3 = (n) => {
18970
- if (ts14.isCallExpression(n) && n.arguments.length === 2 && ts14.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
19061
+ if (ts15.isCallExpression(n) && n.arguments.length === 2 && ts15.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
18971
19062
  candidates.push(n);
18972
19063
  }
18973
- ts14.forEachChild(n, visit3);
19064
+ ts15.forEachChild(n, visit3);
18974
19065
  };
18975
19066
  visit3(root);
18976
19067
  if (candidates.length === 0)
@@ -19006,20 +19097,20 @@ function lowerDateCallsInReactiveExpr(expr, matcher) {
19006
19097
  return expr;
19007
19098
  let sourceFile;
19008
19099
  try {
19009
- sourceFile = ts14.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts14.ScriptTarget.Latest, true, ts14.ScriptKind.TS);
19100
+ sourceFile = ts15.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts15.ScriptTarget.Latest, true, ts15.ScriptKind.TS);
19010
19101
  } catch {
19011
19102
  return expr;
19012
19103
  }
19013
19104
  const stmt = sourceFile.statements[0];
19014
- if (!stmt || !ts14.isExpressionStatement(stmt))
19105
+ if (!stmt || !ts15.isExpressionStatement(stmt))
19015
19106
  return expr;
19016
- const root = ts14.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19107
+ const root = ts15.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19017
19108
  const candidates = [];
19018
19109
  const visit3 = (n) => {
19019
- if (ts14.isCallExpression(n) && n.arguments.length === 0 && ts14.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
19110
+ if (ts15.isCallExpression(n) && n.arguments.length === 0 && ts15.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
19020
19111
  candidates.push(n);
19021
19112
  }
19022
- ts14.forEachChild(n, visit3);
19113
+ ts15.forEachChild(n, visit3);
19023
19114
  };
19024
19115
  visit3(root);
19025
19116
  if (candidates.length === 0)
@@ -20144,7 +20235,8 @@ function stringifyCompositeLoop(lines, plan) {
20144
20235
  template,
20145
20236
  bodyIsMultiRoot,
20146
20237
  indent: bodyIndent,
20147
- singleRootLayout: "multiline"
20238
+ singleRootLayout: "multiline",
20239
+ mountRow: true
20148
20240
  });
20149
20241
  emitComponentAndEventSetup(lines, bodyIndent, "__el", compsArr, eventsArr, loopParam, loopParamBindings, bodyIsMultiRoot);
20150
20242
  if (innerLoops.length > 0) {
@@ -20974,20 +21066,20 @@ var PHASES = [
20974
21066
  ];
20975
21067
 
20976
21068
  // src/ir-to-client-js/rewrite-props-object.ts
20977
- import ts15 from "typescript";
21069
+ import ts16 from "typescript";
20978
21070
  function rewritePropsObjectRef(code, propsObjectName) {
20979
21071
  const srcPropsName = propsObjectName ?? "props";
20980
21072
  if (srcPropsName === PROPS_PARAM)
20981
21073
  return code;
20982
21074
  if (!new RegExp(`\\b${srcPropsName}\\b`).test(code))
20983
21075
  return code;
20984
- const sourceFile = ts15.createSourceFile("init-body.ts", code, ts15.ScriptTarget.Latest, true, ts15.ScriptKind.TS);
21076
+ const sourceFile = ts16.createSourceFile("init-body.ts", code, ts16.ScriptTarget.Latest, true, ts16.ScriptKind.TS);
20985
21077
  const spans = [];
20986
21078
  function visit3(node) {
20987
- if (ts15.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
21079
+ if (ts16.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
20988
21080
  spans.push([node.getStart(sourceFile), node.getEnd()]);
20989
21081
  }
20990
- ts15.forEachChild(node, visit3);
21082
+ ts16.forEachChild(node, visit3);
20991
21083
  }
20992
21084
  visit3(sourceFile);
20993
21085
  if (spans.length === 0)
@@ -21003,17 +21095,17 @@ function shouldRewrite(node) {
21003
21095
  const parent = node.parent;
21004
21096
  if (!parent)
21005
21097
  return true;
21006
- if (ts15.isPropertyAccessExpression(parent) && parent.name === node)
21098
+ if (ts16.isPropertyAccessExpression(parent) && parent.name === node)
21007
21099
  return false;
21008
- if (ts15.isPropertyAssignment(parent) && parent.name === node)
21100
+ if (ts16.isPropertyAssignment(parent) && parent.name === node)
21009
21101
  return false;
21010
- if (ts15.isShorthandPropertyAssignment(parent) && parent.name === node)
21102
+ if (ts16.isShorthandPropertyAssignment(parent) && parent.name === node)
21011
21103
  return false;
21012
- if (ts15.isPropertySignature(parent) && parent.name === node)
21104
+ if (ts16.isPropertySignature(parent) && parent.name === node)
21013
21105
  return false;
21014
- if (ts15.isPropertyDeclaration(parent) && parent.name === node)
21106
+ if (ts16.isPropertyDeclaration(parent) && parent.name === node)
21015
21107
  return false;
21016
- if (ts15.isBindingElement(parent) && parent.name === node)
21108
+ if (ts16.isBindingElement(parent) && parent.name === node)
21017
21109
  return false;
21018
21110
  return true;
21019
21111
  }
@@ -21643,7 +21735,7 @@ function walkIR2(node, visitor) {
21643
21735
  }
21644
21736
 
21645
21737
  // src/preprocess-inline-jsx-callbacks.ts
21646
- import ts16 from "typescript";
21738
+ import ts17 from "typescript";
21647
21739
  var SYNTHETIC_PREFIX = "BFInlineJsxCallback";
21648
21740
  var MAX_FIXPOINT_ITERATIONS = 16;
21649
21741
  function preprocessInlineJsxCallbacks(source, filePath) {
@@ -21665,8 +21757,8 @@ function preprocessInlineJsxCallbacks(source, filePath) {
21665
21757
  return { source: current, errors, syntheticNames };
21666
21758
  }
21667
21759
  function runSinglePass(source, filePath, startingCounter) {
21668
- const sourceFile = ts16.createSourceFile(filePath, source, ts16.ScriptTarget.Latest, true, ts16.ScriptKind.TSX);
21669
- const hasUseClient = sourceFile.statements.some((stmt) => ts16.isExpressionStatement(stmt) && ts16.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
21760
+ const sourceFile = ts17.createSourceFile(filePath, source, ts17.ScriptTarget.Latest, true, ts17.ScriptKind.TSX);
21761
+ const hasUseClient = sourceFile.statements.some((stmt) => ts17.isExpressionStatement(stmt) && ts17.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
21670
21762
  if (!hasUseClient) {
21671
21763
  return { source, errors: [], syntheticNames: [], counterAfter: startingCounter };
21672
21764
  }
@@ -21688,22 +21780,22 @@ function runSinglePass(source, filePath, startingCounter) {
21688
21780
  }
21689
21781
  }
21690
21782
  function visit3(node) {
21691
- if (ts16.isJsxAttribute(node) && node.initializer && ts16.isJsxExpression(node.initializer) && node.initializer.expression) {
21783
+ if (ts17.isJsxAttribute(node) && node.initializer && ts17.isJsxExpression(node.initializer) && node.initializer.expression) {
21692
21784
  if (tryHandleArrowValue(node.initializer.expression)) {
21693
21785
  return;
21694
21786
  }
21695
21787
  }
21696
- if (ts16.isPropertyAssignment(node) && node.initializer) {
21788
+ if (ts17.isPropertyAssignment(node) && node.initializer) {
21697
21789
  if (tryHandleArrowValue(node.initializer))
21698
21790
  return;
21699
21791
  }
21700
- ts16.forEachChild(node, visit3);
21792
+ ts17.forEachChild(node, visit3);
21701
21793
  }
21702
21794
  function tryHandleArrowValue(initializer) {
21703
21795
  let expr = initializer;
21704
- while (ts16.isParenthesizedExpression(expr))
21796
+ while (ts17.isParenthesizedExpression(expr))
21705
21797
  expr = expr.expression;
21706
- if (ts16.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
21798
+ if (ts17.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
21707
21799
  return handleInlineArrow(expr);
21708
21800
  }
21709
21801
  return false;
@@ -21740,7 +21832,7 @@ function runSinglePass(source, filePath, startingCounter) {
21740
21832
  replacements.push({ start: arrowStart, end: arrowEnd, text: name });
21741
21833
  return true;
21742
21834
  }
21743
- ts16.forEachChild(sourceFile, visit3);
21835
+ ts17.forEachChild(sourceFile, visit3);
21744
21836
  if (replacements.length === 0) {
21745
21837
  return { source, errors, syntheticNames, counterAfter: counter };
21746
21838
  }
@@ -21763,11 +21855,11 @@ function errorMessageForCapture(captures) {
21763
21855
  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.`;
21764
21856
  }
21765
21857
  function arrowBodyContainsJsx(arrow) {
21766
- if (ts16.isBlock(arrow.body)) {
21858
+ if (ts17.isBlock(arrow.body)) {
21767
21859
  return blockReturnsJsx(arrow.body);
21768
21860
  }
21769
21861
  let body = arrow.body;
21770
- while (ts16.isParenthesizedExpression(body))
21862
+ while (ts17.isParenthesizedExpression(body))
21771
21863
  body = body.expression;
21772
21864
  return isJsxLike(body);
21773
21865
  }
@@ -21776,24 +21868,24 @@ function blockReturnsJsx(block) {
21776
21868
  function visit3(n) {
21777
21869
  if (found)
21778
21870
  return;
21779
- if (ts16.isReturnStatement(n) && n.expression) {
21871
+ if (ts17.isReturnStatement(n) && n.expression) {
21780
21872
  let e = n.expression;
21781
- while (ts16.isParenthesizedExpression(e))
21873
+ while (ts17.isParenthesizedExpression(e))
21782
21874
  e = e.expression;
21783
21875
  if (isJsxLike(e)) {
21784
21876
  found = true;
21785
21877
  return;
21786
21878
  }
21787
21879
  }
21788
- if (ts16.isArrowFunction(n) || ts16.isFunctionDeclaration(n) || ts16.isFunctionExpression(n))
21880
+ if (ts17.isArrowFunction(n) || ts17.isFunctionDeclaration(n) || ts17.isFunctionExpression(n))
21789
21881
  return;
21790
- ts16.forEachChild(n, visit3);
21882
+ ts17.forEachChild(n, visit3);
21791
21883
  }
21792
- ts16.forEachChild(block, visit3);
21884
+ ts17.forEachChild(block, visit3);
21793
21885
  return found;
21794
21886
  }
21795
21887
  function isJsxLike(expr) {
21796
- return ts16.isJsxElement(expr) || ts16.isJsxSelfClosingElement(expr) || ts16.isJsxFragment(expr);
21888
+ return ts17.isJsxElement(expr) || ts17.isJsxSelfClosingElement(expr) || ts17.isJsxFragment(expr);
21797
21889
  }
21798
21890
  function collectArrowParamNames(arrow) {
21799
21891
  const names = new Set;
@@ -21803,13 +21895,13 @@ function collectArrowParamNames(arrow) {
21803
21895
  }
21804
21896
  function collectBindingNames2(name, out) {
21805
21897
  const push = Array.isArray(out) ? (n) => out.push(n) : (n) => out.add(n);
21806
- if (ts16.isIdentifier(name)) {
21898
+ if (ts17.isIdentifier(name)) {
21807
21899
  push(name.text);
21808
- } else if (ts16.isObjectBindingPattern(name)) {
21900
+ } else if (ts17.isObjectBindingPattern(name)) {
21809
21901
  name.elements.forEach((el) => collectBindingNames2(el.name, out));
21810
- } else if (ts16.isArrayBindingPattern(name)) {
21902
+ } else if (ts17.isArrayBindingPattern(name)) {
21811
21903
  name.elements.forEach((el) => {
21812
- if (!ts16.isOmittedExpression(el))
21904
+ if (!ts17.isOmittedExpression(el))
21813
21905
  collectBindingNames2(el.name, out);
21814
21906
  });
21815
21907
  }
@@ -21836,48 +21928,48 @@ function collectFreeIdentifiers(arrow) {
21836
21928
  return bound.includes(name);
21837
21929
  }
21838
21930
  function visit3(node) {
21839
- if (ts16.isIdentifier(node)) {
21931
+ if (ts17.isIdentifier(node)) {
21840
21932
  const parent = node.parent;
21841
- if (parent && ts16.isPropertyAccessExpression(parent) && parent.name === node)
21933
+ if (parent && ts17.isPropertyAccessExpression(parent) && parent.name === node)
21842
21934
  return;
21843
- if (parent && ts16.isPropertyAssignment(parent) && parent.name === node)
21935
+ if (parent && ts17.isPropertyAssignment(parent) && parent.name === node)
21844
21936
  return;
21845
- if (parent && ts16.isPropertySignature(parent) && parent.name === node)
21937
+ if (parent && ts17.isPropertySignature(parent) && parent.name === node)
21846
21938
  return;
21847
- if (parent && ts16.isPropertyDeclaration(parent) && parent.name === node)
21939
+ if (parent && ts17.isPropertyDeclaration(parent) && parent.name === node)
21848
21940
  return;
21849
- if (parent && ts16.isMethodDeclaration(parent) && parent.name === node)
21941
+ if (parent && ts17.isMethodDeclaration(parent) && parent.name === node)
21850
21942
  return;
21851
- if (parent && ts16.isMethodSignature(parent) && parent.name === node)
21943
+ if (parent && ts17.isMethodSignature(parent) && parent.name === node)
21852
21944
  return;
21853
- if (parent && ts16.isGetAccessorDeclaration(parent) && parent.name === node)
21945
+ if (parent && ts17.isGetAccessorDeclaration(parent) && parent.name === node)
21854
21946
  return;
21855
- if (parent && ts16.isSetAccessorDeclaration(parent) && parent.name === node)
21947
+ if (parent && ts17.isSetAccessorDeclaration(parent) && parent.name === node)
21856
21948
  return;
21857
- if (parent && ts16.isEnumMember(parent) && parent.name === node)
21949
+ if (parent && ts17.isEnumMember(parent) && parent.name === node)
21858
21950
  return;
21859
- if (parent && ts16.isBindingElement(parent) && parent.propertyName === node)
21951
+ if (parent && ts17.isBindingElement(parent) && parent.propertyName === node)
21860
21952
  return;
21861
- if (parent && ts16.isShorthandPropertyAssignment(parent) && parent.name === node) {
21953
+ if (parent && ts17.isShorthandPropertyAssignment(parent) && parent.name === node) {
21862
21954
  if (!isBound(node.text))
21863
21955
  ids.add(node.text);
21864
21956
  return;
21865
21957
  }
21866
- if (parent && ts16.isParameter(parent) && parent.name === node)
21958
+ if (parent && ts17.isParameter(parent) && parent.name === node)
21867
21959
  return;
21868
- if (parent && ts16.isVariableDeclaration(parent) && parent.name === node)
21960
+ if (parent && ts17.isVariableDeclaration(parent) && parent.name === node)
21869
21961
  return;
21870
- if (parent && ts16.isFunctionDeclaration(parent) && parent.name === node)
21962
+ if (parent && ts17.isFunctionDeclaration(parent) && parent.name === node)
21871
21963
  return;
21872
- if (parent && ts16.isClassDeclaration(parent) && parent.name === node)
21964
+ if (parent && ts17.isClassDeclaration(parent) && parent.name === node)
21873
21965
  return;
21874
- if (parent && ts16.isJsxAttribute(parent) && parent.name === node)
21966
+ if (parent && ts17.isJsxAttribute(parent) && parent.name === node)
21875
21967
  return;
21876
- if (parent && ts16.isJsxOpeningElement(parent) && parent.tagName === node) {
21968
+ if (parent && ts17.isJsxOpeningElement(parent) && parent.tagName === node) {
21877
21969
  if (/^[a-z]/.test(node.text))
21878
21970
  return;
21879
21971
  }
21880
- if (parent && ts16.isJsxClosingElement(parent) && parent.tagName === node) {
21972
+ if (parent && ts17.isJsxClosingElement(parent) && parent.tagName === node) {
21881
21973
  if (/^[a-z]/.test(node.text))
21882
21974
  return;
21883
21975
  }
@@ -21886,43 +21978,43 @@ function collectFreeIdentifiers(arrow) {
21886
21978
  ids.add(node.text);
21887
21979
  return;
21888
21980
  }
21889
- if (ts16.isVariableDeclaration(node)) {
21981
+ if (ts17.isVariableDeclaration(node)) {
21890
21982
  const declared = pushBindings(node.name);
21891
21983
  if (node.initializer)
21892
21984
  visit3(node.initializer);
21893
21985
  return;
21894
21986
  }
21895
- if (ts16.isFunctionDeclaration(node)) {
21987
+ if (ts17.isFunctionDeclaration(node)) {
21896
21988
  if (node.name)
21897
21989
  bound.push(node.name.text);
21898
21990
  visitInsideNewScope(node);
21899
21991
  return;
21900
21992
  }
21901
- if (ts16.isClassDeclaration(node)) {
21993
+ if (ts17.isClassDeclaration(node)) {
21902
21994
  if (node.name)
21903
21995
  bound.push(node.name.text);
21904
- ts16.forEachChild(node, visit3);
21996
+ ts17.forEachChild(node, visit3);
21905
21997
  return;
21906
21998
  }
21907
- if (ts16.isArrowFunction(node) || ts16.isFunctionExpression(node)) {
21999
+ if (ts17.isArrowFunction(node) || ts17.isFunctionExpression(node)) {
21908
22000
  visitInsideNewScope(node);
21909
22001
  return;
21910
22002
  }
21911
- if (ts16.isCatchClause(node)) {
22003
+ if (ts17.isCatchClause(node)) {
21912
22004
  const before = bound.length;
21913
22005
  if (node.variableDeclaration)
21914
22006
  pushBindings(node.variableDeclaration.name);
21915
- ts16.forEachChild(node, visit3);
22007
+ ts17.forEachChild(node, visit3);
21916
22008
  popN(bound.length - before);
21917
22009
  return;
21918
22010
  }
21919
- if (ts16.isBlock(node)) {
22011
+ if (ts17.isBlock(node)) {
21920
22012
  const before = bound.length;
21921
- ts16.forEachChild(node, visit3);
22013
+ ts17.forEachChild(node, visit3);
21922
22014
  popN(bound.length - before);
21923
22015
  return;
21924
22016
  }
21925
- ts16.forEachChild(node, visit3);
22017
+ ts17.forEachChild(node, visit3);
21926
22018
  }
21927
22019
  function visitInsideNewScope(fn) {
21928
22020
  const before = bound.length;
@@ -21945,29 +22037,29 @@ function collectFreeIdentifiers(arrow) {
21945
22037
  function collectModuleScopeNames(sourceFile) {
21946
22038
  const names = new Set;
21947
22039
  for (const stmt of sourceFile.statements) {
21948
- if (ts16.isFunctionDeclaration(stmt) && stmt.name)
22040
+ if (ts17.isFunctionDeclaration(stmt) && stmt.name)
21949
22041
  names.add(stmt.name.text);
21950
- else if (ts16.isClassDeclaration(stmt) && stmt.name)
22042
+ else if (ts17.isClassDeclaration(stmt) && stmt.name)
21951
22043
  names.add(stmt.name.text);
21952
- else if (ts16.isVariableStatement(stmt)) {
22044
+ else if (ts17.isVariableStatement(stmt)) {
21953
22045
  for (const decl of stmt.declarationList.declarations)
21954
22046
  collectBindingNames2(decl.name, names);
21955
- } else if (ts16.isImportDeclaration(stmt) && stmt.importClause) {
22047
+ } else if (ts17.isImportDeclaration(stmt) && stmt.importClause) {
21956
22048
  const ic = stmt.importClause;
21957
22049
  if (ic.name)
21958
22050
  names.add(ic.name.text);
21959
22051
  if (ic.namedBindings) {
21960
- if (ts16.isNamespaceImport(ic.namedBindings))
22052
+ if (ts17.isNamespaceImport(ic.namedBindings))
21961
22053
  names.add(ic.namedBindings.name.text);
21962
22054
  else
21963
22055
  for (const e of ic.namedBindings.elements)
21964
22056
  names.add(e.name.text);
21965
22057
  }
21966
- } else if (ts16.isTypeAliasDeclaration(stmt))
22058
+ } else if (ts17.isTypeAliasDeclaration(stmt))
21967
22059
  names.add(stmt.name.text);
21968
- else if (ts16.isInterfaceDeclaration(stmt))
22060
+ else if (ts17.isInterfaceDeclaration(stmt))
21969
22061
  names.add(stmt.name.text);
21970
- else if (ts16.isEnumDeclaration(stmt))
22062
+ else if (ts17.isEnumDeclaration(stmt))
21971
22063
  names.add(stmt.name.text);
21972
22064
  }
21973
22065
  return names;
@@ -21975,7 +22067,7 @@ function collectModuleScopeNames(sourceFile) {
21975
22067
  function buildSyntheticDeclaration(name, arrow, sourceFile) {
21976
22068
  const paramsText = arrow.parameters.length === 0 ? "" : arrow.parameters.map((p) => p.getText(sourceFile)).join(", ");
21977
22069
  let bodyText;
21978
- if (ts16.isBlock(arrow.body)) {
22070
+ if (ts17.isBlock(arrow.body)) {
21979
22071
  bodyText = arrow.body.getText(sourceFile);
21980
22072
  } else {
21981
22073
  const expr = arrow.body.getText(sourceFile);
@@ -21985,7 +22077,7 @@ function buildSyntheticDeclaration(name, arrow, sourceFile) {
21985
22077
  }
21986
22078
 
21987
22079
  // src/ssr-defaults.ts
21988
- import ts17 from "typescript";
22080
+ import ts18 from "typescript";
21989
22081
  var UNRESOLVED = Symbol("unresolved");
21990
22082
  var NO_RETURN = Symbol("no-return");
21991
22083
  function extractSsrDefaults(metadata) {
@@ -22061,11 +22153,11 @@ function collectPropRefs(expr, propsObjectName, out) {
22061
22153
  if (!node)
22062
22154
  return;
22063
22155
  const visit3 = (n) => {
22064
- if (ts17.isPropertyAccessExpression(n) && ts17.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts17.isIdentifier(n.name)) {
22156
+ if (ts18.isPropertyAccessExpression(n) && ts18.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts18.isIdentifier(n.name)) {
22065
22157
  out.add(n.name.text);
22066
22158
  return;
22067
22159
  }
22068
- ts17.forEachChild(n, visit3);
22160
+ ts18.forEachChild(n, visit3);
22069
22161
  };
22070
22162
  visit3(node);
22071
22163
  }
@@ -22086,23 +22178,23 @@ function tryStaticEval(expr, ctx) {
22086
22178
  }
22087
22179
  function evalStatementsForReturn(statements, ctx) {
22088
22180
  for (const stmt of statements) {
22089
- if (ts17.isVariableStatement(stmt)) {
22181
+ if (ts18.isVariableStatement(stmt)) {
22090
22182
  for (const d of stmt.declarationList.declarations) {
22091
- if (!ts17.isIdentifier(d.name) || !d.initializer)
22183
+ if (!ts18.isIdentifier(d.name) || !d.initializer)
22092
22184
  continue;
22093
22185
  const v = evalNode(d.initializer, ctx);
22094
22186
  if (v !== UNRESOLVED)
22095
22187
  ctx.bindings[d.name.text] = v;
22096
22188
  }
22097
- } else if (ts17.isReturnStatement(stmt)) {
22189
+ } else if (ts18.isReturnStatement(stmt)) {
22098
22190
  return stmt.expression ? evalNode(stmt.expression, ctx) : UNRESOLVED;
22099
- } else if (ts17.isIfStatement(stmt)) {
22191
+ } else if (ts18.isIfStatement(stmt)) {
22100
22192
  const cond = evalNode(stmt.expression, ctx);
22101
22193
  if (cond === UNRESOLVED)
22102
22194
  return UNRESOLVED;
22103
22195
  const branch = cond ? stmt.thenStatement : stmt.elseStatement;
22104
22196
  if (branch) {
22105
- const taken = evalStatementsForReturn(ts17.isBlock(branch) ? branch.statements : [branch], ctx);
22197
+ const taken = evalStatementsForReturn(ts18.isBlock(branch) ? branch.statements : [branch], ctx);
22106
22198
  if (taken !== NO_RETURN)
22107
22199
  return taken;
22108
22200
  }
@@ -22113,45 +22205,45 @@ function evalStatementsForReturn(statements, ctx) {
22113
22205
  return NO_RETURN;
22114
22206
  }
22115
22207
  function parseExpression2(expr) {
22116
- const sf = ts17.createSourceFile("__ssr_default__.ts", `(${expr})`, ts17.ScriptTarget.Latest, false, ts17.ScriptKind.TS);
22208
+ const sf = ts18.createSourceFile("__ssr_default__.ts", `(${expr})`, ts18.ScriptTarget.Latest, false, ts18.ScriptKind.TS);
22117
22209
  const stmt = sf.statements[0];
22118
- if (!stmt || !ts17.isExpressionStatement(stmt))
22210
+ if (!stmt || !ts18.isExpressionStatement(stmt))
22119
22211
  return null;
22120
- const inner = ts17.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
22212
+ const inner = ts18.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
22121
22213
  return inner;
22122
22214
  }
22123
22215
  function evalNode(node, ctx) {
22124
- if (ts17.isParenthesizedExpression(node))
22216
+ if (ts18.isParenthesizedExpression(node))
22125
22217
  return evalNode(node.expression, ctx);
22126
- if (ts17.isAsExpression(node))
22218
+ if (ts18.isAsExpression(node))
22127
22219
  return evalNode(node.expression, ctx);
22128
- if (ts17.isSatisfiesExpression(node))
22220
+ if (ts18.isSatisfiesExpression(node))
22129
22221
  return evalNode(node.expression, ctx);
22130
- if (ts17.isTypeAssertionExpression(node))
22222
+ if (ts18.isTypeAssertionExpression(node))
22131
22223
  return evalNode(node.expression, ctx);
22132
- if (ts17.isNonNullExpression(node))
22224
+ if (ts18.isNonNullExpression(node))
22133
22225
  return evalNode(node.expression, ctx);
22134
- if (ts17.isArrowFunction(node)) {
22226
+ if (ts18.isArrowFunction(node)) {
22135
22227
  if (node.parameters.length !== 0)
22136
22228
  return UNRESOLVED;
22137
- if (!ts17.isBlock(node.body))
22229
+ if (!ts18.isBlock(node.body))
22138
22230
  return evalNode(node.body, ctx);
22139
22231
  const localBindings = { ...ctx.bindings };
22140
22232
  const localCtx = { ...ctx, bindings: localBindings };
22141
22233
  const result = evalStatementsForReturn(node.body.statements, localCtx);
22142
22234
  return result === NO_RETURN ? UNRESOLVED : result;
22143
22235
  }
22144
- if (ts17.isNumericLiteral(node))
22236
+ if (ts18.isNumericLiteral(node))
22145
22237
  return Number(node.text);
22146
- if (ts17.isStringLiteralLike(node))
22238
+ if (ts18.isStringLiteralLike(node))
22147
22239
  return node.text;
22148
- if (node.kind === ts17.SyntaxKind.TrueKeyword)
22240
+ if (node.kind === ts18.SyntaxKind.TrueKeyword)
22149
22241
  return true;
22150
- if (node.kind === ts17.SyntaxKind.FalseKeyword)
22242
+ if (node.kind === ts18.SyntaxKind.FalseKeyword)
22151
22243
  return false;
22152
- if (node.kind === ts17.SyntaxKind.NullKeyword)
22244
+ if (node.kind === ts18.SyntaxKind.NullKeyword)
22153
22245
  return null;
22154
- if (ts17.isIdentifier(node)) {
22246
+ if (ts18.isIdentifier(node)) {
22155
22247
  if (node.text === "undefined")
22156
22248
  return;
22157
22249
  if (node.text in ctx.bindings)
@@ -22160,29 +22252,29 @@ function evalNode(node, ctx) {
22160
22252
  return;
22161
22253
  return UNRESOLVED;
22162
22254
  }
22163
- if (ts17.isPrefixUnaryExpression(node)) {
22255
+ if (ts18.isPrefixUnaryExpression(node)) {
22164
22256
  const arg = evalNode(node.operand, ctx);
22165
22257
  if (arg === UNRESOLVED)
22166
22258
  return UNRESOLVED;
22167
22259
  switch (node.operator) {
22168
- case ts17.SyntaxKind.MinusToken:
22260
+ case ts18.SyntaxKind.MinusToken:
22169
22261
  return typeof arg === "number" ? -arg : UNRESOLVED;
22170
- case ts17.SyntaxKind.PlusToken:
22262
+ case ts18.SyntaxKind.PlusToken:
22171
22263
  return typeof arg === "number" ? +arg : UNRESOLVED;
22172
- case ts17.SyntaxKind.ExclamationToken:
22264
+ case ts18.SyntaxKind.ExclamationToken:
22173
22265
  return !arg;
22174
22266
  }
22175
22267
  return UNRESOLVED;
22176
22268
  }
22177
- if (ts17.isObjectLiteralExpression(node)) {
22269
+ if (ts18.isObjectLiteralExpression(node)) {
22178
22270
  const obj = {};
22179
22271
  for (const prop of node.properties) {
22180
- if (!ts17.isPropertyAssignment(prop))
22272
+ if (!ts18.isPropertyAssignment(prop))
22181
22273
  return UNRESOLVED;
22182
22274
  let key;
22183
- if (ts17.isIdentifier(prop.name) || ts17.isStringLiteralLike(prop.name)) {
22275
+ if (ts18.isIdentifier(prop.name) || ts18.isStringLiteralLike(prop.name)) {
22184
22276
  key = prop.name.text;
22185
- } else if (ts17.isNumericLiteral(prop.name)) {
22277
+ } else if (ts18.isNumericLiteral(prop.name)) {
22186
22278
  key = prop.name.text;
22187
22279
  } else {
22188
22280
  return UNRESOLVED;
@@ -22194,10 +22286,10 @@ function evalNode(node, ctx) {
22194
22286
  }
22195
22287
  return obj;
22196
22288
  }
22197
- if (ts17.isArrayLiteralExpression(node)) {
22289
+ if (ts18.isArrayLiteralExpression(node)) {
22198
22290
  const arr = [];
22199
22291
  for (const elem of node.elements) {
22200
- if (ts17.isOmittedExpression(elem))
22292
+ if (ts18.isOmittedExpression(elem))
22201
22293
  return UNRESOLVED;
22202
22294
  const v = evalNode(elem, ctx);
22203
22295
  if (v === UNRESOLVED)
@@ -22206,7 +22298,7 @@ function evalNode(node, ctx) {
22206
22298
  }
22207
22299
  return arr;
22208
22300
  }
22209
- if (ts17.isElementAccessExpression(node)) {
22301
+ if (ts18.isElementAccessExpression(node)) {
22210
22302
  const base = evalNode(node.expression, ctx);
22211
22303
  if (base === undefined)
22212
22304
  return;
@@ -22220,17 +22312,17 @@ function evalNode(node, ctx) {
22220
22312
  const k = String(key);
22221
22313
  return Object.prototype.hasOwnProperty.call(base, k) ? base[k] : undefined;
22222
22314
  }
22223
- if (ts17.isPropertyAccessExpression(node)) {
22315
+ if (ts18.isPropertyAccessExpression(node)) {
22224
22316
  const baseResult = evalNode(node.expression, ctx);
22225
22317
  if (baseResult === undefined)
22226
22318
  return;
22227
22319
  return UNRESOLVED;
22228
22320
  }
22229
- if (ts17.isCallExpression(node)) {
22230
- if (node.arguments.length === 0 && ts17.isIdentifier(node.expression) && node.expression.text in ctx.bindings) {
22321
+ if (ts18.isCallExpression(node)) {
22322
+ if (node.arguments.length === 0 && ts18.isIdentifier(node.expression) && node.expression.text in ctx.bindings) {
22231
22323
  return ctx.bindings[node.expression.text];
22232
22324
  }
22233
- if (ts17.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
22325
+ if (ts18.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
22234
22326
  const recv = evalNode(node.expression.expression, ctx);
22235
22327
  if (Array.isArray(recv)) {
22236
22328
  let sep2 = ",";
@@ -22246,27 +22338,27 @@ function evalNode(node, ctx) {
22246
22338
  }
22247
22339
  return UNRESOLVED;
22248
22340
  }
22249
- if (ts17.isConditionalExpression(node)) {
22341
+ if (ts18.isConditionalExpression(node)) {
22250
22342
  const cond = evalNode(node.condition, ctx);
22251
22343
  if (cond === UNRESOLVED)
22252
22344
  return UNRESOLVED;
22253
22345
  return cond ? evalNode(node.whenTrue, ctx) : evalNode(node.whenFalse, ctx);
22254
22346
  }
22255
- if (ts17.isBinaryExpression(node)) {
22347
+ if (ts18.isBinaryExpression(node)) {
22256
22348
  const op = node.operatorToken.kind;
22257
- if (op === ts17.SyntaxKind.QuestionQuestionToken) {
22349
+ if (op === ts18.SyntaxKind.QuestionQuestionToken) {
22258
22350
  const l2 = evalNode(node.left, ctx);
22259
22351
  if (l2 !== UNRESOLVED && l2 !== null && l2 !== undefined)
22260
22352
  return l2;
22261
22353
  return evalNode(node.right, ctx);
22262
22354
  }
22263
- if (op === ts17.SyntaxKind.BarBarToken) {
22355
+ if (op === ts18.SyntaxKind.BarBarToken) {
22264
22356
  const l2 = evalNode(node.left, ctx);
22265
22357
  if (l2 !== UNRESOLVED && l2)
22266
22358
  return l2;
22267
22359
  return evalNode(node.right, ctx);
22268
22360
  }
22269
- if (op === ts17.SyntaxKind.AmpersandAmpersandToken) {
22361
+ if (op === ts18.SyntaxKind.AmpersandAmpersandToken) {
22270
22362
  const l2 = evalNode(node.left, ctx);
22271
22363
  if (l2 === UNRESOLVED)
22272
22364
  return UNRESOLVED;
@@ -22279,30 +22371,30 @@ function evalNode(node, ctx) {
22279
22371
  if (l === UNRESOLVED || r === UNRESOLVED)
22280
22372
  return UNRESOLVED;
22281
22373
  switch (op) {
22282
- case ts17.SyntaxKind.PlusToken:
22374
+ case ts18.SyntaxKind.PlusToken:
22283
22375
  if (typeof l === "string" || typeof r === "string")
22284
22376
  return `${l}${r}`;
22285
22377
  if (typeof l === "number" && typeof r === "number")
22286
22378
  return l + r;
22287
22379
  return UNRESOLVED;
22288
- case ts17.SyntaxKind.MinusToken:
22380
+ case ts18.SyntaxKind.MinusToken:
22289
22381
  return typeof l === "number" && typeof r === "number" ? l - r : UNRESOLVED;
22290
- case ts17.SyntaxKind.AsteriskToken:
22382
+ case ts18.SyntaxKind.AsteriskToken:
22291
22383
  return typeof l === "number" && typeof r === "number" ? l * r : UNRESOLVED;
22292
- case ts17.SyntaxKind.SlashToken:
22384
+ case ts18.SyntaxKind.SlashToken:
22293
22385
  return typeof l === "number" && typeof r === "number" && r !== 0 ? l / r : UNRESOLVED;
22294
- case ts17.SyntaxKind.PercentToken:
22386
+ case ts18.SyntaxKind.PercentToken:
22295
22387
  return typeof l === "number" && typeof r === "number" && r !== 0 ? l % r : UNRESOLVED;
22296
- case ts17.SyntaxKind.EqualsEqualsEqualsToken:
22297
- case ts17.SyntaxKind.EqualsEqualsToken:
22388
+ case ts18.SyntaxKind.EqualsEqualsEqualsToken:
22389
+ case ts18.SyntaxKind.EqualsEqualsToken:
22298
22390
  return l === r;
22299
- case ts17.SyntaxKind.ExclamationEqualsEqualsToken:
22300
- case ts17.SyntaxKind.ExclamationEqualsToken:
22391
+ case ts18.SyntaxKind.ExclamationEqualsEqualsToken:
22392
+ case ts18.SyntaxKind.ExclamationEqualsToken:
22301
22393
  return l !== r;
22302
22394
  }
22303
22395
  return UNRESOLVED;
22304
22396
  }
22305
- if (ts17.isTemplateExpression(node)) {
22397
+ if (ts18.isTemplateExpression(node)) {
22306
22398
  if (node.templateSpans.length === 0)
22307
22399
  return node.head.text;
22308
22400
  let acc = node.head.text;
@@ -22314,13 +22406,13 @@ function evalNode(node, ctx) {
22314
22406
  }
22315
22407
  return acc;
22316
22408
  }
22317
- if (ts17.isNoSubstitutionTemplateLiteral(node))
22409
+ if (ts18.isNoSubstitutionTemplateLiteral(node))
22318
22410
  return node.text;
22319
22411
  return UNRESOLVED;
22320
22412
  }
22321
22413
 
22322
22414
  // src/augment-inherited-props.ts
22323
- import ts18 from "typescript";
22415
+ import ts19 from "typescript";
22324
22416
  function collectContextConsumers(metadata) {
22325
22417
  const constants = metadata.localConstants ?? [];
22326
22418
  const contextDefaults = new Map;
@@ -22352,47 +22444,47 @@ function collectContextConsumers(metadata) {
22352
22444
  }
22353
22445
  function parseUseContextArg(source) {
22354
22446
  const expr = parseSingleExpression(source);
22355
- if (!expr || !ts18.isCallExpression(expr))
22447
+ if (!expr || !ts19.isCallExpression(expr))
22356
22448
  return null;
22357
- if (!ts18.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
22449
+ if (!ts19.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
22358
22450
  return null;
22359
22451
  if (expr.arguments.length !== 1)
22360
22452
  return null;
22361
22453
  const arg = expr.arguments[0];
22362
- return ts18.isIdentifier(arg) ? arg.text : null;
22454
+ return ts19.isIdentifier(arg) ? arg.text : null;
22363
22455
  }
22364
22456
  function parseCreateContextDefault(source) {
22365
22457
  const expr = parseSingleExpression(source);
22366
- if (!expr || !ts18.isCallExpression(expr))
22458
+ if (!expr || !ts19.isCallExpression(expr))
22367
22459
  return null;
22368
22460
  if (expr.arguments.length === 0)
22369
22461
  return null;
22370
22462
  const arg = expr.arguments[0];
22371
- if (ts18.isStringLiteral(arg) || ts18.isNoSubstitutionTemplateLiteral(arg))
22463
+ if (ts19.isStringLiteral(arg) || ts19.isNoSubstitutionTemplateLiteral(arg))
22372
22464
  return arg.text;
22373
- if (ts18.isNumericLiteral(arg))
22465
+ if (ts19.isNumericLiteral(arg))
22374
22466
  return Number(arg.text);
22375
- if (arg.kind === ts18.SyntaxKind.TrueKeyword)
22467
+ if (arg.kind === ts19.SyntaxKind.TrueKeyword)
22376
22468
  return true;
22377
- if (arg.kind === ts18.SyntaxKind.FalseKeyword)
22469
+ if (arg.kind === ts19.SyntaxKind.FalseKeyword)
22378
22470
  return false;
22379
22471
  return null;
22380
22472
  }
22381
22473
  function isObjectLiteralCreateContextDefault(source) {
22382
22474
  const expr = parseSingleExpression(source);
22383
- if (!expr || !ts18.isCallExpression(expr))
22475
+ if (!expr || !ts19.isCallExpression(expr))
22384
22476
  return false;
22385
22477
  if (expr.arguments.length === 0)
22386
22478
  return false;
22387
- return ts18.isObjectLiteralExpression(expr.arguments[0]);
22479
+ return ts19.isObjectLiteralExpression(expr.arguments[0]);
22388
22480
  }
22389
22481
  function parseSingleExpression(source) {
22390
- const sf = ts18.createSourceFile("__ctx.ts", `(${source})`, ts18.ScriptTarget.Latest, false);
22482
+ const sf = ts19.createSourceFile("__ctx.ts", `(${source})`, ts19.ScriptTarget.Latest, false);
22391
22483
  const stmt = sf.statements[0];
22392
- if (!stmt || !ts18.isExpressionStatement(stmt))
22484
+ if (!stmt || !ts19.isExpressionStatement(stmt))
22393
22485
  return null;
22394
22486
  let e = stmt.expression;
22395
- while (ts18.isParenthesizedExpression(e))
22487
+ while (ts19.isParenthesizedExpression(e))
22396
22488
  e = e.expression;
22397
22489
  return e;
22398
22490
  }
@@ -22417,25 +22509,25 @@ function augmentInheritedPropAccesses(ir) {
22417
22509
  const pinCoalesceLiterals = (s) => {
22418
22510
  if (!s || !s.includes(propsObj))
22419
22511
  return;
22420
- const sf = ts18.createSourceFile("__aug.ts", `(${s})`, ts18.ScriptTarget.Latest, false);
22512
+ const sf = ts19.createSourceFile("__aug.ts", `(${s})`, ts19.ScriptTarget.Latest, false);
22421
22513
  const visit3 = (n) => {
22422
- if (ts18.isBinaryExpression(n) && (n.operatorToken.kind === ts18.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts18.SyntaxKind.BarBarToken)) {
22514
+ if (ts19.isBinaryExpression(n) && (n.operatorToken.kind === ts19.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts19.SyntaxKind.BarBarToken)) {
22423
22515
  let left = n.left;
22424
- while (ts18.isParenthesizedExpression(left))
22516
+ while (ts19.isParenthesizedExpression(left))
22425
22517
  left = left.expression;
22426
- if (ts18.isPropertyAccessExpression(left) && ts18.isIdentifier(left.expression) && left.expression.text === propsObj) {
22518
+ if (ts19.isPropertyAccessExpression(left) && ts19.isIdentifier(left.expression) && left.expression.text === propsObj) {
22427
22519
  const name = left.name.text;
22428
22520
  let right = n.right;
22429
- while (ts18.isParenthesizedExpression(right))
22521
+ while (ts19.isParenthesizedExpression(right))
22430
22522
  right = right.expression;
22431
- if (ts18.isPrefixUnaryExpression(right))
22523
+ if (ts19.isPrefixUnaryExpression(right))
22432
22524
  right = right.operand;
22433
- const kind = ts18.isNumericLiteral(right) ? "number" : right.kind === ts18.SyntaxKind.TrueKeyword || right.kind === ts18.SyntaxKind.FalseKeyword ? "boolean" : ts18.isStringLiteralLike(right) ? "string" : null;
22525
+ const kind = ts19.isNumericLiteral(right) ? "number" : right.kind === ts19.SyntaxKind.TrueKeyword || right.kind === ts19.SyntaxKind.FalseKeyword ? "boolean" : ts19.isStringLiteralLike(right) ? "string" : null;
22434
22526
  if (kind && !coalesceLiteralTypes.has(name))
22435
22527
  coalesceLiteralTypes.set(name, kind);
22436
22528
  }
22437
22529
  }
22438
- ts18.forEachChild(n, visit3);
22530
+ ts19.forEachChild(n, visit3);
22439
22531
  };
22440
22532
  visit3(sf);
22441
22533
  };
@@ -22546,33 +22638,33 @@ function augmentInheritedPropAccesses(ir) {
22546
22638
  }
22547
22639
  }
22548
22640
  function parseStaticStringConst(source) {
22549
- const sf = ts18.createSourceFile("__const.ts", `const __x = (${source});`, ts18.ScriptTarget.Latest, false);
22641
+ const sf = ts19.createSourceFile("__const.ts", `const __x = (${source});`, ts19.ScriptTarget.Latest, false);
22550
22642
  const stmt = sf.statements[0];
22551
- if (!stmt || !ts18.isVariableStatement(stmt))
22643
+ if (!stmt || !ts19.isVariableStatement(stmt))
22552
22644
  return null;
22553
22645
  let init = stmt.declarationList.declarations[0]?.initializer;
22554
- while (init && ts18.isParenthesizedExpression(init))
22646
+ while (init && ts19.isParenthesizedExpression(init))
22555
22647
  init = init.expression;
22556
22648
  if (!init)
22557
22649
  return null;
22558
- if (ts18.isStringLiteral(init) || ts18.isNoSubstitutionTemplateLiteral(init)) {
22650
+ if (ts19.isStringLiteral(init) || ts19.isNoSubstitutionTemplateLiteral(init)) {
22559
22651
  return init.text;
22560
22652
  }
22561
22653
  return evalStringArrayJoin(source);
22562
22654
  }
22563
22655
  function evalTemplateOfStringConsts(source, resolved) {
22564
- const sf = ts18.createSourceFile("__const.ts", `const __x = (${source});`, ts18.ScriptTarget.Latest, false);
22656
+ const sf = ts19.createSourceFile("__const.ts", `const __x = (${source});`, ts19.ScriptTarget.Latest, false);
22565
22657
  const stmt = sf.statements[0];
22566
- if (!stmt || !ts18.isVariableStatement(stmt))
22658
+ if (!stmt || !ts19.isVariableStatement(stmt))
22567
22659
  return null;
22568
22660
  let init = stmt.declarationList.declarations[0]?.initializer;
22569
- while (init && ts18.isParenthesizedExpression(init))
22661
+ while (init && ts19.isParenthesizedExpression(init))
22570
22662
  init = init.expression;
22571
- if (!init || !ts18.isTemplateExpression(init))
22663
+ if (!init || !ts19.isTemplateExpression(init))
22572
22664
  return null;
22573
22665
  let out = init.head.text;
22574
22666
  for (const span of init.templateSpans) {
22575
- if (!ts18.isIdentifier(span.expression))
22667
+ if (!ts19.isIdentifier(span.expression))
22576
22668
  return null;
22577
22669
  const value = resolved.get(span.expression.text);
22578
22670
  if (value === undefined)
@@ -22603,30 +22695,30 @@ function lookupStaticRecordLiteral(objectName, key, constants) {
22603
22695
  const constInfo = (constants ?? []).find((c) => c.name === objectName && c.isModule);
22604
22696
  if (constInfo?.value === undefined)
22605
22697
  return null;
22606
- const sf = ts18.createSourceFile("__rec.ts", `(${constInfo.value})`, ts18.ScriptTarget.Latest, true);
22698
+ const sf = ts19.createSourceFile("__rec.ts", `(${constInfo.value})`, ts19.ScriptTarget.Latest, true);
22607
22699
  if (sf.statements.length !== 1)
22608
22700
  return null;
22609
22701
  const stmt = sf.statements[0];
22610
- if (!ts18.isExpressionStatement(stmt))
22702
+ if (!ts19.isExpressionStatement(stmt))
22611
22703
  return null;
22612
22704
  let parsed = stmt.expression;
22613
- while (ts18.isParenthesizedExpression(parsed))
22705
+ while (ts19.isParenthesizedExpression(parsed))
22614
22706
  parsed = parsed.expression;
22615
- if (!ts18.isObjectLiteralExpression(parsed))
22707
+ if (!ts19.isObjectLiteralExpression(parsed))
22616
22708
  return null;
22617
22709
  for (const prop of parsed.properties) {
22618
- if (!ts18.isPropertyAssignment(prop))
22710
+ if (!ts19.isPropertyAssignment(prop))
22619
22711
  continue;
22620
22712
  const name = prop.name;
22621
- const propKey = ts18.isIdentifier(name) || ts18.isStringLiteral(name) || ts18.isNoSubstitutionTemplateLiteral(name) ? name.text : null;
22713
+ const propKey = ts19.isIdentifier(name) || ts19.isStringLiteral(name) || ts19.isNoSubstitutionTemplateLiteral(name) ? name.text : null;
22622
22714
  if (propKey !== key)
22623
22715
  continue;
22624
22716
  let v = prop.initializer;
22625
- while (ts18.isParenthesizedExpression(v))
22717
+ while (ts19.isParenthesizedExpression(v))
22626
22718
  v = v.expression;
22627
- if (ts18.isNumericLiteral(v))
22719
+ if (ts19.isNumericLiteral(v))
22628
22720
  return { kind: "number", text: v.text };
22629
- if (ts18.isStringLiteral(v) || ts18.isNoSubstitutionTemplateLiteral(v)) {
22721
+ if (ts19.isStringLiteral(v) || ts19.isNoSubstitutionTemplateLiteral(v)) {
22630
22722
  return { kind: "string", text: v.text };
22631
22723
  }
22632
22724
  return null;
@@ -22634,28 +22726,28 @@ function lookupStaticRecordLiteral(objectName, key, constants) {
22634
22726
  return null;
22635
22727
  }
22636
22728
  function evalStringArrayJoin(source) {
22637
- const sf = ts18.createSourceFile("__join.ts", `const __x = (${source});`, ts18.ScriptTarget.Latest, false);
22729
+ const sf = ts19.createSourceFile("__join.ts", `const __x = (${source});`, ts19.ScriptTarget.Latest, false);
22638
22730
  const stmt = sf.statements[0];
22639
- if (!stmt || !ts18.isVariableStatement(stmt))
22731
+ if (!stmt || !ts19.isVariableStatement(stmt))
22640
22732
  return null;
22641
22733
  let node = stmt.declarationList.declarations[0]?.initializer;
22642
- while (node && ts18.isParenthesizedExpression(node))
22734
+ while (node && ts19.isParenthesizedExpression(node))
22643
22735
  node = node.expression;
22644
- if (!node || !ts18.isCallExpression(node))
22736
+ if (!node || !ts19.isCallExpression(node))
22645
22737
  return null;
22646
22738
  const callee = node.expression;
22647
- if (!ts18.isPropertyAccessExpression(callee))
22739
+ if (!ts19.isPropertyAccessExpression(callee))
22648
22740
  return null;
22649
22741
  if (callee.name.text !== "join")
22650
22742
  return null;
22651
22743
  let recv = callee.expression;
22652
- while (ts18.isParenthesizedExpression(recv))
22744
+ while (ts19.isParenthesizedExpression(recv))
22653
22745
  recv = recv.expression;
22654
- if (!ts18.isArrayLiteralExpression(recv))
22746
+ if (!ts19.isArrayLiteralExpression(recv))
22655
22747
  return null;
22656
22748
  const parts = [];
22657
22749
  for (const el of recv.elements) {
22658
- if (ts18.isStringLiteral(el) || ts18.isNoSubstitutionTemplateLiteral(el)) {
22750
+ if (ts19.isStringLiteral(el) || ts19.isNoSubstitutionTemplateLiteral(el)) {
22659
22751
  parts.push(el.text);
22660
22752
  } else {
22661
22753
  return null;
@@ -22664,7 +22756,7 @@ function evalStringArrayJoin(source) {
22664
22756
  let sep2 = ",";
22665
22757
  if (node.arguments.length >= 1) {
22666
22758
  const arg = node.arguments[0];
22667
- if (ts18.isStringLiteral(arg) || ts18.isNoSubstitutionTemplateLiteral(arg))
22759
+ if (ts19.isStringLiteral(arg) || ts19.isNoSubstitutionTemplateLiteral(arg))
22668
22760
  sep2 = arg.text;
22669
22761
  else
22670
22762
  return null;
@@ -22672,11 +22764,11 @@ function evalStringArrayJoin(source) {
22672
22764
  return parts.join(sep2);
22673
22765
  }
22674
22766
  function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
22675
- if (!ts18.isElementAccessExpression(val))
22767
+ if (!ts19.isElementAccessExpression(val))
22676
22768
  return null;
22677
22769
  const obj = val.expression;
22678
22770
  const arg = val.argumentExpression;
22679
- if (!ts18.isIdentifier(obj) || !ts18.isIdentifier(arg))
22771
+ if (!ts19.isIdentifier(obj) || !ts19.isIdentifier(arg))
22680
22772
  return null;
22681
22773
  let indexPropName;
22682
22774
  let defaultKey;
@@ -22692,35 +22784,35 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
22692
22784
  const constInfo = localConstants.find((c) => c.name === obj.text && c.isModule);
22693
22785
  if (constInfo?.value === undefined)
22694
22786
  return null;
22695
- const sf = ts18.createSourceFile("__rec.ts", `(${constInfo.value})`, ts18.ScriptTarget.Latest, true);
22787
+ const sf = ts19.createSourceFile("__rec.ts", `(${constInfo.value})`, ts19.ScriptTarget.Latest, true);
22696
22788
  if (sf.statements.length !== 1)
22697
22789
  return null;
22698
22790
  const stmt = sf.statements[0];
22699
- if (!ts18.isExpressionStatement(stmt))
22791
+ if (!ts19.isExpressionStatement(stmt))
22700
22792
  return null;
22701
22793
  let parsed = stmt.expression;
22702
- while (ts18.isParenthesizedExpression(parsed))
22794
+ while (ts19.isParenthesizedExpression(parsed))
22703
22795
  parsed = parsed.expression;
22704
- if (!ts18.isObjectLiteralExpression(parsed))
22796
+ if (!ts19.isObjectLiteralExpression(parsed))
22705
22797
  return null;
22706
22798
  const entries = [];
22707
22799
  for (const prop of parsed.properties) {
22708
- if (!ts18.isPropertyAssignment(prop))
22800
+ if (!ts19.isPropertyAssignment(prop))
22709
22801
  return null;
22710
22802
  let key;
22711
- if (ts18.isIdentifier(prop.name)) {
22803
+ if (ts19.isIdentifier(prop.name)) {
22712
22804
  key = prop.name.text;
22713
- } else if (ts18.isStringLiteral(prop.name) || ts18.isNoSubstitutionTemplateLiteral(prop.name)) {
22805
+ } else if (ts19.isStringLiteral(prop.name) || ts19.isNoSubstitutionTemplateLiteral(prop.name)) {
22714
22806
  key = prop.name.text;
22715
22807
  } else {
22716
22808
  return null;
22717
22809
  }
22718
22810
  let v = prop.initializer;
22719
- while (ts18.isParenthesizedExpression(v))
22811
+ while (ts19.isParenthesizedExpression(v))
22720
22812
  v = v.expression;
22721
- if (ts18.isNumericLiteral(v)) {
22813
+ if (ts19.isNumericLiteral(v)) {
22722
22814
  entries.push({ key, value: { kind: "number", text: v.text } });
22723
- } else if (ts18.isStringLiteral(v) || ts18.isNoSubstitutionTemplateLiteral(v)) {
22815
+ } else if (ts19.isStringLiteral(v) || ts19.isNoSubstitutionTemplateLiteral(v)) {
22724
22816
  entries.push({ key, value: { kind: "string", text: v.text } });
22725
22817
  } else {
22726
22818
  return null;
@@ -23359,6 +23451,7 @@ function compileJSX(source, filePath, options) {
23359
23451
  const sortedRuntimeImports = [...runtimeImports].sort();
23360
23452
  const runtimeImportLine = sortedRuntimeImports.length > 0 ? `import { ${sortedRuntimeImports.join(", ")} } from '${RUNTIME_MODULE}'` : "";
23361
23453
  const externalImportLines = [];
23454
+ const isUsedAsValue = makeValueUsageTest(body);
23362
23455
  for (const imp of ctx.imports) {
23363
23456
  if (imp.isTypeOnly)
23364
23457
  continue;
@@ -23368,7 +23461,7 @@ function compileJSX(source, filePath, options) {
23368
23461
  externalImportLines.push(`import '${imp.source}'`);
23369
23462
  continue;
23370
23463
  }
23371
- const used = imp.specifiers.filter((s2) => !s2.isDefault && !s2.isNamespace && new RegExp(`\\b${s2.alias || s2.name}\\b`).test(body)).map((s2) => s2.alias ? `${s2.name} as ${s2.alias}` : s2.name);
23464
+ const used = imp.specifiers.filter((s2) => !s2.isDefault && !s2.isNamespace && !s2.isTypeOnly && isUsedAsValue(s2.alias || s2.name)).map((s2) => s2.alias ? `${s2.name} as ${s2.alias}` : s2.name);
23372
23465
  if (used.length > 0) {
23373
23466
  externalImportLines.push(`import { ${used.join(", ")} } from '${imp.source}'`);
23374
23467
  }
@@ -23404,6 +23497,8 @@ function compileJSX(source, filePath, options) {
23404
23497
  if (!imp.source.startsWith("./") && !imp.source.startsWith("../"))
23405
23498
  continue;
23406
23499
  for (const spec of imp.specifiers) {
23500
+ if (spec.isTypeOnly)
23501
+ continue;
23407
23502
  if (ctx.importedClientSignalNames.has(spec.alias ?? spec.name)) {
23408
23503
  sources.add(imp.source);
23409
23504
  break;
@@ -23500,7 +23595,7 @@ function compileJSX(source, filePath, options) {
23500
23595
  return { files, errors };
23501
23596
  }
23502
23597
  // src/shared-program.ts
23503
- import ts19 from "typescript";
23598
+ import ts20 from "typescript";
23504
23599
  function commonParent(paths) {
23505
23600
  if (paths.length === 0)
23506
23601
  return process.cwd();
@@ -23521,10 +23616,10 @@ function commonParent(paths) {
23521
23616
  function createProgramForCorpus(files, options = {}) {
23522
23617
  const baseUrl = options.baseUrl ?? commonParent(files);
23523
23618
  const compilerOptions = {
23524
- target: ts19.ScriptTarget.Latest,
23525
- module: ts19.ModuleKind.ESNext,
23526
- moduleResolution: ts19.ModuleResolutionKind.Bundler,
23527
- jsx: ts19.JsxEmit.ReactJSX,
23619
+ target: ts20.ScriptTarget.Latest,
23620
+ module: ts20.ModuleKind.ESNext,
23621
+ moduleResolution: ts20.ModuleResolutionKind.Bundler,
23622
+ jsx: ts20.JsxEmit.ReactJSX,
23528
23623
  strict: true,
23529
23624
  skipLibCheck: true,
23530
23625
  noEmit: true,
@@ -23534,7 +23629,7 @@ function createProgramForCorpus(files, options = {}) {
23534
23629
  ...options.compilerOptions
23535
23630
  };
23536
23631
  const absolute = files.map((f) => path_default.resolve(f));
23537
- return ts19.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
23632
+ return ts20.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
23538
23633
  }
23539
23634
  // src/adapters/interface.ts
23540
23635
  class BaseAdapter {
@@ -24516,7 +24611,7 @@ function dangerousInnerHtmlDiagnostic(expr, loc, reason) {
24516
24611
  };
24517
24612
  }
24518
24613
  // src/combine-client-js.ts
24519
- import ts20 from "typescript";
24614
+ import ts21 from "typescript";
24520
24615
  var CHILD_PLACEHOLDER_RE = /import '\/\* @bf-child:(\w+) \*\/'/g;
24521
24616
  function combineParentChildClientJs(files) {
24522
24617
  const result = new Map;
@@ -24573,10 +24668,10 @@ function combineParentChildClientJs(files) {
24573
24668
  return result;
24574
24669
  }
24575
24670
  function parseAndMerge(content, importsBySource, otherImports, codeSections) {
24576
- const sourceFile = ts20.createSourceFile("combine.js", content, ts20.ScriptTarget.Latest, false, ts20.ScriptKind.JS);
24671
+ const sourceFile = ts21.createSourceFile("combine.js", content, ts21.ScriptTarget.Latest, false, ts21.ScriptKind.JS);
24577
24672
  const importSpans = [];
24578
24673
  for (const stmt of sourceFile.statements) {
24579
- if (!ts20.isImportDeclaration(stmt))
24674
+ if (!ts21.isImportDeclaration(stmt))
24580
24675
  continue;
24581
24676
  const start = stmt.getStart(sourceFile);
24582
24677
  const end = stmt.getEnd();
@@ -24586,8 +24681,8 @@ function parseAndMerge(content, importsBySource, otherImports, codeSections) {
24586
24681
  continue;
24587
24682
  const clause = stmt.importClause;
24588
24683
  const bindings = clause?.namedBindings;
24589
- const specifier = ts20.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
24590
- if (clause && !clause.name && bindings && ts20.isNamedImports(bindings)) {
24684
+ const specifier = ts21.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
24685
+ if (clause && !clause.name && bindings && ts21.isNamedImports(bindings)) {
24591
24686
  if (!importsBySource.has(specifier)) {
24592
24687
  importsBySource.set(specifier, new Set);
24593
24688
  }
@@ -24754,7 +24849,7 @@ function escapeRe(s) {
24754
24849
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
24755
24850
  }
24756
24851
  // src/debug.ts
24757
- import ts21 from "typescript";
24852
+ import ts22 from "typescript";
24758
24853
  function buildComponentGraph(source, filePath, componentName) {
24759
24854
  const ctx = analyzeComponent(source, filePath, componentName);
24760
24855
  if (!ctx.jsxReturn) {
@@ -26039,7 +26134,7 @@ function truncateExpr(expr, max = 40) {
26039
26134
  function exprReadsPropMember(expr, propsObjectName) {
26040
26135
  let sf;
26041
26136
  try {
26042
- sf = ts21.createSourceFile("__attr.tsx", `(${expr})`, ts21.ScriptTarget.Latest, true, ts21.ScriptKind.TSX);
26137
+ sf = ts22.createSourceFile("__attr.tsx", `(${expr})`, ts22.ScriptTarget.Latest, true, ts22.ScriptKind.TSX);
26043
26138
  } catch {
26044
26139
  return false;
26045
26140
  }
@@ -26047,11 +26142,11 @@ function exprReadsPropMember(expr, propsObjectName) {
26047
26142
  const visit3 = (n) => {
26048
26143
  if (found)
26049
26144
  return;
26050
- if (ts21.isPropertyAccessExpression(n) && ts21.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
26145
+ if (ts22.isPropertyAccessExpression(n) && ts22.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
26051
26146
  found = true;
26052
26147
  return;
26053
26148
  }
26054
- ts21.forEachChild(n, visit3);
26149
+ ts22.forEachChild(n, visit3);
26055
26150
  };
26056
26151
  visit3(sf);
26057
26152
  return found;
@@ -26121,7 +26216,7 @@ function findSourceFile2(meta) {
26121
26216
  return null;
26122
26217
  }
26123
26218
  // src/profiler.ts
26124
- import ts22 from "typescript";
26219
+ import ts23 from "typescript";
26125
26220
  var PROFILE_SCHEMA_VERSION = 1;
26126
26221
  var DEFAULT_FANOUT_THRESHOLD = 8;
26127
26222
  function buildStaticBudget(source, filePath, componentName, options = {}) {
@@ -26391,15 +26486,15 @@ function joinProfilerEvents(events, index) {
26391
26486
  return { joined, unattributed, diagnostics };
26392
26487
  }
26393
26488
  function findUninstrumentedEffects(source, filePath, instrumentedLines) {
26394
- const sf = ts22.createSourceFile(filePath, source, ts22.ScriptTarget.Latest, true, ts22.ScriptKind.TSX);
26489
+ const sf = ts23.createSourceFile(filePath, source, ts23.ScriptTarget.Latest, true, ts23.ScriptKind.TSX);
26395
26490
  const out = [];
26396
26491
  const visit3 = (node) => {
26397
- if (ts22.isCallExpression(node) && ts22.isIdentifier(node.expression) && node.expression.text === "createEffect") {
26492
+ if (ts23.isCallExpression(node) && ts23.isIdentifier(node.expression) && node.expression.text === "createEffect") {
26398
26493
  const line = sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;
26399
26494
  if (!instrumentedLines.has(line))
26400
26495
  out.push({ file: filePath, line });
26401
26496
  }
26402
- ts22.forEachChild(node, visit3);
26497
+ ts23.forEachChild(node, visit3);
26403
26498
  };
26404
26499
  visit3(sf);
26405
26500
  out.sort((a, b) => a.line - b.line);
@@ -26707,13 +26802,13 @@ function assessBatchSafety(args) {
26707
26802
  const signalGetters = new Set(args.graph.signals.map((s) => s.name));
26708
26803
  let sf;
26709
26804
  try {
26710
- sf = ts22.createSourceFile("__h.ts", `const __h = ${args.handler}`, ts22.ScriptTarget.Latest, true);
26805
+ sf = ts23.createSourceFile("__h.ts", `const __h = ${args.handler}`, ts23.ScriptTarget.Latest, true);
26711
26806
  } catch {
26712
26807
  return "unverified";
26713
26808
  }
26714
26809
  const calls = [];
26715
26810
  const visit3 = (node) => {
26716
- if (ts22.isCallExpression(node) && ts22.isIdentifier(node.expression)) {
26811
+ if (ts23.isCallExpression(node) && ts23.isIdentifier(node.expression)) {
26717
26812
  const name = node.expression.text;
26718
26813
  if (setters.has(name))
26719
26814
  calls.push({ pos: node.getStart(sf), kind: "write" });
@@ -26722,7 +26817,7 @@ function assessBatchSafety(args) {
26722
26817
  else if (!signalGetters.has(name) && !memoNames.has(name))
26723
26818
  calls.push({ pos: node.getStart(sf), kind: "risky" });
26724
26819
  }
26725
- ts22.forEachChild(node, visit3);
26820
+ ts23.forEachChild(node, visit3);
26726
26821
  };
26727
26822
  visit3(sf);
26728
26823
  calls.sort((a, b) => a.pos - b.pos);
@@ -27399,6 +27494,7 @@ export {
27399
27494
  listComponentFunctions,
27400
27495
  jsxToIR,
27401
27496
  joinProfilerEvents,
27497
+ isValueReferenceIdentifier,
27402
27498
  isValidHelperId,
27403
27499
  isSupported,
27404
27500
  isStringTypedOperand,
@@ -27473,6 +27569,7 @@ export {
27473
27569
  computeSsrSeedPlan,
27474
27570
  compileJSX,
27475
27571
  combineParentChildClientJs,
27572
+ collectValueReferencedNames,
27476
27573
  collectModuleStringConsts,
27477
27574
  collectLoopBoundNames,
27478
27575
  collectContextConsumers,