@barefootjs/jsx 0.33.1 → 0.33.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/analyzer.d.ts +17 -0
  2. package/dist/analyzer.d.ts.map +1 -1
  3. package/dist/compiler.d.ts +21 -5
  4. package/dist/compiler.d.ts.map +1 -1
  5. package/dist/expression-parser.d.ts +14 -0
  6. package/dist/expression-parser.d.ts.map +1 -1
  7. package/dist/index.d.ts +2 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +817 -457
  10. package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
  11. package/dist/ir-to-client-js/control-flow/stringify/loop-child-arm.d.ts.map +1 -1
  12. package/dist/ir-to-client-js/emit-registration.d.ts.map +1 -1
  13. package/dist/ir-to-client-js/html-template.d.ts +7 -7
  14. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  15. package/dist/ir-to-client-js/imports.d.ts +60 -2
  16. package/dist/ir-to-client-js/imports.d.ts.map +1 -1
  17. package/dist/ir-to-client-js/index.d.ts.map +1 -1
  18. package/dist/ir-to-client-js/prop-handling.d.ts +30 -0
  19. package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
  20. package/dist/ir-to-client-js/reactivity.d.ts +5 -0
  21. package/dist/ir-to-client-js/reactivity.d.ts.map +1 -1
  22. package/dist/ir-to-client-js/rewrite-props-object.d.ts +36 -8
  23. package/dist/ir-to-client-js/rewrite-props-object.d.ts.map +1 -1
  24. package/dist/ir-to-client-js/utils.d.ts +26 -2
  25. package/dist/ir-to-client-js/utils.d.ts.map +1 -1
  26. package/dist/jsx-to-ir.d.ts.map +1 -1
  27. package/dist/props-binding.d.ts +35 -0
  28. package/dist/props-binding.d.ts.map +1 -1
  29. package/dist/types.d.ts +51 -0
  30. package/dist/types.d.ts.map +1 -1
  31. package/package.json +2 -2
  32. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +165 -98
  33. package/src/__tests__/binding-scope-ratchet.test.ts +5 -1
  34. package/src/__tests__/child-component-ref-not-mirrored.test.ts +90 -0
  35. package/src/__tests__/client-js-generation.test.ts +11 -0
  36. package/src/__tests__/ir-to-client-js/imports.test.ts +107 -0
  37. package/src/__tests__/ir-to-client-js/merge-compiled-client-js-imports.test.ts +138 -0
  38. package/src/__tests__/issue-2723-prop-alias-reactivity.test.ts +124 -0
  39. package/src/__tests__/issue-2754-rest-spread-needs-slot.test.ts +85 -0
  40. package/src/__tests__/issue-2756-loop-row-honors-client-only.test.ts +173 -0
  41. package/src/__tests__/merge-template-imports.test.ts +41 -1
  42. package/src/__tests__/multi-component-shared-default-import.test.ts +55 -0
  43. package/src/__tests__/rewrite-props-object.test.ts +41 -4
  44. package/src/__tests__/root-key-relay.test.ts +170 -0
  45. package/src/__tests__/signal-getter-not-called.test.ts +149 -0
  46. package/src/__tests__/state-only-file-default-import.test.ts +47 -0
  47. package/src/analyzer.ts +36 -0
  48. package/src/compiler.ts +94 -104
  49. package/src/expression-parser.ts +26 -0
  50. package/src/index.ts +2 -2
  51. package/src/ir-to-client-js/collect-elements.ts +45 -30
  52. package/src/ir-to-client-js/control-flow/stringify/inner-loop.ts +6 -2
  53. package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +5 -2
  54. package/src/ir-to-client-js/emit-registration.ts +26 -7
  55. package/src/ir-to-client-js/generate-init.ts +1 -1
  56. package/src/ir-to-client-js/html-template.ts +130 -20
  57. package/src/ir-to-client-js/imports.ts +178 -5
  58. package/src/ir-to-client-js/index.ts +11 -4
  59. package/src/ir-to-client-js/prop-handling.ts +83 -0
  60. package/src/ir-to-client-js/reactivity.ts +59 -0
  61. package/src/ir-to-client-js/rewrite-props-object.ts +50 -10
  62. package/src/ir-to-client-js/utils.ts +30 -2
  63. package/src/jsx-to-ir.ts +523 -49
  64. package/src/props-binding.ts +51 -0
  65. package/src/types.ts +48 -0
package/dist/index.js CHANGED
@@ -177,7 +177,7 @@ function findTopLevelTemplateLiterals(code) {
177
177
  }
178
178
 
179
179
  // src/compiler.ts
180
- import ts24 from "typescript";
180
+ import ts25 from "typescript";
181
181
 
182
182
  // src/analyzer.ts
183
183
  import ts9 from "typescript";
@@ -228,6 +228,9 @@ var ARRAY_METHOD_NAMES = [
228
228
  "padEnd",
229
229
  "flat"
230
230
  ];
231
+ var SORT_KEY_TYPES = ["numeric", "string", "auto"];
232
+ var SORT_KEY_TARGETS = ["self", "field"];
233
+ var SORT_KEY_DIRECTIONS = ["asc", "desc"];
231
234
  var UNSUPPORTED_METHODS = new Set([
232
235
  "filter",
233
236
  "map",
@@ -2381,11 +2384,16 @@ import {
2381
2384
  loopStartMarker,
2382
2385
  loopEndMarker,
2383
2386
  loopItemMarker,
2384
- toHTMLAttrName as toHtmlAttrName
2387
+ toHTMLAttrName as toHtmlAttrName,
2388
+ keyAttrName as sharedKeyAttrName
2385
2389
  } from "@barefootjs/shared";
2386
2390
  var PROPS_PARAM = "_p";
2387
- function keyAttrName(loopDepth) {
2388
- return loopDepth > 0 ? `${DATA_KEY_PREFIX}${loopDepth}` : DATA_KEY;
2391
+ var keyAttrName = sharedKeyAttrName;
2392
+ function mapArrayKeyArgs(bfIdArg, keyed, loopDepth) {
2393
+ if (!keyed || loopDepth <= 0)
2394
+ return bfIdArg;
2395
+ const bfIdSlot = bfIdArg || ", undefined";
2396
+ return `${bfIdSlot}, ${JSON.stringify(keyAttrName(loopDepth))}`;
2389
2397
  }
2390
2398
  function varSlotId(slotId) {
2391
2399
  return slotId.startsWith("^") ? slotId.slice(1) : slotId;
@@ -3375,6 +3383,14 @@ function escapeAttrValueExpr(valExpr) {
3375
3383
  function escapeTextSlotExpr(innerExpr, isMarkup = false) {
3376
3384
  return `${isMarkup ? "escapeTextOrMarkup" : "escapeText"}(${innerExpr})`;
3377
3385
  }
3386
+ function isChildrenPassthroughExpr(expr) {
3387
+ return /^([A-Za-z_$][\w$]*\.)?children$/.test(expr.trim());
3388
+ }
3389
+ function bareSpliceExpr(node, valueExpr) {
3390
+ const resolved = valueExpr.trim().replace(/^\(+|\)+$/g, "");
3391
+ const isChildren = isChildrenPassthroughExpr(node.expr) || isChildrenPassthroughExpr(resolved);
3392
+ return !node.joinArrayChild && isChildren ? `markupOrEmpty(${valueExpr})` : valueExpr;
3393
+ }
3378
3394
  function dangerouslyHtmlChildren(attrs, toExpr) {
3379
3395
  const attr = attrs.find((a) => a.name === "dangerouslySetInnerHTML");
3380
3396
  if (!attr || attr.value.kind !== "expression")
@@ -3582,7 +3598,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3582
3598
  case "element": {
3583
3599
  const mergeCtx = {
3584
3600
  isFilteredSpread: (v) => !!restSpreadNames?.has(v.expr),
3585
- honorClientOnly: false
3601
+ honorClientOnly: true
3586
3602
  };
3587
3603
  const useMerge = shouldUseSpreadAttrsMerge(node.attrs, mergeCtx);
3588
3604
  const firstMergeableIdx = useMerge ? node.attrs.findIndex((a) => isMergeableAttr(a, mergeCtx)) : -1;
@@ -3593,6 +3609,8 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3593
3609
  templateExprFor: (v) => wrapExpr(attrValueToString(v) ?? "")
3594
3610
  }) : null;
3595
3611
  const attrParts = node.attrs.map((a, idx) => {
3612
+ if (a.clientOnly)
3613
+ return "";
3596
3614
  if (useMerge && isMergeableAttr(a, mergeCtx)) {
3597
3615
  return idx === firstMergeableIdx ? mergeCall : "";
3598
3616
  }
@@ -3618,17 +3636,18 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3618
3636
  case "expression": {
3619
3637
  if (node.expr === "null" || node.expr === "undefined")
3620
3638
  return "";
3639
+ const escapeForClient = (e) => node.escapeInClientTemplate ? `escapeText(${e})` : e;
3621
3640
  if (node.markerless) {
3622
- const bare = wrapInterpolation(wrapExpr(node.expr));
3641
+ const bare = escapeForClient(wrapInterpolation(wrapExpr(node.expr)));
3623
3642
  return `\${${bare}}`;
3624
3643
  }
3625
- const inner = wrapInterpolation(wrapExpr(node.expr));
3644
+ const inner = escapeForClient(wrapInterpolation(wrapExpr(node.expr)));
3626
3645
  const valueExpr = node.joinArrayChild ? `Array.isArray(${inner}) ? ${inner}.join('') : (${inner} ?? '')` : inner;
3627
3646
  if (node.slotId) {
3628
3647
  const slotted = branchSlotsVar || node.joinArrayChild ? valueExpr : escapeTextSlotExpr(valueExpr);
3629
3648
  return `<!--bf:${node.slotId}-->\${${slotted}}<!--/-->`;
3630
3649
  }
3631
- return `\${${valueExpr}}`;
3650
+ return `\${${bareSpliceExpr(node, valueExpr)}}`;
3632
3651
  }
3633
3652
  case "conditional": {
3634
3653
  const trueBranch = recurse(node.whenTrue);
@@ -3927,6 +3946,8 @@ function irToPlaceholderTemplate(node, restSpreadNames, loopDepth = 0, loopParam
3927
3946
  switch (node.type) {
3928
3947
  case "element": {
3929
3948
  const attrParts = node.attrs.map((a) => {
3949
+ if (a.clientOnly)
3950
+ return "";
3930
3951
  const attrName = a.name === "..." ? "..." : a.name === "key" ? keyAttrName(loopDepth) : toHtmlAttrName(a.name);
3931
3952
  return renderTemplateAttrPart(a, attrName, wrapExpr, restSpreadNames);
3932
3953
  }).filter(Boolean);
@@ -3950,7 +3971,8 @@ function irToPlaceholderTemplate(node, restSpreadNames, loopDepth = 0, loopParam
3950
3971
  if (node.slotId) {
3951
3972
  return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(wrapped)}}<!--/-->`;
3952
3973
  }
3953
- return `\${${value}}`;
3974
+ const spliced = bareSpliceExpr(node, value);
3975
+ return `\${${node.escapeInClientTemplate ? `escapeText(${spliced})` : spliced}}`;
3954
3976
  }
3955
3977
  case "conditional": {
3956
3978
  const trueBranch = recurse(node.whenTrue);
@@ -4192,7 +4214,7 @@ function irToComponentTemplateWithOpts(node, opts) {
4192
4214
  const isMarkup = opts.markupSlotIds?.has(node.slotId) ?? false;
4193
4215
  return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(wrapped, isMarkup)}}<!--/-->`;
4194
4216
  }
4195
- return `\${${value}}`;
4217
+ return `\${${bareSpliceExpr(node, value)}}`;
4196
4218
  }
4197
4219
  case "conditional": {
4198
4220
  if (node.clientOnly && node.slotId) {
@@ -4523,7 +4545,7 @@ function generateCsrTemplateWithOpts(node, opts) {
4523
4545
  const isMarkup = opts.markupSlotIds?.has(node.slotId) ?? false;
4524
4546
  return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(expr, isMarkup)}}<!--/-->`;
4525
4547
  }
4526
- return `\${${value}}`;
4548
+ return `\${${bareSpliceExpr(node, value)}}`;
4527
4549
  }
4528
4550
  case "conditional": {
4529
4551
  if (node.clientOnly && node.slotId) {
@@ -4831,6 +4853,19 @@ function buildPropAliasMap(params) {
4831
4853
  }
4832
4854
  return map;
4833
4855
  }
4856
+ function resolveRestSpreadOriginCore(bindings, constantValues, name) {
4857
+ const visited = new Set;
4858
+ let current = name.trim();
4859
+ while (current !== undefined && !visited.has(current)) {
4860
+ if (bindings.restPropsName && current === bindings.restPropsName)
4861
+ return "rest";
4862
+ if (bindings.propsObjectName && current === bindings.propsObjectName)
4863
+ return "props";
4864
+ visited.add(current);
4865
+ current = constantValues.get(current)?.trim();
4866
+ }
4867
+ return null;
4868
+ }
4834
4869
 
4835
4870
  // src/instrumentation.ts
4836
4871
  var _enabled = false;
@@ -8320,6 +8355,16 @@ function importsBrowserOnlyClientApi(ctx) {
8320
8355
  }
8321
8356
  function listComponentFunctions(source, filePath) {
8322
8357
  const sourceFile = ts9.createSourceFile(filePath, source, ts9.ScriptTarget.Latest, true, ts9.ScriptKind.TSX);
8358
+ return listComponentFunctionsFromSourceFile(sourceFile);
8359
+ }
8360
+ function scanComponentFile(source, filePath) {
8361
+ const sourceFile = ts9.createSourceFile(filePath, source, ts9.ScriptTarget.Latest, true, ts9.ScriptKind.TSX);
8362
+ return {
8363
+ exports: listComponentFunctionsFromSourceFile(sourceFile),
8364
+ referencedComponents: [...collectJsxComponentTags(sourceFile)]
8365
+ };
8366
+ }
8367
+ function listComponentFunctionsFromSourceFile(sourceFile) {
8323
8368
  const componentNames = [];
8324
8369
  const hasUseClient = sourceFile.statements.some((stmt) => ts9.isExpressionStatement(stmt) && ts9.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
8325
8370
  const namedExports = collectNamedExports(sourceFile);
@@ -10261,7 +10306,7 @@ var toLocaleDatePlugin = {
10261
10306
  };
10262
10307
 
10263
10308
  // src/jsx-to-ir.ts
10264
- import { toHTMLAttrName, decodeEntities } from "@barefootjs/shared";
10309
+ import { toHTMLAttrName, decodeEntities, BF_KEY, keyAttrName as keyAttrName2 } from "@barefootjs/shared";
10265
10310
  var CLIENT_DIRECTIVE_INTERIOR_RE2 = /^\s*@client\s*$/;
10266
10311
  var BLOCK_COMMENT_RE2 = /\/\*([\s\S]*?)\*\//g;
10267
10312
  function hasLeadingClientDirective(expr, sourceFile) {
@@ -10714,10 +10759,44 @@ function attachParsedExpressions(node, analyzer, bound = EMPTY_BOUND) {
10714
10759
  break;
10715
10760
  }
10716
10761
  }
10762
+ function resolveRootKeyAttr(node) {
10763
+ if (!node)
10764
+ return;
10765
+ switch (node.type) {
10766
+ case "element":
10767
+ if (node.needsScope && !node.keyAttr)
10768
+ node.keyAttr = { name: BF_KEY };
10769
+ for (const c of node.children)
10770
+ resolveRootKeyAttr(c);
10771
+ return;
10772
+ case "fragment":
10773
+ case "component":
10774
+ case "provider":
10775
+ case "loop":
10776
+ for (const c of node.children)
10777
+ resolveRootKeyAttr(c);
10778
+ return;
10779
+ case "async":
10780
+ resolveRootKeyAttr(node.fallback);
10781
+ for (const c of node.children)
10782
+ resolveRootKeyAttr(c);
10783
+ return;
10784
+ case "conditional":
10785
+ resolveRootKeyAttr(node.whenTrue);
10786
+ resolveRootKeyAttr(node.whenFalse);
10787
+ return;
10788
+ case "if-statement":
10789
+ resolveRootKeyAttr(node.consequent);
10790
+ resolveRootKeyAttr(node.alternate);
10791
+ return;
10792
+ }
10793
+ }
10717
10794
  function jsxToIR(analyzer) {
10718
10795
  const root = buildIRRoot(analyzer);
10719
- if (root)
10796
+ if (root) {
10720
10797
  attachParsedExpressions(root, analyzer);
10798
+ resolveRootKeyAttr(root);
10799
+ }
10721
10800
  return root;
10722
10801
  }
10723
10802
  function buildIRRoot(analyzer) {
@@ -10906,6 +10985,7 @@ function lowerFormControlValueSsr(tagName, attrs, children) {
10906
10985
  type: "expression",
10907
10986
  expr,
10908
10987
  templateExpr: `escapeText(${templateExpr ?? expr})`,
10988
+ escapeInClientTemplate: true,
10909
10989
  typeInfo: null,
10910
10990
  reactive: false,
10911
10991
  slotId: null,
@@ -10943,7 +11023,7 @@ function transformHtmlElement(node, ctx, tagName) {
10943
11023
  ctx.isRoot = false;
10944
11024
  const children = transformChildren(node.children, ctx);
10945
11025
  lowerFormControlValueSsr(tagName, attrs, children);
10946
- const needsSlot = events.length > 0 || hasDynamicContent(children) || hasReactiveAttributes(attrs, ctx) || ref !== null;
11026
+ const needsSlot = events.length > 0 || hasDynamicContent(children) || hasReactiveAttributes(attrs, ctx) || ref !== null || forwardsCallerRestProps(attrs, ctx);
10947
11027
  const slotId = needsSlot ? generateSlotId(ctx) : null;
10948
11028
  if (slotId) {
10949
11029
  propagateSlotIdToLoops(children, slotId);
@@ -10976,7 +11056,7 @@ function transformSelfClosingElement(node, ctx) {
10976
11056
  const { attrs, events, ref } = processAttributes(node.attributes, ctx);
10977
11057
  const selfClosingChildren = [];
10978
11058
  lowerFormControlValueSsr(tagName, attrs, selfClosingChildren);
10979
- const needsSlot = events.length > 0 || hasReactiveAttributes(attrs, ctx) || ref !== null;
11059
+ const needsSlot = events.length > 0 || hasReactiveAttributes(attrs, ctx) || ref !== null || forwardsCallerRestProps(attrs, ctx);
10980
11060
  const slotId = needsSlot ? generateSlotId(ctx) : null;
10981
11061
  const needsScope = ctx.isRoot;
10982
11062
  ctx.isRoot = false;
@@ -11202,6 +11282,33 @@ function unwrapHoistedFragment(node) {
11202
11282
  return node;
11203
11283
  return { ...only, needsScope: true };
11204
11284
  }
11285
+ function markDataKeyCarrier(children) {
11286
+ for (let i = 0;i < children.length; i++) {
11287
+ const marked = markCarrierIn(children[i]);
11288
+ if (!marked)
11289
+ continue;
11290
+ const out = children.slice();
11291
+ out[i] = marked;
11292
+ return out;
11293
+ }
11294
+ return children;
11295
+ }
11296
+ function markCarrierIn(node) {
11297
+ if (node.type === "element") {
11298
+ if (node.keyAttr)
11299
+ return null;
11300
+ return { ...node, keyAttr: { name: BF_KEY } };
11301
+ }
11302
+ if (node.type === "conditional") {
11303
+ const cond = node;
11304
+ const whenTrue = markCarrierIn(cond.whenTrue);
11305
+ const whenFalse = markCarrierIn(cond.whenFalse);
11306
+ if (!whenTrue && !whenFalse)
11307
+ return null;
11308
+ return { ...cond, whenTrue: whenTrue ?? cond.whenTrue, whenFalse: whenFalse ?? cond.whenFalse };
11309
+ }
11310
+ return null;
11311
+ }
11205
11312
  function transformFragment(node, ctx) {
11206
11313
  const isFragmentRoot = ctx.isRoot;
11207
11314
  const isTransparent = isFragmentRoot && isTransparentFragment(node, ctx);
@@ -11212,7 +11319,7 @@ function transformFragment(node, ctx) {
11212
11319
  const needsScopeComment = isFragmentRoot && !isTransparent || undefined;
11213
11320
  return {
11214
11321
  type: "fragment",
11215
- children,
11322
+ children: needsScopeComment ? markDataKeyCarrier(children) : children,
11216
11323
  transparent: isTransparent || undefined,
11217
11324
  needsScopeComment,
11218
11325
  loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath)
@@ -11265,7 +11372,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
11265
11372
  if (isRenderNothingLiteral(expr, ctx)) {
11266
11373
  return null;
11267
11374
  }
11268
- checkBareSignalOrMemoIdentifier(expr, ctx);
11375
+ checkBareSignalOrMemoIdentifier(expr, ctx, { descendNested: true });
11269
11376
  if (ts13.isIdentifier(expr)) {
11270
11377
  const jsxNode = ctx.analyzer.jsxConstants.get(expr.text);
11271
11378
  if (jsxNode) {
@@ -12382,6 +12489,16 @@ function tagLoopItemRootComponents(nodes) {
12382
12489
  }
12383
12490
  }
12384
12491
  }
12492
+ function applyLoopKeyAttr(node, name, value) {
12493
+ if (node.type === "element") {
12494
+ node.keyAttr = { name, value };
12495
+ return;
12496
+ }
12497
+ if (node.type === "conditional") {
12498
+ applyLoopKeyAttr(node.whenTrue, name, value);
12499
+ applyLoopKeyAttr(node.whenFalse, name, value);
12500
+ }
12501
+ }
12385
12502
  function loopBodyItemConditional(children) {
12386
12503
  const real = children.filter((c) => !(c.type === "text" && typeof c.value === "string" && !c.value.trim()));
12387
12504
  if (real.length !== 1)
@@ -12764,6 +12881,14 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12764
12881
  const itemConditional = children.length > 0 ? loopBodyItemConditional(children) : null;
12765
12882
  const bodyIsItemConditional = itemConditional !== null;
12766
12883
  const key = bodyIsItemConditional ? extractItemConditionalKey(itemConditional) : children.length > 0 ? extractLoopKey(children[0]) : null;
12884
+ if (key !== null) {
12885
+ const resolvedKeyAttrName = keyAttrName2(depth);
12886
+ if (bodyIsItemConditional) {
12887
+ applyLoopKeyAttr(itemConditional, resolvedKeyAttrName, key);
12888
+ } else if (children.length > 0) {
12889
+ applyLoopKeyAttr(children[0], resolvedKeyAttrName, key);
12890
+ }
12891
+ }
12767
12892
  const declaredNameSet = preamble && preamble.declaredNames.length > 0 ? new Set(preamble.declaredNames) : undefined;
12768
12893
  if (key && declaredNameSet) {
12769
12894
  const keyRefs = extractFreeIdentifiersFromText(key);
@@ -13454,7 +13579,7 @@ function getAttributeValue(attr, ctx) {
13454
13579
  ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(expr, ctx.sourceFile, ctx.filePath)));
13455
13580
  return AttrValueOf.expression("undefined");
13456
13581
  }
13457
- checkBareSignalOrMemoIdentifier(expr, ctx);
13582
+ checkBareSignalOrMemoIdentifier(expr, ctx, { descendNested: isRenderedElementAttribute(attr, ctx) });
13458
13583
  if (attr.name.getText(ctx.sourceFile) === "style" && ts13.isObjectLiteralExpression(expr)) {
13459
13584
  const cssString = tryStaticStyleObjectToCss(expr);
13460
13585
  if (cssString !== null) {
@@ -13962,34 +14087,142 @@ function processComponentProps(attributes, ctx) {
13962
14087
  }
13963
14088
  return props;
13964
14089
  }
13965
- function checkBareSignalOrMemoIdentifier(expr, ctx) {
13966
- if (!ts13.isIdentifier(expr))
14090
+ function isRenderedElementAttribute(attr, ctx) {
14091
+ const tagName = attr.parent.parent.tagName.getText(ctx.sourceFile);
14092
+ return !/^[A-Z]/.test(tagName);
14093
+ }
14094
+ function checkBareSignalOrMemoIdentifier(expr, ctx, options) {
14095
+ const reactiveNames = new Map;
14096
+ for (const signal of ctx.analyzer.signals)
14097
+ reactiveNames.set(signal.getter, "signal");
14098
+ for (const memo of ctx.analyzer.memos)
14099
+ reactiveNames.set(memo.name, "memo");
14100
+ if (reactiveNames.size === 0)
13967
14101
  return;
13968
- const name = expr.text;
13969
- for (const signal of ctx.analyzer.signals) {
13970
- if (signal.getter === name) {
13971
- ctx.analyzer.errors.push(createError(ErrorCodes.SIGNAL_GETTER_NOT_CALLED, getSourceLocation(expr, ctx.sourceFile, ctx.filePath), {
13972
- message: `Signal getter '${name}' passed without calling it`,
13973
- suggestion: {
13974
- message: `Signal getters must be called to read the value. Use \`${name}()\` instead of \`${name}\`.`,
13975
- replacement: `${name}()`
13976
- }
13977
- }));
14102
+ const report = (id, name, kind) => {
14103
+ const label = kind === "signal" ? "Signal" : "Memo";
14104
+ ctx.analyzer.errors.push(createError(ErrorCodes.SIGNAL_GETTER_NOT_CALLED, getSourceLocation(id, ctx.sourceFile, ctx.filePath), {
14105
+ message: `${label} getter '${name}' passed without calling it`,
14106
+ suggestion: {
14107
+ message: `${label} getters must be called to read the value. Use \`${name}()\` instead of \`${name}\`.`,
14108
+ replacement: `${name}()`
14109
+ }
14110
+ }));
14111
+ };
14112
+ if (ts13.isIdentifier(expr)) {
14113
+ const kind = reactiveNames.get(expr.text);
14114
+ if (kind && !ctx.scope.isBound(expr.text))
14115
+ report(expr, expr.text, kind);
14116
+ return;
14117
+ }
14118
+ if (!options?.descendNested)
14119
+ return;
14120
+ const boundStack = [];
14121
+ const isBound = (name) => {
14122
+ for (let i = boundStack.length - 1;i >= 0; i--) {
14123
+ if (boundStack[i].has(name))
14124
+ return true;
14125
+ }
14126
+ return ctx.scope.isBound(name);
14127
+ };
14128
+ const visitBindingDefaults = (name, bound) => {
14129
+ if (ts13.isIdentifier(name)) {
14130
+ bound.add(name.text);
13978
14131
  return;
13979
14132
  }
13980
- }
13981
- for (const memo of ctx.analyzer.memos) {
13982
- if (memo.name === name) {
13983
- ctx.analyzer.errors.push(createError(ErrorCodes.SIGNAL_GETTER_NOT_CALLED, getSourceLocation(expr, ctx.sourceFile, ctx.filePath), {
13984
- message: `Memo getter '${name}' passed without calling it`,
13985
- suggestion: {
13986
- message: `Memo getters must be called to read the value. Use \`${name}()\` instead of \`${name}\`.`,
13987
- replacement: `${name}()`
13988
- }
13989
- }));
14133
+ for (const el of name.elements) {
14134
+ if (ts13.isOmittedExpression(el))
14135
+ continue;
14136
+ if (el.initializer)
14137
+ visit2(el.initializer);
14138
+ visitBindingDefaults(el.name, bound);
14139
+ }
14140
+ };
14141
+ const collectBindingNames3 = (name, out) => {
14142
+ if (ts13.isIdentifier(name))
14143
+ out.add(name.text);
14144
+ else if (ts13.isObjectBindingPattern(name)) {
14145
+ for (const el of name.elements)
14146
+ collectBindingNames3(el.name, out);
14147
+ } else if (ts13.isArrayBindingPattern(name)) {
14148
+ for (const el of name.elements) {
14149
+ if (!ts13.isOmittedExpression(el))
14150
+ collectBindingNames3(el.name, out);
14151
+ }
14152
+ }
14153
+ };
14154
+ const collectBlockDeclarations = (block, out) => {
14155
+ for (const stmt of block.statements) {
14156
+ if (ts13.isVariableStatement(stmt)) {
14157
+ for (const decl of stmt.declarationList.declarations)
14158
+ collectBindingNames3(decl.name, out);
14159
+ } else if (ts13.isFunctionDeclaration(stmt) && stmt.name) {
14160
+ out.add(stmt.name.text);
14161
+ }
14162
+ }
14163
+ };
14164
+ function visit2(node) {
14165
+ if (ts13.isJsxElement(node) || ts13.isJsxSelfClosingElement(node) || ts13.isJsxFragment(node)) {
13990
14166
  return;
13991
14167
  }
14168
+ if (ts13.isTypeNode(node))
14169
+ return;
14170
+ if (ts13.isCallExpression(node) && node.arguments.length === 0 && ts13.isIdentifier(node.expression)) {
14171
+ return;
14172
+ }
14173
+ if (ts13.isPropertyAccessExpression(node)) {
14174
+ visit2(node.expression);
14175
+ return;
14176
+ }
14177
+ if (ts13.isPropertyAssignment(node)) {
14178
+ if (ts13.isComputedPropertyName(node.name))
14179
+ visit2(node.name.expression);
14180
+ visit2(node.initializer);
14181
+ return;
14182
+ }
14183
+ if (ts13.isShorthandPropertyAssignment(node)) {
14184
+ if (ts13.isIdentifier(node.name) && !isBound(node.name.text)) {
14185
+ const kind = reactiveNames.get(node.name.text);
14186
+ if (kind)
14187
+ report(node.name, node.name.text, kind);
14188
+ }
14189
+ return;
14190
+ }
14191
+ if (ts13.isArrowFunction(node) || ts13.isFunctionExpression(node)) {
14192
+ const bound = new Set;
14193
+ boundStack.push(bound);
14194
+ for (const p of node.parameters) {
14195
+ if (p.initializer)
14196
+ visit2(p.initializer);
14197
+ visitBindingDefaults(p.name, bound);
14198
+ }
14199
+ if (node.body && ts13.isBlock(node.body))
14200
+ collectBlockDeclarations(node.body, bound);
14201
+ if (node.body)
14202
+ visit2(node.body);
14203
+ boundStack.pop();
14204
+ return;
14205
+ }
14206
+ if (ts13.isVariableDeclaration(node)) {
14207
+ if (node.initializer)
14208
+ visit2(node.initializer);
14209
+ const declared = new Set;
14210
+ boundStack.push(declared);
14211
+ visitBindingDefaults(node.name, declared);
14212
+ boundStack.pop();
14213
+ return;
14214
+ }
14215
+ if (ts13.isIdentifier(node)) {
14216
+ if (isBound(node.text))
14217
+ return;
14218
+ const kind = reactiveNames.get(node.text);
14219
+ if (kind)
14220
+ report(node, node.text, kind);
14221
+ return;
14222
+ }
14223
+ ts13.forEachChild(node, visit2);
13992
14224
  }
14225
+ visit2(expr);
13993
14226
  }
13994
14227
  function isArrayExprDirectPropRef(arrayExpr, ctx) {
13995
14228
  const propNames = new Set(ctx.patterns.props.map((p) => p.name));
@@ -14088,6 +14321,31 @@ function isPropsReference(expr, ctx, visited) {
14088
14321
  }
14089
14322
  return false;
14090
14323
  }
14324
+ function forwardsCallerRestProps(attrs, ctx) {
14325
+ for (const attr of attrs) {
14326
+ if (attr.value.kind !== "spread")
14327
+ continue;
14328
+ const constants = restSpreadConstantValues(ctx);
14329
+ for (const name of new Set([attr.value.expr, attr.value.templateExpr])) {
14330
+ if (!name)
14331
+ continue;
14332
+ if (resolveRestSpreadOriginCore(ctx.analyzer, constants, name) !== null)
14333
+ return true;
14334
+ }
14335
+ }
14336
+ return false;
14337
+ }
14338
+ function restSpreadConstantValues(ctx) {
14339
+ if (ctx._restSpreadConstantValues)
14340
+ return ctx._restSpreadConstantValues;
14341
+ const byName = new Map;
14342
+ for (const constant of ctx.analyzer.localConstants) {
14343
+ if (!byName.has(constant.name))
14344
+ byName.set(constant.name, constant.value);
14345
+ }
14346
+ ctx._restSpreadConstantValues = byName;
14347
+ return byName;
14348
+ }
14091
14349
  function hasReactiveAttributes(attrs, ctx) {
14092
14350
  for (const attr of attrs) {
14093
14351
  if (attr.name === "key")
@@ -14309,6 +14567,39 @@ function buildIfStatementChain(analyzer, ctx, opts) {
14309
14567
  }
14310
14568
 
14311
14569
  // src/ir-to-client-js/prop-handling.ts
14570
+ function resolveRestSpreadOrigin(ctx, name) {
14571
+ return resolveRestSpreadOriginCore(ctx, localConstantValues(ctx), name);
14572
+ }
14573
+ var _localConstantValuesCache = new WeakMap;
14574
+ function localConstantValues(ctx) {
14575
+ const cached = _localConstantValuesCache.get(ctx);
14576
+ if (cached)
14577
+ return cached;
14578
+ const byName = new Map;
14579
+ for (const constant of ctx.localConstants) {
14580
+ if (!byName.has(constant.name))
14581
+ byName.set(constant.name, constant.value);
14582
+ }
14583
+ _localConstantValuesCache.set(ctx, byName);
14584
+ return byName;
14585
+ }
14586
+ var _restSpreadNamesCache = new WeakMap;
14587
+ function resolveRestSpreadNames(ctx) {
14588
+ const cached = _restSpreadNamesCache.get(ctx);
14589
+ if (cached)
14590
+ return cached;
14591
+ const names = new Set;
14592
+ if (ctx.restPropsName)
14593
+ names.add(ctx.restPropsName);
14594
+ if (ctx.propsObjectName)
14595
+ names.add(ctx.propsObjectName);
14596
+ for (const constant of ctx.localConstants) {
14597
+ if (resolveRestSpreadOrigin(ctx, constant.name) !== null)
14598
+ names.add(constant.name);
14599
+ }
14600
+ _restSpreadNamesCache.set(ctx, names);
14601
+ return names;
14602
+ }
14312
14603
  function expandDynamicPropValue(value, ctx, scope) {
14313
14604
  const trimmedValue = value.trim();
14314
14605
  if (scope?.isBound(trimmedValue))
@@ -14397,6 +14688,9 @@ function decideWrapForChildProp(expandedValue, ctx, prop) {
14397
14688
  return decideWrapForAttr(expandedValue, ctx, prop);
14398
14689
  }
14399
14690
  function needsEffectWrapper(expr, ctx, freeIdentifiers2) {
14691
+ return needsEffectWrapperCore(expr, ctx, freeIdentifiers2, new Set);
14692
+ }
14693
+ function needsEffectWrapperCore(expr, ctx, freeIdentifiers2, visitedConstants) {
14400
14694
  for (const signal of ctx.signals) {
14401
14695
  if (identifierCallPattern(signal.getter).test(expr)) {
14402
14696
  return true;
@@ -14419,6 +14713,19 @@ function needsEffectWrapper(expr, ctx, freeIdentifiers2) {
14419
14713
  if (propsAccess.test(expr))
14420
14714
  return true;
14421
14715
  }
14716
+ for (const constant of ctx.localConstants) {
14717
+ if (visitedConstants.has(constant.name))
14718
+ continue;
14719
+ if (constant.value === undefined || constant.containsArrow)
14720
+ continue;
14721
+ const referenced = freeIdentifiers2 ? freeIdentifiers2.has(constant.name) : tokenContainsIdent(expr, constant.name);
14722
+ if (!referenced)
14723
+ continue;
14724
+ visitedConstants.add(constant.name);
14725
+ if (needsEffectWrapperCore(constant.value, ctx, constant.freeIdentifiers, visitedConstants)) {
14726
+ return true;
14727
+ }
14728
+ }
14422
14729
  return false;
14423
14730
  }
14424
14731
  function classifyReactivity(expr, ctx, loopParam, loopParamBindings, freeIdentifiers2) {
@@ -14871,6 +15178,7 @@ function emitMultiRootTemplateCloneLines(template, indent, varEl, varExtras) {
14871
15178
  }
14872
15179
 
14873
15180
  // src/ir-to-client-js/collect-elements.ts
15181
+ import { classifyDOMProp } from "@barefootjs/shared";
14874
15182
  var EMPTY_RENDER_EXPRS = new Set(["null", "undefined", "false", "''", '""', "``"]);
14875
15183
  function domElementCount(node) {
14876
15184
  switch (node.type) {
@@ -15092,24 +15400,14 @@ function jsxChildrenContainComponent(nodes) {
15092
15400
  function isSingleElementJsxChildren2(nodes) {
15093
15401
  return nodes.length === 1 && nodes[0].type === "element";
15094
15402
  }
15095
- function buildRestSpreadNames(ctx) {
15096
- const names = new Set;
15097
- if (ctx.restPropsName)
15098
- names.add(ctx.restPropsName);
15099
- if (ctx.propsObjectName)
15100
- names.add(ctx.propsObjectName);
15101
- return names;
15102
- }
15103
15403
  function buildComponentPropsExpr(props, ctx) {
15104
- const restName = ctx.restPropsName;
15105
- const propsObjName = ctx.propsObjectName;
15106
15404
  const knownSpreadProp = props.find((p) => {
15107
15405
  if (p.name !== "..." && !p.name.startsWith("..."))
15108
15406
  return false;
15109
15407
  if (p.value.kind !== "spread" && p.value.kind !== "expression")
15110
15408
  return false;
15111
15409
  const expr = p.value.kind === "spread" ? p.value.expr : p.value.expr;
15112
- return expr === restName || expr === propsObjName;
15410
+ return resolveRestSpreadOrigin(ctx, expr) !== null;
15113
15411
  });
15114
15412
  const spreadSource = knownSpreadProp ? PROPS_PARAM : null;
15115
15413
  const propsForInit = [];
@@ -15167,8 +15465,8 @@ function collectReactiveChildProps(node, ctx) {
15167
15465
  continue;
15168
15466
  if (prop.value.kind === "jsx-children")
15169
15467
  continue;
15170
- const isEventHandler = prop.name.startsWith("on") && prop.name.length > 2 && prop.name[2] === prop.name[2].toUpperCase();
15171
- if (isEventHandler)
15468
+ const domKind = classifyDOMProp(prop.name).kind;
15469
+ if (domKind === "ref" || domKind === "event" || domKind === "skip")
15172
15470
  continue;
15173
15471
  if (prop.value.kind !== "expression" && prop.value.kind !== "template")
15174
15472
  continue;
@@ -15257,13 +15555,13 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
15257
15555
  if (l.childComponent) {
15258
15556
  template = "";
15259
15557
  if (l.isStaticArray && l.children[0]) {
15260
- staticItemTemplate = irToHtmlTemplate(l.children[0], buildRestSpreadNames(ctx), 0, undefined, undefined);
15558
+ staticItemTemplate = irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, undefined, undefined);
15261
15559
  }
15262
15560
  } else if (l.children[0] && !projectionInner) {
15263
15561
  const loopParamSpec = [{ param: l.param, bindings: l.paramBindings }];
15264
- template = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], buildRestSpreadNames(ctx), 0, loopParamSpec) : irToHtmlTemplate(l.children[0], buildRestSpreadNames(ctx), 0, loopParamSpec);
15562
+ template = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, loopParamSpec) : irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx), 0, loopParamSpec);
15265
15563
  if (l.isStaticArray) {
15266
- staticItemTemplate = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], buildRestSpreadNames(ctx), 0) : irToHtmlTemplate(l.children[0], buildRestSpreadNames(ctx), 0);
15564
+ staticItemTemplate = useElementReconciliation ? irToPlaceholderTemplate(l.children[0], resolveRestSpreadNames(ctx), 0) : irToHtmlTemplate(l.children[0], resolveRestSpreadNames(ctx), 0);
15267
15565
  } else if (!useElementReconciliation && !l.bodyIsMultiRoot && !l.bodyIsItemConditional) {
15268
15566
  const skeletonSafeSlots = {
15269
15567
  reactiveAttrKeys: new Set(bindings.reactiveAttrs.map((a) => `${a.childSlotId}::${a.attrName}`)),
@@ -15315,11 +15613,11 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
15315
15613
  preambleRegions: l.preambleRegions,
15316
15614
  flatMapClient: projectionInner ? {
15317
15615
  params: l.index ? `(${l.param}, ${l.index})` : `(${l.param})`,
15318
- body: renderFlatMapProjectionClientBody(projectionInner, buildRestSpreadNames(ctx)),
15616
+ body: renderFlatMapProjectionClientBody(projectionInner, resolveRestSpreadNames(ctx)),
15319
15617
  keyed: projectionInner.key !== null
15320
15618
  } : l.flatMapCallback ? {
15321
15619
  params: l.flatMapCallback.params,
15322
- body: renderFlatMapClientBody(l.flatMapCallback, buildRestSpreadNames(ctx)),
15620
+ body: renderFlatMapClientBody(l.flatMapCallback, resolveRestSpreadNames(ctx)),
15323
15621
  keyed: flatMapCallbackHasKeyedLeaf(l.flatMapCallback)
15324
15622
  } : undefined
15325
15623
  });
@@ -15386,10 +15684,9 @@ function collectFromElement(element, ctx, insideConditional = false) {
15386
15684
  for (const attr of element.attrs) {
15387
15685
  if (attr.name === "..." && attr.value) {
15388
15686
  const spreadVal = attrValueToString(attr.value) ?? "";
15389
- const elemRestName = ctx.restPropsName;
15390
- const elemPropsObjName = ctx.propsObjectName;
15391
- if (spreadVal && (spreadVal === elemRestName || spreadVal === elemPropsObjName)) {
15392
- const consumedKeys = spreadVal === elemRestName ? ctx.propsParams.map((p) => p.sourceName ?? p.name) : [];
15687
+ const spreadOrigin = spreadVal ? resolveRestSpreadOrigin(ctx, spreadVal) : null;
15688
+ if (spreadOrigin !== null) {
15689
+ const consumedKeys = spreadOrigin === "rest" ? ctx.propsParams.map((p) => p.sourceName ?? p.name) : [];
15393
15690
  const staticAttrKeys = element.attrs.filter((a) => a.name !== "...").map((a) => a.name);
15394
15691
  const excludeKeys = [...new Set([...consumedKeys, ...staticAttrKeys])];
15395
15692
  ctx.restAttrElements.push({
@@ -15468,7 +15765,7 @@ function collectBranchTextEffects(node) {
15468
15765
  }
15469
15766
  function collectBranchLoops(node, ctx, siblingOffsets) {
15470
15767
  const loops = [];
15471
- const restNames = ctx ? buildRestSpreadNames(ctx) : undefined;
15768
+ const restNames = ctx ? resolveRestSpreadNames(ctx) : undefined;
15472
15769
  walkIR(node, null, {
15473
15770
  ...stopAt("conditional", "ifStatement"),
15474
15771
  element: ({ node: el, scope: parentSlotId, descend }) => {
@@ -15536,7 +15833,7 @@ function collectBranchLoops(node, ctx, siblingOffsets) {
15536
15833
  return loops;
15537
15834
  }
15538
15835
  function buildConditionalMetadata(node, ctx, siblingOffsets) {
15539
- const restNames = buildRestSpreadNames(ctx);
15836
+ const restNames = resolveRestSpreadNames(ctx);
15540
15837
  return {
15541
15838
  slotId: node.slotId,
15542
15839
  condition: node.condition,
@@ -16086,6 +16383,9 @@ function propHasPropertyAccess(u) {
16086
16383
  return u.accessKinds.has("property") || u.accessKinds.has("index");
16087
16384
  }
16088
16385
 
16386
+ // src/ir-to-client-js/imports.ts
16387
+ import ts16 from "typescript";
16388
+
16089
16389
  // src/value-references.ts
16090
16390
  import ts15 from "typescript";
16091
16391
  function isValueReferenceIdentifier(id) {
@@ -16192,6 +16492,7 @@ var RUNTIME_IMPORT_CANDIDATES = [
16192
16492
  "escapeTextOrNode",
16193
16493
  "bfMarkup",
16194
16494
  "escapeTextOrMarkup",
16495
+ "markupOrEmpty",
16195
16496
  "qsa",
16196
16497
  "qsaItem",
16197
16498
  "qsaChildScope",
@@ -16258,6 +16559,79 @@ function makeValueUsageTest(generatedCode) {
16258
16559
  return generatedCode.includes(localName);
16259
16560
  };
16260
16561
  }
16562
+ function renderUsedImportLines(source, usedDefault, usedNamespace, usedNamed) {
16563
+ const lines = [];
16564
+ const defaultAndNamed = [
16565
+ usedDefault,
16566
+ usedNamed.length > 0 ? `{ ${usedNamed.join(", ")} }` : null
16567
+ ].filter((part) => part !== null).join(", ");
16568
+ if (defaultAndNamed)
16569
+ lines.push(`import ${defaultAndNamed} from '${source}'`);
16570
+ if (usedNamespace)
16571
+ lines.push(`import * as ${usedNamespace} from '${source}'`);
16572
+ return lines;
16573
+ }
16574
+ function mergeCompiledClientJsImports(codeBlobs) {
16575
+ const sourceOrder = [];
16576
+ const namedBySource = new Map;
16577
+ const defaultBySource = new Map;
16578
+ const otherImports = [];
16579
+ const seenOther = new Set;
16580
+ const codeSections = [];
16581
+ const ensureSource = (source) => {
16582
+ if (!namedBySource.has(source)) {
16583
+ namedBySource.set(source, new Set);
16584
+ sourceOrder.push(source);
16585
+ }
16586
+ return namedBySource.get(source);
16587
+ };
16588
+ for (const content of codeBlobs) {
16589
+ const sourceFile = ts16.createSourceFile("combine.js", content, ts16.ScriptTarget.Latest, false, ts16.ScriptKind.JS);
16590
+ const importSpans = [];
16591
+ for (const stmt of sourceFile.statements) {
16592
+ if (!ts16.isImportDeclaration(stmt))
16593
+ continue;
16594
+ const start = stmt.getStart(sourceFile);
16595
+ const end = stmt.getEnd();
16596
+ importSpans.push([start, end]);
16597
+ const clause = stmt.importClause;
16598
+ const bindings = clause?.namedBindings;
16599
+ const specifier = ts16.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
16600
+ const isNamespace = !!bindings && ts16.isNamespaceImport(bindings);
16601
+ const isNamed = !!bindings && ts16.isNamedImports(bindings);
16602
+ if (!isNamespace && (clause?.name || isNamed)) {
16603
+ const set = ensureSource(specifier);
16604
+ if (clause?.name && !defaultBySource.has(specifier)) {
16605
+ defaultBySource.set(specifier, clause.name.text);
16606
+ }
16607
+ if (isNamed) {
16608
+ for (const el of bindings.elements) {
16609
+ set.add(el.propertyName ? `${el.propertyName.text} as ${el.name.text}` : el.name.text);
16610
+ }
16611
+ }
16612
+ } else {
16613
+ const stmtText = content.slice(start, end);
16614
+ if (!seenOther.has(stmtText)) {
16615
+ seenOther.add(stmtText);
16616
+ otherImports.push(stmtText);
16617
+ }
16618
+ }
16619
+ }
16620
+ let code = "";
16621
+ let cursor = 0;
16622
+ for (const [start, end] of importSpans) {
16623
+ code += content.slice(cursor, start);
16624
+ cursor = end;
16625
+ }
16626
+ code += content.slice(cursor);
16627
+ code = code.trim();
16628
+ if (code)
16629
+ codeSections.push(code);
16630
+ }
16631
+ const mergedImports = sourceOrder.flatMap((source) => renderUsedImportLines(source, defaultBySource.get(source) ?? null, null, [...namedBySource.get(source)]));
16632
+ return [...mergedImports, ...otherImports, "", ...codeSections].join(`
16633
+ `);
16634
+ }
16261
16635
  function collectExternalImports(ir, generatedCode, localImportPrefixes) {
16262
16636
  const componentNames = collectComponentNames(ir.root);
16263
16637
  const importLines = [];
@@ -16273,23 +16647,31 @@ function collectExternalImports(ir, generatedCode, localImportPrefixes) {
16273
16647
  importLines.push(`import '${imp.source}'`);
16274
16648
  continue;
16275
16649
  }
16276
- const usedSpecs = [];
16650
+ const usedNamed = [];
16651
+ let usedDefault = null;
16652
+ let usedNamespace = null;
16277
16653
  for (const spec of imp.specifiers) {
16278
16654
  if (spec.isTypeOnly)
16279
16655
  continue;
16280
16656
  const localName = spec.alias || spec.name;
16281
16657
  if (componentNames.has(localName))
16282
16658
  continue;
16283
- if (isUsedAsValue(localName)) {
16284
- usedSpecs.push(spec.alias ? `${spec.name} as ${spec.alias}` : spec.name);
16659
+ if (!isUsedAsValue(localName))
16660
+ continue;
16661
+ if (spec.isDefault) {
16662
+ usedDefault = localName;
16663
+ } else if (spec.isNamespace) {
16664
+ usedNamespace = localName;
16665
+ } else {
16666
+ usedNamed.push(spec.alias ? `${spec.name} as ${spec.alias}` : spec.name);
16285
16667
  }
16286
16668
  }
16287
- if (usedSpecs.length > 0) {
16669
+ if (usedDefault || usedNamespace || usedNamed.length > 0) {
16288
16670
  let source = imp.source;
16289
16671
  if (ir.metadata.clientSignalImportSources?.has(source)) {
16290
16672
  source = source.replace(/\.tsx?$/, "") + ".client.js";
16291
16673
  }
16292
- importLines.push(`import { ${usedSpecs.join(", ")} } from '${source}'`);
16674
+ importLines.push(...renderUsedImportLines(source, usedDefault, usedNamespace, usedNamed));
16293
16675
  }
16294
16676
  }
16295
16677
  return importLines;
@@ -16319,7 +16701,7 @@ function collectComponentNames(node) {
16319
16701
  }
16320
16702
 
16321
16703
  // src/relocate.ts
16322
- import ts16 from "typescript";
16704
+ import ts17 from "typescript";
16323
16705
 
16324
16706
  // src/lowering-registry.ts
16325
16707
  var plugins = [];
@@ -16365,19 +16747,19 @@ function classify(name, env) {
16365
16747
  function collectFreeRefs(node) {
16366
16748
  const refs = new Map;
16367
16749
  function visit3(n, parent) {
16368
- if (ts16.isIdentifier(n)) {
16369
- if (parent && ts16.isPropertyAccessExpression(parent) && parent.name === n)
16750
+ if (ts17.isIdentifier(n)) {
16751
+ if (parent && ts17.isPropertyAccessExpression(parent) && parent.name === n)
16370
16752
  return;
16371
- if (parent && ts16.isPropertyAssignment(parent) && parent.name === n)
16753
+ if (parent && ts17.isPropertyAssignment(parent) && parent.name === n)
16372
16754
  return;
16373
- if (parent && ts16.isShorthandPropertyAssignment(parent) && parent.name === n)
16755
+ if (parent && ts17.isShorthandPropertyAssignment(parent) && parent.name === n)
16374
16756
  return;
16375
16757
  const list = refs.get(n.text) ?? [];
16376
16758
  list.push(n);
16377
16759
  refs.set(n.text, list);
16378
16760
  return;
16379
16761
  }
16380
- ts16.forEachChild(n, (child) => visit3(child, n));
16762
+ ts17.forEachChild(n, (child) => visit3(child, n));
16381
16763
  }
16382
16764
  visit3(node);
16383
16765
  return refs;
@@ -16481,11 +16863,11 @@ function isInlinableInTemplate(value, env) {
16481
16863
  return { ok: true, rewrittenValue: r.text, decisions: r.decisions };
16482
16864
  }
16483
16865
  function getCalleeIdentifierPath(callee) {
16484
- if (ts16.isParenthesizedExpression(callee))
16866
+ if (ts17.isParenthesizedExpression(callee))
16485
16867
  return getCalleeIdentifierPath(callee.expression);
16486
- if (ts16.isIdentifier(callee))
16868
+ if (ts17.isIdentifier(callee))
16487
16869
  return callee.text;
16488
- if (ts16.isPropertyAccessExpression(callee)) {
16870
+ if (ts17.isPropertyAccessExpression(callee)) {
16489
16871
  const left = getCalleeIdentifierPath(callee.expression);
16490
16872
  if (left === null)
16491
16873
  return null;
@@ -16494,11 +16876,11 @@ function getCalleeIdentifierPath(callee) {
16494
16876
  return null;
16495
16877
  }
16496
16878
  function getCalleeLeftmostIdentifier(callee) {
16497
- if (ts16.isParenthesizedExpression(callee))
16879
+ if (ts17.isParenthesizedExpression(callee))
16498
16880
  return getCalleeLeftmostIdentifier(callee.expression);
16499
- if (ts16.isIdentifier(callee))
16881
+ if (ts17.isIdentifier(callee))
16500
16882
  return callee.text;
16501
- if (ts16.isPropertyAccessExpression(callee)) {
16883
+ if (ts17.isPropertyAccessExpression(callee)) {
16502
16884
  return getCalleeLeftmostIdentifier(callee.expression);
16503
16885
  }
16504
16886
  return null;
@@ -16546,12 +16928,12 @@ function isCallAcceptedByAdapter(call, env) {
16546
16928
  }
16547
16929
  function parseExpressionNode(text) {
16548
16930
  try {
16549
- const sf = ts16.createSourceFile("__inline_check__.ts", `(${text});`, ts16.ScriptTarget.Latest, false, ts16.ScriptKind.TS);
16931
+ const sf = ts17.createSourceFile("__inline_check__.ts", `(${text});`, ts17.ScriptTarget.Latest, false, ts17.ScriptKind.TS);
16550
16932
  const stmt = sf.statements[0];
16551
- if (!stmt || !ts16.isExpressionStatement(stmt))
16933
+ if (!stmt || !ts17.isExpressionStatement(stmt))
16552
16934
  return null;
16553
16935
  const inner = stmt.expression;
16554
- return ts16.isParenthesizedExpression(inner) ? inner.expression : inner;
16936
+ return ts17.isParenthesizedExpression(inner) ? inner.expression : inner;
16555
16937
  } catch {
16556
16938
  return null;
16557
16939
  }
@@ -16568,8 +16950,8 @@ function hasCallWithBridgedArg(node, decisions, env) {
16568
16950
  function visit3(n) {
16569
16951
  if (found)
16570
16952
  return;
16571
- if (ts16.isCallExpression(n) || ts16.isNewExpression(n)) {
16572
- const accepted = ts16.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
16953
+ if (ts17.isCallExpression(n) || ts17.isNewExpression(n)) {
16954
+ const accepted = ts17.isCallExpression(n) && isCallAcceptedByAdapter(n, env);
16573
16955
  if (!accepted) {
16574
16956
  const args = n.arguments;
16575
16957
  if (args) {
@@ -16582,7 +16964,7 @@ function hasCallWithBridgedArg(node, decisions, env) {
16582
16964
  }
16583
16965
  }
16584
16966
  }
16585
- ts16.forEachChild(n, visit3);
16967
+ ts17.forEachChild(n, visit3);
16586
16968
  }
16587
16969
  visit3(node);
16588
16970
  return found;
@@ -16592,13 +16974,13 @@ function hasZeroArgCall(node, env) {
16592
16974
  function visit3(n) {
16593
16975
  if (found)
16594
16976
  return;
16595
- if (ts16.isCallExpression(n) && n.arguments.length === 0) {
16977
+ if (ts17.isCallExpression(n) && n.arguments.length === 0) {
16596
16978
  if (!isCallAcceptedByAdapter(n, env)) {
16597
16979
  found = true;
16598
16980
  return;
16599
16981
  }
16600
16982
  }
16601
- ts16.forEachChild(n, visit3);
16983
+ ts17.forEachChild(n, visit3);
16602
16984
  }
16603
16985
  visit3(node);
16604
16986
  return found;
@@ -16608,25 +16990,25 @@ function containsAnyIdentifier(node, names) {
16608
16990
  function visit3(n) {
16609
16991
  if (found)
16610
16992
  return;
16611
- if (ts16.isPropertyAccessExpression(n)) {
16993
+ if (ts17.isPropertyAccessExpression(n)) {
16612
16994
  visit3(n.expression);
16613
16995
  return;
16614
16996
  }
16615
- if (ts16.isPropertyAssignment(n)) {
16997
+ if (ts17.isPropertyAssignment(n)) {
16616
16998
  visit3(n.initializer);
16617
16999
  return;
16618
17000
  }
16619
- if (ts16.isShorthandPropertyAssignment(n)) {
16620
- if (ts16.isIdentifier(n.name) && names.has(n.name.text)) {
17001
+ if (ts17.isShorthandPropertyAssignment(n)) {
17002
+ if (ts17.isIdentifier(n.name) && names.has(n.name.text)) {
16621
17003
  found = true;
16622
17004
  }
16623
17005
  return;
16624
17006
  }
16625
- if (ts16.isIdentifier(n) && names.has(n.text)) {
17007
+ if (ts17.isIdentifier(n) && names.has(n.text)) {
16626
17008
  found = true;
16627
17009
  return;
16628
17010
  }
16629
- ts16.forEachChild(n, visit3);
17011
+ ts17.forEachChild(n, visit3);
16630
17012
  }
16631
17013
  visit3(node);
16632
17014
  return found;
@@ -17198,12 +17580,9 @@ function emitRegistrationAndHydration(lines, ctx, _ir, graph, inlinability) {
17198
17580
  lines.push("");
17199
17581
  const propNamesForStaticCheck = new Set(ctx.propsParams.map((p) => p.name));
17200
17582
  const { inlinableConstants, unsafeLocalNames } = inlinability ?? buildInlinableConstants(ctx, graph, _ir.root);
17201
- const restSpreadNames = new Set;
17202
- if (ctx.restPropsName)
17203
- restSpreadNames.add(ctx.restPropsName);
17204
- if (ctx.propsObjectName)
17205
- restSpreadNames.add(ctx.propsObjectName);
17206
- const isCommentScope = _ir.root.type === "fragment" && _ir.root.needsScopeComment || _ir.root.type === "component";
17583
+ const restSpreadNames = resolveRestSpreadNames(ctx);
17584
+ const isFragmentRoot = _ir.root.type === "fragment" && !!_ir.root.needsScopeComment;
17585
+ const isCommentScope = isFragmentRoot || _ir.root.type === "component";
17207
17586
  const defParts = [`init: init${name}`];
17208
17587
  if (canGenerateStaticTemplate(_ir.root, propNamesForStaticCheck, inlinableConstants, unsafeLocalNames)) {
17209
17588
  const markupSlotIds = new Set(ctx.dynamicElements.map((e) => e.slotId));
@@ -17221,6 +17600,9 @@ function emitRegistrationAndHydration(lines, ctx, _ir, graph, inlinability) {
17221
17600
  if (isCommentScope) {
17222
17601
  defParts.push("comment: true");
17223
17602
  }
17603
+ if (isFragmentRoot) {
17604
+ defParts.push("fragmentRoot: true");
17605
+ }
17224
17606
  const registryKey = nameForRegistryRef(name);
17225
17607
  if (registryKey !== name) {
17226
17608
  defParts.push(`name: '${name}'`);
@@ -17937,23 +18319,23 @@ function resolveFinalImports(generatedCode, ir, localImportPrefixes) {
17937
18319
  }
17938
18320
 
17939
18321
  // src/ir-to-client-js/prune-unused-prop-extractions.ts
17940
- import ts17 from "typescript";
18322
+ import ts18 from "typescript";
17941
18323
  function propExtractionName(stmt) {
17942
- if (!ts17.isVariableStatement(stmt))
18324
+ if (!ts18.isVariableStatement(stmt))
17943
18325
  return null;
17944
18326
  const decls = stmt.declarationList.declarations;
17945
18327
  if (decls.length !== 1)
17946
18328
  return null;
17947
18329
  const decl = decls[0];
17948
- if (!ts17.isIdentifier(decl.name) || !decl.initializer)
18330
+ if (!ts18.isIdentifier(decl.name) || !decl.initializer)
17949
18331
  return null;
17950
18332
  let core = decl.initializer;
17951
- if (ts17.isBinaryExpression(core) && core.operatorToken.kind === ts17.SyntaxKind.QuestionQuestionToken) {
18333
+ if (ts18.isBinaryExpression(core) && core.operatorToken.kind === ts18.SyntaxKind.QuestionQuestionToken) {
17952
18334
  core = core.left;
17953
18335
  }
17954
- if (!ts17.isPropertyAccessExpression(core))
18336
+ if (!ts18.isPropertyAccessExpression(core))
17955
18337
  return null;
17956
- if (!ts17.isIdentifier(core.expression) || core.expression.text !== PROPS_PARAM)
18338
+ if (!ts18.isIdentifier(core.expression) || core.expression.text !== PROPS_PARAM)
17957
18339
  return null;
17958
18340
  if (core.name.text !== decl.name.text)
17959
18341
  return null;
@@ -17966,10 +18348,10 @@ function pruneUnusedPropExtractions(code) {
17966
18348
  console.warn("[barefootjs] pruneUnusedPropExtractions: generated code did not parse; skipping prune");
17967
18349
  return code;
17968
18350
  }
17969
- const sourceFile = ts17.createSourceFile("generated.js", code, ts17.ScriptTarget.Latest, false, ts17.ScriptKind.JS);
18351
+ const sourceFile = ts18.createSourceFile("generated.js", code, ts18.ScriptTarget.Latest, false, ts18.ScriptKind.JS);
17970
18352
  const spans = [];
17971
18353
  for (const stmt of sourceFile.statements) {
17972
- if (!ts17.isFunctionDeclaration(stmt) || !stmt.name?.text.startsWith("init") || !stmt.body)
18354
+ if (!ts18.isFunctionDeclaration(stmt) || !stmt.name?.text.startsWith("init") || !stmt.body)
17973
18355
  continue;
17974
18356
  for (const inner of stmt.body.statements) {
17975
18357
  const name = propExtractionName(inner);
@@ -19430,7 +19812,7 @@ function analyzeLazyConditional(cond, indexParam, arms) {
19430
19812
  }
19431
19813
 
19432
19814
  // src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
19433
- import ts18 from "typescript";
19815
+ import ts19 from "typescript";
19434
19816
  var NO_PREAMBLE = {
19435
19817
  lazySafe: true,
19436
19818
  facts: { declaredNames: new Set, freeNames: new Set }
@@ -19450,12 +19832,12 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19450
19832
  if (text.trim().length === 0)
19451
19833
  return NO_PREAMBLE;
19452
19834
  const declaredNames = new Set;
19453
- const sf = ts18.createSourceFile("__lazy_preamble__.ts", text, ts18.ScriptTarget.Latest, true, ts18.ScriptKind.TS);
19835
+ const sf = ts19.createSourceFile("__lazy_preamble__.ts", text, ts19.ScriptTarget.Latest, true, ts19.ScriptKind.TS);
19454
19836
  for (const stmt of sf.statements) {
19455
- if (!ts18.isVariableStatement(stmt)) {
19456
- return NO2(`map-callback preamble has a non-declaration statement (${ts18.SyntaxKind[stmt.kind]})`);
19837
+ if (!ts19.isVariableStatement(stmt)) {
19838
+ return NO2(`map-callback preamble has a non-declaration statement (${ts19.SyntaxKind[stmt.kind]})`);
19457
19839
  }
19458
- const isConst = (stmt.declarationList.flags & ts18.NodeFlags.Const) !== 0;
19840
+ const isConst = (stmt.declarationList.flags & ts19.NodeFlags.Const) !== 0;
19459
19841
  if (!isConst)
19460
19842
  return NO2("map-callback preamble declares a mutable binding (let/var)");
19461
19843
  for (const decl of stmt.declarationList.declarations) {
@@ -19484,12 +19866,12 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19484
19866
  return { lazySafe: true, facts: { declaredNames, freeNames } };
19485
19867
  }
19486
19868
  function collectBindingNames3(name, out) {
19487
- if (ts18.isIdentifier(name)) {
19869
+ if (ts19.isIdentifier(name)) {
19488
19870
  out.add(name.text);
19489
19871
  return;
19490
19872
  }
19491
19873
  for (const element of name.elements) {
19492
- if (ts18.isOmittedExpression(element))
19874
+ if (ts19.isOmittedExpression(element))
19493
19875
  continue;
19494
19876
  collectBindingNames3(element.name, out);
19495
19877
  }
@@ -19499,56 +19881,56 @@ function findImpureNode(root, primableNames) {
19499
19881
  const visit3 = (node) => {
19500
19882
  if (found)
19501
19883
  return;
19502
- if (ts18.isCallExpression(node)) {
19884
+ if (ts19.isCallExpression(node)) {
19503
19885
  const callee = node.expression;
19504
- const isSignalRead = ts18.isIdentifier(callee) && primableNames.has(callee.text) && node.arguments.length === 0 && node.questionDotToken === undefined;
19886
+ const isSignalRead = ts19.isIdentifier(callee) && primableNames.has(callee.text) && node.arguments.length === 0 && node.questionDotToken === undefined;
19505
19887
  if (!isSignalRead) {
19506
19888
  found = `call to ${callee.getText(callee.getSourceFile())}`;
19507
19889
  return;
19508
19890
  }
19509
19891
  }
19510
- if (ts18.isNewExpression(node)) {
19892
+ if (ts19.isNewExpression(node)) {
19511
19893
  found = "new expression";
19512
19894
  return;
19513
19895
  }
19514
- if (ts18.isTaggedTemplateExpression(node)) {
19896
+ if (ts19.isTaggedTemplateExpression(node)) {
19515
19897
  found = "tagged template";
19516
19898
  return;
19517
19899
  }
19518
- if (ts18.isAwaitExpression(node)) {
19900
+ if (ts19.isAwaitExpression(node)) {
19519
19901
  found = "await";
19520
19902
  return;
19521
19903
  }
19522
- if (ts18.isYieldExpression(node)) {
19904
+ if (ts19.isYieldExpression(node)) {
19523
19905
  found = "yield";
19524
19906
  return;
19525
19907
  }
19526
- if (ts18.isPrefixUnaryExpression(node) || ts18.isPostfixUnaryExpression(node)) {
19908
+ if (ts19.isPrefixUnaryExpression(node) || ts19.isPostfixUnaryExpression(node)) {
19527
19909
  const op = node.operator;
19528
- if (op === ts18.SyntaxKind.PlusPlusToken || op === ts18.SyntaxKind.MinusMinusToken) {
19910
+ if (op === ts19.SyntaxKind.PlusPlusToken || op === ts19.SyntaxKind.MinusMinusToken) {
19529
19911
  found = "increment/decrement";
19530
19912
  return;
19531
19913
  }
19532
19914
  }
19533
- if (ts18.isDeleteExpression(node)) {
19915
+ if (ts19.isDeleteExpression(node)) {
19534
19916
  found = "delete";
19535
19917
  return;
19536
19918
  }
19537
- if (ts18.isFunctionExpression(node) || ts18.isArrowFunction(node) || ts18.isClassExpression(node)) {
19919
+ if (ts19.isFunctionExpression(node) || ts19.isArrowFunction(node) || ts19.isClassExpression(node)) {
19538
19920
  found = "function or class expression";
19539
19921
  return;
19540
19922
  }
19541
- if (ts18.isBinaryExpression(node) && isAssignmentOperator2(node.operatorToken.kind)) {
19923
+ if (ts19.isBinaryExpression(node) && isAssignmentOperator2(node.operatorToken.kind)) {
19542
19924
  found = "assignment";
19543
19925
  return;
19544
19926
  }
19545
- ts18.forEachChild(node, visit3);
19927
+ ts19.forEachChild(node, visit3);
19546
19928
  };
19547
19929
  visit3(root);
19548
19930
  return found;
19549
19931
  }
19550
19932
  function isAssignmentOperator2(kind) {
19551
- return kind >= ts18.SyntaxKind.FirstAssignment && kind <= ts18.SyntaxKind.LastAssignment;
19933
+ return kind >= ts19.SyntaxKind.FirstAssignment && kind <= ts19.SyntaxKind.LastAssignment;
19552
19934
  }
19553
19935
 
19554
19936
  // src/ir-to-client-js/control-flow/plan/lazy-row-eligibility.ts
@@ -20078,7 +20460,7 @@ function buildArmBody(branch, options) {
20078
20460
  }
20079
20461
 
20080
20462
  // src/ir-to-client-js/emit-reactive.ts
20081
- import ts19 from "typescript";
20463
+ import ts20 from "typescript";
20082
20464
 
20083
20465
  // src/ir-to-client-js/control-flow/stringify/claim-plan.ts
20084
20466
  function slotSpecLiteral(slot) {
@@ -20190,20 +20572,20 @@ function lowerToLocaleCallsInReactiveExpr(expr, matcher) {
20190
20572
  return expr;
20191
20573
  let sourceFile;
20192
20574
  try {
20193
- sourceFile = ts19.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts19.ScriptTarget.Latest, true, ts19.ScriptKind.TS);
20575
+ sourceFile = ts20.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts20.ScriptTarget.Latest, true, ts20.ScriptKind.TS);
20194
20576
  } catch {
20195
20577
  return expr;
20196
20578
  }
20197
20579
  const stmt = sourceFile.statements[0];
20198
- if (!stmt || !ts19.isExpressionStatement(stmt))
20580
+ if (!stmt || !ts20.isExpressionStatement(stmt))
20199
20581
  return expr;
20200
- const root = ts19.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20582
+ const root = ts20.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20201
20583
  const candidates = [];
20202
20584
  const visit3 = (n) => {
20203
- if (ts19.isCallExpression(n) && n.arguments.length === 2 && ts19.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
20585
+ if (ts20.isCallExpression(n) && n.arguments.length === 2 && ts20.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
20204
20586
  candidates.push(n);
20205
20587
  }
20206
- ts19.forEachChild(n, visit3);
20588
+ ts20.forEachChild(n, visit3);
20207
20589
  };
20208
20590
  visit3(root);
20209
20591
  if (candidates.length === 0)
@@ -20239,20 +20621,20 @@ function lowerDateCallsInReactiveExpr(expr, matcher) {
20239
20621
  return expr;
20240
20622
  let sourceFile;
20241
20623
  try {
20242
- sourceFile = ts19.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts19.ScriptTarget.Latest, true, ts19.ScriptKind.TS);
20624
+ sourceFile = ts20.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts20.ScriptTarget.Latest, true, ts20.ScriptKind.TS);
20243
20625
  } catch {
20244
20626
  return expr;
20245
20627
  }
20246
20628
  const stmt = sourceFile.statements[0];
20247
- if (!stmt || !ts19.isExpressionStatement(stmt))
20629
+ if (!stmt || !ts20.isExpressionStatement(stmt))
20248
20630
  return expr;
20249
- const root = ts19.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20631
+ const root = ts20.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20250
20632
  const candidates = [];
20251
20633
  const visit3 = (n) => {
20252
- if (ts19.isCallExpression(n) && n.arguments.length === 0 && ts19.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
20634
+ if (ts20.isCallExpression(n) && n.arguments.length === 0 && ts20.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
20253
20635
  candidates.push(n);
20254
20636
  }
20255
- ts19.forEachChild(n, visit3);
20637
+ ts20.forEachChild(n, visit3);
20256
20638
  };
20257
20639
  visit3(root);
20258
20640
  if (candidates.length === 0)
@@ -20514,7 +20896,7 @@ function stringifyBranchInnerLoops(lines, plan, indent, pc) {
20514
20896
  stringifyLoopChildConditionals(lines, inner.nestedConditionals, `${indent} `, pc);
20515
20897
  }
20516
20898
  lines.push(`${indent} return __bel${uid}`);
20517
- lines.push(`${indent}}, '${inner.markerId}'${profileBindingId(pc, inner.slotId)}) }`);
20899
+ lines.push(`${indent}}, '${inner.markerId}'${mapArrayKeyArgs(profileBindingId(pc, inner.slotId), !!inner.wrappedKey, inner.keyDepth)}) }`);
20518
20900
  }
20519
20901
  }
20520
20902
  function stringifyLoopChildConditionals(lines, conditionals, indent, pc) {
@@ -21363,7 +21745,7 @@ function emitReactive(lines, inner, indent, pc) {
21363
21745
  bodyIsMultiRoot: emit.bodyIsMultiRoot
21364
21746
  });
21365
21747
  lines.push(`${indent} return __innerEl${uid}`);
21366
- lines.push(`${indent}}, '${inner.markerId}'${profileBindingId(pc, inner.slotId)}) }`);
21748
+ lines.push(`${indent}}, '${inner.markerId}'${mapArrayKeyArgs(profileBindingId(pc, inner.slotId), !!emit.wrappedKey, inner.keyDepth)}) }`);
21367
21749
  }
21368
21750
  function emitStatic(lines, inner, indent, pc) {
21369
21751
  const uid = inner.uidSuffix;
@@ -22273,20 +22655,28 @@ var PHASES = [
22273
22655
  ];
22274
22656
 
22275
22657
  // src/ir-to-client-js/rewrite-props-object.ts
22276
- import ts20 from "typescript";
22277
- function rewritePropsObjectRef(code, propsObjectName) {
22278
- const srcPropsName = propsObjectName ?? "props";
22279
- if (srcPropsName === PROPS_PARAM)
22280
- return code;
22658
+ import ts21 from "typescript";
22659
+ function rewritePropsObjectRef(code, propsObjectName, restPropsName = null) {
22660
+ let result = code;
22661
+ const seen = new Set;
22662
+ for (const srcPropsName of [propsObjectName ?? "props", restPropsName]) {
22663
+ if (srcPropsName === null || srcPropsName === PROPS_PARAM || seen.has(srcPropsName))
22664
+ continue;
22665
+ seen.add(srcPropsName);
22666
+ result = rewriteOneName(result, srcPropsName);
22667
+ }
22668
+ return result;
22669
+ }
22670
+ function rewriteOneName(code, srcPropsName) {
22281
22671
  if (!identifierPattern(srcPropsName).test(code))
22282
22672
  return code;
22283
- const sourceFile = ts20.createSourceFile("init-body.ts", code, ts20.ScriptTarget.Latest, true, ts20.ScriptKind.TS);
22673
+ const sourceFile = ts21.createSourceFile("init-body.ts", code, ts21.ScriptTarget.Latest, true, ts21.ScriptKind.TS);
22284
22674
  const spans = [];
22285
22675
  function visit3(node) {
22286
- if (ts20.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
22676
+ if (ts21.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
22287
22677
  spans.push([node.getStart(sourceFile), node.getEnd()]);
22288
22678
  }
22289
- ts20.forEachChild(node, visit3);
22679
+ ts21.forEachChild(node, visit3);
22290
22680
  }
22291
22681
  visit3(sourceFile);
22292
22682
  if (spans.length === 0)
@@ -22302,17 +22692,17 @@ function shouldRewrite(node) {
22302
22692
  const parent = node.parent;
22303
22693
  if (!parent)
22304
22694
  return true;
22305
- if (ts20.isPropertyAccessExpression(parent) && parent.name === node)
22695
+ if (ts21.isPropertyAccessExpression(parent) && parent.name === node)
22306
22696
  return false;
22307
- if (ts20.isPropertyAssignment(parent) && parent.name === node)
22697
+ if (ts21.isPropertyAssignment(parent) && parent.name === node)
22308
22698
  return false;
22309
- if (ts20.isShorthandPropertyAssignment(parent) && parent.name === node)
22699
+ if (ts21.isShorthandPropertyAssignment(parent) && parent.name === node)
22310
22700
  return false;
22311
- if (ts20.isPropertySignature(parent) && parent.name === node)
22701
+ if (ts21.isPropertySignature(parent) && parent.name === node)
22312
22702
  return false;
22313
- if (ts20.isPropertyDeclaration(parent) && parent.name === node)
22703
+ if (ts21.isPropertyDeclaration(parent) && parent.name === node)
22314
22704
  return false;
22315
- if (ts20.isBindingElement(parent) && parent.name === node)
22705
+ if (ts21.isBindingElement(parent) && parent.name === node)
22316
22706
  return false;
22317
22707
  return true;
22318
22708
  }
@@ -22346,7 +22736,7 @@ function generateInitFunction(ir, ctx, siblingComponents, localImportPrefixes) {
22346
22736
  runPhases(lines, phaseCtx, PHASES);
22347
22737
  const hydrateLine = emitRegistrationAndHydration(lines, ctx, ir, graph, inlinability);
22348
22738
  let generatedCode = rewritePropsObjectRef(lines.join(`
22349
- `), ctx.propsObjectName);
22739
+ `), ctx.propsObjectName, ctx.restPropsName);
22350
22740
  generatedCode += `
22351
22741
  ` + hydrateLine;
22352
22742
  const moduleConstantsCode = emitModuleLevelDeclarations(classification.moduleLevelConstants, classification.moduleLevelFunctions, classification.moduleLevelSignals, classification.moduleLevelMemos);
@@ -22624,7 +23014,7 @@ function createContext(ir, scope, adapterCapabilities, profile) {
22624
23014
  };
22625
23015
  }
22626
23016
  function needsClientJs(ctx) {
22627
- if (ctx.signals.length > 0 || ctx.memos.length > 0 || ctx.effects.length > 0 || ctx.onMounts.length > 0 || ctx.initStatements.length > 0 || ctx.interactiveElements.length > 0 || ctx.dynamicElements.length > 0 || ctx.conditionalElements.length > 0 || ctx.loopElements.length > 0 || ctx.refElements.length > 0 || ctx.childInits.length > 0 || ctx.reactiveAttrs.length > 0 || ctx.clientOnlyElements.length > 0 || ctx.clientOnlyConditionals.length > 0 || ctx.providerSetups.length > 0)
23017
+ if (ctx.signals.length > 0 || ctx.memos.length > 0 || ctx.effects.length > 0 || ctx.onMounts.length > 0 || ctx.initStatements.length > 0 || ctx.interactiveElements.length > 0 || ctx.dynamicElements.length > 0 || ctx.conditionalElements.length > 0 || ctx.loopElements.length > 0 || ctx.refElements.length > 0 || ctx.restAttrElements.length > 0 || ctx.childInits.length > 0 || ctx.reactiveAttrs.length > 0 || ctx.clientOnlyElements.length > 0 || ctx.clientOnlyConditionals.length > 0 || ctx.providerSetups.length > 0)
22628
23018
  return true;
22629
23019
  return hasInitScopeOnlyConstant(ctx);
22630
23020
  }
@@ -22646,11 +23036,7 @@ function generateTemplateOnlyMount(ir, ctx) {
22646
23036
  const propNamesForStaticCheck = new Set(ctx.propsParams.map((p) => p.name));
22647
23037
  const graph = buildReferencesGraph(ctx, ir.root);
22648
23038
  const { inlinableConstants, unsafeLocalNames } = buildInlinableConstants(ctx, graph, ir.root);
22649
- const restSpreadNames = new Set;
22650
- if (ctx.restPropsName)
22651
- restSpreadNames.add(ctx.restPropsName);
22652
- if (ctx.propsObjectName)
22653
- restSpreadNames.add(ctx.propsObjectName);
23039
+ const restSpreadNames = resolveRestSpreadNames(ctx);
22654
23040
  let templateHtml;
22655
23041
  if (canGenerateStaticTemplate(ir.root, propNamesForStaticCheck, inlinableConstants, unsafeLocalNames)) {
22656
23042
  const markupSlotIds = new Set(ctx.dynamicElements.map((e) => e.slotId));
@@ -22966,7 +23352,7 @@ function walkIR2(node, visitor) {
22966
23352
  }
22967
23353
 
22968
23354
  // src/preprocess-inline-jsx-callbacks.ts
22969
- import ts21 from "typescript";
23355
+ import ts22 from "typescript";
22970
23356
  var SYNTHETIC_PREFIX = "BFInlineJsxCallback";
22971
23357
  var MAX_FIXPOINT_ITERATIONS = 16;
22972
23358
  function preprocessInlineJsxCallbacks(source, filePath) {
@@ -22988,8 +23374,8 @@ function preprocessInlineJsxCallbacks(source, filePath) {
22988
23374
  return { source: current, errors, syntheticNames };
22989
23375
  }
22990
23376
  function runSinglePass(source, filePath, startingCounter) {
22991
- const sourceFile = ts21.createSourceFile(filePath, source, ts21.ScriptTarget.Latest, true, ts21.ScriptKind.TSX);
22992
- const hasUseClient = sourceFile.statements.some((stmt) => ts21.isExpressionStatement(stmt) && ts21.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
23377
+ const sourceFile = ts22.createSourceFile(filePath, source, ts22.ScriptTarget.Latest, true, ts22.ScriptKind.TSX);
23378
+ const hasUseClient = sourceFile.statements.some((stmt) => ts22.isExpressionStatement(stmt) && ts22.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
22993
23379
  if (!hasUseClient) {
22994
23380
  return { source, errors: [], syntheticNames: [], counterAfter: startingCounter };
22995
23381
  }
@@ -23011,22 +23397,22 @@ function runSinglePass(source, filePath, startingCounter) {
23011
23397
  }
23012
23398
  }
23013
23399
  function visit3(node) {
23014
- if (ts21.isJsxAttribute(node) && node.initializer && ts21.isJsxExpression(node.initializer) && node.initializer.expression) {
23400
+ if (ts22.isJsxAttribute(node) && node.initializer && ts22.isJsxExpression(node.initializer) && node.initializer.expression) {
23015
23401
  if (tryHandleArrowValue(node.initializer.expression)) {
23016
23402
  return;
23017
23403
  }
23018
23404
  }
23019
- if (ts21.isPropertyAssignment(node) && node.initializer) {
23405
+ if (ts22.isPropertyAssignment(node) && node.initializer) {
23020
23406
  if (tryHandleArrowValue(node.initializer))
23021
23407
  return;
23022
23408
  }
23023
- ts21.forEachChild(node, visit3);
23409
+ ts22.forEachChild(node, visit3);
23024
23410
  }
23025
23411
  function tryHandleArrowValue(initializer) {
23026
23412
  let expr = initializer;
23027
- while (ts21.isParenthesizedExpression(expr))
23413
+ while (ts22.isParenthesizedExpression(expr))
23028
23414
  expr = expr.expression;
23029
- if (ts21.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
23415
+ if (ts22.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
23030
23416
  return handleInlineArrow(expr);
23031
23417
  }
23032
23418
  return false;
@@ -23063,7 +23449,7 @@ function runSinglePass(source, filePath, startingCounter) {
23063
23449
  replacements.push({ start: arrowStart, end: arrowEnd, text: name });
23064
23450
  return true;
23065
23451
  }
23066
- ts21.forEachChild(sourceFile, visit3);
23452
+ ts22.forEachChild(sourceFile, visit3);
23067
23453
  if (replacements.length === 0) {
23068
23454
  return { source, errors, syntheticNames, counterAfter: counter };
23069
23455
  }
@@ -23086,11 +23472,11 @@ function errorMessageForCapture(captures) {
23086
23472
  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.`;
23087
23473
  }
23088
23474
  function arrowBodyContainsJsx(arrow) {
23089
- if (ts21.isBlock(arrow.body)) {
23475
+ if (ts22.isBlock(arrow.body)) {
23090
23476
  return blockReturnsJsx(arrow.body);
23091
23477
  }
23092
23478
  let body = arrow.body;
23093
- while (ts21.isParenthesizedExpression(body))
23479
+ while (ts22.isParenthesizedExpression(body))
23094
23480
  body = body.expression;
23095
23481
  return isJsxLike(body);
23096
23482
  }
@@ -23099,24 +23485,24 @@ function blockReturnsJsx(block) {
23099
23485
  function visit3(n) {
23100
23486
  if (found)
23101
23487
  return;
23102
- if (ts21.isReturnStatement(n) && n.expression) {
23488
+ if (ts22.isReturnStatement(n) && n.expression) {
23103
23489
  let e = n.expression;
23104
- while (ts21.isParenthesizedExpression(e))
23490
+ while (ts22.isParenthesizedExpression(e))
23105
23491
  e = e.expression;
23106
23492
  if (isJsxLike(e)) {
23107
23493
  found = true;
23108
23494
  return;
23109
23495
  }
23110
23496
  }
23111
- if (ts21.isArrowFunction(n) || ts21.isFunctionDeclaration(n) || ts21.isFunctionExpression(n))
23497
+ if (ts22.isArrowFunction(n) || ts22.isFunctionDeclaration(n) || ts22.isFunctionExpression(n))
23112
23498
  return;
23113
- ts21.forEachChild(n, visit3);
23499
+ ts22.forEachChild(n, visit3);
23114
23500
  }
23115
- ts21.forEachChild(block, visit3);
23501
+ ts22.forEachChild(block, visit3);
23116
23502
  return found;
23117
23503
  }
23118
23504
  function isJsxLike(expr) {
23119
- return ts21.isJsxElement(expr) || ts21.isJsxSelfClosingElement(expr) || ts21.isJsxFragment(expr);
23505
+ return ts22.isJsxElement(expr) || ts22.isJsxSelfClosingElement(expr) || ts22.isJsxFragment(expr);
23120
23506
  }
23121
23507
  function collectArrowParamNames(arrow) {
23122
23508
  const names = new Set;
@@ -23126,13 +23512,13 @@ function collectArrowParamNames(arrow) {
23126
23512
  }
23127
23513
  function collectBindingNames4(name, out) {
23128
23514
  const push = Array.isArray(out) ? (n) => out.push(n) : (n) => out.add(n);
23129
- if (ts21.isIdentifier(name)) {
23515
+ if (ts22.isIdentifier(name)) {
23130
23516
  push(name.text);
23131
- } else if (ts21.isObjectBindingPattern(name)) {
23517
+ } else if (ts22.isObjectBindingPattern(name)) {
23132
23518
  name.elements.forEach((el) => collectBindingNames4(el.name, out));
23133
- } else if (ts21.isArrayBindingPattern(name)) {
23519
+ } else if (ts22.isArrayBindingPattern(name)) {
23134
23520
  name.elements.forEach((el) => {
23135
- if (!ts21.isOmittedExpression(el))
23521
+ if (!ts22.isOmittedExpression(el))
23136
23522
  collectBindingNames4(el.name, out);
23137
23523
  });
23138
23524
  }
@@ -23159,48 +23545,48 @@ function collectFreeIdentifiers(arrow) {
23159
23545
  return bound.includes(name);
23160
23546
  }
23161
23547
  function visit3(node) {
23162
- if (ts21.isIdentifier(node)) {
23548
+ if (ts22.isIdentifier(node)) {
23163
23549
  const parent = node.parent;
23164
- if (parent && ts21.isPropertyAccessExpression(parent) && parent.name === node)
23550
+ if (parent && ts22.isPropertyAccessExpression(parent) && parent.name === node)
23165
23551
  return;
23166
- if (parent && ts21.isPropertyAssignment(parent) && parent.name === node)
23552
+ if (parent && ts22.isPropertyAssignment(parent) && parent.name === node)
23167
23553
  return;
23168
- if (parent && ts21.isPropertySignature(parent) && parent.name === node)
23554
+ if (parent && ts22.isPropertySignature(parent) && parent.name === node)
23169
23555
  return;
23170
- if (parent && ts21.isPropertyDeclaration(parent) && parent.name === node)
23556
+ if (parent && ts22.isPropertyDeclaration(parent) && parent.name === node)
23171
23557
  return;
23172
- if (parent && ts21.isMethodDeclaration(parent) && parent.name === node)
23558
+ if (parent && ts22.isMethodDeclaration(parent) && parent.name === node)
23173
23559
  return;
23174
- if (parent && ts21.isMethodSignature(parent) && parent.name === node)
23560
+ if (parent && ts22.isMethodSignature(parent) && parent.name === node)
23175
23561
  return;
23176
- if (parent && ts21.isGetAccessorDeclaration(parent) && parent.name === node)
23562
+ if (parent && ts22.isGetAccessorDeclaration(parent) && parent.name === node)
23177
23563
  return;
23178
- if (parent && ts21.isSetAccessorDeclaration(parent) && parent.name === node)
23564
+ if (parent && ts22.isSetAccessorDeclaration(parent) && parent.name === node)
23179
23565
  return;
23180
- if (parent && ts21.isEnumMember(parent) && parent.name === node)
23566
+ if (parent && ts22.isEnumMember(parent) && parent.name === node)
23181
23567
  return;
23182
- if (parent && ts21.isBindingElement(parent) && parent.propertyName === node)
23568
+ if (parent && ts22.isBindingElement(parent) && parent.propertyName === node)
23183
23569
  return;
23184
- if (parent && ts21.isShorthandPropertyAssignment(parent) && parent.name === node) {
23570
+ if (parent && ts22.isShorthandPropertyAssignment(parent) && parent.name === node) {
23185
23571
  if (!isBound(node.text))
23186
23572
  ids.add(node.text);
23187
23573
  return;
23188
23574
  }
23189
- if (parent && ts21.isParameter(parent) && parent.name === node)
23575
+ if (parent && ts22.isParameter(parent) && parent.name === node)
23190
23576
  return;
23191
- if (parent && ts21.isVariableDeclaration(parent) && parent.name === node)
23577
+ if (parent && ts22.isVariableDeclaration(parent) && parent.name === node)
23192
23578
  return;
23193
- if (parent && ts21.isFunctionDeclaration(parent) && parent.name === node)
23579
+ if (parent && ts22.isFunctionDeclaration(parent) && parent.name === node)
23194
23580
  return;
23195
- if (parent && ts21.isClassDeclaration(parent) && parent.name === node)
23581
+ if (parent && ts22.isClassDeclaration(parent) && parent.name === node)
23196
23582
  return;
23197
- if (parent && ts21.isJsxAttribute(parent) && parent.name === node)
23583
+ if (parent && ts22.isJsxAttribute(parent) && parent.name === node)
23198
23584
  return;
23199
- if (parent && ts21.isJsxOpeningElement(parent) && parent.tagName === node) {
23585
+ if (parent && ts22.isJsxOpeningElement(parent) && parent.tagName === node) {
23200
23586
  if (/^[a-z]/.test(node.text))
23201
23587
  return;
23202
23588
  }
23203
- if (parent && ts21.isJsxClosingElement(parent) && parent.tagName === node) {
23589
+ if (parent && ts22.isJsxClosingElement(parent) && parent.tagName === node) {
23204
23590
  if (/^[a-z]/.test(node.text))
23205
23591
  return;
23206
23592
  }
@@ -23209,43 +23595,43 @@ function collectFreeIdentifiers(arrow) {
23209
23595
  ids.add(node.text);
23210
23596
  return;
23211
23597
  }
23212
- if (ts21.isVariableDeclaration(node)) {
23598
+ if (ts22.isVariableDeclaration(node)) {
23213
23599
  const declared = pushBindings(node.name);
23214
23600
  if (node.initializer)
23215
23601
  visit3(node.initializer);
23216
23602
  return;
23217
23603
  }
23218
- if (ts21.isFunctionDeclaration(node)) {
23604
+ if (ts22.isFunctionDeclaration(node)) {
23219
23605
  if (node.name)
23220
23606
  bound.push(node.name.text);
23221
23607
  visitInsideNewScope(node);
23222
23608
  return;
23223
23609
  }
23224
- if (ts21.isClassDeclaration(node)) {
23610
+ if (ts22.isClassDeclaration(node)) {
23225
23611
  if (node.name)
23226
23612
  bound.push(node.name.text);
23227
- ts21.forEachChild(node, visit3);
23613
+ ts22.forEachChild(node, visit3);
23228
23614
  return;
23229
23615
  }
23230
- if (ts21.isArrowFunction(node) || ts21.isFunctionExpression(node)) {
23616
+ if (ts22.isArrowFunction(node) || ts22.isFunctionExpression(node)) {
23231
23617
  visitInsideNewScope(node);
23232
23618
  return;
23233
23619
  }
23234
- if (ts21.isCatchClause(node)) {
23620
+ if (ts22.isCatchClause(node)) {
23235
23621
  const before = bound.length;
23236
23622
  if (node.variableDeclaration)
23237
23623
  pushBindings(node.variableDeclaration.name);
23238
- ts21.forEachChild(node, visit3);
23624
+ ts22.forEachChild(node, visit3);
23239
23625
  popN(bound.length - before);
23240
23626
  return;
23241
23627
  }
23242
- if (ts21.isBlock(node)) {
23628
+ if (ts22.isBlock(node)) {
23243
23629
  const before = bound.length;
23244
- ts21.forEachChild(node, visit3);
23630
+ ts22.forEachChild(node, visit3);
23245
23631
  popN(bound.length - before);
23246
23632
  return;
23247
23633
  }
23248
- ts21.forEachChild(node, visit3);
23634
+ ts22.forEachChild(node, visit3);
23249
23635
  }
23250
23636
  function visitInsideNewScope(fn) {
23251
23637
  const before = bound.length;
@@ -23268,29 +23654,29 @@ function collectFreeIdentifiers(arrow) {
23268
23654
  function collectModuleScopeNames(sourceFile) {
23269
23655
  const names = new Set;
23270
23656
  for (const stmt of sourceFile.statements) {
23271
- if (ts21.isFunctionDeclaration(stmt) && stmt.name)
23657
+ if (ts22.isFunctionDeclaration(stmt) && stmt.name)
23272
23658
  names.add(stmt.name.text);
23273
- else if (ts21.isClassDeclaration(stmt) && stmt.name)
23659
+ else if (ts22.isClassDeclaration(stmt) && stmt.name)
23274
23660
  names.add(stmt.name.text);
23275
- else if (ts21.isVariableStatement(stmt)) {
23661
+ else if (ts22.isVariableStatement(stmt)) {
23276
23662
  for (const decl of stmt.declarationList.declarations)
23277
23663
  collectBindingNames4(decl.name, names);
23278
- } else if (ts21.isImportDeclaration(stmt) && stmt.importClause) {
23664
+ } else if (ts22.isImportDeclaration(stmt) && stmt.importClause) {
23279
23665
  const ic = stmt.importClause;
23280
23666
  if (ic.name)
23281
23667
  names.add(ic.name.text);
23282
23668
  if (ic.namedBindings) {
23283
- if (ts21.isNamespaceImport(ic.namedBindings))
23669
+ if (ts22.isNamespaceImport(ic.namedBindings))
23284
23670
  names.add(ic.namedBindings.name.text);
23285
23671
  else
23286
23672
  for (const e of ic.namedBindings.elements)
23287
23673
  names.add(e.name.text);
23288
23674
  }
23289
- } else if (ts21.isTypeAliasDeclaration(stmt))
23675
+ } else if (ts22.isTypeAliasDeclaration(stmt))
23290
23676
  names.add(stmt.name.text);
23291
- else if (ts21.isInterfaceDeclaration(stmt))
23677
+ else if (ts22.isInterfaceDeclaration(stmt))
23292
23678
  names.add(stmt.name.text);
23293
- else if (ts21.isEnumDeclaration(stmt))
23679
+ else if (ts22.isEnumDeclaration(stmt))
23294
23680
  names.add(stmt.name.text);
23295
23681
  }
23296
23682
  return names;
@@ -23298,7 +23684,7 @@ function collectModuleScopeNames(sourceFile) {
23298
23684
  function buildSyntheticDeclaration(name, arrow, sourceFile) {
23299
23685
  const paramsText = arrow.parameters.length === 0 ? "" : arrow.parameters.map((p) => p.getText(sourceFile)).join(", ");
23300
23686
  let bodyText;
23301
- if (ts21.isBlock(arrow.body)) {
23687
+ if (ts22.isBlock(arrow.body)) {
23302
23688
  bodyText = arrow.body.getText(sourceFile);
23303
23689
  } else {
23304
23690
  const expr = arrow.body.getText(sourceFile);
@@ -23308,7 +23694,7 @@ function buildSyntheticDeclaration(name, arrow, sourceFile) {
23308
23694
  }
23309
23695
 
23310
23696
  // src/ssr-defaults.ts
23311
- import ts22 from "typescript";
23697
+ import ts23 from "typescript";
23312
23698
  function deriveStashFromDefaults(defaults, props) {
23313
23699
  const extra = {};
23314
23700
  for (const [name, d] of Object.entries(defaults)) {
@@ -23431,11 +23817,11 @@ function collectPropRefs(expr, propsObjectName, out) {
23431
23817
  if (!node)
23432
23818
  return;
23433
23819
  const visit3 = (n) => {
23434
- if (ts22.isPropertyAccessExpression(n) && ts22.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts22.isIdentifier(n.name)) {
23820
+ if (ts23.isPropertyAccessExpression(n) && ts23.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts23.isIdentifier(n.name)) {
23435
23821
  out.add(n.name.text);
23436
23822
  return;
23437
23823
  }
23438
- ts22.forEachChild(n, visit3);
23824
+ ts23.forEachChild(n, visit3);
23439
23825
  };
23440
23826
  visit3(node);
23441
23827
  }
@@ -23473,23 +23859,23 @@ function tryStaticEval(expr, ctx) {
23473
23859
  }
23474
23860
  function evalStatementsForReturn(statements, ctx) {
23475
23861
  for (const stmt of statements) {
23476
- if (ts22.isVariableStatement(stmt)) {
23862
+ if (ts23.isVariableStatement(stmt)) {
23477
23863
  for (const d of stmt.declarationList.declarations) {
23478
- if (!ts22.isIdentifier(d.name) || !d.initializer)
23864
+ if (!ts23.isIdentifier(d.name) || !d.initializer)
23479
23865
  continue;
23480
23866
  const v = evalNode(d.initializer, ctx);
23481
23867
  if (v !== UNRESOLVED)
23482
23868
  ctx.bindings[d.name.text] = v;
23483
23869
  }
23484
- } else if (ts22.isReturnStatement(stmt)) {
23870
+ } else if (ts23.isReturnStatement(stmt)) {
23485
23871
  return stmt.expression ? evalNode(stmt.expression, ctx) : UNRESOLVED;
23486
- } else if (ts22.isIfStatement(stmt)) {
23872
+ } else if (ts23.isIfStatement(stmt)) {
23487
23873
  const cond = evalNode(stmt.expression, ctx);
23488
23874
  if (cond === UNRESOLVED)
23489
23875
  return UNRESOLVED;
23490
23876
  const branch = cond ? stmt.thenStatement : stmt.elseStatement;
23491
23877
  if (branch) {
23492
- const taken = evalStatementsForReturn(ts22.isBlock(branch) ? branch.statements : [branch], ctx);
23878
+ const taken = evalStatementsForReturn(ts23.isBlock(branch) ? branch.statements : [branch], ctx);
23493
23879
  if (taken !== NO_RETURN)
23494
23880
  return taken;
23495
23881
  }
@@ -23500,45 +23886,45 @@ function evalStatementsForReturn(statements, ctx) {
23500
23886
  return NO_RETURN;
23501
23887
  }
23502
23888
  function parseExpression2(expr) {
23503
- const sf = ts22.createSourceFile("__ssr_default__.ts", `(${expr})`, ts22.ScriptTarget.Latest, true, ts22.ScriptKind.TS);
23889
+ const sf = ts23.createSourceFile("__ssr_default__.ts", `(${expr})`, ts23.ScriptTarget.Latest, true, ts23.ScriptKind.TS);
23504
23890
  const stmt = sf.statements[0];
23505
- if (!stmt || !ts22.isExpressionStatement(stmt))
23891
+ if (!stmt || !ts23.isExpressionStatement(stmt))
23506
23892
  return null;
23507
- const inner = ts22.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
23893
+ const inner = ts23.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
23508
23894
  return inner;
23509
23895
  }
23510
23896
  function evalNode(node, ctx) {
23511
- if (ts22.isParenthesizedExpression(node))
23897
+ if (ts23.isParenthesizedExpression(node))
23512
23898
  return evalNode(node.expression, ctx);
23513
- if (ts22.isAsExpression(node))
23899
+ if (ts23.isAsExpression(node))
23514
23900
  return evalNode(node.expression, ctx);
23515
- if (ts22.isSatisfiesExpression(node))
23901
+ if (ts23.isSatisfiesExpression(node))
23516
23902
  return evalNode(node.expression, ctx);
23517
- if (ts22.isTypeAssertionExpression(node))
23903
+ if (ts23.isTypeAssertionExpression(node))
23518
23904
  return evalNode(node.expression, ctx);
23519
- if (ts22.isNonNullExpression(node))
23905
+ if (ts23.isNonNullExpression(node))
23520
23906
  return evalNode(node.expression, ctx);
23521
- if (ts22.isArrowFunction(node)) {
23907
+ if (ts23.isArrowFunction(node)) {
23522
23908
  if (node.parameters.length !== 0)
23523
23909
  return UNRESOLVED;
23524
- if (!ts22.isBlock(node.body))
23910
+ if (!ts23.isBlock(node.body))
23525
23911
  return evalNode(node.body, ctx);
23526
23912
  const localBindings = { ...ctx.bindings };
23527
23913
  const localCtx = { ...ctx, bindings: localBindings };
23528
23914
  const result = evalStatementsForReturn(node.body.statements, localCtx);
23529
23915
  return result === NO_RETURN ? UNRESOLVED : result;
23530
23916
  }
23531
- if (ts22.isNumericLiteral(node))
23917
+ if (ts23.isNumericLiteral(node))
23532
23918
  return Number(node.text);
23533
- if (ts22.isStringLiteralLike(node))
23919
+ if (ts23.isStringLiteralLike(node))
23534
23920
  return node.text;
23535
- if (node.kind === ts22.SyntaxKind.TrueKeyword)
23921
+ if (node.kind === ts23.SyntaxKind.TrueKeyword)
23536
23922
  return true;
23537
- if (node.kind === ts22.SyntaxKind.FalseKeyword)
23923
+ if (node.kind === ts23.SyntaxKind.FalseKeyword)
23538
23924
  return false;
23539
- if (node.kind === ts22.SyntaxKind.NullKeyword)
23925
+ if (node.kind === ts23.SyntaxKind.NullKeyword)
23540
23926
  return null;
23541
- if (ts22.isIdentifier(node)) {
23927
+ if (ts23.isIdentifier(node)) {
23542
23928
  if (node.text === "undefined")
23543
23929
  return;
23544
23930
  if (node.text in ctx.bindings)
@@ -23547,29 +23933,29 @@ function evalNode(node, ctx) {
23547
23933
  return;
23548
23934
  return UNRESOLVED;
23549
23935
  }
23550
- if (ts22.isPrefixUnaryExpression(node)) {
23936
+ if (ts23.isPrefixUnaryExpression(node)) {
23551
23937
  const arg = evalNode(node.operand, ctx);
23552
23938
  if (arg === UNRESOLVED)
23553
23939
  return UNRESOLVED;
23554
23940
  switch (node.operator) {
23555
- case ts22.SyntaxKind.MinusToken:
23941
+ case ts23.SyntaxKind.MinusToken:
23556
23942
  return typeof arg === "number" ? -arg : UNRESOLVED;
23557
- case ts22.SyntaxKind.PlusToken:
23943
+ case ts23.SyntaxKind.PlusToken:
23558
23944
  return typeof arg === "number" ? +arg : UNRESOLVED;
23559
- case ts22.SyntaxKind.ExclamationToken:
23945
+ case ts23.SyntaxKind.ExclamationToken:
23560
23946
  return !arg;
23561
23947
  }
23562
23948
  return UNRESOLVED;
23563
23949
  }
23564
- if (ts22.isObjectLiteralExpression(node)) {
23950
+ if (ts23.isObjectLiteralExpression(node)) {
23565
23951
  const obj = {};
23566
23952
  for (const prop of node.properties) {
23567
- if (!ts22.isPropertyAssignment(prop))
23953
+ if (!ts23.isPropertyAssignment(prop))
23568
23954
  return UNRESOLVED;
23569
23955
  let key;
23570
- if (ts22.isIdentifier(prop.name) || ts22.isStringLiteralLike(prop.name)) {
23956
+ if (ts23.isIdentifier(prop.name) || ts23.isStringLiteralLike(prop.name)) {
23571
23957
  key = prop.name.text;
23572
- } else if (ts22.isNumericLiteral(prop.name)) {
23958
+ } else if (ts23.isNumericLiteral(prop.name)) {
23573
23959
  key = prop.name.text;
23574
23960
  } else {
23575
23961
  return UNRESOLVED;
@@ -23581,10 +23967,10 @@ function evalNode(node, ctx) {
23581
23967
  }
23582
23968
  return obj;
23583
23969
  }
23584
- if (ts22.isArrayLiteralExpression(node)) {
23970
+ if (ts23.isArrayLiteralExpression(node)) {
23585
23971
  const arr = [];
23586
23972
  for (const elem of node.elements) {
23587
- if (ts22.isOmittedExpression(elem))
23973
+ if (ts23.isOmittedExpression(elem))
23588
23974
  return UNRESOLVED;
23589
23975
  const v = evalNode(elem, ctx);
23590
23976
  if (v === UNRESOLVED)
@@ -23593,7 +23979,7 @@ function evalNode(node, ctx) {
23593
23979
  }
23594
23980
  return arr;
23595
23981
  }
23596
- if (ts22.isElementAccessExpression(node)) {
23982
+ if (ts23.isElementAccessExpression(node)) {
23597
23983
  const base = evalNode(node.expression, ctx);
23598
23984
  if (base === undefined)
23599
23985
  return;
@@ -23607,7 +23993,7 @@ function evalNode(node, ctx) {
23607
23993
  const k = String(key);
23608
23994
  return Object.prototype.hasOwnProperty.call(base, k) ? base[k] : undefined;
23609
23995
  }
23610
- if (ts22.isPropertyAccessExpression(node)) {
23996
+ if (ts23.isPropertyAccessExpression(node)) {
23611
23997
  const baseResult = evalNode(node.expression, ctx);
23612
23998
  if (baseResult === undefined)
23613
23999
  return;
@@ -23620,13 +24006,13 @@ function evalNode(node, ctx) {
23620
24006
  const key = node.name.text;
23621
24007
  return Object.prototype.hasOwnProperty.call(baseResult, key) ? baseResult[key] : undefined;
23622
24008
  }
23623
- if (ts22.isCallExpression(node)) {
23624
- if (node.arguments.length === 0 && ts22.isIdentifier(node.expression) && node.expression.text in ctx.bindings) {
24009
+ if (ts23.isCallExpression(node)) {
24010
+ if (node.arguments.length === 0 && ts23.isIdentifier(node.expression) && node.expression.text in ctx.bindings) {
23625
24011
  return ctx.bindings[node.expression.text];
23626
24012
  }
23627
- if (ts22.isPropertyAccessExpression(node.expression) && node.expression.name.text === "map" && node.arguments.length === 1) {
24013
+ if (ts23.isPropertyAccessExpression(node.expression) && node.expression.name.text === "map" && node.arguments.length === 1) {
23628
24014
  const arrow = node.arguments[0];
23629
- if (ts22.isArrowFunction(arrow) && arrow.parameters.length === 1 && ts22.isIdentifier(arrow.parameters[0].name) && !ts22.isBlock(arrow.body)) {
24015
+ if (ts23.isArrowFunction(arrow) && arrow.parameters.length === 1 && ts23.isIdentifier(arrow.parameters[0].name) && !ts23.isBlock(arrow.body)) {
23630
24016
  const recv = evalNode(node.expression.expression, ctx);
23631
24017
  if (Array.isArray(recv)) {
23632
24018
  const paramName = arrow.parameters[0].name.text;
@@ -23643,7 +24029,7 @@ function evalNode(node, ctx) {
23643
24029
  }
23644
24030
  return UNRESOLVED;
23645
24031
  }
23646
- if (ts22.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
24032
+ if (ts23.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
23647
24033
  const recv = evalNode(node.expression.expression, ctx);
23648
24034
  if (Array.isArray(recv)) {
23649
24035
  let sep2 = ",";
@@ -23659,27 +24045,27 @@ function evalNode(node, ctx) {
23659
24045
  }
23660
24046
  return UNRESOLVED;
23661
24047
  }
23662
- if (ts22.isConditionalExpression(node)) {
24048
+ if (ts23.isConditionalExpression(node)) {
23663
24049
  const cond = evalNode(node.condition, ctx);
23664
24050
  if (cond === UNRESOLVED)
23665
24051
  return UNRESOLVED;
23666
24052
  return cond ? evalNode(node.whenTrue, ctx) : evalNode(node.whenFalse, ctx);
23667
24053
  }
23668
- if (ts22.isBinaryExpression(node)) {
24054
+ if (ts23.isBinaryExpression(node)) {
23669
24055
  const op = node.operatorToken.kind;
23670
- if (op === ts22.SyntaxKind.QuestionQuestionToken) {
24056
+ if (op === ts23.SyntaxKind.QuestionQuestionToken) {
23671
24057
  const l2 = evalNode(node.left, ctx);
23672
24058
  if (l2 !== UNRESOLVED && l2 !== null && l2 !== undefined)
23673
24059
  return l2;
23674
24060
  return evalNode(node.right, ctx);
23675
24061
  }
23676
- if (op === ts22.SyntaxKind.BarBarToken) {
24062
+ if (op === ts23.SyntaxKind.BarBarToken) {
23677
24063
  const l2 = evalNode(node.left, ctx);
23678
24064
  if (l2 !== UNRESOLVED && l2)
23679
24065
  return l2;
23680
24066
  return evalNode(node.right, ctx);
23681
24067
  }
23682
- if (op === ts22.SyntaxKind.AmpersandAmpersandToken) {
24068
+ if (op === ts23.SyntaxKind.AmpersandAmpersandToken) {
23683
24069
  const l2 = evalNode(node.left, ctx);
23684
24070
  if (l2 === UNRESOLVED)
23685
24071
  return UNRESOLVED;
@@ -23692,30 +24078,30 @@ function evalNode(node, ctx) {
23692
24078
  if (l === UNRESOLVED || r === UNRESOLVED)
23693
24079
  return UNRESOLVED;
23694
24080
  switch (op) {
23695
- case ts22.SyntaxKind.PlusToken:
24081
+ case ts23.SyntaxKind.PlusToken:
23696
24082
  if (typeof l === "string" || typeof r === "string")
23697
24083
  return `${l}${r}`;
23698
24084
  if (typeof l === "number" && typeof r === "number")
23699
24085
  return l + r;
23700
24086
  return UNRESOLVED;
23701
- case ts22.SyntaxKind.MinusToken:
24087
+ case ts23.SyntaxKind.MinusToken:
23702
24088
  return typeof l === "number" && typeof r === "number" ? l - r : UNRESOLVED;
23703
- case ts22.SyntaxKind.AsteriskToken:
24089
+ case ts23.SyntaxKind.AsteriskToken:
23704
24090
  return typeof l === "number" && typeof r === "number" ? l * r : UNRESOLVED;
23705
- case ts22.SyntaxKind.SlashToken:
24091
+ case ts23.SyntaxKind.SlashToken:
23706
24092
  return typeof l === "number" && typeof r === "number" && r !== 0 ? l / r : UNRESOLVED;
23707
- case ts22.SyntaxKind.PercentToken:
24093
+ case ts23.SyntaxKind.PercentToken:
23708
24094
  return typeof l === "number" && typeof r === "number" && r !== 0 ? l % r : UNRESOLVED;
23709
- case ts22.SyntaxKind.EqualsEqualsEqualsToken:
23710
- case ts22.SyntaxKind.EqualsEqualsToken:
24095
+ case ts23.SyntaxKind.EqualsEqualsEqualsToken:
24096
+ case ts23.SyntaxKind.EqualsEqualsToken:
23711
24097
  return l === r;
23712
- case ts22.SyntaxKind.ExclamationEqualsEqualsToken:
23713
- case ts22.SyntaxKind.ExclamationEqualsToken:
24098
+ case ts23.SyntaxKind.ExclamationEqualsEqualsToken:
24099
+ case ts23.SyntaxKind.ExclamationEqualsToken:
23714
24100
  return l !== r;
23715
24101
  }
23716
24102
  return UNRESOLVED;
23717
24103
  }
23718
- if (ts22.isTemplateExpression(node)) {
24104
+ if (ts23.isTemplateExpression(node)) {
23719
24105
  if (node.templateSpans.length === 0)
23720
24106
  return node.head.text;
23721
24107
  let acc = node.head.text;
@@ -23727,13 +24113,13 @@ function evalNode(node, ctx) {
23727
24113
  }
23728
24114
  return acc;
23729
24115
  }
23730
- if (ts22.isNoSubstitutionTemplateLiteral(node))
24116
+ if (ts23.isNoSubstitutionTemplateLiteral(node))
23731
24117
  return node.text;
23732
24118
  return UNRESOLVED;
23733
24119
  }
23734
24120
 
23735
24121
  // src/augment-inherited-props.ts
23736
- import ts23 from "typescript";
24122
+ import ts24 from "typescript";
23737
24123
  function collectContextConsumers(metadata) {
23738
24124
  const constants = metadata.localConstants ?? [];
23739
24125
  const contextDefaults = new Map;
@@ -23765,47 +24151,47 @@ function collectContextConsumers(metadata) {
23765
24151
  }
23766
24152
  function parseUseContextArg(source) {
23767
24153
  const expr = parseSingleExpression(source);
23768
- if (!expr || !ts23.isCallExpression(expr))
24154
+ if (!expr || !ts24.isCallExpression(expr))
23769
24155
  return null;
23770
- if (!ts23.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
24156
+ if (!ts24.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
23771
24157
  return null;
23772
24158
  if (expr.arguments.length !== 1)
23773
24159
  return null;
23774
24160
  const arg = expr.arguments[0];
23775
- return ts23.isIdentifier(arg) ? arg.text : null;
24161
+ return ts24.isIdentifier(arg) ? arg.text : null;
23776
24162
  }
23777
24163
  function parseCreateContextDefault(source) {
23778
24164
  const expr = parseSingleExpression(source);
23779
- if (!expr || !ts23.isCallExpression(expr))
24165
+ if (!expr || !ts24.isCallExpression(expr))
23780
24166
  return null;
23781
24167
  if (expr.arguments.length === 0)
23782
24168
  return null;
23783
24169
  const arg = expr.arguments[0];
23784
- if (ts23.isStringLiteral(arg) || ts23.isNoSubstitutionTemplateLiteral(arg))
24170
+ if (ts24.isStringLiteral(arg) || ts24.isNoSubstitutionTemplateLiteral(arg))
23785
24171
  return arg.text;
23786
- if (ts23.isNumericLiteral(arg))
24172
+ if (ts24.isNumericLiteral(arg))
23787
24173
  return Number(arg.text);
23788
- if (arg.kind === ts23.SyntaxKind.TrueKeyword)
24174
+ if (arg.kind === ts24.SyntaxKind.TrueKeyword)
23789
24175
  return true;
23790
- if (arg.kind === ts23.SyntaxKind.FalseKeyword)
24176
+ if (arg.kind === ts24.SyntaxKind.FalseKeyword)
23791
24177
  return false;
23792
24178
  return null;
23793
24179
  }
23794
24180
  function isObjectLiteralCreateContextDefault(source) {
23795
24181
  const expr = parseSingleExpression(source);
23796
- if (!expr || !ts23.isCallExpression(expr))
24182
+ if (!expr || !ts24.isCallExpression(expr))
23797
24183
  return false;
23798
24184
  if (expr.arguments.length === 0)
23799
24185
  return false;
23800
- return ts23.isObjectLiteralExpression(expr.arguments[0]);
24186
+ return ts24.isObjectLiteralExpression(expr.arguments[0]);
23801
24187
  }
23802
24188
  function parseSingleExpression(source) {
23803
- const sf = ts23.createSourceFile("__ctx.ts", `(${source})`, ts23.ScriptTarget.Latest, false);
24189
+ const sf = ts24.createSourceFile("__ctx.ts", `(${source})`, ts24.ScriptTarget.Latest, false);
23804
24190
  const stmt = sf.statements[0];
23805
- if (!stmt || !ts23.isExpressionStatement(stmt))
24191
+ if (!stmt || !ts24.isExpressionStatement(stmt))
23806
24192
  return null;
23807
24193
  let e = stmt.expression;
23808
- while (ts23.isParenthesizedExpression(e))
24194
+ while (ts24.isParenthesizedExpression(e))
23809
24195
  e = e.expression;
23810
24196
  return e;
23811
24197
  }
@@ -23830,25 +24216,25 @@ function augmentInheritedPropAccesses(ir) {
23830
24216
  const pinCoalesceLiterals = (s) => {
23831
24217
  if (!s || !s.includes(propsObj))
23832
24218
  return;
23833
- const sf = ts23.createSourceFile("__aug.ts", `(${s})`, ts23.ScriptTarget.Latest, false);
24219
+ const sf = ts24.createSourceFile("__aug.ts", `(${s})`, ts24.ScriptTarget.Latest, false);
23834
24220
  const visit3 = (n) => {
23835
- if (ts23.isBinaryExpression(n) && (n.operatorToken.kind === ts23.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts23.SyntaxKind.BarBarToken)) {
24221
+ if (ts24.isBinaryExpression(n) && (n.operatorToken.kind === ts24.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts24.SyntaxKind.BarBarToken)) {
23836
24222
  let left = n.left;
23837
- while (ts23.isParenthesizedExpression(left))
24223
+ while (ts24.isParenthesizedExpression(left))
23838
24224
  left = left.expression;
23839
- if (ts23.isPropertyAccessExpression(left) && ts23.isIdentifier(left.expression) && left.expression.text === propsObj) {
24225
+ if (ts24.isPropertyAccessExpression(left) && ts24.isIdentifier(left.expression) && left.expression.text === propsObj) {
23840
24226
  const name = left.name.text;
23841
24227
  let right = n.right;
23842
- while (ts23.isParenthesizedExpression(right))
24228
+ while (ts24.isParenthesizedExpression(right))
23843
24229
  right = right.expression;
23844
- if (ts23.isPrefixUnaryExpression(right))
24230
+ if (ts24.isPrefixUnaryExpression(right))
23845
24231
  right = right.operand;
23846
- const kind = ts23.isNumericLiteral(right) ? "number" : right.kind === ts23.SyntaxKind.TrueKeyword || right.kind === ts23.SyntaxKind.FalseKeyword ? "boolean" : ts23.isStringLiteralLike(right) ? "string" : null;
24232
+ const kind = ts24.isNumericLiteral(right) ? "number" : right.kind === ts24.SyntaxKind.TrueKeyword || right.kind === ts24.SyntaxKind.FalseKeyword ? "boolean" : ts24.isStringLiteralLike(right) ? "string" : null;
23847
24233
  if (kind && !coalesceLiteralTypes.has(name))
23848
24234
  coalesceLiteralTypes.set(name, kind);
23849
24235
  }
23850
24236
  }
23851
- ts23.forEachChild(n, visit3);
24237
+ ts24.forEachChild(n, visit3);
23852
24238
  };
23853
24239
  visit3(sf);
23854
24240
  };
@@ -23959,33 +24345,33 @@ function augmentInheritedPropAccesses(ir) {
23959
24345
  }
23960
24346
  }
23961
24347
  function parseStaticStringConst(source) {
23962
- const sf = ts23.createSourceFile("__const.ts", `const __x = (${source});`, ts23.ScriptTarget.Latest, false);
24348
+ const sf = ts24.createSourceFile("__const.ts", `const __x = (${source});`, ts24.ScriptTarget.Latest, false);
23963
24349
  const stmt = sf.statements[0];
23964
- if (!stmt || !ts23.isVariableStatement(stmt))
24350
+ if (!stmt || !ts24.isVariableStatement(stmt))
23965
24351
  return null;
23966
24352
  let init = stmt.declarationList.declarations[0]?.initializer;
23967
- while (init && ts23.isParenthesizedExpression(init))
24353
+ while (init && ts24.isParenthesizedExpression(init))
23968
24354
  init = init.expression;
23969
24355
  if (!init)
23970
24356
  return null;
23971
- if (ts23.isStringLiteral(init) || ts23.isNoSubstitutionTemplateLiteral(init)) {
24357
+ if (ts24.isStringLiteral(init) || ts24.isNoSubstitutionTemplateLiteral(init)) {
23972
24358
  return init.text;
23973
24359
  }
23974
24360
  return evalStringArrayJoin(source);
23975
24361
  }
23976
24362
  function evalTemplateOfStringConsts(source, resolved) {
23977
- const sf = ts23.createSourceFile("__const.ts", `const __x = (${source});`, ts23.ScriptTarget.Latest, false);
24363
+ const sf = ts24.createSourceFile("__const.ts", `const __x = (${source});`, ts24.ScriptTarget.Latest, false);
23978
24364
  const stmt = sf.statements[0];
23979
- if (!stmt || !ts23.isVariableStatement(stmt))
24365
+ if (!stmt || !ts24.isVariableStatement(stmt))
23980
24366
  return null;
23981
24367
  let init = stmt.declarationList.declarations[0]?.initializer;
23982
- while (init && ts23.isParenthesizedExpression(init))
24368
+ while (init && ts24.isParenthesizedExpression(init))
23983
24369
  init = init.expression;
23984
- if (!init || !ts23.isTemplateExpression(init))
24370
+ if (!init || !ts24.isTemplateExpression(init))
23985
24371
  return null;
23986
24372
  let out = init.head.text;
23987
24373
  for (const span of init.templateSpans) {
23988
- if (!ts23.isIdentifier(span.expression))
24374
+ if (!ts24.isIdentifier(span.expression))
23989
24375
  return null;
23990
24376
  const value = resolved.get(span.expression.text);
23991
24377
  if (value === undefined)
@@ -24018,30 +24404,30 @@ function lookupStaticRecordLiteral(objectName, key, constants, isShadowed) {
24018
24404
  const constInfo = (constants ?? []).find((c) => c.name === objectName && c.isModule);
24019
24405
  if (constInfo?.value === undefined)
24020
24406
  return null;
24021
- const sf = ts23.createSourceFile("__rec.ts", `(${constInfo.value})`, ts23.ScriptTarget.Latest, true);
24407
+ const sf = ts24.createSourceFile("__rec.ts", `(${constInfo.value})`, ts24.ScriptTarget.Latest, true);
24022
24408
  if (sf.statements.length !== 1)
24023
24409
  return null;
24024
24410
  const stmt = sf.statements[0];
24025
- if (!ts23.isExpressionStatement(stmt))
24411
+ if (!ts24.isExpressionStatement(stmt))
24026
24412
  return null;
24027
24413
  let parsed = stmt.expression;
24028
- while (ts23.isParenthesizedExpression(parsed))
24414
+ while (ts24.isParenthesizedExpression(parsed))
24029
24415
  parsed = parsed.expression;
24030
- if (!ts23.isObjectLiteralExpression(parsed))
24416
+ if (!ts24.isObjectLiteralExpression(parsed))
24031
24417
  return null;
24032
24418
  for (const prop of parsed.properties) {
24033
- if (!ts23.isPropertyAssignment(prop))
24419
+ if (!ts24.isPropertyAssignment(prop))
24034
24420
  continue;
24035
24421
  const name = prop.name;
24036
- const propKey = ts23.isIdentifier(name) || ts23.isStringLiteral(name) || ts23.isNoSubstitutionTemplateLiteral(name) ? name.text : null;
24422
+ const propKey = ts24.isIdentifier(name) || ts24.isStringLiteral(name) || ts24.isNoSubstitutionTemplateLiteral(name) ? name.text : null;
24037
24423
  if (propKey !== key)
24038
24424
  continue;
24039
24425
  let v = prop.initializer;
24040
- while (ts23.isParenthesizedExpression(v))
24426
+ while (ts24.isParenthesizedExpression(v))
24041
24427
  v = v.expression;
24042
- if (ts23.isNumericLiteral(v))
24428
+ if (ts24.isNumericLiteral(v))
24043
24429
  return { kind: "number", text: v.text };
24044
- if (ts23.isStringLiteral(v) || ts23.isNoSubstitutionTemplateLiteral(v)) {
24430
+ if (ts24.isStringLiteral(v) || ts24.isNoSubstitutionTemplateLiteral(v)) {
24045
24431
  return { kind: "string", text: v.text };
24046
24432
  }
24047
24433
  return null;
@@ -24049,28 +24435,28 @@ function lookupStaticRecordLiteral(objectName, key, constants, isShadowed) {
24049
24435
  return null;
24050
24436
  }
24051
24437
  function evalStringArrayJoin(source) {
24052
- const sf = ts23.createSourceFile("__join.ts", `const __x = (${source});`, ts23.ScriptTarget.Latest, false);
24438
+ const sf = ts24.createSourceFile("__join.ts", `const __x = (${source});`, ts24.ScriptTarget.Latest, false);
24053
24439
  const stmt = sf.statements[0];
24054
- if (!stmt || !ts23.isVariableStatement(stmt))
24440
+ if (!stmt || !ts24.isVariableStatement(stmt))
24055
24441
  return null;
24056
24442
  let node = stmt.declarationList.declarations[0]?.initializer;
24057
- while (node && ts23.isParenthesizedExpression(node))
24443
+ while (node && ts24.isParenthesizedExpression(node))
24058
24444
  node = node.expression;
24059
- if (!node || !ts23.isCallExpression(node))
24445
+ if (!node || !ts24.isCallExpression(node))
24060
24446
  return null;
24061
24447
  const callee = node.expression;
24062
- if (!ts23.isPropertyAccessExpression(callee))
24448
+ if (!ts24.isPropertyAccessExpression(callee))
24063
24449
  return null;
24064
24450
  if (callee.name.text !== "join")
24065
24451
  return null;
24066
24452
  let recv = callee.expression;
24067
- while (ts23.isParenthesizedExpression(recv))
24453
+ while (ts24.isParenthesizedExpression(recv))
24068
24454
  recv = recv.expression;
24069
- if (!ts23.isArrayLiteralExpression(recv))
24455
+ if (!ts24.isArrayLiteralExpression(recv))
24070
24456
  return null;
24071
24457
  const parts = [];
24072
24458
  for (const el of recv.elements) {
24073
- if (ts23.isStringLiteral(el) || ts23.isNoSubstitutionTemplateLiteral(el)) {
24459
+ if (ts24.isStringLiteral(el) || ts24.isNoSubstitutionTemplateLiteral(el)) {
24074
24460
  parts.push(el.text);
24075
24461
  } else {
24076
24462
  return null;
@@ -24079,7 +24465,7 @@ function evalStringArrayJoin(source) {
24079
24465
  let sep2 = ",";
24080
24466
  if (node.arguments.length >= 1) {
24081
24467
  const arg = node.arguments[0];
24082
- if (ts23.isStringLiteral(arg) || ts23.isNoSubstitutionTemplateLiteral(arg))
24468
+ if (ts24.isStringLiteral(arg) || ts24.isNoSubstitutionTemplateLiteral(arg))
24083
24469
  sep2 = arg.text;
24084
24470
  else
24085
24471
  return null;
@@ -24087,11 +24473,11 @@ function evalStringArrayJoin(source) {
24087
24473
  return parts.join(sep2);
24088
24474
  }
24089
24475
  function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
24090
- if (!ts23.isElementAccessExpression(val))
24476
+ if (!ts24.isElementAccessExpression(val))
24091
24477
  return null;
24092
24478
  const obj = val.expression;
24093
24479
  const arg = val.argumentExpression;
24094
- if (!ts23.isIdentifier(obj) || !ts23.isIdentifier(arg))
24480
+ if (!ts24.isIdentifier(obj) || !ts24.isIdentifier(arg))
24095
24481
  return null;
24096
24482
  let indexPropName;
24097
24483
  let defaultKey;
@@ -24107,35 +24493,35 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
24107
24493
  const constInfo = localConstants.find((c) => c.name === obj.text && c.isModule);
24108
24494
  if (constInfo?.value === undefined)
24109
24495
  return null;
24110
- const sf = ts23.createSourceFile("__rec.ts", `(${constInfo.value})`, ts23.ScriptTarget.Latest, true);
24496
+ const sf = ts24.createSourceFile("__rec.ts", `(${constInfo.value})`, ts24.ScriptTarget.Latest, true);
24111
24497
  if (sf.statements.length !== 1)
24112
24498
  return null;
24113
24499
  const stmt = sf.statements[0];
24114
- if (!ts23.isExpressionStatement(stmt))
24500
+ if (!ts24.isExpressionStatement(stmt))
24115
24501
  return null;
24116
24502
  let parsed = stmt.expression;
24117
- while (ts23.isParenthesizedExpression(parsed))
24503
+ while (ts24.isParenthesizedExpression(parsed))
24118
24504
  parsed = parsed.expression;
24119
- if (!ts23.isObjectLiteralExpression(parsed))
24505
+ if (!ts24.isObjectLiteralExpression(parsed))
24120
24506
  return null;
24121
24507
  const entries = [];
24122
24508
  for (const prop of parsed.properties) {
24123
- if (!ts23.isPropertyAssignment(prop))
24509
+ if (!ts24.isPropertyAssignment(prop))
24124
24510
  return null;
24125
24511
  let key;
24126
- if (ts23.isIdentifier(prop.name)) {
24512
+ if (ts24.isIdentifier(prop.name)) {
24127
24513
  key = prop.name.text;
24128
- } else if (ts23.isStringLiteral(prop.name) || ts23.isNoSubstitutionTemplateLiteral(prop.name)) {
24514
+ } else if (ts24.isStringLiteral(prop.name) || ts24.isNoSubstitutionTemplateLiteral(prop.name)) {
24129
24515
  key = prop.name.text;
24130
24516
  } else {
24131
24517
  return null;
24132
24518
  }
24133
24519
  let v = prop.initializer;
24134
- while (ts23.isParenthesizedExpression(v))
24520
+ while (ts24.isParenthesizedExpression(v))
24135
24521
  v = v.expression;
24136
- if (ts23.isNumericLiteral(v)) {
24522
+ if (ts24.isNumericLiteral(v)) {
24137
24523
  entries.push({ key, value: { kind: "number", text: v.text } });
24138
- } else if (ts23.isStringLiteral(v) || ts23.isNoSubstitutionTemplateLiteral(v)) {
24524
+ } else if (ts24.isStringLiteral(v) || ts24.isNoSubstitutionTemplateLiteral(v)) {
24139
24525
  entries.push({ key, value: { kind: "string", text: v.text } });
24140
24526
  } else {
24141
24527
  return null;
@@ -24496,31 +24882,54 @@ function walkNode2(node, meta, bindings, matchers, errors, seen) {
24496
24882
  function mergeTemplateImports(lines) {
24497
24883
  const result = [];
24498
24884
  const valueIdx = new Map;
24885
+ const valueDefault = new Map;
24499
24886
  const valueNames = new Map;
24500
24887
  const typeIdx = new Map;
24501
24888
  const typeNames = new Map;
24502
24889
  const seenOther = new Set;
24503
- const fold = (src, rawNames, idx, names, render) => {
24504
- if (!idx.has(src)) {
24505
- idx.set(src, result.length);
24506
- names.set(src, new Set);
24890
+ const foldType = (src, rawNames) => {
24891
+ if (!typeIdx.has(src)) {
24892
+ typeIdx.set(src, result.length);
24893
+ typeNames.set(src, new Set);
24507
24894
  result.push("");
24508
24895
  }
24509
- const set = names.get(src);
24896
+ const set = typeNames.get(src);
24510
24897
  for (const n of rawNames.split(",").map((s) => s.trim()).filter(Boolean))
24511
24898
  set.add(n);
24512
- result[idx.get(src)] = render(src, set);
24899
+ result[typeIdx.get(src)] = `import type { ${[...set].join(", ")} } from '${src}'`;
24900
+ };
24901
+ const foldValue = (src, defaultName, rawNames) => {
24902
+ if (!valueIdx.has(src)) {
24903
+ valueIdx.set(src, result.length);
24904
+ valueNames.set(src, new Set);
24905
+ result.push("");
24906
+ }
24907
+ if (defaultName && !valueDefault.has(src))
24908
+ valueDefault.set(src, defaultName);
24909
+ if (rawNames) {
24910
+ const set = valueNames.get(src);
24911
+ for (const n of rawNames.split(",").map((s) => s.trim()).filter(Boolean))
24912
+ set.add(n);
24913
+ }
24914
+ result[valueIdx.get(src)] = renderUsedImportLines(src, valueDefault.get(src) ?? null, null, [...valueNames.get(src)]).join(`
24915
+ `);
24513
24916
  };
24514
24917
  for (const raw of lines) {
24515
24918
  const line = raw.trim();
24516
24919
  if (!line)
24517
24920
  continue;
24518
24921
  const typeMatch = line.match(/^import\s+type\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]\s*;?$/);
24519
- const valueMatch = line.match(/^import\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]\s*;?$/);
24520
- if (valueMatch) {
24521
- fold(valueMatch[2], valueMatch[1], valueIdx, valueNames, (s, n) => `import { ${[...n].join(", ")} } from '${s}'`);
24522
- } else if (typeMatch) {
24523
- fold(typeMatch[2], typeMatch[1], typeIdx, typeNames, (s, n) => `import type { ${[...n].join(", ")} } from '${s}'`);
24922
+ const namedMatch = line.match(/^import\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]\s*;?$/);
24923
+ const defaultNamedMatch = line.match(/^import\s+([A-Za-z_$][\w$]*)\s*,\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]\s*;?$/);
24924
+ const defaultOnlyMatch = line.match(/^import\s+([A-Za-z_$][\w$]*)\s*from\s*['"]([^'"]+)['"]\s*;?$/);
24925
+ if (typeMatch) {
24926
+ foldType(typeMatch[2], typeMatch[1]);
24927
+ } else if (namedMatch) {
24928
+ foldValue(namedMatch[2], null, namedMatch[1]);
24929
+ } else if (defaultNamedMatch) {
24930
+ foldValue(defaultNamedMatch[3], defaultNamedMatch[1], defaultNamedMatch[2]);
24931
+ } else if (defaultOnlyMatch) {
24932
+ foldValue(defaultOnlyMatch[2], defaultOnlyMatch[1], null);
24524
24933
  } else if (!seenOther.has(line)) {
24525
24934
  seenOther.add(line);
24526
24935
  result.push(line);
@@ -24562,13 +24971,13 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
24562
24971
  if (entries.some((e) => e.componentIR.metadata.isClientComponent)) {
24563
24972
  const topLevelNames = new Set;
24564
24973
  {
24565
- const sf = ts24.createSourceFile(filePath, source, ts24.ScriptTarget.Latest, true, ts24.ScriptKind.TSX);
24974
+ const sf = ts25.createSourceFile(filePath, source, ts25.ScriptTarget.Latest, true, ts25.ScriptKind.TSX);
24566
24975
  for (const stmt of sf.statements) {
24567
- if (ts24.isFunctionDeclaration(stmt) && stmt.name)
24976
+ if (ts25.isFunctionDeclaration(stmt) && stmt.name)
24568
24977
  topLevelNames.add(stmt.name.text);
24569
- else if (ts24.isVariableStatement(stmt)) {
24978
+ else if (ts25.isVariableStatement(stmt)) {
24570
24979
  for (const d of stmt.declarationList.declarations) {
24571
- if (ts24.isIdentifier(d.name))
24980
+ if (ts25.isIdentifier(d.name))
24572
24981
  topLevelNames.add(d.name.text);
24573
24982
  }
24574
24983
  }
@@ -24627,7 +25036,7 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
24627
25036
  const moduleStatementSeen = new Set;
24628
25037
  const moduleStatementsOrdered = [];
24629
25038
  const collectModuleStatements = (block) => {
24630
- const sf = ts24.createSourceFile("__bf_module_decls.tsx", block, ts24.ScriptTarget.Latest, false, ts24.ScriptKind.TSX);
25039
+ const sf = ts25.createSourceFile("__bf_module_decls.tsx", block, ts25.ScriptTarget.Latest, false, ts25.ScriptKind.TSX);
24631
25040
  for (const stmt of sf.statements) {
24632
25041
  const text = stmt.getText(sf);
24633
25042
  if (moduleStatementSeen.has(text))
@@ -24716,32 +25125,9 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
24716
25125
  }
24717
25126
  const clientJsOutputs2 = allOutputs.map((o) => o.clientJs).filter(Boolean);
24718
25127
  if (clientJsOutputs2.length > 0) {
24719
- const importsBySource = new Map;
24720
- const otherImports = [];
24721
- const allCode = [];
24722
- for (const js of clientJsOutputs2) {
24723
- for (const line of js.split(`
24724
- `)) {
24725
- if (line.startsWith("import ")) {
24726
- const match = line.match(/^import \{ ([^}]+) \} from ['"]([^'"]+)['"]$/);
24727
- if (match) {
24728
- const source2 = match[2];
24729
- if (!importsBySource.has(source2))
24730
- importsBySource.set(source2, new Set);
24731
- for (const n of match[1].split(",").map((n2) => n2.trim()))
24732
- importsBySource.get(source2).add(n);
24733
- } else if (!otherImports.includes(line)) {
24734
- otherImports.push(line);
24735
- }
24736
- }
24737
- }
24738
- allCode.push(js.replace(/^import .+\n/gm, "").trim());
24739
- }
24740
- const mergedClientImports = [...importsBySource].map(([src, names]) => `import { ${[...names].sort().join(", ")} } from '${src}'`);
24741
25128
  files.push({
24742
25129
  path: filePath.replace(/\.tsx?$/, ".client.js"),
24743
- content: [...mergedClientImports, ...otherImports, "", ...allCode.filter(Boolean)].join(`
24744
- `),
25130
+ content: mergeCompiledClientJsImports(clientJsOutputs2),
24745
25131
  type: "clientJs"
24746
25132
  });
24747
25133
  }
@@ -24812,53 +25198,9 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
24812
25198
  }
24813
25199
  const clientJsOutputs = allOutputs.map((o) => o.clientJs).filter(Boolean);
24814
25200
  if (clientJsOutputs.length > 0) {
24815
- const importsBySource = new Map;
24816
- const otherImports = [];
24817
- const allCode = [];
24818
- for (const js of clientJsOutputs) {
24819
- const lines = js.split(`
24820
- `);
24821
- const codeLines = [];
24822
- for (const line of lines) {
24823
- if (line.startsWith("import ")) {
24824
- const match = line.match(/^import \{ ([^}]+) \} from ['"]([^'"]+)['"]$/);
24825
- if (match) {
24826
- const names = match[1].split(",").map((n) => n.trim());
24827
- const source2 = match[2];
24828
- if (!importsBySource.has(source2)) {
24829
- importsBySource.set(source2, new Set);
24830
- }
24831
- const set = importsBySource.get(source2);
24832
- for (const name of names) {
24833
- set.add(name);
24834
- }
24835
- } else {
24836
- if (!otherImports.includes(line)) {
24837
- otherImports.push(line);
24838
- }
24839
- }
24840
- } else {
24841
- codeLines.push(line);
24842
- }
24843
- }
24844
- allCode.push(codeLines.join(`
24845
- `).trim());
24846
- }
24847
- const mergedImports2 = [];
24848
- for (const [source2, names] of importsBySource) {
24849
- const sortedNames = [...names].sort();
24850
- mergedImports2.push(`import { ${sortedNames.join(", ")} } from '${source2}'`);
24851
- }
24852
- const combinedClientJs = [
24853
- ...mergedImports2,
24854
- ...otherImports,
24855
- "",
24856
- ...allCode.filter(Boolean)
24857
- ].join(`
24858
- `);
24859
25201
  files.push({
24860
25202
  path: filePath.replace(/\.tsx?$/, ".client.js"),
24861
- content: combinedClientJs,
25203
+ content: mergeCompiledClientJsImports(clientJsOutputs),
24862
25204
  type: "clientJs"
24863
25205
  });
24864
25206
  }
@@ -24931,10 +25273,24 @@ function compileJSX(source, filePath, options) {
24931
25273
  externalImportLines.push(`import '${imp.source}'`);
24932
25274
  continue;
24933
25275
  }
24934
- 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);
24935
- if (used.length > 0) {
24936
- externalImportLines.push(`import { ${used.join(", ")} } from '${imp.source}'`);
25276
+ const usedNamed = [];
25277
+ let usedDefault = null;
25278
+ let usedNamespace = null;
25279
+ for (const s2 of imp.specifiers) {
25280
+ if (s2.isTypeOnly)
25281
+ continue;
25282
+ const localName = s2.alias || s2.name;
25283
+ if (!isUsedAsValue(localName))
25284
+ continue;
25285
+ if (s2.isDefault) {
25286
+ usedDefault = localName;
25287
+ } else if (s2.isNamespace) {
25288
+ usedNamespace = localName;
25289
+ } else {
25290
+ usedNamed.push(s2.alias ? `${s2.name} as ${s2.alias}` : s2.name);
25291
+ }
24937
25292
  }
25293
+ externalImportLines.push(...renderUsedImportLines(imp.source, usedDefault, usedNamespace, usedNamed));
24938
25294
  }
24939
25295
  const allImports = [runtimeImportLine, ...externalImportLines].filter(Boolean).join(`
24940
25296
  `);
@@ -25070,7 +25426,7 @@ function compileJSX(source, filePath, options) {
25070
25426
  return { files, errors };
25071
25427
  }
25072
25428
  // src/shared-program.ts
25073
- import ts25 from "typescript";
25429
+ import ts26 from "typescript";
25074
25430
  function commonParent(paths) {
25075
25431
  if (paths.length === 0)
25076
25432
  return process.cwd();
@@ -25091,10 +25447,10 @@ function commonParent(paths) {
25091
25447
  function createProgramForCorpus(files, options = {}) {
25092
25448
  const baseUrl = options.baseUrl ?? commonParent(files);
25093
25449
  const compilerOptions = {
25094
- target: ts25.ScriptTarget.Latest,
25095
- module: ts25.ModuleKind.ESNext,
25096
- moduleResolution: ts25.ModuleResolutionKind.Bundler,
25097
- jsx: ts25.JsxEmit.ReactJSX,
25450
+ target: ts26.ScriptTarget.Latest,
25451
+ module: ts26.ModuleKind.ESNext,
25452
+ moduleResolution: ts26.ModuleResolutionKind.Bundler,
25453
+ jsx: ts26.JsxEmit.ReactJSX,
25098
25454
  strict: true,
25099
25455
  skipLibCheck: true,
25100
25456
  noEmit: true,
@@ -25104,7 +25460,7 @@ function createProgramForCorpus(files, options = {}) {
25104
25460
  ...options.compilerOptions
25105
25461
  };
25106
25462
  const absolute = files.map((f) => path_default.resolve(f));
25107
- return ts25.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
25463
+ return ts26.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
25108
25464
  }
25109
25465
  // src/adapters/interface.ts
25110
25466
  class BaseAdapter {
@@ -25388,7 +25744,7 @@ class JsxAdapter extends BaseAdapter {
25388
25744
  }
25389
25745
 
25390
25746
  // src/adapters/template-imports.ts
25391
- import ts26 from "typescript";
25747
+ import ts27 from "typescript";
25392
25748
  var CLIENT_PACKAGE_SOURCES = new Set([
25393
25749
  "@barefootjs/client",
25394
25750
  "@barefootjs/client/runtime"
@@ -25438,18 +25794,18 @@ function specKey(s) {
25438
25794
  function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
25439
25795
  if (!sourceText.includes("import"))
25440
25796
  return sourceText;
25441
- const sf = ts26.createSourceFile("bf-template-fragment.tsx", sourceText, ts26.ScriptTarget.Latest, false, ts26.ScriptKind.TSX);
25797
+ const sf = ts27.createSourceFile("bf-template-fragment.tsx", sourceText, ts27.ScriptTarget.Latest, false, ts27.ScriptKind.TSX);
25442
25798
  const edits = [];
25443
25799
  const visit3 = (node) => {
25444
- if (ts26.isCallExpression(node) && node.expression.kind === ts26.SyntaxKind.ImportKeyword && node.arguments.length > 0 && ts26.isStringLiteralLike(node.arguments[0])) {
25800
+ if (ts27.isCallExpression(node) && node.expression.kind === ts27.SyntaxKind.ImportKeyword && node.arguments.length > 0 && ts27.isStringLiteralLike(node.arguments[0])) {
25445
25801
  collect(node.arguments[0]);
25446
25802
  }
25447
- if (ts26.isImportTypeNode(node) && ts26.isLiteralTypeNode(node.argument)) {
25803
+ if (ts27.isImportTypeNode(node) && ts27.isLiteralTypeNode(node.argument)) {
25448
25804
  const literal = node.argument.literal;
25449
- if (ts26.isStringLiteralLike(literal))
25805
+ if (ts27.isStringLiteralLike(literal))
25450
25806
  collect(literal);
25451
25807
  }
25452
- ts26.forEachChild(node, visit3);
25808
+ ts27.forEachChild(node, visit3);
25453
25809
  };
25454
25810
  const collect = (literal) => {
25455
25811
  const specifier = literal.text;
@@ -25464,7 +25820,7 @@ function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
25464
25820
  text: `'${next}'`
25465
25821
  });
25466
25822
  };
25467
- ts26.forEachChild(sf, visit3);
25823
+ ts27.forEachChild(sf, visit3);
25468
25824
  if (edits.length === 0)
25469
25825
  return sourceText;
25470
25826
  let out = sourceText;
@@ -26229,7 +26585,7 @@ function dangerousInnerHtmlDiagnostic(expr, loc, reason) {
26229
26585
  };
26230
26586
  }
26231
26587
  // src/combine-client-js.ts
26232
- import ts27 from "typescript";
26588
+ import ts28 from "typescript";
26233
26589
  var CHILD_PLACEHOLDER_RE = /import '\/\* @bf-child:(\w+) \*\/'/g;
26234
26590
  function combineParentChildClientJs(files) {
26235
26591
  const result = new Map;
@@ -26286,10 +26642,10 @@ function combineParentChildClientJs(files) {
26286
26642
  return result;
26287
26643
  }
26288
26644
  function parseAndMerge(content, importsBySource, otherImports, codeSections) {
26289
- const sourceFile = ts27.createSourceFile("combine.js", content, ts27.ScriptTarget.Latest, false, ts27.ScriptKind.JS);
26645
+ const sourceFile = ts28.createSourceFile("combine.js", content, ts28.ScriptTarget.Latest, false, ts28.ScriptKind.JS);
26290
26646
  const importSpans = [];
26291
26647
  for (const stmt of sourceFile.statements) {
26292
- if (!ts27.isImportDeclaration(stmt))
26648
+ if (!ts28.isImportDeclaration(stmt))
26293
26649
  continue;
26294
26650
  const start = stmt.getStart(sourceFile);
26295
26651
  const end = stmt.getEnd();
@@ -26299,8 +26655,8 @@ function parseAndMerge(content, importsBySource, otherImports, codeSections) {
26299
26655
  continue;
26300
26656
  const clause = stmt.importClause;
26301
26657
  const bindings = clause?.namedBindings;
26302
- const specifier = ts27.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
26303
- if (clause && !clause.name && bindings && ts27.isNamedImports(bindings)) {
26658
+ const specifier = ts28.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
26659
+ if (clause && !clause.name && bindings && ts28.isNamedImports(bindings)) {
26304
26660
  if (!importsBySource.has(specifier)) {
26305
26661
  importsBySource.set(specifier, new Set);
26306
26662
  }
@@ -26467,7 +26823,7 @@ function escapeRe(s) {
26467
26823
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
26468
26824
  }
26469
26825
  // src/debug.ts
26470
- import ts28 from "typescript";
26826
+ import ts29 from "typescript";
26471
26827
  function buildComponentGraph(source, filePath, componentName) {
26472
26828
  const ctx = analyzeComponent(source, filePath, componentName);
26473
26829
  if (!ctx.jsxReturn) {
@@ -27755,7 +28111,7 @@ function truncateExpr(expr, max = 40) {
27755
28111
  function exprReadsPropMember(expr, propsObjectName) {
27756
28112
  let sf;
27757
28113
  try {
27758
- sf = ts28.createSourceFile("__attr.tsx", `(${expr})`, ts28.ScriptTarget.Latest, true, ts28.ScriptKind.TSX);
28114
+ sf = ts29.createSourceFile("__attr.tsx", `(${expr})`, ts29.ScriptTarget.Latest, true, ts29.ScriptKind.TSX);
27759
28115
  } catch {
27760
28116
  return false;
27761
28117
  }
@@ -27763,11 +28119,11 @@ function exprReadsPropMember(expr, propsObjectName) {
27763
28119
  const visit3 = (n) => {
27764
28120
  if (found)
27765
28121
  return;
27766
- if (ts28.isPropertyAccessExpression(n) && ts28.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
28122
+ if (ts29.isPropertyAccessExpression(n) && ts29.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
27767
28123
  found = true;
27768
28124
  return;
27769
28125
  }
27770
- ts28.forEachChild(n, visit3);
28126
+ ts29.forEachChild(n, visit3);
27771
28127
  };
27772
28128
  visit3(sf);
27773
28129
  return found;
@@ -27837,7 +28193,7 @@ function findSourceFile2(meta) {
27837
28193
  return null;
27838
28194
  }
27839
28195
  // src/profiler.ts
27840
- import ts29 from "typescript";
28196
+ import ts30 from "typescript";
27841
28197
  var PROFILE_SCHEMA_VERSION = 1;
27842
28198
  var DEFAULT_FANOUT_THRESHOLD = 8;
27843
28199
  function buildStaticBudget(source, filePath, componentName, options = {}) {
@@ -28107,15 +28463,15 @@ function joinProfilerEvents(events, index) {
28107
28463
  return { joined, unattributed, diagnostics };
28108
28464
  }
28109
28465
  function findUninstrumentedEffects(source, filePath, instrumentedLines) {
28110
- const sf = ts29.createSourceFile(filePath, source, ts29.ScriptTarget.Latest, true, ts29.ScriptKind.TSX);
28466
+ const sf = ts30.createSourceFile(filePath, source, ts30.ScriptTarget.Latest, true, ts30.ScriptKind.TSX);
28111
28467
  const out = [];
28112
28468
  const visit3 = (node) => {
28113
- if (ts29.isCallExpression(node) && ts29.isIdentifier(node.expression) && node.expression.text === "createEffect") {
28469
+ if (ts30.isCallExpression(node) && ts30.isIdentifier(node.expression) && node.expression.text === "createEffect") {
28114
28470
  const line = sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;
28115
28471
  if (!instrumentedLines.has(line))
28116
28472
  out.push({ file: filePath, line });
28117
28473
  }
28118
- ts29.forEachChild(node, visit3);
28474
+ ts30.forEachChild(node, visit3);
28119
28475
  };
28120
28476
  visit3(sf);
28121
28477
  out.sort((a, b) => a.line - b.line);
@@ -28423,13 +28779,13 @@ function assessBatchSafety(args) {
28423
28779
  const signalGetters = new Set(args.graph.signals.map((s) => s.name));
28424
28780
  let sf;
28425
28781
  try {
28426
- sf = ts29.createSourceFile("__h.ts", `const __h = ${args.handler}`, ts29.ScriptTarget.Latest, true);
28782
+ sf = ts30.createSourceFile("__h.ts", `const __h = ${args.handler}`, ts30.ScriptTarget.Latest, true);
28427
28783
  } catch {
28428
28784
  return "unverified";
28429
28785
  }
28430
28786
  const calls = [];
28431
28787
  const visit3 = (node) => {
28432
- if (ts29.isCallExpression(node) && ts29.isIdentifier(node.expression)) {
28788
+ if (ts30.isCallExpression(node) && ts30.isIdentifier(node.expression)) {
28433
28789
  const name = node.expression.text;
28434
28790
  if (setters.has(name))
28435
28791
  calls.push({ pos: node.getStart(sf), kind: "write" });
@@ -28438,7 +28794,7 @@ function assessBatchSafety(args) {
28438
28794
  else if (!signalGetters.has(name) && !memoNames.has(name))
28439
28795
  calls.push({ pos: node.getStart(sf), kind: "risky" });
28440
28796
  }
28441
- ts29.forEachChild(node, visit3);
28797
+ ts30.forEachChild(node, visit3);
28442
28798
  };
28443
28799
  visit3(sf);
28444
28800
  calls.sort((a, b) => a.pos - b.pos);
@@ -29082,6 +29438,7 @@ export {
29082
29438
  sortComparatorFromArrow,
29083
29439
  serializeParsedExpr,
29084
29440
  searchParamsLocalNames,
29441
+ scanComponentFile,
29085
29442
  rewriteImportsForTemplate,
29086
29443
  rewriteDynamicImportsInSource,
29087
29444
  resolveStaticLoopSource,
@@ -29226,6 +29583,9 @@ export {
29226
29583
  __resetLoweringPluginsForTest,
29227
29584
  TestAdapter,
29228
29585
  SourceMapGenerator,
29586
+ SORT_KEY_TYPES,
29587
+ SORT_KEY_TARGETS,
29588
+ SORT_KEY_DIRECTIONS,
29229
29589
  REACTIVE_PRIMITIVES,
29230
29590
  PROFILE_SCHEMA_VERSION,
29231
29591
  PARSED_EXPR_KINDS,