@barefootjs/cli 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 (2) hide show
  1. package/dist/index.js +1171 -425
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -5553,6 +5553,13 @@ var init_errors = __esm({
5553
5553
  // so an unimported tag with the built-in name is either a forgotten import
5554
5554
  // or an undeclared component — fail loud with the import to add.
5555
5555
  BUILTIN_REQUIRES_IMPORT: "BF054",
5556
+ // A relative `.ts` module inlined into a client bundle (`resolveRelativeImports`'s
5557
+ // top-level IIFE wrap) was asked for a name it does not export. The IIFE's
5558
+ // `return { … }` has no binding for that name, so the reference throws
5559
+ // `ReferenceError: <name> is not defined` at load — killing the page's
5560
+ // client JS before hydrate. Fail the build instead of shipping the
5561
+ // dangling reference (#2432).
5562
+ INLINED_IMPORT_MISSING_EXPORT: "BF055",
5556
5563
  // Init statement errors (BF052)
5557
5564
  UNDECLARED_INIT_STATEMENT_REFERENCE: "BF052",
5558
5565
  // Stripped-import diagnostics (BF053) — a relative import was removed
@@ -5614,6 +5621,7 @@ var init_errors = __esm({
5614
5621
  [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.",
5615
5622
  [ErrorCodes.UNDECLARED_INIT_STATEMENT_REFERENCE]: "Init statement references an undeclared identifier. Declare it at module scope, inside the component, or import it \u2014 otherwise ESM strict mode throws ReferenceError at runtime.",
5616
5623
  [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 \u2014 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.",
5624
+ [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.",
5617
5625
  [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.",
5618
5626
  [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.",
5619
5627
  [ErrorCodes.STAGE_AWAIT_IN_TEMPLATE]: "AwaitExpression in template scope. The generated template and init functions are synchronous \u2014 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.",
@@ -7874,6 +7882,7 @@ function importsBrowserOnlyClientApi(ctx2) {
7874
7882
  if (imp.source !== "@barefootjs/client") continue;
7875
7883
  if (imp.isTypeOnly) continue;
7876
7884
  for (const spec of imp.specifiers) {
7885
+ if (spec.isTypeOnly) continue;
7877
7886
  const importedName = spec.name;
7878
7887
  if (BROWSER_ONLY_CLIENT_APIS.has(importedName)) return true;
7879
7888
  }
@@ -11161,7 +11170,8 @@ function transformConditionalBranch(node, ctx2) {
11161
11170
  const callsReactive = exprCallsReactiveGetters(node, ctx2);
11162
11171
  const hasCalls = exprHasFunctionCalls(node);
11163
11172
  const reactive = isReactiveExpression(exprText, ctx2, node) || isReactiveOrigin(branchOrigin);
11164
- const needsSlot = reactive || callsReactive;
11173
+ const refsLoopParam = branchOrigin.freeRefs?.some((r2) => r2.kind === "render-item") ?? false;
11174
+ const needsSlot = reactive || callsReactive || refsLoopParam;
11165
11175
  const slotId = needsSlot ? generateSlotId(ctx2) : null;
11166
11176
  return {
11167
11177
  type: "expression",
@@ -14761,19 +14771,54 @@ function summarizeLoopChildBranch(node, ctx2, siblingOffsets, loopParam, loopPar
14761
14771
  // on the branch root yields exactly this branch's direct bindings
14762
14772
  // without re-collecting what a nested arm already owns (#2347).
14763
14773
  reactiveAttrs: collectLoopChildReactiveAttrs(node, ctx2, loopParam, loopParamBindings, true),
14764
- // Skip when the branch's ENTIRE content is a single bare `expression`
14765
- // (no wrapping element) e.g. a hoisted `renderNode={(n) => <Pill/>}`
14766
- // callback (#1211/#1213). That value is already fully re-evaluated and
14767
- // spliced via `__bfSlot` whenever `insert()` (re-)mounts this branch;
14768
- // an *additional* nested createEffect for the same expression re-calls
14769
- // it and creates a second, independent live element (a JSX-callback
14770
- // result isn't idempotent to re-invoke the way a plain signal read is),
14771
- // and the loop-child arm's `$t()`-based anchor lookup designed for
14772
- // text nodes doesn't cleanly displace an already-mounted Element,
14773
- // so the second instance lands beside the first instead of replacing
14774
- // it. A text *nested inside* a static wrapper element in the branch
14775
- // (the element-descent case) is unaffected and still collected below.
14776
- reactiveTexts: node.type === "expression" ? [] : collectLoopChildReactiveTexts(node, ctx2, loopParam, loopParamBindings, true)
14774
+ // Skip ONLY when the branch's entire content is a single bare
14775
+ // `expression` (no wrapping element) that MAY yield a live DOM node
14776
+ // i.e. it contains a call anywhere (`node.hasFunctionCalls`, computed
14777
+ // by the AST walk in `exprHasFunctionCalls`/jsx-to-ir.ts, recursively
14778
+ // catches a call nested in a template literal or a nested ternary, not
14779
+ // just a top-level call). A call can return an Element (a hoisted
14780
+ // `renderNode={(n) => <Pill/>}` callback lowered to a component call,
14781
+ // #1211/#1213) and the compiler cannot tell from syntax whether it does
14782
+ // — both `renderChild(...)` and `_p.renderCell(...)` are a
14783
+ // `CallExpression` so this stays conservative for ANY call, not just
14784
+ // ones known to return JSX. Re-evaluating a non-idempotent call inside
14785
+ // an *additional* nested createEffect (on top of the eval already done
14786
+ // for the `__bfSlot`-wrapped splice whenever `insert()` (re-)mounts this
14787
+ // branch) would call it again on every unrelated tick and discard the
14788
+ // previous element's listeners/state.
14789
+ //
14790
+ // Everything else — a property access (`row.label`), an identifier, a
14791
+ // literal, a template literal, string concatenation, or a nested
14792
+ // ternary of those — cannot itself construct a DOM node (only a JSX
14793
+ // literal or a call can, and a JSX literal branch is never `type:
14794
+ // 'expression'` in the first place — see `transformJsxExpression`), so
14795
+ // it is safe to collect. This is the fix for the loop-branch-stale-text
14796
+ // defect: a keyed loop row whose branch is e.g. `row.done ? row.label :
14797
+ // 'pending'` previously had NO update path at all when `row.label`
14798
+ // changed without `row.done` flipping — `insert()` (runtime/insert.ts)
14799
+ // correctly no-ops when its condition is unchanged (branch-internal
14800
+ // updates are deliberately the effect system's job, not DOM
14801
+ // replacement's), but with reactiveTexts always `[]` for this shape,
14802
+ // no effect existed either, so the branch was frozen at its mount-time
14803
+ // value. The stale rationale in a prior version of this comment blamed
14804
+ // "the loop-child arm's `$t()`-based anchor lookup", but `$t()` no
14805
+ // longer exists — it was one of four content mechanisms deleted by the
14806
+ // slot-unification work. The current claim door
14807
+ // (`stringifyLoopChildArm` → `lazySlots(..., kind: 'markup')` →
14808
+ // `writeMarkup`, runtime/claim-slots.ts) clears the claimed range and
14809
+ // splices the Node by identity, so "lands beside the first" cannot
14810
+ // happen through it; only the call's non-idempotence still applies, and
14811
+ // that alone is why the skip narrows rather than disappears.
14812
+ //
14813
+ // Collecting here is necessary but not sufficient: `n.slotId` must also
14814
+ // be set for `collectLoopChildReactiveTexts` (ir-to-client-js/
14815
+ // reactivity.ts) to do anything — see `transformConditionalBranch`'s
14816
+ // `refsLoopParam` check (jsx-to-ir.ts) for the matching half of this fix
14817
+ // that gives a bare loop-item-reading branch a slotId at all, which also
14818
+ // makes `irToHtmlTemplate` emit its `<!--bf:sN-->…<!--/-->` marker (the
14819
+ // same call builds both the SSR and the CSR/hydration template, so the
14820
+ // two can't disagree on shape).
14821
+ reactiveTexts: node.type === "expression" && node.hasFunctionCalls ? [] : collectLoopChildReactiveTexts(node, ctx2, loopParam, loopParamBindings, true)
14777
14822
  };
14778
14823
  }
14779
14824
  var EMPTY_RENDER_EXPRS, branchInnerLoopOptions;
@@ -15238,6 +15283,64 @@ var init_compute_prop_usage = __esm({
15238
15283
  }
15239
15284
  });
15240
15285
 
15286
+ // ../jsx/src/value-references.ts
15287
+ import ts13 from "typescript";
15288
+ function isValueReferenceIdentifier(id2) {
15289
+ const parent2 = id2.parent;
15290
+ if (!parent2) return false;
15291
+ if (ts13.isPropertyAccessExpression(parent2) && parent2.name === id2) return false;
15292
+ if (ts13.isPropertyAssignment(parent2) && parent2.name === id2) return false;
15293
+ if ((ts13.isMethodDeclaration(parent2) || ts13.isGetAccessorDeclaration(parent2) || ts13.isSetAccessorDeclaration(parent2)) && parent2.name === id2) {
15294
+ return false;
15295
+ }
15296
+ if (ts13.isVariableDeclaration(parent2) && parent2.name === id2) return false;
15297
+ if (ts13.isFunctionDeclaration(parent2) && parent2.name === id2) return false;
15298
+ if (ts13.isFunctionExpression(parent2) && parent2.name === id2) return false;
15299
+ if (ts13.isClassDeclaration(parent2) && parent2.name === id2) return false;
15300
+ if (ts13.isClassExpression(parent2) && parent2.name === id2) return false;
15301
+ if (ts13.isParameter(parent2) && parent2.name === id2) return false;
15302
+ if (ts13.isBindingElement(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
15303
+ if (ts13.isLabeledStatement(parent2) && parent2.label === id2) return false;
15304
+ if (ts13.isBreakOrContinueStatement(parent2) && parent2.label === id2) return false;
15305
+ if (ts13.isImportSpecifier(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
15306
+ if (ts13.isExportSpecifier(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
15307
+ if (ts13.isImportClause(parent2) && parent2.name === id2) return false;
15308
+ if (ts13.isNamespaceImport(parent2) && parent2.name === id2) return false;
15309
+ if (ts13.isQualifiedName(parent2) && parent2.right === id2) return false;
15310
+ return true;
15311
+ }
15312
+ function collectValueReferencedNames(code) {
15313
+ let sourceFile;
15314
+ try {
15315
+ sourceFile = ts13.createSourceFile(
15316
+ "generated.js",
15317
+ code,
15318
+ ts13.ScriptTarget.Latest,
15319
+ /*setParentNodes*/
15320
+ true,
15321
+ ts13.ScriptKind.JS
15322
+ );
15323
+ } catch {
15324
+ return null;
15325
+ }
15326
+ const diagnostics = sourceFile.parseDiagnostics;
15327
+ if (diagnostics && diagnostics.length > 0) return null;
15328
+ const names = /* @__PURE__ */ new Set();
15329
+ function visit3(node) {
15330
+ if (ts13.isIdentifier(node) && isValueReferenceIdentifier(node)) {
15331
+ names.add(node.text);
15332
+ }
15333
+ ts13.forEachChild(node, visit3);
15334
+ }
15335
+ visit3(sourceFile);
15336
+ return names;
15337
+ }
15338
+ var init_value_references = __esm({
15339
+ "../jsx/src/value-references.ts"() {
15340
+ "use strict";
15341
+ }
15342
+ });
15343
+
15241
15344
  // ../jsx/src/ir-to-client-js/imports.ts
15242
15345
  function detectUsedImports(code) {
15243
15346
  const used = /* @__PURE__ */ new Set();
@@ -15263,7 +15366,7 @@ function collectUserDomImports(ir) {
15263
15366
  for (const imp of ir.metadata.imports) {
15264
15367
  if (runtimeSources.has(imp.source) && !imp.isTypeOnly) {
15265
15368
  for (const spec of imp.specifiers) {
15266
- if (!spec.isDefault && !spec.isNamespace) {
15369
+ if (!spec.isDefault && !spec.isNamespace && !spec.isTypeOnly) {
15267
15370
  if (isClientBuiltinName(spec.name)) continue;
15268
15371
  userImports.push(spec.alias ? `${spec.name} as ${spec.alias}` : spec.name);
15269
15372
  }
@@ -15272,9 +15375,22 @@ function collectUserDomImports(ir) {
15272
15375
  }
15273
15376
  return userImports;
15274
15377
  }
15378
+ function makeValueUsageTest(generatedCode) {
15379
+ let referenced;
15380
+ return (localName2) => {
15381
+ if (referenced === void 0) {
15382
+ referenced = collectValueReferencedNames(generatedCode);
15383
+ }
15384
+ if (referenced !== null) {
15385
+ return referenced.has(localName2);
15386
+ }
15387
+ return generatedCode.includes(localName2);
15388
+ };
15389
+ }
15275
15390
  function collectExternalImports(ir, generatedCode, localImportPrefixes) {
15276
15391
  const componentNames = collectComponentNames(ir.root);
15277
15392
  const importLines = [];
15393
+ const isUsedAsValue = makeValueUsageTest(generatedCode);
15278
15394
  for (const imp of ir.metadata.imports) {
15279
15395
  if (imp.isTypeOnly) continue;
15280
15396
  if (imp.source === "@barefootjs/client" || imp.source === RUNTIME_MODULE) continue;
@@ -15285,9 +15401,10 @@ function collectExternalImports(ir, generatedCode, localImportPrefixes) {
15285
15401
  }
15286
15402
  const usedSpecs = [];
15287
15403
  for (const spec of imp.specifiers) {
15404
+ if (spec.isTypeOnly) continue;
15288
15405
  const localName2 = spec.alias || spec.name;
15289
15406
  if (componentNames.has(localName2)) continue;
15290
- if (new RegExp(`\\b${localName2}\\b`).test(generatedCode)) {
15407
+ if (isUsedAsValue(localName2)) {
15291
15408
  usedSpecs.push(spec.alias ? `${spec.name} as ${spec.alias}` : spec.name);
15292
15409
  }
15293
15410
  }
@@ -15327,6 +15444,7 @@ var init_imports = __esm({
15327
15444
  "../jsx/src/ir-to-client-js/imports.ts"() {
15328
15445
  "use strict";
15329
15446
  init_builtins();
15447
+ init_value_references();
15330
15448
  RUNTIME_IMPORT_CANDIDATES = [
15331
15449
  "createSignal",
15332
15450
  "createMemo",
@@ -15339,6 +15457,7 @@ var init_imports = __esm({
15339
15457
  "getLoopNodes",
15340
15458
  "mapArray",
15341
15459
  "mapArrayAnchored",
15460
+ "mapArrayLazy",
15342
15461
  "patchLeaf",
15343
15462
  "createDisposableEffect",
15344
15463
  "createComponent",
@@ -15370,8 +15489,16 @@ var init_imports = __esm({
15370
15489
  // Claim-plan interpreter (slot unification A2/A3, spec/slot-unification.md)
15371
15490
  // — the "one claim mechanism" that replaced `patchSlotRange` and
15372
15491
  // `updateClientMarker` (both deleted) as the content-slot update door.
15492
+ // `lazyClaimSlots` is the read-capable twin of `lazySlots` over the same
15493
+ // claim — emitted only by lazy loops that seed an outer-involving TEXT
15494
+ // binding by read-compare-write (§9.3(1)).
15495
+ // `textOrNode` is the 'text' door's Node guard: a child-position value that
15496
+ // turns out to be a live Node must reach the writer as a Node so the claim
15497
+ // can promote to 'markup', never as `String(node)`.
15373
15498
  "claimSlots",
15374
15499
  "lazySlots",
15500
+ "lazyClaimSlots",
15501
+ "textOrNode",
15375
15502
  // Profile mode (#1690, SR3) — turn-boundary markers around event handlers.
15376
15503
  "beginTurn",
15377
15504
  "endTurn",
@@ -15430,23 +15557,23 @@ var init_lowering_registry = __esm({
15430
15557
  });
15431
15558
 
15432
15559
  // ../jsx/src/relocate.ts
15433
- import ts13 from "typescript";
15560
+ import ts14 from "typescript";
15434
15561
  function classify(name2, env) {
15435
15562
  return env.bindings.get(name2) ?? "global";
15436
15563
  }
15437
15564
  function collectFreeRefs(node) {
15438
15565
  const refs = /* @__PURE__ */ new Map();
15439
15566
  function visit3(n, parent2) {
15440
- if (ts13.isIdentifier(n)) {
15441
- if (parent2 && ts13.isPropertyAccessExpression(parent2) && parent2.name === n) return;
15442
- if (parent2 && ts13.isPropertyAssignment(parent2) && parent2.name === n) return;
15443
- if (parent2 && ts13.isShorthandPropertyAssignment(parent2) && parent2.name === n) return;
15567
+ if (ts14.isIdentifier(n)) {
15568
+ if (parent2 && ts14.isPropertyAccessExpression(parent2) && parent2.name === n) return;
15569
+ if (parent2 && ts14.isPropertyAssignment(parent2) && parent2.name === n) return;
15570
+ if (parent2 && ts14.isShorthandPropertyAssignment(parent2) && parent2.name === n) return;
15444
15571
  const list = refs.get(n.text) ?? [];
15445
15572
  list.push(n);
15446
15573
  refs.set(n.text, list);
15447
15574
  return;
15448
15575
  }
15449
- ts13.forEachChild(n, (child) => visit3(child, n));
15576
+ ts14.forEachChild(n, (child) => visit3(child, n));
15450
15577
  }
15451
15578
  visit3(node);
15452
15579
  return refs;
@@ -15547,9 +15674,9 @@ function isInlinableInTemplate(value2, env) {
15547
15674
  return { ok: true, rewrittenValue: r2.text, decisions: r2.decisions };
15548
15675
  }
15549
15676
  function getCalleeIdentifierPath(callee) {
15550
- if (ts13.isParenthesizedExpression(callee)) return getCalleeIdentifierPath(callee.expression);
15551
- if (ts13.isIdentifier(callee)) return callee.text;
15552
- if (ts13.isPropertyAccessExpression(callee)) {
15677
+ if (ts14.isParenthesizedExpression(callee)) return getCalleeIdentifierPath(callee.expression);
15678
+ if (ts14.isIdentifier(callee)) return callee.text;
15679
+ if (ts14.isPropertyAccessExpression(callee)) {
15553
15680
  const left = getCalleeIdentifierPath(callee.expression);
15554
15681
  if (left === null) return null;
15555
15682
  return `${left}.${callee.name.text}`;
@@ -15557,9 +15684,9 @@ function getCalleeIdentifierPath(callee) {
15557
15684
  return null;
15558
15685
  }
15559
15686
  function getCalleeLeftmostIdentifier(callee) {
15560
- if (ts13.isParenthesizedExpression(callee)) return getCalleeLeftmostIdentifier(callee.expression);
15561
- if (ts13.isIdentifier(callee)) return callee.text;
15562
- if (ts13.isPropertyAccessExpression(callee)) {
15687
+ if (ts14.isParenthesizedExpression(callee)) return getCalleeLeftmostIdentifier(callee.expression);
15688
+ if (ts14.isIdentifier(callee)) return callee.text;
15689
+ if (ts14.isPropertyAccessExpression(callee)) {
15563
15690
  return getCalleeLeftmostIdentifier(callee.expression);
15564
15691
  }
15565
15692
  return null;
@@ -15598,17 +15725,17 @@ function isCallAcceptedByAdapter(call, env) {
15598
15725
  }
15599
15726
  function parseExpressionNode(text) {
15600
15727
  try {
15601
- const sf = ts13.createSourceFile(
15728
+ const sf = ts14.createSourceFile(
15602
15729
  "__inline_check__.ts",
15603
15730
  `(${text});`,
15604
- ts13.ScriptTarget.Latest,
15731
+ ts14.ScriptTarget.Latest,
15605
15732
  false,
15606
- ts13.ScriptKind.TS
15733
+ ts14.ScriptKind.TS
15607
15734
  );
15608
15735
  const stmt = sf.statements[0];
15609
- if (!stmt || !ts13.isExpressionStatement(stmt)) return null;
15736
+ if (!stmt || !ts14.isExpressionStatement(stmt)) return null;
15610
15737
  const inner = stmt.expression;
15611
- return ts13.isParenthesizedExpression(inner) ? inner.expression : inner;
15738
+ return ts14.isParenthesizedExpression(inner) ? inner.expression : inner;
15612
15739
  } catch {
15613
15740
  return null;
15614
15741
  }
@@ -15622,8 +15749,8 @@ function hasCallWithBridgedArg(node, decisions, env) {
15622
15749
  let found = false;
15623
15750
  function visit3(n) {
15624
15751
  if (found) return;
15625
- if (ts13.isCallExpression(n) || ts13.isNewExpression(n)) {
15626
- const accepted = ts13.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
15752
+ if (ts14.isCallExpression(n) || ts14.isNewExpression(n)) {
15753
+ const accepted = ts14.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
15627
15754
  if (!accepted) {
15628
15755
  const args2 = n.arguments;
15629
15756
  if (args2) {
@@ -15636,7 +15763,7 @@ function hasCallWithBridgedArg(node, decisions, env) {
15636
15763
  }
15637
15764
  }
15638
15765
  }
15639
- ts13.forEachChild(n, visit3);
15766
+ ts14.forEachChild(n, visit3);
15640
15767
  }
15641
15768
  visit3(node);
15642
15769
  return found;
@@ -15645,13 +15772,13 @@ function hasZeroArgCall(node, env) {
15645
15772
  let found = false;
15646
15773
  function visit3(n) {
15647
15774
  if (found) return;
15648
- if (ts13.isCallExpression(n) && n.arguments.length === 0) {
15775
+ if (ts14.isCallExpression(n) && n.arguments.length === 0) {
15649
15776
  if (!isCallAcceptedByAdapter(n, env)) {
15650
15777
  found = true;
15651
15778
  return;
15652
15779
  }
15653
15780
  }
15654
- ts13.forEachChild(n, visit3);
15781
+ ts14.forEachChild(n, visit3);
15655
15782
  }
15656
15783
  visit3(node);
15657
15784
  return found;
@@ -15660,25 +15787,25 @@ function containsAnyIdentifier(node, names) {
15660
15787
  let found = false;
15661
15788
  function visit3(n) {
15662
15789
  if (found) return;
15663
- if (ts13.isPropertyAccessExpression(n)) {
15790
+ if (ts14.isPropertyAccessExpression(n)) {
15664
15791
  visit3(n.expression);
15665
15792
  return;
15666
15793
  }
15667
- if (ts13.isPropertyAssignment(n)) {
15794
+ if (ts14.isPropertyAssignment(n)) {
15668
15795
  visit3(n.initializer);
15669
15796
  return;
15670
15797
  }
15671
- if (ts13.isShorthandPropertyAssignment(n)) {
15672
- if (ts13.isIdentifier(n.name) && names.has(n.name.text)) {
15798
+ if (ts14.isShorthandPropertyAssignment(n)) {
15799
+ if (ts14.isIdentifier(n.name) && names.has(n.name.text)) {
15673
15800
  found = true;
15674
15801
  }
15675
15802
  return;
15676
15803
  }
15677
- if (ts13.isIdentifier(n) && names.has(n.text)) {
15804
+ if (ts14.isIdentifier(n) && names.has(n.text)) {
15678
15805
  found = true;
15679
15806
  return;
15680
15807
  }
15681
- ts13.forEachChild(n, visit3);
15808
+ ts14.forEachChild(n, visit3);
15682
15809
  }
15683
15810
  visit3(node);
15684
15811
  return found;
@@ -18494,8 +18621,340 @@ var init_build_event_delegation = __esm({
18494
18621
  }
18495
18622
  });
18496
18623
 
18624
+ // ../jsx/src/ir-to-client-js/control-flow/plan/lazy-row-eligibility.ts
18625
+ function lazyRowEligibility(args2) {
18626
+ const { shape, bindings, arraySourceIdentifiers, scope } = args2;
18627
+ if (scope.profile) return NO("profile mode keeps the granular eager emission");
18628
+ if (shape.callSite !== "plain" && shape.callSite !== "branch-plain") {
18629
+ return NO(`call site '${shape.callSite}' is not a plain loop row`);
18630
+ }
18631
+ if (shape.flatMapLeafItem) return NO("flatMap descriptor loop (build-or-patch renderItem)");
18632
+ if (shape.anchored) return NO("anchored whole-item-conditional loop");
18633
+ if (shape.bodyIsMultiRoot) return NO("multi-root (Fragment) row");
18634
+ if (!shape.hasExplicitKey) return NO("index-keyed loop (no explicit key)");
18635
+ if (shape.conditionalCount > 0) return NO("row contains a reactive conditional");
18636
+ if (shape.childRefCount > 0) return NO("row has imperative child refs");
18637
+ if (shape.hasChildComponent) return NO("row body is a child component");
18638
+ if (shape.nestedComponentCount > 0) return NO("row contains nested child components");
18639
+ if (shape.innerLoopCount > 0) return NO("row contains an inner loop");
18640
+ if (shape.hasMapPreamble) return NO("row has a map-callback preamble (may declare row-local reactivity)");
18641
+ if (shape.preambleRegionCount > 0) return NO("row has preamble-patched regions");
18642
+ if (shape.hasParamUnwrap) return NO("destructured loop param without param bindings");
18643
+ for (const b of bindings) {
18644
+ if (b.referencesIndex) {
18645
+ return NO(`binding on slot ${b.slotId} references the loop index parameter`);
18646
+ }
18647
+ if (b.opaqueOuterNames.includes(UNKNOWN_IDENTIFIERS)) {
18648
+ return NO(`binding on slot ${b.slotId} has no analyzable identifier set`);
18649
+ }
18650
+ }
18651
+ if (!arraySourceIdentifiers) return NO("loop source free identifiers unavailable");
18652
+ const sourceGate = checkSourceConsistency(arraySourceIdentifiers, scope);
18653
+ if (sourceGate) return NO(`loop source is not provably hydration-consistent: ${sourceGate}`);
18654
+ return { eligible: true };
18655
+ }
18656
+ function checkSourceConsistency(names, scope) {
18657
+ const seen = /* @__PURE__ */ new Set();
18658
+ const resolve12 = (name2) => {
18659
+ if (seen.has(name2)) return null;
18660
+ seen.add(name2);
18661
+ if (scope.props.has(name2)) return null;
18662
+ if (PURE_SOURCE_GLOBALS.has(name2)) return null;
18663
+ const constFree = scope.constants.get(name2);
18664
+ if (constFree !== void 0) {
18665
+ if (constFree === null) return `constant '${name2}' has no analyzable value`;
18666
+ for (const inner of constFree) {
18667
+ const failure = resolve12(inner);
18668
+ if (failure) return failure;
18669
+ }
18670
+ return null;
18671
+ }
18672
+ const signal2 = scope.signals.get(name2);
18673
+ if (signal2 !== void 0) {
18674
+ if (signal2.initializerFreeIdentifiers === null) {
18675
+ return `signal '${name2}' has no structured initializer to prove props/literal derivation`;
18676
+ }
18677
+ for (const inner of signal2.initializerFreeIdentifiers) {
18678
+ const failure = resolve12(inner);
18679
+ if (failure) return failure;
18680
+ }
18681
+ return null;
18682
+ }
18683
+ if (scope.memos.has(name2)) return `memo '${name2}' initializer is not analyzed by the v1 gate`;
18684
+ if (scope.inert.has(name2)) return `'${name2}' is an import or local function`;
18685
+ return `'${name2}' does not resolve to a prop, literal-derived const, or props/literal-derived signal`;
18686
+ };
18687
+ for (const name2 of names) {
18688
+ const failure = resolve12(name2);
18689
+ if (failure) return failure;
18690
+ }
18691
+ return null;
18692
+ }
18693
+ function classifyLazyBinding(args2) {
18694
+ const { kind: kind2, slotId, free, rowLocalNames, indexParam, scope } = args2;
18695
+ if (free === null) {
18696
+ return {
18697
+ kind: kind2,
18698
+ slotId,
18699
+ readsItem: true,
18700
+ readsOuter: true,
18701
+ reactiveOuterNames: [],
18702
+ opaqueOuterNames: [UNKNOWN_IDENTIFIERS],
18703
+ // An ASSUMPTION, not knowledge — which is precisely why
18704
+ // `UNKNOWN_IDENTIFIERS` must keep refusing the loop: with no
18705
+ // identifier set we cannot rule out an index read either, and
18706
+ // `applyItem` / `applyOuter` have no index parameter to give it.
18707
+ referencesIndex: false
18708
+ };
18709
+ }
18710
+ let readsItem = false;
18711
+ let referencesIndex = false;
18712
+ const reactiveOuterNames = [];
18713
+ const opaqueOuterNames = [];
18714
+ for (const name2 of free) {
18715
+ if (rowLocalNames.has(name2)) {
18716
+ readsItem = true;
18717
+ continue;
18718
+ }
18719
+ if (name2 === indexParam) {
18720
+ referencesIndex = true;
18721
+ continue;
18722
+ }
18723
+ if (INERT_BINDING_GLOBALS.has(name2)) continue;
18724
+ if (scope.signals.has(name2) || scope.memos.has(name2)) {
18725
+ if (!reactiveOuterNames.includes(name2)) reactiveOuterNames.push(name2);
18726
+ continue;
18727
+ }
18728
+ const constFree = scope.constants.get(name2);
18729
+ if (constFree !== void 0 && constFree !== null && constFree.size === 0) continue;
18730
+ opaqueOuterNames.push(name2);
18731
+ }
18732
+ return {
18733
+ kind: kind2,
18734
+ slotId,
18735
+ readsItem,
18736
+ readsOuter: reactiveOuterNames.length > 0 || opaqueOuterNames.length > 0,
18737
+ reactiveOuterNames,
18738
+ opaqueOuterNames,
18739
+ referencesIndex
18740
+ };
18741
+ }
18742
+ var PURE_SOURCE_GLOBALS, INERT_BINDING_GLOBALS, UNKNOWN_IDENTIFIERS, NO;
18743
+ var init_lazy_row_eligibility = __esm({
18744
+ "../jsx/src/ir-to-client-js/control-flow/plan/lazy-row-eligibility.ts"() {
18745
+ "use strict";
18746
+ PURE_SOURCE_GLOBALS = /* @__PURE__ */ new Set([
18747
+ "Object",
18748
+ "Array",
18749
+ "JSON",
18750
+ "Number",
18751
+ "String",
18752
+ "Boolean"
18753
+ ]);
18754
+ INERT_BINDING_GLOBALS = /* @__PURE__ */ new Set([
18755
+ "Object",
18756
+ "Array",
18757
+ "JSON",
18758
+ "Number",
18759
+ "String",
18760
+ "Boolean",
18761
+ "Math",
18762
+ "Date",
18763
+ "Intl",
18764
+ "Symbol",
18765
+ "Map",
18766
+ "Set",
18767
+ "WeakMap",
18768
+ "WeakSet",
18769
+ "Promise",
18770
+ "RegExp",
18771
+ "Error",
18772
+ "BigInt",
18773
+ "console",
18774
+ "undefined",
18775
+ "NaN",
18776
+ "Infinity",
18777
+ "globalThis",
18778
+ "parseInt",
18779
+ "parseFloat",
18780
+ "isNaN",
18781
+ "isFinite",
18782
+ "encodeURIComponent",
18783
+ "decodeURIComponent",
18784
+ "encodeURI",
18785
+ "decodeURI"
18786
+ ]);
18787
+ UNKNOWN_IDENTIFIERS = "<unknown>";
18788
+ NO = (reason2) => ({ eligible: false, reason: reason2 });
18789
+ }
18790
+ });
18791
+
18792
+ // ../jsx/src/ir-to-client-js/control-flow/plan/build-lazy-row.ts
18793
+ function buildLazyRowPlan(args2) {
18794
+ return decideLazyRow(args2).plan;
18795
+ }
18796
+ function decideLazyRow(args2) {
18797
+ const { loop, scope } = args2;
18798
+ if (!scope) {
18799
+ return { plan: null, decision: { eligible: false, reason: "no component scope info supplied" } };
18800
+ }
18801
+ const wrap = (expr) => wrapLoopParamAsAccessor(expr, loop.param, loop.paramBindings);
18802
+ const rowLocalNames = /* @__PURE__ */ new Set([loop.param]);
18803
+ for (const b of loop.paramBindings ?? []) rowLocalNames.add(b.name);
18804
+ const classified = [];
18805
+ const attrClass = /* @__PURE__ */ new Map();
18806
+ loop.bindings.reactiveAttrs.forEach((attr, i) => {
18807
+ const c = classifyLazyBinding({
18808
+ kind: "attr",
18809
+ slotId: attr.childSlotId,
18810
+ free: attrFreeIdentifiers2(attr.expression),
18811
+ rowLocalNames,
18812
+ indexParam: args2.indexParam,
18813
+ scope
18814
+ });
18815
+ attrClass.set(i, c);
18816
+ classified.push(c);
18817
+ });
18818
+ const textClass = /* @__PURE__ */ new Map();
18819
+ loop.bindings.reactiveTexts.forEach((text, i) => {
18820
+ const c = classifyLazyBinding({
18821
+ kind: "text",
18822
+ slotId: text.slotId,
18823
+ free: text.freeIdentifiers ?? null,
18824
+ rowLocalNames,
18825
+ indexParam: args2.indexParam,
18826
+ scope
18827
+ });
18828
+ textClass.set(i, c);
18829
+ classified.push(c);
18830
+ });
18831
+ const shape = {
18832
+ callSite: args2.callSite,
18833
+ flatMapLeafItem: args2.flatMapLeafItem,
18834
+ anchored: args2.anchored,
18835
+ bodyIsMultiRoot: loop.bodyIsMultiRoot ?? false,
18836
+ hasExplicitKey: loop.key != null,
18837
+ conditionalCount: loop.bindings.conditionals?.length ?? 0,
18838
+ childRefCount: loop.bindings.refs?.length ?? 0,
18839
+ nestedComponentCount: loop.nestedComponents?.length ?? 0,
18840
+ innerLoopCount: loop.innerLoops?.length ?? 0,
18841
+ hasChildComponent: "childComponent" in loop && loop.childComponent != null,
18842
+ hasMapPreamble: args2.mapPreambleWrapped.length > 0,
18843
+ preambleRegionCount: args2.preambleRegionCount,
18844
+ hasParamUnwrap: args2.paramUnwrap.length > 0
18845
+ };
18846
+ const decision = lazyRowEligibility({
18847
+ shape,
18848
+ bindings: classified,
18849
+ arraySourceIdentifiers: loopSourceIdentifiers(loop, args2.arrayExpr),
18850
+ scope
18851
+ });
18852
+ if (!decision.eligible) return { plan: null, decision };
18853
+ const attrSlotIds = [];
18854
+ for (const attr of loop.bindings.reactiveAttrs) {
18855
+ if (!attrSlotIds.includes(attr.childSlotId)) attrSlotIds.push(attr.childSlotId);
18856
+ }
18857
+ let ordinal = 0;
18858
+ const attrs = loop.bindings.reactiveAttrs.map((attr, i) => {
18859
+ const c = attrClass.get(i);
18860
+ return {
18861
+ slotId: attr.childSlotId,
18862
+ attrName: attr.attrName,
18863
+ wrappedExpression: wrap(attr.expression),
18864
+ meta: pickAttrMeta(attr),
18865
+ refIndex: attrSlotIds.indexOf(attr.childSlotId),
18866
+ ordinal: ordinal++,
18867
+ readsItem: c.readsItem,
18868
+ readsOuter: c.readsOuter
18869
+ };
18870
+ });
18871
+ const texts = loop.bindings.reactiveTexts.map((text, i) => {
18872
+ const c = textClass.get(i);
18873
+ return {
18874
+ slotId: text.slotId,
18875
+ wrappedExpression: wrap(text.expression),
18876
+ ordinal: ordinal++,
18877
+ // A text that classified as NEITHER item- nor outer-driven still gets
18878
+ // applied on item change (harmless, dedup-guarded) rather than
18879
+ // silently never being written. Anything the classifier did place in
18880
+ // a list keeps exactly the classifier's answer.
18881
+ readsItem: c.readsItem || !c.readsOuter,
18882
+ readsOuter: c.readsOuter
18883
+ };
18884
+ });
18885
+ const outerPrimeGetters = [];
18886
+ for (const c of classified) {
18887
+ for (const name2 of c.reactiveOuterNames) {
18888
+ if (!outerPrimeGetters.includes(name2)) outerPrimeGetters.push(name2);
18889
+ }
18890
+ }
18891
+ return {
18892
+ plan: {
18893
+ attrSlotIds,
18894
+ attrs,
18895
+ texts,
18896
+ writerIndex: texts.length > 0 ? attrSlotIds.length : -1,
18897
+ textNeedsRead: texts.some((t) => t.readsOuter),
18898
+ lastCount: ordinal,
18899
+ outerPrimeGetters,
18900
+ hasOuter: attrs.some((a) => a.readsOuter) || texts.some((t) => t.readsOuter)
18901
+ },
18902
+ decision
18903
+ };
18904
+ }
18905
+ function buildLazyRowScopeInfo(ctx2) {
18906
+ const signals = /* @__PURE__ */ new Map();
18907
+ for (const s of ctx2.signals) {
18908
+ signals.set(s.getter, {
18909
+ // `parsed` is the analyzer's structured initializer. Absent (or
18910
+ // refused by `freeIdentifiers`) ⇒ unprovable, which the source gate
18911
+ // treats as a hard stop rather than an assumption.
18912
+ initializerFreeIdentifiers: s.parsed ? freeIdentifiers(s.parsed) : null
18913
+ });
18914
+ }
18915
+ const memos = new Set(ctx2.memos.map((m) => m.name));
18916
+ const props = /* @__PURE__ */ new Set([PROPS_PARAM]);
18917
+ if (ctx2.propsObjectName) props.add(ctx2.propsObjectName);
18918
+ for (const p of ctx2.propsParams) props.add(p.name);
18919
+ const constants = /* @__PURE__ */ new Map();
18920
+ for (const c of ctx2.localConstants) {
18921
+ constants.set(c.name, c.freeIdentifiers ?? null);
18922
+ }
18923
+ const inert = /* @__PURE__ */ new Set();
18924
+ for (const f of ctx2.localFunctions) inert.add(f.name);
18925
+ for (const imp of ctx2.imports) {
18926
+ if (imp.isTypeOnly) continue;
18927
+ for (const spec of imp.specifiers) inert.add(spec.alias || spec.name);
18928
+ }
18929
+ return { signals, memos, props, constants, inert, profile: ctx2.profile };
18930
+ }
18931
+ function attrFreeIdentifiers2(expression) {
18932
+ if (!expression || expression.trim().length === 0) return /* @__PURE__ */ new Set();
18933
+ try {
18934
+ return freeIdentifiers(parseExpression(expression));
18935
+ } catch {
18936
+ return null;
18937
+ }
18938
+ }
18939
+ function loopSourceIdentifiers(loop, arrayExpr) {
18940
+ if (!loop.arrayFreeIdentifiers) return null;
18941
+ const names = new Set(loop.arrayFreeIdentifiers);
18942
+ for (const name2 of extractFreeIdentifiersFromText(arrayExpr)) names.add(name2);
18943
+ return names;
18944
+ }
18945
+ var init_build_lazy_row = __esm({
18946
+ "../jsx/src/ir-to-client-js/control-flow/plan/build-lazy-row.ts"() {
18947
+ "use strict";
18948
+ init_expression_parser();
18949
+ init_types();
18950
+ init_csr_substitute();
18951
+ init_utils();
18952
+ init_lazy_row_eligibility();
18953
+ }
18954
+ });
18955
+
18497
18956
  // ../jsx/src/ir-to-client-js/control-flow/plan/build-branch-loop.ts
18498
- function buildBranchLoopPlan(loop, profileComponentName) {
18957
+ function buildBranchLoopPlan(loop, profileComponentName, lazyScope) {
18499
18958
  const containerSlotId = loop.containerSlotId;
18500
18959
  const cv = varSlotId(containerSlotId);
18501
18960
  const containerVar = `__loop_${cv}`;
@@ -18511,6 +18970,13 @@ function buildBranchLoopPlan(loop, profileComponentName) {
18511
18970
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(loop.param, loop.paramBindings);
18512
18971
  const hasReactiveEffects = loop.bindings.reactiveAttrs.length > 0 || loop.bindings.reactiveTexts.length > 0 || loop.bindings.conditionals.length > 0;
18513
18972
  const fm = loop.flatMapClient;
18973
+ const arrayExpr = fm ? `(${buildChainedArrayExpr(loop)}).flatMap(${fm.params} => ${fm.body})` : buildChainedArrayExpr(loop);
18974
+ const indexParam = loop.index || "__idx";
18975
+ const mapPreambleWrapped = loop.preamble ? renderPreamble(loop.preamble, {
18976
+ transformJs: (t) => wrapLoopParamAsAccessor(t, loop.param, loop.paramBindings),
18977
+ renderLeaf: (ir) => irToHtmlTemplate(ir, void 0, 1, [{ param: loop.param, bindings: loop.paramBindings }], void 0, true)
18978
+ }) : "";
18979
+ const preambleRegions = buildPreambleRegionPlans(loop.preambleRegions, loop.param, loop.paramBindings);
18514
18980
  const plan = {
18515
18981
  kind: "plain",
18516
18982
  rowConstruction: "string-template",
@@ -18518,17 +18984,27 @@ function buildBranchLoopPlan(loop, profileComponentName) {
18518
18984
  containerVar,
18519
18985
  markerId: loop.markerId,
18520
18986
  flatMapLeafItem: fm ? true : void 0,
18521
- arrayExpr: fm ? `(${buildChainedArrayExpr(loop)}).flatMap(${fm.params} => ${fm.body})` : buildChainedArrayExpr(loop),
18987
+ arrayExpr,
18522
18988
  keyFn: fm ? fm.keyed ? "(__bfD, __bfI) => String(__bfD.k ?? __bfI)" : "null" : loopKeyFn(loop),
18523
18989
  paramHead,
18524
18990
  paramUnwrap,
18525
- indexParam: loop.index || "__idx",
18991
+ indexParam,
18526
18992
  // Wrap loop-param references to signal-accessor form so the preamble
18527
18993
  // matches the template literal's already-wrapped reads (#1065).
18528
- mapPreambleWrapped: loop.preamble ? renderPreamble(loop.preamble, {
18529
- transformJs: (t) => wrapLoopParamAsAccessor(t, loop.param, loop.paramBindings),
18530
- renderLeaf: (ir) => irToHtmlTemplate(ir, void 0, 1, [{ param: loop.param, bindings: loop.paramBindings }], void 0, true)
18531
- }) : "",
18994
+ mapPreambleWrapped,
18995
+ // Lazy row graph (§9, L3) — undefined for every ineligible loop.
18996
+ lazyRow: buildLazyRowPlan({
18997
+ loop,
18998
+ arrayExpr,
18999
+ indexParam,
19000
+ paramUnwrap,
19001
+ mapPreambleWrapped,
19002
+ preambleRegionCount: preambleRegions.length,
19003
+ callSite: "branch-plain",
19004
+ flatMapLeafItem: Boolean(fm),
19005
+ anchored: false,
19006
+ scope: lazyScope
19007
+ }) ?? void 0,
18532
19008
  template: loop.template,
18533
19009
  reactiveEffects: hasReactiveEffects ? buildReactiveEffectsPlan({
18534
19010
  attrs: loop.bindings.reactiveAttrs,
@@ -18540,7 +19016,7 @@ function buildBranchLoopPlan(loop, profileComponentName) {
18540
19016
  }) : null,
18541
19017
  eventDelegation: buildBranchLoopDelegationPlan(loop, cv, profileComponentName),
18542
19018
  childRefs: buildChildRefBindings(loop.bindings.refs, loop.param, loop.paramBindings),
18543
- preambleRegions: buildPreambleRegionPlans(loop.preambleRegions, loop.param, loop.paramBindings),
19019
+ preambleRegions,
18544
19020
  bodyIsMultiRoot: loop.bodyIsMultiRoot ?? false,
18545
19021
  profileLoopId: profileComponentName ? `${profileComponentName}#binding:${containerSlotId}` : void 0
18546
19022
  };
@@ -18553,6 +19029,7 @@ var init_build_branch_loop = __esm({
18553
19029
  init_build_composite_loop();
18554
19030
  init_build_event_delegation();
18555
19031
  init_build_reactive_effects();
19032
+ init_build_lazy_row();
18556
19033
  init_shared();
18557
19034
  init_html_template();
18558
19035
  }
@@ -18609,13 +19086,13 @@ function buildArmBody(branch, options2) {
18609
19086
  expression: t.expression
18610
19087
  })),
18611
19088
  // Branch-scoped loops, fully Plan-built (Item 2 final migration).
18612
- loops: branch.loops.map((l) => buildBranchLoopPlan(l, pc)),
19089
+ loops: branch.loops.map((l) => buildBranchLoopPlan(l, pc, options2.lazyScope)),
18613
19090
  // Nested conditionals are themselves InsertPlans — built recursively so
18614
19091
  // the same stringifier handles arbitrary depth. Their scope is always
18615
19092
  // `__branchScope` (the parent arm's bindEvents argument), regardless of
18616
19093
  // the outer scope; only the eventNameMode is inherited.
18617
19094
  conditionals: branch.conditionals.map(
18618
- (c) => buildInsertPlan(c, { scope: { kind: "branchScope" }, eventNameMode: options2.eventNameMode, profileComponentName: pc })
19095
+ (c) => buildInsertPlan(c, { scope: { kind: "branchScope" }, eventNameMode: options2.eventNameMode, profileComponentName: pc, lazyScope: options2.lazyScope })
18619
19096
  )
18620
19097
  };
18621
19098
  }
@@ -18647,7 +19124,7 @@ var init_claim_plan = __esm({
18647
19124
  });
18648
19125
 
18649
19126
  // ../jsx/src/ir-to-client-js/emit-reactive.ts
18650
- import ts14 from "typescript";
19127
+ import ts15 from "typescript";
18651
19128
  function bindingIdArg(ctx2, slotId) {
18652
19129
  if (!ctx2.profile || !slotId) return "";
18653
19130
  return `, ${JSON.stringify(`${ctx2.componentName}#binding:${slotId}`)}`;
@@ -18727,19 +19204,19 @@ function lowerToLocaleCallsInReactiveExpr(expr, matcher) {
18727
19204
  if (!matcher) return expr;
18728
19205
  let sourceFile;
18729
19206
  try {
18730
- sourceFile = ts14.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts14.ScriptTarget.Latest, true, ts14.ScriptKind.TS);
19207
+ sourceFile = ts15.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts15.ScriptTarget.Latest, true, ts15.ScriptKind.TS);
18731
19208
  } catch {
18732
19209
  return expr;
18733
19210
  }
18734
19211
  const stmt = sourceFile.statements[0];
18735
- if (!stmt || !ts14.isExpressionStatement(stmt)) return expr;
18736
- const root2 = ts14.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19212
+ if (!stmt || !ts15.isExpressionStatement(stmt)) return expr;
19213
+ const root2 = ts15.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
18737
19214
  const candidates = [];
18738
19215
  const visit3 = (n) => {
18739
- if (ts14.isCallExpression(n) && n.arguments.length === 2 && ts14.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
19216
+ if (ts15.isCallExpression(n) && n.arguments.length === 2 && ts15.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
18740
19217
  candidates.push(n);
18741
19218
  }
18742
- ts14.forEachChild(n, visit3);
19219
+ ts15.forEachChild(n, visit3);
18743
19220
  };
18744
19221
  visit3(root2);
18745
19222
  if (candidates.length === 0) return expr;
@@ -18776,19 +19253,19 @@ function lowerDateCallsInReactiveExpr(expr, matcher) {
18776
19253
  if (!matcher) return expr;
18777
19254
  let sourceFile;
18778
19255
  try {
18779
- sourceFile = ts14.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts14.ScriptTarget.Latest, true, ts14.ScriptKind.TS);
19256
+ sourceFile = ts15.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts15.ScriptTarget.Latest, true, ts15.ScriptKind.TS);
18780
19257
  } catch {
18781
19258
  return expr;
18782
19259
  }
18783
19260
  const stmt = sourceFile.statements[0];
18784
- if (!stmt || !ts14.isExpressionStatement(stmt)) return expr;
18785
- const root2 = ts14.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19261
+ if (!stmt || !ts15.isExpressionStatement(stmt)) return expr;
19262
+ const root2 = ts15.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
18786
19263
  const candidates = [];
18787
19264
  const visit3 = (n) => {
18788
- if (ts14.isCallExpression(n) && n.arguments.length === 0 && ts14.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
19265
+ if (ts15.isCallExpression(n) && n.arguments.length === 0 && ts15.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
18789
19266
  candidates.push(n);
18790
19267
  }
18791
- ts14.forEachChild(n, visit3);
19268
+ ts15.forEachChild(n, visit3);
18792
19269
  };
18793
19270
  visit3(root2);
18794
19271
  if (candidates.length === 0) return expr;
@@ -19008,7 +19485,7 @@ function stringifyBranchEventBindings(lines, plan, indent) {
19008
19485
  }
19009
19486
  function stringifyBranchChildComponentInits(lines, plan, indent) {
19010
19487
  for (const init of plan) {
19011
- lines.push(`${indent}{ let __c = qsa(__branchScope, ${init.selector}); if (!__c) { const __ph = __branchScope.querySelector('[${BF_PLACEHOLDER}="${init.placeholderId}"]'); if (__ph) { __c = createComponent('${nameForRegistryRef(init.name)}', ${init.propsExpr}); __ph.replaceWith(__c) } } if (__c) initChild('${nameForRegistryRef(init.name)}', __c, ${init.propsExpr}) }`);
19488
+ lines.push(`${indent}{ let __c = qsa(__branchScope, ${init.selector}); if (!__c) { const __ph = __branchScope.querySelector('[${BF_PLACEHOLDER}="${init.placeholderId}"]'); if (__ph) { __c = createComponent('${nameForRegistryRef(init.name)}', ${init.propsExpr}, undefined, undefined, __ph) } } if (__c) initChild('${nameForRegistryRef(init.name)}', __c, ${init.propsExpr}) }`);
19012
19489
  }
19013
19490
  }
19014
19491
  function stringifyBranchInnerLoops(lines, plan, indent, pc) {
@@ -19356,6 +19833,179 @@ var init_component_loop = __esm({
19356
19833
  }
19357
19834
  });
19358
19835
 
19836
+ // ../jsx/src/ir-to-client-js/control-flow/stringify/lazy-row.ts
19837
+ function stringifyLazyRowLoop(lines, o) {
19838
+ const { indent, lazyRow, paramHead } = o;
19839
+ const mid = o.markerId.replace(/[^A-Za-z0-9_$]/g, "_");
19840
+ const tplVar = `__tpl_${mid}`;
19841
+ const claimVar = `__lzc_${mid}`;
19842
+ const hasRefs = lazyRow.attrSlotIds.length > 0 || lazyRow.texts.length > 0;
19843
+ const hasBindings = lazyRow.attrs.length > 0 || lazyRow.texts.length > 0;
19844
+ const rwDoor = lazyRow.textNeedsRead;
19845
+ const paths = o.skeletonPaths;
19846
+ const useHoisted = Boolean(o.skeletonTemplate);
19847
+ if (useHoisted) emitHoistedTemplateDecl(lines, indent, tplVar, o.skeletonTemplate);
19848
+ const textPathVar = useHoisted && paths && lazyRow.texts.length > 0 ? `__lzp_${mid}` : null;
19849
+ if (textPathVar) {
19850
+ const arrays = lazyRow.texts.map((t) => `[${(paths.textMarkerPaths.get(t.slotId) ?? []).join(", ")}]`);
19851
+ lines.push(`${indent}const ${textPathVar} = [${arrays.join(", ")}]`);
19852
+ }
19853
+ let adoptedPlanVar = null;
19854
+ let freshPlanVar = null;
19855
+ if (lazyRow.texts.length > 0) {
19856
+ adoptedPlanVar = `__lzs_${mid}`;
19857
+ const adoptedSlots = lazyRow.texts.map((t) => ({ id: t.slotId, kind: "text", path: [] }));
19858
+ lines.push(`${indent}const ${adoptedPlanVar} = ${claimPlanLiteral(adoptedSlots)}`);
19859
+ if (textPathVar) {
19860
+ freshPlanVar = `__lzsc_${mid}`;
19861
+ const freshSlots = lazyRow.texts.map((t, i) => ({
19862
+ id: t.slotId,
19863
+ kind: "text",
19864
+ path: [],
19865
+ pathExpr: `${textPathVar}[${i}]`
19866
+ }));
19867
+ lines.push(`${indent}const ${freshPlanVar} = ${claimPlanLiteral(freshSlots)}`);
19868
+ } else {
19869
+ freshPlanVar = adoptedPlanVar;
19870
+ }
19871
+ }
19872
+ if (hasRefs) {
19873
+ const parts = refParts(lazyRow, "__el", null, adoptedPlanVar, true);
19874
+ lines.push(`${indent}const ${claimVar} = (__e) => {`);
19875
+ if (parts.some((p) => p.includes("__el"))) lines.push(`${indent} const __el = __e.primaryEl`);
19876
+ lines.push(`${indent} return [${parts.join(", ")}]`);
19877
+ lines.push(`${indent}}`);
19878
+ }
19879
+ const call = `mapArrayLazy(() => ${o.arrayExpr}, ${o.containerVar}, ${o.keyFn}, {`;
19880
+ lines.push(`${indent}${o.guardContainer ? `if (${o.containerVar}) ` : ""}${call}`);
19881
+ const b1 = `${indent} `;
19882
+ const b2 = `${indent} `;
19883
+ lines.push(`${b1}createRow: (__e, ${o.indexParam}) => {`);
19884
+ lines.push(`${b2}const ${paramHead} = () => __e.item`);
19885
+ const cloneExpr = useHoisted ? hoistedCloneExpr(tplVar, o.skeletonTemplate) : `(() => { ${emitTemplateCloneInline(o.template)} })()`;
19886
+ lines.push(`${b2}const __el = ${cloneExpr}`);
19887
+ if (hasRefs) {
19888
+ lines.push(`${b2}const __r = __e.refs = [${refParts(lazyRow, "__el", useHoisted ? paths ?? null : null, freshPlanVar).join(", ")}]`);
19889
+ }
19890
+ if (hasBindings) {
19891
+ lines.push(`${b2}const __l = __e.last = []`);
19892
+ for (const a of lazyRow.attrs) emitAttrBinding(lines, b2, a, "create");
19893
+ const createDoor = `__r[${lazyRow.writerIndex}]`;
19894
+ for (const t of lazyRow.texts) emitTextBinding(lines, b2, t, createDoor, "create", rwDoor);
19895
+ }
19896
+ lines.push(`${b2}return __el`);
19897
+ lines.push(`${b1}},`);
19898
+ const itemAttrs = lazyRow.attrs.filter((a) => a.readsItem);
19899
+ const itemTexts = lazyRow.texts.filter((t) => t.readsItem);
19900
+ if (itemAttrs.length === 0 && itemTexts.length === 0) {
19901
+ lines.push(`${b1}applyItem: () => {},`);
19902
+ } else {
19903
+ lines.push(`${b1}applyItem: (__e) => {`);
19904
+ lines.push(`${b2}const ${paramHead} = () => __e.item`);
19905
+ lines.push(`${b2}const __r = __e.refs ?? (__e.refs = ${claimVar}(__e))`);
19906
+ lines.push(`${b2}const __l = __e.last ?? (__e.last = [])`);
19907
+ for (const a of itemAttrs) emitAttrBinding(lines, b2, a, "item");
19908
+ if (itemTexts.length > 0) {
19909
+ lines.push(`${b2}const __d = ${doorAccess(lazyRow, lazyRow.writerIndex, adoptedPlanVar)}`);
19910
+ for (const t of itemTexts) emitTextBinding(lines, b2, t, "__d", "item", rwDoor);
19911
+ }
19912
+ lines.push(`${b1}},`);
19913
+ }
19914
+ const outerAttrs = lazyRow.attrs.filter((a) => a.readsOuter);
19915
+ const outerTexts = lazyRow.texts.filter((t) => t.readsOuter);
19916
+ if (outerAttrs.length > 0 || outerTexts.length > 0) {
19917
+ const b3 = `${indent} `;
19918
+ lines.push(`${b1}applyOuter: (__es, __seed) => {`);
19919
+ for (const g of lazyRow.outerPrimeGetters) lines.push(`${b2}${g}()`);
19920
+ lines.push(`${b2}for (const __e of __es) {`);
19921
+ lines.push(`${b3}const ${paramHead} = () => __e.item`);
19922
+ lines.push(`${b3}const __r = __e.refs ?? (__e.refs = ${claimVar}(__e))`);
19923
+ lines.push(`${b3}const __l = __e.last ?? (__e.last = [])`);
19924
+ for (const a of outerAttrs) emitAttrBinding(lines, b3, a, "outer");
19925
+ if (outerTexts.length > 0) {
19926
+ lines.push(`${b3}const __d = ${doorAccess(lazyRow, lazyRow.writerIndex, adoptedPlanVar)}`);
19927
+ for (const t of outerTexts) emitTextBinding(lines, b3, t, "__d", "outer", rwDoor);
19928
+ }
19929
+ lines.push(`${b2}}`);
19930
+ lines.push(`${b1}},`);
19931
+ }
19932
+ lines.push(`${indent}}, '${o.markerId}')`);
19933
+ }
19934
+ function refParts(lazyRow, elVar, skeletonPaths, planVar, deferDoor = false) {
19935
+ const parts = [];
19936
+ for (const slotId of lazyRow.attrSlotIds) {
19937
+ const path25 = skeletonPaths?.elementPaths.get(slotId);
19938
+ parts.push(path25 ? pathExpr(elVar, path25) : `qsa(${elVar}, '[bf="${slotId}"]')`);
19939
+ }
19940
+ if (lazyRow.texts.length > 0) {
19941
+ parts.push(deferDoor ? "null" : `${doorCtor(lazyRow)}(${elVar}, ${planVar})`);
19942
+ }
19943
+ return parts;
19944
+ }
19945
+ function doorCtor(lazyRow) {
19946
+ return lazyRow.textNeedsRead ? "lazyClaimSlots" : "lazySlots";
19947
+ }
19948
+ function doorAccess(lazyRow, writerIndex, adoptedPlanVar) {
19949
+ const slot = `__r[${writerIndex}]`;
19950
+ return `${slot} ?? (${slot} = ${doorCtor(lazyRow)}(__e.primaryEl, ${adoptedPlanVar}))`;
19951
+ }
19952
+ function dedupGuard(ordinal) {
19953
+ return `!(${ordinal} in __l) || !Object.is(__l[${ordinal}], __x)`;
19954
+ }
19955
+ function emitAttrBinding(lines, ind, a, mode2) {
19956
+ lines.push(`${ind}{ const __t = __r[${a.refIndex}]`);
19957
+ lines.push(`${ind}if (__t) {`);
19958
+ lines.push(`${ind} const __x = ${a.wrappedExpression}`);
19959
+ const guard = mode2 === "create" ? null : mode2 === "item" ? dedupGuard(a.ordinal) : `__seed ? (${seedDiffersExpr("__t", a)}) : (${dedupGuard(a.ordinal)})`;
19960
+ const writeIndent = guard ? `${ind} ` : `${ind} `;
19961
+ if (guard) lines.push(`${ind} if (${guard}) {`);
19962
+ for (const stmt of emitAttrUpdate("__t", a.attrName, "__x", a.meta)) {
19963
+ lines.push(`${writeIndent}${stmt}`);
19964
+ }
19965
+ if (guard) lines.push(`${ind} }`);
19966
+ lines.push(`${ind} __l[${a.ordinal}] = __x`);
19967
+ lines.push(`${ind}} }`);
19968
+ }
19969
+ function emitTextBinding(lines, ind, t, doorExpr, mode2, rwDoor) {
19970
+ lines.push(`${ind}{ const __x = ${t.wrappedExpression}`);
19971
+ const writeOf = (valueExpr) => rwDoor ? `${doorExpr}.write('${t.slotId}', ${valueExpr})` : `${doorExpr}('${t.slotId}', ${valueExpr})`;
19972
+ if (mode2 === "outer") {
19973
+ lines.push(`${ind}if (__seed) {`);
19974
+ lines.push(`${ind} const __s = textOrNode(__x)`);
19975
+ lines.push(`${ind} if (${doorExpr}.read('${t.slotId}') !== __s) ${writeOf("__s")}`);
19976
+ lines.push(`${ind}} else if (${dedupGuard(t.ordinal)}) ${writeOf("textOrNode(__x)")}`);
19977
+ } else if (mode2 === "item") {
19978
+ lines.push(`${ind}if (${dedupGuard(t.ordinal)}) ${writeOf("textOrNode(__x)")}`);
19979
+ } else {
19980
+ lines.push(`${ind}${writeOf("textOrNode(__x)")}`);
19981
+ }
19982
+ lines.push(`${ind}__l[${t.ordinal}] = __x }`);
19983
+ }
19984
+ function seedDiffersExpr(target2, a) {
19985
+ const html = toHTMLAttrName(a.attrName);
19986
+ if (a.attrName === "dangerouslySetInnerHTML" || html === "dangerouslySetInnerHTML") return "true";
19987
+ if (html === "style") return `${target2}.getAttribute('style') !== styleToCss(__x)`;
19988
+ if (html === "class") return `${target2}.getAttribute('class') !== (__x != null ? String(__x) : null)`;
19989
+ if (html === "value") return `${target2}.value !== String(__x)`;
19990
+ if (isBooleanAttr(html)) return `${target2}.${html} !== !!(__x)`;
19991
+ if (a.meta.presenceOrUndefined) {
19992
+ const written = html.startsWith("aria-") ? "true" : "";
19993
+ return `${target2}.getAttribute('${html}') !== (__x ? '${written}' : null)`;
19994
+ }
19995
+ return `${target2}.getAttribute('${html}') !== (__x != null ? String(__x) : null)`;
19996
+ }
19997
+ var init_lazy_row = __esm({
19998
+ "../jsx/src/ir-to-client-js/control-flow/stringify/lazy-row.ts"() {
19999
+ "use strict";
20000
+ init_html_constants();
20001
+ init_emit_reactive();
20002
+ init_utils();
20003
+ init_claim_plan();
20004
+ init_skeleton_paths();
20005
+ init_template_parse();
20006
+ }
20007
+ });
20008
+
19359
20009
  // ../jsx/src/ir-to-client-js/control-flow/stringify/loop.ts
19360
20010
  function emitLoopChildRefs(lines, refs, opts) {
19361
20011
  if (refs.length === 0) return;
@@ -19432,6 +20082,23 @@ function stringifyPlainLoop(lines, plan, topIndent = " ") {
19432
20082
  stringifyAnchoredLoop(lines, plan, topIndent, anchorKeyExpr);
19433
20083
  return;
19434
20084
  }
20085
+ if (plan.lazyRow) {
20086
+ stringifyLazyRowLoop(lines, {
20087
+ indent: topIndent,
20088
+ containerVar,
20089
+ guardContainer: false,
20090
+ markerId,
20091
+ arrayExpr,
20092
+ keyFn,
20093
+ paramHead,
20094
+ indexParam,
20095
+ template,
20096
+ skeletonTemplate,
20097
+ skeletonPaths: plan.skeletonPaths,
20098
+ lazyRow: plan.lazyRow
20099
+ });
20100
+ return;
20101
+ }
19435
20102
  const hoistedTpl = !bodyIsMultiRoot && skeletonTemplate ? skeletonTemplate : null;
19436
20103
  const tplVar = `__tpl_${markerId.replace(/[^A-Za-z0-9_$]/g, "_")}`;
19437
20104
  if (hoistedTpl) {
@@ -19619,6 +20286,7 @@ var init_loop = __esm({
19619
20286
  init_component_loop();
19620
20287
  init_composite_loop();
19621
20288
  init_claim_plan();
20289
+ init_lazy_row();
19622
20290
  }
19623
20291
  });
19624
20292
 
@@ -20052,6 +20720,23 @@ function emitPlain(lines, plan) {
20052
20720
  stringifyEventDelegation(lines, eventDelegation);
20053
20721
  return;
20054
20722
  }
20723
+ if (plan.lazyRow) {
20724
+ stringifyLazyRowLoop(lines, {
20725
+ indent: " ",
20726
+ containerVar,
20727
+ guardContainer: true,
20728
+ markerId,
20729
+ arrayExpr,
20730
+ keyFn,
20731
+ paramHead,
20732
+ indexParam,
20733
+ template,
20734
+ lazyRow: plan.lazyRow
20735
+ });
20736
+ lines.push(` }))`);
20737
+ stringifyEventDelegation(lines, eventDelegation);
20738
+ return;
20739
+ }
20055
20740
  if (reactiveEffects === null && !bodyIsMultiRoot && childRefs.length === 0 && preambleRegions.length === 0) {
20056
20741
  const cloneExpr = emitTemplateCloneInline(template);
20057
20742
  if (mapPreambleWrapped) {
@@ -20097,6 +20782,7 @@ var init_branch_loop = __esm({
20097
20782
  init_reactive_effects();
20098
20783
  init_template_parse();
20099
20784
  init_loop();
20785
+ init_lazy_row();
20100
20786
  }
20101
20787
  });
20102
20788
 
@@ -20283,7 +20969,7 @@ var init_build_component_loop = __esm({
20283
20969
  // ../jsx/src/ir-to-client-js/control-flow/plan/build-loop.ts
20284
20970
  function buildLoopPlan(elem, opts) {
20285
20971
  if (elem.bodyIsItemConditional) {
20286
- return buildPlainLoopPlan(elem, opts.profileComponentName);
20972
+ return buildPlainLoopPlan(elem, opts.profileComponentName, opts.lazyScope);
20287
20973
  }
20288
20974
  if (elem.isStaticArray) {
20289
20975
  return buildStaticLoopPlan(elem, opts.unsafeLocalNames, opts.profileComponentName);
@@ -20295,9 +20981,9 @@ function buildLoopPlan(elem, opts) {
20295
20981
  if (elem.childComponent) {
20296
20982
  return buildComponentLoopPlan(elem, opts.profileComponentName);
20297
20983
  }
20298
- return buildPlainLoopPlan(elem, opts.profileComponentName);
20984
+ return buildPlainLoopPlan(elem, opts.profileComponentName, opts.lazyScope);
20299
20985
  }
20300
- function buildPlainLoopPlan(elem, profileComponentName) {
20986
+ function buildPlainLoopPlan(elem, profileComponentName, lazyScope) {
20301
20987
  const wrap = (expr) => wrapLoopParamAsAccessor(expr, elem.param, elem.paramBindings);
20302
20988
  const { head: paramHead, unwrap: paramUnwrap } = destructureLoopParam(elem.param, elem.paramBindings);
20303
20989
  const hasReactive2 = elem.bindings.reactiveAttrs.length > 0 || elem.bindings.reactiveTexts.length > 0 || elem.bindings.conditionals.length > 0;
@@ -20326,30 +21012,48 @@ function buildPlainLoopPlan(elem, profileComponentName) {
20326
21012
  preambleRegions: []
20327
21013
  };
20328
21014
  }
21015
+ const arrayExpr = buildChainedArrayExpr(elem);
21016
+ const indexParam = elem.index || "__idx";
21017
+ const mapPreambleWrapped = elem.preamble ? renderPreamble(elem.preamble, {
21018
+ transformJs: wrap,
21019
+ renderLeaf: (ir) => irToHtmlTemplate(ir, void 0, 1, [{ param: elem.param, bindings: elem.paramBindings }], void 0, true)
21020
+ }) : "";
21021
+ const preambleRegions = buildPreambleRegionPlans(elem.preambleRegions, elem.param, elem.paramBindings);
20329
21022
  return {
20330
21023
  kind: "plain",
20331
21024
  rowConstruction: "string-template",
20332
21025
  containerVar: `_${varSlotId(elem.slotId)}`,
20333
21026
  markerId: elem.markerId,
20334
21027
  profileLoopId: profileComponentName ? `${profileComponentName}#binding:${elem.slotId}` : void 0,
20335
- arrayExpr: buildChainedArrayExpr(elem),
21028
+ arrayExpr,
20336
21029
  keyFn: loopKeyFn(elem),
20337
21030
  paramHead,
20338
21031
  paramUnwrap,
20339
- indexParam: elem.index || "__idx",
21032
+ indexParam,
21033
+ // Lazy row graph (§9, L3). `null` for every ineligible loop, which then
21034
+ // keeps the eager emission below byte-for-byte.
21035
+ lazyRow: buildLazyRowPlan({
21036
+ loop: elem,
21037
+ arrayExpr,
21038
+ indexParam,
21039
+ paramUnwrap,
21040
+ mapPreambleWrapped,
21041
+ preambleRegionCount: preambleRegions.length,
21042
+ callSite: "plain",
21043
+ flatMapLeafItem: false,
21044
+ anchored: elem.bodyIsItemConditional ?? false,
21045
+ scope: lazyScope
21046
+ }) ?? void 0,
20340
21047
  // Stage 3 / D4 — js segments get the loop-param accessor wrap; jsx leaves
20341
21048
  // render as HTML-string templates under this loop's param context so a
20342
21049
  // leaf that reads the item (`r`) becomes `r()`.
20343
- mapPreambleWrapped: elem.preamble ? renderPreamble(elem.preamble, {
20344
- transformJs: wrap,
20345
- renderLeaf: (ir) => irToHtmlTemplate(ir, void 0, 1, [{ param: elem.param, bindings: elem.paramBindings }], void 0, true)
20346
- }) : "",
21050
+ mapPreambleWrapped,
20347
21051
  template: elem.template,
20348
21052
  skeletonTemplate: elem.skeletonTemplate,
20349
21053
  skeletonPaths: elem.skeletonPaths,
20350
21054
  reactiveEffects: hasReactive2 ? buildLoopReactiveEffectsPlan(elem, profileComponentName) : null,
20351
21055
  childRefs: buildChildRefBindings(elem.bindings.refs, elem.param, elem.paramBindings),
20352
- preambleRegions: buildPreambleRegionPlans(elem.preambleRegions, elem.param, elem.paramBindings),
21056
+ preambleRegions,
20353
21057
  bodyIsMultiRoot: elem.bodyIsMultiRoot ?? false,
20354
21058
  anchored: elem.bodyIsItemConditional ?? false,
20355
21059
  // Fall back to the iteration index when the loop has no key. A whole-item
@@ -20411,6 +21115,7 @@ var init_build_loop = __esm({
20411
21115
  init_utils();
20412
21116
  init_shared();
20413
21117
  init_build_reactive_effects();
21118
+ init_build_lazy_row();
20414
21119
  init_build_component_loop();
20415
21120
  init_build_composite_loop();
20416
21121
  init_html_template();
@@ -20421,7 +21126,7 @@ var init_build_loop = __esm({
20421
21126
  function emitConditionalUpdates(lines, ctx2) {
20422
21127
  const profileComponentName = ctx2.profile ? ctx2.componentName : void 0;
20423
21128
  for (const elem of ctx2.conditionalElements) {
20424
- const plan = buildInsertPlan(elem, { scope: { kind: "top" }, eventNameMode: "dom", profileComponentName });
21129
+ const plan = buildInsertPlan(elem, { scope: { kind: "top" }, eventNameMode: "dom", profileComponentName, lazyScope: buildLazyRowScopeInfo(ctx2) });
20425
21130
  stringifyInsert(lines, plan, { leadingIndent: " ", bodyIndent: " " });
20426
21131
  lines.push("");
20427
21132
  }
@@ -20429,17 +21134,19 @@ function emitConditionalUpdates(lines, ctx2) {
20429
21134
  function emitClientOnlyConditionals(lines, ctx2) {
20430
21135
  const profileComponentName = ctx2.profile ? ctx2.componentName : void 0;
20431
21136
  for (const elem of ctx2.clientOnlyConditionals) {
20432
- const plan = buildInsertPlan(elem, { scope: { kind: "top" }, eventNameMode: "raw", profileComponentName });
21137
+ const plan = buildInsertPlan(elem, { scope: { kind: "top" }, eventNameMode: "raw", profileComponentName, lazyScope: buildLazyRowScopeInfo(ctx2) });
20433
21138
  lines.push(` // @client conditional: ${elem.slotId}`);
20434
21139
  stringifyInsert(lines, plan, { leadingIndent: " ", bodyIndent: " " });
20435
21140
  lines.push("");
20436
21141
  }
20437
21142
  }
20438
21143
  function emitLoopUpdates(lines, ctx2, unsafeLocalNames) {
21144
+ const lazyScope = buildLazyRowScopeInfo(ctx2);
20439
21145
  for (const elem of ctx2.loopElements) {
20440
21146
  const plan = buildLoopPlan(elem, {
20441
21147
  unsafeLocalNames,
20442
- profileComponentName: ctx2.profile ? ctx2.componentName : void 0
21148
+ profileComponentName: ctx2.profile ? ctx2.componentName : void 0,
21149
+ lazyScope
20443
21150
  });
20444
21151
  internalInvariant(
20445
21152
  !(elem.preamble && elem.preamble.builderNames.length > 0 && plan.rowConstruction === "dom-ops"),
@@ -20467,6 +21174,7 @@ var init_control_flow = __esm({
20467
21174
  init_build_insert();
20468
21175
  init_insert();
20469
21176
  init_build_loop();
21177
+ init_build_lazy_row();
20470
21178
  init_loop();
20471
21179
  init_build_event_delegation();
20472
21180
  init_event_delegation();
@@ -20692,25 +21400,25 @@ var init_phases = __esm({
20692
21400
  });
20693
21401
 
20694
21402
  // ../jsx/src/ir-to-client-js/rewrite-props-object.ts
20695
- import ts15 from "typescript";
21403
+ import ts16 from "typescript";
20696
21404
  function rewritePropsObjectRef(code, propsObjectName) {
20697
21405
  const srcPropsName = propsObjectName ?? "props";
20698
21406
  if (srcPropsName === PROPS_PARAM) return code;
20699
21407
  if (!new RegExp(`\\b${srcPropsName}\\b`).test(code)) return code;
20700
- const sourceFile = ts15.createSourceFile(
21408
+ const sourceFile = ts16.createSourceFile(
20701
21409
  "init-body.ts",
20702
21410
  code,
20703
- ts15.ScriptTarget.Latest,
21411
+ ts16.ScriptTarget.Latest,
20704
21412
  /*setParentNodes*/
20705
21413
  true,
20706
- ts15.ScriptKind.TS
21414
+ ts16.ScriptKind.TS
20707
21415
  );
20708
21416
  const spans = [];
20709
21417
  function visit3(node) {
20710
- if (ts15.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
21418
+ if (ts16.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
20711
21419
  spans.push([node.getStart(sourceFile), node.getEnd()]);
20712
21420
  }
20713
- ts15.forEachChild(node, visit3);
21421
+ ts16.forEachChild(node, visit3);
20714
21422
  }
20715
21423
  visit3(sourceFile);
20716
21424
  if (spans.length === 0) return code;
@@ -20724,12 +21432,12 @@ function rewritePropsObjectRef(code, propsObjectName) {
20724
21432
  function shouldRewrite(node) {
20725
21433
  const parent2 = node.parent;
20726
21434
  if (!parent2) return true;
20727
- if (ts15.isPropertyAccessExpression(parent2) && parent2.name === node) return false;
20728
- if (ts15.isPropertyAssignment(parent2) && parent2.name === node) return false;
20729
- if (ts15.isShorthandPropertyAssignment(parent2) && parent2.name === node) return false;
20730
- if (ts15.isPropertySignature(parent2) && parent2.name === node) return false;
20731
- if (ts15.isPropertyDeclaration(parent2) && parent2.name === node) return false;
20732
- if (ts15.isBindingElement(parent2) && parent2.name === node) return false;
21435
+ if (ts16.isPropertyAccessExpression(parent2) && parent2.name === node) return false;
21436
+ if (ts16.isPropertyAssignment(parent2) && parent2.name === node) return false;
21437
+ if (ts16.isShorthandPropertyAssignment(parent2) && parent2.name === node) return false;
21438
+ if (ts16.isPropertySignature(parent2) && parent2.name === node) return false;
21439
+ if (ts16.isPropertyDeclaration(parent2) && parent2.name === node) return false;
21440
+ if (ts16.isBindingElement(parent2) && parent2.name === node) return false;
20733
21441
  return true;
20734
21442
  }
20735
21443
  var init_rewrite_props_object = __esm({
@@ -21413,7 +22121,7 @@ var init_css_layer_prefixer = __esm({
21413
22121
  });
21414
22122
 
21415
22123
  // ../jsx/src/preprocess-inline-jsx-callbacks.ts
21416
- import ts16 from "typescript";
22124
+ import ts17 from "typescript";
21417
22125
  function preprocessInlineJsxCallbacks(source, filePath) {
21418
22126
  const errors = [];
21419
22127
  const syntheticNames = [];
@@ -21433,15 +22141,15 @@ function preprocessInlineJsxCallbacks(source, filePath) {
21433
22141
  return { source: current, errors, syntheticNames };
21434
22142
  }
21435
22143
  function runSinglePass(source, filePath, startingCounter) {
21436
- const sourceFile = ts16.createSourceFile(
22144
+ const sourceFile = ts17.createSourceFile(
21437
22145
  filePath,
21438
22146
  source,
21439
- ts16.ScriptTarget.Latest,
22147
+ ts17.ScriptTarget.Latest,
21440
22148
  true,
21441
- ts16.ScriptKind.TSX
22149
+ ts17.ScriptKind.TSX
21442
22150
  );
21443
22151
  const hasUseClient = sourceFile.statements.some(
21444
- (stmt) => ts16.isExpressionStatement(stmt) && ts16.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'")
22152
+ (stmt) => ts17.isExpressionStatement(stmt) && ts17.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'")
21445
22153
  );
21446
22154
  if (!hasUseClient) {
21447
22155
  return { source, errors: [], syntheticNames: [], counterAfter: startingCounter };
@@ -21464,20 +22172,20 @@ function runSinglePass(source, filePath, startingCounter) {
21464
22172
  }
21465
22173
  }
21466
22174
  function visit3(node) {
21467
- if (ts16.isJsxAttribute(node) && node.initializer && ts16.isJsxExpression(node.initializer) && node.initializer.expression) {
22175
+ if (ts17.isJsxAttribute(node) && node.initializer && ts17.isJsxExpression(node.initializer) && node.initializer.expression) {
21468
22176
  if (tryHandleArrowValue(node.initializer.expression)) {
21469
22177
  return;
21470
22178
  }
21471
22179
  }
21472
- if (ts16.isPropertyAssignment(node) && node.initializer) {
22180
+ if (ts17.isPropertyAssignment(node) && node.initializer) {
21473
22181
  if (tryHandleArrowValue(node.initializer)) return;
21474
22182
  }
21475
- ts16.forEachChild(node, visit3);
22183
+ ts17.forEachChild(node, visit3);
21476
22184
  }
21477
22185
  function tryHandleArrowValue(initializer) {
21478
22186
  let expr = initializer;
21479
- while (ts16.isParenthesizedExpression(expr)) expr = expr.expression;
21480
- if (ts16.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
22187
+ while (ts17.isParenthesizedExpression(expr)) expr = expr.expression;
22188
+ if (ts17.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
21481
22189
  return handleInlineArrow(expr);
21482
22190
  }
21483
22191
  return false;
@@ -21512,7 +22220,7 @@ function runSinglePass(source, filePath, startingCounter) {
21512
22220
  replacements.push({ start: arrowStart, end: arrowEnd, text: name2 });
21513
22221
  return true;
21514
22222
  }
21515
- ts16.forEachChild(sourceFile, visit3);
22223
+ ts17.forEachChild(sourceFile, visit3);
21516
22224
  if (replacements.length === 0) {
21517
22225
  return { source, errors, syntheticNames, counterAfter: counter };
21518
22226
  }
@@ -21531,33 +22239,33 @@ function errorMessageForCapture(captures) {
21531
22239
  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.`;
21532
22240
  }
21533
22241
  function arrowBodyContainsJsx(arrow) {
21534
- if (ts16.isBlock(arrow.body)) {
22242
+ if (ts17.isBlock(arrow.body)) {
21535
22243
  return blockReturnsJsx(arrow.body);
21536
22244
  }
21537
22245
  let body2 = arrow.body;
21538
- while (ts16.isParenthesizedExpression(body2)) body2 = body2.expression;
22246
+ while (ts17.isParenthesizedExpression(body2)) body2 = body2.expression;
21539
22247
  return isJsxLike(body2);
21540
22248
  }
21541
22249
  function blockReturnsJsx(block) {
21542
22250
  let found = false;
21543
22251
  function visit3(n) {
21544
22252
  if (found) return;
21545
- if (ts16.isReturnStatement(n) && n.expression) {
22253
+ if (ts17.isReturnStatement(n) && n.expression) {
21546
22254
  let e = n.expression;
21547
- while (ts16.isParenthesizedExpression(e)) e = e.expression;
22255
+ while (ts17.isParenthesizedExpression(e)) e = e.expression;
21548
22256
  if (isJsxLike(e)) {
21549
22257
  found = true;
21550
22258
  return;
21551
22259
  }
21552
22260
  }
21553
- if (ts16.isArrowFunction(n) || ts16.isFunctionDeclaration(n) || ts16.isFunctionExpression(n)) return;
21554
- ts16.forEachChild(n, visit3);
22261
+ if (ts17.isArrowFunction(n) || ts17.isFunctionDeclaration(n) || ts17.isFunctionExpression(n)) return;
22262
+ ts17.forEachChild(n, visit3);
21555
22263
  }
21556
- ts16.forEachChild(block, visit3);
22264
+ ts17.forEachChild(block, visit3);
21557
22265
  return found;
21558
22266
  }
21559
22267
  function isJsxLike(expr) {
21560
- return ts16.isJsxElement(expr) || ts16.isJsxSelfClosingElement(expr) || ts16.isJsxFragment(expr);
22268
+ return ts17.isJsxElement(expr) || ts17.isJsxSelfClosingElement(expr) || ts17.isJsxFragment(expr);
21561
22269
  }
21562
22270
  function collectArrowParamNames(arrow) {
21563
22271
  const names = /* @__PURE__ */ new Set();
@@ -21566,13 +22274,13 @@ function collectArrowParamNames(arrow) {
21566
22274
  }
21567
22275
  function collectBindingNames2(name2, out) {
21568
22276
  const push = Array.isArray(out) ? (n) => out.push(n) : (n) => out.add(n);
21569
- if (ts16.isIdentifier(name2)) {
22277
+ if (ts17.isIdentifier(name2)) {
21570
22278
  push(name2.text);
21571
- } else if (ts16.isObjectBindingPattern(name2)) {
22279
+ } else if (ts17.isObjectBindingPattern(name2)) {
21572
22280
  name2.elements.forEach((el) => collectBindingNames2(el.name, out));
21573
- } else if (ts16.isArrayBindingPattern(name2)) {
22281
+ } else if (ts17.isArrayBindingPattern(name2)) {
21574
22282
  name2.elements.forEach((el) => {
21575
- if (!ts16.isOmittedExpression(el)) collectBindingNames2(el.name, out);
22283
+ if (!ts17.isOmittedExpression(el)) collectBindingNames2(el.name, out);
21576
22284
  });
21577
22285
  }
21578
22286
  }
@@ -21597,71 +22305,71 @@ function collectFreeIdentifiers(arrow) {
21597
22305
  return bound.includes(name2);
21598
22306
  }
21599
22307
  function visit3(node) {
21600
- if (ts16.isIdentifier(node)) {
22308
+ if (ts17.isIdentifier(node)) {
21601
22309
  const parent2 = node.parent;
21602
- if (parent2 && ts16.isPropertyAccessExpression(parent2) && parent2.name === node) return;
21603
- if (parent2 && ts16.isPropertyAssignment(parent2) && parent2.name === node) return;
21604
- if (parent2 && ts16.isPropertySignature(parent2) && parent2.name === node) return;
21605
- if (parent2 && ts16.isPropertyDeclaration(parent2) && parent2.name === node) return;
21606
- if (parent2 && ts16.isMethodDeclaration(parent2) && parent2.name === node) return;
21607
- if (parent2 && ts16.isMethodSignature(parent2) && parent2.name === node) return;
21608
- if (parent2 && ts16.isGetAccessorDeclaration(parent2) && parent2.name === node) return;
21609
- if (parent2 && ts16.isSetAccessorDeclaration(parent2) && parent2.name === node) return;
21610
- if (parent2 && ts16.isEnumMember(parent2) && parent2.name === node) return;
21611
- if (parent2 && ts16.isBindingElement(parent2) && parent2.propertyName === node) return;
21612
- if (parent2 && ts16.isShorthandPropertyAssignment(parent2) && parent2.name === node) {
22310
+ if (parent2 && ts17.isPropertyAccessExpression(parent2) && parent2.name === node) return;
22311
+ if (parent2 && ts17.isPropertyAssignment(parent2) && parent2.name === node) return;
22312
+ if (parent2 && ts17.isPropertySignature(parent2) && parent2.name === node) return;
22313
+ if (parent2 && ts17.isPropertyDeclaration(parent2) && parent2.name === node) return;
22314
+ if (parent2 && ts17.isMethodDeclaration(parent2) && parent2.name === node) return;
22315
+ if (parent2 && ts17.isMethodSignature(parent2) && parent2.name === node) return;
22316
+ if (parent2 && ts17.isGetAccessorDeclaration(parent2) && parent2.name === node) return;
22317
+ if (parent2 && ts17.isSetAccessorDeclaration(parent2) && parent2.name === node) return;
22318
+ if (parent2 && ts17.isEnumMember(parent2) && parent2.name === node) return;
22319
+ if (parent2 && ts17.isBindingElement(parent2) && parent2.propertyName === node) return;
22320
+ if (parent2 && ts17.isShorthandPropertyAssignment(parent2) && parent2.name === node) {
21613
22321
  if (!isBound(node.text)) ids.add(node.text);
21614
22322
  return;
21615
22323
  }
21616
- if (parent2 && ts16.isParameter(parent2) && parent2.name === node) return;
21617
- if (parent2 && ts16.isVariableDeclaration(parent2) && parent2.name === node) return;
21618
- if (parent2 && ts16.isFunctionDeclaration(parent2) && parent2.name === node) return;
21619
- if (parent2 && ts16.isClassDeclaration(parent2) && parent2.name === node) return;
21620
- if (parent2 && ts16.isJsxAttribute(parent2) && parent2.name === node) return;
21621
- if (parent2 && ts16.isJsxOpeningElement(parent2) && parent2.tagName === node) {
22324
+ if (parent2 && ts17.isParameter(parent2) && parent2.name === node) return;
22325
+ if (parent2 && ts17.isVariableDeclaration(parent2) && parent2.name === node) return;
22326
+ if (parent2 && ts17.isFunctionDeclaration(parent2) && parent2.name === node) return;
22327
+ if (parent2 && ts17.isClassDeclaration(parent2) && parent2.name === node) return;
22328
+ if (parent2 && ts17.isJsxAttribute(parent2) && parent2.name === node) return;
22329
+ if (parent2 && ts17.isJsxOpeningElement(parent2) && parent2.tagName === node) {
21622
22330
  if (/^[a-z]/.test(node.text)) return;
21623
22331
  }
21624
- if (parent2 && ts16.isJsxClosingElement(parent2) && parent2.tagName === node) {
22332
+ if (parent2 && ts17.isJsxClosingElement(parent2) && parent2.tagName === node) {
21625
22333
  if (/^[a-z]/.test(node.text)) return;
21626
22334
  }
21627
22335
  if (isBound(node.text)) return;
21628
22336
  ids.add(node.text);
21629
22337
  return;
21630
22338
  }
21631
- if (ts16.isVariableDeclaration(node)) {
22339
+ if (ts17.isVariableDeclaration(node)) {
21632
22340
  const declared = pushBindings(node.name);
21633
22341
  if (node.initializer) visit3(node.initializer);
21634
22342
  declared;
21635
22343
  return;
21636
22344
  }
21637
- if (ts16.isFunctionDeclaration(node)) {
22345
+ if (ts17.isFunctionDeclaration(node)) {
21638
22346
  if (node.name) bound.push(node.name.text);
21639
22347
  visitInsideNewScope(node);
21640
22348
  return;
21641
22349
  }
21642
- if (ts16.isClassDeclaration(node)) {
22350
+ if (ts17.isClassDeclaration(node)) {
21643
22351
  if (node.name) bound.push(node.name.text);
21644
- ts16.forEachChild(node, visit3);
22352
+ ts17.forEachChild(node, visit3);
21645
22353
  return;
21646
22354
  }
21647
- if (ts16.isArrowFunction(node) || ts16.isFunctionExpression(node)) {
22355
+ if (ts17.isArrowFunction(node) || ts17.isFunctionExpression(node)) {
21648
22356
  visitInsideNewScope(node);
21649
22357
  return;
21650
22358
  }
21651
- if (ts16.isCatchClause(node)) {
22359
+ if (ts17.isCatchClause(node)) {
21652
22360
  const before = bound.length;
21653
22361
  if (node.variableDeclaration) pushBindings(node.variableDeclaration.name);
21654
- ts16.forEachChild(node, visit3);
22362
+ ts17.forEachChild(node, visit3);
21655
22363
  popN(bound.length - before);
21656
22364
  return;
21657
22365
  }
21658
- if (ts16.isBlock(node)) {
22366
+ if (ts17.isBlock(node)) {
21659
22367
  const before = bound.length;
21660
- ts16.forEachChild(node, visit3);
22368
+ ts17.forEachChild(node, visit3);
21661
22369
  popN(bound.length - before);
21662
22370
  return;
21663
22371
  }
21664
- ts16.forEachChild(node, visit3);
22372
+ ts17.forEachChild(node, visit3);
21665
22373
  }
21666
22374
  function visitInsideNewScope(fn) {
21667
22375
  const before = bound.length;
@@ -21681,27 +22389,27 @@ function collectFreeIdentifiers(arrow) {
21681
22389
  function collectModuleScopeNames(sourceFile) {
21682
22390
  const names = /* @__PURE__ */ new Set();
21683
22391
  for (const stmt of sourceFile.statements) {
21684
- if (ts16.isFunctionDeclaration(stmt) && stmt.name) names.add(stmt.name.text);
21685
- else if (ts16.isClassDeclaration(stmt) && stmt.name) names.add(stmt.name.text);
21686
- else if (ts16.isVariableStatement(stmt)) {
22392
+ if (ts17.isFunctionDeclaration(stmt) && stmt.name) names.add(stmt.name.text);
22393
+ else if (ts17.isClassDeclaration(stmt) && stmt.name) names.add(stmt.name.text);
22394
+ else if (ts17.isVariableStatement(stmt)) {
21687
22395
  for (const decl of stmt.declarationList.declarations) collectBindingNames2(decl.name, names);
21688
- } else if (ts16.isImportDeclaration(stmt) && stmt.importClause) {
22396
+ } else if (ts17.isImportDeclaration(stmt) && stmt.importClause) {
21689
22397
  const ic = stmt.importClause;
21690
22398
  if (ic.name) names.add(ic.name.text);
21691
22399
  if (ic.namedBindings) {
21692
- if (ts16.isNamespaceImport(ic.namedBindings)) names.add(ic.namedBindings.name.text);
22400
+ if (ts17.isNamespaceImport(ic.namedBindings)) names.add(ic.namedBindings.name.text);
21693
22401
  else for (const e of ic.namedBindings.elements) names.add(e.name.text);
21694
22402
  }
21695
- } else if (ts16.isTypeAliasDeclaration(stmt)) names.add(stmt.name.text);
21696
- else if (ts16.isInterfaceDeclaration(stmt)) names.add(stmt.name.text);
21697
- else if (ts16.isEnumDeclaration(stmt)) names.add(stmt.name.text);
22403
+ } else if (ts17.isTypeAliasDeclaration(stmt)) names.add(stmt.name.text);
22404
+ else if (ts17.isInterfaceDeclaration(stmt)) names.add(stmt.name.text);
22405
+ else if (ts17.isEnumDeclaration(stmt)) names.add(stmt.name.text);
21698
22406
  }
21699
22407
  return names;
21700
22408
  }
21701
22409
  function buildSyntheticDeclaration(name2, arrow, sourceFile) {
21702
22410
  const paramsText = arrow.parameters.length === 0 ? "" : arrow.parameters.map((p) => p.getText(sourceFile)).join(", ");
21703
22411
  let bodyText;
21704
- if (ts16.isBlock(arrow.body)) {
22412
+ if (ts17.isBlock(arrow.body)) {
21705
22413
  bodyText = arrow.body.getText(sourceFile);
21706
22414
  } else {
21707
22415
  const expr = arrow.body.getText(sourceFile);
@@ -21720,7 +22428,7 @@ var init_preprocess_inline_jsx_callbacks = __esm({
21720
22428
  });
21721
22429
 
21722
22430
  // ../jsx/src/ssr-defaults.ts
21723
- import ts17 from "typescript";
22431
+ import ts18 from "typescript";
21724
22432
  function extractSsrDefaults(metadata) {
21725
22433
  const out = {};
21726
22434
  const propsLike = /* @__PURE__ */ new Set();
@@ -21780,11 +22488,11 @@ function collectPropRefs(expr, propsObjectName, out) {
21780
22488
  const node = parseExpression2(expr);
21781
22489
  if (!node) return;
21782
22490
  const visit3 = (n) => {
21783
- if (ts17.isPropertyAccessExpression(n) && ts17.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts17.isIdentifier(n.name)) {
22491
+ if (ts18.isPropertyAccessExpression(n) && ts18.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts18.isIdentifier(n.name)) {
21784
22492
  out.add(n.name.text);
21785
22493
  return;
21786
22494
  }
21787
- ts17.forEachChild(n, visit3);
22495
+ ts18.forEachChild(n, visit3);
21788
22496
  };
21789
22497
  visit3(node);
21790
22498
  }
@@ -21801,21 +22509,21 @@ function tryStaticEval(expr, ctx2) {
21801
22509
  }
21802
22510
  function evalStatementsForReturn(statements, ctx2) {
21803
22511
  for (const stmt of statements) {
21804
- if (ts17.isVariableStatement(stmt)) {
22512
+ if (ts18.isVariableStatement(stmt)) {
21805
22513
  for (const d of stmt.declarationList.declarations) {
21806
- if (!ts17.isIdentifier(d.name) || !d.initializer) continue;
22514
+ if (!ts18.isIdentifier(d.name) || !d.initializer) continue;
21807
22515
  const v = evalNode(d.initializer, ctx2);
21808
22516
  if (v !== UNRESOLVED) ctx2.bindings[d.name.text] = v;
21809
22517
  }
21810
- } else if (ts17.isReturnStatement(stmt)) {
22518
+ } else if (ts18.isReturnStatement(stmt)) {
21811
22519
  return stmt.expression ? evalNode(stmt.expression, ctx2) : UNRESOLVED;
21812
- } else if (ts17.isIfStatement(stmt)) {
22520
+ } else if (ts18.isIfStatement(stmt)) {
21813
22521
  const cond = evalNode(stmt.expression, ctx2);
21814
22522
  if (cond === UNRESOLVED) return UNRESOLVED;
21815
22523
  const branch = cond ? stmt.thenStatement : stmt.elseStatement;
21816
22524
  if (branch) {
21817
22525
  const taken = evalStatementsForReturn(
21818
- ts17.isBlock(branch) ? branch.statements : [branch],
22526
+ ts18.isBlock(branch) ? branch.statements : [branch],
21819
22527
  ctx2
21820
22528
  );
21821
22529
  if (taken !== NO_RETURN) return taken;
@@ -21827,64 +22535,64 @@ function evalStatementsForReturn(statements, ctx2) {
21827
22535
  return NO_RETURN;
21828
22536
  }
21829
22537
  function parseExpression2(expr) {
21830
- const sf = ts17.createSourceFile(
22538
+ const sf = ts18.createSourceFile(
21831
22539
  "__ssr_default__.ts",
21832
22540
  `(${expr})`,
21833
- ts17.ScriptTarget.Latest,
22541
+ ts18.ScriptTarget.Latest,
21834
22542
  false,
21835
- ts17.ScriptKind.TS
22543
+ ts18.ScriptKind.TS
21836
22544
  );
21837
22545
  const stmt = sf.statements[0];
21838
- if (!stmt || !ts17.isExpressionStatement(stmt)) return null;
21839
- const inner = ts17.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
22546
+ if (!stmt || !ts18.isExpressionStatement(stmt)) return null;
22547
+ const inner = ts18.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
21840
22548
  return inner;
21841
22549
  }
21842
22550
  function evalNode(node, ctx2) {
21843
- if (ts17.isParenthesizedExpression(node)) return evalNode(node.expression, ctx2);
21844
- if (ts17.isAsExpression(node)) return evalNode(node.expression, ctx2);
21845
- if (ts17.isSatisfiesExpression(node)) return evalNode(node.expression, ctx2);
21846
- if (ts17.isTypeAssertionExpression(node)) return evalNode(node.expression, ctx2);
21847
- if (ts17.isNonNullExpression(node)) return evalNode(node.expression, ctx2);
21848
- if (ts17.isArrowFunction(node)) {
22551
+ if (ts18.isParenthesizedExpression(node)) return evalNode(node.expression, ctx2);
22552
+ if (ts18.isAsExpression(node)) return evalNode(node.expression, ctx2);
22553
+ if (ts18.isSatisfiesExpression(node)) return evalNode(node.expression, ctx2);
22554
+ if (ts18.isTypeAssertionExpression(node)) return evalNode(node.expression, ctx2);
22555
+ if (ts18.isNonNullExpression(node)) return evalNode(node.expression, ctx2);
22556
+ if (ts18.isArrowFunction(node)) {
21849
22557
  if (node.parameters.length !== 0) return UNRESOLVED;
21850
- if (!ts17.isBlock(node.body)) return evalNode(node.body, ctx2);
22558
+ if (!ts18.isBlock(node.body)) return evalNode(node.body, ctx2);
21851
22559
  const localBindings = { ...ctx2.bindings };
21852
22560
  const localCtx = { ...ctx2, bindings: localBindings };
21853
22561
  const result2 = evalStatementsForReturn(node.body.statements, localCtx);
21854
22562
  return result2 === NO_RETURN ? UNRESOLVED : result2;
21855
22563
  }
21856
- if (ts17.isNumericLiteral(node)) return Number(node.text);
21857
- if (ts17.isStringLiteralLike(node)) return node.text;
21858
- if (node.kind === ts17.SyntaxKind.TrueKeyword) return true;
21859
- if (node.kind === ts17.SyntaxKind.FalseKeyword) return false;
21860
- if (node.kind === ts17.SyntaxKind.NullKeyword) return null;
21861
- if (ts17.isIdentifier(node)) {
22564
+ if (ts18.isNumericLiteral(node)) return Number(node.text);
22565
+ if (ts18.isStringLiteralLike(node)) return node.text;
22566
+ if (node.kind === ts18.SyntaxKind.TrueKeyword) return true;
22567
+ if (node.kind === ts18.SyntaxKind.FalseKeyword) return false;
22568
+ if (node.kind === ts18.SyntaxKind.NullKeyword) return null;
22569
+ if (ts18.isIdentifier(node)) {
21862
22570
  if (node.text === "undefined") return void 0;
21863
22571
  if (node.text in ctx2.bindings) return ctx2.bindings[node.text];
21864
22572
  if (ctx2.propsLike.has(node.text)) return void 0;
21865
22573
  return UNRESOLVED;
21866
22574
  }
21867
- if (ts17.isPrefixUnaryExpression(node)) {
22575
+ if (ts18.isPrefixUnaryExpression(node)) {
21868
22576
  const arg = evalNode(node.operand, ctx2);
21869
22577
  if (arg === UNRESOLVED) return UNRESOLVED;
21870
22578
  switch (node.operator) {
21871
- case ts17.SyntaxKind.MinusToken:
22579
+ case ts18.SyntaxKind.MinusToken:
21872
22580
  return typeof arg === "number" ? -arg : UNRESOLVED;
21873
- case ts17.SyntaxKind.PlusToken:
22581
+ case ts18.SyntaxKind.PlusToken:
21874
22582
  return typeof arg === "number" ? +arg : UNRESOLVED;
21875
- case ts17.SyntaxKind.ExclamationToken:
22583
+ case ts18.SyntaxKind.ExclamationToken:
21876
22584
  return !arg;
21877
22585
  }
21878
22586
  return UNRESOLVED;
21879
22587
  }
21880
- if (ts17.isObjectLiteralExpression(node)) {
22588
+ if (ts18.isObjectLiteralExpression(node)) {
21881
22589
  const obj = {};
21882
22590
  for (const prop of node.properties) {
21883
- if (!ts17.isPropertyAssignment(prop)) return UNRESOLVED;
22591
+ if (!ts18.isPropertyAssignment(prop)) return UNRESOLVED;
21884
22592
  let key;
21885
- if (ts17.isIdentifier(prop.name) || ts17.isStringLiteralLike(prop.name)) {
22593
+ if (ts18.isIdentifier(prop.name) || ts18.isStringLiteralLike(prop.name)) {
21886
22594
  key = prop.name.text;
21887
- } else if (ts17.isNumericLiteral(prop.name)) {
22595
+ } else if (ts18.isNumericLiteral(prop.name)) {
21888
22596
  key = prop.name.text;
21889
22597
  } else {
21890
22598
  return UNRESOLVED;
@@ -21895,17 +22603,17 @@ function evalNode(node, ctx2) {
21895
22603
  }
21896
22604
  return obj;
21897
22605
  }
21898
- if (ts17.isArrayLiteralExpression(node)) {
22606
+ if (ts18.isArrayLiteralExpression(node)) {
21899
22607
  const arr = [];
21900
22608
  for (const elem of node.elements) {
21901
- if (ts17.isOmittedExpression(elem)) return UNRESOLVED;
22609
+ if (ts18.isOmittedExpression(elem)) return UNRESOLVED;
21902
22610
  const v = evalNode(elem, ctx2);
21903
22611
  if (v === UNRESOLVED) return UNRESOLVED;
21904
22612
  arr.push(v === void 0 ? null : v);
21905
22613
  }
21906
22614
  return arr;
21907
22615
  }
21908
- if (ts17.isElementAccessExpression(node)) {
22616
+ if (ts18.isElementAccessExpression(node)) {
21909
22617
  const base = evalNode(node.expression, ctx2);
21910
22618
  if (base === void 0) return void 0;
21911
22619
  if (base === UNRESOLVED || base === null || typeof base !== "object") return UNRESOLVED;
@@ -21915,16 +22623,16 @@ function evalNode(node, ctx2) {
21915
22623
  const k = String(key);
21916
22624
  return Object.prototype.hasOwnProperty.call(base, k) ? base[k] : void 0;
21917
22625
  }
21918
- if (ts17.isPropertyAccessExpression(node)) {
22626
+ if (ts18.isPropertyAccessExpression(node)) {
21919
22627
  const baseResult = evalNode(node.expression, ctx2);
21920
22628
  if (baseResult === void 0) return void 0;
21921
22629
  return UNRESOLVED;
21922
22630
  }
21923
- if (ts17.isCallExpression(node)) {
21924
- if (node.arguments.length === 0 && ts17.isIdentifier(node.expression) && node.expression.text in ctx2.bindings) {
22631
+ if (ts18.isCallExpression(node)) {
22632
+ if (node.arguments.length === 0 && ts18.isIdentifier(node.expression) && node.expression.text in ctx2.bindings) {
21925
22633
  return ctx2.bindings[node.expression.text];
21926
22634
  }
21927
- if (ts17.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
22635
+ if (ts18.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
21928
22636
  const recv = evalNode(node.expression.expression, ctx2);
21929
22637
  if (Array.isArray(recv)) {
21930
22638
  let sep = ",";
@@ -21939,24 +22647,24 @@ function evalNode(node, ctx2) {
21939
22647
  }
21940
22648
  return UNRESOLVED;
21941
22649
  }
21942
- if (ts17.isConditionalExpression(node)) {
22650
+ if (ts18.isConditionalExpression(node)) {
21943
22651
  const cond = evalNode(node.condition, ctx2);
21944
22652
  if (cond === UNRESOLVED) return UNRESOLVED;
21945
22653
  return cond ? evalNode(node.whenTrue, ctx2) : evalNode(node.whenFalse, ctx2);
21946
22654
  }
21947
- if (ts17.isBinaryExpression(node)) {
22655
+ if (ts18.isBinaryExpression(node)) {
21948
22656
  const op = node.operatorToken.kind;
21949
- if (op === ts17.SyntaxKind.QuestionQuestionToken) {
22657
+ if (op === ts18.SyntaxKind.QuestionQuestionToken) {
21950
22658
  const l2 = evalNode(node.left, ctx2);
21951
22659
  if (l2 !== UNRESOLVED && l2 !== null && l2 !== void 0) return l2;
21952
22660
  return evalNode(node.right, ctx2);
21953
22661
  }
21954
- if (op === ts17.SyntaxKind.BarBarToken) {
22662
+ if (op === ts18.SyntaxKind.BarBarToken) {
21955
22663
  const l2 = evalNode(node.left, ctx2);
21956
22664
  if (l2 !== UNRESOLVED && l2) return l2;
21957
22665
  return evalNode(node.right, ctx2);
21958
22666
  }
21959
- if (op === ts17.SyntaxKind.AmpersandAmpersandToken) {
22667
+ if (op === ts18.SyntaxKind.AmpersandAmpersandToken) {
21960
22668
  const l2 = evalNode(node.left, ctx2);
21961
22669
  if (l2 === UNRESOLVED) return UNRESOLVED;
21962
22670
  if (!l2) return l2;
@@ -21966,28 +22674,28 @@ function evalNode(node, ctx2) {
21966
22674
  const r2 = evalNode(node.right, ctx2);
21967
22675
  if (l === UNRESOLVED || r2 === UNRESOLVED) return UNRESOLVED;
21968
22676
  switch (op) {
21969
- case ts17.SyntaxKind.PlusToken:
22677
+ case ts18.SyntaxKind.PlusToken:
21970
22678
  if (typeof l === "string" || typeof r2 === "string") return `${l}${r2}`;
21971
22679
  if (typeof l === "number" && typeof r2 === "number") return l + r2;
21972
22680
  return UNRESOLVED;
21973
- case ts17.SyntaxKind.MinusToken:
22681
+ case ts18.SyntaxKind.MinusToken:
21974
22682
  return typeof l === "number" && typeof r2 === "number" ? l - r2 : UNRESOLVED;
21975
- case ts17.SyntaxKind.AsteriskToken:
22683
+ case ts18.SyntaxKind.AsteriskToken:
21976
22684
  return typeof l === "number" && typeof r2 === "number" ? l * r2 : UNRESOLVED;
21977
- case ts17.SyntaxKind.SlashToken:
22685
+ case ts18.SyntaxKind.SlashToken:
21978
22686
  return typeof l === "number" && typeof r2 === "number" && r2 !== 0 ? l / r2 : UNRESOLVED;
21979
- case ts17.SyntaxKind.PercentToken:
22687
+ case ts18.SyntaxKind.PercentToken:
21980
22688
  return typeof l === "number" && typeof r2 === "number" && r2 !== 0 ? l % r2 : UNRESOLVED;
21981
- case ts17.SyntaxKind.EqualsEqualsEqualsToken:
21982
- case ts17.SyntaxKind.EqualsEqualsToken:
22689
+ case ts18.SyntaxKind.EqualsEqualsEqualsToken:
22690
+ case ts18.SyntaxKind.EqualsEqualsToken:
21983
22691
  return l === r2;
21984
- case ts17.SyntaxKind.ExclamationEqualsEqualsToken:
21985
- case ts17.SyntaxKind.ExclamationEqualsToken:
22692
+ case ts18.SyntaxKind.ExclamationEqualsEqualsToken:
22693
+ case ts18.SyntaxKind.ExclamationEqualsToken:
21986
22694
  return l !== r2;
21987
22695
  }
21988
22696
  return UNRESOLVED;
21989
22697
  }
21990
- if (ts17.isTemplateExpression(node)) {
22698
+ if (ts18.isTemplateExpression(node)) {
21991
22699
  if (node.templateSpans.length === 0) return node.head.text;
21992
22700
  let acc = node.head.text;
21993
22701
  for (const span of node.templateSpans) {
@@ -21997,7 +22705,7 @@ function evalNode(node, ctx2) {
21997
22705
  }
21998
22706
  return acc;
21999
22707
  }
22000
- if (ts17.isNoSubstitutionTemplateLiteral(node)) return node.text;
22708
+ if (ts18.isNoSubstitutionTemplateLiteral(node)) return node.text;
22001
22709
  return UNRESOLVED;
22002
22710
  }
22003
22711
  var UNRESOLVED, NO_RETURN;
@@ -22010,7 +22718,7 @@ var init_ssr_defaults = __esm({
22010
22718
  });
22011
22719
 
22012
22720
  // ../jsx/src/augment-inherited-props.ts
22013
- import ts18 from "typescript";
22721
+ import ts19 from "typescript";
22014
22722
  function collectContextConsumers(metadata) {
22015
22723
  const constants = metadata.localConstants ?? [];
22016
22724
  const contextDefaults = /* @__PURE__ */ new Map();
@@ -22037,35 +22745,35 @@ function collectContextConsumers(metadata) {
22037
22745
  }
22038
22746
  function parseUseContextArg(source) {
22039
22747
  const expr = parseSingleExpression(source);
22040
- if (!expr || !ts18.isCallExpression(expr)) return null;
22041
- if (!ts18.isIdentifier(expr.expression) || expr.expression.text !== "useContext") return null;
22748
+ if (!expr || !ts19.isCallExpression(expr)) return null;
22749
+ if (!ts19.isIdentifier(expr.expression) || expr.expression.text !== "useContext") return null;
22042
22750
  if (expr.arguments.length !== 1) return null;
22043
22751
  const arg = expr.arguments[0];
22044
- return ts18.isIdentifier(arg) ? arg.text : null;
22752
+ return ts19.isIdentifier(arg) ? arg.text : null;
22045
22753
  }
22046
22754
  function parseCreateContextDefault(source) {
22047
22755
  const expr = parseSingleExpression(source);
22048
- if (!expr || !ts18.isCallExpression(expr)) return null;
22756
+ if (!expr || !ts19.isCallExpression(expr)) return null;
22049
22757
  if (expr.arguments.length === 0) return null;
22050
22758
  const arg = expr.arguments[0];
22051
- if (ts18.isStringLiteral(arg) || ts18.isNoSubstitutionTemplateLiteral(arg)) return arg.text;
22052
- if (ts18.isNumericLiteral(arg)) return Number(arg.text);
22053
- if (arg.kind === ts18.SyntaxKind.TrueKeyword) return true;
22054
- if (arg.kind === ts18.SyntaxKind.FalseKeyword) return false;
22759
+ if (ts19.isStringLiteral(arg) || ts19.isNoSubstitutionTemplateLiteral(arg)) return arg.text;
22760
+ if (ts19.isNumericLiteral(arg)) return Number(arg.text);
22761
+ if (arg.kind === ts19.SyntaxKind.TrueKeyword) return true;
22762
+ if (arg.kind === ts19.SyntaxKind.FalseKeyword) return false;
22055
22763
  return null;
22056
22764
  }
22057
22765
  function isObjectLiteralCreateContextDefault(source) {
22058
22766
  const expr = parseSingleExpression(source);
22059
- if (!expr || !ts18.isCallExpression(expr)) return false;
22767
+ if (!expr || !ts19.isCallExpression(expr)) return false;
22060
22768
  if (expr.arguments.length === 0) return false;
22061
- return ts18.isObjectLiteralExpression(expr.arguments[0]);
22769
+ return ts19.isObjectLiteralExpression(expr.arguments[0]);
22062
22770
  }
22063
22771
  function parseSingleExpression(source) {
22064
- const sf = ts18.createSourceFile("__ctx.ts", `(${source})`, ts18.ScriptTarget.Latest, false);
22772
+ const sf = ts19.createSourceFile("__ctx.ts", `(${source})`, ts19.ScriptTarget.Latest, false);
22065
22773
  const stmt = sf.statements[0];
22066
- if (!stmt || !ts18.isExpressionStatement(stmt)) return null;
22774
+ if (!stmt || !ts19.isExpressionStatement(stmt)) return null;
22067
22775
  let e = stmt.expression;
22068
- while (ts18.isParenthesizedExpression(e)) e = e.expression;
22776
+ while (ts19.isParenthesizedExpression(e)) e = e.expression;
22069
22777
  return e;
22070
22778
  }
22071
22779
  function augmentInheritedPropAccesses(ir) {
@@ -22086,21 +22794,21 @@ function augmentInheritedPropAccesses(ir) {
22086
22794
  const coalesceLiteralTypes = /* @__PURE__ */ new Map();
22087
22795
  const pinCoalesceLiterals = (s) => {
22088
22796
  if (!s || !s.includes(propsObj)) return;
22089
- const sf = ts18.createSourceFile("__aug.ts", `(${s})`, ts18.ScriptTarget.Latest, false);
22797
+ const sf = ts19.createSourceFile("__aug.ts", `(${s})`, ts19.ScriptTarget.Latest, false);
22090
22798
  const visit3 = (n) => {
22091
- if (ts18.isBinaryExpression(n) && (n.operatorToken.kind === ts18.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts18.SyntaxKind.BarBarToken)) {
22799
+ if (ts19.isBinaryExpression(n) && (n.operatorToken.kind === ts19.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts19.SyntaxKind.BarBarToken)) {
22092
22800
  let left = n.left;
22093
- while (ts18.isParenthesizedExpression(left)) left = left.expression;
22094
- if (ts18.isPropertyAccessExpression(left) && ts18.isIdentifier(left.expression) && left.expression.text === propsObj) {
22801
+ while (ts19.isParenthesizedExpression(left)) left = left.expression;
22802
+ if (ts19.isPropertyAccessExpression(left) && ts19.isIdentifier(left.expression) && left.expression.text === propsObj) {
22095
22803
  const name2 = left.name.text;
22096
22804
  let right = n.right;
22097
- while (ts18.isParenthesizedExpression(right)) right = right.expression;
22098
- if (ts18.isPrefixUnaryExpression(right)) right = right.operand;
22099
- const kind2 = ts18.isNumericLiteral(right) ? "number" : right.kind === ts18.SyntaxKind.TrueKeyword || right.kind === ts18.SyntaxKind.FalseKeyword ? "boolean" : ts18.isStringLiteralLike(right) ? "string" : null;
22805
+ while (ts19.isParenthesizedExpression(right)) right = right.expression;
22806
+ if (ts19.isPrefixUnaryExpression(right)) right = right.operand;
22807
+ const kind2 = ts19.isNumericLiteral(right) ? "number" : right.kind === ts19.SyntaxKind.TrueKeyword || right.kind === ts19.SyntaxKind.FalseKeyword ? "boolean" : ts19.isStringLiteralLike(right) ? "string" : null;
22100
22808
  if (kind2 && !coalesceLiteralTypes.has(name2)) coalesceLiteralTypes.set(name2, kind2);
22101
22809
  }
22102
22810
  }
22103
- ts18.forEachChild(n, visit3);
22811
+ ts19.forEachChild(n, visit3);
22104
22812
  };
22105
22813
  visit3(sf);
22106
22814
  };
@@ -22196,39 +22904,39 @@ function augmentInheritedPropAccesses(ir) {
22196
22904
  }
22197
22905
  }
22198
22906
  function parseStaticStringConst(source) {
22199
- const sf = ts18.createSourceFile(
22907
+ const sf = ts19.createSourceFile(
22200
22908
  "__const.ts",
22201
22909
  `const __x = (${source});`,
22202
- ts18.ScriptTarget.Latest,
22910
+ ts19.ScriptTarget.Latest,
22203
22911
  /*setParentNodes*/
22204
22912
  false
22205
22913
  );
22206
22914
  const stmt = sf.statements[0];
22207
- if (!stmt || !ts18.isVariableStatement(stmt)) return null;
22915
+ if (!stmt || !ts19.isVariableStatement(stmt)) return null;
22208
22916
  let init = stmt.declarationList.declarations[0]?.initializer;
22209
- while (init && ts18.isParenthesizedExpression(init)) init = init.expression;
22917
+ while (init && ts19.isParenthesizedExpression(init)) init = init.expression;
22210
22918
  if (!init) return null;
22211
- if (ts18.isStringLiteral(init) || ts18.isNoSubstitutionTemplateLiteral(init)) {
22919
+ if (ts19.isStringLiteral(init) || ts19.isNoSubstitutionTemplateLiteral(init)) {
22212
22920
  return init.text;
22213
22921
  }
22214
22922
  return evalStringArrayJoin(source);
22215
22923
  }
22216
22924
  function evalTemplateOfStringConsts(source, resolved) {
22217
- const sf = ts18.createSourceFile(
22925
+ const sf = ts19.createSourceFile(
22218
22926
  "__const.ts",
22219
22927
  `const __x = (${source});`,
22220
- ts18.ScriptTarget.Latest,
22928
+ ts19.ScriptTarget.Latest,
22221
22929
  /*setParentNodes*/
22222
22930
  false
22223
22931
  );
22224
22932
  const stmt = sf.statements[0];
22225
- if (!stmt || !ts18.isVariableStatement(stmt)) return null;
22933
+ if (!stmt || !ts19.isVariableStatement(stmt)) return null;
22226
22934
  let init = stmt.declarationList.declarations[0]?.initializer;
22227
- while (init && ts18.isParenthesizedExpression(init)) init = init.expression;
22228
- if (!init || !ts18.isTemplateExpression(init)) return null;
22935
+ while (init && ts19.isParenthesizedExpression(init)) init = init.expression;
22936
+ if (!init || !ts19.isTemplateExpression(init)) return null;
22229
22937
  let out = init.head.text;
22230
22938
  for (const span of init.templateSpans) {
22231
- if (!ts18.isIdentifier(span.expression)) return null;
22939
+ if (!ts19.isIdentifier(span.expression)) return null;
22232
22940
  const value2 = resolved.get(span.expression.text);
22233
22941
  if (value2 === void 0) return null;
22234
22942
  out += value2 + span.literal.text;
@@ -22257,28 +22965,28 @@ function collectModuleStringConsts(constants) {
22257
22965
  function lookupStaticRecordLiteral(objectName, key, constants) {
22258
22966
  const constInfo = (constants ?? []).find((c) => c.name === objectName && c.isModule);
22259
22967
  if (constInfo?.value === void 0) return null;
22260
- const sf = ts18.createSourceFile(
22968
+ const sf = ts19.createSourceFile(
22261
22969
  "__rec.ts",
22262
22970
  `(${constInfo.value})`,
22263
- ts18.ScriptTarget.Latest,
22971
+ ts19.ScriptTarget.Latest,
22264
22972
  /*setParentNodes*/
22265
22973
  true
22266
22974
  );
22267
22975
  if (sf.statements.length !== 1) return null;
22268
22976
  const stmt = sf.statements[0];
22269
- if (!ts18.isExpressionStatement(stmt)) return null;
22977
+ if (!ts19.isExpressionStatement(stmt)) return null;
22270
22978
  let parsed = stmt.expression;
22271
- while (ts18.isParenthesizedExpression(parsed)) parsed = parsed.expression;
22272
- if (!ts18.isObjectLiteralExpression(parsed)) return null;
22979
+ while (ts19.isParenthesizedExpression(parsed)) parsed = parsed.expression;
22980
+ if (!ts19.isObjectLiteralExpression(parsed)) return null;
22273
22981
  for (const prop of parsed.properties) {
22274
- if (!ts18.isPropertyAssignment(prop)) continue;
22982
+ if (!ts19.isPropertyAssignment(prop)) continue;
22275
22983
  const name2 = prop.name;
22276
- const propKey = ts18.isIdentifier(name2) || ts18.isStringLiteral(name2) || ts18.isNoSubstitutionTemplateLiteral(name2) ? name2.text : null;
22984
+ const propKey = ts19.isIdentifier(name2) || ts19.isStringLiteral(name2) || ts19.isNoSubstitutionTemplateLiteral(name2) ? name2.text : null;
22277
22985
  if (propKey !== key) continue;
22278
22986
  let v = prop.initializer;
22279
- while (ts18.isParenthesizedExpression(v)) v = v.expression;
22280
- if (ts18.isNumericLiteral(v)) return { kind: "number", text: v.text };
22281
- if (ts18.isStringLiteral(v) || ts18.isNoSubstitutionTemplateLiteral(v)) {
22987
+ while (ts19.isParenthesizedExpression(v)) v = v.expression;
22988
+ if (ts19.isNumericLiteral(v)) return { kind: "number", text: v.text };
22989
+ if (ts19.isStringLiteral(v) || ts19.isNoSubstitutionTemplateLiteral(v)) {
22282
22990
  return { kind: "string", text: v.text };
22283
22991
  }
22284
22992
  return null;
@@ -22286,27 +22994,27 @@ function lookupStaticRecordLiteral(objectName, key, constants) {
22286
22994
  return null;
22287
22995
  }
22288
22996
  function evalStringArrayJoin(source) {
22289
- const sf = ts18.createSourceFile(
22997
+ const sf = ts19.createSourceFile(
22290
22998
  "__join.ts",
22291
22999
  `const __x = (${source});`,
22292
- ts18.ScriptTarget.Latest,
23000
+ ts19.ScriptTarget.Latest,
22293
23001
  /*setParentNodes*/
22294
23002
  false
22295
23003
  );
22296
23004
  const stmt = sf.statements[0];
22297
- if (!stmt || !ts18.isVariableStatement(stmt)) return null;
23005
+ if (!stmt || !ts19.isVariableStatement(stmt)) return null;
22298
23006
  let node = stmt.declarationList.declarations[0]?.initializer;
22299
- while (node && ts18.isParenthesizedExpression(node)) node = node.expression;
22300
- if (!node || !ts18.isCallExpression(node)) return null;
23007
+ while (node && ts19.isParenthesizedExpression(node)) node = node.expression;
23008
+ if (!node || !ts19.isCallExpression(node)) return null;
22301
23009
  const callee = node.expression;
22302
- if (!ts18.isPropertyAccessExpression(callee)) return null;
23010
+ if (!ts19.isPropertyAccessExpression(callee)) return null;
22303
23011
  if (callee.name.text !== "join") return null;
22304
23012
  let recv = callee.expression;
22305
- while (ts18.isParenthesizedExpression(recv)) recv = recv.expression;
22306
- if (!ts18.isArrayLiteralExpression(recv)) return null;
23013
+ while (ts19.isParenthesizedExpression(recv)) recv = recv.expression;
23014
+ if (!ts19.isArrayLiteralExpression(recv)) return null;
22307
23015
  const parts = [];
22308
23016
  for (const el of recv.elements) {
22309
- if (ts18.isStringLiteral(el) || ts18.isNoSubstitutionTemplateLiteral(el)) {
23017
+ if (ts19.isStringLiteral(el) || ts19.isNoSubstitutionTemplateLiteral(el)) {
22310
23018
  parts.push(el.text);
22311
23019
  } else {
22312
23020
  return null;
@@ -22315,16 +23023,16 @@ function evalStringArrayJoin(source) {
22315
23023
  let sep = ",";
22316
23024
  if (node.arguments.length >= 1) {
22317
23025
  const arg = node.arguments[0];
22318
- if (ts18.isStringLiteral(arg) || ts18.isNoSubstitutionTemplateLiteral(arg)) sep = arg.text;
23026
+ if (ts19.isStringLiteral(arg) || ts19.isNoSubstitutionTemplateLiteral(arg)) sep = arg.text;
22319
23027
  else return null;
22320
23028
  }
22321
23029
  return parts.join(sep);
22322
23030
  }
22323
23031
  function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
22324
- if (!ts18.isElementAccessExpression(val)) return null;
23032
+ if (!ts19.isElementAccessExpression(val)) return null;
22325
23033
  const obj = val.expression;
22326
23034
  const arg = val.argumentExpression;
22327
- if (!ts18.isIdentifier(obj) || !ts18.isIdentifier(arg)) return null;
23035
+ if (!ts19.isIdentifier(obj) || !ts19.isIdentifier(arg)) return null;
22328
23036
  let indexPropName;
22329
23037
  let defaultKey;
22330
23038
  const resolved = resolveKey?.(arg.text);
@@ -22338,35 +23046,35 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
22338
23046
  }
22339
23047
  const constInfo = localConstants.find((c) => c.name === obj.text && c.isModule);
22340
23048
  if (constInfo?.value === void 0) return null;
22341
- const sf = ts18.createSourceFile(
23049
+ const sf = ts19.createSourceFile(
22342
23050
  "__rec.ts",
22343
23051
  `(${constInfo.value})`,
22344
- ts18.ScriptTarget.Latest,
23052
+ ts19.ScriptTarget.Latest,
22345
23053
  /* setParentNodes */
22346
23054
  true
22347
23055
  );
22348
23056
  if (sf.statements.length !== 1) return null;
22349
23057
  const stmt = sf.statements[0];
22350
- if (!ts18.isExpressionStatement(stmt)) return null;
23058
+ if (!ts19.isExpressionStatement(stmt)) return null;
22351
23059
  let parsed = stmt.expression;
22352
- while (ts18.isParenthesizedExpression(parsed)) parsed = parsed.expression;
22353
- if (!ts18.isObjectLiteralExpression(parsed)) return null;
23060
+ while (ts19.isParenthesizedExpression(parsed)) parsed = parsed.expression;
23061
+ if (!ts19.isObjectLiteralExpression(parsed)) return null;
22354
23062
  const entries2 = [];
22355
23063
  for (const prop of parsed.properties) {
22356
- if (!ts18.isPropertyAssignment(prop)) return null;
23064
+ if (!ts19.isPropertyAssignment(prop)) return null;
22357
23065
  let key;
22358
- if (ts18.isIdentifier(prop.name)) {
23066
+ if (ts19.isIdentifier(prop.name)) {
22359
23067
  key = prop.name.text;
22360
- } else if (ts18.isStringLiteral(prop.name) || ts18.isNoSubstitutionTemplateLiteral(prop.name)) {
23068
+ } else if (ts19.isStringLiteral(prop.name) || ts19.isNoSubstitutionTemplateLiteral(prop.name)) {
22361
23069
  key = prop.name.text;
22362
23070
  } else {
22363
23071
  return null;
22364
23072
  }
22365
23073
  let v = prop.initializer;
22366
- while (ts18.isParenthesizedExpression(v)) v = v.expression;
22367
- if (ts18.isNumericLiteral(v)) {
23074
+ while (ts19.isParenthesizedExpression(v)) v = v.expression;
23075
+ if (ts19.isNumericLiteral(v)) {
22368
23076
  entries2.push({ key, value: { kind: "number", text: v.text } });
22369
- } else if (ts18.isStringLiteral(v) || ts18.isNoSubstitutionTemplateLiteral(v)) {
23077
+ } else if (ts19.isStringLiteral(v) || ts19.isNoSubstitutionTemplateLiteral(v)) {
22370
23078
  entries2.push({ key, value: { kind: "string", text: v.text } });
22371
23079
  } else {
22372
23080
  return null;
@@ -23001,6 +23709,7 @@ function compileJSX(source, filePath, options2) {
23001
23709
  const sortedRuntimeImports = [...runtimeImports].sort();
23002
23710
  const runtimeImportLine = sortedRuntimeImports.length > 0 ? `import { ${sortedRuntimeImports.join(", ")} } from '${RUNTIME_MODULE}'` : "";
23003
23711
  const externalImportLines = [];
23712
+ const isUsedAsValue = makeValueUsageTest(body2);
23004
23713
  for (const imp of ctx2.imports) {
23005
23714
  if (imp.isTypeOnly) continue;
23006
23715
  if (imp.source === "@barefootjs/client" || imp.source === RUNTIME_MODULE) continue;
@@ -23008,7 +23717,7 @@ function compileJSX(source, filePath, options2) {
23008
23717
  externalImportLines.push(`import '${imp.source}'`);
23009
23718
  continue;
23010
23719
  }
23011
- const used = imp.specifiers.filter((s2) => !s2.isDefault && !s2.isNamespace && new RegExp(`\\b${s2.alias || s2.name}\\b`).test(body2)).map((s2) => s2.alias ? `${s2.name} as ${s2.alias}` : s2.name);
23720
+ 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);
23012
23721
  if (used.length > 0) {
23013
23722
  externalImportLines.push(`import { ${used.join(", ")} } from '${imp.source}'`);
23014
23723
  }
@@ -23039,6 +23748,7 @@ function compileJSX(source, filePath, options2) {
23039
23748
  if (imp.isTypeOnly) continue;
23040
23749
  if (!imp.source.startsWith("./") && !imp.source.startsWith("../")) continue;
23041
23750
  for (const spec of imp.specifiers) {
23751
+ if (spec.isTypeOnly) continue;
23042
23752
  if (ctx2.importedClientSignalNames.has(spec.alias ?? spec.name)) {
23043
23753
  sources.add(imp.source);
23044
23754
  break;
@@ -23168,7 +23878,7 @@ var init_compiler = __esm({
23168
23878
  });
23169
23879
 
23170
23880
  // ../jsx/src/shared-program.ts
23171
- import ts19 from "typescript";
23881
+ import ts20 from "typescript";
23172
23882
  import path5 from "node:path";
23173
23883
  function commonParent(paths) {
23174
23884
  if (paths.length === 0) return process.cwd();
@@ -23186,10 +23896,10 @@ function commonParent(paths) {
23186
23896
  function createProgramForCorpus(files2, options2 = {}) {
23187
23897
  const baseUrl = options2.baseUrl ?? commonParent(files2);
23188
23898
  const compilerOptions = {
23189
- target: ts19.ScriptTarget.Latest,
23190
- module: ts19.ModuleKind.ESNext,
23191
- moduleResolution: ts19.ModuleResolutionKind.Bundler,
23192
- jsx: ts19.JsxEmit.ReactJSX,
23899
+ target: ts20.ScriptTarget.Latest,
23900
+ module: ts20.ModuleKind.ESNext,
23901
+ moduleResolution: ts20.ModuleResolutionKind.Bundler,
23902
+ jsx: ts20.JsxEmit.ReactJSX,
23193
23903
  strict: true,
23194
23904
  skipLibCheck: true,
23195
23905
  noEmit: true,
@@ -23199,7 +23909,7 @@ function createProgramForCorpus(files2, options2 = {}) {
23199
23909
  ...options2.compilerOptions
23200
23910
  };
23201
23911
  const absolute = files2.map((f) => path5.resolve(f));
23202
- return ts19.createProgram(absolute, compilerOptions, void 0, options2.oldProgram);
23912
+ return ts20.createProgram(absolute, compilerOptions, void 0, options2.oldProgram);
23203
23913
  }
23204
23914
  var init_shared_program = __esm({
23205
23915
  "../jsx/src/shared-program.ts"() {
@@ -24268,7 +24978,7 @@ var init_dangerous_inner_html = __esm({
24268
24978
  });
24269
24979
 
24270
24980
  // ../jsx/src/combine-client-js.ts
24271
- import ts20 from "typescript";
24981
+ import ts21 from "typescript";
24272
24982
  function combineParentChildClientJs(files2) {
24273
24983
  const result2 = /* @__PURE__ */ new Map();
24274
24984
  const lookup = /* @__PURE__ */ new Map();
@@ -24325,17 +25035,17 @@ function combineParentChildClientJs(files2) {
24325
25035
  return result2;
24326
25036
  }
24327
25037
  function parseAndMerge(content2, importsBySource, otherImports, codeSections) {
24328
- const sourceFile = ts20.createSourceFile(
25038
+ const sourceFile = ts21.createSourceFile(
24329
25039
  "combine.js",
24330
25040
  content2,
24331
- ts20.ScriptTarget.Latest,
25041
+ ts21.ScriptTarget.Latest,
24332
25042
  /*setParentNodes*/
24333
25043
  false,
24334
- ts20.ScriptKind.JS
25044
+ ts21.ScriptKind.JS
24335
25045
  );
24336
25046
  const importSpans = [];
24337
25047
  for (const stmt of sourceFile.statements) {
24338
- if (!ts20.isImportDeclaration(stmt)) continue;
25048
+ if (!ts21.isImportDeclaration(stmt)) continue;
24339
25049
  const start2 = stmt.getStart(sourceFile);
24340
25050
  const end2 = stmt.getEnd();
24341
25051
  importSpans.push([start2, end2]);
@@ -24343,8 +25053,8 @@ function parseAndMerge(content2, importsBySource, otherImports, codeSections) {
24343
25053
  if (stmtText.includes("@bf-child:")) continue;
24344
25054
  const clause = stmt.importClause;
24345
25055
  const bindings = clause?.namedBindings;
24346
- const specifier = ts20.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
24347
- if (clause && !clause.name && bindings && ts20.isNamedImports(bindings)) {
25056
+ const specifier = ts21.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
25057
+ if (clause && !clause.name && bindings && ts21.isNamedImports(bindings)) {
24348
25058
  if (!importsBySource.has(specifier)) {
24349
25059
  importsBySource.set(specifier, /* @__PURE__ */ new Set());
24350
25060
  }
@@ -24538,7 +25248,7 @@ var init_loop_destructure = __esm({
24538
25248
  });
24539
25249
 
24540
25250
  // ../jsx/src/debug.ts
24541
- import ts21 from "typescript";
25251
+ import ts22 from "typescript";
24542
25252
  function buildComponentGraph(source, filePath, componentName) {
24543
25253
  const ctx2 = analyzeComponent(source, filePath, componentName);
24544
25254
  if (!ctx2.jsxReturn) {
@@ -25750,18 +26460,18 @@ function truncateExpr(expr, max = 40) {
25750
26460
  function exprReadsPropMember(expr, propsObjectName) {
25751
26461
  let sf;
25752
26462
  try {
25753
- sf = ts21.createSourceFile("__attr.tsx", `(${expr})`, ts21.ScriptTarget.Latest, true, ts21.ScriptKind.TSX);
26463
+ sf = ts22.createSourceFile("__attr.tsx", `(${expr})`, ts22.ScriptTarget.Latest, true, ts22.ScriptKind.TSX);
25754
26464
  } catch {
25755
26465
  return false;
25756
26466
  }
25757
26467
  let found = false;
25758
26468
  const visit3 = (n) => {
25759
26469
  if (found) return;
25760
- if (ts21.isPropertyAccessExpression(n) && ts21.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
26470
+ if (ts22.isPropertyAccessExpression(n) && ts22.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
25761
26471
  found = true;
25762
26472
  return;
25763
26473
  }
25764
- ts21.forEachChild(n, visit3);
26474
+ ts22.forEachChild(n, visit3);
25765
26475
  };
25766
26476
  visit3(sf);
25767
26477
  return found;
@@ -25838,7 +26548,7 @@ var init_debug = __esm({
25838
26548
  });
25839
26549
 
25840
26550
  // ../jsx/src/profiler.ts
25841
- import ts22 from "typescript";
26551
+ import ts23 from "typescript";
25842
26552
  function buildStaticBudget(source, filePath, componentName, options2 = {}) {
25843
26553
  const threshold = options2.fanOutThreshold ?? DEFAULT_FANOUT_THRESHOLD;
25844
26554
  const program = createProgramForFile(source, filePath)?.program;
@@ -26093,14 +26803,14 @@ function joinProfilerEvents(events, index) {
26093
26803
  return { joined, unattributed, diagnostics };
26094
26804
  }
26095
26805
  function findUninstrumentedEffects(source, filePath, instrumentedLines) {
26096
- const sf = ts22.createSourceFile(filePath, source, ts22.ScriptTarget.Latest, true, ts22.ScriptKind.TSX);
26806
+ const sf = ts23.createSourceFile(filePath, source, ts23.ScriptTarget.Latest, true, ts23.ScriptKind.TSX);
26097
26807
  const out = [];
26098
26808
  const visit3 = (node) => {
26099
- if (ts22.isCallExpression(node) && ts22.isIdentifier(node.expression) && node.expression.text === "createEffect") {
26809
+ if (ts23.isCallExpression(node) && ts23.isIdentifier(node.expression) && node.expression.text === "createEffect") {
26100
26810
  const line = sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;
26101
26811
  if (!instrumentedLines.has(line)) out.push({ file: filePath, line });
26102
26812
  }
26103
- ts22.forEachChild(node, visit3);
26813
+ ts23.forEachChild(node, visit3);
26104
26814
  };
26105
26815
  visit3(sf);
26106
26816
  out.sort((a, b) => a.line - b.line);
@@ -26386,19 +27096,19 @@ function assessBatchSafety(args2) {
26386
27096
  const signalGetters = new Set(args2.graph.signals.map((s) => s.name));
26387
27097
  let sf;
26388
27098
  try {
26389
- sf = ts22.createSourceFile("__h.ts", `const __h = ${args2.handler}`, ts22.ScriptTarget.Latest, true);
27099
+ sf = ts23.createSourceFile("__h.ts", `const __h = ${args2.handler}`, ts23.ScriptTarget.Latest, true);
26390
27100
  } catch {
26391
27101
  return "unverified";
26392
27102
  }
26393
27103
  const calls = [];
26394
27104
  const visit3 = (node) => {
26395
- if (ts22.isCallExpression(node) && ts22.isIdentifier(node.expression)) {
27105
+ if (ts23.isCallExpression(node) && ts23.isIdentifier(node.expression)) {
26396
27106
  const name2 = node.expression.text;
26397
27107
  if (setters.has(name2)) calls.push({ pos: node.getStart(sf), kind: "write" });
26398
27108
  else if (D.has(name2) && node.arguments.length === 0) calls.push({ pos: node.getStart(sf), kind: "memoRead" });
26399
27109
  else if (!signalGetters.has(name2) && !memoNames.has(name2)) calls.push({ pos: node.getStart(sf), kind: "risky" });
26400
27110
  }
26401
- ts22.forEachChild(node, visit3);
27111
+ ts23.forEachChild(node, visit3);
26402
27112
  };
26403
27113
  visit3(sf);
26404
27114
  calls.sort((a, b) => a.pos - b.pos);
@@ -27091,6 +27801,7 @@ __export(src_exports, {
27091
27801
  collectContextConsumers: () => collectContextConsumers,
27092
27802
  collectLoopBoundNames: () => collectLoopBoundNames,
27093
27803
  collectModuleStringConsts: () => collectModuleStringConsts,
27804
+ collectValueReferencedNames: () => collectValueReferencedNames,
27094
27805
  combineParentChildClientJs: () => combineParentChildClientJs,
27095
27806
  compileJSX: () => compileJSX,
27096
27807
  computeSsrSeedPlan: () => computeSsrSeedPlan,
@@ -27165,6 +27876,7 @@ __export(src_exports, {
27165
27876
  isStringTypedOperand: () => isStringTypedOperand,
27166
27877
  isSupported: () => isSupported,
27167
27878
  isValidHelperId: () => isValidHelperId,
27879
+ isValueReferenceIdentifier: () => isValueReferenceIdentifier,
27168
27880
  joinProfilerEvents: () => joinProfilerEvents,
27169
27881
  jsxToIR: () => jsxToIR,
27170
27882
  listComponentFunctions: () => listComponentFunctions,
@@ -27241,6 +27953,7 @@ var init_src2 = __esm({
27241
27953
  init_css_layer_prefixer();
27242
27954
  init_instrumentation();
27243
27955
  init_errors();
27956
+ init_value_references();
27244
27957
  init_expression_parser();
27245
27958
  init_expression_parser();
27246
27959
  init_loop_chain();
@@ -27315,7 +28028,7 @@ var init_runtime = __esm({
27315
28028
 
27316
28029
  // src/lib/resolve-imports.ts
27317
28030
  import { dirname as dirname2, resolve as resolve2 } from "node:path";
27318
- import ts23 from "typescript";
28031
+ import ts24 from "typescript";
27319
28032
  function shapeFromDecl(decl) {
27320
28033
  const clause = decl.importClause;
27321
28034
  if (!clause) return null;
@@ -27325,7 +28038,7 @@ function shapeFromDecl(decl) {
27325
28038
  }
27326
28039
  const bindings = clause.namedBindings;
27327
28040
  if (bindings) {
27328
- if (ts23.isNamespaceImport(bindings)) {
28041
+ if (ts24.isNamespaceImport(bindings)) {
27329
28042
  shape.namespace = bindings.name.text;
27330
28043
  } else {
27331
28044
  for (const el of bindings.elements) {
@@ -27337,60 +28050,85 @@ function shapeFromDecl(decl) {
27337
28050
  }
27338
28051
  return shape;
27339
28052
  }
27340
- function collectExportedNames(source) {
27341
- const names = /* @__PURE__ */ new Set();
27342
- const sourceFile = ts23.createSourceFile(
28053
+ function collectExportInfo(source) {
28054
+ const localValueExports = /* @__PURE__ */ new Set();
28055
+ const otherValueExports = /* @__PURE__ */ new Set();
28056
+ const reExportedNames = /* @__PURE__ */ new Set();
28057
+ let hasStarReExport = false;
28058
+ const sourceFile = ts24.createSourceFile(
27343
28059
  "mod.ts",
27344
28060
  source,
27345
- ts23.ScriptTarget.Latest,
28061
+ ts24.ScriptTarget.Latest,
27346
28062
  /*setParents*/
27347
28063
  false,
27348
- ts23.ScriptKind.TS
28064
+ ts24.ScriptKind.TS
27349
28065
  );
27350
28066
  function hasExport(node) {
27351
- if (!ts23.canHaveModifiers(node)) return false;
27352
- const mods = ts23.getModifiers(node);
27353
- return mods?.some((m) => m.kind === ts23.SyntaxKind.ExportKeyword) ?? false;
28067
+ if (!ts24.canHaveModifiers(node)) return false;
28068
+ const mods = ts24.getModifiers(node);
28069
+ return mods?.some((m) => m.kind === ts24.SyntaxKind.ExportKeyword) ?? false;
28070
+ }
28071
+ function isAmbient(node) {
28072
+ if (!ts24.canHaveModifiers(node)) return false;
28073
+ const mods = ts24.getModifiers(node);
28074
+ return mods?.some((m) => m.kind === ts24.SyntaxKind.DeclareKeyword) ?? false;
27354
28075
  }
27355
28076
  function collectFromBindingName(name2) {
27356
- if (ts23.isIdentifier(name2)) {
27357
- names.add(name2.text);
28077
+ if (ts24.isIdentifier(name2)) {
28078
+ localValueExports.add(name2.text);
27358
28079
  return;
27359
28080
  }
27360
28081
  for (const el of name2.elements) {
27361
- if (ts23.isBindingElement(el)) collectFromBindingName(el.name);
28082
+ if (ts24.isBindingElement(el)) collectFromBindingName(el.name);
27362
28083
  }
27363
28084
  }
27364
28085
  for (const stmt of sourceFile.statements) {
27365
- if (ts23.isVariableStatement(stmt) && hasExport(stmt)) {
28086
+ if (ts24.isVariableStatement(stmt) && hasExport(stmt)) {
27366
28087
  for (const d of stmt.declarationList.declarations) {
27367
28088
  collectFromBindingName(d.name);
27368
28089
  }
27369
- } else if (ts23.isFunctionDeclaration(stmt) && hasExport(stmt) && stmt.name) {
27370
- names.add(stmt.name.text);
27371
- } else if (ts23.isClassDeclaration(stmt) && hasExport(stmt) && stmt.name) {
27372
- names.add(stmt.name.text);
27373
- } else if (ts23.isExportDeclaration(stmt) && !stmt.moduleSpecifier && stmt.exportClause && ts23.isNamedExports(stmt.exportClause)) {
28090
+ } else if (ts24.isFunctionDeclaration(stmt) && hasExport(stmt) && stmt.name) {
28091
+ localValueExports.add(stmt.name.text);
28092
+ } else if (ts24.isClassDeclaration(stmt) && hasExport(stmt) && stmt.name) {
28093
+ localValueExports.add(stmt.name.text);
28094
+ } else if (ts24.isEnumDeclaration(stmt) && hasExport(stmt) && stmt.name) {
28095
+ otherValueExports.add(stmt.name.text);
28096
+ } else if (ts24.isModuleDeclaration(stmt) && hasExport(stmt) && ts24.isIdentifier(stmt.name)) {
28097
+ if (!isAmbient(stmt)) otherValueExports.add(stmt.name.text);
28098
+ } else if (ts24.isExportDeclaration(stmt)) {
27374
28099
  if (stmt.isTypeOnly) continue;
27375
- for (const el of stmt.exportClause.elements) {
27376
- if (el.isTypeOnly) continue;
27377
- names.add(el.name.text);
28100
+ if (!stmt.moduleSpecifier) {
28101
+ if (stmt.exportClause && ts24.isNamedExports(stmt.exportClause)) {
28102
+ for (const el of stmt.exportClause.elements) {
28103
+ if (el.isTypeOnly) continue;
28104
+ localValueExports.add(el.name.text);
28105
+ }
28106
+ }
28107
+ } else if (!stmt.exportClause) {
28108
+ hasStarReExport = true;
28109
+ } else if (ts24.isNamespaceExport(stmt.exportClause)) {
28110
+ reExportedNames.add(stmt.exportClause.name.text);
28111
+ } else if (ts24.isNamedExports(stmt.exportClause)) {
28112
+ for (const el of stmt.exportClause.elements) {
28113
+ if (el.isTypeOnly) continue;
28114
+ reExportedNames.add(el.name.text);
28115
+ }
27378
28116
  }
27379
28117
  }
27380
28118
  }
27381
- return [...names];
28119
+ return { localValueExports, otherValueExports, reExportedNames, hasStarReExport };
27382
28120
  }
27383
28121
  function hasUseClientDirective(source) {
27384
- const sourceFile = ts23.createSourceFile(
28122
+ const sourceFile = ts24.createSourceFile(
27385
28123
  "check.tsx",
27386
28124
  source,
27387
- ts23.ScriptTarget.Latest,
28125
+ ts24.ScriptTarget.Latest,
27388
28126
  /*setParents*/
27389
28127
  false,
27390
- ts23.ScriptKind.TSX
28128
+ ts24.ScriptKind.TSX
27391
28129
  );
27392
28130
  for (const stmt of sourceFile.statements) {
27393
- if (!ts23.isExpressionStatement(stmt) || !ts23.isStringLiteral(stmt.expression)) {
28131
+ if (!ts24.isExpressionStatement(stmt) || !ts24.isStringLiteral(stmt.expression)) {
27394
28132
  return false;
27395
28133
  }
27396
28134
  if (stmt.expression.text === "use client") return true;
@@ -27399,53 +28137,53 @@ function hasUseClientDirective(source) {
27399
28137
  }
27400
28138
  function collectTopLevelBindings(source) {
27401
28139
  const names = /* @__PURE__ */ new Set();
27402
- const sourceFile = ts23.createSourceFile(
28140
+ const sourceFile = ts24.createSourceFile(
27403
28141
  "bundle.ts",
27404
28142
  source,
27405
- ts23.ScriptTarget.Latest,
28143
+ ts24.ScriptTarget.Latest,
27406
28144
  /*setParents*/
27407
28145
  false,
27408
- ts23.ScriptKind.TS
28146
+ ts24.ScriptKind.TS
27409
28147
  );
27410
28148
  function collectFromBindingName(name2) {
27411
- if (ts23.isIdentifier(name2)) {
28149
+ if (ts24.isIdentifier(name2)) {
27412
28150
  names.add(name2.text);
27413
28151
  return;
27414
28152
  }
27415
28153
  for (const el of name2.elements) {
27416
- if (ts23.isBindingElement(el)) collectFromBindingName(el.name);
28154
+ if (ts24.isBindingElement(el)) collectFromBindingName(el.name);
27417
28155
  }
27418
28156
  }
27419
28157
  for (const stmt of sourceFile.statements) {
27420
- if (ts23.isVariableStatement(stmt)) {
28158
+ if (ts24.isVariableStatement(stmt)) {
27421
28159
  for (const d of stmt.declarationList.declarations) {
27422
28160
  collectFromBindingName(d.name);
27423
28161
  }
27424
- } else if (ts23.isFunctionDeclaration(stmt) && stmt.name) {
28162
+ } else if (ts24.isFunctionDeclaration(stmt) && stmt.name) {
27425
28163
  names.add(stmt.name.text);
27426
- } else if (ts23.isClassDeclaration(stmt) && stmt.name) {
28164
+ } else if (ts24.isClassDeclaration(stmt) && stmt.name) {
27427
28165
  names.add(stmt.name.text);
27428
28166
  }
27429
28167
  }
27430
28168
  return names;
27431
28169
  }
27432
28170
  function stripImportsAndExports(body2) {
27433
- const sourceFile = ts23.createSourceFile(
28171
+ const sourceFile = ts24.createSourceFile(
27434
28172
  "body.ts",
27435
28173
  body2,
27436
- ts23.ScriptTarget.Latest,
28174
+ ts24.ScriptTarget.Latest,
27437
28175
  /*setParents*/
27438
28176
  false,
27439
- ts23.ScriptKind.TS
28177
+ ts24.ScriptKind.TS
27440
28178
  );
27441
28179
  const spans = [];
27442
28180
  const hoistedImports = [];
27443
28181
  for (const stmt of sourceFile.statements) {
27444
- if (ts23.isImportDeclaration(stmt)) {
28182
+ if (ts24.isImportDeclaration(stmt)) {
27445
28183
  const start2 = stmt.getStart(sourceFile);
27446
28184
  const end2 = stmt.getEnd();
27447
28185
  const specifier = stmt.moduleSpecifier;
27448
- if (ts23.isStringLiteral(specifier)) {
28186
+ if (ts24.isStringLiteral(specifier)) {
27449
28187
  const path25 = specifier.text;
27450
28188
  const isRelative = path25.startsWith("./") || path25.startsWith("../");
27451
28189
  if (!isRelative) {
@@ -27455,24 +28193,24 @@ function stripImportsAndExports(body2) {
27455
28193
  spans.push([start2, end2]);
27456
28194
  continue;
27457
28195
  }
27458
- if (ts23.isExportDeclaration(stmt)) {
28196
+ if (ts24.isExportDeclaration(stmt)) {
27459
28197
  spans.push([stmt.getStart(sourceFile), stmt.getEnd()]);
27460
28198
  continue;
27461
28199
  }
27462
- if (ts23.isExportAssignment(stmt)) {
27463
- const exportKw = stmt.getChildren(sourceFile).find((c) => c.kind === ts23.SyntaxKind.ExportKeyword);
27464
- const defaultKw = stmt.getChildren(sourceFile).find((c) => c.kind === ts23.SyntaxKind.DefaultKeyword);
27465
- const equalsKw = stmt.getChildren(sourceFile).find((c) => c.kind === ts23.SyntaxKind.EqualsToken);
28200
+ if (ts24.isExportAssignment(stmt)) {
28201
+ const exportKw = stmt.getChildren(sourceFile).find((c) => c.kind === ts24.SyntaxKind.ExportKeyword);
28202
+ const defaultKw = stmt.getChildren(sourceFile).find((c) => c.kind === ts24.SyntaxKind.DefaultKeyword);
28203
+ const equalsKw = stmt.getChildren(sourceFile).find((c) => c.kind === ts24.SyntaxKind.EqualsToken);
27466
28204
  const start2 = exportKw?.getStart(sourceFile) ?? stmt.getStart(sourceFile);
27467
28205
  const end2 = (defaultKw ?? equalsKw)?.getEnd() ?? exportKw?.getEnd() ?? stmt.getStart(sourceFile);
27468
28206
  if (end2 > start2) spans.push([start2, end2]);
27469
28207
  continue;
27470
28208
  }
27471
- if (ts23.canHaveModifiers(stmt)) {
27472
- const mods = ts23.getModifiers(stmt);
28209
+ if (ts24.canHaveModifiers(stmt)) {
28210
+ const mods = ts24.getModifiers(stmt);
27473
28211
  if (!mods) continue;
27474
28212
  for (const mod of mods) {
27475
- if (mod.kind === ts23.SyntaxKind.ExportKeyword) {
28213
+ if (mod.kind === ts24.SyntaxKind.ExportKeyword) {
27476
28214
  const start2 = mod.getStart(sourceFile);
27477
28215
  let end2 = mod.getEnd();
27478
28216
  while (end2 < body2.length && /\s/.test(body2[end2])) end2++;
@@ -27504,15 +28242,43 @@ function buildConsumerBinding(shape, topLevelId) {
27504
28242
  );
27505
28243
  return `const { ${entries2.join(", ")} } = ${topLevelId};`;
27506
28244
  }
27507
- function buildTopLevelIIFE(topLevelId, body2, shapesNeeded, originalSource) {
28245
+ function buildMissingExportMessage(name2, modulePath) {
28246
+ return {
28247
+ message: `Import \`${name2}\` from '${modulePath}' has no matching export in that module. The client bundle would throw \`ReferenceError: ${name2} is not defined\` at load.`,
28248
+ suggestion: `Either \`${name2}\` is a TYPE \u2014 import it with \`import type { ${name2} }\` or \`import { type ${name2} }\` (the compiler no longer emits type-only specifiers into the client bundle as of #2432) \u2014 or it's a typo / removed export: check '${modulePath}' actually exports \`${name2}\`.`
28249
+ };
28250
+ }
28251
+ function buildTopLevelIIFE(topLevelId, body2, shapesNeeded, originalSource, modulePath) {
27508
28252
  const { body: stripped, hoistedImports } = stripImportsAndExports(body2);
27509
28253
  const wantsNamespace = shapesNeeded.some((s) => !!s.namespace);
27510
28254
  const namesNeeded = /* @__PURE__ */ new Set();
27511
- if (wantsNamespace) {
27512
- for (const n of collectExportedNames(originalSource)) namesNeeded.add(n);
27513
- }
28255
+ const namedRequests = /* @__PURE__ */ new Set();
27514
28256
  for (const shape of shapesNeeded) {
27515
- for (const { imported } of shape.named) namesNeeded.add(imported);
28257
+ for (const { imported } of shape.named) {
28258
+ namesNeeded.add(imported);
28259
+ namedRequests.add(imported);
28260
+ }
28261
+ }
28262
+ const errors = [];
28263
+ if (wantsNamespace || namedRequests.size > 0) {
28264
+ const info = collectExportInfo(originalSource);
28265
+ if (wantsNamespace) {
28266
+ for (const n of info.localValueExports) namesNeeded.add(n);
28267
+ }
28268
+ if (namedRequests.size > 0 && !info.hasStarReExport) {
28269
+ const surfaceNames = /* @__PURE__ */ new Set([...info.localValueExports, ...info.otherValueExports, ...info.reExportedNames]);
28270
+ const loc = { file: modulePath, start: { line: 1, column: 0 }, end: { line: 1, column: 0 } };
28271
+ for (const name2 of namedRequests) {
28272
+ if (surfaceNames.has(name2)) continue;
28273
+ const { message, suggestion } = buildMissingExportMessage(name2, modulePath);
28274
+ errors.push(
28275
+ createError(ErrorCodes.INLINED_IMPORT_MISSING_EXPORT, loc, {
28276
+ message,
28277
+ suggestion: { message: suggestion }
28278
+ })
28279
+ );
28280
+ }
28281
+ }
27516
28282
  }
27517
28283
  if (namesNeeded.size === 0) {
27518
28284
  return {
@@ -27520,7 +28286,8 @@ function buildTopLevelIIFE(topLevelId, body2, shapesNeeded, originalSource) {
27520
28286
  ${stripped}
27521
28287
  return {};
27522
28288
  })();`,
27523
- hoistedImports
28289
+ hoistedImports,
28290
+ errors
27524
28291
  };
27525
28292
  }
27526
28293
  const ret = `{ ${[...namesNeeded].join(", ")} }`;
@@ -27529,7 +28296,8 @@ return {};
27529
28296
  ${stripped}
27530
28297
  return ${ret};
27531
28298
  })();`,
27532
- hoistedImports
28299
+ hoistedImports,
28300
+ errors
27533
28301
  };
27534
28302
  }
27535
28303
  async function resolveSourceFile(importPath, searchDirs) {
@@ -27578,51 +28346,27 @@ function buildDanglingReferenceMessage(binding, s) {
27578
28346
  };
27579
28347
  }
27580
28348
  }
27581
- function isValueReference(id2) {
27582
- const parent2 = id2.parent;
27583
- if (!parent2) return false;
27584
- if (ts23.isPropertyAccessExpression(parent2) && parent2.name === id2) return false;
27585
- if (ts23.isPropertyAssignment(parent2) && parent2.name === id2) return false;
27586
- if ((ts23.isMethodDeclaration(parent2) || ts23.isGetAccessorDeclaration(parent2) || ts23.isSetAccessorDeclaration(parent2)) && parent2.name === id2) {
27587
- return false;
27588
- }
27589
- if (ts23.isVariableDeclaration(parent2) && parent2.name === id2) return false;
27590
- if (ts23.isFunctionDeclaration(parent2) && parent2.name === id2) return false;
27591
- if (ts23.isFunctionExpression(parent2) && parent2.name === id2) return false;
27592
- if (ts23.isClassDeclaration(parent2) && parent2.name === id2) return false;
27593
- if (ts23.isClassExpression(parent2) && parent2.name === id2) return false;
27594
- if (ts23.isParameter(parent2) && parent2.name === id2) return false;
27595
- if (ts23.isBindingElement(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
27596
- if (ts23.isLabeledStatement(parent2) && parent2.label === id2) return false;
27597
- if (ts23.isBreakOrContinueStatement(parent2) && parent2.label === id2) return false;
27598
- if (ts23.isImportSpecifier(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
27599
- if (ts23.isExportSpecifier(parent2) && (parent2.name === id2 || parent2.propertyName === id2)) return false;
27600
- if (ts23.isImportClause(parent2) && parent2.name === id2) return false;
27601
- if (ts23.isNamespaceImport(parent2) && parent2.name === id2) return false;
27602
- if (ts23.isQualifiedName(parent2) && parent2.right === id2) return false;
27603
- return true;
27604
- }
27605
28349
  function detectStrippedReferences(bundleSource, stripped) {
27606
28350
  if (stripped.length === 0) return [];
27607
28351
  let sf;
27608
28352
  try {
27609
- sf = ts23.createSourceFile(
28353
+ sf = ts24.createSourceFile(
27610
28354
  "bundle.js",
27611
28355
  bundleSource,
27612
- ts23.ScriptTarget.Latest,
28356
+ ts24.ScriptTarget.Latest,
27613
28357
  /*setParents*/
27614
28358
  true,
27615
- ts23.ScriptKind.JS
28359
+ ts24.ScriptKind.JS
27616
28360
  );
27617
28361
  } catch {
27618
28362
  return [];
27619
28363
  }
27620
28364
  const firstReference = /* @__PURE__ */ new Map();
27621
28365
  function visit3(node) {
27622
- if (ts23.isIdentifier(node) && isValueReference(node)) {
28366
+ if (ts24.isIdentifier(node) && isValueReferenceIdentifier(node)) {
27623
28367
  if (!firstReference.has(node.text)) firstReference.set(node.text, node);
27624
28368
  }
27625
- ts23.forEachChild(node, visit3);
28369
+ ts24.forEachChild(node, visit3);
27626
28370
  }
27627
28371
  visit3(sf);
27628
28372
  const errors = [];
@@ -27652,18 +28396,18 @@ function detectStrippedReferences(bundleSource, stripped) {
27652
28396
  return errors;
27653
28397
  }
27654
28398
  async function walkAndCollect(content2, searchDirs, modules2, visiting, loggingPath, stripped, stubDeps, nextId) {
27655
- const sourceFile = ts23.createSourceFile(
28399
+ const sourceFile = ts24.createSourceFile(
27656
28400
  "walk.js",
27657
28401
  content2,
27658
- ts23.ScriptTarget.Latest,
28402
+ ts24.ScriptTarget.Latest,
27659
28403
  /*setParents*/
27660
28404
  false,
27661
- ts23.ScriptKind.JS
28405
+ ts24.ScriptKind.JS
27662
28406
  );
27663
28407
  const sites = [];
27664
28408
  for (const stmt of sourceFile.statements) {
27665
- if (!ts23.isImportDeclaration(stmt)) continue;
27666
- if (!ts23.isStringLiteral(stmt.moduleSpecifier)) continue;
28409
+ if (!ts24.isImportDeclaration(stmt)) continue;
28410
+ if (!ts24.isStringLiteral(stmt.moduleSpecifier)) continue;
27667
28411
  const spec = stmt.moduleSpecifier.text;
27668
28412
  if (!spec.startsWith("./") && !spec.startsWith("../")) continue;
27669
28413
  const start2 = stmt.getStart(sourceFile);
@@ -27812,14 +28556,16 @@ async function inlineRelativeImports(content2, searchDirs, loggingPath, hoistedA
27812
28556
  const ordered = topoSort(modules2);
27813
28557
  const iifes = [];
27814
28558
  for (const mod of ordered) {
27815
- const { wrapped, hoistedImports } = buildTopLevelIIFE(
28559
+ const { wrapped, hoistedImports, errors } = buildTopLevelIIFE(
27816
28560
  mod.topLevelId,
27817
28561
  mod.transpiledBody,
27818
28562
  mod.consumerShapes,
27819
- mod.originalSource
28563
+ mod.originalSource,
28564
+ mod.path
27820
28565
  );
27821
28566
  iifes.push(wrapped);
27822
28567
  for (const h of hoistedImports) hoistedAcc.push(h);
28568
+ for (const err of errors) errorAcc.push(err);
27823
28569
  }
27824
28570
  const finalContent = iifes.join("\n") + "\n" + parentContent;
27825
28571
  for (const err of detectStrippedReferences(finalContent, stripped)) errorAcc.push(err);
@@ -28115,7 +28861,7 @@ var init_assets_ignore = __esm({
28115
28861
  });
28116
28862
 
28117
28863
  // src/lib/runtime-treeshake.ts
28118
- import ts24 from "typescript";
28864
+ import ts25 from "typescript";
28119
28865
  import { basename, dirname as dirname3 } from "node:path";
28120
28866
  import { build as esbuildBuild } from "esbuild";
28121
28867
  function isBarefootClientSpecifier(spec) {
@@ -28132,13 +28878,13 @@ function collectUsedRuntimeExports(code, sourceLabel = "<input>") {
28132
28878
  if (!code.includes("@barefootjs/client") && !code.includes("barefoot.js")) return result2;
28133
28879
  let sourceFile;
28134
28880
  try {
28135
- sourceFile = ts24.createSourceFile(
28881
+ sourceFile = ts25.createSourceFile(
28136
28882
  sourceLabel,
28137
28883
  code,
28138
- ts24.ScriptTarget.Latest,
28884
+ ts25.ScriptTarget.Latest,
28139
28885
  /*setParentNodes*/
28140
28886
  false,
28141
- ts24.ScriptKind.JS
28887
+ ts25.ScriptKind.JS
28142
28888
  );
28143
28889
  } catch (err) {
28144
28890
  result2.unsafe = true;
@@ -28146,13 +28892,13 @@ function collectUsedRuntimeExports(code, sourceLabel = "<input>") {
28146
28892
  return result2;
28147
28893
  }
28148
28894
  const visit3 = (node) => {
28149
- if (ts24.isImportDeclaration(node)) {
28895
+ if (ts25.isImportDeclaration(node)) {
28150
28896
  const spec = node.moduleSpecifier;
28151
- if (ts24.isStringLiteral(spec) && isEmittedRuntimeSpecifier(spec.text)) {
28897
+ if (ts25.isStringLiteral(spec) && isEmittedRuntimeSpecifier(spec.text)) {
28152
28898
  const clause = node.importClause;
28153
28899
  if (!clause) {
28154
28900
  } else if (clause.isTypeOnly) {
28155
- } else if (clause.namedBindings && ts24.isNamedImports(clause.namedBindings)) {
28901
+ } else if (clause.namedBindings && ts25.isNamedImports(clause.namedBindings)) {
28156
28902
  for (const el of clause.namedBindings.elements) {
28157
28903
  if (el.isTypeOnly) continue;
28158
28904
  const imported = (el.propertyName ?? el.name).text;
@@ -28162,7 +28908,7 @@ function collectUsedRuntimeExports(code, sourceLabel = "<input>") {
28162
28908
  result2.unsafe = true;
28163
28909
  result2.reasons.push(`default import of "${spec.text}" in ${sourceLabel}`);
28164
28910
  }
28165
- } else if (clause.namedBindings && ts24.isNamespaceImport(clause.namedBindings)) {
28911
+ } else if (clause.namedBindings && ts25.isNamespaceImport(clause.namedBindings)) {
28166
28912
  result2.unsafe = true;
28167
28913
  result2.reasons.push(`namespace import (* as ${clause.namedBindings.name.text}) of "${spec.text}" in ${sourceLabel}`);
28168
28914
  } else if (clause.name) {
@@ -28170,14 +28916,14 @@ function collectUsedRuntimeExports(code, sourceLabel = "<input>") {
28170
28916
  result2.reasons.push(`default import of "${spec.text}" in ${sourceLabel}`);
28171
28917
  }
28172
28918
  }
28173
- } else if (ts24.isCallExpression(node) && node.expression.kind === ts24.SyntaxKind.ImportKeyword) {
28919
+ } else if (ts25.isCallExpression(node) && node.expression.kind === ts25.SyntaxKind.ImportKeyword) {
28174
28920
  const arg = node.arguments[0];
28175
- if (arg && ts24.isStringLiteral(arg) && isEmittedRuntimeSpecifier(arg.text)) {
28921
+ if (arg && ts25.isStringLiteral(arg) && isEmittedRuntimeSpecifier(arg.text)) {
28176
28922
  result2.unsafe = true;
28177
28923
  result2.reasons.push(`dynamic import("${arg.text}") in ${sourceLabel}`);
28178
28924
  }
28179
28925
  }
28180
- ts24.forEachChild(node, visit3);
28926
+ ts25.forEachChild(node, visit3);
28181
28927
  };
28182
28928
  visit3(sourceFile);
28183
28929
  return result2;
@@ -28250,7 +28996,7 @@ var init_runtime_treeshake = __esm({
28250
28996
  });
28251
28997
 
28252
28998
  // src/lib/build.ts
28253
- import ts25 from "typescript";
28999
+ import ts26 from "typescript";
28254
29000
  import { mkdir, readdir, stat, unlink } from "node:fs/promises";
28255
29001
  import { resolve as resolve6, basename as basename2, relative as relative2, dirname as dirname4, isAbsolute as isAbsolute2 } from "node:path";
28256
29002
  import { fileURLToPath as fileURLToPath2 } from "node:url";
@@ -28898,7 +29644,7 @@ async function build(config, options2 = {}) {
28898
29644
  };
28899
29645
  }
28900
29646
  function extractBareImports(code) {
28901
- const { importedFiles } = ts25.preProcessFile(code, true, true);
29647
+ const { importedFiles } = ts26.preProcessFile(code, true, true);
28902
29648
  const specifiers = /* @__PURE__ */ new Set();
28903
29649
  for (const { fileName } of importedFiles) {
28904
29650
  if (!fileName.startsWith(".") && !fileName.startsWith("/") && !fileName.includes("://")) {
@@ -28965,16 +29711,16 @@ function effectiveOutName(tplPath, entryBaseNoExt) {
28965
29711
  }
28966
29712
  function topLevelImportLines(content2) {
28967
29713
  const lines = /* @__PURE__ */ new Set();
28968
- const sourceFile = ts25.createSourceFile(
29714
+ const sourceFile = ts26.createSourceFile(
28969
29715
  "merge.js",
28970
29716
  content2,
28971
- ts25.ScriptTarget.Latest,
29717
+ ts26.ScriptTarget.Latest,
28972
29718
  /*setParentNodes*/
28973
29719
  true,
28974
- ts25.ScriptKind.JS
29720
+ ts26.ScriptKind.JS
28975
29721
  );
28976
29722
  for (const stmt of sourceFile.statements) {
28977
- if (ts25.isImportDeclaration(stmt)) {
29723
+ if (ts26.isImportDeclaration(stmt)) {
28978
29724
  const { line } = sourceFile.getLineAndCharacterOfPosition(stmt.getStart(sourceFile));
28979
29725
  lines.add(line);
28980
29726
  }
@@ -28983,29 +29729,29 @@ function topLevelImportLines(content2) {
28983
29729
  }
28984
29730
  function rewriteBarefootClientSpecifiers(content2, rel) {
28985
29731
  if (!content2.includes("@barefootjs/client")) return content2;
28986
- const sourceFile = ts25.createSourceFile(
29732
+ const sourceFile = ts26.createSourceFile(
28987
29733
  "client.js",
28988
29734
  content2,
28989
- ts25.ScriptTarget.Latest,
29735
+ ts26.ScriptTarget.Latest,
28990
29736
  /*setParentNodes*/
28991
29737
  true,
28992
- ts25.ScriptKind.JS
29738
+ ts26.ScriptKind.JS
28993
29739
  );
28994
29740
  const isBarefootClient = (s) => s === "@barefootjs/client" || s.startsWith("@barefootjs/client/");
28995
29741
  const spans = [];
28996
29742
  const visit3 = (node) => {
28997
- if (ts25.isImportDeclaration(node) || ts25.isExportDeclaration(node)) {
29743
+ if (ts26.isImportDeclaration(node) || ts26.isExportDeclaration(node)) {
28998
29744
  const ms = node.moduleSpecifier;
28999
- if (ms && ts25.isStringLiteral(ms) && isBarefootClient(ms.text)) {
29745
+ if (ms && ts26.isStringLiteral(ms) && isBarefootClient(ms.text)) {
29000
29746
  spans.push([ms.getStart(sourceFile), ms.getEnd()]);
29001
29747
  }
29002
- } else if (ts25.isCallExpression(node) && node.expression.kind === ts25.SyntaxKind.ImportKeyword) {
29748
+ } else if (ts26.isCallExpression(node) && node.expression.kind === ts26.SyntaxKind.ImportKeyword) {
29003
29749
  const arg = node.arguments[0];
29004
- if (arg && ts25.isStringLiteral(arg) && isBarefootClient(arg.text)) {
29750
+ if (arg && ts26.isStringLiteral(arg) && isBarefootClient(arg.text)) {
29005
29751
  spans.push([arg.getStart(sourceFile), arg.getEnd()]);
29006
29752
  }
29007
29753
  }
29008
- ts25.forEachChild(node, visit3);
29754
+ ts26.forEachChild(node, visit3);
29009
29755
  };
29010
29756
  visit3(sourceFile);
29011
29757
  if (spans.length === 0) return content2;
@@ -110268,7 +111014,7 @@ __export(scenario_driver_exports, {
110268
111014
  import { writeFileSync as writeFileSync9, mkdtempSync, rmSync, readFileSync as readFileSync19, existsSync as existsSync23, statSync as statSync3 } from "node:fs";
110269
111015
  import { join as join2, dirname as dirname7, resolve as resolve11 } from "node:path";
110270
111016
  import { tmpdir } from "node:os";
110271
- import ts26 from "typescript";
111017
+ import ts27 from "typescript";
110272
111018
  function externalRuntimeImport(clientJs) {
110273
111019
  const chunks = Array.isArray(clientJs) ? clientJs : [clientJs];
110274
111020
  for (const chunk of chunks) {
@@ -110338,11 +111084,11 @@ function resolveLocalFile(spec) {
110338
111084
  }
110339
111085
  function rewriteLocalImports(js, chunkPath, inlined) {
110340
111086
  const chunkDir = dirname7(chunkPath);
110341
- const sf = ts26.createSourceFile("chunk.mjs", js, ts26.ScriptTarget.Latest, false, ts26.ScriptKind.JS);
111087
+ const sf = ts27.createSourceFile("chunk.mjs", js, ts27.ScriptTarget.Latest, false, ts27.ScriptKind.JS);
110342
111088
  const edits = [];
110343
111089
  for (const stmt of sf.statements) {
110344
- if (!ts26.isImportDeclaration(stmt)) continue;
110345
- if (!ts26.isStringLiteral(stmt.moduleSpecifier)) continue;
111090
+ if (!ts27.isImportDeclaration(stmt)) continue;
111091
+ if (!ts27.isStringLiteral(stmt.moduleSpecifier)) continue;
110346
111092
  const spec = stmt.moduleSpecifier.text;
110347
111093
  if (!spec.startsWith(".")) continue;
110348
111094
  const resolved = resolveLocalFile(join2(chunkDir, spec.replace(/\.client\.js$/, "")));
@@ -110354,13 +111100,13 @@ function rewriteLocalImports(js, chunkPath, inlined) {
110354
111100
  const abs = resolve11(resolved);
110355
111101
  if (inlined.has(abs)) {
110356
111102
  const clause = stmt.importClause;
110357
- if (clause && (clause.name || clause.namedBindings && ts26.isNamespaceImport(clause.namedBindings))) {
111103
+ if (clause && (clause.name || clause.namedBindings && ts27.isNamespaceImport(clause.namedBindings))) {
110358
111104
  throw new Error(
110359
111105
  `"${spec}" (imported by ${chunkPath}) uses a default or namespace import of a sibling client file, which the dynamic scenario runner cannot bind after inlining that file into the run. Import its exports by name, or use the static budget (\`bf debug profile <component>\`), which needs no run.`
110360
111106
  );
110361
111107
  }
110362
111108
  const shims = [];
110363
- if (clause?.namedBindings && ts26.isNamedImports(clause.namedBindings)) {
111109
+ if (clause?.namedBindings && ts27.isNamedImports(clause.namedBindings)) {
110364
111110
  for (const el of clause.namedBindings.elements) {
110365
111111
  if (el.propertyName) shims.push(`var ${el.name.text} = ${el.propertyName.text}`);
110366
111112
  }
@@ -110869,9 +111615,9 @@ function findProjectConfig(startDir) {
110869
111615
  let dir = path.resolve(startDir);
110870
111616
  const { root: fsRoot } = path.parse(dir);
110871
111617
  while (true) {
110872
- const ts27 = path.join(dir, "barefoot.config.ts");
110873
- if (existsSync2(ts27)) {
110874
- return { dir, tsConfigPath: ts27 };
111618
+ const ts28 = path.join(dir, "barefoot.config.ts");
111619
+ if (existsSync2(ts28)) {
111620
+ return { dir, tsConfigPath: ts28 };
110875
111621
  }
110876
111622
  if (dir === fsRoot) return null;
110877
111623
  dir = path.dirname(dir);