@barefootjs/jsx 0.20.0 → 0.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -215,6 +215,32 @@ var PARSED_EXPR_KINDS = [
215
215
  "array-method",
216
216
  "unsupported"
217
217
  ];
218
+ var ARRAY_METHOD_NAMES = [
219
+ "join",
220
+ "includes",
221
+ "indexOf",
222
+ "lastIndexOf",
223
+ "at",
224
+ "concat",
225
+ "slice",
226
+ "reverse",
227
+ "toReversed",
228
+ "toLowerCase",
229
+ "toUpperCase",
230
+ "trim",
231
+ "trimStart",
232
+ "trimEnd",
233
+ "toFixed",
234
+ "split",
235
+ "startsWith",
236
+ "endsWith",
237
+ "replace",
238
+ "replaceAll",
239
+ "repeat",
240
+ "padStart",
241
+ "padEnd",
242
+ "flat"
243
+ ];
218
244
  var UNSUPPORTED_METHODS = new Set([
219
245
  "filter",
220
246
  "map",
@@ -5302,6 +5328,135 @@ function internalInvariant(cond, message) {
5302
5328
  }
5303
5329
  }
5304
5330
 
5331
+ // src/rich-type-evidence.ts
5332
+ var HOST_RICH_TYPE_NAMES = new Set([
5333
+ "Date",
5334
+ "Map",
5335
+ "Set",
5336
+ "WeakMap",
5337
+ "WeakSet",
5338
+ "URL",
5339
+ "URLSearchParams",
5340
+ "RegExp",
5341
+ "Promise",
5342
+ "Error",
5343
+ "Symbol",
5344
+ "BigInt",
5345
+ "Function"
5346
+ ]);
5347
+ function baseTypeName(raw) {
5348
+ const idx = raw.indexOf("<");
5349
+ return (idx === -1 ? raw : raw.slice(0, idx)).trim();
5350
+ }
5351
+ function isNullishArm(t) {
5352
+ if (t.kind === "primitive" && (t.primitive === "null" || t.primitive === "undefined"))
5353
+ return true;
5354
+ return t.kind === "unknown" && (t.raw === "null" || t.raw === "undefined");
5355
+ }
5356
+ function stripUnion(type) {
5357
+ if (!type || type.kind !== "union" || !type.unionTypes)
5358
+ return type;
5359
+ const nonNullish = type.unionTypes.filter((t) => !isNullishArm(t));
5360
+ return nonNullish.length === 1 ? stripUnion(nonNullish[0]) : type;
5361
+ }
5362
+ function derefNamedType(type, meta) {
5363
+ if (type.kind !== "interface")
5364
+ return type;
5365
+ if (type.properties && type.properties.length > 0)
5366
+ return type;
5367
+ const name = baseTypeName(type.raw);
5368
+ const def = meta.typeDefinitions.find((d) => d.name === name);
5369
+ if (!def?.properties)
5370
+ return type;
5371
+ return { ...type, properties: def.properties };
5372
+ }
5373
+ function lookupProperty(objType, propName, meta) {
5374
+ const stripped = stripUnion(objType);
5375
+ if (!stripped)
5376
+ return null;
5377
+ const deref = derefNamedType(stripped, meta);
5378
+ const prop = deref.properties?.find((p) => p.name === propName);
5379
+ return prop ? stripUnion(prop.type) : null;
5380
+ }
5381
+ function resolveReceiverType(expr, meta, bindings) {
5382
+ if (expr.kind === "identifier") {
5383
+ if (bindings.has(expr.name))
5384
+ return stripUnion(bindings.get(expr.name) ?? null);
5385
+ if (meta.propsObjectName !== null) {
5386
+ return expr.name === meta.propsObjectName ? stripUnion(meta.propsType) : null;
5387
+ }
5388
+ const param = meta.propsParams.find((p) => p.name === expr.name && !p.isRest);
5389
+ if (!param)
5390
+ return null;
5391
+ return lookupProperty(meta.propsType, param.sourceName ?? param.name, meta);
5392
+ }
5393
+ if (expr.kind === "member" && !expr.computed) {
5394
+ const objType = resolveReceiverType(expr.object, meta, bindings);
5395
+ return lookupProperty(objType, expr.property, meta);
5396
+ }
5397
+ return null;
5398
+ }
5399
+
5400
+ // src/date-lowering.ts
5401
+ var CATALOGUED_RICH_TYPE_NAMES = new Set(["Date"]);
5402
+ var DATE_METHODS = new Set([
5403
+ "getUTCFullYear",
5404
+ "getUTCMonth",
5405
+ "getUTCDate",
5406
+ "getUTCHours",
5407
+ "getUTCMinutes",
5408
+ "getUTCSeconds",
5409
+ "getTime",
5410
+ "toISOString"
5411
+ ]);
5412
+ var EMPTY_BINDINGS = new Map;
5413
+ function typeReachesDate(type, meta, seen) {
5414
+ const stripped = stripUnion(type);
5415
+ if (!stripped)
5416
+ return false;
5417
+ if (stripped.kind === "interface") {
5418
+ const name = baseTypeName(stripped.raw);
5419
+ if (name === "Date")
5420
+ return true;
5421
+ if (seen.has(name))
5422
+ return false;
5423
+ seen.add(name);
5424
+ } else if (stripped.kind !== "object") {
5425
+ return false;
5426
+ }
5427
+ const deref = derefNamedType(stripped, meta);
5428
+ if (!deref.properties)
5429
+ return false;
5430
+ return deref.properties.some((p) => typeReachesDate(p.type, meta, seen));
5431
+ }
5432
+ function matchDateCall(callee, args, metadata) {
5433
+ if (callee.kind !== "member" || callee.computed)
5434
+ return null;
5435
+ if (args.length !== 0 || !DATE_METHODS.has(callee.property))
5436
+ return null;
5437
+ const receiverType = resolveReceiverType(callee.object, metadata, EMPTY_BINDINGS);
5438
+ if (!receiverType || receiverType.kind !== "interface")
5439
+ return null;
5440
+ const typeName = baseTypeName(receiverType.raw);
5441
+ if (typeName !== "Date")
5442
+ return null;
5443
+ if (metadata.typeDefinitions.some((d) => d.name === typeName))
5444
+ return null;
5445
+ return {
5446
+ kind: "helper-call",
5447
+ helper: "date",
5448
+ args: [callee.object, { kind: "literal", value: callee.property, literalType: "string" }]
5449
+ };
5450
+ }
5451
+ var datePlugin = {
5452
+ name: "date",
5453
+ prepare(metadata) {
5454
+ if (!metadata.propsType || !typeReachesDate(metadata.propsType, metadata, new Set))
5455
+ return null;
5456
+ return (callee, args) => matchDateCall(callee, args, metadata);
5457
+ }
5458
+ };
5459
+
5305
5460
  // src/analyzer.ts
5306
5461
  var { default: fs} = (() => ({}));
5307
5462
  var REACTIVE_BRAND_PACKAGES = [
@@ -7150,7 +7305,7 @@ function collectKeysFromMembers(members, ctx) {
7150
7305
  return keys;
7151
7306
  }
7152
7307
  function collectMemberTypes(typeNode, ctx) {
7153
- const isResolvablePrimitive = (info) => info.kind === "primitive" && (info.primitive === "string" || info.primitive === "number" || info.primitive === "boolean");
7308
+ const isResolvablePrimitive = (info) => info.kind === "primitive" && (info.primitive === "string" || info.primitive === "number" || info.primitive === "boolean") || info.kind === "interface" && CATALOGUED_RICH_TYPE_NAMES.has(baseTypeName(info.raw));
7154
7309
  const fromMembers = (members) => {
7155
7310
  const map = new Map;
7156
7311
  for (const member of members) {
@@ -8387,18 +8542,60 @@ function exprHasFunctionCalls(expr) {
8387
8542
  visit2(expr);
8388
8543
  return found;
8389
8544
  }
8545
+ function getDateLoweringMatcher(ctx) {
8546
+ if (ctx._dateLoweringMatcher === undefined) {
8547
+ const a = ctx.analyzer;
8548
+ const metadataSlice = {
8549
+ propsType: a.propsType,
8550
+ propsObjectName: a.propsObjectName,
8551
+ propsParams: a.propsParams,
8552
+ typeDefinitions: a.typeDefinitions
8553
+ };
8554
+ ctx._dateLoweringMatcher = datePlugin.prepare(metadataSlice);
8555
+ }
8556
+ return ctx._dateLoweringMatcher;
8557
+ }
8558
+ function lowerDateCalls(text, expr, ctx) {
8559
+ const matcher = getDateLoweringMatcher(ctx);
8560
+ if (!matcher)
8561
+ return text;
8562
+ const candidates = [];
8563
+ function visit2(n) {
8564
+ if (ts11.isCallExpression(n) && n.arguments.length === 0 && ts11.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
8565
+ candidates.push(n);
8566
+ }
8567
+ ts11.forEachChild(n, visit2);
8568
+ }
8569
+ visit2(expr);
8570
+ if (candidates.length === 0)
8571
+ return text;
8572
+ const { protect, restore } = createTemplateAwareStringProtector();
8573
+ let result = protect(text);
8574
+ for (const call of candidates) {
8575
+ const propAccess = call.expression;
8576
+ const node = matcher(tsNodeToParsedExpr(propAccess), []);
8577
+ if (!node || node.kind !== "helper-call" || node.helper !== "date")
8578
+ continue;
8579
+ const op = propAccess.name.text;
8580
+ const receiverText = ctx.getJS(propAccess.expression);
8581
+ const matchText = ctx.getJS(call);
8582
+ result = result.replace(matchText, () => `date(${receiverText}, "${op}")`);
8583
+ }
8584
+ return restore(result);
8585
+ }
8390
8586
  function rewriteBarePropRefs2(text, expr, ctx) {
8587
+ const dateLowered = lowerDateCalls(text, expr, ctx);
8391
8588
  let propNames = getDestructuredPropNames(ctx);
8392
8589
  if (!propNames)
8393
- return;
8590
+ return dateLowered === text ? undefined : dateLowered;
8394
8591
  if (ctx.loopParams.size > 0) {
8395
8592
  const filtered = new Set([...propNames].filter((n) => !ctx.loopParams.has(n)));
8396
8593
  if (filtered.size === 0)
8397
- return;
8594
+ return dateLowered === text ? undefined : dateLowered;
8398
8595
  propNames = filtered;
8399
8596
  }
8400
8597
  const extraPropRefs = collectBranchLocalPropRefsViaSubstitution(expr, ctx);
8401
- return rewriteBarePropRefs(text, expr, propNames, extraPropRefs);
8598
+ return rewriteBarePropRefs(dateLowered, expr, propNames, extraPropRefs);
8402
8599
  }
8403
8600
  function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
8404
8601
  const propDepsMap = ctx._branchScopePropDeps;
@@ -10770,6 +10967,12 @@ function getAttributeValue(attr, ctx) {
10770
10967
  return AttrValueOf.template(parts);
10771
10968
  }
10772
10969
  }
10970
+ if (ts11.isElementAccessExpression(expr) && !ts11.isStringLiteralLike(expr.argumentExpression) && !ts11.isNumericLiteral(expr.argumentExpression)) {
10971
+ const parts = tryResolveTemplateSpanFromConst(expr, ctx);
10972
+ if (parts) {
10973
+ return AttrValueOf.template(parts);
10974
+ }
10975
+ }
10773
10976
  if (ts11.isIdentifier(expr)) {
10774
10977
  const resolved = tryResolveIdentifierAsTemplateLiteral(expr, ctx);
10775
10978
  if (resolved) {
@@ -13232,7 +13435,8 @@ var RUNTIME_IMPORT_CANDIDATES = [
13232
13435
  "__bfText",
13233
13436
  "tAfter",
13234
13437
  "beginTurn",
13235
- "endTurn"
13438
+ "endTurn",
13439
+ "date"
13236
13440
  ];
13237
13441
  var RUNTIME_MODULE = "@barefootjs/client/runtime";
13238
13442
  var IMPORT_PLACEHOLDER = "/* __BAREFOOTJS_DOM_IMPORTS__ */";
@@ -16327,6 +16531,7 @@ function buildArmBody(branch, options) {
16327
16531
  }
16328
16532
 
16329
16533
  // src/ir-to-client-js/emit-reactive.ts
16534
+ import ts14 from "typescript";
16330
16535
  function bindingIdArg(ctx, slotId) {
16331
16536
  if (!ctx.profile || !slotId)
16332
16537
  return "";
@@ -16386,7 +16591,56 @@ function rewriteDestructuredPropsInExpr(expr, ctx) {
16386
16591
  }
16387
16592
  return restore(result);
16388
16593
  }
16594
+ function getReactiveDateLoweringMatcher(ctx) {
16595
+ if (!ctx.propsType)
16596
+ return null;
16597
+ const metadataSlice = {
16598
+ propsType: ctx.propsType,
16599
+ propsObjectName: ctx.propsObjectName,
16600
+ propsParams: ctx.propsParams,
16601
+ typeDefinitions: ctx.typeDefinitions ?? []
16602
+ };
16603
+ return datePlugin.prepare(metadataSlice);
16604
+ }
16605
+ function lowerDateCallsInReactiveExpr(expr, matcher) {
16606
+ if (!matcher)
16607
+ return expr;
16608
+ let sourceFile;
16609
+ try {
16610
+ sourceFile = ts14.createSourceFile("__reactive_expr__.ts", `(${expr});`, ts14.ScriptTarget.Latest, true, ts14.ScriptKind.TS);
16611
+ } catch {
16612
+ return expr;
16613
+ }
16614
+ const stmt = sourceFile.statements[0];
16615
+ if (!stmt || !ts14.isExpressionStatement(stmt))
16616
+ return expr;
16617
+ const root = ts14.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
16618
+ const candidates = [];
16619
+ const visit3 = (n) => {
16620
+ if (ts14.isCallExpression(n) && n.arguments.length === 0 && ts14.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
16621
+ candidates.push(n);
16622
+ }
16623
+ ts14.forEachChild(n, visit3);
16624
+ };
16625
+ visit3(root);
16626
+ if (candidates.length === 0)
16627
+ return expr;
16628
+ const { protect, restore } = createTemplateAwareStringProtector();
16629
+ let result = protect(expr);
16630
+ for (const call of candidates) {
16631
+ const propAccess = call.expression;
16632
+ const node = matcher(tsNodeToParsedExpr(propAccess), []);
16633
+ if (!node || node.kind !== "helper-call" || node.helper !== "date")
16634
+ continue;
16635
+ const op = propAccess.name.text;
16636
+ const receiverText = propAccess.expression.getText(sourceFile);
16637
+ const matchText = call.getText(sourceFile);
16638
+ result = result.replace(matchText, () => `date(${receiverText}, "${op}")`);
16639
+ }
16640
+ return restore(result);
16641
+ }
16389
16642
  function emitDynamicTextUpdates(lines, ctx) {
16643
+ const dateLoweringMatcher = getReactiveDateLoweringMatcher(ctx);
16390
16644
  const byExpression = new Map;
16391
16645
  for (const elem of ctx.dynamicElements) {
16392
16646
  const key = elem.expression;
@@ -16395,7 +16649,8 @@ function emitDynamicTextUpdates(lines, ctx) {
16395
16649
  }
16396
16650
  byExpression.get(key).push(elem);
16397
16651
  }
16398
- for (const [expr, elems] of byExpression) {
16652
+ for (const [rawExpr, elems] of byExpression) {
16653
+ const expr = lowerDateCallsInReactiveExpr(rawExpr, dateLoweringMatcher);
16399
16654
  const conditionalElems = elems.filter((e) => e.insideConditional);
16400
16655
  const normalElems = elems.filter((e) => !e.insideConditional);
16401
16656
  if (normalElems.length > 0 || conditionalElems.length > 0) {
@@ -17895,20 +18150,20 @@ var PHASES = [
17895
18150
  ];
17896
18151
 
17897
18152
  // src/ir-to-client-js/rewrite-props-object.ts
17898
- import ts14 from "typescript";
18153
+ import ts15 from "typescript";
17899
18154
  function rewritePropsObjectRef(code, propsObjectName) {
17900
18155
  const srcPropsName = propsObjectName ?? "props";
17901
18156
  if (srcPropsName === PROPS_PARAM)
17902
18157
  return code;
17903
18158
  if (!new RegExp(`\\b${srcPropsName}\\b`).test(code))
17904
18159
  return code;
17905
- const sourceFile = ts14.createSourceFile("init-body.ts", code, ts14.ScriptTarget.Latest, true, ts14.ScriptKind.TS);
18160
+ const sourceFile = ts15.createSourceFile("init-body.ts", code, ts15.ScriptTarget.Latest, true, ts15.ScriptKind.TS);
17906
18161
  const spans = [];
17907
18162
  function visit3(node) {
17908
- if (ts14.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
18163
+ if (ts15.isIdentifier(node) && node.text === srcPropsName && shouldRewrite(node)) {
17909
18164
  spans.push([node.getStart(sourceFile), node.getEnd()]);
17910
18165
  }
17911
- ts14.forEachChild(node, visit3);
18166
+ ts15.forEachChild(node, visit3);
17912
18167
  }
17913
18168
  visit3(sourceFile);
17914
18169
  if (spans.length === 0)
@@ -17924,17 +18179,17 @@ function shouldRewrite(node) {
17924
18179
  const parent = node.parent;
17925
18180
  if (!parent)
17926
18181
  return true;
17927
- if (ts14.isPropertyAccessExpression(parent) && parent.name === node)
18182
+ if (ts15.isPropertyAccessExpression(parent) && parent.name === node)
17928
18183
  return false;
17929
- if (ts14.isPropertyAssignment(parent) && parent.name === node)
18184
+ if (ts15.isPropertyAssignment(parent) && parent.name === node)
17930
18185
  return false;
17931
- if (ts14.isShorthandPropertyAssignment(parent) && parent.name === node)
18186
+ if (ts15.isShorthandPropertyAssignment(parent) && parent.name === node)
17932
18187
  return false;
17933
- if (ts14.isPropertySignature(parent) && parent.name === node)
18188
+ if (ts15.isPropertySignature(parent) && parent.name === node)
17934
18189
  return false;
17935
- if (ts14.isPropertyDeclaration(parent) && parent.name === node)
18190
+ if (ts15.isPropertyDeclaration(parent) && parent.name === node)
17936
18191
  return false;
17937
- if (ts14.isBindingElement(parent) && parent.name === node)
18192
+ if (ts15.isBindingElement(parent) && parent.name === node)
17938
18193
  return false;
17939
18194
  return true;
17940
18195
  }
@@ -18222,6 +18477,8 @@ function createContext(ir, scope, adapterCapabilities, profile) {
18222
18477
  propsParams: ir.metadata.propsParams,
18223
18478
  propsObjectName: ir.metadata.propsObjectName,
18224
18479
  restPropsName: ir.metadata.restPropsName,
18480
+ propsType: ir.metadata.propsType,
18481
+ typeDefinitions: ir.metadata.typeDefinitions,
18225
18482
  interactiveElements: [],
18226
18483
  dynamicElements: [],
18227
18484
  conditionalElements: [],
@@ -18457,7 +18714,7 @@ function walkIR2(node, visitor) {
18457
18714
  }
18458
18715
 
18459
18716
  // src/preprocess-inline-jsx-callbacks.ts
18460
- import ts15 from "typescript";
18717
+ import ts16 from "typescript";
18461
18718
  var SYNTHETIC_PREFIX = "BFInlineJsxCallback";
18462
18719
  var MAX_FIXPOINT_ITERATIONS = 16;
18463
18720
  function preprocessInlineJsxCallbacks(source, filePath) {
@@ -18479,8 +18736,8 @@ function preprocessInlineJsxCallbacks(source, filePath) {
18479
18736
  return { source: current, errors, syntheticNames };
18480
18737
  }
18481
18738
  function runSinglePass(source, filePath, startingCounter) {
18482
- const sourceFile = ts15.createSourceFile(filePath, source, ts15.ScriptTarget.Latest, true, ts15.ScriptKind.TSX);
18483
- const hasUseClient = sourceFile.statements.some((stmt) => ts15.isExpressionStatement(stmt) && ts15.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
18739
+ const sourceFile = ts16.createSourceFile(filePath, source, ts16.ScriptTarget.Latest, true, ts16.ScriptKind.TSX);
18740
+ const hasUseClient = sourceFile.statements.some((stmt) => ts16.isExpressionStatement(stmt) && ts16.isStringLiteral(stmt.expression) && (stmt.expression.text === "use client" || stmt.expression.text === "'use client'"));
18484
18741
  if (!hasUseClient) {
18485
18742
  return { source, errors: [], syntheticNames: [], counterAfter: startingCounter };
18486
18743
  }
@@ -18502,22 +18759,22 @@ function runSinglePass(source, filePath, startingCounter) {
18502
18759
  }
18503
18760
  }
18504
18761
  function visit3(node) {
18505
- if (ts15.isJsxAttribute(node) && node.initializer && ts15.isJsxExpression(node.initializer) && node.initializer.expression) {
18762
+ if (ts16.isJsxAttribute(node) && node.initializer && ts16.isJsxExpression(node.initializer) && node.initializer.expression) {
18506
18763
  if (tryHandleArrowValue(node.initializer.expression)) {
18507
18764
  return;
18508
18765
  }
18509
18766
  }
18510
- if (ts15.isPropertyAssignment(node) && node.initializer) {
18767
+ if (ts16.isPropertyAssignment(node) && node.initializer) {
18511
18768
  if (tryHandleArrowValue(node.initializer))
18512
18769
  return;
18513
18770
  }
18514
- ts15.forEachChild(node, visit3);
18771
+ ts16.forEachChild(node, visit3);
18515
18772
  }
18516
18773
  function tryHandleArrowValue(initializer) {
18517
18774
  let expr = initializer;
18518
- while (ts15.isParenthesizedExpression(expr))
18775
+ while (ts16.isParenthesizedExpression(expr))
18519
18776
  expr = expr.expression;
18520
- if (ts15.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
18777
+ if (ts16.isArrowFunction(expr) && arrowBodyContainsJsx(expr)) {
18521
18778
  return handleInlineArrow(expr);
18522
18779
  }
18523
18780
  return false;
@@ -18554,7 +18811,7 @@ function runSinglePass(source, filePath, startingCounter) {
18554
18811
  replacements.push({ start: arrowStart, end: arrowEnd, text: name });
18555
18812
  return true;
18556
18813
  }
18557
- ts15.forEachChild(sourceFile, visit3);
18814
+ ts16.forEachChild(sourceFile, visit3);
18558
18815
  if (replacements.length === 0) {
18559
18816
  return { source, errors, syntheticNames, counterAfter: counter };
18560
18817
  }
@@ -18577,11 +18834,11 @@ function errorMessageForCapture(captures) {
18577
18834
  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.`;
18578
18835
  }
18579
18836
  function arrowBodyContainsJsx(arrow) {
18580
- if (ts15.isBlock(arrow.body)) {
18837
+ if (ts16.isBlock(arrow.body)) {
18581
18838
  return blockReturnsJsx(arrow.body);
18582
18839
  }
18583
18840
  let body = arrow.body;
18584
- while (ts15.isParenthesizedExpression(body))
18841
+ while (ts16.isParenthesizedExpression(body))
18585
18842
  body = body.expression;
18586
18843
  return isJsxLike(body);
18587
18844
  }
@@ -18590,24 +18847,24 @@ function blockReturnsJsx(block) {
18590
18847
  function visit3(n) {
18591
18848
  if (found)
18592
18849
  return;
18593
- if (ts15.isReturnStatement(n) && n.expression) {
18850
+ if (ts16.isReturnStatement(n) && n.expression) {
18594
18851
  let e = n.expression;
18595
- while (ts15.isParenthesizedExpression(e))
18852
+ while (ts16.isParenthesizedExpression(e))
18596
18853
  e = e.expression;
18597
18854
  if (isJsxLike(e)) {
18598
18855
  found = true;
18599
18856
  return;
18600
18857
  }
18601
18858
  }
18602
- if (ts15.isArrowFunction(n) || ts15.isFunctionDeclaration(n) || ts15.isFunctionExpression(n))
18859
+ if (ts16.isArrowFunction(n) || ts16.isFunctionDeclaration(n) || ts16.isFunctionExpression(n))
18603
18860
  return;
18604
- ts15.forEachChild(n, visit3);
18861
+ ts16.forEachChild(n, visit3);
18605
18862
  }
18606
- ts15.forEachChild(block, visit3);
18863
+ ts16.forEachChild(block, visit3);
18607
18864
  return found;
18608
18865
  }
18609
18866
  function isJsxLike(expr) {
18610
- return ts15.isJsxElement(expr) || ts15.isJsxSelfClosingElement(expr) || ts15.isJsxFragment(expr);
18867
+ return ts16.isJsxElement(expr) || ts16.isJsxSelfClosingElement(expr) || ts16.isJsxFragment(expr);
18611
18868
  }
18612
18869
  function collectArrowParamNames(arrow) {
18613
18870
  const names = new Set;
@@ -18617,13 +18874,13 @@ function collectArrowParamNames(arrow) {
18617
18874
  }
18618
18875
  function collectBindingNames(name, out) {
18619
18876
  const push = Array.isArray(out) ? (n) => out.push(n) : (n) => out.add(n);
18620
- if (ts15.isIdentifier(name)) {
18877
+ if (ts16.isIdentifier(name)) {
18621
18878
  push(name.text);
18622
- } else if (ts15.isObjectBindingPattern(name)) {
18879
+ } else if (ts16.isObjectBindingPattern(name)) {
18623
18880
  name.elements.forEach((el) => collectBindingNames(el.name, out));
18624
- } else if (ts15.isArrayBindingPattern(name)) {
18881
+ } else if (ts16.isArrayBindingPattern(name)) {
18625
18882
  name.elements.forEach((el) => {
18626
- if (!ts15.isOmittedExpression(el))
18883
+ if (!ts16.isOmittedExpression(el))
18627
18884
  collectBindingNames(el.name, out);
18628
18885
  });
18629
18886
  }
@@ -18650,48 +18907,48 @@ function collectFreeIdentifiers(arrow) {
18650
18907
  return bound.includes(name);
18651
18908
  }
18652
18909
  function visit3(node) {
18653
- if (ts15.isIdentifier(node)) {
18910
+ if (ts16.isIdentifier(node)) {
18654
18911
  const parent = node.parent;
18655
- if (parent && ts15.isPropertyAccessExpression(parent) && parent.name === node)
18912
+ if (parent && ts16.isPropertyAccessExpression(parent) && parent.name === node)
18656
18913
  return;
18657
- if (parent && ts15.isPropertyAssignment(parent) && parent.name === node)
18914
+ if (parent && ts16.isPropertyAssignment(parent) && parent.name === node)
18658
18915
  return;
18659
- if (parent && ts15.isPropertySignature(parent) && parent.name === node)
18916
+ if (parent && ts16.isPropertySignature(parent) && parent.name === node)
18660
18917
  return;
18661
- if (parent && ts15.isPropertyDeclaration(parent) && parent.name === node)
18918
+ if (parent && ts16.isPropertyDeclaration(parent) && parent.name === node)
18662
18919
  return;
18663
- if (parent && ts15.isMethodDeclaration(parent) && parent.name === node)
18920
+ if (parent && ts16.isMethodDeclaration(parent) && parent.name === node)
18664
18921
  return;
18665
- if (parent && ts15.isMethodSignature(parent) && parent.name === node)
18922
+ if (parent && ts16.isMethodSignature(parent) && parent.name === node)
18666
18923
  return;
18667
- if (parent && ts15.isGetAccessorDeclaration(parent) && parent.name === node)
18924
+ if (parent && ts16.isGetAccessorDeclaration(parent) && parent.name === node)
18668
18925
  return;
18669
- if (parent && ts15.isSetAccessorDeclaration(parent) && parent.name === node)
18926
+ if (parent && ts16.isSetAccessorDeclaration(parent) && parent.name === node)
18670
18927
  return;
18671
- if (parent && ts15.isEnumMember(parent) && parent.name === node)
18928
+ if (parent && ts16.isEnumMember(parent) && parent.name === node)
18672
18929
  return;
18673
- if (parent && ts15.isBindingElement(parent) && parent.propertyName === node)
18930
+ if (parent && ts16.isBindingElement(parent) && parent.propertyName === node)
18674
18931
  return;
18675
- if (parent && ts15.isShorthandPropertyAssignment(parent) && parent.name === node) {
18932
+ if (parent && ts16.isShorthandPropertyAssignment(parent) && parent.name === node) {
18676
18933
  if (!isBound(node.text))
18677
18934
  ids.add(node.text);
18678
18935
  return;
18679
18936
  }
18680
- if (parent && ts15.isParameter(parent) && parent.name === node)
18937
+ if (parent && ts16.isParameter(parent) && parent.name === node)
18681
18938
  return;
18682
- if (parent && ts15.isVariableDeclaration(parent) && parent.name === node)
18939
+ if (parent && ts16.isVariableDeclaration(parent) && parent.name === node)
18683
18940
  return;
18684
- if (parent && ts15.isFunctionDeclaration(parent) && parent.name === node)
18941
+ if (parent && ts16.isFunctionDeclaration(parent) && parent.name === node)
18685
18942
  return;
18686
- if (parent && ts15.isClassDeclaration(parent) && parent.name === node)
18943
+ if (parent && ts16.isClassDeclaration(parent) && parent.name === node)
18687
18944
  return;
18688
- if (parent && ts15.isJsxAttribute(parent) && parent.name === node)
18945
+ if (parent && ts16.isJsxAttribute(parent) && parent.name === node)
18689
18946
  return;
18690
- if (parent && ts15.isJsxOpeningElement(parent) && parent.tagName === node) {
18947
+ if (parent && ts16.isJsxOpeningElement(parent) && parent.tagName === node) {
18691
18948
  if (/^[a-z]/.test(node.text))
18692
18949
  return;
18693
18950
  }
18694
- if (parent && ts15.isJsxClosingElement(parent) && parent.tagName === node) {
18951
+ if (parent && ts16.isJsxClosingElement(parent) && parent.tagName === node) {
18695
18952
  if (/^[a-z]/.test(node.text))
18696
18953
  return;
18697
18954
  }
@@ -18700,43 +18957,43 @@ function collectFreeIdentifiers(arrow) {
18700
18957
  ids.add(node.text);
18701
18958
  return;
18702
18959
  }
18703
- if (ts15.isVariableDeclaration(node)) {
18960
+ if (ts16.isVariableDeclaration(node)) {
18704
18961
  const declared = pushBindings(node.name);
18705
18962
  if (node.initializer)
18706
18963
  visit3(node.initializer);
18707
18964
  return;
18708
18965
  }
18709
- if (ts15.isFunctionDeclaration(node)) {
18966
+ if (ts16.isFunctionDeclaration(node)) {
18710
18967
  if (node.name)
18711
18968
  bound.push(node.name.text);
18712
18969
  visitInsideNewScope(node);
18713
18970
  return;
18714
18971
  }
18715
- if (ts15.isClassDeclaration(node)) {
18972
+ if (ts16.isClassDeclaration(node)) {
18716
18973
  if (node.name)
18717
18974
  bound.push(node.name.text);
18718
- ts15.forEachChild(node, visit3);
18975
+ ts16.forEachChild(node, visit3);
18719
18976
  return;
18720
18977
  }
18721
- if (ts15.isArrowFunction(node) || ts15.isFunctionExpression(node)) {
18978
+ if (ts16.isArrowFunction(node) || ts16.isFunctionExpression(node)) {
18722
18979
  visitInsideNewScope(node);
18723
18980
  return;
18724
18981
  }
18725
- if (ts15.isCatchClause(node)) {
18982
+ if (ts16.isCatchClause(node)) {
18726
18983
  const before = bound.length;
18727
18984
  if (node.variableDeclaration)
18728
18985
  pushBindings(node.variableDeclaration.name);
18729
- ts15.forEachChild(node, visit3);
18986
+ ts16.forEachChild(node, visit3);
18730
18987
  popN(bound.length - before);
18731
18988
  return;
18732
18989
  }
18733
- if (ts15.isBlock(node)) {
18990
+ if (ts16.isBlock(node)) {
18734
18991
  const before = bound.length;
18735
- ts15.forEachChild(node, visit3);
18992
+ ts16.forEachChild(node, visit3);
18736
18993
  popN(bound.length - before);
18737
18994
  return;
18738
18995
  }
18739
- ts15.forEachChild(node, visit3);
18996
+ ts16.forEachChild(node, visit3);
18740
18997
  }
18741
18998
  function visitInsideNewScope(fn) {
18742
18999
  const before = bound.length;
@@ -18759,29 +19016,29 @@ function collectFreeIdentifiers(arrow) {
18759
19016
  function collectModuleScopeNames(sourceFile) {
18760
19017
  const names = new Set;
18761
19018
  for (const stmt of sourceFile.statements) {
18762
- if (ts15.isFunctionDeclaration(stmt) && stmt.name)
19019
+ if (ts16.isFunctionDeclaration(stmt) && stmt.name)
18763
19020
  names.add(stmt.name.text);
18764
- else if (ts15.isClassDeclaration(stmt) && stmt.name)
19021
+ else if (ts16.isClassDeclaration(stmt) && stmt.name)
18765
19022
  names.add(stmt.name.text);
18766
- else if (ts15.isVariableStatement(stmt)) {
19023
+ else if (ts16.isVariableStatement(stmt)) {
18767
19024
  for (const decl of stmt.declarationList.declarations)
18768
19025
  collectBindingNames(decl.name, names);
18769
- } else if (ts15.isImportDeclaration(stmt) && stmt.importClause) {
19026
+ } else if (ts16.isImportDeclaration(stmt) && stmt.importClause) {
18770
19027
  const ic = stmt.importClause;
18771
19028
  if (ic.name)
18772
19029
  names.add(ic.name.text);
18773
19030
  if (ic.namedBindings) {
18774
- if (ts15.isNamespaceImport(ic.namedBindings))
19031
+ if (ts16.isNamespaceImport(ic.namedBindings))
18775
19032
  names.add(ic.namedBindings.name.text);
18776
19033
  else
18777
19034
  for (const e of ic.namedBindings.elements)
18778
19035
  names.add(e.name.text);
18779
19036
  }
18780
- } else if (ts15.isTypeAliasDeclaration(stmt))
19037
+ } else if (ts16.isTypeAliasDeclaration(stmt))
18781
19038
  names.add(stmt.name.text);
18782
- else if (ts15.isInterfaceDeclaration(stmt))
19039
+ else if (ts16.isInterfaceDeclaration(stmt))
18783
19040
  names.add(stmt.name.text);
18784
- else if (ts15.isEnumDeclaration(stmt))
19041
+ else if (ts16.isEnumDeclaration(stmt))
18785
19042
  names.add(stmt.name.text);
18786
19043
  }
18787
19044
  return names;
@@ -18789,7 +19046,7 @@ function collectModuleScopeNames(sourceFile) {
18789
19046
  function buildSyntheticDeclaration(name, arrow, sourceFile) {
18790
19047
  const paramsText = arrow.parameters.length === 0 ? "" : arrow.parameters.map((p) => p.getText(sourceFile)).join(", ");
18791
19048
  let bodyText;
18792
- if (ts15.isBlock(arrow.body)) {
19049
+ if (ts16.isBlock(arrow.body)) {
18793
19050
  bodyText = arrow.body.getText(sourceFile);
18794
19051
  } else {
18795
19052
  const expr = arrow.body.getText(sourceFile);
@@ -18799,7 +19056,7 @@ function buildSyntheticDeclaration(name, arrow, sourceFile) {
18799
19056
  }
18800
19057
 
18801
19058
  // src/ssr-defaults.ts
18802
- import ts16 from "typescript";
19059
+ import ts17 from "typescript";
18803
19060
  var UNRESOLVED = Symbol("unresolved");
18804
19061
  var NO_RETURN = Symbol("no-return");
18805
19062
  function extractSsrDefaults(metadata) {
@@ -18875,11 +19132,11 @@ function collectPropRefs(expr, propsObjectName, out) {
18875
19132
  if (!node)
18876
19133
  return;
18877
19134
  const visit3 = (n) => {
18878
- if (ts16.isPropertyAccessExpression(n) && ts16.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts16.isIdentifier(n.name)) {
19135
+ if (ts17.isPropertyAccessExpression(n) && ts17.isIdentifier(n.expression) && n.expression.text === propsObjectName && ts17.isIdentifier(n.name)) {
18879
19136
  out.add(n.name.text);
18880
19137
  return;
18881
19138
  }
18882
- ts16.forEachChild(n, visit3);
19139
+ ts17.forEachChild(n, visit3);
18883
19140
  };
18884
19141
  visit3(node);
18885
19142
  }
@@ -18900,23 +19157,23 @@ function tryStaticEval(expr, ctx) {
18900
19157
  }
18901
19158
  function evalStatementsForReturn(statements, ctx) {
18902
19159
  for (const stmt of statements) {
18903
- if (ts16.isVariableStatement(stmt)) {
19160
+ if (ts17.isVariableStatement(stmt)) {
18904
19161
  for (const d of stmt.declarationList.declarations) {
18905
- if (!ts16.isIdentifier(d.name) || !d.initializer)
19162
+ if (!ts17.isIdentifier(d.name) || !d.initializer)
18906
19163
  continue;
18907
19164
  const v = evalNode(d.initializer, ctx);
18908
19165
  if (v !== UNRESOLVED)
18909
19166
  ctx.bindings[d.name.text] = v;
18910
19167
  }
18911
- } else if (ts16.isReturnStatement(stmt)) {
19168
+ } else if (ts17.isReturnStatement(stmt)) {
18912
19169
  return stmt.expression ? evalNode(stmt.expression, ctx) : UNRESOLVED;
18913
- } else if (ts16.isIfStatement(stmt)) {
19170
+ } else if (ts17.isIfStatement(stmt)) {
18914
19171
  const cond = evalNode(stmt.expression, ctx);
18915
19172
  if (cond === UNRESOLVED)
18916
19173
  return UNRESOLVED;
18917
19174
  const branch = cond ? stmt.thenStatement : stmt.elseStatement;
18918
19175
  if (branch) {
18919
- const taken = evalStatementsForReturn(ts16.isBlock(branch) ? branch.statements : [branch], ctx);
19176
+ const taken = evalStatementsForReturn(ts17.isBlock(branch) ? branch.statements : [branch], ctx);
18920
19177
  if (taken !== NO_RETURN)
18921
19178
  return taken;
18922
19179
  }
@@ -18927,45 +19184,45 @@ function evalStatementsForReturn(statements, ctx) {
18927
19184
  return NO_RETURN;
18928
19185
  }
18929
19186
  function parseExpression2(expr) {
18930
- const sf = ts16.createSourceFile("__ssr_default__.ts", `(${expr})`, ts16.ScriptTarget.Latest, false, ts16.ScriptKind.TS);
19187
+ const sf = ts17.createSourceFile("__ssr_default__.ts", `(${expr})`, ts17.ScriptTarget.Latest, false, ts17.ScriptKind.TS);
18931
19188
  const stmt = sf.statements[0];
18932
- if (!stmt || !ts16.isExpressionStatement(stmt))
19189
+ if (!stmt || !ts17.isExpressionStatement(stmt))
18933
19190
  return null;
18934
- const inner = ts16.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
19191
+ const inner = ts17.isParenthesizedExpression(stmt.expression) ? stmt.expression.expression : stmt.expression;
18935
19192
  return inner;
18936
19193
  }
18937
19194
  function evalNode(node, ctx) {
18938
- if (ts16.isParenthesizedExpression(node))
19195
+ if (ts17.isParenthesizedExpression(node))
18939
19196
  return evalNode(node.expression, ctx);
18940
- if (ts16.isAsExpression(node))
19197
+ if (ts17.isAsExpression(node))
18941
19198
  return evalNode(node.expression, ctx);
18942
- if (ts16.isSatisfiesExpression(node))
19199
+ if (ts17.isSatisfiesExpression(node))
18943
19200
  return evalNode(node.expression, ctx);
18944
- if (ts16.isTypeAssertionExpression(node))
19201
+ if (ts17.isTypeAssertionExpression(node))
18945
19202
  return evalNode(node.expression, ctx);
18946
- if (ts16.isNonNullExpression(node))
19203
+ if (ts17.isNonNullExpression(node))
18947
19204
  return evalNode(node.expression, ctx);
18948
- if (ts16.isArrowFunction(node)) {
19205
+ if (ts17.isArrowFunction(node)) {
18949
19206
  if (node.parameters.length !== 0)
18950
19207
  return UNRESOLVED;
18951
- if (!ts16.isBlock(node.body))
19208
+ if (!ts17.isBlock(node.body))
18952
19209
  return evalNode(node.body, ctx);
18953
19210
  const localBindings = { ...ctx.bindings };
18954
19211
  const localCtx = { ...ctx, bindings: localBindings };
18955
19212
  const result = evalStatementsForReturn(node.body.statements, localCtx);
18956
19213
  return result === NO_RETURN ? UNRESOLVED : result;
18957
19214
  }
18958
- if (ts16.isNumericLiteral(node))
19215
+ if (ts17.isNumericLiteral(node))
18959
19216
  return Number(node.text);
18960
- if (ts16.isStringLiteralLike(node))
19217
+ if (ts17.isStringLiteralLike(node))
18961
19218
  return node.text;
18962
- if (node.kind === ts16.SyntaxKind.TrueKeyword)
19219
+ if (node.kind === ts17.SyntaxKind.TrueKeyword)
18963
19220
  return true;
18964
- if (node.kind === ts16.SyntaxKind.FalseKeyword)
19221
+ if (node.kind === ts17.SyntaxKind.FalseKeyword)
18965
19222
  return false;
18966
- if (node.kind === ts16.SyntaxKind.NullKeyword)
19223
+ if (node.kind === ts17.SyntaxKind.NullKeyword)
18967
19224
  return null;
18968
- if (ts16.isIdentifier(node)) {
19225
+ if (ts17.isIdentifier(node)) {
18969
19226
  if (node.text === "undefined")
18970
19227
  return;
18971
19228
  if (node.text in ctx.bindings)
@@ -18974,29 +19231,29 @@ function evalNode(node, ctx) {
18974
19231
  return;
18975
19232
  return UNRESOLVED;
18976
19233
  }
18977
- if (ts16.isPrefixUnaryExpression(node)) {
19234
+ if (ts17.isPrefixUnaryExpression(node)) {
18978
19235
  const arg = evalNode(node.operand, ctx);
18979
19236
  if (arg === UNRESOLVED)
18980
19237
  return UNRESOLVED;
18981
19238
  switch (node.operator) {
18982
- case ts16.SyntaxKind.MinusToken:
19239
+ case ts17.SyntaxKind.MinusToken:
18983
19240
  return typeof arg === "number" ? -arg : UNRESOLVED;
18984
- case ts16.SyntaxKind.PlusToken:
19241
+ case ts17.SyntaxKind.PlusToken:
18985
19242
  return typeof arg === "number" ? +arg : UNRESOLVED;
18986
- case ts16.SyntaxKind.ExclamationToken:
19243
+ case ts17.SyntaxKind.ExclamationToken:
18987
19244
  return !arg;
18988
19245
  }
18989
19246
  return UNRESOLVED;
18990
19247
  }
18991
- if (ts16.isObjectLiteralExpression(node)) {
19248
+ if (ts17.isObjectLiteralExpression(node)) {
18992
19249
  const obj = {};
18993
19250
  for (const prop of node.properties) {
18994
- if (!ts16.isPropertyAssignment(prop))
19251
+ if (!ts17.isPropertyAssignment(prop))
18995
19252
  return UNRESOLVED;
18996
19253
  let key;
18997
- if (ts16.isIdentifier(prop.name) || ts16.isStringLiteralLike(prop.name)) {
19254
+ if (ts17.isIdentifier(prop.name) || ts17.isStringLiteralLike(prop.name)) {
18998
19255
  key = prop.name.text;
18999
- } else if (ts16.isNumericLiteral(prop.name)) {
19256
+ } else if (ts17.isNumericLiteral(prop.name)) {
19000
19257
  key = prop.name.text;
19001
19258
  } else {
19002
19259
  return UNRESOLVED;
@@ -19008,10 +19265,10 @@ function evalNode(node, ctx) {
19008
19265
  }
19009
19266
  return obj;
19010
19267
  }
19011
- if (ts16.isArrayLiteralExpression(node)) {
19268
+ if (ts17.isArrayLiteralExpression(node)) {
19012
19269
  const arr = [];
19013
19270
  for (const elem of node.elements) {
19014
- if (ts16.isOmittedExpression(elem))
19271
+ if (ts17.isOmittedExpression(elem))
19015
19272
  return UNRESOLVED;
19016
19273
  const v = evalNode(elem, ctx);
19017
19274
  if (v === UNRESOLVED)
@@ -19020,7 +19277,7 @@ function evalNode(node, ctx) {
19020
19277
  }
19021
19278
  return arr;
19022
19279
  }
19023
- if (ts16.isElementAccessExpression(node)) {
19280
+ if (ts17.isElementAccessExpression(node)) {
19024
19281
  const base = evalNode(node.expression, ctx);
19025
19282
  if (base === undefined)
19026
19283
  return;
@@ -19034,17 +19291,17 @@ function evalNode(node, ctx) {
19034
19291
  const k = String(key);
19035
19292
  return Object.prototype.hasOwnProperty.call(base, k) ? base[k] : undefined;
19036
19293
  }
19037
- if (ts16.isPropertyAccessExpression(node)) {
19294
+ if (ts17.isPropertyAccessExpression(node)) {
19038
19295
  const baseResult = evalNode(node.expression, ctx);
19039
19296
  if (baseResult === undefined)
19040
19297
  return;
19041
19298
  return UNRESOLVED;
19042
19299
  }
19043
- if (ts16.isCallExpression(node)) {
19044
- if (node.arguments.length === 0 && ts16.isIdentifier(node.expression) && node.expression.text in ctx.bindings) {
19300
+ if (ts17.isCallExpression(node)) {
19301
+ if (node.arguments.length === 0 && ts17.isIdentifier(node.expression) && node.expression.text in ctx.bindings) {
19045
19302
  return ctx.bindings[node.expression.text];
19046
19303
  }
19047
- if (ts16.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
19304
+ if (ts17.isPropertyAccessExpression(node.expression) && node.expression.name.text === "join") {
19048
19305
  const recv = evalNode(node.expression.expression, ctx);
19049
19306
  if (Array.isArray(recv)) {
19050
19307
  let sep2 = ",";
@@ -19060,27 +19317,27 @@ function evalNode(node, ctx) {
19060
19317
  }
19061
19318
  return UNRESOLVED;
19062
19319
  }
19063
- if (ts16.isConditionalExpression(node)) {
19320
+ if (ts17.isConditionalExpression(node)) {
19064
19321
  const cond = evalNode(node.condition, ctx);
19065
19322
  if (cond === UNRESOLVED)
19066
19323
  return UNRESOLVED;
19067
19324
  return cond ? evalNode(node.whenTrue, ctx) : evalNode(node.whenFalse, ctx);
19068
19325
  }
19069
- if (ts16.isBinaryExpression(node)) {
19326
+ if (ts17.isBinaryExpression(node)) {
19070
19327
  const op = node.operatorToken.kind;
19071
- if (op === ts16.SyntaxKind.QuestionQuestionToken) {
19328
+ if (op === ts17.SyntaxKind.QuestionQuestionToken) {
19072
19329
  const l2 = evalNode(node.left, ctx);
19073
19330
  if (l2 !== UNRESOLVED && l2 !== null && l2 !== undefined)
19074
19331
  return l2;
19075
19332
  return evalNode(node.right, ctx);
19076
19333
  }
19077
- if (op === ts16.SyntaxKind.BarBarToken) {
19334
+ if (op === ts17.SyntaxKind.BarBarToken) {
19078
19335
  const l2 = evalNode(node.left, ctx);
19079
19336
  if (l2 !== UNRESOLVED && l2)
19080
19337
  return l2;
19081
19338
  return evalNode(node.right, ctx);
19082
19339
  }
19083
- if (op === ts16.SyntaxKind.AmpersandAmpersandToken) {
19340
+ if (op === ts17.SyntaxKind.AmpersandAmpersandToken) {
19084
19341
  const l2 = evalNode(node.left, ctx);
19085
19342
  if (l2 === UNRESOLVED)
19086
19343
  return UNRESOLVED;
@@ -19093,30 +19350,30 @@ function evalNode(node, ctx) {
19093
19350
  if (l === UNRESOLVED || r === UNRESOLVED)
19094
19351
  return UNRESOLVED;
19095
19352
  switch (op) {
19096
- case ts16.SyntaxKind.PlusToken:
19353
+ case ts17.SyntaxKind.PlusToken:
19097
19354
  if (typeof l === "string" || typeof r === "string")
19098
19355
  return `${l}${r}`;
19099
19356
  if (typeof l === "number" && typeof r === "number")
19100
19357
  return l + r;
19101
19358
  return UNRESOLVED;
19102
- case ts16.SyntaxKind.MinusToken:
19359
+ case ts17.SyntaxKind.MinusToken:
19103
19360
  return typeof l === "number" && typeof r === "number" ? l - r : UNRESOLVED;
19104
- case ts16.SyntaxKind.AsteriskToken:
19361
+ case ts17.SyntaxKind.AsteriskToken:
19105
19362
  return typeof l === "number" && typeof r === "number" ? l * r : UNRESOLVED;
19106
- case ts16.SyntaxKind.SlashToken:
19363
+ case ts17.SyntaxKind.SlashToken:
19107
19364
  return typeof l === "number" && typeof r === "number" && r !== 0 ? l / r : UNRESOLVED;
19108
- case ts16.SyntaxKind.PercentToken:
19365
+ case ts17.SyntaxKind.PercentToken:
19109
19366
  return typeof l === "number" && typeof r === "number" && r !== 0 ? l % r : UNRESOLVED;
19110
- case ts16.SyntaxKind.EqualsEqualsEqualsToken:
19111
- case ts16.SyntaxKind.EqualsEqualsToken:
19367
+ case ts17.SyntaxKind.EqualsEqualsEqualsToken:
19368
+ case ts17.SyntaxKind.EqualsEqualsToken:
19112
19369
  return l === r;
19113
- case ts16.SyntaxKind.ExclamationEqualsEqualsToken:
19114
- case ts16.SyntaxKind.ExclamationEqualsToken:
19370
+ case ts17.SyntaxKind.ExclamationEqualsEqualsToken:
19371
+ case ts17.SyntaxKind.ExclamationEqualsToken:
19115
19372
  return l !== r;
19116
19373
  }
19117
19374
  return UNRESOLVED;
19118
19375
  }
19119
- if (ts16.isTemplateExpression(node)) {
19376
+ if (ts17.isTemplateExpression(node)) {
19120
19377
  if (node.templateSpans.length === 0)
19121
19378
  return node.head.text;
19122
19379
  let acc = node.head.text;
@@ -19128,13 +19385,13 @@ function evalNode(node, ctx) {
19128
19385
  }
19129
19386
  return acc;
19130
19387
  }
19131
- if (ts16.isNoSubstitutionTemplateLiteral(node))
19388
+ if (ts17.isNoSubstitutionTemplateLiteral(node))
19132
19389
  return node.text;
19133
19390
  return UNRESOLVED;
19134
19391
  }
19135
19392
 
19136
19393
  // src/augment-inherited-props.ts
19137
- import ts17 from "typescript";
19394
+ import ts18 from "typescript";
19138
19395
  function collectContextConsumers(metadata) {
19139
19396
  const constants = metadata.localConstants ?? [];
19140
19397
  const contextDefaults = new Map;
@@ -19166,47 +19423,47 @@ function collectContextConsumers(metadata) {
19166
19423
  }
19167
19424
  function parseUseContextArg(source) {
19168
19425
  const expr = parseSingleExpression(source);
19169
- if (!expr || !ts17.isCallExpression(expr))
19426
+ if (!expr || !ts18.isCallExpression(expr))
19170
19427
  return null;
19171
- if (!ts17.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
19428
+ if (!ts18.isIdentifier(expr.expression) || expr.expression.text !== "useContext")
19172
19429
  return null;
19173
19430
  if (expr.arguments.length !== 1)
19174
19431
  return null;
19175
19432
  const arg = expr.arguments[0];
19176
- return ts17.isIdentifier(arg) ? arg.text : null;
19433
+ return ts18.isIdentifier(arg) ? arg.text : null;
19177
19434
  }
19178
19435
  function parseCreateContextDefault(source) {
19179
19436
  const expr = parseSingleExpression(source);
19180
- if (!expr || !ts17.isCallExpression(expr))
19437
+ if (!expr || !ts18.isCallExpression(expr))
19181
19438
  return null;
19182
19439
  if (expr.arguments.length === 0)
19183
19440
  return null;
19184
19441
  const arg = expr.arguments[0];
19185
- if (ts17.isStringLiteral(arg) || ts17.isNoSubstitutionTemplateLiteral(arg))
19442
+ if (ts18.isStringLiteral(arg) || ts18.isNoSubstitutionTemplateLiteral(arg))
19186
19443
  return arg.text;
19187
- if (ts17.isNumericLiteral(arg))
19444
+ if (ts18.isNumericLiteral(arg))
19188
19445
  return Number(arg.text);
19189
- if (arg.kind === ts17.SyntaxKind.TrueKeyword)
19446
+ if (arg.kind === ts18.SyntaxKind.TrueKeyword)
19190
19447
  return true;
19191
- if (arg.kind === ts17.SyntaxKind.FalseKeyword)
19448
+ if (arg.kind === ts18.SyntaxKind.FalseKeyword)
19192
19449
  return false;
19193
19450
  return null;
19194
19451
  }
19195
19452
  function isObjectLiteralCreateContextDefault(source) {
19196
19453
  const expr = parseSingleExpression(source);
19197
- if (!expr || !ts17.isCallExpression(expr))
19454
+ if (!expr || !ts18.isCallExpression(expr))
19198
19455
  return false;
19199
19456
  if (expr.arguments.length === 0)
19200
19457
  return false;
19201
- return ts17.isObjectLiteralExpression(expr.arguments[0]);
19458
+ return ts18.isObjectLiteralExpression(expr.arguments[0]);
19202
19459
  }
19203
19460
  function parseSingleExpression(source) {
19204
- const sf = ts17.createSourceFile("__ctx.ts", `(${source})`, ts17.ScriptTarget.Latest, false);
19461
+ const sf = ts18.createSourceFile("__ctx.ts", `(${source})`, ts18.ScriptTarget.Latest, false);
19205
19462
  const stmt = sf.statements[0];
19206
- if (!stmt || !ts17.isExpressionStatement(stmt))
19463
+ if (!stmt || !ts18.isExpressionStatement(stmt))
19207
19464
  return null;
19208
19465
  let e = stmt.expression;
19209
- while (ts17.isParenthesizedExpression(e))
19466
+ while (ts18.isParenthesizedExpression(e))
19210
19467
  e = e.expression;
19211
19468
  return e;
19212
19469
  }
@@ -19231,25 +19488,25 @@ function augmentInheritedPropAccesses(ir) {
19231
19488
  const pinCoalesceLiterals = (s) => {
19232
19489
  if (!s || !s.includes(propsObj))
19233
19490
  return;
19234
- const sf = ts17.createSourceFile("__aug.ts", `(${s})`, ts17.ScriptTarget.Latest, false);
19491
+ const sf = ts18.createSourceFile("__aug.ts", `(${s})`, ts18.ScriptTarget.Latest, false);
19235
19492
  const visit3 = (n) => {
19236
- if (ts17.isBinaryExpression(n) && (n.operatorToken.kind === ts17.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts17.SyntaxKind.BarBarToken)) {
19493
+ if (ts18.isBinaryExpression(n) && (n.operatorToken.kind === ts18.SyntaxKind.QuestionQuestionToken || n.operatorToken.kind === ts18.SyntaxKind.BarBarToken)) {
19237
19494
  let left = n.left;
19238
- while (ts17.isParenthesizedExpression(left))
19495
+ while (ts18.isParenthesizedExpression(left))
19239
19496
  left = left.expression;
19240
- if (ts17.isPropertyAccessExpression(left) && ts17.isIdentifier(left.expression) && left.expression.text === propsObj) {
19497
+ if (ts18.isPropertyAccessExpression(left) && ts18.isIdentifier(left.expression) && left.expression.text === propsObj) {
19241
19498
  const name = left.name.text;
19242
19499
  let right = n.right;
19243
- while (ts17.isParenthesizedExpression(right))
19500
+ while (ts18.isParenthesizedExpression(right))
19244
19501
  right = right.expression;
19245
- if (ts17.isPrefixUnaryExpression(right))
19502
+ if (ts18.isPrefixUnaryExpression(right))
19246
19503
  right = right.operand;
19247
- const kind = ts17.isNumericLiteral(right) ? "number" : right.kind === ts17.SyntaxKind.TrueKeyword || right.kind === ts17.SyntaxKind.FalseKeyword ? "boolean" : ts17.isStringLiteralLike(right) ? "string" : null;
19504
+ const kind = ts18.isNumericLiteral(right) ? "number" : right.kind === ts18.SyntaxKind.TrueKeyword || right.kind === ts18.SyntaxKind.FalseKeyword ? "boolean" : ts18.isStringLiteralLike(right) ? "string" : null;
19248
19505
  if (kind && !coalesceLiteralTypes.has(name))
19249
19506
  coalesceLiteralTypes.set(name, kind);
19250
19507
  }
19251
19508
  }
19252
- ts17.forEachChild(n, visit3);
19509
+ ts18.forEachChild(n, visit3);
19253
19510
  };
19254
19511
  visit3(sf);
19255
19512
  };
@@ -19360,33 +19617,33 @@ function augmentInheritedPropAccesses(ir) {
19360
19617
  }
19361
19618
  }
19362
19619
  function parseStaticStringConst(source) {
19363
- const sf = ts17.createSourceFile("__const.ts", `const __x = (${source});`, ts17.ScriptTarget.Latest, false);
19620
+ const sf = ts18.createSourceFile("__const.ts", `const __x = (${source});`, ts18.ScriptTarget.Latest, false);
19364
19621
  const stmt = sf.statements[0];
19365
- if (!stmt || !ts17.isVariableStatement(stmt))
19622
+ if (!stmt || !ts18.isVariableStatement(stmt))
19366
19623
  return null;
19367
19624
  let init = stmt.declarationList.declarations[0]?.initializer;
19368
- while (init && ts17.isParenthesizedExpression(init))
19625
+ while (init && ts18.isParenthesizedExpression(init))
19369
19626
  init = init.expression;
19370
19627
  if (!init)
19371
19628
  return null;
19372
- if (ts17.isStringLiteral(init) || ts17.isNoSubstitutionTemplateLiteral(init)) {
19629
+ if (ts18.isStringLiteral(init) || ts18.isNoSubstitutionTemplateLiteral(init)) {
19373
19630
  return init.text;
19374
19631
  }
19375
19632
  return evalStringArrayJoin(source);
19376
19633
  }
19377
19634
  function evalTemplateOfStringConsts(source, resolved) {
19378
- const sf = ts17.createSourceFile("__const.ts", `const __x = (${source});`, ts17.ScriptTarget.Latest, false);
19635
+ const sf = ts18.createSourceFile("__const.ts", `const __x = (${source});`, ts18.ScriptTarget.Latest, false);
19379
19636
  const stmt = sf.statements[0];
19380
- if (!stmt || !ts17.isVariableStatement(stmt))
19637
+ if (!stmt || !ts18.isVariableStatement(stmt))
19381
19638
  return null;
19382
19639
  let init = stmt.declarationList.declarations[0]?.initializer;
19383
- while (init && ts17.isParenthesizedExpression(init))
19640
+ while (init && ts18.isParenthesizedExpression(init))
19384
19641
  init = init.expression;
19385
- if (!init || !ts17.isTemplateExpression(init))
19642
+ if (!init || !ts18.isTemplateExpression(init))
19386
19643
  return null;
19387
19644
  let out = init.head.text;
19388
19645
  for (const span of init.templateSpans) {
19389
- if (!ts17.isIdentifier(span.expression))
19646
+ if (!ts18.isIdentifier(span.expression))
19390
19647
  return null;
19391
19648
  const value = resolved.get(span.expression.text);
19392
19649
  if (value === undefined)
@@ -19417,30 +19674,30 @@ function lookupStaticRecordLiteral(objectName, key, constants) {
19417
19674
  const constInfo = (constants ?? []).find((c) => c.name === objectName && c.isModule);
19418
19675
  if (constInfo?.value === undefined)
19419
19676
  return null;
19420
- const sf = ts17.createSourceFile("__rec.ts", `(${constInfo.value})`, ts17.ScriptTarget.Latest, true);
19677
+ const sf = ts18.createSourceFile("__rec.ts", `(${constInfo.value})`, ts18.ScriptTarget.Latest, true);
19421
19678
  if (sf.statements.length !== 1)
19422
19679
  return null;
19423
19680
  const stmt = sf.statements[0];
19424
- if (!ts17.isExpressionStatement(stmt))
19681
+ if (!ts18.isExpressionStatement(stmt))
19425
19682
  return null;
19426
19683
  let parsed = stmt.expression;
19427
- while (ts17.isParenthesizedExpression(parsed))
19684
+ while (ts18.isParenthesizedExpression(parsed))
19428
19685
  parsed = parsed.expression;
19429
- if (!ts17.isObjectLiteralExpression(parsed))
19686
+ if (!ts18.isObjectLiteralExpression(parsed))
19430
19687
  return null;
19431
19688
  for (const prop of parsed.properties) {
19432
- if (!ts17.isPropertyAssignment(prop))
19689
+ if (!ts18.isPropertyAssignment(prop))
19433
19690
  continue;
19434
19691
  const name = prop.name;
19435
- const propKey = ts17.isIdentifier(name) || ts17.isStringLiteral(name) || ts17.isNoSubstitutionTemplateLiteral(name) ? name.text : null;
19692
+ const propKey = ts18.isIdentifier(name) || ts18.isStringLiteral(name) || ts18.isNoSubstitutionTemplateLiteral(name) ? name.text : null;
19436
19693
  if (propKey !== key)
19437
19694
  continue;
19438
19695
  let v = prop.initializer;
19439
- while (ts17.isParenthesizedExpression(v))
19696
+ while (ts18.isParenthesizedExpression(v))
19440
19697
  v = v.expression;
19441
- if (ts17.isNumericLiteral(v))
19698
+ if (ts18.isNumericLiteral(v))
19442
19699
  return { kind: "number", text: v.text };
19443
- if (ts17.isStringLiteral(v) || ts17.isNoSubstitutionTemplateLiteral(v)) {
19700
+ if (ts18.isStringLiteral(v) || ts18.isNoSubstitutionTemplateLiteral(v)) {
19444
19701
  return { kind: "string", text: v.text };
19445
19702
  }
19446
19703
  return null;
@@ -19448,28 +19705,28 @@ function lookupStaticRecordLiteral(objectName, key, constants) {
19448
19705
  return null;
19449
19706
  }
19450
19707
  function evalStringArrayJoin(source) {
19451
- const sf = ts17.createSourceFile("__join.ts", `const __x = (${source});`, ts17.ScriptTarget.Latest, false);
19708
+ const sf = ts18.createSourceFile("__join.ts", `const __x = (${source});`, ts18.ScriptTarget.Latest, false);
19452
19709
  const stmt = sf.statements[0];
19453
- if (!stmt || !ts17.isVariableStatement(stmt))
19710
+ if (!stmt || !ts18.isVariableStatement(stmt))
19454
19711
  return null;
19455
19712
  let node = stmt.declarationList.declarations[0]?.initializer;
19456
- while (node && ts17.isParenthesizedExpression(node))
19713
+ while (node && ts18.isParenthesizedExpression(node))
19457
19714
  node = node.expression;
19458
- if (!node || !ts17.isCallExpression(node))
19715
+ if (!node || !ts18.isCallExpression(node))
19459
19716
  return null;
19460
19717
  const callee = node.expression;
19461
- if (!ts17.isPropertyAccessExpression(callee))
19718
+ if (!ts18.isPropertyAccessExpression(callee))
19462
19719
  return null;
19463
19720
  if (callee.name.text !== "join")
19464
19721
  return null;
19465
19722
  let recv = callee.expression;
19466
- while (ts17.isParenthesizedExpression(recv))
19723
+ while (ts18.isParenthesizedExpression(recv))
19467
19724
  recv = recv.expression;
19468
- if (!ts17.isArrayLiteralExpression(recv))
19725
+ if (!ts18.isArrayLiteralExpression(recv))
19469
19726
  return null;
19470
19727
  const parts = [];
19471
19728
  for (const el of recv.elements) {
19472
- if (ts17.isStringLiteral(el) || ts17.isNoSubstitutionTemplateLiteral(el)) {
19729
+ if (ts18.isStringLiteral(el) || ts18.isNoSubstitutionTemplateLiteral(el)) {
19473
19730
  parts.push(el.text);
19474
19731
  } else {
19475
19732
  return null;
@@ -19478,7 +19735,7 @@ function evalStringArrayJoin(source) {
19478
19735
  let sep2 = ",";
19479
19736
  if (node.arguments.length >= 1) {
19480
19737
  const arg = node.arguments[0];
19481
- if (ts17.isStringLiteral(arg) || ts17.isNoSubstitutionTemplateLiteral(arg))
19738
+ if (ts18.isStringLiteral(arg) || ts18.isNoSubstitutionTemplateLiteral(arg))
19482
19739
  sep2 = arg.text;
19483
19740
  else
19484
19741
  return null;
@@ -19486,11 +19743,11 @@ function evalStringArrayJoin(source) {
19486
19743
  return parts.join(sep2);
19487
19744
  }
19488
19745
  function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
19489
- if (!ts17.isElementAccessExpression(val))
19746
+ if (!ts18.isElementAccessExpression(val))
19490
19747
  return null;
19491
19748
  const obj = val.expression;
19492
19749
  const arg = val.argumentExpression;
19493
- if (!ts17.isIdentifier(obj) || !ts17.isIdentifier(arg))
19750
+ if (!ts18.isIdentifier(obj) || !ts18.isIdentifier(arg))
19494
19751
  return null;
19495
19752
  let indexPropName;
19496
19753
  let defaultKey;
@@ -19506,35 +19763,35 @@ function parseRecordIndexAccess(val, localConstants, propsParams, resolveKey) {
19506
19763
  const constInfo = localConstants.find((c) => c.name === obj.text && c.isModule);
19507
19764
  if (constInfo?.value === undefined)
19508
19765
  return null;
19509
- const sf = ts17.createSourceFile("__rec.ts", `(${constInfo.value})`, ts17.ScriptTarget.Latest, true);
19766
+ const sf = ts18.createSourceFile("__rec.ts", `(${constInfo.value})`, ts18.ScriptTarget.Latest, true);
19510
19767
  if (sf.statements.length !== 1)
19511
19768
  return null;
19512
19769
  const stmt = sf.statements[0];
19513
- if (!ts17.isExpressionStatement(stmt))
19770
+ if (!ts18.isExpressionStatement(stmt))
19514
19771
  return null;
19515
19772
  let parsed = stmt.expression;
19516
- while (ts17.isParenthesizedExpression(parsed))
19773
+ while (ts18.isParenthesizedExpression(parsed))
19517
19774
  parsed = parsed.expression;
19518
- if (!ts17.isObjectLiteralExpression(parsed))
19775
+ if (!ts18.isObjectLiteralExpression(parsed))
19519
19776
  return null;
19520
19777
  const entries = [];
19521
19778
  for (const prop of parsed.properties) {
19522
- if (!ts17.isPropertyAssignment(prop))
19779
+ if (!ts18.isPropertyAssignment(prop))
19523
19780
  return null;
19524
19781
  let key;
19525
- if (ts17.isIdentifier(prop.name)) {
19782
+ if (ts18.isIdentifier(prop.name)) {
19526
19783
  key = prop.name.text;
19527
- } else if (ts17.isStringLiteral(prop.name) || ts17.isNoSubstitutionTemplateLiteral(prop.name)) {
19784
+ } else if (ts18.isStringLiteral(prop.name) || ts18.isNoSubstitutionTemplateLiteral(prop.name)) {
19528
19785
  key = prop.name.text;
19529
19786
  } else {
19530
19787
  return null;
19531
19788
  }
19532
19789
  let v = prop.initializer;
19533
- while (ts17.isParenthesizedExpression(v))
19790
+ while (ts18.isParenthesizedExpression(v))
19534
19791
  v = v.expression;
19535
- if (ts17.isNumericLiteral(v)) {
19792
+ if (ts18.isNumericLiteral(v)) {
19536
19793
  entries.push({ key, value: { kind: "number", text: v.text } });
19537
- } else if (ts17.isStringLiteral(v) || ts17.isNoSubstitutionTemplateLiteral(v)) {
19794
+ } else if (ts18.isStringLiteral(v) || ts18.isNoSubstitutionTemplateLiteral(v)) {
19538
19795
  entries.push({ key, value: { kind: "string", text: v.text } });
19539
19796
  } else {
19540
19797
  return null;
@@ -19587,83 +19844,14 @@ function computeSsrSeedPlan(metadata) {
19587
19844
  return { baseScope, steps };
19588
19845
  }
19589
19846
 
19590
- // src/rich-type-evidence.ts
19591
- var HOST_RICH_TYPE_NAMES = new Set([
19592
- "Date",
19593
- "Map",
19594
- "Set",
19595
- "WeakMap",
19596
- "WeakSet",
19597
- "URL",
19598
- "URLSearchParams",
19599
- "RegExp",
19600
- "Promise",
19601
- "Error",
19602
- "Symbol",
19603
- "BigInt",
19604
- "Function"
19605
- ]);
19606
- function baseTypeName(raw) {
19607
- const idx = raw.indexOf("<");
19608
- return (idx === -1 ? raw : raw.slice(0, idx)).trim();
19609
- }
19610
- function isNullishArm(t) {
19611
- if (t.kind === "primitive" && (t.primitive === "null" || t.primitive === "undefined"))
19612
- return true;
19613
- return t.kind === "unknown" && (t.raw === "null" || t.raw === "undefined");
19614
- }
19615
- function stripUnion(type) {
19616
- if (!type || type.kind !== "union" || !type.unionTypes)
19617
- return type;
19618
- const nonNullish = type.unionTypes.filter((t) => !isNullishArm(t));
19619
- return nonNullish.length === 1 ? stripUnion(nonNullish[0]) : type;
19620
- }
19621
- function derefNamedType(type, meta) {
19622
- if (type.kind !== "interface")
19623
- return type;
19624
- if (type.properties && type.properties.length > 0)
19625
- return type;
19626
- const name = baseTypeName(type.raw);
19627
- const def = meta.typeDefinitions.find((d) => d.name === name);
19628
- if (!def?.properties)
19629
- return type;
19630
- return { ...type, properties: def.properties };
19631
- }
19632
- function lookupProperty(objType, propName, meta) {
19633
- const stripped = stripUnion(objType);
19634
- if (!stripped)
19635
- return null;
19636
- const deref = derefNamedType(stripped, meta);
19637
- const prop = deref.properties?.find((p) => p.name === propName);
19638
- return prop ? stripUnion(prop.type) : null;
19639
- }
19640
- function resolveReceiverType(expr, meta, bindings) {
19641
- if (expr.kind === "identifier") {
19642
- if (bindings.has(expr.name))
19643
- return stripUnion(bindings.get(expr.name) ?? null);
19644
- if (meta.propsObjectName !== null) {
19645
- return expr.name === meta.propsObjectName ? stripUnion(meta.propsType) : null;
19646
- }
19647
- const param = meta.propsParams.find((p) => p.name === expr.name && !p.isRest);
19648
- if (!param)
19649
- return null;
19650
- return lookupProperty(meta.propsType, param.sourceName ?? param.name, meta);
19651
- }
19652
- if (expr.kind === "member" && !expr.computed) {
19653
- const objType = resolveReceiverType(expr.object, meta, bindings);
19654
- return lookupProperty(objType, expr.property, meta);
19655
- }
19656
- return null;
19657
- }
19658
-
19659
19847
  // src/rich-type-refusal.ts
19660
- var EMPTY_BINDINGS = new Map;
19848
+ var EMPTY_BINDINGS2 = new Map;
19661
19849
  function checkRichTypeMethodCalls(root, metadata, errors) {
19662
19850
  if (!metadata.propsType)
19663
19851
  return;
19664
19852
  const matchers = prepareLoweringMatchers(metadata);
19665
19853
  const seen = new Set;
19666
- walkNode(root, metadata, EMPTY_BINDINGS, matchers, errors, seen);
19854
+ walkNode(root, metadata, EMPTY_BINDINGS2, matchers, errors, seen);
19667
19855
  }
19668
19856
  function isLoweringClaimed(matchers, callee, args) {
19669
19857
  return matchers.some((m) => m(callee, args) !== null);
@@ -20375,7 +20563,7 @@ function compileJSX(source, filePath, options) {
20375
20563
  return { files, errors };
20376
20564
  }
20377
20565
  // src/shared-program.ts
20378
- import ts18 from "typescript";
20566
+ import ts19 from "typescript";
20379
20567
  function commonParent(paths) {
20380
20568
  if (paths.length === 0)
20381
20569
  return process.cwd();
@@ -20396,10 +20584,10 @@ function commonParent(paths) {
20396
20584
  function createProgramForCorpus(files, options = {}) {
20397
20585
  const baseUrl = options.baseUrl ?? commonParent(files);
20398
20586
  const compilerOptions = {
20399
- target: ts18.ScriptTarget.Latest,
20400
- module: ts18.ModuleKind.ESNext,
20401
- moduleResolution: ts18.ModuleResolutionKind.Bundler,
20402
- jsx: ts18.JsxEmit.ReactJSX,
20587
+ target: ts19.ScriptTarget.Latest,
20588
+ module: ts19.ModuleKind.ESNext,
20589
+ moduleResolution: ts19.ModuleResolutionKind.Bundler,
20590
+ jsx: ts19.JsxEmit.ReactJSX,
20403
20591
  strict: true,
20404
20592
  skipLibCheck: true,
20405
20593
  noEmit: true,
@@ -20409,7 +20597,7 @@ function createProgramForCorpus(files, options = {}) {
20409
20597
  ...options.compilerOptions
20410
20598
  };
20411
20599
  const absolute = files.map((f) => path_default.resolve(f));
20412
- return ts18.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
20600
+ return ts19.createProgram(absolute, compilerOptions, undefined, options.oldProgram);
20413
20601
  }
20414
20602
  // src/adapters/interface.ts
20415
20603
  class BaseAdapter {
@@ -21222,7 +21410,7 @@ var queryHrefPlugin = {
21222
21410
  };
21223
21411
  }
21224
21412
  };
21225
- var BUILTIN_LOWERING_PLUGINS = [queryHrefPlugin];
21413
+ var BUILTIN_LOWERING_PLUGINS = [queryHrefPlugin, datePlugin];
21226
21414
  function registerBuiltinLoweringPlugins() {
21227
21415
  for (const plugin of BUILTIN_LOWERING_PLUGINS)
21228
21416
  registerLoweringPlugin(plugin);
@@ -21348,7 +21536,7 @@ function dangerousInnerHtmlDiagnostic(expr, loc, reason) {
21348
21536
  };
21349
21537
  }
21350
21538
  // src/combine-client-js.ts
21351
- import ts19 from "typescript";
21539
+ import ts20 from "typescript";
21352
21540
  var CHILD_PLACEHOLDER_RE = /import '\/\* @bf-child:(\w+) \*\/'/g;
21353
21541
  function combineParentChildClientJs(files) {
21354
21542
  const result = new Map;
@@ -21405,10 +21593,10 @@ function combineParentChildClientJs(files) {
21405
21593
  return result;
21406
21594
  }
21407
21595
  function parseAndMerge(content, importsBySource, otherImports, codeSections) {
21408
- const sourceFile = ts19.createSourceFile("combine.js", content, ts19.ScriptTarget.Latest, false, ts19.ScriptKind.JS);
21596
+ const sourceFile = ts20.createSourceFile("combine.js", content, ts20.ScriptTarget.Latest, false, ts20.ScriptKind.JS);
21409
21597
  const importSpans = [];
21410
21598
  for (const stmt of sourceFile.statements) {
21411
- if (!ts19.isImportDeclaration(stmt))
21599
+ if (!ts20.isImportDeclaration(stmt))
21412
21600
  continue;
21413
21601
  const start = stmt.getStart(sourceFile);
21414
21602
  const end = stmt.getEnd();
@@ -21418,8 +21606,8 @@ function parseAndMerge(content, importsBySource, otherImports, codeSections) {
21418
21606
  continue;
21419
21607
  const clause = stmt.importClause;
21420
21608
  const bindings = clause?.namedBindings;
21421
- const specifier = ts19.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
21422
- if (clause && !clause.name && bindings && ts19.isNamedImports(bindings)) {
21609
+ const specifier = ts20.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : "";
21610
+ if (clause && !clause.name && bindings && ts20.isNamedImports(bindings)) {
21423
21611
  if (!importsBySource.has(specifier)) {
21424
21612
  importsBySource.set(specifier, new Set);
21425
21613
  }
@@ -21582,7 +21770,7 @@ function escapeRe(s) {
21582
21770
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
21583
21771
  }
21584
21772
  // src/debug.ts
21585
- import ts20 from "typescript";
21773
+ import ts21 from "typescript";
21586
21774
  function buildComponentGraph(source, filePath, componentName) {
21587
21775
  const ctx = analyzeComponent(source, filePath, componentName);
21588
21776
  if (!ctx.jsxReturn) {
@@ -22867,7 +23055,7 @@ function truncateExpr(expr, max = 40) {
22867
23055
  function exprReadsPropMember(expr, propsObjectName) {
22868
23056
  let sf;
22869
23057
  try {
22870
- sf = ts20.createSourceFile("__attr.tsx", `(${expr})`, ts20.ScriptTarget.Latest, true, ts20.ScriptKind.TSX);
23058
+ sf = ts21.createSourceFile("__attr.tsx", `(${expr})`, ts21.ScriptTarget.Latest, true, ts21.ScriptKind.TSX);
22871
23059
  } catch {
22872
23060
  return false;
22873
23061
  }
@@ -22875,11 +23063,11 @@ function exprReadsPropMember(expr, propsObjectName) {
22875
23063
  const visit3 = (n) => {
22876
23064
  if (found)
22877
23065
  return;
22878
- if (ts20.isPropertyAccessExpression(n) && ts20.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
23066
+ if (ts21.isPropertyAccessExpression(n) && ts21.isIdentifier(n.expression) && n.expression.text === propsObjectName && n.name.text !== "children") {
22879
23067
  found = true;
22880
23068
  return;
22881
23069
  }
22882
- ts20.forEachChild(n, visit3);
23070
+ ts21.forEachChild(n, visit3);
22883
23071
  };
22884
23072
  visit3(sf);
22885
23073
  return found;
@@ -22949,7 +23137,7 @@ function findSourceFile2(meta) {
22949
23137
  return null;
22950
23138
  }
22951
23139
  // src/profiler.ts
22952
- import ts21 from "typescript";
23140
+ import ts22 from "typescript";
22953
23141
  var PROFILE_SCHEMA_VERSION = 1;
22954
23142
  var DEFAULT_FANOUT_THRESHOLD = 8;
22955
23143
  function buildStaticBudget(source, filePath, componentName, options = {}) {
@@ -23219,15 +23407,15 @@ function joinProfilerEvents(events, index) {
23219
23407
  return { joined, unattributed, diagnostics };
23220
23408
  }
23221
23409
  function findUninstrumentedEffects(source, filePath, instrumentedLines) {
23222
- const sf = ts21.createSourceFile(filePath, source, ts21.ScriptTarget.Latest, true, ts21.ScriptKind.TSX);
23410
+ const sf = ts22.createSourceFile(filePath, source, ts22.ScriptTarget.Latest, true, ts22.ScriptKind.TSX);
23223
23411
  const out = [];
23224
23412
  const visit3 = (node) => {
23225
- if (ts21.isCallExpression(node) && ts21.isIdentifier(node.expression) && node.expression.text === "createEffect") {
23413
+ if (ts22.isCallExpression(node) && ts22.isIdentifier(node.expression) && node.expression.text === "createEffect") {
23226
23414
  const line = sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;
23227
23415
  if (!instrumentedLines.has(line))
23228
23416
  out.push({ file: filePath, line });
23229
23417
  }
23230
- ts21.forEachChild(node, visit3);
23418
+ ts22.forEachChild(node, visit3);
23231
23419
  };
23232
23420
  visit3(sf);
23233
23421
  out.sort((a, b) => a.line - b.line);
@@ -23535,13 +23723,13 @@ function assessBatchSafety(args) {
23535
23723
  const signalGetters = new Set(args.graph.signals.map((s) => s.name));
23536
23724
  let sf;
23537
23725
  try {
23538
- sf = ts21.createSourceFile("__h.ts", `const __h = ${args.handler}`, ts21.ScriptTarget.Latest, true);
23726
+ sf = ts22.createSourceFile("__h.ts", `const __h = ${args.handler}`, ts22.ScriptTarget.Latest, true);
23539
23727
  } catch {
23540
23728
  return "unverified";
23541
23729
  }
23542
23730
  const calls = [];
23543
23731
  const visit3 = (node) => {
23544
- if (ts21.isCallExpression(node) && ts21.isIdentifier(node.expression)) {
23732
+ if (ts22.isCallExpression(node) && ts22.isIdentifier(node.expression)) {
23545
23733
  const name = node.expression.text;
23546
23734
  if (setters.has(name))
23547
23735
  calls.push({ pos: node.getStart(sf), kind: "write" });
@@ -23550,7 +23738,7 @@ function assessBatchSafety(args) {
23550
23738
  else if (!signalGetters.has(name) && !memoNames.has(name))
23551
23739
  calls.push({ pos: node.getStart(sf), kind: "risky" });
23552
23740
  }
23553
- ts21.forEachChild(node, visit3);
23741
+ ts22.forEachChild(node, visit3);
23554
23742
  };
23555
23743
  visit3(sf);
23556
23744
  calls.sort((a, b) => a.pos - b.pos);
@@ -24340,5 +24528,6 @@ export {
24340
24528
  BUILTIN_LOWERING_PLUGINS,
24341
24529
  BROWSER_ONLY_CLIENT_APIS,
24342
24530
  BOOLEAN_ATTRS,
24343
- AttrValueOf
24531
+ AttrValueOf,
24532
+ ARRAY_METHOD_NAMES
24344
24533
  };