@barefootjs/jsx 0.33.2 → 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 (47) 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/index.d.ts +1 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +707 -431
  8. package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
  9. package/dist/ir-to-client-js/control-flow/stringify/loop-child-arm.d.ts.map +1 -1
  10. package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
  11. package/dist/ir-to-client-js/imports.d.ts +60 -2
  12. package/dist/ir-to-client-js/imports.d.ts.map +1 -1
  13. package/dist/ir-to-client-js/prop-handling.d.ts +4 -7
  14. package/dist/ir-to-client-js/prop-handling.d.ts.map +1 -1
  15. package/dist/ir-to-client-js/utils.d.ts +26 -2
  16. package/dist/ir-to-client-js/utils.d.ts.map +1 -1
  17. package/dist/jsx-to-ir.d.ts.map +1 -1
  18. package/dist/props-binding.d.ts +35 -0
  19. package/dist/props-binding.d.ts.map +1 -1
  20. package/dist/types.d.ts +50 -13
  21. package/dist/types.d.ts.map +1 -1
  22. package/package.json +2 -2
  23. package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +145 -97
  24. package/src/__tests__/child-component-ref-not-mirrored.test.ts +90 -0
  25. package/src/__tests__/ir-to-client-js/imports.test.ts +107 -0
  26. package/src/__tests__/ir-to-client-js/merge-compiled-client-js-imports.test.ts +138 -0
  27. package/src/__tests__/issue-2754-rest-spread-needs-slot.test.ts +85 -0
  28. package/src/__tests__/issue-2756-loop-row-honors-client-only.test.ts +173 -0
  29. package/src/__tests__/merge-template-imports.test.ts +41 -1
  30. package/src/__tests__/multi-component-shared-default-import.test.ts +55 -0
  31. package/src/__tests__/root-key-relay.test.ts +170 -0
  32. package/src/__tests__/signal-getter-not-called.test.ts +149 -0
  33. package/src/__tests__/state-only-file-default-import.test.ts +47 -0
  34. package/src/analyzer.ts +36 -0
  35. package/src/compiler.ts +94 -104
  36. package/src/index.ts +1 -1
  37. package/src/ir-to-client-js/collect-elements.ts +27 -5
  38. package/src/ir-to-client-js/control-flow/stringify/inner-loop.ts +6 -2
  39. package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +5 -2
  40. package/src/ir-to-client-js/html-template.ts +122 -12
  41. package/src/ir-to-client-js/imports.ts +178 -5
  42. package/src/ir-to-client-js/index.ts +5 -0
  43. package/src/ir-to-client-js/prop-handling.ts +6 -17
  44. package/src/ir-to-client-js/utils.ts +30 -2
  45. package/src/jsx-to-ir.ts +480 -52
  46. package/src/props-binding.ts +51 -0
  47. package/src/types.ts +47 -13
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";
@@ -2384,11 +2384,16 @@ import {
2384
2384
  loopStartMarker,
2385
2385
  loopEndMarker,
2386
2386
  loopItemMarker,
2387
- toHTMLAttrName as toHtmlAttrName
2387
+ toHTMLAttrName as toHtmlAttrName,
2388
+ keyAttrName as sharedKeyAttrName
2388
2389
  } from "@barefootjs/shared";
2389
2390
  var PROPS_PARAM = "_p";
2390
- function keyAttrName(loopDepth) {
2391
- 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))}`;
2392
2397
  }
2393
2398
  function varSlotId(slotId) {
2394
2399
  return slotId.startsWith("^") ? slotId.slice(1) : slotId;
@@ -3378,6 +3383,14 @@ function escapeAttrValueExpr(valExpr) {
3378
3383
  function escapeTextSlotExpr(innerExpr, isMarkup = false) {
3379
3384
  return `${isMarkup ? "escapeTextOrMarkup" : "escapeText"}(${innerExpr})`;
3380
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
+ }
3381
3394
  function dangerouslyHtmlChildren(attrs, toExpr) {
3382
3395
  const attr = attrs.find((a) => a.name === "dangerouslySetInnerHTML");
3383
3396
  if (!attr || attr.value.kind !== "expression")
@@ -3585,7 +3598,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3585
3598
  case "element": {
3586
3599
  const mergeCtx = {
3587
3600
  isFilteredSpread: (v) => !!restSpreadNames?.has(v.expr),
3588
- honorClientOnly: false
3601
+ honorClientOnly: true
3589
3602
  };
3590
3603
  const useMerge = shouldUseSpreadAttrsMerge(node.attrs, mergeCtx);
3591
3604
  const firstMergeableIdx = useMerge ? node.attrs.findIndex((a) => isMergeableAttr(a, mergeCtx)) : -1;
@@ -3596,6 +3609,8 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3596
3609
  templateExprFor: (v) => wrapExpr(attrValueToString(v) ?? "")
3597
3610
  }) : null;
3598
3611
  const attrParts = node.attrs.map((a, idx) => {
3612
+ if (a.clientOnly)
3613
+ return "";
3599
3614
  if (useMerge && isMergeableAttr(a, mergeCtx)) {
3600
3615
  return idx === firstMergeableIdx ? mergeCall : "";
3601
3616
  }
@@ -3621,17 +3636,18 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
3621
3636
  case "expression": {
3622
3637
  if (node.expr === "null" || node.expr === "undefined")
3623
3638
  return "";
3639
+ const escapeForClient = (e) => node.escapeInClientTemplate ? `escapeText(${e})` : e;
3624
3640
  if (node.markerless) {
3625
- const bare = wrapInterpolation(wrapExpr(node.expr));
3641
+ const bare = escapeForClient(wrapInterpolation(wrapExpr(node.expr)));
3626
3642
  return `\${${bare}}`;
3627
3643
  }
3628
- const inner = wrapInterpolation(wrapExpr(node.expr));
3644
+ const inner = escapeForClient(wrapInterpolation(wrapExpr(node.expr)));
3629
3645
  const valueExpr = node.joinArrayChild ? `Array.isArray(${inner}) ? ${inner}.join('') : (${inner} ?? '')` : inner;
3630
3646
  if (node.slotId) {
3631
3647
  const slotted = branchSlotsVar || node.joinArrayChild ? valueExpr : escapeTextSlotExpr(valueExpr);
3632
3648
  return `<!--bf:${node.slotId}-->\${${slotted}}<!--/-->`;
3633
3649
  }
3634
- return `\${${valueExpr}}`;
3650
+ return `\${${bareSpliceExpr(node, valueExpr)}}`;
3635
3651
  }
3636
3652
  case "conditional": {
3637
3653
  const trueBranch = recurse(node.whenTrue);
@@ -3930,6 +3946,8 @@ function irToPlaceholderTemplate(node, restSpreadNames, loopDepth = 0, loopParam
3930
3946
  switch (node.type) {
3931
3947
  case "element": {
3932
3948
  const attrParts = node.attrs.map((a) => {
3949
+ if (a.clientOnly)
3950
+ return "";
3933
3951
  const attrName = a.name === "..." ? "..." : a.name === "key" ? keyAttrName(loopDepth) : toHtmlAttrName(a.name);
3934
3952
  return renderTemplateAttrPart(a, attrName, wrapExpr, restSpreadNames);
3935
3953
  }).filter(Boolean);
@@ -3953,7 +3971,8 @@ function irToPlaceholderTemplate(node, restSpreadNames, loopDepth = 0, loopParam
3953
3971
  if (node.slotId) {
3954
3972
  return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(wrapped)}}<!--/-->`;
3955
3973
  }
3956
- return `\${${value}}`;
3974
+ const spliced = bareSpliceExpr(node, value);
3975
+ return `\${${node.escapeInClientTemplate ? `escapeText(${spliced})` : spliced}}`;
3957
3976
  }
3958
3977
  case "conditional": {
3959
3978
  const trueBranch = recurse(node.whenTrue);
@@ -4195,7 +4214,7 @@ function irToComponentTemplateWithOpts(node, opts) {
4195
4214
  const isMarkup = opts.markupSlotIds?.has(node.slotId) ?? false;
4196
4215
  return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(wrapped, isMarkup)}}<!--/-->`;
4197
4216
  }
4198
- return `\${${value}}`;
4217
+ return `\${${bareSpliceExpr(node, value)}}`;
4199
4218
  }
4200
4219
  case "conditional": {
4201
4220
  if (node.clientOnly && node.slotId) {
@@ -4526,7 +4545,7 @@ function generateCsrTemplateWithOpts(node, opts) {
4526
4545
  const isMarkup = opts.markupSlotIds?.has(node.slotId) ?? false;
4527
4546
  return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(expr, isMarkup)}}<!--/-->`;
4528
4547
  }
4529
- return `\${${value}}`;
4548
+ return `\${${bareSpliceExpr(node, value)}}`;
4530
4549
  }
4531
4550
  case "conditional": {
4532
4551
  if (node.clientOnly && node.slotId) {
@@ -4834,6 +4853,19 @@ function buildPropAliasMap(params) {
4834
4853
  }
4835
4854
  return map;
4836
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
+ }
4837
4869
 
4838
4870
  // src/instrumentation.ts
4839
4871
  var _enabled = false;
@@ -8323,6 +8355,16 @@ function importsBrowserOnlyClientApi(ctx) {
8323
8355
  }
8324
8356
  function listComponentFunctions(source, filePath) {
8325
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) {
8326
8368
  const componentNames = [];
8327
8369
  const hasUseClient = sourceFile.statements.some((stmt) => ts9.isExpressionStatement(stmt) && ts9.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
8328
8370
  const namedExports = collectNamedExports(sourceFile);
@@ -10264,7 +10306,7 @@ var toLocaleDatePlugin = {
10264
10306
  };
10265
10307
 
10266
10308
  // src/jsx-to-ir.ts
10267
- import { toHTMLAttrName, decodeEntities } from "@barefootjs/shared";
10309
+ import { toHTMLAttrName, decodeEntities, BF_KEY, keyAttrName as keyAttrName2 } from "@barefootjs/shared";
10268
10310
  var CLIENT_DIRECTIVE_INTERIOR_RE2 = /^\s*@client\s*$/;
10269
10311
  var BLOCK_COMMENT_RE2 = /\/\*([\s\S]*?)\*\//g;
10270
10312
  function hasLeadingClientDirective(expr, sourceFile) {
@@ -10717,10 +10759,44 @@ function attachParsedExpressions(node, analyzer, bound = EMPTY_BOUND) {
10717
10759
  break;
10718
10760
  }
10719
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
+ }
10720
10794
  function jsxToIR(analyzer) {
10721
10795
  const root = buildIRRoot(analyzer);
10722
- if (root)
10796
+ if (root) {
10723
10797
  attachParsedExpressions(root, analyzer);
10798
+ resolveRootKeyAttr(root);
10799
+ }
10724
10800
  return root;
10725
10801
  }
10726
10802
  function buildIRRoot(analyzer) {
@@ -10909,6 +10985,7 @@ function lowerFormControlValueSsr(tagName, attrs, children) {
10909
10985
  type: "expression",
10910
10986
  expr,
10911
10987
  templateExpr: `escapeText(${templateExpr ?? expr})`,
10988
+ escapeInClientTemplate: true,
10912
10989
  typeInfo: null,
10913
10990
  reactive: false,
10914
10991
  slotId: null,
@@ -10946,7 +11023,7 @@ function transformHtmlElement(node, ctx, tagName) {
10946
11023
  ctx.isRoot = false;
10947
11024
  const children = transformChildren(node.children, ctx);
10948
11025
  lowerFormControlValueSsr(tagName, attrs, children);
10949
- 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);
10950
11027
  const slotId = needsSlot ? generateSlotId(ctx) : null;
10951
11028
  if (slotId) {
10952
11029
  propagateSlotIdToLoops(children, slotId);
@@ -10979,7 +11056,7 @@ function transformSelfClosingElement(node, ctx) {
10979
11056
  const { attrs, events, ref } = processAttributes(node.attributes, ctx);
10980
11057
  const selfClosingChildren = [];
10981
11058
  lowerFormControlValueSsr(tagName, attrs, selfClosingChildren);
10982
- const needsSlot = events.length > 0 || hasReactiveAttributes(attrs, ctx) || ref !== null;
11059
+ const needsSlot = events.length > 0 || hasReactiveAttributes(attrs, ctx) || ref !== null || forwardsCallerRestProps(attrs, ctx);
10983
11060
  const slotId = needsSlot ? generateSlotId(ctx) : null;
10984
11061
  const needsScope = ctx.isRoot;
10985
11062
  ctx.isRoot = false;
@@ -11218,7 +11295,9 @@ function markDataKeyCarrier(children) {
11218
11295
  }
11219
11296
  function markCarrierIn(node) {
11220
11297
  if (node.type === "element") {
11221
- return { ...node, carriesDataKey: true };
11298
+ if (node.keyAttr)
11299
+ return null;
11300
+ return { ...node, keyAttr: { name: BF_KEY } };
11222
11301
  }
11223
11302
  if (node.type === "conditional") {
11224
11303
  const cond = node;
@@ -11293,7 +11372,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
11293
11372
  if (isRenderNothingLiteral(expr, ctx)) {
11294
11373
  return null;
11295
11374
  }
11296
- checkBareSignalOrMemoIdentifier(expr, ctx);
11375
+ checkBareSignalOrMemoIdentifier(expr, ctx, { descendNested: true });
11297
11376
  if (ts13.isIdentifier(expr)) {
11298
11377
  const jsxNode = ctx.analyzer.jsxConstants.get(expr.text);
11299
11378
  if (jsxNode) {
@@ -12410,6 +12489,16 @@ function tagLoopItemRootComponents(nodes) {
12410
12489
  }
12411
12490
  }
12412
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
+ }
12413
12502
  function loopBodyItemConditional(children) {
12414
12503
  const real = children.filter((c) => !(c.type === "text" && typeof c.value === "string" && !c.value.trim()));
12415
12504
  if (real.length !== 1)
@@ -12792,6 +12881,14 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
12792
12881
  const itemConditional = children.length > 0 ? loopBodyItemConditional(children) : null;
12793
12882
  const bodyIsItemConditional = itemConditional !== null;
12794
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
+ }
12795
12892
  const declaredNameSet = preamble && preamble.declaredNames.length > 0 ? new Set(preamble.declaredNames) : undefined;
12796
12893
  if (key && declaredNameSet) {
12797
12894
  const keyRefs = extractFreeIdentifiersFromText(key);
@@ -13482,7 +13579,7 @@ function getAttributeValue(attr, ctx) {
13482
13579
  ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(expr, ctx.sourceFile, ctx.filePath)));
13483
13580
  return AttrValueOf.expression("undefined");
13484
13581
  }
13485
- checkBareSignalOrMemoIdentifier(expr, ctx);
13582
+ checkBareSignalOrMemoIdentifier(expr, ctx, { descendNested: isRenderedElementAttribute(attr, ctx) });
13486
13583
  if (attr.name.getText(ctx.sourceFile) === "style" && ts13.isObjectLiteralExpression(expr)) {
13487
13584
  const cssString = tryStaticStyleObjectToCss(expr);
13488
13585
  if (cssString !== null) {
@@ -13990,34 +14087,142 @@ function processComponentProps(attributes, ctx) {
13990
14087
  }
13991
14088
  return props;
13992
14089
  }
13993
- function checkBareSignalOrMemoIdentifier(expr, ctx) {
13994
- 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)
13995
14101
  return;
13996
- const name = expr.text;
13997
- for (const signal of ctx.analyzer.signals) {
13998
- if (signal.getter === name) {
13999
- ctx.analyzer.errors.push(createError(ErrorCodes.SIGNAL_GETTER_NOT_CALLED, getSourceLocation(expr, ctx.sourceFile, ctx.filePath), {
14000
- message: `Signal getter '${name}' passed without calling it`,
14001
- suggestion: {
14002
- message: `Signal getters must be called to read the value. Use \`${name}()\` instead of \`${name}\`.`,
14003
- replacement: `${name}()`
14004
- }
14005
- }));
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);
14006
14131
  return;
14007
14132
  }
14008
- }
14009
- for (const memo of ctx.analyzer.memos) {
14010
- if (memo.name === name) {
14011
- ctx.analyzer.errors.push(createError(ErrorCodes.SIGNAL_GETTER_NOT_CALLED, getSourceLocation(expr, ctx.sourceFile, ctx.filePath), {
14012
- message: `Memo getter '${name}' passed without calling it`,
14013
- suggestion: {
14014
- message: `Memo getters must be called to read the value. Use \`${name}()\` instead of \`${name}\`.`,
14015
- replacement: `${name}()`
14016
- }
14017
- }));
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)) {
14166
+ return;
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);
14018
14221
  return;
14019
14222
  }
14223
+ ts13.forEachChild(node, visit2);
14020
14224
  }
14225
+ visit2(expr);
14021
14226
  }
14022
14227
  function isArrayExprDirectPropRef(arrayExpr, ctx) {
14023
14228
  const propNames = new Set(ctx.patterns.props.map((p) => p.name));
@@ -14116,6 +14321,31 @@ function isPropsReference(expr, ctx, visited) {
14116
14321
  }
14117
14322
  return false;
14118
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
+ }
14119
14349
  function hasReactiveAttributes(attrs, ctx) {
14120
14350
  for (const attr of attrs) {
14121
14351
  if (attr.name === "key")
@@ -14338,18 +14568,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
14338
14568
 
14339
14569
  // src/ir-to-client-js/prop-handling.ts
14340
14570
  function resolveRestSpreadOrigin(ctx, name) {
14341
- const byName = localConstantValues(ctx);
14342
- const visited = new Set;
14343
- let current = name.trim();
14344
- while (current !== undefined && !visited.has(current)) {
14345
- if (ctx.restPropsName && current === ctx.restPropsName)
14346
- return "rest";
14347
- if (ctx.propsObjectName && current === ctx.propsObjectName)
14348
- return "props";
14349
- visited.add(current);
14350
- current = byName.get(current)?.trim();
14351
- }
14352
- return null;
14571
+ return resolveRestSpreadOriginCore(ctx, localConstantValues(ctx), name);
14353
14572
  }
14354
14573
  var _localConstantValuesCache = new WeakMap;
14355
14574
  function localConstantValues(ctx) {
@@ -14959,6 +15178,7 @@ function emitMultiRootTemplateCloneLines(template, indent, varEl, varExtras) {
14959
15178
  }
14960
15179
 
14961
15180
  // src/ir-to-client-js/collect-elements.ts
15181
+ import { classifyDOMProp } from "@barefootjs/shared";
14962
15182
  var EMPTY_RENDER_EXPRS = new Set(["null", "undefined", "false", "''", '""', "``"]);
14963
15183
  function domElementCount(node) {
14964
15184
  switch (node.type) {
@@ -15245,8 +15465,8 @@ function collectReactiveChildProps(node, ctx) {
15245
15465
  continue;
15246
15466
  if (prop.value.kind === "jsx-children")
15247
15467
  continue;
15248
- const isEventHandler = prop.name.startsWith("on") && prop.name.length > 2 && prop.name[2] === prop.name[2].toUpperCase();
15249
- if (isEventHandler)
15468
+ const domKind = classifyDOMProp(prop.name).kind;
15469
+ if (domKind === "ref" || domKind === "event" || domKind === "skip")
15250
15470
  continue;
15251
15471
  if (prop.value.kind !== "expression" && prop.value.kind !== "template")
15252
15472
  continue;
@@ -16163,6 +16383,9 @@ function propHasPropertyAccess(u) {
16163
16383
  return u.accessKinds.has("property") || u.accessKinds.has("index");
16164
16384
  }
16165
16385
 
16386
+ // src/ir-to-client-js/imports.ts
16387
+ import ts16 from "typescript";
16388
+
16166
16389
  // src/value-references.ts
16167
16390
  import ts15 from "typescript";
16168
16391
  function isValueReferenceIdentifier(id) {
@@ -16269,6 +16492,7 @@ var RUNTIME_IMPORT_CANDIDATES = [
16269
16492
  "escapeTextOrNode",
16270
16493
  "bfMarkup",
16271
16494
  "escapeTextOrMarkup",
16495
+ "markupOrEmpty",
16272
16496
  "qsa",
16273
16497
  "qsaItem",
16274
16498
  "qsaChildScope",
@@ -16335,6 +16559,79 @@ function makeValueUsageTest(generatedCode) {
16335
16559
  return generatedCode.includes(localName);
16336
16560
  };
16337
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
+ }
16338
16635
  function collectExternalImports(ir, generatedCode, localImportPrefixes) {
16339
16636
  const componentNames = collectComponentNames(ir.root);
16340
16637
  const importLines = [];
@@ -16350,23 +16647,31 @@ function collectExternalImports(ir, generatedCode, localImportPrefixes) {
16350
16647
  importLines.push(`import '${imp.source}'`);
16351
16648
  continue;
16352
16649
  }
16353
- const usedSpecs = [];
16650
+ const usedNamed = [];
16651
+ let usedDefault = null;
16652
+ let usedNamespace = null;
16354
16653
  for (const spec of imp.specifiers) {
16355
16654
  if (spec.isTypeOnly)
16356
16655
  continue;
16357
16656
  const localName = spec.alias || spec.name;
16358
16657
  if (componentNames.has(localName))
16359
16658
  continue;
16360
- if (isUsedAsValue(localName)) {
16361
- 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);
16362
16667
  }
16363
16668
  }
16364
- if (usedSpecs.length > 0) {
16669
+ if (usedDefault || usedNamespace || usedNamed.length > 0) {
16365
16670
  let source = imp.source;
16366
16671
  if (ir.metadata.clientSignalImportSources?.has(source)) {
16367
16672
  source = source.replace(/\.tsx?$/, "") + ".client.js";
16368
16673
  }
16369
- importLines.push(`import { ${usedSpecs.join(", ")} } from '${source}'`);
16674
+ importLines.push(...renderUsedImportLines(source, usedDefault, usedNamespace, usedNamed));
16370
16675
  }
16371
16676
  }
16372
16677
  return importLines;
@@ -16396,7 +16701,7 @@ function collectComponentNames(node) {
16396
16701
  }
16397
16702
 
16398
16703
  // src/relocate.ts
16399
- import ts16 from "typescript";
16704
+ import ts17 from "typescript";
16400
16705
 
16401
16706
  // src/lowering-registry.ts
16402
16707
  var plugins = [];
@@ -16442,19 +16747,19 @@ function classify(name, env) {
16442
16747
  function collectFreeRefs(node) {
16443
16748
  const refs = new Map;
16444
16749
  function visit3(n, parent) {
16445
- if (ts16.isIdentifier(n)) {
16446
- if (parent && ts16.isPropertyAccessExpression(parent) && parent.name === n)
16750
+ if (ts17.isIdentifier(n)) {
16751
+ if (parent && ts17.isPropertyAccessExpression(parent) && parent.name === n)
16447
16752
  return;
16448
- if (parent && ts16.isPropertyAssignment(parent) && parent.name === n)
16753
+ if (parent && ts17.isPropertyAssignment(parent) && parent.name === n)
16449
16754
  return;
16450
- if (parent && ts16.isShorthandPropertyAssignment(parent) && parent.name === n)
16755
+ if (parent && ts17.isShorthandPropertyAssignment(parent) && parent.name === n)
16451
16756
  return;
16452
16757
  const list = refs.get(n.text) ?? [];
16453
16758
  list.push(n);
16454
16759
  refs.set(n.text, list);
16455
16760
  return;
16456
16761
  }
16457
- ts16.forEachChild(n, (child) => visit3(child, n));
16762
+ ts17.forEachChild(n, (child) => visit3(child, n));
16458
16763
  }
16459
16764
  visit3(node);
16460
16765
  return refs;
@@ -16558,11 +16863,11 @@ function isInlinableInTemplate(value, env) {
16558
16863
  return { ok: true, rewrittenValue: r.text, decisions: r.decisions };
16559
16864
  }
16560
16865
  function getCalleeIdentifierPath(callee) {
16561
- if (ts16.isParenthesizedExpression(callee))
16866
+ if (ts17.isParenthesizedExpression(callee))
16562
16867
  return getCalleeIdentifierPath(callee.expression);
16563
- if (ts16.isIdentifier(callee))
16868
+ if (ts17.isIdentifier(callee))
16564
16869
  return callee.text;
16565
- if (ts16.isPropertyAccessExpression(callee)) {
16870
+ if (ts17.isPropertyAccessExpression(callee)) {
16566
16871
  const left = getCalleeIdentifierPath(callee.expression);
16567
16872
  if (left === null)
16568
16873
  return null;
@@ -16571,11 +16876,11 @@ function getCalleeIdentifierPath(callee) {
16571
16876
  return null;
16572
16877
  }
16573
16878
  function getCalleeLeftmostIdentifier(callee) {
16574
- if (ts16.isParenthesizedExpression(callee))
16879
+ if (ts17.isParenthesizedExpression(callee))
16575
16880
  return getCalleeLeftmostIdentifier(callee.expression);
16576
- if (ts16.isIdentifier(callee))
16881
+ if (ts17.isIdentifier(callee))
16577
16882
  return callee.text;
16578
- if (ts16.isPropertyAccessExpression(callee)) {
16883
+ if (ts17.isPropertyAccessExpression(callee)) {
16579
16884
  return getCalleeLeftmostIdentifier(callee.expression);
16580
16885
  }
16581
16886
  return null;
@@ -16623,12 +16928,12 @@ function isCallAcceptedByAdapter(call, env) {
16623
16928
  }
16624
16929
  function parseExpressionNode(text) {
16625
16930
  try {
16626
- 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);
16627
16932
  const stmt = sf.statements[0];
16628
- if (!stmt || !ts16.isExpressionStatement(stmt))
16933
+ if (!stmt || !ts17.isExpressionStatement(stmt))
16629
16934
  return null;
16630
16935
  const inner = stmt.expression;
16631
- return ts16.isParenthesizedExpression(inner) ? inner.expression : inner;
16936
+ return ts17.isParenthesizedExpression(inner) ? inner.expression : inner;
16632
16937
  } catch {
16633
16938
  return null;
16634
16939
  }
@@ -16645,8 +16950,8 @@ function hasCallWithBridgedArg(node, decisions, env) {
16645
16950
  function visit3(n) {
16646
16951
  if (found)
16647
16952
  return;
16648
- if (ts16.isCallExpression(n) || ts16.isNewExpression(n)) {
16649
- 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);
16650
16955
  if (!accepted) {
16651
16956
  const args = n.arguments;
16652
16957
  if (args) {
@@ -16659,7 +16964,7 @@ function hasCallWithBridgedArg(node, decisions, env) {
16659
16964
  }
16660
16965
  }
16661
16966
  }
16662
- ts16.forEachChild(n, visit3);
16967
+ ts17.forEachChild(n, visit3);
16663
16968
  }
16664
16969
  visit3(node);
16665
16970
  return found;
@@ -16669,13 +16974,13 @@ function hasZeroArgCall(node, env) {
16669
16974
  function visit3(n) {
16670
16975
  if (found)
16671
16976
  return;
16672
- if (ts16.isCallExpression(n) && n.arguments.length === 0) {
16977
+ if (ts17.isCallExpression(n) && n.arguments.length === 0) {
16673
16978
  if (!isCallAcceptedByAdapter(n, env)) {
16674
16979
  found = true;
16675
16980
  return;
16676
16981
  }
16677
16982
  }
16678
- ts16.forEachChild(n, visit3);
16983
+ ts17.forEachChild(n, visit3);
16679
16984
  }
16680
16985
  visit3(node);
16681
16986
  return found;
@@ -16685,25 +16990,25 @@ function containsAnyIdentifier(node, names) {
16685
16990
  function visit3(n) {
16686
16991
  if (found)
16687
16992
  return;
16688
- if (ts16.isPropertyAccessExpression(n)) {
16993
+ if (ts17.isPropertyAccessExpression(n)) {
16689
16994
  visit3(n.expression);
16690
16995
  return;
16691
16996
  }
16692
- if (ts16.isPropertyAssignment(n)) {
16997
+ if (ts17.isPropertyAssignment(n)) {
16693
16998
  visit3(n.initializer);
16694
16999
  return;
16695
17000
  }
16696
- if (ts16.isShorthandPropertyAssignment(n)) {
16697
- 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)) {
16698
17003
  found = true;
16699
17004
  }
16700
17005
  return;
16701
17006
  }
16702
- if (ts16.isIdentifier(n) && names.has(n.text)) {
17007
+ if (ts17.isIdentifier(n) && names.has(n.text)) {
16703
17008
  found = true;
16704
17009
  return;
16705
17010
  }
16706
- ts16.forEachChild(n, visit3);
17011
+ ts17.forEachChild(n, visit3);
16707
17012
  }
16708
17013
  visit3(node);
16709
17014
  return found;
@@ -18014,23 +18319,23 @@ function resolveFinalImports(generatedCode, ir, localImportPrefixes) {
18014
18319
  }
18015
18320
 
18016
18321
  // src/ir-to-client-js/prune-unused-prop-extractions.ts
18017
- import ts17 from "typescript";
18322
+ import ts18 from "typescript";
18018
18323
  function propExtractionName(stmt) {
18019
- if (!ts17.isVariableStatement(stmt))
18324
+ if (!ts18.isVariableStatement(stmt))
18020
18325
  return null;
18021
18326
  const decls = stmt.declarationList.declarations;
18022
18327
  if (decls.length !== 1)
18023
18328
  return null;
18024
18329
  const decl = decls[0];
18025
- if (!ts17.isIdentifier(decl.name) || !decl.initializer)
18330
+ if (!ts18.isIdentifier(decl.name) || !decl.initializer)
18026
18331
  return null;
18027
18332
  let core = decl.initializer;
18028
- if (ts17.isBinaryExpression(core) && core.operatorToken.kind === ts17.SyntaxKind.QuestionQuestionToken) {
18333
+ if (ts18.isBinaryExpression(core) && core.operatorToken.kind === ts18.SyntaxKind.QuestionQuestionToken) {
18029
18334
  core = core.left;
18030
18335
  }
18031
- if (!ts17.isPropertyAccessExpression(core))
18336
+ if (!ts18.isPropertyAccessExpression(core))
18032
18337
  return null;
18033
- if (!ts17.isIdentifier(core.expression) || core.expression.text !== PROPS_PARAM)
18338
+ if (!ts18.isIdentifier(core.expression) || core.expression.text !== PROPS_PARAM)
18034
18339
  return null;
18035
18340
  if (core.name.text !== decl.name.text)
18036
18341
  return null;
@@ -18043,10 +18348,10 @@ function pruneUnusedPropExtractions(code) {
18043
18348
  console.warn("[barefootjs] pruneUnusedPropExtractions: generated code did not parse; skipping prune");
18044
18349
  return code;
18045
18350
  }
18046
- 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);
18047
18352
  const spans = [];
18048
18353
  for (const stmt of sourceFile.statements) {
18049
- if (!ts17.isFunctionDeclaration(stmt) || !stmt.name?.text.startsWith("init") || !stmt.body)
18354
+ if (!ts18.isFunctionDeclaration(stmt) || !stmt.name?.text.startsWith("init") || !stmt.body)
18050
18355
  continue;
18051
18356
  for (const inner of stmt.body.statements) {
18052
18357
  const name = propExtractionName(inner);
@@ -19507,7 +19812,7 @@ function analyzeLazyConditional(cond, indexParam, arms) {
19507
19812
  }
19508
19813
 
19509
19814
  // src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
19510
- import ts18 from "typescript";
19815
+ import ts19 from "typescript";
19511
19816
  var NO_PREAMBLE = {
19512
19817
  lazySafe: true,
19513
19818
  facts: { declaredNames: new Set, freeNames: new Set }
@@ -19527,12 +19832,12 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19527
19832
  if (text.trim().length === 0)
19528
19833
  return NO_PREAMBLE;
19529
19834
  const declaredNames = new Set;
19530
- 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);
19531
19836
  for (const stmt of sf.statements) {
19532
- if (!ts18.isVariableStatement(stmt)) {
19533
- 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]})`);
19534
19839
  }
19535
- const isConst = (stmt.declarationList.flags & ts18.NodeFlags.Const) !== 0;
19840
+ const isConst = (stmt.declarationList.flags & ts19.NodeFlags.Const) !== 0;
19536
19841
  if (!isConst)
19537
19842
  return NO2("map-callback preamble declares a mutable binding (let/var)");
19538
19843
  for (const decl of stmt.declarationList.declarations) {
@@ -19561,12 +19866,12 @@ function analyzeLazyPreamble(preamble, indexParam, primableNames) {
19561
19866
  return { lazySafe: true, facts: { declaredNames, freeNames } };
19562
19867
  }
19563
19868
  function collectBindingNames3(name, out) {
19564
- if (ts18.isIdentifier(name)) {
19869
+ if (ts19.isIdentifier(name)) {
19565
19870
  out.add(name.text);
19566
19871
  return;
19567
19872
  }
19568
19873
  for (const element of name.elements) {
19569
- if (ts18.isOmittedExpression(element))
19874
+ if (ts19.isOmittedExpression(element))
19570
19875
  continue;
19571
19876
  collectBindingNames3(element.name, out);
19572
19877
  }
@@ -19576,56 +19881,56 @@ function findImpureNode(root, primableNames) {
19576
19881
  const visit3 = (node) => {
19577
19882
  if (found)
19578
19883
  return;
19579
- if (ts18.isCallExpression(node)) {
19884
+ if (ts19.isCallExpression(node)) {
19580
19885
  const callee = node.expression;
19581
- 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;
19582
19887
  if (!isSignalRead) {
19583
19888
  found = `call to ${callee.getText(callee.getSourceFile())}`;
19584
19889
  return;
19585
19890
  }
19586
19891
  }
19587
- if (ts18.isNewExpression(node)) {
19892
+ if (ts19.isNewExpression(node)) {
19588
19893
  found = "new expression";
19589
19894
  return;
19590
19895
  }
19591
- if (ts18.isTaggedTemplateExpression(node)) {
19896
+ if (ts19.isTaggedTemplateExpression(node)) {
19592
19897
  found = "tagged template";
19593
19898
  return;
19594
19899
  }
19595
- if (ts18.isAwaitExpression(node)) {
19900
+ if (ts19.isAwaitExpression(node)) {
19596
19901
  found = "await";
19597
19902
  return;
19598
19903
  }
19599
- if (ts18.isYieldExpression(node)) {
19904
+ if (ts19.isYieldExpression(node)) {
19600
19905
  found = "yield";
19601
19906
  return;
19602
19907
  }
19603
- if (ts18.isPrefixUnaryExpression(node) || ts18.isPostfixUnaryExpression(node)) {
19908
+ if (ts19.isPrefixUnaryExpression(node) || ts19.isPostfixUnaryExpression(node)) {
19604
19909
  const op = node.operator;
19605
- if (op === ts18.SyntaxKind.PlusPlusToken || op === ts18.SyntaxKind.MinusMinusToken) {
19910
+ if (op === ts19.SyntaxKind.PlusPlusToken || op === ts19.SyntaxKind.MinusMinusToken) {
19606
19911
  found = "increment/decrement";
19607
19912
  return;
19608
19913
  }
19609
19914
  }
19610
- if (ts18.isDeleteExpression(node)) {
19915
+ if (ts19.isDeleteExpression(node)) {
19611
19916
  found = "delete";
19612
19917
  return;
19613
19918
  }
19614
- if (ts18.isFunctionExpression(node) || ts18.isArrowFunction(node) || ts18.isClassExpression(node)) {
19919
+ if (ts19.isFunctionExpression(node) || ts19.isArrowFunction(node) || ts19.isClassExpression(node)) {
19615
19920
  found = "function or class expression";
19616
19921
  return;
19617
19922
  }
19618
- if (ts18.isBinaryExpression(node) && isAssignmentOperator2(node.operatorToken.kind)) {
19923
+ if (ts19.isBinaryExpression(node) && isAssignmentOperator2(node.operatorToken.kind)) {
19619
19924
  found = "assignment";
19620
19925
  return;
19621
19926
  }
19622
- ts18.forEachChild(node, visit3);
19927
+ ts19.forEachChild(node, visit3);
19623
19928
  };
19624
19929
  visit3(root);
19625
19930
  return found;
19626
19931
  }
19627
19932
  function isAssignmentOperator2(kind) {
19628
- return kind >= ts18.SyntaxKind.FirstAssignment && kind <= ts18.SyntaxKind.LastAssignment;
19933
+ return kind >= ts19.SyntaxKind.FirstAssignment && kind <= ts19.SyntaxKind.LastAssignment;
19629
19934
  }
19630
19935
 
19631
19936
  // src/ir-to-client-js/control-flow/plan/lazy-row-eligibility.ts
@@ -20155,7 +20460,7 @@ function buildArmBody(branch, options) {
20155
20460
  }
20156
20461
 
20157
20462
  // src/ir-to-client-js/emit-reactive.ts
20158
- import ts19 from "typescript";
20463
+ import ts20 from "typescript";
20159
20464
 
20160
20465
  // src/ir-to-client-js/control-flow/stringify/claim-plan.ts
20161
20466
  function slotSpecLiteral(slot) {
@@ -20267,20 +20572,20 @@ function lowerToLocaleCallsInReactiveExpr(expr, matcher) {
20267
20572
  return expr;
20268
20573
  let sourceFile;
20269
20574
  try {
20270
- 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);
20271
20576
  } catch {
20272
20577
  return expr;
20273
20578
  }
20274
20579
  const stmt = sourceFile.statements[0];
20275
- if (!stmt || !ts19.isExpressionStatement(stmt))
20580
+ if (!stmt || !ts20.isExpressionStatement(stmt))
20276
20581
  return expr;
20277
- const root = ts19.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20582
+ const root = ts20.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20278
20583
  const candidates = [];
20279
20584
  const visit3 = (n) => {
20280
- 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") {
20281
20586
  candidates.push(n);
20282
20587
  }
20283
- ts19.forEachChild(n, visit3);
20588
+ ts20.forEachChild(n, visit3);
20284
20589
  };
20285
20590
  visit3(root);
20286
20591
  if (candidates.length === 0)
@@ -20316,20 +20621,20 @@ function lowerDateCallsInReactiveExpr(expr, matcher) {
20316
20621
  return expr;
20317
20622
  let sourceFile;
20318
20623
  try {
20319
- 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);
20320
20625
  } catch {
20321
20626
  return expr;
20322
20627
  }
20323
20628
  const stmt = sourceFile.statements[0];
20324
- if (!stmt || !ts19.isExpressionStatement(stmt))
20629
+ if (!stmt || !ts20.isExpressionStatement(stmt))
20325
20630
  return expr;
20326
- const root = ts19.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20631
+ const root = ts20.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
20327
20632
  const candidates = [];
20328
20633
  const visit3 = (n) => {
20329
- 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)) {
20330
20635
  candidates.push(n);
20331
20636
  }
20332
- ts19.forEachChild(n, visit3);
20637
+ ts20.forEachChild(n, visit3);
20333
20638
  };
20334
20639
  visit3(root);
20335
20640
  if (candidates.length === 0)
@@ -20591,7 +20896,7 @@ function stringifyBranchInnerLoops(lines, plan, indent, pc) {
20591
20896
  stringifyLoopChildConditionals(lines, inner.nestedConditionals, `${indent} `, pc);
20592
20897
  }
20593
20898
  lines.push(`${indent} return __bel${uid}`);
20594
- lines.push(`${indent}}, '${inner.markerId}'${profileBindingId(pc, inner.slotId)}) }`);
20899
+ lines.push(`${indent}}, '${inner.markerId}'${mapArrayKeyArgs(profileBindingId(pc, inner.slotId), !!inner.wrappedKey, inner.keyDepth)}) }`);
20595
20900
  }
20596
20901
  }
20597
20902
  function stringifyLoopChildConditionals(lines, conditionals, indent, pc) {
@@ -21440,7 +21745,7 @@ function emitReactive(lines, inner, indent, pc) {
21440
21745
  bodyIsMultiRoot: emit.bodyIsMultiRoot
21441
21746
  });
21442
21747
  lines.push(`${indent} return __innerEl${uid}`);
21443
- lines.push(`${indent}}, '${inner.markerId}'${profileBindingId(pc, inner.slotId)}) }`);
21748
+ lines.push(`${indent}}, '${inner.markerId}'${mapArrayKeyArgs(profileBindingId(pc, inner.slotId), !!emit.wrappedKey, inner.keyDepth)}) }`);
21444
21749
  }
21445
21750
  function emitStatic(lines, inner, indent, pc) {
21446
21751
  const uid = inner.uidSuffix;
@@ -22350,7 +22655,7 @@ var PHASES = [
22350
22655
  ];
22351
22656
 
22352
22657
  // src/ir-to-client-js/rewrite-props-object.ts
22353
- import ts20 from "typescript";
22658
+ import ts21 from "typescript";
22354
22659
  function rewritePropsObjectRef(code, propsObjectName, restPropsName = null) {
22355
22660
  let result = code;
22356
22661
  const seen = new Set;
@@ -22365,13 +22670,13 @@ function rewritePropsObjectRef(code, propsObjectName, restPropsName = null) {
22365
22670
  function rewriteOneName(code, srcPropsName) {
22366
22671
  if (!identifierPattern(srcPropsName).test(code))
22367
22672
  return code;
22368
- 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);
22369
22674
  const spans = [];
22370
22675
  function visit3(node) {
22371
- if (ts20.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
22676
+ if (ts21.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
22372
22677
  spans.push([node.getStart(sourceFile), node.getEnd()]);
22373
22678
  }
22374
- ts20.forEachChild(node, visit3);
22679
+ ts21.forEachChild(node, visit3);
22375
22680
  }
22376
22681
  visit3(sourceFile);
22377
22682
  if (spans.length === 0)
@@ -22387,17 +22692,17 @@ function shouldRewrite(node) {
22387
22692
  const parent = node.parent;
22388
22693
  if (!parent)
22389
22694
  return true;
22390
- if (ts20.isPropertyAccessExpression(parent) && parent.name === node)
22695
+ if (ts21.isPropertyAccessExpression(parent) && parent.name === node)
22391
22696
  return false;
22392
- if (ts20.isPropertyAssignment(parent) && parent.name === node)
22697
+ if (ts21.isPropertyAssignment(parent) && parent.name === node)
22393
22698
  return false;
22394
- if (ts20.isShorthandPropertyAssignment(parent) && parent.name === node)
22699
+ if (ts21.isShorthandPropertyAssignment(parent) && parent.name === node)
22395
22700
  return false;
22396
- if (ts20.isPropertySignature(parent) && parent.name === node)
22701
+ if (ts21.isPropertySignature(parent) && parent.name === node)
22397
22702
  return false;
22398
- if (ts20.isPropertyDeclaration(parent) && parent.name === node)
22703
+ if (ts21.isPropertyDeclaration(parent) && parent.name === node)
22399
22704
  return false;
22400
- if (ts20.isBindingElement(parent) && parent.name === node)
22705
+ if (ts21.isBindingElement(parent) && parent.name === node)
22401
22706
  return false;
22402
22707
  return true;
22403
22708
  }
@@ -22709,7 +23014,7 @@ function createContext(ir, scope, adapterCapabilities, profile) {
22709
23014
  };
22710
23015
  }
22711
23016
  function needsClientJs(ctx) {
22712
- 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)
22713
23018
  return true;
22714
23019
  return hasInitScopeOnlyConstant(ctx);
22715
23020
  }
@@ -23047,7 +23352,7 @@ function walkIR2(node, visitor) {
23047
23352
  }
23048
23353
 
23049
23354
  // src/preprocess-inline-jsx-callbacks.ts
23050
- import ts21 from "typescript";
23355
+ import ts22 from "typescript";
23051
23356
  var SYNTHETIC_PREFIX = "BFInlineJsxCallback";
23052
23357
  var MAX_FIXPOINT_ITERATIONS = 16;
23053
23358
  function preprocessInlineJsxCallbacks(source, filePath) {
@@ -23069,8 +23374,8 @@ function preprocessInlineJsxCallbacks(source, filePath) {
23069
23374
  return { source: current, errors, syntheticNames };
23070
23375
  }
23071
23376
  function runSinglePass(source, filePath, startingCounter) {
23072
- const sourceFile = ts21.createSourceFile(filePath, source, ts21.ScriptTarget.Latest, true, ts21.ScriptKind.TSX);
23073
- 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'"));
23074
23379
  if (!hasUseClient) {
23075
23380
  return { source, errors: [], syntheticNames: [], counterAfter: startingCounter };
23076
23381
  }
@@ -23092,22 +23397,22 @@ function runSinglePass(source, filePath, startingCounter) {
23092
23397
  }
23093
23398
  }
23094
23399
  function visit3(node) {
23095
- 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) {
23096
23401
  if (tryHandleArrowValue(node.initializer.expression)) {
23097
23402
  return;
23098
23403
  }
23099
23404
  }
23100
- if (ts21.isPropertyAssignment(node) && node.initializer) {
23405
+ if (ts22.isPropertyAssignment(node) && node.initializer) {
23101
23406
  if (tryHandleArrowValue(node.initializer))
23102
23407
  return;
23103
23408
  }
23104
- ts21.forEachChild(node, visit3);
23409
+ ts22.forEachChild(node, visit3);
23105
23410
  }
23106
23411
  function tryHandleArrowValue(initializer) {
23107
23412
  let expr = initializer;
23108
- while (ts21.isParenthesizedExpression(expr))
23413
+ while (ts22.isParenthesizedExpression(expr))
23109
23414
  expr = expr.expression;
23110
- if (ts21.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
23415
+ if (ts22.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
23111
23416
  return handleInlineArrow(expr);
23112
23417
  }
23113
23418
  return false;
@@ -23144,7 +23449,7 @@ function runSinglePass(source, filePath, startingCounter) {
23144
23449
  replacements.push({ start: arrowStart, end: arrowEnd, text: name });
23145
23450
  return true;
23146
23451
  }
23147
- ts21.forEachChild(sourceFile, visit3);
23452
+ ts22.forEachChild(sourceFile, visit3);
23148
23453
  if (replacements.length === 0) {
23149
23454
  return { source, errors, syntheticNames, counterAfter: counter };
23150
23455
  }
@@ -23167,11 +23472,11 @@ function errorMessageForCapture(captures) {
23167
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.`;
23168
23473
  }
23169
23474
  function arrowBodyContainsJsx(arrow) {
23170
- if (ts21.isBlock(arrow.body)) {
23475
+ if (ts22.isBlock(arrow.body)) {
23171
23476
  return blockReturnsJsx(arrow.body);
23172
23477
  }
23173
23478
  let body = arrow.body;
23174
- while (ts21.isParenthesizedExpression(body))
23479
+ while (ts22.isParenthesizedExpression(body))
23175
23480
  body = body.expression;
23176
23481
  return isJsxLike(body);
23177
23482
  }
@@ -23180,24 +23485,24 @@ function blockReturnsJsx(block) {
23180
23485
  function visit3(n) {
23181
23486
  if (found)
23182
23487
  return;
23183
- if (ts21.isReturnStatement(n) && n.expression) {
23488
+ if (ts22.isReturnStatement(n) && n.expression) {
23184
23489
  let e = n.expression;
23185
- while (ts21.isParenthesizedExpression(e))
23490
+ while (ts22.isParenthesizedExpression(e))
23186
23491
  e = e.expression;
23187
23492
  if (isJsxLike(e)) {
23188
23493
  found = true;
23189
23494
  return;
23190
23495
  }
23191
23496
  }
23192
- if (ts21.isArrowFunction(n) || ts21.isFunctionDeclaration(n) || ts21.isFunctionExpression(n))
23497
+ if (ts22.isArrowFunction(n) || ts22.isFunctionDeclaration(n) || ts22.isFunctionExpression(n))
23193
23498
  return;
23194
- ts21.forEachChild(n, visit3);
23499
+ ts22.forEachChild(n, visit3);
23195
23500
  }
23196
- ts21.forEachChild(block, visit3);
23501
+ ts22.forEachChild(block, visit3);
23197
23502
  return found;
23198
23503
  }
23199
23504
  function isJsxLike(expr) {
23200
- return ts21.isJsxElement(expr) || ts21.isJsxSelfClosingElement(expr) || ts21.isJsxFragment(expr);
23505
+ return ts22.isJsxElement(expr) || ts22.isJsxSelfClosingElement(expr) || ts22.isJsxFragment(expr);
23201
23506
  }
23202
23507
  function collectArrowParamNames(arrow) {
23203
23508
  const names = new Set;
@@ -23207,13 +23512,13 @@ function collectArrowParamNames(arrow) {
23207
23512
  }
23208
23513
  function collectBindingNames4(name, out) {
23209
23514
  const push = Array.isArray(out) ? (n) => out.push(n) : (n) => out.add(n);
23210
- if (ts21.isIdentifier(name)) {
23515
+ if (ts22.isIdentifier(name)) {
23211
23516
  push(name.text);
23212
- } else if (ts21.isObjectBindingPattern(name)) {
23517
+ } else if (ts22.isObjectBindingPattern(name)) {
23213
23518
  name.elements.forEach((el) => collectBindingNames4(el.name, out));
23214
- } else if (ts21.isArrayBindingPattern(name)) {
23519
+ } else if (ts22.isArrayBindingPattern(name)) {
23215
23520
  name.elements.forEach((el) => {
23216
- if (!ts21.isOmittedExpression(el))
23521
+ if (!ts22.isOmittedExpression(el))
23217
23522
  collectBindingNames4(el.name, out);
23218
23523
  });
23219
23524
  }
@@ -23240,48 +23545,48 @@ function collectFreeIdentifiers(arrow) {
23240
23545
  return bound.includes(name);
23241
23546
  }
23242
23547
  function visit3(node) {
23243
- if (ts21.isIdentifier(node)) {
23548
+ if (ts22.isIdentifier(node)) {
23244
23549
  const parent = node.parent;
23245
- if (parent && ts21.isPropertyAccessExpression(parent) && parent.name === node)
23550
+ if (parent && ts22.isPropertyAccessExpression(parent) && parent.name === node)
23246
23551
  return;
23247
- if (parent && ts21.isPropertyAssignment(parent) && parent.name === node)
23552
+ if (parent && ts22.isPropertyAssignment(parent) && parent.name === node)
23248
23553
  return;
23249
- if (parent && ts21.isPropertySignature(parent) && parent.name === node)
23554
+ if (parent && ts22.isPropertySignature(parent) && parent.name === node)
23250
23555
  return;
23251
- if (parent && ts21.isPropertyDeclaration(parent) && parent.name === node)
23556
+ if (parent && ts22.isPropertyDeclaration(parent) && parent.name === node)
23252
23557
  return;
23253
- if (parent && ts21.isMethodDeclaration(parent) && parent.name === node)
23558
+ if (parent && ts22.isMethodDeclaration(parent) && parent.name === node)
23254
23559
  return;
23255
- if (parent && ts21.isMethodSignature(parent) && parent.name === node)
23560
+ if (parent && ts22.isMethodSignature(parent) && parent.name === node)
23256
23561
  return;
23257
- if (parent && ts21.isGetAccessorDeclaration(parent) && parent.name === node)
23562
+ if (parent && ts22.isGetAccessorDeclaration(parent) && parent.name === node)
23258
23563
  return;
23259
- if (parent && ts21.isSetAccessorDeclaration(parent) && parent.name === node)
23564
+ if (parent && ts22.isSetAccessorDeclaration(parent) && parent.name === node)
23260
23565
  return;
23261
- if (parent && ts21.isEnumMember(parent) && parent.name === node)
23566
+ if (parent && ts22.isEnumMember(parent) && parent.name === node)
23262
23567
  return;
23263
- if (parent && ts21.isBindingElement(parent) && parent.propertyName === node)
23568
+ if (parent && ts22.isBindingElement(parent) && parent.propertyName === node)
23264
23569
  return;
23265
- if (parent && ts21.isShorthandPropertyAssignment(parent) && parent.name === node) {
23570
+ if (parent && ts22.isShorthandPropertyAssignment(parent) && parent.name === node) {
23266
23571
  if (!isBound(node.text))
23267
23572
  ids.add(node.text);
23268
23573
  return;
23269
23574
  }
23270
- if (parent && ts21.isParameter(parent) && parent.name === node)
23575
+ if (parent && ts22.isParameter(parent) && parent.name === node)
23271
23576
  return;
23272
- if (parent && ts21.isVariableDeclaration(parent) && parent.name === node)
23577
+ if (parent && ts22.isVariableDeclaration(parent) && parent.name === node)
23273
23578
  return;
23274
- if (parent && ts21.isFunctionDeclaration(parent) && parent.name === node)
23579
+ if (parent && ts22.isFunctionDeclaration(parent) && parent.name === node)
23275
23580
  return;
23276
- if (parent && ts21.isClassDeclaration(parent) && parent.name === node)
23581
+ if (parent && ts22.isClassDeclaration(parent) && parent.name === node)
23277
23582
  return;
23278
- if (parent && ts21.isJsxAttribute(parent) && parent.name === node)
23583
+ if (parent && ts22.isJsxAttribute(parent) && parent.name === node)
23279
23584
  return;
23280
- if (parent && ts21.isJsxOpeningElement(parent) && parent.tagName === node) {
23585
+ if (parent && ts22.isJsxOpeningElement(parent) && parent.tagName === node) {
23281
23586
  if (/^[a-z]/.test(node.text))
23282
23587
  return;
23283
23588
  }
23284
- if (parent && ts21.isJsxClosingElement(parent) && parent.tagName === node) {
23589
+ if (parent && ts22.isJsxClosingElement(parent) && parent.tagName === node) {
23285
23590
  if (/^[a-z]/.test(node.text))
23286
23591
  return;
23287
23592
  }
@@ -23290,43 +23595,43 @@ function collectFreeIdentifiers(arrow) {
23290
23595
  ids.add(node.text);
23291
23596
  return;
23292
23597
  }
23293
- if (ts21.isVariableDeclaration(node)) {
23598
+ if (ts22.isVariableDeclaration(node)) {
23294
23599
  const declared = pushBindings(node.name);
23295
23600
  if (node.initializer)
23296
23601
  visit3(node.initializer);
23297
23602
  return;
23298
23603
  }
23299
- if (ts21.isFunctionDeclaration(node)) {
23604
+ if (ts22.isFunctionDeclaration(node)) {
23300
23605
  if (node.name)
23301
23606
  bound.push(node.name.text);
23302
23607
  visitInsideNewScope(node);
23303
23608
  return;
23304
23609
  }
23305
- if (ts21.isClassDeclaration(node)) {
23610
+ if (ts22.isClassDeclaration(node)) {
23306
23611
  if (node.name)
23307
23612
  bound.push(node.name.text);
23308
- ts21.forEachChild(node, visit3);
23613
+ ts22.forEachChild(node, visit3);
23309
23614
  return;
23310
23615
  }
23311
- if (ts21.isArrowFunction(node) || ts21.isFunctionExpression(node)) {
23616
+ if (ts22.isArrowFunction(node) || ts22.isFunctionExpression(node)) {
23312
23617
  visitInsideNewScope(node);
23313
23618
  return;
23314
23619
  }
23315
- if (ts21.isCatchClause(node)) {
23620
+ if (ts22.isCatchClause(node)) {
23316
23621
  const before = bound.length;
23317
23622
  if (node.variableDeclaration)
23318
23623
  pushBindings(node.variableDeclaration.name);
23319
- ts21.forEachChild(node, visit3);
23624
+ ts22.forEachChild(node, visit3);
23320
23625
  popN(bound.length - before);
23321
23626
  return;
23322
23627
  }
23323
- if (ts21.isBlock(node)) {
23628
+ if (ts22.isBlock(node)) {
23324
23629
  const before = bound.length;
23325
- ts21.forEachChild(node, visit3);
23630
+ ts22.forEachChild(node, visit3);
23326
23631
  popN(bound.length - before);
23327
23632
  return;
23328
23633
  }
23329
- ts21.forEachChild(node, visit3);
23634
+ ts22.forEachChild(node, visit3);
23330
23635
  }
23331
23636
  function visitInsideNewScope(fn) {
23332
23637
  const before = bound.length;
@@ -23349,29 +23654,29 @@ function collectFreeIdentifiers(arrow) {
23349
23654
  function collectModuleScopeNames(sourceFile) {
23350
23655
  const names = new Set;
23351
23656
  for (const stmt of sourceFile.statements) {
23352
- if (ts21.isFunctionDeclaration(stmt) && stmt.name)
23657
+ if (ts22.isFunctionDeclaration(stmt) && stmt.name)
23353
23658
  names.add(stmt.name.text);
23354
- else if (ts21.isClassDeclaration(stmt) && stmt.name)
23659
+ else if (ts22.isClassDeclaration(stmt) && stmt.name)
23355
23660
  names.add(stmt.name.text);
23356
- else if (ts21.isVariableStatement(stmt)) {
23661
+ else if (ts22.isVariableStatement(stmt)) {
23357
23662
  for (const decl of stmt.declarationList.declarations)
23358
23663
  collectBindingNames4(decl.name, names);
23359
- } else if (ts21.isImportDeclaration(stmt) && stmt.importClause) {
23664
+ } else if (ts22.isImportDeclaration(stmt) && stmt.importClause) {
23360
23665
  const ic = stmt.importClause;
23361
23666
  if (ic.name)
23362
23667
  names.add(ic.name.text);
23363
23668
  if (ic.namedBindings) {
23364
- if (ts21.isNamespaceImport(ic.namedBindings))
23669
+ if (ts22.isNamespaceImport(ic.namedBindings))
23365
23670
  names.add(ic.namedBindings.name.text);
23366
23671
  else
23367
23672
  for (const e of ic.namedBindings.elements)
23368
23673
  names.add(e.name.text);
23369
23674
  }
23370
- } else if (ts21.isTypeAliasDeclaration(stmt))
23675
+ } else if (ts22.isTypeAliasDeclaration(stmt))
23371
23676
  names.add(stmt.name.text);
23372
- else if (ts21.isInterfaceDeclaration(stmt))
23677
+ else if (ts22.isInterfaceDeclaration(stmt))
23373
23678
  names.add(stmt.name.text);
23374
- else if (ts21.isEnumDeclaration(stmt))
23679
+ else if (ts22.isEnumDeclaration(stmt))
23375
23680
  names.add(stmt.name.text);
23376
23681
  }
23377
23682
  return names;
@@ -23379,7 +23684,7 @@ function collectModuleScopeNames(sourceFile) {
23379
23684
  function buildSyntheticDeclaration(name, arrow, sourceFile) {
23380
23685
  const paramsText = arrow.parameters.length === 0 ? "" : arrow.parameters.map((p) => p.getText(sourceFile)).join(", ");
23381
23686
  let bodyText;
23382
- if (ts21.isBlock(arrow.body)) {
23687
+ if (ts22.isBlock(arrow.body)) {
23383
23688
  bodyText = arrow.body.getText(sourceFile);
23384
23689
  } else {
23385
23690
  const expr = arrow.body.getText(sourceFile);
@@ -23389,7 +23694,7 @@ function buildSyntheticDeclaration(name, arrow, sourceFile) {
23389
23694
  }
23390
23695
 
23391
23696
  // src/ssr-defaults.ts
23392
- import ts22 from "typescript";
23697
+ import ts23 from "typescript";
23393
23698
  function deriveStashFromDefaults(defaults, props) {
23394
23699
  const extra = {};
23395
23700
  for (const [name, d] of Object.entries(defaults)) {
@@ -23512,11 +23817,11 @@ function collectPropRefs(expr, propsObjectName, out) {
23512
23817
  if (!node)
23513
23818
  return;
23514
23819
  const visit3 = (n) => {
23515
- 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)) {
23516
23821
  out.add(n.name.text);
23517
23822
  return;
23518
23823
  }
23519
- ts22.forEachChild(n, visit3);
23824
+ ts23.forEachChild(n, visit3);
23520
23825
  };
23521
23826
  visit3(node);
23522
23827
  }
@@ -23554,23 +23859,23 @@ function tryStaticEval(expr, ctx) {
23554
23859
  }
23555
23860
  function evalStatementsForReturn(statements, ctx) {
23556
23861
  for (const stmt of statements) {
23557
- if (ts22.isVariableStatement(stmt)) {
23862
+ if (ts23.isVariableStatement(stmt)) {
23558
23863
  for (const d of stmt.declarationList.declarations) {
23559
- if (!ts22.isIdentifier(d.name) || !d.initializer)
23864
+ if (!ts23.isIdentifier(d.name) || !d.initializer)
23560
23865
  continue;
23561
23866
  const v = evalNode(d.initializer, ctx);
23562
23867
  if (v !== UNRESOLVED)
23563
23868
  ctx.bindings[d.name.text] = v;
23564
23869
  }
23565
- } else if (ts22.isReturnStatement(stmt)) {
23870
+ } else if (ts23.isReturnStatement(stmt)) {
23566
23871
  return stmt.expression ? evalNode(stmt.expression, ctx) : UNRESOLVED;
23567
- } else if (ts22.isIfStatement(stmt)) {
23872
+ } else if (ts23.isIfStatement(stmt)) {
23568
23873
  const cond = evalNode(stmt.expression, ctx);
23569
23874
  if (cond === UNRESOLVED)
23570
23875
  return UNRESOLVED;
23571
23876
  const branch = cond ? stmt.thenStatement : stmt.elseStatement;
23572
23877
  if (branch) {
23573
- const taken = evalStatementsForReturn(ts22.isBlock(branch) ? branch.statements : [branch], ctx);
23878
+ const taken = evalStatementsForReturn(ts23.isBlock(branch) ? branch.statements : [branch], ctx);
23574
23879
  if (taken !== NO_RETURN)
23575
23880
  return taken;
23576
23881
  }
@@ -23581,45 +23886,45 @@ function evalStatementsForReturn(statements, ctx) {
23581
23886
  return NO_RETURN;
23582
23887
  }
23583
23888
  function parseExpression2(expr) {
23584
- 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);
23585
23890
  const stmt = sf.statements[0];
23586
- if (!stmt || !ts22.isExpressionStatement(stmt))
23891
+ if (!stmt || !ts23.isExpressionStatement(stmt))
23587
23892
  return null;
23588
- const inner = ts22.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
23893
+ const inner = ts23.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
23589
23894
  return inner;
23590
23895
  }
23591
23896
  function evalNode(node, ctx) {
23592
- if (ts22.isParenthesizedExpression(node))
23897
+ if (ts23.isParenthesizedExpression(node))
23593
23898
  return evalNode(node.expression, ctx);
23594
- if (ts22.isAsExpression(node))
23899
+ if (ts23.isAsExpression(node))
23595
23900
  return evalNode(node.expression, ctx);
23596
- if (ts22.isSatisfiesExpression(node))
23901
+ if (ts23.isSatisfiesExpression(node))
23597
23902
  return evalNode(node.expression, ctx);
23598
- if (ts22.isTypeAssertionExpression(node))
23903
+ if (ts23.isTypeAssertionExpression(node))
23599
23904
  return evalNode(node.expression, ctx);
23600
- if (ts22.isNonNullExpression(node))
23905
+ if (ts23.isNonNullExpression(node))
23601
23906
  return evalNode(node.expression, ctx);
23602
- if (ts22.isArrowFunction(node)) {
23907
+ if (ts23.isArrowFunction(node)) {
23603
23908
  if (node.parameters.length !== 0)
23604
23909
  return UNRESOLVED;
23605
- if (!ts22.isBlock(node.body))
23910
+ if (!ts23.isBlock(node.body))
23606
23911
  return evalNode(node.body, ctx);
23607
23912
  const localBindings = { ...ctx.bindings };
23608
23913
  const localCtx = { ...ctx, bindings: localBindings };
23609
23914
  const result = evalStatementsForReturn(node.body.statements, localCtx);
23610
23915
  return result === NO_RETURN ? UNRESOLVED : result;
23611
23916
  }
23612
- if (ts22.isNumericLiteral(node))
23917
+ if (ts23.isNumericLiteral(node))
23613
23918
  return Number(node.text);
23614
- if (ts22.isStringLiteralLike(node))
23919
+ if (ts23.isStringLiteralLike(node))
23615
23920
  return node.text;
23616
- if (node.kind === ts22.SyntaxKind.TrueKeyword)
23921
+ if (node.kind === ts23.SyntaxKind.TrueKeyword)
23617
23922
  return true;
23618
- if (node.kind === ts22.SyntaxKind.FalseKeyword)
23923
+ if (node.kind === ts23.SyntaxKind.FalseKeyword)
23619
23924
  return false;
23620
- if (node.kind === ts22.SyntaxKind.NullKeyword)
23925
+ if (node.kind === ts23.SyntaxKind.NullKeyword)
23621
23926
  return null;
23622
- if (ts22.isIdentifier(node)) {
23927
+ if (ts23.isIdentifier(node)) {
23623
23928
  if (node.text === "undefined")
23624
23929
  return;
23625
23930
  if (node.text in ctx.bindings)
@@ -23628,29 +23933,29 @@ function evalNode(node, ctx) {
23628
23933
  return;
23629
23934
  return UNRESOLVED;
23630
23935
  }
23631
- if (ts22.isPrefixUnaryExpression(node)) {
23936
+ if (ts23.isPrefixUnaryExpression(node)) {
23632
23937
  const arg = evalNode(node.operand, ctx);
23633
23938
  if (arg === UNRESOLVED)
23634
23939
  return UNRESOLVED;
23635
23940
  switch (node.operator) {
23636
- case ts22.SyntaxKind.MinusToken:
23941
+ case ts23.SyntaxKind.MinusToken:
23637
23942
  return typeof arg === "number" ? -arg : UNRESOLVED;
23638
- case ts22.SyntaxKind.PlusToken:
23943
+ case ts23.SyntaxKind.PlusToken:
23639
23944
  return typeof arg === "number" ? +arg : UNRESOLVED;
23640
- case ts22.SyntaxKind.ExclamationToken:
23945
+ case ts23.SyntaxKind.ExclamationToken:
23641
23946
  return !arg;
23642
23947
  }
23643
23948
  return UNRESOLVED;
23644
23949
  }
23645
- if (ts22.isObjectLiteralExpression(node)) {
23950
+ if (ts23.isObjectLiteralExpression(node)) {
23646
23951
  const obj = {};
23647
23952
  for (const prop of node.properties) {
23648
- if (!ts22.isPropertyAssignment(prop))
23953
+ if (!ts23.isPropertyAssignment(prop))
23649
23954
  return UNRESOLVED;
23650
23955
  let key;
23651
- if (ts22.isIdentifier(prop.name) || ts22.isStringLiteralLike(prop.name)) {
23956
+ if (ts23.isIdentifier(prop.name) || ts23.isStringLiteralLike(prop.name)) {
23652
23957
  key = prop.name.text;
23653
- } else if (ts22.isNumericLiteral(prop.name)) {
23958
+ } else if (ts23.isNumericLiteral(prop.name)) {
23654
23959
  key = prop.name.text;
23655
23960
  } else {
23656
23961
  return UNRESOLVED;
@@ -23662,10 +23967,10 @@ function evalNode(node, ctx) {
23662
23967
  }
23663
23968
  return obj;
23664
23969
  }
23665
- if (ts22.isArrayLiteralExpression(node)) {
23970
+ if (ts23.isArrayLiteralExpression(node)) {
23666
23971
  const arr = [];
23667
23972
  for (const elem of node.elements) {
23668
- if (ts22.isOmittedExpression(elem))
23973
+ if (ts23.isOmittedExpression(elem))
23669
23974
  return UNRESOLVED;
23670
23975
  const v = evalNode(elem, ctx);
23671
23976
  if (v === UNRESOLVED)
@@ -23674,7 +23979,7 @@ function evalNode(node, ctx) {
23674
23979
  }
23675
23980
  return arr;
23676
23981
  }
23677
- if (ts22.isElementAccessExpression(node)) {
23982
+ if (ts23.isElementAccessExpression(node)) {
23678
23983
  const base = evalNode(node.expression, ctx);
23679
23984
  if (base === undefined)
23680
23985
  return;
@@ -23688,7 +23993,7 @@ function evalNode(node, ctx) {
23688
23993
  const k = String(key);
23689
23994
  return Object.prototype.hasOwnProperty.call(base, k) ? base[k] : undefined;
23690
23995
  }
23691
- if (ts22.isPropertyAccessExpression(node)) {
23996
+ if (ts23.isPropertyAccessExpression(node)) {
23692
23997
  const baseResult = evalNode(node.expression, ctx);
23693
23998
  if (baseResult === undefined)
23694
23999
  return;
@@ -23701,13 +24006,13 @@ function evalNode(node, ctx) {
23701
24006
  const key = node.name.text;
23702
24007
  return Object.prototype.hasOwnProperty.call(baseResult, key) ? baseResult[key] : undefined;
23703
24008
  }
23704
- if (ts22.isCallExpression(node)) {
23705
- 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) {
23706
24011
  return ctx.bindings[node.expression.text];
23707
24012
  }
23708
- 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) {
23709
24014
  const arrow = node.arguments[0];
23710
- 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)) {
23711
24016
  const recv = evalNode(node.expression.expression, ctx);
23712
24017
  if (Array.isArray(recv)) {
23713
24018
  const paramName = arrow.parameters[0].name.text;
@@ -23724,7 +24029,7 @@ function evalNode(node, ctx) {
23724
24029
  }
23725
24030
  return UNRESOLVED;
23726
24031
  }
23727
- if (ts22.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
24032
+ if (ts23.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
23728
24033
  const recv = evalNode(node.expression.expression, ctx);
23729
24034
  if (Array.isArray(recv)) {
23730
24035
  let sep2 = ",";
@@ -23740,27 +24045,27 @@ function evalNode(node, ctx) {
23740
24045
  }
23741
24046
  return UNRESOLVED;
23742
24047
  }
23743
- if (ts22.isConditionalExpression(node)) {
24048
+ if (ts23.isConditionalExpression(node)) {
23744
24049
  const cond = evalNode(node.condition, ctx);
23745
24050
  if (cond === UNRESOLVED)
23746
24051
  return UNRESOLVED;
23747
24052
  return cond ? evalNode(node.whenTrue, ctx) : evalNode(node.whenFalse, ctx);
23748
24053
  }
23749
- if (ts22.isBinaryExpression(node)) {
24054
+ if (ts23.isBinaryExpression(node)) {
23750
24055
  const op = node.operatorToken.kind;
23751
- if (op === ts22.SyntaxKind.QuestionQuestionToken) {
24056
+ if (op === ts23.SyntaxKind.QuestionQuestionToken) {
23752
24057
  const l2 = evalNode(node.left, ctx);
23753
24058
  if (l2 !== UNRESOLVED && l2 !== null && l2 !== undefined)
23754
24059
  return l2;
23755
24060
  return evalNode(node.right, ctx);
23756
24061
  }
23757
- if (op === ts22.SyntaxKind.BarBarToken) {
24062
+ if (op === ts23.SyntaxKind.BarBarToken) {
23758
24063
  const l2 = evalNode(node.left, ctx);
23759
24064
  if (l2 !== UNRESOLVED && l2)
23760
24065
  return l2;
23761
24066
  return evalNode(node.right, ctx);
23762
24067
  }
23763
- if (op === ts22.SyntaxKind.AmpersandAmpersandToken) {
24068
+ if (op === ts23.SyntaxKind.AmpersandAmpersandToken) {
23764
24069
  const l2 = evalNode(node.left, ctx);
23765
24070
  if (l2 === UNRESOLVED)
23766
24071
  return UNRESOLVED;
@@ -23773,30 +24078,30 @@ function evalNode(node, ctx) {
23773
24078
  if (l === UNRESOLVED || r === UNRESOLVED)
23774
24079
  return UNRESOLVED;
23775
24080
  switch (op) {
23776
- case ts22.SyntaxKind.PlusToken:
24081
+ case ts23.SyntaxKind.PlusToken:
23777
24082
  if (typeof l === "string" || typeof r === "string")
23778
24083
  return `${l}${r}`;
23779
24084
  if (typeof l === "number" && typeof r === "number")
23780
24085
  return l + r;
23781
24086
  return UNRESOLVED;
23782
- case ts22.SyntaxKind.MinusToken:
24087
+ case ts23.SyntaxKind.MinusToken:
23783
24088
  return typeof l === "number" && typeof r === "number" ? l - r : UNRESOLVED;
23784
- case ts22.SyntaxKind.AsteriskToken:
24089
+ case ts23.SyntaxKind.AsteriskToken:
23785
24090
  return typeof l === "number" && typeof r === "number" ? l * r : UNRESOLVED;
23786
- case ts22.SyntaxKind.SlashToken:
24091
+ case ts23.SyntaxKind.SlashToken:
23787
24092
  return typeof l === "number" && typeof r === "number" && r !== 0 ? l / r : UNRESOLVED;
23788
- case ts22.SyntaxKind.PercentToken:
24093
+ case ts23.SyntaxKind.PercentToken:
23789
24094
  return typeof l === "number" && typeof r === "number" && r !== 0 ? l % r : UNRESOLVED;
23790
- case ts22.SyntaxKind.EqualsEqualsEqualsToken:
23791
- case ts22.SyntaxKind.EqualsEqualsToken:
24095
+ case ts23.SyntaxKind.EqualsEqualsEqualsToken:
24096
+ case ts23.SyntaxKind.EqualsEqualsToken:
23792
24097
  return l === r;
23793
- case ts22.SyntaxKind.ExclamationEqualsEqualsToken:
23794
- case ts22.SyntaxKind.ExclamationEqualsToken:
24098
+ case ts23.SyntaxKind.ExclamationEqualsEqualsToken:
24099
+ case ts23.SyntaxKind.ExclamationEqualsToken:
23795
24100
  return l !== r;
23796
24101
  }
23797
24102
  return UNRESOLVED;
23798
24103
  }
23799
- if (ts22.isTemplateExpression(node)) {
24104
+ if (ts23.isTemplateExpression(node)) {
23800
24105
  if (node.templateSpans.length === 0)
23801
24106
  return node.head.text;
23802
24107
  let acc = node.head.text;
@@ -23808,13 +24113,13 @@ function evalNode(node, ctx) {
23808
24113
  }
23809
24114
  return acc;
23810
24115
  }
23811
- if (ts22.isNoSubstitutionTemplateLiteral(node))
24116
+ if (ts23.isNoSubstitutionTemplateLiteral(node))
23812
24117
  return node.text;
23813
24118
  return UNRESOLVED;
23814
24119
  }
23815
24120
 
23816
24121
  // src/augment-inherited-props.ts
23817
- import ts23 from "typescript";
24122
+ import ts24 from "typescript";
23818
24123
  function collectContextConsumers(metadata) {
23819
24124
  const constants = metadata.localConstants ?? [];
23820
24125
  const contextDefaults = new Map;
@@ -23846,47 +24151,47 @@ function collectContextConsumers(metadata) {
23846
24151
  }
23847
24152
  function parseUseContextArg(source) {
23848
24153
  const expr = parseSingleExpression(source);
23849
- if (!expr || !ts23.isCallExpression(expr))
24154
+ if (!expr || !ts24.isCallExpression(expr))
23850
24155
  return null;
23851
- if (!ts23.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
24156
+ if (!ts24.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
23852
24157
  return null;
23853
24158
  if (expr.arguments.length !== 1)
23854
24159
  return null;
23855
24160
  const arg = expr.arguments[0];
23856
- return ts23.isIdentifier(arg) ? arg.text : null;
24161
+ return ts24.isIdentifier(arg) ? arg.text : null;
23857
24162
  }
23858
24163
  function parseCreateContextDefault(source) {
23859
24164
  const expr = parseSingleExpression(source);
23860
- if (!expr || !ts23.isCallExpression(expr))
24165
+ if (!expr || !ts24.isCallExpression(expr))
23861
24166
  return null;
23862
24167
  if (expr.arguments.length === 0)
23863
24168
  return null;
23864
24169
  const arg = expr.arguments[0];
23865
- if (ts23.isStringLiteral(arg) || ts23.isNoSubstitutionTemplateLiteral(arg))
24170
+ if (ts24.isStringLiteral(arg) || ts24.isNoSubstitutionTemplateLiteral(arg))
23866
24171
  return arg.text;
23867
- if (ts23.isNumericLiteral(arg))
24172
+ if (ts24.isNumericLiteral(arg))
23868
24173
  return Number(arg.text);
23869
- if (arg.kind === ts23.SyntaxKind.TrueKeyword)
24174
+ if (arg.kind === ts24.SyntaxKind.TrueKeyword)
23870
24175
  return true;
23871
- if (arg.kind === ts23.SyntaxKind.FalseKeyword)
24176
+ if (arg.kind === ts24.SyntaxKind.FalseKeyword)
23872
24177
  return false;
23873
24178
  return null;
23874
24179
  }
23875
24180
  function isObjectLiteralCreateContextDefault(source) {
23876
24181
  const expr = parseSingleExpression(source);
23877
- if (!expr || !ts23.isCallExpression(expr))
24182
+ if (!expr || !ts24.isCallExpression(expr))
23878
24183
  return false;
23879
24184
  if (expr.arguments.length === 0)
23880
24185
  return false;
23881
- return ts23.isObjectLiteralExpression(expr.arguments[0]);
24186
+ return ts24.isObjectLiteralExpression(expr.arguments[0]);
23882
24187
  }
23883
24188
  function parseSingleExpression(source) {
23884
- const sf = ts23.createSourceFile("__ctx.ts", `(${source})`, ts23.ScriptTarget.Latest, false);
24189
+ const sf = ts24.createSourceFile("__ctx.ts", `(${source})`, ts24.ScriptTarget.Latest, false);
23885
24190
  const stmt = sf.statements[0];
23886
- if (!stmt || !ts23.isExpressionStatement(stmt))
24191
+ if (!stmt || !ts24.isExpressionStatement(stmt))
23887
24192
  return null;
23888
24193
  let e = stmt.expression;
23889
- while (ts23.isParenthesizedExpression(e))
24194
+ while (ts24.isParenthesizedExpression(e))
23890
24195
  e = e.expression;
23891
24196
  return e;
23892
24197
  }
@@ -23911,25 +24216,25 @@ function augmentInheritedPropAccesses(ir) {
23911
24216
  const pinCoalesceLiterals = (s) => {
23912
24217
  if (!s || !s.includes(propsObj))
23913
24218
  return;
23914
- const sf = ts23.createSourceFile("__aug.ts", `(${s})`, ts23.ScriptTarget.Latest, false);
24219
+ const sf = ts24.createSourceFile("__aug.ts", `(${s})`, ts24.ScriptTarget.Latest, false);
23915
24220
  const visit3 = (n) => {
23916
- 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)) {
23917
24222
  let left = n.left;
23918
- while (ts23.isParenthesizedExpression(left))
24223
+ while (ts24.isParenthesizedExpression(left))
23919
24224
  left = left.expression;
23920
- 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) {
23921
24226
  const name = left.name.text;
23922
24227
  let right = n.right;
23923
- while (ts23.isParenthesizedExpression(right))
24228
+ while (ts24.isParenthesizedExpression(right))
23924
24229
  right = right.expression;
23925
- if (ts23.isPrefixUnaryExpression(right))
24230
+ if (ts24.isPrefixUnaryExpression(right))
23926
24231
  right = right.operand;
23927
- 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;
23928
24233
  if (kind && !coalesceLiteralTypes.has(name))
23929
24234
  coalesceLiteralTypes.set(name, kind);
23930
24235
  }
23931
24236
  }
23932
- ts23.forEachChild(n, visit3);
24237
+ ts24.forEachChild(n, visit3);
23933
24238
  };
23934
24239
  visit3(sf);
23935
24240
  };
@@ -24040,33 +24345,33 @@ function augmentInheritedPropAccesses(ir) {
24040
24345
  }
24041
24346
  }
24042
24347
  function parseStaticStringConst(source) {
24043
- 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);
24044
24349
  const stmt = sf.statements[0];
24045
- if (!stmt || !ts23.isVariableStatement(stmt))
24350
+ if (!stmt || !ts24.isVariableStatement(stmt))
24046
24351
  return null;
24047
24352
  let init = stmt.declarationList.declarations[0]?.initializer;
24048
- while (init && ts23.isParenthesizedExpression(init))
24353
+ while (init && ts24.isParenthesizedExpression(init))
24049
24354
  init = init.expression;
24050
24355
  if (!init)
24051
24356
  return null;
24052
- if (ts23.isStringLiteral(init) || ts23.isNoSubstitutionTemplateLiteral(init)) {
24357
+ if (ts24.isStringLiteral(init) || ts24.isNoSubstitutionTemplateLiteral(init)) {
24053
24358
  return init.text;
24054
24359
  }
24055
24360
  return evalStringArrayJoin(source);
24056
24361
  }
24057
24362
  function evalTemplateOfStringConsts(source, resolved) {
24058
- 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);
24059
24364
  const stmt = sf.statements[0];
24060
- if (!stmt || !ts23.isVariableStatement(stmt))
24365
+ if (!stmt || !ts24.isVariableStatement(stmt))
24061
24366
  return null;
24062
24367
  let init = stmt.declarationList.declarations[0]?.initializer;
24063
- while (init && ts23.isParenthesizedExpression(init))
24368
+ while (init && ts24.isParenthesizedExpression(init))
24064
24369
  init = init.expression;
24065
- if (!init || !ts23.isTemplateExpression(init))
24370
+ if (!init || !ts24.isTemplateExpression(init))
24066
24371
  return null;
24067
24372
  let out = init.head.text;
24068
24373
  for (const span of init.templateSpans) {
24069
- if (!ts23.isIdentifier(span.expression))
24374
+ if (!ts24.isIdentifier(span.expression))
24070
24375
  return null;
24071
24376
  const value = resolved.get(span.expression.text);
24072
24377
  if (value === undefined)
@@ -24099,30 +24404,30 @@ function lookupStaticRecordLiteral(objectName, key, constants, isShadowed) {
24099
24404
  const constInfo = (constants ?? []).find((c) => c.name === objectName && c.isModule);
24100
24405
  if (constInfo?.value === undefined)
24101
24406
  return null;
24102
- 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);
24103
24408
  if (sf.statements.length !== 1)
24104
24409
  return null;
24105
24410
  const stmt = sf.statements[0];
24106
- if (!ts23.isExpressionStatement(stmt))
24411
+ if (!ts24.isExpressionStatement(stmt))
24107
24412
  return null;
24108
24413
  let parsed = stmt.expression;
24109
- while (ts23.isParenthesizedExpression(parsed))
24414
+ while (ts24.isParenthesizedExpression(parsed))
24110
24415
  parsed = parsed.expression;
24111
- if (!ts23.isObjectLiteralExpression(parsed))
24416
+ if (!ts24.isObjectLiteralExpression(parsed))
24112
24417
  return null;
24113
24418
  for (const prop of parsed.properties) {
24114
- if (!ts23.isPropertyAssignment(prop))
24419
+ if (!ts24.isPropertyAssignment(prop))
24115
24420
  continue;
24116
24421
  const name = prop.name;
24117
- 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;
24118
24423
  if (propKey !== key)
24119
24424
  continue;
24120
24425
  let v = prop.initializer;
24121
- while (ts23.isParenthesizedExpression(v))
24426
+ while (ts24.isParenthesizedExpression(v))
24122
24427
  v = v.expression;
24123
- if (ts23.isNumericLiteral(v))
24428
+ if (ts24.isNumericLiteral(v))
24124
24429
  return { kind: "number", text: v.text };
24125
- if (ts23.isStringLiteral(v) || ts23.isNoSubstitutionTemplateLiteral(v)) {
24430
+ if (ts24.isStringLiteral(v) || ts24.isNoSubstitutionTemplateLiteral(v)) {
24126
24431
  return { kind: "string", text: v.text };
24127
24432
  }
24128
24433
  return null;
@@ -24130,28 +24435,28 @@ function lookupStaticRecordLiteral(objectName, key, constants, isShadowed) {
24130
24435
  return null;
24131
24436
  }
24132
24437
  function evalStringArrayJoin(source) {
24133
- 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);
24134
24439
  const stmt = sf.statements[0];
24135
- if (!stmt || !ts23.isVariableStatement(stmt))
24440
+ if (!stmt || !ts24.isVariableStatement(stmt))
24136
24441
  return null;
24137
24442
  let node = stmt.declarationList.declarations[0]?.initializer;
24138
- while (node && ts23.isParenthesizedExpression(node))
24443
+ while (node && ts24.isParenthesizedExpression(node))
24139
24444
  node = node.expression;
24140
- if (!node || !ts23.isCallExpression(node))
24445
+ if (!node || !ts24.isCallExpression(node))
24141
24446
  return null;
24142
24447
  const callee = node.expression;
24143
- if (!ts23.isPropertyAccessExpression(callee))
24448
+ if (!ts24.isPropertyAccessExpression(callee))
24144
24449
  return null;
24145
24450
  if (callee.name.text !== "join")
24146
24451
  return null;
24147
24452
  let recv = callee.expression;
24148
- while (ts23.isParenthesizedExpression(recv))
24453
+ while (ts24.isParenthesizedExpression(recv))
24149
24454
  recv = recv.expression;
24150
- if (!ts23.isArrayLiteralExpression(recv))
24455
+ if (!ts24.isArrayLiteralExpression(recv))
24151
24456
  return null;
24152
24457
  const parts = [];
24153
24458
  for (const el of recv.elements) {
24154
- if (ts23.isStringLiteral(el) || ts23.isNoSubstitutionTemplateLiteral(el)) {
24459
+ if (ts24.isStringLiteral(el) || ts24.isNoSubstitutionTemplateLiteral(el)) {
24155
24460
  parts.push(el.text);
24156
24461
  } else {
24157
24462
  return null;
@@ -24160,7 +24465,7 @@ function evalStringArrayJoin(source) {
24160
24465
  let sep2 = ",";
24161
24466
  if (node.arguments.length >= 1) {
24162
24467
  const arg = node.arguments[0];
24163
- if (ts23.isStringLiteral(arg) || ts23.isNoSubstitutionTemplateLiteral(arg))
24468
+ if (ts24.isStringLiteral(arg) || ts24.isNoSubstitutionTemplateLiteral(arg))
24164
24469
  sep2 = arg.text;
24165
24470
  else
24166
24471
  return null;
@@ -24168,11 +24473,11 @@ function evalStringArrayJoin(source) {
24168
24473
  return parts.join(sep2);
24169
24474
  }
24170
24475
  function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
24171
- if (!ts23.isElementAccessExpression(val))
24476
+ if (!ts24.isElementAccessExpression(val))
24172
24477
  return null;
24173
24478
  const obj = val.expression;
24174
24479
  const arg = val.argumentExpression;
24175
- if (!ts23.isIdentifier(obj) || !ts23.isIdentifier(arg))
24480
+ if (!ts24.isIdentifier(obj) || !ts24.isIdentifier(arg))
24176
24481
  return null;
24177
24482
  let indexPropName;
24178
24483
  let defaultKey;
@@ -24188,35 +24493,35 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
24188
24493
  const constInfo = localConstants.find((c) => c.name === obj.text && c.isModule);
24189
24494
  if (constInfo?.value === undefined)
24190
24495
  return null;
24191
- 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);
24192
24497
  if (sf.statements.length !== 1)
24193
24498
  return null;
24194
24499
  const stmt = sf.statements[0];
24195
- if (!ts23.isExpressionStatement(stmt))
24500
+ if (!ts24.isExpressionStatement(stmt))
24196
24501
  return null;
24197
24502
  let parsed = stmt.expression;
24198
- while (ts23.isParenthesizedExpression(parsed))
24503
+ while (ts24.isParenthesizedExpression(parsed))
24199
24504
  parsed = parsed.expression;
24200
- if (!ts23.isObjectLiteralExpression(parsed))
24505
+ if (!ts24.isObjectLiteralExpression(parsed))
24201
24506
  return null;
24202
24507
  const entries = [];
24203
24508
  for (const prop of parsed.properties) {
24204
- if (!ts23.isPropertyAssignment(prop))
24509
+ if (!ts24.isPropertyAssignment(prop))
24205
24510
  return null;
24206
24511
  let key;
24207
- if (ts23.isIdentifier(prop.name)) {
24512
+ if (ts24.isIdentifier(prop.name)) {
24208
24513
  key = prop.name.text;
24209
- } else if (ts23.isStringLiteral(prop.name) || ts23.isNoSubstitutionTemplateLiteral(prop.name)) {
24514
+ } else if (ts24.isStringLiteral(prop.name) || ts24.isNoSubstitutionTemplateLiteral(prop.name)) {
24210
24515
  key = prop.name.text;
24211
24516
  } else {
24212
24517
  return null;
24213
24518
  }
24214
24519
  let v = prop.initializer;
24215
- while (ts23.isParenthesizedExpression(v))
24520
+ while (ts24.isParenthesizedExpression(v))
24216
24521
  v = v.expression;
24217
- if (ts23.isNumericLiteral(v)) {
24522
+ if (ts24.isNumericLiteral(v)) {
24218
24523
  entries.push({ key, value: { kind: "number", text: v.text } });
24219
- } else if (ts23.isStringLiteral(v) || ts23.isNoSubstitutionTemplateLiteral(v)) {
24524
+ } else if (ts24.isStringLiteral(v) || ts24.isNoSubstitutionTemplateLiteral(v)) {
24220
24525
  entries.push({ key, value: { kind: "string", text: v.text } });
24221
24526
  } else {
24222
24527
  return null;
@@ -24577,31 +24882,54 @@ function walkNode2(node, meta, bindings, matchers, errors, seen) {
24577
24882
  function mergeTemplateImports(lines) {
24578
24883
  const result = [];
24579
24884
  const valueIdx = new Map;
24885
+ const valueDefault = new Map;
24580
24886
  const valueNames = new Map;
24581
24887
  const typeIdx = new Map;
24582
24888
  const typeNames = new Map;
24583
24889
  const seenOther = new Set;
24584
- const fold = (src, rawNames, idx, names, render) => {
24585
- if (!idx.has(src)) {
24586
- idx.set(src, result.length);
24587
- 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);
24588
24894
  result.push("");
24589
24895
  }
24590
- const set = names.get(src);
24896
+ const set = typeNames.get(src);
24591
24897
  for (const n of rawNames.split(",").map((s) => s.trim()).filter(Boolean))
24592
24898
  set.add(n);
24593
- 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
+ `);
24594
24916
  };
24595
24917
  for (const raw of lines) {
24596
24918
  const line = raw.trim();
24597
24919
  if (!line)
24598
24920
  continue;
24599
24921
  const typeMatch = line.match(/^import\s+type\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]\s*;?$/);
24600
- const valueMatch = line.match(/^import\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]\s*;?$/);
24601
- if (valueMatch) {
24602
- fold(valueMatch[2], valueMatch[1], valueIdx, valueNames, (s, n) => `import { ${[...n].join(", ")} } from '${s}'`);
24603
- } else if (typeMatch) {
24604
- 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);
24605
24933
  } else if (!seenOther.has(line)) {
24606
24934
  seenOther.add(line);
24607
24935
  result.push(line);
@@ -24643,13 +24971,13 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
24643
24971
  if (entries.some((e) => e.componentIR.metadata.isClientComponent)) {
24644
24972
  const topLevelNames = new Set;
24645
24973
  {
24646
- 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);
24647
24975
  for (const stmt of sf.statements) {
24648
- if (ts24.isFunctionDeclaration(stmt) && stmt.name)
24976
+ if (ts25.isFunctionDeclaration(stmt) && stmt.name)
24649
24977
  topLevelNames.add(stmt.name.text);
24650
- else if (ts24.isVariableStatement(stmt)) {
24978
+ else if (ts25.isVariableStatement(stmt)) {
24651
24979
  for (const d of stmt.declarationList.declarations) {
24652
- if (ts24.isIdentifier(d.name))
24980
+ if (ts25.isIdentifier(d.name))
24653
24981
  topLevelNames.add(d.name.text);
24654
24982
  }
24655
24983
  }
@@ -24708,7 +25036,7 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
24708
25036
  const moduleStatementSeen = new Set;
24709
25037
  const moduleStatementsOrdered = [];
24710
25038
  const collectModuleStatements = (block) => {
24711
- 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);
24712
25040
  for (const stmt of sf.statements) {
24713
25041
  const text = stmt.getText(sf);
24714
25042
  if (moduleStatementSeen.has(text))
@@ -24797,32 +25125,9 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
24797
25125
  }
24798
25126
  const clientJsOutputs2 = allOutputs.map((o) => o.clientJs).filter(Boolean);
24799
25127
  if (clientJsOutputs2.length > 0) {
24800
- const importsBySource = new Map;
24801
- const otherImports = [];
24802
- const allCode = [];
24803
- for (const js of clientJsOutputs2) {
24804
- for (const line of js.split(`
24805
- `)) {
24806
- if (line.startsWith("import ")) {
24807
- const match = line.match(/^import \{ ([^}]+) \} from ['"]([^'"]+)['"]$/);
24808
- if (match) {
24809
- const source2 = match[2];
24810
- if (!importsBySource.has(source2))
24811
- importsBySource.set(source2, new Set);
24812
- for (const n of match[1].split(",").map((n2) => n2.trim()))
24813
- importsBySource.get(source2).add(n);
24814
- } else if (!otherImports.includes(line)) {
24815
- otherImports.push(line);
24816
- }
24817
- }
24818
- }
24819
- allCode.push(js.replace(/^import .+\n/gm, "").trim());
24820
- }
24821
- const mergedClientImports = [...importsBySource].map(([src, names]) => `import { ${[...names].sort().join(", ")} } from '${src}'`);
24822
25128
  files.push({
24823
25129
  path: filePath.replace(/\.tsx?$/, ".client.js"),
24824
- content: [...mergedClientImports, ...otherImports, "", ...allCode.filter(Boolean)].join(`
24825
- `),
25130
+ content: mergeCompiledClientJsImports(clientJsOutputs2),
24826
25131
  type: "clientJs"
24827
25132
  });
24828
25133
  }
@@ -24893,53 +25198,9 @@ function compileMultipleComponents(source, filePath, componentNames, options) {
24893
25198
  }
24894
25199
  const clientJsOutputs = allOutputs.map((o) => o.clientJs).filter(Boolean);
24895
25200
  if (clientJsOutputs.length > 0) {
24896
- const importsBySource = new Map;
24897
- const otherImports = [];
24898
- const allCode = [];
24899
- for (const js of clientJsOutputs) {
24900
- const lines = js.split(`
24901
- `);
24902
- const codeLines = [];
24903
- for (const line of lines) {
24904
- if (line.startsWith("import ")) {
24905
- const match = line.match(/^import \{ ([^}]+) \} from ['"]([^'"]+)['"]$/);
24906
- if (match) {
24907
- const names = match[1].split(",").map((n) => n.trim());
24908
- const source2 = match[2];
24909
- if (!importsBySource.has(source2)) {
24910
- importsBySource.set(source2, new Set);
24911
- }
24912
- const set = importsBySource.get(source2);
24913
- for (const name of names) {
24914
- set.add(name);
24915
- }
24916
- } else {
24917
- if (!otherImports.includes(line)) {
24918
- otherImports.push(line);
24919
- }
24920
- }
24921
- } else {
24922
- codeLines.push(line);
24923
- }
24924
- }
24925
- allCode.push(codeLines.join(`
24926
- `).trim());
24927
- }
24928
- const mergedImports2 = [];
24929
- for (const [source2, names] of importsBySource) {
24930
- const sortedNames = [...names].sort();
24931
- mergedImports2.push(`import { ${sortedNames.join(", ")} } from '${source2}'`);
24932
- }
24933
- const combinedClientJs = [
24934
- ...mergedImports2,
24935
- ...otherImports,
24936
- "",
24937
- ...allCode.filter(Boolean)
24938
- ].join(`
24939
- `);
24940
25201
  files.push({
24941
25202
  path: filePath.replace(/\.tsx?$/, ".client.js"),
24942
- content: combinedClientJs,
25203
+ content: mergeCompiledClientJsImports(clientJsOutputs),
24943
25204
  type: "clientJs"
24944
25205
  });
24945
25206
  }
@@ -25012,10 +25273,24 @@ function compileJSX(source, filePath, options) {
25012
25273
  externalImportLines.push(`import '${imp.source}'`);
25013
25274
  continue;
25014
25275
  }
25015
- 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);
25016
- if (used.length > 0) {
25017
- 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
+ }
25018
25292
  }
25293
+ externalImportLines.push(...renderUsedImportLines(imp.source, usedDefault, usedNamespace, usedNamed));
25019
25294
  }
25020
25295
  const allImports = [runtimeImportLine, ...externalImportLines].filter(Boolean).join(`
25021
25296
  `);
@@ -25151,7 +25426,7 @@ function compileJSX(source, filePath, options) {
25151
25426
  return { files, errors };
25152
25427
  }
25153
25428
  // src/shared-program.ts
25154
- import ts25 from "typescript";
25429
+ import ts26 from "typescript";
25155
25430
  function commonParent(paths) {
25156
25431
  if (paths.length === 0)
25157
25432
  return process.cwd();
@@ -25172,10 +25447,10 @@ function commonParent(paths) {
25172
25447
  function createProgramForCorpus(files, options = {}) {
25173
25448
  const baseUrl = options.baseUrl ?? commonParent(files);
25174
25449
  const compilerOptions = {
25175
- target: ts25.ScriptTarget.Latest,
25176
- module: ts25.ModuleKind.ESNext,
25177
- moduleResolution: ts25.ModuleResolutionKind.Bundler,
25178
- jsx: ts25.JsxEmit.ReactJSX,
25450
+ target: ts26.ScriptTarget.Latest,
25451
+ module: ts26.ModuleKind.ESNext,
25452
+ moduleResolution: ts26.ModuleResolutionKind.Bundler,
25453
+ jsx: ts26.JsxEmit.ReactJSX,
25179
25454
  strict: true,
25180
25455
  skipLibCheck: true,
25181
25456
  noEmit: true,
@@ -25185,7 +25460,7 @@ function createProgramForCorpus(files, options = {}) {
25185
25460
  ...options.compilerOptions
25186
25461
  };
25187
25462
  const absolute = files.map((f) => path_default.resolve(f));
25188
- return ts25.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
25463
+ return ts26.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
25189
25464
  }
25190
25465
  // src/adapters/interface.ts
25191
25466
  class BaseAdapter {
@@ -25469,7 +25744,7 @@ class JsxAdapter extends BaseAdapter {
25469
25744
  }
25470
25745
 
25471
25746
  // src/adapters/template-imports.ts
25472
- import ts26 from "typescript";
25747
+ import ts27 from "typescript";
25473
25748
  var CLIENT_PACKAGE_SOURCES = new Set([
25474
25749
  "@barefootjs/client",
25475
25750
  "@barefootjs/client/runtime"
@@ -25519,18 +25794,18 @@ function specKey(s) {
25519
25794
  function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
25520
25795
  if (!sourceText.includes("import"))
25521
25796
  return sourceText;
25522
- 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);
25523
25798
  const edits = [];
25524
25799
  const visit3 = (node) => {
25525
- 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])) {
25526
25801
  collect(node.arguments[0]);
25527
25802
  }
25528
- if (ts26.isImportTypeNode(node) && ts26.isLiteralTypeNode(node.argument)) {
25803
+ if (ts27.isImportTypeNode(node) && ts27.isLiteralTypeNode(node.argument)) {
25529
25804
  const literal = node.argument.literal;
25530
- if (ts26.isStringLiteralLike(literal))
25805
+ if (ts27.isStringLiteralLike(literal))
25531
25806
  collect(literal);
25532
25807
  }
25533
- ts26.forEachChild(node, visit3);
25808
+ ts27.forEachChild(node, visit3);
25534
25809
  };
25535
25810
  const collect = (literal) => {
25536
25811
  const specifier = literal.text;
@@ -25545,7 +25820,7 @@ function rewriteDynamicImportsInSource(sourceText, rewriteRelative) {
25545
25820
  text: `'${next}'`
25546
25821
  });
25547
25822
  };
25548
- ts26.forEachChild(sf, visit3);
25823
+ ts27.forEachChild(sf, visit3);
25549
25824
  if (edits.length === 0)
25550
25825
  return sourceText;
25551
25826
  let out = sourceText;
@@ -26310,7 +26585,7 @@ function dangerousInnerHtmlDiagnostic(expr, loc, reason) {
26310
26585
  };
26311
26586
  }
26312
26587
  // src/combine-client-js.ts
26313
- import ts27 from "typescript";
26588
+ import ts28 from "typescript";
26314
26589
  var CHILD_PLACEHOLDER_RE = /import '\/\* @bf-child:(\w+) \*\/'/g;
26315
26590
  function combineParentChildClientJs(files) {
26316
26591
  const result = new Map;
@@ -26367,10 +26642,10 @@ function combineParentChildClientJs(files) {
26367
26642
  return result;
26368
26643
  }
26369
26644
  function parseAndMerge(content, importsBySource, otherImports, codeSections) {
26370
- 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);
26371
26646
  const importSpans = [];
26372
26647
  for (const stmt of sourceFile.statements) {
26373
- if (!ts27.isImportDeclaration(stmt))
26648
+ if (!ts28.isImportDeclaration(stmt))
26374
26649
  continue;
26375
26650
  const start = stmt.getStart(sourceFile);
26376
26651
  const end = stmt.getEnd();
@@ -26380,8 +26655,8 @@ function parseAndMerge(content, importsBySource, otherImports, codeSections) {
26380
26655
  continue;
26381
26656
  const clause = stmt.importClause;
26382
26657
  const bindings = clause?.namedBindings;
26383
- const specifier = ts27.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
26384
- 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)) {
26385
26660
  if (!importsBySource.has(specifier)) {
26386
26661
  importsBySource.set(specifier, new Set);
26387
26662
  }
@@ -26548,7 +26823,7 @@ function escapeRe(s) {
26548
26823
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
26549
26824
  }
26550
26825
  // src/debug.ts
26551
- import ts28 from "typescript";
26826
+ import ts29 from "typescript";
26552
26827
  function buildComponentGraph(source, filePath, componentName) {
26553
26828
  const ctx = analyzeComponent(source, filePath, componentName);
26554
26829
  if (!ctx.jsxReturn) {
@@ -27836,7 +28111,7 @@ function truncateExpr(expr, max = 40) {
27836
28111
  function exprReadsPropMember(expr, propsObjectName) {
27837
28112
  let sf;
27838
28113
  try {
27839
- 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);
27840
28115
  } catch {
27841
28116
  return false;
27842
28117
  }
@@ -27844,11 +28119,11 @@ function exprReadsPropMember(expr, propsObjectName) {
27844
28119
  const visit3 = (n) => {
27845
28120
  if (found)
27846
28121
  return;
27847
- 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") {
27848
28123
  found = true;
27849
28124
  return;
27850
28125
  }
27851
- ts28.forEachChild(n, visit3);
28126
+ ts29.forEachChild(n, visit3);
27852
28127
  };
27853
28128
  visit3(sf);
27854
28129
  return found;
@@ -27918,7 +28193,7 @@ function findSourceFile2(meta) {
27918
28193
  return null;
27919
28194
  }
27920
28195
  // src/profiler.ts
27921
- import ts29 from "typescript";
28196
+ import ts30 from "typescript";
27922
28197
  var PROFILE_SCHEMA_VERSION = 1;
27923
28198
  var DEFAULT_FANOUT_THRESHOLD = 8;
27924
28199
  function buildStaticBudget(source, filePath, componentName, options = {}) {
@@ -28188,15 +28463,15 @@ function joinProfilerEvents(events, index) {
28188
28463
  return { joined, unattributed, diagnostics };
28189
28464
  }
28190
28465
  function findUninstrumentedEffects(source, filePath, instrumentedLines) {
28191
- 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);
28192
28467
  const out = [];
28193
28468
  const visit3 = (node) => {
28194
- 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") {
28195
28470
  const line = sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;
28196
28471
  if (!instrumentedLines.has(line))
28197
28472
  out.push({ file: filePath, line });
28198
28473
  }
28199
- ts29.forEachChild(node, visit3);
28474
+ ts30.forEachChild(node, visit3);
28200
28475
  };
28201
28476
  visit3(sf);
28202
28477
  out.sort((a, b) => a.line - b.line);
@@ -28504,13 +28779,13 @@ function assessBatchSafety(args) {
28504
28779
  const signalGetters = new Set(args.graph.signals.map((s) => s.name));
28505
28780
  let sf;
28506
28781
  try {
28507
- 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);
28508
28783
  } catch {
28509
28784
  return "unverified";
28510
28785
  }
28511
28786
  const calls = [];
28512
28787
  const visit3 = (node) => {
28513
- if (ts29.isCallExpression(node) && ts29.isIdentifier(node.expression)) {
28788
+ if (ts30.isCallExpression(node) && ts30.isIdentifier(node.expression)) {
28514
28789
  const name = node.expression.text;
28515
28790
  if (setters.has(name))
28516
28791
  calls.push({ pos: node.getStart(sf), kind: "write" });
@@ -28519,7 +28794,7 @@ function assessBatchSafety(args) {
28519
28794
  else if (!signalGetters.has(name) && !memoNames.has(name))
28520
28795
  calls.push({ pos: node.getStart(sf), kind: "risky" });
28521
28796
  }
28522
- ts29.forEachChild(node, visit3);
28797
+ ts30.forEachChild(node, visit3);
28523
28798
  };
28524
28799
  visit3(sf);
28525
28800
  calls.sort((a, b) => a.pos - b.pos);
@@ -29163,6 +29438,7 @@ export {
29163
29438
  sortComparatorFromArrow,
29164
29439
  serializeParsedExpr,
29165
29440
  searchParamsLocalNames,
29441
+ scanComponentFile,
29166
29442
  rewriteImportsForTemplate,
29167
29443
  rewriteDynamicImportsInSource,
29168
29444
  resolveStaticLoopSource,