@barefootjs/jsx 0.27.0 → 0.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/analyzer.d.ts.map +1 -1
  2. package/dist/compiler.d.ts.map +1 -1
  3. package/dist/errors.d.ts +1 -0
  4. package/dist/errors.d.ts.map +1 -1
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +955 -273
  8. package/dist/ir-to-client-js/control-flow/plan/branch-loop.d.ts +6 -0
  9. package/dist/ir-to-client-js/control-flow/plan/branch-loop.d.ts.map +1 -1
  10. package/dist/ir-to-client-js/control-flow/plan/build-branch-loop.d.ts +2 -1
  11. package/dist/ir-to-client-js/control-flow/plan/build-branch-loop.d.ts.map +1 -1
  12. package/dist/ir-to-client-js/control-flow/plan/build-insert.d.ts +7 -0
  13. package/dist/ir-to-client-js/control-flow/plan/build-insert.d.ts.map +1 -1
  14. package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts +107 -0
  15. package/dist/ir-to-client-js/control-flow/plan/build-lazy-row.d.ts.map +1 -0
  16. package/dist/ir-to-client-js/control-flow/plan/build-loop.d.ts +9 -1
  17. package/dist/ir-to-client-js/control-flow/plan/build-loop.d.ts.map +1 -1
  18. package/dist/ir-to-client-js/control-flow/plan/lazy-row-eligibility.d.ts +203 -0
  19. package/dist/ir-to-client-js/control-flow/plan/lazy-row-eligibility.d.ts.map +1 -0
  20. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts +10 -0
  21. package/dist/ir-to-client-js/control-flow/plan/loop.d.ts.map +1 -1
  22. package/dist/ir-to-client-js/control-flow/stringify/branch-loop.d.ts.map +1 -1
  23. package/dist/ir-to-client-js/control-flow/stringify/lazy-row.d.ts +98 -0
  24. package/dist/ir-to-client-js/control-flow/stringify/lazy-row.d.ts.map +1 -0
  25. package/dist/ir-to-client-js/control-flow/stringify/loop-child-arm.d.ts +5 -0
  26. package/dist/ir-to-client-js/control-flow/stringify/loop-child-arm.d.ts.map +1 -1
  27. package/dist/ir-to-client-js/control-flow/stringify/loop.d.ts.map +1 -1
  28. package/dist/ir-to-client-js/control-flow.d.ts.map +1 -1
  29. package/dist/ir-to-client-js/imports.d.ts +26 -2
  30. package/dist/ir-to-client-js/imports.d.ts.map +1 -1
  31. package/dist/value-references.d.ts +48 -0
  32. package/dist/value-references.d.ts.map +1 -0
  33. package/package.json +2 -2
  34. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +162 -36
  35. package/src/__tests__/client-js-generation.test.ts +4 -1
  36. package/src/__tests__/composite-branch-loop.test.ts +12 -3
  37. package/src/__tests__/conditional-mapArray-key.test.ts +7 -1
  38. package/src/__tests__/create-selector.test.ts +21 -7
  39. package/src/__tests__/ir-to-client-js/imports.test.ts +98 -1
  40. package/src/__tests__/lazy-row-eligibility.test.ts +692 -0
  41. package/src/__tests__/loop-branch-bare-expression-reactive-text.test.ts +98 -0
  42. package/src/__tests__/loop-fallback-wrap.test.ts +31 -12
  43. package/src/__tests__/loop-hoisted-template.test.ts +10 -6
  44. package/src/__tests__/static-loop-csr-materialize.test.ts +6 -1
  45. package/src/__tests__/type-only-import-leak.test.ts +60 -0
  46. package/src/analyzer.ts +3 -0
  47. package/src/compiler.ts +6 -2
  48. package/src/errors.ts +11 -0
  49. package/src/index.ts +4 -0
  50. package/src/ir-to-client-js/collect-elements.ts +48 -13
  51. package/src/ir-to-client-js/control-flow/plan/branch-loop.ts +6 -0
  52. package/src/ir-to-client-js/control-flow/plan/build-branch-loop.ts +35 -12
  53. package/src/ir-to-client-js/control-flow/plan/build-insert.ts +9 -2
  54. package/src/ir-to-client-js/control-flow/plan/build-lazy-row.ts +305 -0
  55. package/src/ir-to-client-js/control-flow/plan/build-loop.ts +44 -12
  56. package/src/ir-to-client-js/control-flow/plan/lazy-row-eligibility.ts +440 -0
  57. package/src/ir-to-client-js/control-flow/plan/loop.ts +10 -0
  58. package/src/ir-to-client-js/control-flow/stringify/branch-loop.ts +22 -0
  59. package/src/ir-to-client-js/control-flow/stringify/lazy-row.ts +478 -0
  60. package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +6 -1
  61. package/src/ir-to-client-js/control-flow/stringify/loop.ts +23 -0
  62. package/src/ir-to-client-js/control-flow.ts +7 -2
  63. package/src/ir-to-client-js/imports.ts +53 -4
  64. package/src/jsx-to-ir.ts +18 -1
  65. package/src/value-references.ts +108 -0
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;
@@ -11237,7 +11241,8 @@ function transformConditionalBranch(node, ctx) {
11237
11241
  const callsReactive = exprCallsReactiveGetters(node, ctx);
11238
11242
  const hasCalls = exprHasFunctionCalls(node);
11239
11243
  const reactive = isReactiveExpression(exprText, ctx, node) || isReactiveOrigin(branchOrigin);
11240
- const needsSlot = reactive || callsReactive;
11244
+ const refsLoopParam = branchOrigin.freeRefs?.some((r) => r.kind === "render-item") ?? false;
11245
+ const needsSlot = reactive || callsReactive || refsLoopParam;
11241
11246
  const slotId = needsSlot ? generateSlotId(ctx) : null;
11242
11247
  return {
11243
11248
  type: "expression",
@@ -14832,7 +14837,7 @@ function summarizeLoopChildBranch(node, ctx, siblingOffsets, loopParam, loopPara
14832
14837
  conditionals: collectLoopChildConditionals(node, ctx, siblingOffsets, loopParam, loopParamBindings),
14833
14838
  events: collectConditionalBranchEvents(node),
14834
14839
  reactiveAttrs: collectLoopChildReactiveAttrs(node, ctx, loopParam, loopParamBindings, true),
14835
- reactiveTexts: node.type === "expression" ? [] : collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings, true)
14840
+ reactiveTexts: node.type === "expression" && node.hasFunctionCalls ? [] : collectLoopChildReactiveTexts(node, ctx, loopParam, loopParamBindings, true)
14836
14841
  };
14837
14842
  }
14838
14843
 
@@ -15278,6 +15283,70 @@ function propHasPropertyAccess(u) {
15278
15283
  return u.accessKinds.has("property") || u.accessKinds.has("index");
15279
15284
  }
15280
15285
 
15286
+ // src/value-references.ts
15287
+ import ts13 from "typescript";
15288
+ function isValueReferenceIdentifier(id) {
15289
+ const parent = id.parent;
15290
+ if (!parent)
15291
+ return false;
15292
+ if (ts13.isPropertyAccessExpression(parent) && parent.name === id)
15293
+ return false;
15294
+ if (ts13.isPropertyAssignment(parent) && parent.name === id)
15295
+ return false;
15296
+ if ((ts13.isMethodDeclaration(parent) || ts13.isGetAccessorDeclaration(parent) || ts13.isSetAccessorDeclaration(parent)) && parent.name === id) {
15297
+ return false;
15298
+ }
15299
+ if (ts13.isVariableDeclaration(parent) && parent.name === id)
15300
+ return false;
15301
+ if (ts13.isFunctionDeclaration(parent) && parent.name === id)
15302
+ return false;
15303
+ if (ts13.isFunctionExpression(parent) && parent.name === id)
15304
+ return false;
15305
+ if (ts13.isClassDeclaration(parent) && parent.name === id)
15306
+ return false;
15307
+ if (ts13.isClassExpression(parent) && parent.name === id)
15308
+ return false;
15309
+ if (ts13.isParameter(parent) && parent.name === id)
15310
+ return false;
15311
+ if (ts13.isBindingElement(parent) && (parent.name === id || parent.propertyName === id))
15312
+ return false;
15313
+ if (ts13.isLabeledStatement(parent) && parent.label === id)
15314
+ return false;
15315
+ if (ts13.isBreakOrContinueStatement(parent) && parent.label === id)
15316
+ return false;
15317
+ if (ts13.isImportSpecifier(parent) && (parent.name === id || parent.propertyName === id))
15318
+ return false;
15319
+ if (ts13.isExportSpecifier(parent) && (parent.name === id || parent.propertyName === id))
15320
+ return false;
15321
+ if (ts13.isImportClause(parent) && parent.name === id)
15322
+ return false;
15323
+ if (ts13.isNamespaceImport(parent) && parent.name === id)
15324
+ return false;
15325
+ if (ts13.isQualifiedName(parent) && parent.right === id)
15326
+ return false;
15327
+ return true;
15328
+ }
15329
+ function collectValueReferencedNames(code) {
15330
+ let sourceFile;
15331
+ try {
15332
+ sourceFile = ts13.createSourceFile("generated.js", code, ts13.ScriptTarget.Latest, true, ts13.ScriptKind.JS);
15333
+ } catch {
15334
+ return null;
15335
+ }
15336
+ const diagnostics = sourceFile.parseDiagnostics;
15337
+ if (diagnostics && diagnostics.length > 0)
15338
+ return null;
15339
+ const names = new Set;
15340
+ function visit3(node) {
15341
+ if (ts13.isIdentifier(node) && isValueReferenceIdentifier(node)) {
15342
+ names.add(node.text);
15343
+ }
15344
+ ts13.forEachChild(node, visit3);
15345
+ }
15346
+ visit3(sourceFile);
15347
+ return names;
15348
+ }
15349
+
15281
15350
  // src/ir-to-client-js/imports.ts
15282
15351
  var RUNTIME_IMPORT_CANDIDATES = [
15283
15352
  "createSignal",
@@ -15291,6 +15360,7 @@ var RUNTIME_IMPORT_CANDIDATES = [
15291
15360
  "getLoopNodes",
15292
15361
  "mapArray",
15293
15362
  "mapArrayAnchored",
15363
+ "mapArrayLazy",
15294
15364
  "patchLeaf",
15295
15365
  "createDisposableEffect",
15296
15366
  "createComponent",
@@ -15321,6 +15391,8 @@ var RUNTIME_IMPORT_CANDIDATES = [
15321
15391
  "__bfText",
15322
15392
  "claimSlots",
15323
15393
  "lazySlots",
15394
+ "lazyClaimSlots",
15395
+ "textOrNode",
15324
15396
  "beginTurn",
15325
15397
  "endTurn",
15326
15398
  "date",
@@ -15353,7 +15425,7 @@ function collectUserDomImports(ir) {
15353
15425
  for (const imp of ir.metadata.imports) {
15354
15426
  if (runtimeSources.has(imp.source) && !imp.isTypeOnly) {
15355
15427
  for (const spec of imp.specifiers) {
15356
- if (!spec.isDefault && !spec.isNamespace) {
15428
+ if (!spec.isDefault && !spec.isNamespace && !spec.isTypeOnly) {
15357
15429
  if (isClientBuiltinName(spec.name))
15358
15430
  continue;
15359
15431
  userImports.push(spec.alias ? `${spec.name} as ${spec.alias}` : spec.name);
@@ -15363,9 +15435,22 @@ function collectUserDomImports(ir) {
15363
15435
  }
15364
15436
  return userImports;
15365
15437
  }
15438
+ function makeValueUsageTest(generatedCode) {
15439
+ let referenced;
15440
+ return (localName) => {
15441
+ if (referenced === undefined) {
15442
+ referenced = collectValueReferencedNames(generatedCode);
15443
+ }
15444
+ if (referenced !== null) {
15445
+ return referenced.has(localName);
15446
+ }
15447
+ return generatedCode.includes(localName);
15448
+ };
15449
+ }
15366
15450
  function collectExternalImports(ir, generatedCode, localImportPrefixes) {
15367
15451
  const componentNames = collectComponentNames(ir.root);
15368
15452
  const importLines = [];
15453
+ const isUsedAsValue = makeValueUsageTest(generatedCode);
15369
15454
  for (const imp of ir.metadata.imports) {
15370
15455
  if (imp.isTypeOnly)
15371
15456
  continue;
@@ -15379,10 +15464,12 @@ function collectExternalImports(ir, generatedCode, localImportPrefixes) {
15379
15464
  }
15380
15465
  const usedSpecs = [];
15381
15466
  for (const spec of imp.specifiers) {
15467
+ if (spec.isTypeOnly)
15468
+ continue;
15382
15469
  const localName = spec.alias || spec.name;
15383
15470
  if (componentNames.has(localName))
15384
15471
  continue;
15385
- if (new RegExp(`\\b${localName}\\b`).test(generatedCode)) {
15472
+ if (isUsedAsValue(localName)) {
15386
15473
  usedSpecs.push(spec.alias ? `${spec.name} as ${spec.alias}` : spec.name);
15387
15474
  }
15388
15475
  }
@@ -15421,7 +15508,7 @@ function collectComponentNames(node) {
15421
15508
  }
15422
15509
 
15423
15510
  // src/relocate.ts
15424
- import ts13 from "typescript";
15511
+ import ts14 from "typescript";
15425
15512
 
15426
15513
  // src/lowering-registry.ts
15427
15514
  var plugins = [];
@@ -15467,19 +15554,19 @@ function classify(name, env) {
15467
15554
  function collectFreeRefs(node) {
15468
15555
  const refs = new Map;
15469
15556
  function visit3(n, parent) {
15470
- if (ts13.isIdentifier(n)) {
15471
- if (parent && ts13.isPropertyAccessExpression(parent) && parent.name === n)
15557
+ if (ts14.isIdentifier(n)) {
15558
+ if (parent && ts14.isPropertyAccessExpression(parent) && parent.name === n)
15472
15559
  return;
15473
- if (parent && ts13.isPropertyAssignment(parent) && parent.name === n)
15560
+ if (parent && ts14.isPropertyAssignment(parent) && parent.name === n)
15474
15561
  return;
15475
- if (parent && ts13.isShorthandPropertyAssignment(parent) && parent.name === n)
15562
+ if (parent && ts14.isShorthandPropertyAssignment(parent) && parent.name === n)
15476
15563
  return;
15477
15564
  const list = refs.get(n.text) ?? [];
15478
15565
  list.push(n);
15479
15566
  refs.set(n.text, list);
15480
15567
  return;
15481
15568
  }
15482
- ts13.forEachChild(n, (child) => visit3(child, n));
15569
+ ts14.forEachChild(n, (child) => visit3(child, n));
15483
15570
  }
15484
15571
  visit3(node);
15485
15572
  return refs;
@@ -15582,11 +15669,11 @@ function isInlinableInTemplate(value, env) {
15582
15669
  return { ok: true, rewrittenValue: r.text, decisions: r.decisions };
15583
15670
  }
15584
15671
  function getCalleeIdentifierPath(callee) {
15585
- if (ts13.isParenthesizedExpression(callee))
15672
+ if (ts14.isParenthesizedExpression(callee))
15586
15673
  return getCalleeIdentifierPath(callee.expression);
15587
- if (ts13.isIdentifier(callee))
15674
+ if (ts14.isIdentifier(callee))
15588
15675
  return callee.text;
15589
- if (ts13.isPropertyAccessExpression(callee)) {
15676
+ if (ts14.isPropertyAccessExpression(callee)) {
15590
15677
  const left = getCalleeIdentifierPath(callee.expression);
15591
15678
  if (left === null)
15592
15679
  return null;
@@ -15595,11 +15682,11 @@ function getCalleeIdentifierPath(callee) {
15595
15682
  return null;
15596
15683
  }
15597
15684
  function getCalleeLeftmostIdentifier(callee) {
15598
- if (ts13.isParenthesizedExpression(callee))
15685
+ if (ts14.isParenthesizedExpression(callee))
15599
15686
  return getCalleeLeftmostIdentifier(callee.expression);
15600
- if (ts13.isIdentifier(callee))
15687
+ if (ts14.isIdentifier(callee))
15601
15688
  return callee.text;
15602
- if (ts13.isPropertyAccessExpression(callee)) {
15689
+ if (ts14.isPropertyAccessExpression(callee)) {
15603
15690
  return getCalleeLeftmostIdentifier(callee.expression);
15604
15691
  }
15605
15692
  return null;
@@ -15647,12 +15734,12 @@ function isCallAcceptedByAdapter(call, env) {
15647
15734
  }
15648
15735
  function parseExpressionNode(text) {
15649
15736
  try {
15650
- const sf = ts13.createSourceFile("__inline_check__.ts", `(${text});`, ts13.ScriptTarget.Latest, false, ts13.ScriptKind.TS);
15737
+ const sf = ts14.createSourceFile("__inline_check__.ts", `(${text});`, ts14.ScriptTarget.Latest, false, ts14.ScriptKind.TS);
15651
15738
  const stmt = sf.statements[0];
15652
- if (!stmt || !ts13.isExpressionStatement(stmt))
15739
+ if (!stmt || !ts14.isExpressionStatement(stmt))
15653
15740
  return null;
15654
15741
  const inner = stmt.expression;
15655
- return ts13.isParenthesizedExpression(inner) ? inner.expression : inner;
15742
+ return ts14.isParenthesizedExpression(inner) ? inner.expression : inner;
15656
15743
  } catch {
15657
15744
  return null;
15658
15745
  }
@@ -15669,8 +15756,8 @@ function hasCallWithBridgedArg(node, decisions, env) {
15669
15756
  function visit3(n) {
15670
15757
  if (found)
15671
15758
  return;
15672
- if (ts13.isCallExpression(n) || ts13.isNewExpression(n)) {
15673
- const accepted = ts13.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
15759
+ if (ts14.isCallExpression(n) || ts14.isNewExpression(n)) {
15760
+ const accepted = ts14.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
15674
15761
  if (!accepted) {
15675
15762
  const args = n.arguments;
15676
15763
  if (args) {
@@ -15683,7 +15770,7 @@ function hasCallWithBridgedArg(node, decisions, env) {
15683
15770
  }
15684
15771
  }
15685
15772
  }
15686
- ts13.forEachChild(n, visit3);
15773
+ ts14.forEachChild(n, visit3);
15687
15774
  }
15688
15775
  visit3(node);
15689
15776
  return found;
@@ -15693,13 +15780,13 @@ function hasZeroArgCall(node, env) {
15693
15780
  function visit3(n) {
15694
15781
  if (found)
15695
15782
  return;
15696
- if (ts13.isCallExpression(n) && n.arguments.length === 0) {
15783
+ if (ts14.isCallExpression(n) && n.arguments.length === 0) {
15697
15784
  if (!isCallAcceptedByAdapter(n, env)) {
15698
15785
  found = true;
15699
15786
  return;
15700
15787
  }
15701
15788
  }
15702
- ts13.forEachChild(n, visit3);
15789
+ ts14.forEachChild(n, visit3);
15703
15790
  }
15704
15791
  visit3(node);
15705
15792
  return found;
@@ -15709,25 +15796,25 @@ function containsAnyIdentifier(node, names) {
15709
15796
  function visit3(n) {
15710
15797
  if (found)
15711
15798
  return;
15712
- if (ts13.isPropertyAccessExpression(n)) {
15799
+ if (ts14.isPropertyAccessExpression(n)) {
15713
15800
  visit3(n.expression);
15714
15801
  return;
15715
15802
  }
15716
- if (ts13.isPropertyAssignment(n)) {
15803
+ if (ts14.isPropertyAssignment(n)) {
15717
15804
  visit3(n.initializer);
15718
15805
  return;
15719
15806
  }
15720
- if (ts13.isShorthandPropertyAssignment(n)) {
15721
- if (ts13.isIdentifier(n.name) && names.has(n.name.text)) {
15807
+ if (ts14.isShorthandPropertyAssignment(n)) {
15808
+ if (ts14.isIdentifier(n.name) && names.has(n.name.text)) {
15722
15809
  found = true;
15723
15810
  }
15724
15811
  return;
15725
15812
  }
15726
- if (ts13.isIdentifier(n) && names.has(n.text)) {
15813
+ if (ts14.isIdentifier(n) && names.has(n.text)) {
15727
15814
  found = true;
15728
15815
  return;
15729
15816
  }
15730
- ts13.forEachChild(n, visit3);
15817
+ ts14.forEachChild(n, visit3);
15731
15818
  }
15732
15819
  visit3(node);
15733
15820
  return found;
@@ -18389,8 +18476,352 @@ function buildKeyedOrIndexLookup(args) {
18389
18476
  };
18390
18477
  }
18391
18478
 
18479
+ // src/ir-to-client-js/control-flow/plan/lazy-row-eligibility.ts
18480
+ var PURE_SOURCE_GLOBALS = new Set([
18481
+ "Object",
18482
+ "Array",
18483
+ "JSON",
18484
+ "Number",
18485
+ "String",
18486
+ "Boolean"
18487
+ ]);
18488
+ var INERT_BINDING_GLOBALS = new Set([
18489
+ "Object",
18490
+ "Array",
18491
+ "JSON",
18492
+ "Number",
18493
+ "String",
18494
+ "Boolean",
18495
+ "Math",
18496
+ "Date",
18497
+ "Intl",
18498
+ "Symbol",
18499
+ "Map",
18500
+ "Set",
18501
+ "WeakMap",
18502
+ "WeakSet",
18503
+ "Promise",
18504
+ "RegExp",
18505
+ "Error",
18506
+ "BigInt",
18507
+ "console",
18508
+ "undefined",
18509
+ "NaN",
18510
+ "Infinity",
18511
+ "globalThis",
18512
+ "parseInt",
18513
+ "parseFloat",
18514
+ "isNaN",
18515
+ "isFinite",
18516
+ "encodeURIComponent",
18517
+ "decodeURIComponent",
18518
+ "encodeURI",
18519
+ "decodeURI"
18520
+ ]);
18521
+ var UNKNOWN_IDENTIFIERS = "<unknown>";
18522
+ var NO = (reason) => ({ eligible: false, reason });
18523
+ function lazyRowEligibility(args) {
18524
+ const { shape, bindings, arraySourceIdentifiers, scope } = args;
18525
+ if (scope.profile)
18526
+ return NO("profile mode keeps the granular eager emission");
18527
+ if (shape.callSite !== "plain" && shape.callSite !== "branch-plain") {
18528
+ return NO(`call site '${shape.callSite}' is not a plain loop row`);
18529
+ }
18530
+ if (shape.flatMapLeafItem)
18531
+ return NO("flatMap descriptor loop (build-or-patch renderItem)");
18532
+ if (shape.anchored)
18533
+ return NO("anchored whole-item-conditional loop");
18534
+ if (shape.bodyIsMultiRoot)
18535
+ return NO("multi-root (Fragment) row");
18536
+ if (!shape.hasExplicitKey)
18537
+ return NO("index-keyed loop (no explicit key)");
18538
+ if (shape.conditionalCount > 0)
18539
+ return NO("row contains a reactive conditional");
18540
+ if (shape.childRefCount > 0)
18541
+ return NO("row has imperative child refs");
18542
+ if (shape.hasChildComponent)
18543
+ return NO("row body is a child component");
18544
+ if (shape.nestedComponentCount > 0)
18545
+ return NO("row contains nested child components");
18546
+ if (shape.innerLoopCount > 0)
18547
+ return NO("row contains an inner loop");
18548
+ if (shape.hasMapPreamble)
18549
+ return NO("row has a map-callback preamble (may declare row-local reactivity)");
18550
+ if (shape.preambleRegionCount > 0)
18551
+ return NO("row has preamble-patched regions");
18552
+ if (shape.hasParamUnwrap)
18553
+ return NO("destructured loop param without param bindings");
18554
+ for (const b of bindings) {
18555
+ if (b.referencesIndex) {
18556
+ return NO(`binding on slot ${b.slotId} references the loop index parameter`);
18557
+ }
18558
+ if (b.opaqueOuterNames.includes(UNKNOWN_IDENTIFIERS)) {
18559
+ return NO(`binding on slot ${b.slotId} has no analyzable identifier set`);
18560
+ }
18561
+ }
18562
+ if (!arraySourceIdentifiers)
18563
+ return NO("loop source free identifiers unavailable");
18564
+ const sourceGate = checkSourceConsistency(arraySourceIdentifiers, scope);
18565
+ if (sourceGate)
18566
+ return NO(`loop source is not provably hydration-consistent: ${sourceGate}`);
18567
+ return { eligible: true };
18568
+ }
18569
+ function checkSourceConsistency(names, scope) {
18570
+ const seen = new Set;
18571
+ const resolve2 = (name) => {
18572
+ if (seen.has(name))
18573
+ return null;
18574
+ seen.add(name);
18575
+ if (scope.props.has(name))
18576
+ return null;
18577
+ if (PURE_SOURCE_GLOBALS.has(name))
18578
+ return null;
18579
+ const constFree = scope.constants.get(name);
18580
+ if (constFree !== undefined) {
18581
+ if (constFree === null)
18582
+ return `constant '${name}' has no analyzable value`;
18583
+ for (const inner of constFree) {
18584
+ const failure = resolve2(inner);
18585
+ if (failure)
18586
+ return failure;
18587
+ }
18588
+ return null;
18589
+ }
18590
+ const signal = scope.signals.get(name);
18591
+ if (signal !== undefined) {
18592
+ if (signal.initializerFreeIdentifiers === null) {
18593
+ return `signal '${name}' has no structured initializer to prove props/literal derivation`;
18594
+ }
18595
+ for (const inner of signal.initializerFreeIdentifiers) {
18596
+ const failure = resolve2(inner);
18597
+ if (failure)
18598
+ return failure;
18599
+ }
18600
+ return null;
18601
+ }
18602
+ if (scope.memos.has(name))
18603
+ return `memo '${name}' initializer is not analyzed by the v1 gate`;
18604
+ if (scope.inert.has(name))
18605
+ return `'${name}' is an import or local function`;
18606
+ return `'${name}' does not resolve to a prop, literal-derived const, or props/literal-derived signal`;
18607
+ };
18608
+ for (const name of names) {
18609
+ const failure = resolve2(name);
18610
+ if (failure)
18611
+ return failure;
18612
+ }
18613
+ return null;
18614
+ }
18615
+ function classifyLazyBinding(args) {
18616
+ const { kind, slotId, free, rowLocalNames, indexParam, scope } = args;
18617
+ if (free === null) {
18618
+ return {
18619
+ kind,
18620
+ slotId,
18621
+ readsItem: true,
18622
+ readsOuter: true,
18623
+ reactiveOuterNames: [],
18624
+ opaqueOuterNames: [UNKNOWN_IDENTIFIERS],
18625
+ referencesIndex: false
18626
+ };
18627
+ }
18628
+ let readsItem = false;
18629
+ let referencesIndex = false;
18630
+ const reactiveOuterNames = [];
18631
+ const opaqueOuterNames = [];
18632
+ for (const name of free) {
18633
+ if (rowLocalNames.has(name)) {
18634
+ readsItem = true;
18635
+ continue;
18636
+ }
18637
+ if (name === indexParam) {
18638
+ referencesIndex = true;
18639
+ continue;
18640
+ }
18641
+ if (INERT_BINDING_GLOBALS.has(name))
18642
+ continue;
18643
+ if (scope.signals.has(name) || scope.memos.has(name)) {
18644
+ if (!reactiveOuterNames.includes(name))
18645
+ reactiveOuterNames.push(name);
18646
+ continue;
18647
+ }
18648
+ const constFree = scope.constants.get(name);
18649
+ if (constFree !== undefined && constFree !== null && constFree.size === 0)
18650
+ continue;
18651
+ opaqueOuterNames.push(name);
18652
+ }
18653
+ return {
18654
+ kind,
18655
+ slotId,
18656
+ readsItem,
18657
+ readsOuter: reactiveOuterNames.length > 0 || opaqueOuterNames.length > 0,
18658
+ reactiveOuterNames,
18659
+ opaqueOuterNames,
18660
+ referencesIndex
18661
+ };
18662
+ }
18663
+
18664
+ // src/ir-to-client-js/control-flow/plan/build-lazy-row.ts
18665
+ function buildLazyRowPlan(args) {
18666
+ return decideLazyRow(args).plan;
18667
+ }
18668
+ function decideLazyRow(args) {
18669
+ const { loop, scope } = args;
18670
+ if (!scope) {
18671
+ return { plan: null, decision: { eligible: false, reason: "no component scope info supplied" } };
18672
+ }
18673
+ const wrap = (expr) => wrapLoopParamAsAccessor(expr, loop.param, loop.paramBindings);
18674
+ const rowLocalNames = new Set([loop.param]);
18675
+ for (const b of loop.paramBindings ?? [])
18676
+ rowLocalNames.add(b.name);
18677
+ const classified = [];
18678
+ const attrClass = new Map;
18679
+ loop.bindings.reactiveAttrs.forEach((attr, i) => {
18680
+ const c = classifyLazyBinding({
18681
+ kind: "attr",
18682
+ slotId: attr.childSlotId,
18683
+ free: attrFreeIdentifiers2(attr.expression),
18684
+ rowLocalNames,
18685
+ indexParam: args.indexParam,
18686
+ scope
18687
+ });
18688
+ attrClass.set(i, c);
18689
+ classified.push(c);
18690
+ });
18691
+ const textClass = new Map;
18692
+ loop.bindings.reactiveTexts.forEach((text, i) => {
18693
+ const c = classifyLazyBinding({
18694
+ kind: "text",
18695
+ slotId: text.slotId,
18696
+ free: text.freeIdentifiers ?? null,
18697
+ rowLocalNames,
18698
+ indexParam: args.indexParam,
18699
+ scope
18700
+ });
18701
+ textClass.set(i, c);
18702
+ classified.push(c);
18703
+ });
18704
+ const shape = {
18705
+ callSite: args.callSite,
18706
+ flatMapLeafItem: args.flatMapLeafItem,
18707
+ anchored: args.anchored,
18708
+ bodyIsMultiRoot: loop.bodyIsMultiRoot ?? false,
18709
+ hasExplicitKey: loop.key != null,
18710
+ conditionalCount: loop.bindings.conditionals?.length ?? 0,
18711
+ childRefCount: loop.bindings.refs?.length ?? 0,
18712
+ nestedComponentCount: loop.nestedComponents?.length ?? 0,
18713
+ innerLoopCount: loop.innerLoops?.length ?? 0,
18714
+ hasChildComponent: "childComponent" in loop && loop.childComponent != null,
18715
+ hasMapPreamble: args.mapPreambleWrapped.length > 0,
18716
+ preambleRegionCount: args.preambleRegionCount,
18717
+ hasParamUnwrap: args.paramUnwrap.length > 0
18718
+ };
18719
+ const decision = lazyRowEligibility({
18720
+ shape,
18721
+ bindings: classified,
18722
+ arraySourceIdentifiers: loopSourceIdentifiers(loop, args.arrayExpr),
18723
+ scope
18724
+ });
18725
+ if (!decision.eligible)
18726
+ return { plan: null, decision };
18727
+ const attrSlotIds = [];
18728
+ for (const attr of loop.bindings.reactiveAttrs) {
18729
+ if (!attrSlotIds.includes(attr.childSlotId))
18730
+ attrSlotIds.push(attr.childSlotId);
18731
+ }
18732
+ let ordinal = 0;
18733
+ const attrs = loop.bindings.reactiveAttrs.map((attr, i) => {
18734
+ const c = attrClass.get(i);
18735
+ return {
18736
+ slotId: attr.childSlotId,
18737
+ attrName: attr.attrName,
18738
+ wrappedExpression: wrap(attr.expression),
18739
+ meta: pickAttrMeta(attr),
18740
+ refIndex: attrSlotIds.indexOf(attr.childSlotId),
18741
+ ordinal: ordinal++,
18742
+ readsItem: c.readsItem,
18743
+ readsOuter: c.readsOuter
18744
+ };
18745
+ });
18746
+ const texts = loop.bindings.reactiveTexts.map((text, i) => {
18747
+ const c = textClass.get(i);
18748
+ return {
18749
+ slotId: text.slotId,
18750
+ wrappedExpression: wrap(text.expression),
18751
+ ordinal: ordinal++,
18752
+ readsItem: c.readsItem || !c.readsOuter,
18753
+ readsOuter: c.readsOuter
18754
+ };
18755
+ });
18756
+ const outerPrimeGetters = [];
18757
+ for (const c of classified) {
18758
+ for (const name of c.reactiveOuterNames) {
18759
+ if (!outerPrimeGetters.includes(name))
18760
+ outerPrimeGetters.push(name);
18761
+ }
18762
+ }
18763
+ return {
18764
+ plan: {
18765
+ attrSlotIds,
18766
+ attrs,
18767
+ texts,
18768
+ writerIndex: texts.length > 0 ? attrSlotIds.length : -1,
18769
+ textNeedsRead: texts.some((t) => t.readsOuter),
18770
+ lastCount: ordinal,
18771
+ outerPrimeGetters,
18772
+ hasOuter: attrs.some((a) => a.readsOuter) || texts.some((t) => t.readsOuter)
18773
+ },
18774
+ decision
18775
+ };
18776
+ }
18777
+ function buildLazyRowScopeInfo(ctx) {
18778
+ const signals = new Map;
18779
+ for (const s of ctx.signals) {
18780
+ signals.set(s.getter, {
18781
+ initializerFreeIdentifiers: s.parsed ? freeIdentifiers(s.parsed) : null
18782
+ });
18783
+ }
18784
+ const memos = new Set(ctx.memos.map((m) => m.name));
18785
+ const props = new Set([PROPS_PARAM]);
18786
+ if (ctx.propsObjectName)
18787
+ props.add(ctx.propsObjectName);
18788
+ for (const p of ctx.propsParams)
18789
+ props.add(p.name);
18790
+ const constants = new Map;
18791
+ for (const c of ctx.localConstants) {
18792
+ constants.set(c.name, c.freeIdentifiers ?? null);
18793
+ }
18794
+ const inert = new Set;
18795
+ for (const f of ctx.localFunctions)
18796
+ inert.add(f.name);
18797
+ for (const imp of ctx.imports) {
18798
+ if (imp.isTypeOnly)
18799
+ continue;
18800
+ for (const spec of imp.specifiers)
18801
+ inert.add(spec.alias || spec.name);
18802
+ }
18803
+ return { signals, memos, props, constants, inert, profile: ctx.profile };
18804
+ }
18805
+ function attrFreeIdentifiers2(expression) {
18806
+ if (!expression || expression.trim().length === 0)
18807
+ return new Set;
18808
+ try {
18809
+ return freeIdentifiers(parseExpression(expression));
18810
+ } catch {
18811
+ return null;
18812
+ }
18813
+ }
18814
+ function loopSourceIdentifiers(loop, arrayExpr) {
18815
+ if (!loop.arrayFreeIdentifiers)
18816
+ return null;
18817
+ const names = new Set(loop.arrayFreeIdentifiers);
18818
+ for (const name of extractFreeIdentifiersFromText(arrayExpr))
18819
+ names.add(name);
18820
+ return names;
18821
+ }
18822
+
18392
18823
  // src/ir-to-client-js/control-flow/plan/build-branch-loop.ts
18393
- function buildBranchLoopPlan(loop, profileComponentName) {
18824
+ function buildBranchLoopPlan(loop, profileComponentName, lazyScope) {
18394
18825
  const containerSlotId = loop.containerSlotId;
18395
18826
  const cv = varSlotId(containerSlotId);
18396
18827
  const containerVar = `__loop_${cv}`;
@@ -18406,6 +18837,13 @@ function buildBranchLoopPlan(loop, profileComponentName) {
18406
18837
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(loop.param, loop.paramBindings);
18407
18838
  const hasReactiveEffects = loop.bindings.reactiveAttrs.length > 0 || loop.bindings.reactiveTexts.length > 0 || loop.bindings.conditionals.length > 0;
18408
18839
  const fm = loop.flatMapClient;
18840
+ const arrayExpr = fm ? `(${buildChainedArrayExpr(loop)}).flatMap(${fm.params} => ${fm.body})` : buildChainedArrayExpr(loop);
18841
+ const indexParam = loop.index || "__idx";
18842
+ const mapPreambleWrapped = loop.preamble ? renderPreamble(loop.preamble, {
18843
+ transformJs: (t) => wrapLoopParamAsAccessor(t, loop.param, loop.paramBindings),
18844
+ renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: loop.param, bindings: loop.paramBindings }], undefined, true)
18845
+ }) : "";
18846
+ const preambleRegions = buildPreambleRegionPlans(loop.preambleRegions, loop.param, loop.paramBindings);
18409
18847
  const plan = {
18410
18848
  kind: "plain",
18411
18849
  rowConstruction: "string-template",
@@ -18413,15 +18851,24 @@ function buildBranchLoopPlan(loop, profileComponentName) {
18413
18851
  containerVar,
18414
18852
  markerId: loop.markerId,
18415
18853
  flatMapLeafItem: fm ? true : undefined,
18416
- arrayExpr: fm ? `(${buildChainedArrayExpr(loop)}).flatMap(${fm.params} => ${fm.body})` : buildChainedArrayExpr(loop),
18854
+ arrayExpr,
18417
18855
  keyFn: fm ? fm.keyed ? "(__bfD, __bfI) => String(__bfD.k ?? __bfI)" : "null" : loopKeyFn(loop),
18418
18856
  paramHead,
18419
18857
  paramUnwrap,
18420
- indexParam: loop.index || "__idx",
18421
- mapPreambleWrapped: loop.preamble ? renderPreamble(loop.preamble, {
18422
- transformJs: (t) => wrapLoopParamAsAccessor(t, loop.param, loop.paramBindings),
18423
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: loop.param, bindings: loop.paramBindings }], undefined, true)
18424
- }) : "",
18858
+ indexParam,
18859
+ mapPreambleWrapped,
18860
+ lazyRow: buildLazyRowPlan({
18861
+ loop,
18862
+ arrayExpr,
18863
+ indexParam,
18864
+ paramUnwrap,
18865
+ mapPreambleWrapped,
18866
+ preambleRegionCount: preambleRegions.length,
18867
+ callSite: "branch-plain",
18868
+ flatMapLeafItem: Boolean(fm),
18869
+ anchored: false,
18870
+ scope: lazyScope
18871
+ }) ?? undefined,
18425
18872
  template: loop.template,
18426
18873
  reactiveEffects: hasReactiveEffects ? buildReactiveEffectsPlan({
18427
18874
  attrs: loop.bindings.reactiveAttrs,
@@ -18433,7 +18880,7 @@ function buildBranchLoopPlan(loop, profileComponentName) {
18433
18880
  }) : null,
18434
18881
  eventDelegation: buildBranchLoopDelegationPlan(loop, cv, profileComponentName),
18435
18882
  childRefs: buildChildRefBindings(loop.bindings.refs, loop.param, loop.paramBindings),
18436
- preambleRegions: buildPreambleRegionPlans(loop.preambleRegions, loop.param, loop.paramBindings),
18883
+ preambleRegions,
18437
18884
  bodyIsMultiRoot: loop.bodyIsMultiRoot ?? false,
18438
18885
  profileLoopId: profileComponentName ? `${profileComponentName}#binding:${containerSlotId}` : undefined
18439
18886
  };
@@ -18484,13 +18931,13 @@ function buildArmBody(branch, options) {
18484
18931
  slotId: t.slotId,
18485
18932
  expression: t.expression
18486
18933
  })),
18487
- loops: branch.loops.map((l) => buildBranchLoopPlan(l, pc)),
18488
- conditionals: branch.conditionals.map((c) => buildInsertPlan(c, { scope: { kind: "branchScope" }, eventNameMode: options.eventNameMode, profileComponentName: pc }))
18934
+ loops: branch.loops.map((l) => buildBranchLoopPlan(l, pc, options.lazyScope)),
18935
+ conditionals: branch.conditionals.map((c) => buildInsertPlan(c, { scope: { kind: "branchScope" }, eventNameMode: options.eventNameMode, profileComponentName: pc, lazyScope: options.lazyScope }))
18489
18936
  };
18490
18937
  }
18491
18938
 
18492
18939
  // src/ir-to-client-js/emit-reactive.ts
18493
- import ts14 from "typescript";
18940
+ import ts15 from "typescript";
18494
18941
 
18495
18942
  // src/ir-to-client-js/control-flow/stringify/claim-plan.ts
18496
18943
  function slotSpecLiteral(slot) {
@@ -18593,20 +19040,20 @@ function lowerToLocaleCallsInReactiveExpr(expr, matcher) {
18593
19040
  return expr;
18594
19041
  let sourceFile;
18595
19042
  try {
18596
- sourceFile = ts14.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts14.ScriptTarget.Latest, true, ts14.ScriptKind.TS);
19043
+ sourceFile = ts15.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts15.ScriptTarget.Latest, true, ts15.ScriptKind.TS);
18597
19044
  } catch {
18598
19045
  return expr;
18599
19046
  }
18600
19047
  const stmt = sourceFile.statements[0];
18601
- if (!stmt || !ts14.isExpressionStatement(stmt))
19048
+ if (!stmt || !ts15.isExpressionStatement(stmt))
18602
19049
  return expr;
18603
- const root = ts14.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19050
+ const root = ts15.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
18604
19051
  const candidates = [];
18605
19052
  const visit3 = (n) => {
18606
- if (ts14.isCallExpression(n) && n.arguments.length === 2 && ts14.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
19053
+ if (ts15.isCallExpression(n) && n.arguments.length === 2 && ts15.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
18607
19054
  candidates.push(n);
18608
19055
  }
18609
- ts14.forEachChild(n, visit3);
19056
+ ts15.forEachChild(n, visit3);
18610
19057
  };
18611
19058
  visit3(root);
18612
19059
  if (candidates.length === 0)
@@ -18642,20 +19089,20 @@ function lowerDateCallsInReactiveExpr(expr, matcher) {
18642
19089
  return expr;
18643
19090
  let sourceFile;
18644
19091
  try {
18645
- sourceFile = ts14.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts14.ScriptTarget.Latest, true, ts14.ScriptKind.TS);
19092
+ sourceFile = ts15.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts15.ScriptTarget.Latest, true, ts15.ScriptKind.TS);
18646
19093
  } catch {
18647
19094
  return expr;
18648
19095
  }
18649
19096
  const stmt = sourceFile.statements[0];
18650
- if (!stmt || !ts14.isExpressionStatement(stmt))
19097
+ if (!stmt || !ts15.isExpressionStatement(stmt))
18651
19098
  return expr;
18652
- const root = ts14.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19099
+ const root = ts15.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
18653
19100
  const candidates = [];
18654
19101
  const visit3 = (n) => {
18655
- if (ts14.isCallExpression(n) && n.arguments.length === 0 && ts14.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
19102
+ if (ts15.isCallExpression(n) && n.arguments.length === 0 && ts15.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
18656
19103
  candidates.push(n);
18657
19104
  }
18658
- ts14.forEachChild(n, visit3);
19105
+ ts15.forEachChild(n, visit3);
18659
19106
  };
18660
19107
  visit3(root);
18661
19108
  if (candidates.length === 0)
@@ -18862,7 +19309,7 @@ function stringifyBranchEventBindings(lines, plan, indent) {
18862
19309
  }
18863
19310
  function stringifyBranchChildComponentInits(lines, plan, indent) {
18864
19311
  for (const init of plan) {
18865
- lines.push(`${indent}{ let __c = qsa(__branchScope, ${init.selector}); if (!__c) { const __ph = __branchScope.querySelector('[${DATA_BF_PH}="${init.placeholderId}"]'); if (__ph) { __c = createComponent('${nameForRegistryRef(init.name)}', ${init.propsExpr}); __ph.replaceWith(__c) } } if (__c) initChild('${nameForRegistryRef(init.name)}', __c, ${init.propsExpr}) }`);
19312
+ lines.push(`${indent}{ let __c = qsa(__branchScope, ${init.selector}); if (!__c) { const __ph = __branchScope.querySelector('[${DATA_BF_PH}="${init.placeholderId}"]'); if (__ph) { __c = createComponent('${nameForRegistryRef(init.name)}', ${init.propsExpr}, undefined, undefined, __ph) } } if (__c) initChild('${nameForRegistryRef(init.name)}', __c, ${init.propsExpr}) }`);
18866
19313
  }
18867
19314
  }
18868
19315
  function stringifyBranchInnerLoops(lines, plan, indent, pc) {
@@ -19171,6 +19618,184 @@ function emitNestedInit(lines, indent, parentVar, nc) {
19171
19618
  }
19172
19619
  }
19173
19620
 
19621
+ // src/ir-to-client-js/control-flow/stringify/lazy-row.ts
19622
+ function stringifyLazyRowLoop(lines, o) {
19623
+ const { indent, lazyRow, paramHead } = o;
19624
+ const mid = o.markerId.replace(/[^A-Za-z0-9_$]/g, "_");
19625
+ const tplVar = `__tpl_${mid}`;
19626
+ const claimVar = `__lzc_${mid}`;
19627
+ const hasRefs = lazyRow.attrSlotIds.length > 0 || lazyRow.texts.length > 0;
19628
+ const hasBindings = lazyRow.attrs.length > 0 || lazyRow.texts.length > 0;
19629
+ const rwDoor = lazyRow.textNeedsRead;
19630
+ const paths = o.skeletonPaths;
19631
+ const useHoisted = Boolean(o.skeletonTemplate);
19632
+ if (useHoisted)
19633
+ emitHoistedTemplateDecl(lines, indent, tplVar, o.skeletonTemplate);
19634
+ const textPathVar = useHoisted && paths && lazyRow.texts.length > 0 ? `__lzp_${mid}` : null;
19635
+ if (textPathVar) {
19636
+ const arrays = lazyRow.texts.map((t) => `[${(paths.textMarkerPaths.get(t.slotId) ?? []).join(", ")}]`);
19637
+ lines.push(`${indent}const ${textPathVar} = [${arrays.join(", ")}]`);
19638
+ }
19639
+ let adoptedPlanVar = null;
19640
+ let freshPlanVar = null;
19641
+ if (lazyRow.texts.length > 0) {
19642
+ adoptedPlanVar = `__lzs_${mid}`;
19643
+ const adoptedSlots = lazyRow.texts.map((t) => ({ id: t.slotId, kind: "text", path: [] }));
19644
+ lines.push(`${indent}const ${adoptedPlanVar} = ${claimPlanLiteral(adoptedSlots)}`);
19645
+ if (textPathVar) {
19646
+ freshPlanVar = `__lzsc_${mid}`;
19647
+ const freshSlots = lazyRow.texts.map((t, i) => ({
19648
+ id: t.slotId,
19649
+ kind: "text",
19650
+ path: [],
19651
+ pathExpr: `${textPathVar}[${i}]`
19652
+ }));
19653
+ lines.push(`${indent}const ${freshPlanVar} = ${claimPlanLiteral(freshSlots)}`);
19654
+ } else {
19655
+ freshPlanVar = adoptedPlanVar;
19656
+ }
19657
+ }
19658
+ if (hasRefs) {
19659
+ const parts = refParts(lazyRow, "__el", null, adoptedPlanVar, true);
19660
+ lines.push(`${indent}const ${claimVar} = (__e) => {`);
19661
+ if (parts.some((p) => p.includes("__el")))
19662
+ lines.push(`${indent} const __el = __e.primaryEl`);
19663
+ lines.push(`${indent} return [${parts.join(", ")}]`);
19664
+ lines.push(`${indent}}`);
19665
+ }
19666
+ const call = `mapArrayLazy(() => ${o.arrayExpr}, ${o.containerVar}, ${o.keyFn}, {`;
19667
+ lines.push(`${indent}${o.guardContainer ? `if (${o.containerVar}) ` : ""}${call}`);
19668
+ const b1 = `${indent} `;
19669
+ const b2 = `${indent} `;
19670
+ lines.push(`${b1}createRow: (__e, ${o.indexParam}) => {`);
19671
+ lines.push(`${b2}const ${paramHead} = () => __e.item`);
19672
+ const cloneExpr = useHoisted ? hoistedCloneExpr(tplVar, o.skeletonTemplate) : `(() => { ${emitTemplateCloneInline(o.template)} })()`;
19673
+ lines.push(`${b2}const __el = ${cloneExpr}`);
19674
+ if (hasRefs) {
19675
+ lines.push(`${b2}const __r = __e.refs = [${refParts(lazyRow, "__el", useHoisted ? paths ?? null : null, freshPlanVar).join(", ")}]`);
19676
+ }
19677
+ if (hasBindings) {
19678
+ lines.push(`${b2}const __l = __e.last = []`);
19679
+ for (const a of lazyRow.attrs)
19680
+ emitAttrBinding(lines, b2, a, "create");
19681
+ const createDoor = `__r[${lazyRow.writerIndex}]`;
19682
+ for (const t of lazyRow.texts)
19683
+ emitTextBinding(lines, b2, t, createDoor, "create", rwDoor);
19684
+ }
19685
+ lines.push(`${b2}return __el`);
19686
+ lines.push(`${b1}},`);
19687
+ const itemAttrs = lazyRow.attrs.filter((a) => a.readsItem);
19688
+ const itemTexts = lazyRow.texts.filter((t) => t.readsItem);
19689
+ if (itemAttrs.length === 0 && itemTexts.length === 0) {
19690
+ lines.push(`${b1}applyItem: () => {},`);
19691
+ } else {
19692
+ lines.push(`${b1}applyItem: (__e) => {`);
19693
+ lines.push(`${b2}const ${paramHead} = () => __e.item`);
19694
+ lines.push(`${b2}const __r = __e.refs ?? (__e.refs = ${claimVar}(__e))`);
19695
+ lines.push(`${b2}const __l = __e.last ?? (__e.last = [])`);
19696
+ for (const a of itemAttrs)
19697
+ emitAttrBinding(lines, b2, a, "item");
19698
+ if (itemTexts.length > 0) {
19699
+ lines.push(`${b2}const __d = ${doorAccess(lazyRow, lazyRow.writerIndex, adoptedPlanVar)}`);
19700
+ for (const t of itemTexts)
19701
+ emitTextBinding(lines, b2, t, "__d", "item", rwDoor);
19702
+ }
19703
+ lines.push(`${b1}},`);
19704
+ }
19705
+ const outerAttrs = lazyRow.attrs.filter((a) => a.readsOuter);
19706
+ const outerTexts = lazyRow.texts.filter((t) => t.readsOuter);
19707
+ if (outerAttrs.length > 0 || outerTexts.length > 0) {
19708
+ const b3 = `${indent} `;
19709
+ lines.push(`${b1}applyOuter: (__es, __seed) => {`);
19710
+ for (const g of lazyRow.outerPrimeGetters)
19711
+ lines.push(`${b2}${g}()`);
19712
+ lines.push(`${b2}for (const __e of __es) {`);
19713
+ lines.push(`${b3}const ${paramHead} = () => __e.item`);
19714
+ lines.push(`${b3}const __r = __e.refs ?? (__e.refs = ${claimVar}(__e))`);
19715
+ lines.push(`${b3}const __l = __e.last ?? (__e.last = [])`);
19716
+ for (const a of outerAttrs)
19717
+ emitAttrBinding(lines, b3, a, "outer");
19718
+ if (outerTexts.length > 0) {
19719
+ lines.push(`${b3}const __d = ${doorAccess(lazyRow, lazyRow.writerIndex, adoptedPlanVar)}`);
19720
+ for (const t of outerTexts)
19721
+ emitTextBinding(lines, b3, t, "__d", "outer", rwDoor);
19722
+ }
19723
+ lines.push(`${b2}}`);
19724
+ lines.push(`${b1}},`);
19725
+ }
19726
+ lines.push(`${indent}}, '${o.markerId}')`);
19727
+ }
19728
+ function refParts(lazyRow, elVar, skeletonPaths, planVar, deferDoor = false) {
19729
+ const parts = [];
19730
+ for (const slotId of lazyRow.attrSlotIds) {
19731
+ const path = skeletonPaths?.elementPaths.get(slotId);
19732
+ parts.push(path ? pathExpr(elVar, path) : `qsa(${elVar}, '[bf="${slotId}"]')`);
19733
+ }
19734
+ if (lazyRow.texts.length > 0) {
19735
+ parts.push(deferDoor ? "null" : `${doorCtor(lazyRow)}(${elVar}, ${planVar})`);
19736
+ }
19737
+ return parts;
19738
+ }
19739
+ function doorCtor(lazyRow) {
19740
+ return lazyRow.textNeedsRead ? "lazyClaimSlots" : "lazySlots";
19741
+ }
19742
+ function doorAccess(lazyRow, writerIndex, adoptedPlanVar) {
19743
+ const slot = `__r[${writerIndex}]`;
19744
+ return `${slot} ?? (${slot} = ${doorCtor(lazyRow)}(__e.primaryEl, ${adoptedPlanVar}))`;
19745
+ }
19746
+ function dedupGuard(ordinal) {
19747
+ return `!(${ordinal} in __l) || !Object.is(__l[${ordinal}], __x)`;
19748
+ }
19749
+ function emitAttrBinding(lines, ind, a, mode) {
19750
+ lines.push(`${ind}{ const __t = __r[${a.refIndex}]`);
19751
+ lines.push(`${ind}if (__t) {`);
19752
+ lines.push(`${ind} const __x = ${a.wrappedExpression}`);
19753
+ const guard = mode === "create" ? null : mode === "item" ? dedupGuard(a.ordinal) : `__seed ? (${seedDiffersExpr("__t", a)}) : (${dedupGuard(a.ordinal)})`;
19754
+ const writeIndent = guard ? `${ind} ` : `${ind} `;
19755
+ if (guard)
19756
+ lines.push(`${ind} if (${guard}) {`);
19757
+ for (const stmt of emitAttrUpdate("__t", a.attrName, "__x", a.meta)) {
19758
+ lines.push(`${writeIndent}${stmt}`);
19759
+ }
19760
+ if (guard)
19761
+ lines.push(`${ind} }`);
19762
+ lines.push(`${ind} __l[${a.ordinal}] = __x`);
19763
+ lines.push(`${ind}} }`);
19764
+ }
19765
+ function emitTextBinding(lines, ind, t, doorExpr, mode, rwDoor) {
19766
+ lines.push(`${ind}{ const __x = ${t.wrappedExpression}`);
19767
+ const writeOf = (valueExpr) => rwDoor ? `${doorExpr}.write('${t.slotId}', ${valueExpr})` : `${doorExpr}('${t.slotId}', ${valueExpr})`;
19768
+ if (mode === "outer") {
19769
+ lines.push(`${ind}if (__seed) {`);
19770
+ lines.push(`${ind} const __s = textOrNode(__x)`);
19771
+ lines.push(`${ind} if (${doorExpr}.read('${t.slotId}') !== __s) ${writeOf("__s")}`);
19772
+ lines.push(`${ind}} else if (${dedupGuard(t.ordinal)}) ${writeOf("textOrNode(__x)")}`);
19773
+ } else if (mode === "item") {
19774
+ lines.push(`${ind}if (${dedupGuard(t.ordinal)}) ${writeOf("textOrNode(__x)")}`);
19775
+ } else {
19776
+ lines.push(`${ind}${writeOf("textOrNode(__x)")}`);
19777
+ }
19778
+ lines.push(`${ind}__l[${t.ordinal}] = __x }`);
19779
+ }
19780
+ function seedDiffersExpr(target, a) {
19781
+ const html = toHtmlAttrName(a.attrName);
19782
+ if (a.attrName === "dangerouslySetInnerHTML" || html === "dangerouslySetInnerHTML")
19783
+ return "true";
19784
+ if (html === "style")
19785
+ return `${target}.getAttribute('style') !== styleToCss(__x)`;
19786
+ if (html === "class")
19787
+ return `${target}.getAttribute('class') !== (__x != null ? String(__x) : null)`;
19788
+ if (html === "value")
19789
+ return `${target}.value !== String(__x)`;
19790
+ if (isBooleanAttr(html))
19791
+ return `${target}.${html} !== !!(__x)`;
19792
+ if (a.meta.presenceOrUndefined) {
19793
+ const written = html.startsWith("aria-") ? "true" : "";
19794
+ return `${target}.getAttribute('${html}') !== (__x ? '${written}' : null)`;
19795
+ }
19796
+ return `${target}.getAttribute('${html}') !== (__x != null ? String(__x) : null)`;
19797
+ }
19798
+
19174
19799
  // src/ir-to-client-js/control-flow/stringify/loop.ts
19175
19800
  function emitLoopChildRefs(lines, refs, opts) {
19176
19801
  if (refs.length === 0)
@@ -19248,6 +19873,23 @@ function stringifyPlainLoop(lines, plan, topIndent = " ") {
19248
19873
  stringifyAnchoredLoop(lines, plan, topIndent, anchorKeyExpr);
19249
19874
  return;
19250
19875
  }
19876
+ if (plan.lazyRow) {
19877
+ stringifyLazyRowLoop(lines, {
19878
+ indent: topIndent,
19879
+ containerVar,
19880
+ guardContainer: false,
19881
+ markerId,
19882
+ arrayExpr,
19883
+ keyFn,
19884
+ paramHead,
19885
+ indexParam,
19886
+ template,
19887
+ skeletonTemplate,
19888
+ skeletonPaths: plan.skeletonPaths,
19889
+ lazyRow: plan.lazyRow
19890
+ });
19891
+ return;
19892
+ }
19251
19893
  const hoistedTpl = !bodyIsMultiRoot && skeletonTemplate ? skeletonTemplate : null;
19252
19894
  const tplVar = `__tpl_${markerId.replace(/[^A-Za-z0-9_$]/g, "_")}`;
19253
19895
  if (hoistedTpl) {
@@ -19841,6 +20483,23 @@ function emitPlain(lines, plan) {
19841
20483
  stringifyEventDelegation(lines, eventDelegation);
19842
20484
  return;
19843
20485
  }
20486
+ if (plan.lazyRow) {
20487
+ stringifyLazyRowLoop(lines, {
20488
+ indent: " ",
20489
+ containerVar,
20490
+ guardContainer: true,
20491
+ markerId,
20492
+ arrayExpr,
20493
+ keyFn,
20494
+ paramHead,
20495
+ indexParam,
20496
+ template,
20497
+ lazyRow: plan.lazyRow
20498
+ });
20499
+ lines.push(` }))`);
20500
+ stringifyEventDelegation(lines, eventDelegation);
20501
+ return;
20502
+ }
19844
20503
  if (reactiveEffects === null && !bodyIsMultiRoot && childRefs.length === 0 && preambleRegions.length === 0) {
19845
20504
  const cloneExpr = emitTemplateCloneInline(template);
19846
20505
  if (mapPreambleWrapped) {
@@ -20039,7 +20698,7 @@ function buildComponentLoopPlan(elem, profileComponentName) {
20039
20698
  // src/ir-to-client-js/control-flow/plan/build-loop.ts
20040
20699
  function buildLoopPlan(elem, opts) {
20041
20700
  if (elem.bodyIsItemConditional) {
20042
- return buildPlainLoopPlan(elem, opts.profileComponentName);
20701
+ return buildPlainLoopPlan(elem, opts.profileComponentName, opts.lazyScope);
20043
20702
  }
20044
20703
  if (elem.isStaticArray) {
20045
20704
  return buildStaticLoopPlan(elem, opts.unsafeLocalNames, opts.profileComponentName);
@@ -20051,9 +20710,9 @@ function buildLoopPlan(elem, opts) {
20051
20710
  if (elem.childComponent) {
20052
20711
  return buildComponentLoopPlan(elem, opts.profileComponentName);
20053
20712
  }
20054
- return buildPlainLoopPlan(elem, opts.profileComponentName);
20713
+ return buildPlainLoopPlan(elem, opts.profileComponentName, opts.lazyScope);
20055
20714
  }
20056
- function buildPlainLoopPlan(elem, profileComponentName) {
20715
+ function buildPlainLoopPlan(elem, profileComponentName, lazyScope) {
20057
20716
  const wrap = (expr) => wrapLoopParamAsAccessor(expr, elem.param, elem.paramBindings);
20058
20717
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(elem.param, elem.paramBindings);
20059
20718
  const hasReactive2 = elem.bindings.reactiveAttrs.length > 0 || elem.bindings.reactiveTexts.length > 0 || elem.bindings.conditionals.length > 0;
@@ -20080,27 +20739,43 @@ function buildPlainLoopPlan(elem, profileComponentName) {
20080
20739
  preambleRegions: []
20081
20740
  };
20082
20741
  }
20742
+ const arrayExpr = buildChainedArrayExpr(elem);
20743
+ const indexParam = elem.index || "__idx";
20744
+ const mapPreambleWrapped = elem.preamble ? renderPreamble(elem.preamble, {
20745
+ transformJs: wrap,
20746
+ renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: elem.param, bindings: elem.paramBindings }], undefined, true)
20747
+ }) : "";
20748
+ const preambleRegions = buildPreambleRegionPlans(elem.preambleRegions, elem.param, elem.paramBindings);
20083
20749
  return {
20084
20750
  kind: "plain",
20085
20751
  rowConstruction: "string-template",
20086
20752
  containerVar: `_${varSlotId(elem.slotId)}`,
20087
20753
  markerId: elem.markerId,
20088
20754
  profileLoopId: profileComponentName ? `${profileComponentName}#binding:${elem.slotId}` : undefined,
20089
- arrayExpr: buildChainedArrayExpr(elem),
20755
+ arrayExpr,
20090
20756
  keyFn: loopKeyFn(elem),
20091
20757
  paramHead,
20092
20758
  paramUnwrap,
20093
- indexParam: elem.index || "__idx",
20094
- mapPreambleWrapped: elem.preamble ? renderPreamble(elem.preamble, {
20095
- transformJs: wrap,
20096
- renderLeaf: (ir) => irToHtmlTemplate(ir, undefined, 1, [{ param: elem.param, bindings: elem.paramBindings }], undefined, true)
20097
- }) : "",
20759
+ indexParam,
20760
+ lazyRow: buildLazyRowPlan({
20761
+ loop: elem,
20762
+ arrayExpr,
20763
+ indexParam,
20764
+ paramUnwrap,
20765
+ mapPreambleWrapped,
20766
+ preambleRegionCount: preambleRegions.length,
20767
+ callSite: "plain",
20768
+ flatMapLeafItem: false,
20769
+ anchored: elem.bodyIsItemConditional ?? false,
20770
+ scope: lazyScope
20771
+ }) ?? undefined,
20772
+ mapPreambleWrapped,
20098
20773
  template: elem.template,
20099
20774
  skeletonTemplate: elem.skeletonTemplate,
20100
20775
  skeletonPaths: elem.skeletonPaths,
20101
20776
  reactiveEffects: hasReactive2 ? buildLoopReactiveEffectsPlan(elem, profileComponentName) : null,
20102
20777
  childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings),
20103
- preambleRegions: buildPreambleRegionPlans(elem.preambleRegions, elem.param, elem.paramBindings),
20778
+ preambleRegions,
20104
20779
  bodyIsMultiRoot: elem.bodyIsMultiRoot ?? false,
20105
20780
  anchored: elem.bodyIsItemConditional ?? false,
20106
20781
  anchorKeyExpr: elem.key ? wrap(elem.key) : elem.index || "__idx"
@@ -20155,7 +20830,7 @@ function buildStaticLoopMaterialize(elem, unsafeLocalNames) {
20155
20830
  function emitConditionalUpdates(lines, ctx) {
20156
20831
  const profileComponentName = ctx.profile ? ctx.componentName : undefined;
20157
20832
  for (const elem of ctx.conditionalElements) {
20158
- const plan = buildInsertPlan(elem, { scope: { kind: "top" }, eventNameMode: "dom", profileComponentName });
20833
+ const plan = buildInsertPlan(elem, { scope: { kind: "top" }, eventNameMode: "dom", profileComponentName, lazyScope: buildLazyRowScopeInfo(ctx) });
20159
20834
  stringifyInsert(lines, plan, { leadingIndent: " ", bodyIndent: " " });
20160
20835
  lines.push("");
20161
20836
  }
@@ -20163,17 +20838,19 @@ function emitConditionalUpdates(lines, ctx) {
20163
20838
  function emitClientOnlyConditionals(lines, ctx) {
20164
20839
  const profileComponentName = ctx.profile ? ctx.componentName : undefined;
20165
20840
  for (const elem of ctx.clientOnlyConditionals) {
20166
- const plan = buildInsertPlan(elem, { scope: { kind: "top" }, eventNameMode: "raw", profileComponentName });
20841
+ const plan = buildInsertPlan(elem, { scope: { kind: "top" }, eventNameMode: "raw", profileComponentName, lazyScope: buildLazyRowScopeInfo(ctx) });
20167
20842
  lines.push(` // @client conditional: ${elem.slotId}`);
20168
20843
  stringifyInsert(lines, plan, { leadingIndent: " ", bodyIndent: " " });
20169
20844
  lines.push("");
20170
20845
  }
20171
20846
  }
20172
20847
  function emitLoopUpdates(lines, ctx, unsafeLocalNames) {
20848
+ const lazyScope = buildLazyRowScopeInfo(ctx);
20173
20849
  for (const elem of ctx.loopElements) {
20174
20850
  const plan = buildLoopPlan(elem, {
20175
20851
  unsafeLocalNames,
20176
- profileComponentName: ctx.profile ? ctx.componentName : undefined
20852
+ profileComponentName: ctx.profile ? ctx.componentName : undefined,
20853
+ lazyScope
20177
20854
  });
20178
20855
  internalInvariant(!(elem.preamble && elem.preamble.builderNames.length > 0 && plan.rowConstruction === "dom-ops"), `loop variant '${plan.kind}' declares dom-ops row construction but received a JSX-bearing preamble — add a Phase-1 refusal (or wire renderPreamble support) for this shape`);
20179
20856
  stringifyLoop(lines, plan);
@@ -20380,20 +21057,20 @@ var PHASES = [
20380
21057
  ];
20381
21058
 
20382
21059
  // src/ir-to-client-js/rewrite-props-object.ts
20383
- import ts15 from "typescript";
21060
+ import ts16 from "typescript";
20384
21061
  function rewritePropsObjectRef(code, propsObjectName) {
20385
21062
  const srcPropsName = propsObjectName ?? "props";
20386
21063
  if (srcPropsName === PROPS_PARAM)
20387
21064
  return code;
20388
21065
  if (!new RegExp(`\\b${srcPropsName}\\b`).test(code))
20389
21066
  return code;
20390
- const sourceFile = ts15.createSourceFile("init-body.ts", code, ts15.ScriptTarget.Latest, true, ts15.ScriptKind.TS);
21067
+ const sourceFile = ts16.createSourceFile("init-body.ts", code, ts16.ScriptTarget.Latest, true, ts16.ScriptKind.TS);
20391
21068
  const spans = [];
20392
21069
  function visit3(node) {
20393
- if (ts15.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
21070
+ if (ts16.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
20394
21071
  spans.push([node.getStart(sourceFile), node.getEnd()]);
20395
21072
  }
20396
- ts15.forEachChild(node, visit3);
21073
+ ts16.forEachChild(node, visit3);
20397
21074
  }
20398
21075
  visit3(sourceFile);
20399
21076
  if (spans.length === 0)
@@ -20409,17 +21086,17 @@ function shouldRewrite(node) {
20409
21086
  const parent = node.parent;
20410
21087
  if (!parent)
20411
21088
  return true;
20412
- if (ts15.isPropertyAccessExpression(parent) && parent.name === node)
21089
+ if (ts16.isPropertyAccessExpression(parent) && parent.name === node)
20413
21090
  return false;
20414
- if (ts15.isPropertyAssignment(parent) && parent.name === node)
21091
+ if (ts16.isPropertyAssignment(parent) && parent.name === node)
20415
21092
  return false;
20416
- if (ts15.isShorthandPropertyAssignment(parent) && parent.name === node)
21093
+ if (ts16.isShorthandPropertyAssignment(parent) && parent.name === node)
20417
21094
  return false;
20418
- if (ts15.isPropertySignature(parent) && parent.name === node)
21095
+ if (ts16.isPropertySignature(parent) && parent.name === node)
20419
21096
  return false;
20420
- if (ts15.isPropertyDeclaration(parent) && parent.name === node)
21097
+ if (ts16.isPropertyDeclaration(parent) && parent.name === node)
20421
21098
  return false;
20422
- if (ts15.isBindingElement(parent) && parent.name === node)
21099
+ if (ts16.isBindingElement(parent) && parent.name === node)
20423
21100
  return false;
20424
21101
  return true;
20425
21102
  }
@@ -21049,7 +21726,7 @@ function walkIR2(node, visitor) {
21049
21726
  }
21050
21727
 
21051
21728
  // src/preprocess-inline-jsx-callbacks.ts
21052
- import ts16 from "typescript";
21729
+ import ts17 from "typescript";
21053
21730
  var SYNTHETIC_PREFIX = "BFInlineJsxCallback";
21054
21731
  var MAX_FIXPOINT_ITERATIONS = 16;
21055
21732
  function preprocessInlineJsxCallbacks(source, filePath) {
@@ -21071,8 +21748,8 @@ function preprocessInlineJsxCallbacks(source, filePath) {
21071
21748
  return { source: current, errors, syntheticNames };
21072
21749
  }
21073
21750
  function runSinglePass(source, filePath, startingCounter) {
21074
- const sourceFile = ts16.createSourceFile(filePath, source, ts16.ScriptTarget.Latest, true, ts16.ScriptKind.TSX);
21075
- const hasUseClient = sourceFile.statements.some((stmt) => ts16.isExpressionStatement(stmt) && ts16.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
21751
+ const sourceFile = ts17.createSourceFile(filePath, source, ts17.ScriptTarget.Latest, true, ts17.ScriptKind.TSX);
21752
+ const hasUseClient = sourceFile.statements.some((stmt) => ts17.isExpressionStatement(stmt) && ts17.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
21076
21753
  if (!hasUseClient) {
21077
21754
  return { source, errors: [], syntheticNames: [], counterAfter: startingCounter };
21078
21755
  }
@@ -21094,22 +21771,22 @@ function runSinglePass(source, filePath, startingCounter) {
21094
21771
  }
21095
21772
  }
21096
21773
  function visit3(node) {
21097
- if (ts16.isJsxAttribute(node) && node.initializer && ts16.isJsxExpression(node.initializer) && node.initializer.expression) {
21774
+ if (ts17.isJsxAttribute(node) && node.initializer && ts17.isJsxExpression(node.initializer) && node.initializer.expression) {
21098
21775
  if (tryHandleArrowValue(node.initializer.expression)) {
21099
21776
  return;
21100
21777
  }
21101
21778
  }
21102
- if (ts16.isPropertyAssignment(node) && node.initializer) {
21779
+ if (ts17.isPropertyAssignment(node) && node.initializer) {
21103
21780
  if (tryHandleArrowValue(node.initializer))
21104
21781
  return;
21105
21782
  }
21106
- ts16.forEachChild(node, visit3);
21783
+ ts17.forEachChild(node, visit3);
21107
21784
  }
21108
21785
  function tryHandleArrowValue(initializer) {
21109
21786
  let expr = initializer;
21110
- while (ts16.isParenthesizedExpression(expr))
21787
+ while (ts17.isParenthesizedExpression(expr))
21111
21788
  expr = expr.expression;
21112
- if (ts16.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
21789
+ if (ts17.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
21113
21790
  return handleInlineArrow(expr);
21114
21791
  }
21115
21792
  return false;
@@ -21146,7 +21823,7 @@ function runSinglePass(source, filePath, startingCounter) {
21146
21823
  replacements.push({ start: arrowStart, end: arrowEnd, text: name });
21147
21824
  return true;
21148
21825
  }
21149
- ts16.forEachChild(sourceFile, visit3);
21826
+ ts17.forEachChild(sourceFile, visit3);
21150
21827
  if (replacements.length === 0) {
21151
21828
  return { source, errors, syntheticNames, counterAfter: counter };
21152
21829
  }
@@ -21169,11 +21846,11 @@ function errorMessageForCapture(captures) {
21169
21846
  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.`;
21170
21847
  }
21171
21848
  function arrowBodyContainsJsx(arrow) {
21172
- if (ts16.isBlock(arrow.body)) {
21849
+ if (ts17.isBlock(arrow.body)) {
21173
21850
  return blockReturnsJsx(arrow.body);
21174
21851
  }
21175
21852
  let body = arrow.body;
21176
- while (ts16.isParenthesizedExpression(body))
21853
+ while (ts17.isParenthesizedExpression(body))
21177
21854
  body = body.expression;
21178
21855
  return isJsxLike(body);
21179
21856
  }
@@ -21182,24 +21859,24 @@ function blockReturnsJsx(block) {
21182
21859
  function visit3(n) {
21183
21860
  if (found)
21184
21861
  return;
21185
- if (ts16.isReturnStatement(n) && n.expression) {
21862
+ if (ts17.isReturnStatement(n) && n.expression) {
21186
21863
  let e = n.expression;
21187
- while (ts16.isParenthesizedExpression(e))
21864
+ while (ts17.isParenthesizedExpression(e))
21188
21865
  e = e.expression;
21189
21866
  if (isJsxLike(e)) {
21190
21867
  found = true;
21191
21868
  return;
21192
21869
  }
21193
21870
  }
21194
- if (ts16.isArrowFunction(n) || ts16.isFunctionDeclaration(n) || ts16.isFunctionExpression(n))
21871
+ if (ts17.isArrowFunction(n) || ts17.isFunctionDeclaration(n) || ts17.isFunctionExpression(n))
21195
21872
  return;
21196
- ts16.forEachChild(n, visit3);
21873
+ ts17.forEachChild(n, visit3);
21197
21874
  }
21198
- ts16.forEachChild(block, visit3);
21875
+ ts17.forEachChild(block, visit3);
21199
21876
  return found;
21200
21877
  }
21201
21878
  function isJsxLike(expr) {
21202
- return ts16.isJsxElement(expr) || ts16.isJsxSelfClosingElement(expr) || ts16.isJsxFragment(expr);
21879
+ return ts17.isJsxElement(expr) || ts17.isJsxSelfClosingElement(expr) || ts17.isJsxFragment(expr);
21203
21880
  }
21204
21881
  function collectArrowParamNames(arrow) {
21205
21882
  const names = new Set;
@@ -21209,13 +21886,13 @@ function collectArrowParamNames(arrow) {
21209
21886
  }
21210
21887
  function collectBindingNames2(name, out) {
21211
21888
  const push = Array.isArray(out) ? (n) => out.push(n) : (n) => out.add(n);
21212
- if (ts16.isIdentifier(name)) {
21889
+ if (ts17.isIdentifier(name)) {
21213
21890
  push(name.text);
21214
- } else if (ts16.isObjectBindingPattern(name)) {
21891
+ } else if (ts17.isObjectBindingPattern(name)) {
21215
21892
  name.elements.forEach((el) => collectBindingNames2(el.name, out));
21216
- } else if (ts16.isArrayBindingPattern(name)) {
21893
+ } else if (ts17.isArrayBindingPattern(name)) {
21217
21894
  name.elements.forEach((el) => {
21218
- if (!ts16.isOmittedExpression(el))
21895
+ if (!ts17.isOmittedExpression(el))
21219
21896
  collectBindingNames2(el.name, out);
21220
21897
  });
21221
21898
  }
@@ -21242,48 +21919,48 @@ function collectFreeIdentifiers(arrow) {
21242
21919
  return bound.includes(name);
21243
21920
  }
21244
21921
  function visit3(node) {
21245
- if (ts16.isIdentifier(node)) {
21922
+ if (ts17.isIdentifier(node)) {
21246
21923
  const parent = node.parent;
21247
- if (parent && ts16.isPropertyAccessExpression(parent) && parent.name === node)
21924
+ if (parent && ts17.isPropertyAccessExpression(parent) && parent.name === node)
21248
21925
  return;
21249
- if (parent && ts16.isPropertyAssignment(parent) && parent.name === node)
21926
+ if (parent && ts17.isPropertyAssignment(parent) && parent.name === node)
21250
21927
  return;
21251
- if (parent && ts16.isPropertySignature(parent) && parent.name === node)
21928
+ if (parent && ts17.isPropertySignature(parent) && parent.name === node)
21252
21929
  return;
21253
- if (parent && ts16.isPropertyDeclaration(parent) && parent.name === node)
21930
+ if (parent && ts17.isPropertyDeclaration(parent) && parent.name === node)
21254
21931
  return;
21255
- if (parent && ts16.isMethodDeclaration(parent) && parent.name === node)
21932
+ if (parent && ts17.isMethodDeclaration(parent) && parent.name === node)
21256
21933
  return;
21257
- if (parent && ts16.isMethodSignature(parent) && parent.name === node)
21934
+ if (parent && ts17.isMethodSignature(parent) && parent.name === node)
21258
21935
  return;
21259
- if (parent && ts16.isGetAccessorDeclaration(parent) && parent.name === node)
21936
+ if (parent && ts17.isGetAccessorDeclaration(parent) && parent.name === node)
21260
21937
  return;
21261
- if (parent && ts16.isSetAccessorDeclaration(parent) && parent.name === node)
21938
+ if (parent && ts17.isSetAccessorDeclaration(parent) && parent.name === node)
21262
21939
  return;
21263
- if (parent && ts16.isEnumMember(parent) && parent.name === node)
21940
+ if (parent && ts17.isEnumMember(parent) && parent.name === node)
21264
21941
  return;
21265
- if (parent && ts16.isBindingElement(parent) && parent.propertyName === node)
21942
+ if (parent && ts17.isBindingElement(parent) && parent.propertyName === node)
21266
21943
  return;
21267
- if (parent && ts16.isShorthandPropertyAssignment(parent) && parent.name === node) {
21944
+ if (parent && ts17.isShorthandPropertyAssignment(parent) && parent.name === node) {
21268
21945
  if (!isBound(node.text))
21269
21946
  ids.add(node.text);
21270
21947
  return;
21271
21948
  }
21272
- if (parent && ts16.isParameter(parent) && parent.name === node)
21949
+ if (parent && ts17.isParameter(parent) && parent.name === node)
21273
21950
  return;
21274
- if (parent && ts16.isVariableDeclaration(parent) && parent.name === node)
21951
+ if (parent && ts17.isVariableDeclaration(parent) && parent.name === node)
21275
21952
  return;
21276
- if (parent && ts16.isFunctionDeclaration(parent) && parent.name === node)
21953
+ if (parent && ts17.isFunctionDeclaration(parent) && parent.name === node)
21277
21954
  return;
21278
- if (parent && ts16.isClassDeclaration(parent) && parent.name === node)
21955
+ if (parent && ts17.isClassDeclaration(parent) && parent.name === node)
21279
21956
  return;
21280
- if (parent && ts16.isJsxAttribute(parent) && parent.name === node)
21957
+ if (parent && ts17.isJsxAttribute(parent) && parent.name === node)
21281
21958
  return;
21282
- if (parent && ts16.isJsxOpeningElement(parent) && parent.tagName === node) {
21959
+ if (parent && ts17.isJsxOpeningElement(parent) && parent.tagName === node) {
21283
21960
  if (/^[a-z]/.test(node.text))
21284
21961
  return;
21285
21962
  }
21286
- if (parent && ts16.isJsxClosingElement(parent) && parent.tagName === node) {
21963
+ if (parent && ts17.isJsxClosingElement(parent) && parent.tagName === node) {
21287
21964
  if (/^[a-z]/.test(node.text))
21288
21965
  return;
21289
21966
  }
@@ -21292,43 +21969,43 @@ function collectFreeIdentifiers(arrow) {
21292
21969
  ids.add(node.text);
21293
21970
  return;
21294
21971
  }
21295
- if (ts16.isVariableDeclaration(node)) {
21972
+ if (ts17.isVariableDeclaration(node)) {
21296
21973
  const declared = pushBindings(node.name);
21297
21974
  if (node.initializer)
21298
21975
  visit3(node.initializer);
21299
21976
  return;
21300
21977
  }
21301
- if (ts16.isFunctionDeclaration(node)) {
21978
+ if (ts17.isFunctionDeclaration(node)) {
21302
21979
  if (node.name)
21303
21980
  bound.push(node.name.text);
21304
21981
  visitInsideNewScope(node);
21305
21982
  return;
21306
21983
  }
21307
- if (ts16.isClassDeclaration(node)) {
21984
+ if (ts17.isClassDeclaration(node)) {
21308
21985
  if (node.name)
21309
21986
  bound.push(node.name.text);
21310
- ts16.forEachChild(node, visit3);
21987
+ ts17.forEachChild(node, visit3);
21311
21988
  return;
21312
21989
  }
21313
- if (ts16.isArrowFunction(node) || ts16.isFunctionExpression(node)) {
21990
+ if (ts17.isArrowFunction(node) || ts17.isFunctionExpression(node)) {
21314
21991
  visitInsideNewScope(node);
21315
21992
  return;
21316
21993
  }
21317
- if (ts16.isCatchClause(node)) {
21994
+ if (ts17.isCatchClause(node)) {
21318
21995
  const before = bound.length;
21319
21996
  if (node.variableDeclaration)
21320
21997
  pushBindings(node.variableDeclaration.name);
21321
- ts16.forEachChild(node, visit3);
21998
+ ts17.forEachChild(node, visit3);
21322
21999
  popN(bound.length - before);
21323
22000
  return;
21324
22001
  }
21325
- if (ts16.isBlock(node)) {
22002
+ if (ts17.isBlock(node)) {
21326
22003
  const before = bound.length;
21327
- ts16.forEachChild(node, visit3);
22004
+ ts17.forEachChild(node, visit3);
21328
22005
  popN(bound.length - before);
21329
22006
  return;
21330
22007
  }
21331
- ts16.forEachChild(node, visit3);
22008
+ ts17.forEachChild(node, visit3);
21332
22009
  }
21333
22010
  function visitInsideNewScope(fn) {
21334
22011
  const before = bound.length;
@@ -21351,29 +22028,29 @@ function collectFreeIdentifiers(arrow) {
21351
22028
  function collectModuleScopeNames(sourceFile) {
21352
22029
  const names = new Set;
21353
22030
  for (const stmt of sourceFile.statements) {
21354
- if (ts16.isFunctionDeclaration(stmt) && stmt.name)
22031
+ if (ts17.isFunctionDeclaration(stmt) && stmt.name)
21355
22032
  names.add(stmt.name.text);
21356
- else if (ts16.isClassDeclaration(stmt) && stmt.name)
22033
+ else if (ts17.isClassDeclaration(stmt) && stmt.name)
21357
22034
  names.add(stmt.name.text);
21358
- else if (ts16.isVariableStatement(stmt)) {
22035
+ else if (ts17.isVariableStatement(stmt)) {
21359
22036
  for (const decl of stmt.declarationList.declarations)
21360
22037
  collectBindingNames2(decl.name, names);
21361
- } else if (ts16.isImportDeclaration(stmt) && stmt.importClause) {
22038
+ } else if (ts17.isImportDeclaration(stmt) && stmt.importClause) {
21362
22039
  const ic = stmt.importClause;
21363
22040
  if (ic.name)
21364
22041
  names.add(ic.name.text);
21365
22042
  if (ic.namedBindings) {
21366
- if (ts16.isNamespaceImport(ic.namedBindings))
22043
+ if (ts17.isNamespaceImport(ic.namedBindings))
21367
22044
  names.add(ic.namedBindings.name.text);
21368
22045
  else
21369
22046
  for (const e of ic.namedBindings.elements)
21370
22047
  names.add(e.name.text);
21371
22048
  }
21372
- } else if (ts16.isTypeAliasDeclaration(stmt))
22049
+ } else if (ts17.isTypeAliasDeclaration(stmt))
21373
22050
  names.add(stmt.name.text);
21374
- else if (ts16.isInterfaceDeclaration(stmt))
22051
+ else if (ts17.isInterfaceDeclaration(stmt))
21375
22052
  names.add(stmt.name.text);
21376
- else if (ts16.isEnumDeclaration(stmt))
22053
+ else if (ts17.isEnumDeclaration(stmt))
21377
22054
  names.add(stmt.name.text);
21378
22055
  }
21379
22056
  return names;
@@ -21381,7 +22058,7 @@ function collectModuleScopeNames(sourceFile) {
21381
22058
  function buildSyntheticDeclaration(name, arrow, sourceFile) {
21382
22059
  const paramsText = arrow.parameters.length === 0 ? "" : arrow.parameters.map((p) => p.getText(sourceFile)).join(", ");
21383
22060
  let bodyText;
21384
- if (ts16.isBlock(arrow.body)) {
22061
+ if (ts17.isBlock(arrow.body)) {
21385
22062
  bodyText = arrow.body.getText(sourceFile);
21386
22063
  } else {
21387
22064
  const expr = arrow.body.getText(sourceFile);
@@ -21391,7 +22068,7 @@ function buildSyntheticDeclaration(name, arrow, sourceFile) {
21391
22068
  }
21392
22069
 
21393
22070
  // src/ssr-defaults.ts
21394
- import ts17 from "typescript";
22071
+ import ts18 from "typescript";
21395
22072
  var UNRESOLVED = Symbol("unresolved");
21396
22073
  var NO_RETURN = Symbol("no-return");
21397
22074
  function extractSsrDefaults(metadata) {
@@ -21467,11 +22144,11 @@ function collectPropRefs(expr, propsObjectName, out) {
21467
22144
  if (!node)
21468
22145
  return;
21469
22146
  const visit3 = (n) => {
21470
- if (ts17.isPropertyAccessExpression(n) && ts17.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts17.isIdentifier(n.name)) {
22147
+ if (ts18.isPropertyAccessExpression(n) && ts18.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts18.isIdentifier(n.name)) {
21471
22148
  out.add(n.name.text);
21472
22149
  return;
21473
22150
  }
21474
- ts17.forEachChild(n, visit3);
22151
+ ts18.forEachChild(n, visit3);
21475
22152
  };
21476
22153
  visit3(node);
21477
22154
  }
@@ -21492,23 +22169,23 @@ function tryStaticEval(expr, ctx) {
21492
22169
  }
21493
22170
  function evalStatementsForReturn(statements, ctx) {
21494
22171
  for (const stmt of statements) {
21495
- if (ts17.isVariableStatement(stmt)) {
22172
+ if (ts18.isVariableStatement(stmt)) {
21496
22173
  for (const d of stmt.declarationList.declarations) {
21497
- if (!ts17.isIdentifier(d.name) || !d.initializer)
22174
+ if (!ts18.isIdentifier(d.name) || !d.initializer)
21498
22175
  continue;
21499
22176
  const v = evalNode(d.initializer, ctx);
21500
22177
  if (v !== UNRESOLVED)
21501
22178
  ctx.bindings[d.name.text] = v;
21502
22179
  }
21503
- } else if (ts17.isReturnStatement(stmt)) {
22180
+ } else if (ts18.isReturnStatement(stmt)) {
21504
22181
  return stmt.expression ? evalNode(stmt.expression, ctx) : UNRESOLVED;
21505
- } else if (ts17.isIfStatement(stmt)) {
22182
+ } else if (ts18.isIfStatement(stmt)) {
21506
22183
  const cond = evalNode(stmt.expression, ctx);
21507
22184
  if (cond === UNRESOLVED)
21508
22185
  return UNRESOLVED;
21509
22186
  const branch = cond ? stmt.thenStatement : stmt.elseStatement;
21510
22187
  if (branch) {
21511
- const taken = evalStatementsForReturn(ts17.isBlock(branch) ? branch.statements : [branch], ctx);
22188
+ const taken = evalStatementsForReturn(ts18.isBlock(branch) ? branch.statements : [branch], ctx);
21512
22189
  if (taken !== NO_RETURN)
21513
22190
  return taken;
21514
22191
  }
@@ -21519,45 +22196,45 @@ function evalStatementsForReturn(statements, ctx) {
21519
22196
  return NO_RETURN;
21520
22197
  }
21521
22198
  function parseExpression2(expr) {
21522
- const sf = ts17.createSourceFile("__ssr_default__.ts", `(${expr})`, ts17.ScriptTarget.Latest, false, ts17.ScriptKind.TS);
22199
+ const sf = ts18.createSourceFile("__ssr_default__.ts", `(${expr})`, ts18.ScriptTarget.Latest, false, ts18.ScriptKind.TS);
21523
22200
  const stmt = sf.statements[0];
21524
- if (!stmt || !ts17.isExpressionStatement(stmt))
22201
+ if (!stmt || !ts18.isExpressionStatement(stmt))
21525
22202
  return null;
21526
- const inner = ts17.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
22203
+ const inner = ts18.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
21527
22204
  return inner;
21528
22205
  }
21529
22206
  function evalNode(node, ctx) {
21530
- if (ts17.isParenthesizedExpression(node))
22207
+ if (ts18.isParenthesizedExpression(node))
21531
22208
  return evalNode(node.expression, ctx);
21532
- if (ts17.isAsExpression(node))
22209
+ if (ts18.isAsExpression(node))
21533
22210
  return evalNode(node.expression, ctx);
21534
- if (ts17.isSatisfiesExpression(node))
22211
+ if (ts18.isSatisfiesExpression(node))
21535
22212
  return evalNode(node.expression, ctx);
21536
- if (ts17.isTypeAssertionExpression(node))
22213
+ if (ts18.isTypeAssertionExpression(node))
21537
22214
  return evalNode(node.expression, ctx);
21538
- if (ts17.isNonNullExpression(node))
22215
+ if (ts18.isNonNullExpression(node))
21539
22216
  return evalNode(node.expression, ctx);
21540
- if (ts17.isArrowFunction(node)) {
22217
+ if (ts18.isArrowFunction(node)) {
21541
22218
  if (node.parameters.length !== 0)
21542
22219
  return UNRESOLVED;
21543
- if (!ts17.isBlock(node.body))
22220
+ if (!ts18.isBlock(node.body))
21544
22221
  return evalNode(node.body, ctx);
21545
22222
  const localBindings = { ...ctx.bindings };
21546
22223
  const localCtx = { ...ctx, bindings: localBindings };
21547
22224
  const result = evalStatementsForReturn(node.body.statements, localCtx);
21548
22225
  return result === NO_RETURN ? UNRESOLVED : result;
21549
22226
  }
21550
- if (ts17.isNumericLiteral(node))
22227
+ if (ts18.isNumericLiteral(node))
21551
22228
  return Number(node.text);
21552
- if (ts17.isStringLiteralLike(node))
22229
+ if (ts18.isStringLiteralLike(node))
21553
22230
  return node.text;
21554
- if (node.kind === ts17.SyntaxKind.TrueKeyword)
22231
+ if (node.kind === ts18.SyntaxKind.TrueKeyword)
21555
22232
  return true;
21556
- if (node.kind === ts17.SyntaxKind.FalseKeyword)
22233
+ if (node.kind === ts18.SyntaxKind.FalseKeyword)
21557
22234
  return false;
21558
- if (node.kind === ts17.SyntaxKind.NullKeyword)
22235
+ if (node.kind === ts18.SyntaxKind.NullKeyword)
21559
22236
  return null;
21560
- if (ts17.isIdentifier(node)) {
22237
+ if (ts18.isIdentifier(node)) {
21561
22238
  if (node.text === "undefined")
21562
22239
  return;
21563
22240
  if (node.text in ctx.bindings)
@@ -21566,29 +22243,29 @@ function evalNode(node, ctx) {
21566
22243
  return;
21567
22244
  return UNRESOLVED;
21568
22245
  }
21569
- if (ts17.isPrefixUnaryExpression(node)) {
22246
+ if (ts18.isPrefixUnaryExpression(node)) {
21570
22247
  const arg = evalNode(node.operand, ctx);
21571
22248
  if (arg === UNRESOLVED)
21572
22249
  return UNRESOLVED;
21573
22250
  switch (node.operator) {
21574
- case ts17.SyntaxKind.MinusToken:
22251
+ case ts18.SyntaxKind.MinusToken:
21575
22252
  return typeof arg === "number" ? -arg : UNRESOLVED;
21576
- case ts17.SyntaxKind.PlusToken:
22253
+ case ts18.SyntaxKind.PlusToken:
21577
22254
  return typeof arg === "number" ? +arg : UNRESOLVED;
21578
- case ts17.SyntaxKind.ExclamationToken:
22255
+ case ts18.SyntaxKind.ExclamationToken:
21579
22256
  return !arg;
21580
22257
  }
21581
22258
  return UNRESOLVED;
21582
22259
  }
21583
- if (ts17.isObjectLiteralExpression(node)) {
22260
+ if (ts18.isObjectLiteralExpression(node)) {
21584
22261
  const obj = {};
21585
22262
  for (const prop of node.properties) {
21586
- if (!ts17.isPropertyAssignment(prop))
22263
+ if (!ts18.isPropertyAssignment(prop))
21587
22264
  return UNRESOLVED;
21588
22265
  let key;
21589
- if (ts17.isIdentifier(prop.name) || ts17.isStringLiteralLike(prop.name)) {
22266
+ if (ts18.isIdentifier(prop.name) || ts18.isStringLiteralLike(prop.name)) {
21590
22267
  key = prop.name.text;
21591
- } else if (ts17.isNumericLiteral(prop.name)) {
22268
+ } else if (ts18.isNumericLiteral(prop.name)) {
21592
22269
  key = prop.name.text;
21593
22270
  } else {
21594
22271
  return UNRESOLVED;
@@ -21600,10 +22277,10 @@ function evalNode(node, ctx) {
21600
22277
  }
21601
22278
  return obj;
21602
22279
  }
21603
- if (ts17.isArrayLiteralExpression(node)) {
22280
+ if (ts18.isArrayLiteralExpression(node)) {
21604
22281
  const arr = [];
21605
22282
  for (const elem of node.elements) {
21606
- if (ts17.isOmittedExpression(elem))
22283
+ if (ts18.isOmittedExpression(elem))
21607
22284
  return UNRESOLVED;
21608
22285
  const v = evalNode(elem, ctx);
21609
22286
  if (v === UNRESOLVED)
@@ -21612,7 +22289,7 @@ function evalNode(node, ctx) {
21612
22289
  }
21613
22290
  return arr;
21614
22291
  }
21615
- if (ts17.isElementAccessExpression(node)) {
22292
+ if (ts18.isElementAccessExpression(node)) {
21616
22293
  const base = evalNode(node.expression, ctx);
21617
22294
  if (base === undefined)
21618
22295
  return;
@@ -21626,17 +22303,17 @@ function evalNode(node, ctx) {
21626
22303
  const k = String(key);
21627
22304
  return Object.prototype.hasOwnProperty.call(base, k) ? base[k] : undefined;
21628
22305
  }
21629
- if (ts17.isPropertyAccessExpression(node)) {
22306
+ if (ts18.isPropertyAccessExpression(node)) {
21630
22307
  const baseResult = evalNode(node.expression, ctx);
21631
22308
  if (baseResult === undefined)
21632
22309
  return;
21633
22310
  return UNRESOLVED;
21634
22311
  }
21635
- if (ts17.isCallExpression(node)) {
21636
- if (node.arguments.length === 0 && ts17.isIdentifier(node.expression) && node.expression.text in ctx.bindings) {
22312
+ if (ts18.isCallExpression(node)) {
22313
+ if (node.arguments.length === 0 && ts18.isIdentifier(node.expression) && node.expression.text in ctx.bindings) {
21637
22314
  return ctx.bindings[node.expression.text];
21638
22315
  }
21639
- if (ts17.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
22316
+ if (ts18.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
21640
22317
  const recv = evalNode(node.expression.expression, ctx);
21641
22318
  if (Array.isArray(recv)) {
21642
22319
  let sep2 = ",";
@@ -21652,27 +22329,27 @@ function evalNode(node, ctx) {
21652
22329
  }
21653
22330
  return UNRESOLVED;
21654
22331
  }
21655
- if (ts17.isConditionalExpression(node)) {
22332
+ if (ts18.isConditionalExpression(node)) {
21656
22333
  const cond = evalNode(node.condition, ctx);
21657
22334
  if (cond === UNRESOLVED)
21658
22335
  return UNRESOLVED;
21659
22336
  return cond ? evalNode(node.whenTrue, ctx) : evalNode(node.whenFalse, ctx);
21660
22337
  }
21661
- if (ts17.isBinaryExpression(node)) {
22338
+ if (ts18.isBinaryExpression(node)) {
21662
22339
  const op = node.operatorToken.kind;
21663
- if (op === ts17.SyntaxKind.QuestionQuestionToken) {
22340
+ if (op === ts18.SyntaxKind.QuestionQuestionToken) {
21664
22341
  const l2 = evalNode(node.left, ctx);
21665
22342
  if (l2 !== UNRESOLVED && l2 !== null && l2 !== undefined)
21666
22343
  return l2;
21667
22344
  return evalNode(node.right, ctx);
21668
22345
  }
21669
- if (op === ts17.SyntaxKind.BarBarToken) {
22346
+ if (op === ts18.SyntaxKind.BarBarToken) {
21670
22347
  const l2 = evalNode(node.left, ctx);
21671
22348
  if (l2 !== UNRESOLVED && l2)
21672
22349
  return l2;
21673
22350
  return evalNode(node.right, ctx);
21674
22351
  }
21675
- if (op === ts17.SyntaxKind.AmpersandAmpersandToken) {
22352
+ if (op === ts18.SyntaxKind.AmpersandAmpersandToken) {
21676
22353
  const l2 = evalNode(node.left, ctx);
21677
22354
  if (l2 === UNRESOLVED)
21678
22355
  return UNRESOLVED;
@@ -21685,30 +22362,30 @@ function evalNode(node, ctx) {
21685
22362
  if (l === UNRESOLVED || r === UNRESOLVED)
21686
22363
  return UNRESOLVED;
21687
22364
  switch (op) {
21688
- case ts17.SyntaxKind.PlusToken:
22365
+ case ts18.SyntaxKind.PlusToken:
21689
22366
  if (typeof l === "string" || typeof r === "string")
21690
22367
  return `${l}${r}`;
21691
22368
  if (typeof l === "number" && typeof r === "number")
21692
22369
  return l + r;
21693
22370
  return UNRESOLVED;
21694
- case ts17.SyntaxKind.MinusToken:
22371
+ case ts18.SyntaxKind.MinusToken:
21695
22372
  return typeof l === "number" && typeof r === "number" ? l - r : UNRESOLVED;
21696
- case ts17.SyntaxKind.AsteriskToken:
22373
+ case ts18.SyntaxKind.AsteriskToken:
21697
22374
  return typeof l === "number" && typeof r === "number" ? l * r : UNRESOLVED;
21698
- case ts17.SyntaxKind.SlashToken:
22375
+ case ts18.SyntaxKind.SlashToken:
21699
22376
  return typeof l === "number" && typeof r === "number" && r !== 0 ? l / r : UNRESOLVED;
21700
- case ts17.SyntaxKind.PercentToken:
22377
+ case ts18.SyntaxKind.PercentToken:
21701
22378
  return typeof l === "number" && typeof r === "number" && r !== 0 ? l % r : UNRESOLVED;
21702
- case ts17.SyntaxKind.EqualsEqualsEqualsToken:
21703
- case ts17.SyntaxKind.EqualsEqualsToken:
22379
+ case ts18.SyntaxKind.EqualsEqualsEqualsToken:
22380
+ case ts18.SyntaxKind.EqualsEqualsToken:
21704
22381
  return l === r;
21705
- case ts17.SyntaxKind.ExclamationEqualsEqualsToken:
21706
- case ts17.SyntaxKind.ExclamationEqualsToken:
22382
+ case ts18.SyntaxKind.ExclamationEqualsEqualsToken:
22383
+ case ts18.SyntaxKind.ExclamationEqualsToken:
21707
22384
  return l !== r;
21708
22385
  }
21709
22386
  return UNRESOLVED;
21710
22387
  }
21711
- if (ts17.isTemplateExpression(node)) {
22388
+ if (ts18.isTemplateExpression(node)) {
21712
22389
  if (node.templateSpans.length === 0)
21713
22390
  return node.head.text;
21714
22391
  let acc = node.head.text;
@@ -21720,13 +22397,13 @@ function evalNode(node, ctx) {
21720
22397
  }
21721
22398
  return acc;
21722
22399
  }
21723
- if (ts17.isNoSubstitutionTemplateLiteral(node))
22400
+ if (ts18.isNoSubstitutionTemplateLiteral(node))
21724
22401
  return node.text;
21725
22402
  return UNRESOLVED;
21726
22403
  }
21727
22404
 
21728
22405
  // src/augment-inherited-props.ts
21729
- import ts18 from "typescript";
22406
+ import ts19 from "typescript";
21730
22407
  function collectContextConsumers(metadata) {
21731
22408
  const constants = metadata.localConstants ?? [];
21732
22409
  const contextDefaults = new Map;
@@ -21758,47 +22435,47 @@ function collectContextConsumers(metadata) {
21758
22435
  }
21759
22436
  function parseUseContextArg(source) {
21760
22437
  const expr = parseSingleExpression(source);
21761
- if (!expr || !ts18.isCallExpression(expr))
22438
+ if (!expr || !ts19.isCallExpression(expr))
21762
22439
  return null;
21763
- if (!ts18.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
22440
+ if (!ts19.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
21764
22441
  return null;
21765
22442
  if (expr.arguments.length !== 1)
21766
22443
  return null;
21767
22444
  const arg = expr.arguments[0];
21768
- return ts18.isIdentifier(arg) ? arg.text : null;
22445
+ return ts19.isIdentifier(arg) ? arg.text : null;
21769
22446
  }
21770
22447
  function parseCreateContextDefault(source) {
21771
22448
  const expr = parseSingleExpression(source);
21772
- if (!expr || !ts18.isCallExpression(expr))
22449
+ if (!expr || !ts19.isCallExpression(expr))
21773
22450
  return null;
21774
22451
  if (expr.arguments.length === 0)
21775
22452
  return null;
21776
22453
  const arg = expr.arguments[0];
21777
- if (ts18.isStringLiteral(arg) || ts18.isNoSubstitutionTemplateLiteral(arg))
22454
+ if (ts19.isStringLiteral(arg) || ts19.isNoSubstitutionTemplateLiteral(arg))
21778
22455
  return arg.text;
21779
- if (ts18.isNumericLiteral(arg))
22456
+ if (ts19.isNumericLiteral(arg))
21780
22457
  return Number(arg.text);
21781
- if (arg.kind === ts18.SyntaxKind.TrueKeyword)
22458
+ if (arg.kind === ts19.SyntaxKind.TrueKeyword)
21782
22459
  return true;
21783
- if (arg.kind === ts18.SyntaxKind.FalseKeyword)
22460
+ if (arg.kind === ts19.SyntaxKind.FalseKeyword)
21784
22461
  return false;
21785
22462
  return null;
21786
22463
  }
21787
22464
  function isObjectLiteralCreateContextDefault(source) {
21788
22465
  const expr = parseSingleExpression(source);
21789
- if (!expr || !ts18.isCallExpression(expr))
22466
+ if (!expr || !ts19.isCallExpression(expr))
21790
22467
  return false;
21791
22468
  if (expr.arguments.length === 0)
21792
22469
  return false;
21793
- return ts18.isObjectLiteralExpression(expr.arguments[0]);
22470
+ return ts19.isObjectLiteralExpression(expr.arguments[0]);
21794
22471
  }
21795
22472
  function parseSingleExpression(source) {
21796
- const sf = ts18.createSourceFile("__ctx.ts", `(${source})`, ts18.ScriptTarget.Latest, false);
22473
+ const sf = ts19.createSourceFile("__ctx.ts", `(${source})`, ts19.ScriptTarget.Latest, false);
21797
22474
  const stmt = sf.statements[0];
21798
- if (!stmt || !ts18.isExpressionStatement(stmt))
22475
+ if (!stmt || !ts19.isExpressionStatement(stmt))
21799
22476
  return null;
21800
22477
  let e = stmt.expression;
21801
- while (ts18.isParenthesizedExpression(e))
22478
+ while (ts19.isParenthesizedExpression(e))
21802
22479
  e = e.expression;
21803
22480
  return e;
21804
22481
  }
@@ -21823,25 +22500,25 @@ function augmentInheritedPropAccesses(ir) {
21823
22500
  const pinCoalesceLiterals = (s) => {
21824
22501
  if (!s || !s.includes(propsObj))
21825
22502
  return;
21826
- const sf = ts18.createSourceFile("__aug.ts", `(${s})`, ts18.ScriptTarget.Latest, false);
22503
+ const sf = ts19.createSourceFile("__aug.ts", `(${s})`, ts19.ScriptTarget.Latest, false);
21827
22504
  const visit3 = (n) => {
21828
- if (ts18.isBinaryExpression(n) && (n.operatorToken.kind === ts18.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts18.SyntaxKind.BarBarToken)) {
22505
+ if (ts19.isBinaryExpression(n) && (n.operatorToken.kind === ts19.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts19.SyntaxKind.BarBarToken)) {
21829
22506
  let left = n.left;
21830
- while (ts18.isParenthesizedExpression(left))
22507
+ while (ts19.isParenthesizedExpression(left))
21831
22508
  left = left.expression;
21832
- if (ts18.isPropertyAccessExpression(left) && ts18.isIdentifier(left.expression) && left.expression.text === propsObj) {
22509
+ if (ts19.isPropertyAccessExpression(left) && ts19.isIdentifier(left.expression) && left.expression.text === propsObj) {
21833
22510
  const name = left.name.text;
21834
22511
  let right = n.right;
21835
- while (ts18.isParenthesizedExpression(right))
22512
+ while (ts19.isParenthesizedExpression(right))
21836
22513
  right = right.expression;
21837
- if (ts18.isPrefixUnaryExpression(right))
22514
+ if (ts19.isPrefixUnaryExpression(right))
21838
22515
  right = right.operand;
21839
- const kind = ts18.isNumericLiteral(right) ? "number" : right.kind === ts18.SyntaxKind.TrueKeyword || right.kind === ts18.SyntaxKind.FalseKeyword ? "boolean" : ts18.isStringLiteralLike(right) ? "string" : null;
22516
+ const kind = ts19.isNumericLiteral(right) ? "number" : right.kind === ts19.SyntaxKind.TrueKeyword || right.kind === ts19.SyntaxKind.FalseKeyword ? "boolean" : ts19.isStringLiteralLike(right) ? "string" : null;
21840
22517
  if (kind && !coalesceLiteralTypes.has(name))
21841
22518
  coalesceLiteralTypes.set(name, kind);
21842
22519
  }
21843
22520
  }
21844
- ts18.forEachChild(n, visit3);
22521
+ ts19.forEachChild(n, visit3);
21845
22522
  };
21846
22523
  visit3(sf);
21847
22524
  };
@@ -21952,33 +22629,33 @@ function augmentInheritedPropAccesses(ir) {
21952
22629
  }
21953
22630
  }
21954
22631
  function parseStaticStringConst(source) {
21955
- const sf = ts18.createSourceFile("__const.ts", `const __x = (${source});`, ts18.ScriptTarget.Latest, false);
22632
+ const sf = ts19.createSourceFile("__const.ts", `const __x = (${source});`, ts19.ScriptTarget.Latest, false);
21956
22633
  const stmt = sf.statements[0];
21957
- if (!stmt || !ts18.isVariableStatement(stmt))
22634
+ if (!stmt || !ts19.isVariableStatement(stmt))
21958
22635
  return null;
21959
22636
  let init = stmt.declarationList.declarations[0]?.initializer;
21960
- while (init && ts18.isParenthesizedExpression(init))
22637
+ while (init && ts19.isParenthesizedExpression(init))
21961
22638
  init = init.expression;
21962
22639
  if (!init)
21963
22640
  return null;
21964
- if (ts18.isStringLiteral(init) || ts18.isNoSubstitutionTemplateLiteral(init)) {
22641
+ if (ts19.isStringLiteral(init) || ts19.isNoSubstitutionTemplateLiteral(init)) {
21965
22642
  return init.text;
21966
22643
  }
21967
22644
  return evalStringArrayJoin(source);
21968
22645
  }
21969
22646
  function evalTemplateOfStringConsts(source, resolved) {
21970
- const sf = ts18.createSourceFile("__const.ts", `const __x = (${source});`, ts18.ScriptTarget.Latest, false);
22647
+ const sf = ts19.createSourceFile("__const.ts", `const __x = (${source});`, ts19.ScriptTarget.Latest, false);
21971
22648
  const stmt = sf.statements[0];
21972
- if (!stmt || !ts18.isVariableStatement(stmt))
22649
+ if (!stmt || !ts19.isVariableStatement(stmt))
21973
22650
  return null;
21974
22651
  let init = stmt.declarationList.declarations[0]?.initializer;
21975
- while (init && ts18.isParenthesizedExpression(init))
22652
+ while (init && ts19.isParenthesizedExpression(init))
21976
22653
  init = init.expression;
21977
- if (!init || !ts18.isTemplateExpression(init))
22654
+ if (!init || !ts19.isTemplateExpression(init))
21978
22655
  return null;
21979
22656
  let out = init.head.text;
21980
22657
  for (const span of init.templateSpans) {
21981
- if (!ts18.isIdentifier(span.expression))
22658
+ if (!ts19.isIdentifier(span.expression))
21982
22659
  return null;
21983
22660
  const value = resolved.get(span.expression.text);
21984
22661
  if (value === undefined)
@@ -22009,30 +22686,30 @@ function lookupStaticRecordLiteral(objectName, key, constants) {
22009
22686
  const constInfo = (constants ?? []).find((c) => c.name === objectName && c.isModule);
22010
22687
  if (constInfo?.value === undefined)
22011
22688
  return null;
22012
- const sf = ts18.createSourceFile("__rec.ts", `(${constInfo.value})`, ts18.ScriptTarget.Latest, true);
22689
+ const sf = ts19.createSourceFile("__rec.ts", `(${constInfo.value})`, ts19.ScriptTarget.Latest, true);
22013
22690
  if (sf.statements.length !== 1)
22014
22691
  return null;
22015
22692
  const stmt = sf.statements[0];
22016
- if (!ts18.isExpressionStatement(stmt))
22693
+ if (!ts19.isExpressionStatement(stmt))
22017
22694
  return null;
22018
22695
  let parsed = stmt.expression;
22019
- while (ts18.isParenthesizedExpression(parsed))
22696
+ while (ts19.isParenthesizedExpression(parsed))
22020
22697
  parsed = parsed.expression;
22021
- if (!ts18.isObjectLiteralExpression(parsed))
22698
+ if (!ts19.isObjectLiteralExpression(parsed))
22022
22699
  return null;
22023
22700
  for (const prop of parsed.properties) {
22024
- if (!ts18.isPropertyAssignment(prop))
22701
+ if (!ts19.isPropertyAssignment(prop))
22025
22702
  continue;
22026
22703
  const name = prop.name;
22027
- const propKey = ts18.isIdentifier(name) || ts18.isStringLiteral(name) || ts18.isNoSubstitutionTemplateLiteral(name) ? name.text : null;
22704
+ const propKey = ts19.isIdentifier(name) || ts19.isStringLiteral(name) || ts19.isNoSubstitutionTemplateLiteral(name) ? name.text : null;
22028
22705
  if (propKey !== key)
22029
22706
  continue;
22030
22707
  let v = prop.initializer;
22031
- while (ts18.isParenthesizedExpression(v))
22708
+ while (ts19.isParenthesizedExpression(v))
22032
22709
  v = v.expression;
22033
- if (ts18.isNumericLiteral(v))
22710
+ if (ts19.isNumericLiteral(v))
22034
22711
  return { kind: "number", text: v.text };
22035
- if (ts18.isStringLiteral(v) || ts18.isNoSubstitutionTemplateLiteral(v)) {
22712
+ if (ts19.isStringLiteral(v) || ts19.isNoSubstitutionTemplateLiteral(v)) {
22036
22713
  return { kind: "string", text: v.text };
22037
22714
  }
22038
22715
  return null;
@@ -22040,28 +22717,28 @@ function lookupStaticRecordLiteral(objectName, key, constants) {
22040
22717
  return null;
22041
22718
  }
22042
22719
  function evalStringArrayJoin(source) {
22043
- const sf = ts18.createSourceFile("__join.ts", `const __x = (${source});`, ts18.ScriptTarget.Latest, false);
22720
+ const sf = ts19.createSourceFile("__join.ts", `const __x = (${source});`, ts19.ScriptTarget.Latest, false);
22044
22721
  const stmt = sf.statements[0];
22045
- if (!stmt || !ts18.isVariableStatement(stmt))
22722
+ if (!stmt || !ts19.isVariableStatement(stmt))
22046
22723
  return null;
22047
22724
  let node = stmt.declarationList.declarations[0]?.initializer;
22048
- while (node && ts18.isParenthesizedExpression(node))
22725
+ while (node && ts19.isParenthesizedExpression(node))
22049
22726
  node = node.expression;
22050
- if (!node || !ts18.isCallExpression(node))
22727
+ if (!node || !ts19.isCallExpression(node))
22051
22728
  return null;
22052
22729
  const callee = node.expression;
22053
- if (!ts18.isPropertyAccessExpression(callee))
22730
+ if (!ts19.isPropertyAccessExpression(callee))
22054
22731
  return null;
22055
22732
  if (callee.name.text !== "join")
22056
22733
  return null;
22057
22734
  let recv = callee.expression;
22058
- while (ts18.isParenthesizedExpression(recv))
22735
+ while (ts19.isParenthesizedExpression(recv))
22059
22736
  recv = recv.expression;
22060
- if (!ts18.isArrayLiteralExpression(recv))
22737
+ if (!ts19.isArrayLiteralExpression(recv))
22061
22738
  return null;
22062
22739
  const parts = [];
22063
22740
  for (const el of recv.elements) {
22064
- if (ts18.isStringLiteral(el) || ts18.isNoSubstitutionTemplateLiteral(el)) {
22741
+ if (ts19.isStringLiteral(el) || ts19.isNoSubstitutionTemplateLiteral(el)) {
22065
22742
  parts.push(el.text);
22066
22743
  } else {
22067
22744
  return null;
@@ -22070,7 +22747,7 @@ function evalStringArrayJoin(source) {
22070
22747
  let sep2 = ",";
22071
22748
  if (node.arguments.length >= 1) {
22072
22749
  const arg = node.arguments[0];
22073
- if (ts18.isStringLiteral(arg) || ts18.isNoSubstitutionTemplateLiteral(arg))
22750
+ if (ts19.isStringLiteral(arg) || ts19.isNoSubstitutionTemplateLiteral(arg))
22074
22751
  sep2 = arg.text;
22075
22752
  else
22076
22753
  return null;
@@ -22078,11 +22755,11 @@ function evalStringArrayJoin(source) {
22078
22755
  return parts.join(sep2);
22079
22756
  }
22080
22757
  function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
22081
- if (!ts18.isElementAccessExpression(val))
22758
+ if (!ts19.isElementAccessExpression(val))
22082
22759
  return null;
22083
22760
  const obj = val.expression;
22084
22761
  const arg = val.argumentExpression;
22085
- if (!ts18.isIdentifier(obj) || !ts18.isIdentifier(arg))
22762
+ if (!ts19.isIdentifier(obj) || !ts19.isIdentifier(arg))
22086
22763
  return null;
22087
22764
  let indexPropName;
22088
22765
  let defaultKey;
@@ -22098,35 +22775,35 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
22098
22775
  const constInfo = localConstants.find((c) => c.name === obj.text && c.isModule);
22099
22776
  if (constInfo?.value === undefined)
22100
22777
  return null;
22101
- const sf = ts18.createSourceFile("__rec.ts", `(${constInfo.value})`, ts18.ScriptTarget.Latest, true);
22778
+ const sf = ts19.createSourceFile("__rec.ts", `(${constInfo.value})`, ts19.ScriptTarget.Latest, true);
22102
22779
  if (sf.statements.length !== 1)
22103
22780
  return null;
22104
22781
  const stmt = sf.statements[0];
22105
- if (!ts18.isExpressionStatement(stmt))
22782
+ if (!ts19.isExpressionStatement(stmt))
22106
22783
  return null;
22107
22784
  let parsed = stmt.expression;
22108
- while (ts18.isParenthesizedExpression(parsed))
22785
+ while (ts19.isParenthesizedExpression(parsed))
22109
22786
  parsed = parsed.expression;
22110
- if (!ts18.isObjectLiteralExpression(parsed))
22787
+ if (!ts19.isObjectLiteralExpression(parsed))
22111
22788
  return null;
22112
22789
  const entries = [];
22113
22790
  for (const prop of parsed.properties) {
22114
- if (!ts18.isPropertyAssignment(prop))
22791
+ if (!ts19.isPropertyAssignment(prop))
22115
22792
  return null;
22116
22793
  let key;
22117
- if (ts18.isIdentifier(prop.name)) {
22794
+ if (ts19.isIdentifier(prop.name)) {
22118
22795
  key = prop.name.text;
22119
- } else if (ts18.isStringLiteral(prop.name) || ts18.isNoSubstitutionTemplateLiteral(prop.name)) {
22796
+ } else if (ts19.isStringLiteral(prop.name) || ts19.isNoSubstitutionTemplateLiteral(prop.name)) {
22120
22797
  key = prop.name.text;
22121
22798
  } else {
22122
22799
  return null;
22123
22800
  }
22124
22801
  let v = prop.initializer;
22125
- while (ts18.isParenthesizedExpression(v))
22802
+ while (ts19.isParenthesizedExpression(v))
22126
22803
  v = v.expression;
22127
- if (ts18.isNumericLiteral(v)) {
22804
+ if (ts19.isNumericLiteral(v)) {
22128
22805
  entries.push({ key, value: { kind: "number", text: v.text } });
22129
- } else if (ts18.isStringLiteral(v) || ts18.isNoSubstitutionTemplateLiteral(v)) {
22806
+ } else if (ts19.isStringLiteral(v) || ts19.isNoSubstitutionTemplateLiteral(v)) {
22130
22807
  entries.push({ key, value: { kind: "string", text: v.text } });
22131
22808
  } else {
22132
22809
  return null;
@@ -22765,6 +23442,7 @@ function compileJSX(source, filePath, options) {
22765
23442
  const sortedRuntimeImports = [...runtimeImports].sort();
22766
23443
  const runtimeImportLine = sortedRuntimeImports.length > 0 ? `import { ${sortedRuntimeImports.join(", ")} } from '${RUNTIME_MODULE}'` : "";
22767
23444
  const externalImportLines = [];
23445
+ const isUsedAsValue = makeValueUsageTest(body);
22768
23446
  for (const imp of ctx.imports) {
22769
23447
  if (imp.isTypeOnly)
22770
23448
  continue;
@@ -22774,7 +23452,7 @@ function compileJSX(source, filePath, options) {
22774
23452
  externalImportLines.push(`import '${imp.source}'`);
22775
23453
  continue;
22776
23454
  }
22777
- 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);
23455
+ 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);
22778
23456
  if (used.length > 0) {
22779
23457
  externalImportLines.push(`import { ${used.join(", ")} } from '${imp.source}'`);
22780
23458
  }
@@ -22810,6 +23488,8 @@ function compileJSX(source, filePath, options) {
22810
23488
  if (!imp.source.startsWith("./") && !imp.source.startsWith("../"))
22811
23489
  continue;
22812
23490
  for (const spec of imp.specifiers) {
23491
+ if (spec.isTypeOnly)
23492
+ continue;
22813
23493
  if (ctx.importedClientSignalNames.has(spec.alias ?? spec.name)) {
22814
23494
  sources.add(imp.source);
22815
23495
  break;
@@ -22906,7 +23586,7 @@ function compileJSX(source, filePath, options) {
22906
23586
  return { files, errors };
22907
23587
  }
22908
23588
  // src/shared-program.ts
22909
- import ts19 from "typescript";
23589
+ import ts20 from "typescript";
22910
23590
  function commonParent(paths) {
22911
23591
  if (paths.length === 0)
22912
23592
  return process.cwd();
@@ -22927,10 +23607,10 @@ function commonParent(paths) {
22927
23607
  function createProgramForCorpus(files, options = {}) {
22928
23608
  const baseUrl = options.baseUrl ?? commonParent(files);
22929
23609
  const compilerOptions = {
22930
- target: ts19.ScriptTarget.Latest,
22931
- module: ts19.ModuleKind.ESNext,
22932
- moduleResolution: ts19.ModuleResolutionKind.Bundler,
22933
- jsx: ts19.JsxEmit.ReactJSX,
23610
+ target: ts20.ScriptTarget.Latest,
23611
+ module: ts20.ModuleKind.ESNext,
23612
+ moduleResolution: ts20.ModuleResolutionKind.Bundler,
23613
+ jsx: ts20.JsxEmit.ReactJSX,
22934
23614
  strict: true,
22935
23615
  skipLibCheck: true,
22936
23616
  noEmit: true,
@@ -22940,7 +23620,7 @@ function createProgramForCorpus(files, options = {}) {
22940
23620
  ...options.compilerOptions
22941
23621
  };
22942
23622
  const absolute = files.map((f) => path_default.resolve(f));
22943
- return ts19.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
23623
+ return ts20.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
22944
23624
  }
22945
23625
  // src/adapters/interface.ts
22946
23626
  class BaseAdapter {
@@ -23922,7 +24602,7 @@ function dangerousInnerHtmlDiagnostic(expr, loc, reason) {
23922
24602
  };
23923
24603
  }
23924
24604
  // src/combine-client-js.ts
23925
- import ts20 from "typescript";
24605
+ import ts21 from "typescript";
23926
24606
  var CHILD_PLACEHOLDER_RE = /import '\/\* @bf-child:(\w+) \*\/'/g;
23927
24607
  function combineParentChildClientJs(files) {
23928
24608
  const result = new Map;
@@ -23979,10 +24659,10 @@ function combineParentChildClientJs(files) {
23979
24659
  return result;
23980
24660
  }
23981
24661
  function parseAndMerge(content, importsBySource, otherImports, codeSections) {
23982
- const sourceFile = ts20.createSourceFile("combine.js", content, ts20.ScriptTarget.Latest, false, ts20.ScriptKind.JS);
24662
+ const sourceFile = ts21.createSourceFile("combine.js", content, ts21.ScriptTarget.Latest, false, ts21.ScriptKind.JS);
23983
24663
  const importSpans = [];
23984
24664
  for (const stmt of sourceFile.statements) {
23985
- if (!ts20.isImportDeclaration(stmt))
24665
+ if (!ts21.isImportDeclaration(stmt))
23986
24666
  continue;
23987
24667
  const start = stmt.getStart(sourceFile);
23988
24668
  const end = stmt.getEnd();
@@ -23992,8 +24672,8 @@ function parseAndMerge(content, importsBySource, otherImports, codeSections) {
23992
24672
  continue;
23993
24673
  const clause = stmt.importClause;
23994
24674
  const bindings = clause?.namedBindings;
23995
- const specifier = ts20.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
23996
- if (clause && !clause.name && bindings && ts20.isNamedImports(bindings)) {
24675
+ const specifier = ts21.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
24676
+ if (clause && !clause.name && bindings && ts21.isNamedImports(bindings)) {
23997
24677
  if (!importsBySource.has(specifier)) {
23998
24678
  importsBySource.set(specifier, new Set);
23999
24679
  }
@@ -24160,7 +24840,7 @@ function escapeRe(s) {
24160
24840
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
24161
24841
  }
24162
24842
  // src/debug.ts
24163
- import ts21 from "typescript";
24843
+ import ts22 from "typescript";
24164
24844
  function buildComponentGraph(source, filePath, componentName) {
24165
24845
  const ctx = analyzeComponent(source, filePath, componentName);
24166
24846
  if (!ctx.jsxReturn) {
@@ -25445,7 +26125,7 @@ function truncateExpr(expr, max = 40) {
25445
26125
  function exprReadsPropMember(expr, propsObjectName) {
25446
26126
  let sf;
25447
26127
  try {
25448
- sf = ts21.createSourceFile("__attr.tsx", `(${expr})`, ts21.ScriptTarget.Latest, true, ts21.ScriptKind.TSX);
26128
+ sf = ts22.createSourceFile("__attr.tsx", `(${expr})`, ts22.ScriptTarget.Latest, true, ts22.ScriptKind.TSX);
25449
26129
  } catch {
25450
26130
  return false;
25451
26131
  }
@@ -25453,11 +26133,11 @@ function exprReadsPropMember(expr, propsObjectName) {
25453
26133
  const visit3 = (n) => {
25454
26134
  if (found)
25455
26135
  return;
25456
- if (ts21.isPropertyAccessExpression(n) && ts21.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
26136
+ if (ts22.isPropertyAccessExpression(n) && ts22.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
25457
26137
  found = true;
25458
26138
  return;
25459
26139
  }
25460
- ts21.forEachChild(n, visit3);
26140
+ ts22.forEachChild(n, visit3);
25461
26141
  };
25462
26142
  visit3(sf);
25463
26143
  return found;
@@ -25527,7 +26207,7 @@ function findSourceFile2(meta) {
25527
26207
  return null;
25528
26208
  }
25529
26209
  // src/profiler.ts
25530
- import ts22 from "typescript";
26210
+ import ts23 from "typescript";
25531
26211
  var PROFILE_SCHEMA_VERSION = 1;
25532
26212
  var DEFAULT_FANOUT_THRESHOLD = 8;
25533
26213
  function buildStaticBudget(source, filePath, componentName, options = {}) {
@@ -25797,15 +26477,15 @@ function joinProfilerEvents(events, index) {
25797
26477
  return { joined, unattributed, diagnostics };
25798
26478
  }
25799
26479
  function findUninstrumentedEffects(source, filePath, instrumentedLines) {
25800
- const sf = ts22.createSourceFile(filePath, source, ts22.ScriptTarget.Latest, true, ts22.ScriptKind.TSX);
26480
+ const sf = ts23.createSourceFile(filePath, source, ts23.ScriptTarget.Latest, true, ts23.ScriptKind.TSX);
25801
26481
  const out = [];
25802
26482
  const visit3 = (node) => {
25803
- if (ts22.isCallExpression(node) && ts22.isIdentifier(node.expression) && node.expression.text === "createEffect") {
26483
+ if (ts23.isCallExpression(node) && ts23.isIdentifier(node.expression) && node.expression.text === "createEffect") {
25804
26484
  const line = sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;
25805
26485
  if (!instrumentedLines.has(line))
25806
26486
  out.push({ file: filePath, line });
25807
26487
  }
25808
- ts22.forEachChild(node, visit3);
26488
+ ts23.forEachChild(node, visit3);
25809
26489
  };
25810
26490
  visit3(sf);
25811
26491
  out.sort((a, b) => a.line - b.line);
@@ -26113,13 +26793,13 @@ function assessBatchSafety(args) {
26113
26793
  const signalGetters = new Set(args.graph.signals.map((s) => s.name));
26114
26794
  let sf;
26115
26795
  try {
26116
- sf = ts22.createSourceFile("__h.ts", `const __h = ${args.handler}`, ts22.ScriptTarget.Latest, true);
26796
+ sf = ts23.createSourceFile("__h.ts", `const __h = ${args.handler}`, ts23.ScriptTarget.Latest, true);
26117
26797
  } catch {
26118
26798
  return "unverified";
26119
26799
  }
26120
26800
  const calls = [];
26121
26801
  const visit3 = (node) => {
26122
- if (ts22.isCallExpression(node) && ts22.isIdentifier(node.expression)) {
26802
+ if (ts23.isCallExpression(node) && ts23.isIdentifier(node.expression)) {
26123
26803
  const name = node.expression.text;
26124
26804
  if (setters.has(name))
26125
26805
  calls.push({ pos: node.getStart(sf), kind: "write" });
@@ -26128,7 +26808,7 @@ function assessBatchSafety(args) {
26128
26808
  else if (!signalGetters.has(name) && !memoNames.has(name))
26129
26809
  calls.push({ pos: node.getStart(sf), kind: "risky" });
26130
26810
  }
26131
- ts22.forEachChild(node, visit3);
26811
+ ts23.forEachChild(node, visit3);
26132
26812
  };
26133
26813
  visit3(sf);
26134
26814
  calls.sort((a, b) => a.pos - b.pos);
@@ -26805,6 +27485,7 @@ export {
26805
27485
  listComponentFunctions,
26806
27486
  jsxToIR,
26807
27487
  joinProfilerEvents,
27488
+ isValueReferenceIdentifier,
26808
27489
  isValidHelperId,
26809
27490
  isSupported,
26810
27491
  isStringTypedOperand,
@@ -26879,6 +27560,7 @@ export {
26879
27560
  computeSsrSeedPlan,
26880
27561
  compileJSX,
26881
27562
  combineParentChildClientJs,
27563
+ collectValueReferencedNames,
26882
27564
  collectModuleStringConsts,
26883
27565
  collectLoopBoundNames,
26884
27566
  collectContextConsumers,