@barefootjs/test 0.31.1 → 0.31.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 +971 -767
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -187287,8 +187287,11 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
187287
187287
|
} });
|
|
187288
187288
|
});
|
|
187289
187289
|
|
|
187290
|
+
// ../jsx/src/compiler.ts
|
|
187291
|
+
var import_typescript23 = __toESM(require_typescript(), 1);
|
|
187292
|
+
|
|
187290
187293
|
// ../jsx/src/analyzer.ts
|
|
187291
|
-
var
|
|
187294
|
+
var import_typescript9 = __toESM(require_typescript(), 1);
|
|
187292
187295
|
|
|
187293
187296
|
// ../jsx/src/expression-parser.ts
|
|
187294
187297
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
@@ -188820,6 +188823,29 @@ var import_typescript5 = __toESM(require_typescript(), 1);
|
|
|
188820
188823
|
// ../jsx/src/ir-to-client-js/utils.ts
|
|
188821
188824
|
var import_typescript3 = __toESM(require_typescript(), 1);
|
|
188822
188825
|
|
|
188826
|
+
// ../jsx/src/template-parts.ts
|
|
188827
|
+
function lookupPartToJsExpr(part, opts) {
|
|
188828
|
+
const key = opts?.useTemplate && part.templateKey ? part.templateKey : part.key;
|
|
188829
|
+
const obj = "{" + Object.entries(part.cases).map(([k, v]) => `${JSON.stringify(k)}: ${JSON.stringify(v)}`).join(", ") + "}";
|
|
188830
|
+
const typed = opts?.typed ? " as Record<string, string>" : "";
|
|
188831
|
+
return `(${obj}${typed})[${key}]`;
|
|
188832
|
+
}
|
|
188833
|
+
function templatePartsToJsExpr(parts, opts) {
|
|
188834
|
+
let result = "`";
|
|
188835
|
+
for (const part of parts) {
|
|
188836
|
+
if (part.type === "string") {
|
|
188837
|
+
result += opts?.useTemplate && part.templateValue ? part.templateValue : part.value;
|
|
188838
|
+
} else if (part.type === "ternary") {
|
|
188839
|
+
const cond = opts?.useTemplate && part.templateCondition ? part.templateCondition : part.condition;
|
|
188840
|
+
result += `\${${cond} ? '${part.whenTrue}' : '${part.whenFalse}'}`;
|
|
188841
|
+
} else if (part.type === "lookup") {
|
|
188842
|
+
result += `\${${lookupPartToJsExpr(part, opts)}}`;
|
|
188843
|
+
}
|
|
188844
|
+
}
|
|
188845
|
+
result += "`";
|
|
188846
|
+
return result;
|
|
188847
|
+
}
|
|
188848
|
+
|
|
188823
188849
|
// ../jsx/src/scanner/js-scanner.ts
|
|
188824
188850
|
var import_typescript2 = __toESM(require_typescript(), 1);
|
|
188825
188851
|
function* iterateJsTokens(text, start = 0, end = text.length) {
|
|
@@ -189398,7 +189424,7 @@ function collectAstPropRefs(node, propNames, out) {
|
|
|
189398
189424
|
out.add(n.text);
|
|
189399
189425
|
});
|
|
189400
189426
|
}
|
|
189401
|
-
function applyScopedPropRefRewrite(text, propRefs) {
|
|
189427
|
+
function applyScopedPropRefRewrite(text, propRefs, propAliases) {
|
|
189402
189428
|
const prefix = "(";
|
|
189403
189429
|
const sf = import_typescript5.default.createSourceFile("__bf_prop_rewrite.ts", `${prefix}${text}
|
|
189404
189430
|
)`, import_typescript5.default.ScriptTarget.Latest, true);
|
|
@@ -189415,11 +189441,12 @@ function applyScopedPropRefRewrite(text, propRefs) {
|
|
|
189415
189441
|
const end = n.getEnd() - prefix.length;
|
|
189416
189442
|
if (start < 0 || end > text.length)
|
|
189417
189443
|
return;
|
|
189444
|
+
const callerKey = propAliases?.get(n.text) ?? n.text;
|
|
189418
189445
|
if (parent && import_typescript5.default.isShorthandPropertyAssignment(parent) && parent.name === n) {
|
|
189419
|
-
edits.push({ start, end, replacement: `${n.text}: ${PROPS_PARAM}.${
|
|
189446
|
+
edits.push({ start, end, replacement: `${n.text}: ${PROPS_PARAM}.${callerKey}` });
|
|
189420
189447
|
return;
|
|
189421
189448
|
}
|
|
189422
|
-
edits.push({ start, end, replacement: `${PROPS_PARAM}.${
|
|
189449
|
+
edits.push({ start, end, replacement: `${PROPS_PARAM}.${callerKey}` });
|
|
189423
189450
|
});
|
|
189424
189451
|
if (edits.length === 0)
|
|
189425
189452
|
return text;
|
|
@@ -189429,10 +189456,11 @@ function applyScopedPropRefRewrite(text, propRefs) {
|
|
|
189429
189456
|
}
|
|
189430
189457
|
return result;
|
|
189431
189458
|
}
|
|
189432
|
-
function applyRegexPropRefRewrite(text, propRefs) {
|
|
189459
|
+
function applyRegexPropRefRewrite(text, propRefs, propAliases) {
|
|
189433
189460
|
const { protect, restore } = createTemplateAwareStringProtector();
|
|
189434
189461
|
let result = protect(text);
|
|
189435
189462
|
for (const propName of propRefs) {
|
|
189463
|
+
const callerKey = propAliases?.get(propName) ?? propName;
|
|
189436
189464
|
const pattern = new RegExp(`(?<!${PROPS_PARAM}\\.)(?<!['"\\w.-])\\b${propName}\\b(?![a-zA-Z0-9_$])`, "g");
|
|
189437
189465
|
result = result.replace(pattern, (match, offset, str) => {
|
|
189438
189466
|
const after = str.slice(offset + match.length);
|
|
@@ -189441,12 +189469,12 @@ function applyRegexPropRefRewrite(text, propRefs) {
|
|
|
189441
189469
|
if (/[{,]\s*$/.test(before))
|
|
189442
189470
|
return match;
|
|
189443
189471
|
}
|
|
189444
|
-
return `${PROPS_PARAM}.${
|
|
189472
|
+
return `${PROPS_PARAM}.${callerKey}`;
|
|
189445
189473
|
});
|
|
189446
189474
|
}
|
|
189447
189475
|
return restore(result);
|
|
189448
189476
|
}
|
|
189449
|
-
function rewriteBarePropRefs(text, node, propNames, extraPropRefs) {
|
|
189477
|
+
function rewriteBarePropRefs(text, node, propNames, extraPropRefs, propAliases) {
|
|
189450
189478
|
const foundPropRefs = new Set;
|
|
189451
189479
|
collectAstPropRefs(node, propNames, foundPropRefs);
|
|
189452
189480
|
if (extraPropRefs) {
|
|
@@ -189457,7 +189485,39 @@ function rewriteBarePropRefs(text, node, propNames, extraPropRefs) {
|
|
|
189457
189485
|
}
|
|
189458
189486
|
if (foundPropRefs.size === 0)
|
|
189459
189487
|
return;
|
|
189460
|
-
return applyScopedPropRefRewrite(text, foundPropRefs) ?? applyRegexPropRefRewrite(text, foundPropRefs);
|
|
189488
|
+
return applyScopedPropRefRewrite(text, foundPropRefs, propAliases) ?? applyRegexPropRefRewrite(text, foundPropRefs, propAliases);
|
|
189489
|
+
}
|
|
189490
|
+
|
|
189491
|
+
// ../jsx/src/props-binding.ts
|
|
189492
|
+
var import_typescript6 = __toESM(require_typescript(), 1);
|
|
189493
|
+
function isIdentifierName(key) {
|
|
189494
|
+
if (key.length === 0)
|
|
189495
|
+
return false;
|
|
189496
|
+
for (let i2 = 0;i2 < key.length; ) {
|
|
189497
|
+
const cp = key.codePointAt(i2);
|
|
189498
|
+
const ok = i2 === 0 ? import_typescript6.default.isIdentifierStart(cp, import_typescript6.default.ScriptTarget.Latest) : import_typescript6.default.isIdentifierPart(cp, import_typescript6.default.ScriptTarget.Latest);
|
|
189499
|
+
if (!ok)
|
|
189500
|
+
return false;
|
|
189501
|
+
i2 += cp > 65535 ? 2 : 1;
|
|
189502
|
+
}
|
|
189503
|
+
return true;
|
|
189504
|
+
}
|
|
189505
|
+
function propsDestructureBinding(p) {
|
|
189506
|
+
const callerKey = p.sourceName ?? p.name;
|
|
189507
|
+
const localName = p.name;
|
|
189508
|
+
const binding = callerKey === localName ? localName : `${isIdentifierName(callerKey) ? callerKey : JSON.stringify(callerKey)}: ${localName}`;
|
|
189509
|
+
return p.defaultValue ? `${binding} = ${p.defaultValue}` : binding;
|
|
189510
|
+
}
|
|
189511
|
+
function buildPropAliasMap(params) {
|
|
189512
|
+
let map;
|
|
189513
|
+
for (const p of params) {
|
|
189514
|
+
if (p.sourceName) {
|
|
189515
|
+
if (!map)
|
|
189516
|
+
map = new Map;
|
|
189517
|
+
map.set(p.name, p.sourceName);
|
|
189518
|
+
}
|
|
189519
|
+
}
|
|
189520
|
+
return map;
|
|
189461
189521
|
}
|
|
189462
189522
|
|
|
189463
189523
|
// ../jsx/src/instrumentation.ts
|
|
@@ -189478,10 +189538,10 @@ function incrementCounter(key) {
|
|
|
189478
189538
|
}
|
|
189479
189539
|
|
|
189480
189540
|
// ../jsx/src/analyzer-context.ts
|
|
189481
|
-
var
|
|
189541
|
+
var import_typescript8 = __toESM(require_typescript(), 1);
|
|
189482
189542
|
|
|
189483
189543
|
// ../jsx/src/strip-types.ts
|
|
189484
|
-
var
|
|
189544
|
+
var import_typescript7 = __toESM(require_typescript(), 1);
|
|
189485
189545
|
function collectAllTypeRanges(sourceFile) {
|
|
189486
189546
|
const ranges = [];
|
|
189487
189547
|
collectTypeRanges(sourceFile, sourceFile, sourceFile.text, ranges);
|
|
@@ -189566,7 +189626,7 @@ function mergeRanges(ranges) {
|
|
|
189566
189626
|
return merged;
|
|
189567
189627
|
}
|
|
189568
189628
|
function collectTypeRanges(node, sourceFile, fullText, ranges) {
|
|
189569
|
-
if (
|
|
189629
|
+
if (import_typescript7.default.isParameter(node)) {
|
|
189570
189630
|
const hasQuestion = !!node.questionToken;
|
|
189571
189631
|
const hasType = !!node.type;
|
|
189572
189632
|
if (hasQuestion && hasType) {
|
|
@@ -189580,72 +189640,72 @@ function collectTypeRanges(node, sourceFile, fullText, ranges) {
|
|
|
189580
189640
|
}
|
|
189581
189641
|
}
|
|
189582
189642
|
}
|
|
189583
|
-
if (
|
|
189643
|
+
if (import_typescript7.default.isVariableDeclaration(node) && node.type) {
|
|
189584
189644
|
const colonPos = findColonBefore(node.type, fullText, node.name.getEnd());
|
|
189585
189645
|
if (colonPos >= 0) {
|
|
189586
189646
|
ranges.push({ start: colonPos, end: node.type.getEnd() });
|
|
189587
189647
|
}
|
|
189588
189648
|
}
|
|
189589
|
-
if (
|
|
189649
|
+
if (import_typescript7.default.isArrowFunction(node) && node.type) {
|
|
189590
189650
|
const colonPos = findColonBefore(node.type, fullText, node.parameters.end);
|
|
189591
189651
|
if (colonPos >= 0) {
|
|
189592
189652
|
ranges.push({ start: colonPos, end: node.type.getEnd() });
|
|
189593
189653
|
}
|
|
189594
189654
|
}
|
|
189595
|
-
if ((
|
|
189655
|
+
if ((import_typescript7.default.isFunctionDeclaration(node) || import_typescript7.default.isFunctionExpression(node)) && node.type) {
|
|
189596
189656
|
const colonPos = findColonBefore(node.type, fullText, node.parameters.end);
|
|
189597
189657
|
if (colonPos >= 0) {
|
|
189598
189658
|
ranges.push({ start: colonPos, end: node.type.getEnd() });
|
|
189599
189659
|
}
|
|
189600
189660
|
}
|
|
189601
|
-
if (
|
|
189661
|
+
if (import_typescript7.default.isAsExpression(node)) {
|
|
189602
189662
|
const exprEnd = node.expression.getEnd();
|
|
189603
189663
|
ranges.push({ start: exprEnd, end: node.getEnd() });
|
|
189604
189664
|
collectTypeRanges(node.expression, sourceFile, fullText, ranges);
|
|
189605
189665
|
return;
|
|
189606
189666
|
}
|
|
189607
|
-
if (
|
|
189667
|
+
if (import_typescript7.default.isSatisfiesExpression(node)) {
|
|
189608
189668
|
const exprEnd = node.expression.getEnd();
|
|
189609
189669
|
ranges.push({ start: exprEnd, end: node.getEnd() });
|
|
189610
189670
|
collectTypeRanges(node.expression, sourceFile, fullText, ranges);
|
|
189611
189671
|
return;
|
|
189612
189672
|
}
|
|
189613
|
-
if (
|
|
189673
|
+
if (import_typescript7.default.isNonNullExpression(node)) {
|
|
189614
189674
|
const exprEnd = node.expression.getEnd();
|
|
189615
189675
|
ranges.push({ start: exprEnd, end: node.getEnd() });
|
|
189616
189676
|
collectTypeRanges(node.expression, sourceFile, fullText, ranges);
|
|
189617
189677
|
return;
|
|
189618
189678
|
}
|
|
189619
|
-
if (
|
|
189679
|
+
if (import_typescript7.default.isTypeAssertionExpression(node)) {
|
|
189620
189680
|
const exprStart = node.expression.getStart(sourceFile);
|
|
189621
189681
|
ranges.push({ start: node.getStart(sourceFile), end: exprStart });
|
|
189622
189682
|
collectTypeRanges(node.expression, sourceFile, fullText, ranges);
|
|
189623
189683
|
return;
|
|
189624
189684
|
}
|
|
189625
|
-
if (
|
|
189685
|
+
if (import_typescript7.default.isCallExpression(node) && node.typeArguments) {
|
|
189626
189686
|
const typeArgsStart = findAngleBracketBefore(node.typeArguments[0], fullText, node.expression.getEnd());
|
|
189627
189687
|
const typeArgsEnd = findAngleBracketAfter(node.typeArguments[node.typeArguments.length - 1], fullText);
|
|
189628
189688
|
if (typeArgsStart >= 0 && typeArgsEnd >= 0) {
|
|
189629
189689
|
ranges.push({ start: typeArgsStart, end: typeArgsEnd });
|
|
189630
189690
|
}
|
|
189631
189691
|
}
|
|
189632
|
-
if (
|
|
189692
|
+
if (import_typescript7.default.isNewExpression(node) && node.typeArguments) {
|
|
189633
189693
|
const typeArgsStart = findAngleBracketBefore(node.typeArguments[0], fullText, node.expression.getEnd());
|
|
189634
189694
|
const typeArgsEnd = findAngleBracketAfter(node.typeArguments[node.typeArguments.length - 1], fullText);
|
|
189635
189695
|
if (typeArgsStart >= 0 && typeArgsEnd >= 0) {
|
|
189636
189696
|
ranges.push({ start: typeArgsStart, end: typeArgsEnd });
|
|
189637
189697
|
}
|
|
189638
189698
|
}
|
|
189639
|
-
if (
|
|
189699
|
+
if (import_typescript7.default.isTypeAliasDeclaration(node) || import_typescript7.default.isInterfaceDeclaration(node)) {
|
|
189640
189700
|
ranges.push({
|
|
189641
189701
|
start: expandToLineStart(node.getStart(sourceFile), fullText),
|
|
189642
189702
|
end: expandThroughLineEnd(node.getEnd(), fullText)
|
|
189643
189703
|
});
|
|
189644
189704
|
return;
|
|
189645
189705
|
}
|
|
189646
|
-
if (
|
|
189706
|
+
if (import_typescript7.default.isTypeNode(node))
|
|
189647
189707
|
return;
|
|
189648
|
-
|
|
189708
|
+
import_typescript7.default.forEachChild(node, (child) => {
|
|
189649
189709
|
collectTypeRanges(child, sourceFile, fullText, ranges);
|
|
189650
189710
|
});
|
|
189651
189711
|
}
|
|
@@ -189757,9 +189817,9 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
|
|
|
189757
189817
|
};
|
|
189758
189818
|
}
|
|
189759
189819
|
function nodeContainsJsx(node) {
|
|
189760
|
-
if (
|
|
189820
|
+
if (import_typescript8.default.isJsxElement(node) || import_typescript8.default.isJsxSelfClosingElement(node) || import_typescript8.default.isJsxFragment(node))
|
|
189761
189821
|
return true;
|
|
189762
|
-
return
|
|
189822
|
+
return import_typescript8.default.forEachChild(node, nodeContainsJsx) ?? false;
|
|
189763
189823
|
}
|
|
189764
189824
|
function getSourceLocation(node, sourceFile, filePath) {
|
|
189765
189825
|
const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
@@ -189777,20 +189837,20 @@ function getSourceLocation(node, sourceFile, filePath) {
|
|
|
189777
189837
|
};
|
|
189778
189838
|
}
|
|
189779
189839
|
function membersToProperties(members, sourceFile) {
|
|
189780
|
-
return members.filter(
|
|
189840
|
+
return members.filter(import_typescript8.default.isPropertySignature).map((member) => ({
|
|
189781
189841
|
name: propertyNameText(member.name, sourceFile),
|
|
189782
189842
|
type: typeNodeToTypeInfo(member.type, sourceFile) ?? {
|
|
189783
189843
|
kind: "unknown",
|
|
189784
189844
|
raw: "unknown"
|
|
189785
189845
|
},
|
|
189786
189846
|
optional: !!member.questionToken,
|
|
189787
|
-
readonly: !!member.modifiers?.some((m) => m.kind ===
|
|
189847
|
+
readonly: !!member.modifiers?.some((m) => m.kind === import_typescript8.default.SyntaxKind.ReadonlyKeyword)
|
|
189788
189848
|
}));
|
|
189789
189849
|
}
|
|
189790
189850
|
function propertyNameText(name, sourceFile) {
|
|
189791
189851
|
if (!name)
|
|
189792
189852
|
return "";
|
|
189793
|
-
if (
|
|
189853
|
+
if (import_typescript8.default.isStringLiteral(name) || import_typescript8.default.isNumericLiteral(name))
|
|
189794
189854
|
return name.text;
|
|
189795
189855
|
return name.getText(sourceFile);
|
|
189796
189856
|
}
|
|
@@ -189801,56 +189861,56 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
|
|
|
189801
189861
|
const raw = rawOf ? rawOf(typeNode) : typeNode.getText(sourceFile);
|
|
189802
189862
|
const recurse = (n) => typeNodeToTypeInfo(n, sourceFile, rawOf) ?? { kind: "unknown", raw: "unknown" };
|
|
189803
189863
|
switch (typeNode.kind) {
|
|
189804
|
-
case
|
|
189864
|
+
case import_typescript8.default.SyntaxKind.StringKeyword:
|
|
189805
189865
|
return { kind: "primitive", raw, primitive: "string" };
|
|
189806
|
-
case
|
|
189866
|
+
case import_typescript8.default.SyntaxKind.NumberKeyword:
|
|
189807
189867
|
return { kind: "primitive", raw, primitive: "number" };
|
|
189808
|
-
case
|
|
189868
|
+
case import_typescript8.default.SyntaxKind.BooleanKeyword:
|
|
189809
189869
|
return { kind: "primitive", raw, primitive: "boolean" };
|
|
189810
|
-
case
|
|
189870
|
+
case import_typescript8.default.SyntaxKind.NullKeyword:
|
|
189811
189871
|
return { kind: "primitive", raw, primitive: "null" };
|
|
189812
|
-
case
|
|
189872
|
+
case import_typescript8.default.SyntaxKind.UndefinedKeyword:
|
|
189813
189873
|
return { kind: "primitive", raw, primitive: "undefined" };
|
|
189814
189874
|
}
|
|
189815
|
-
if (
|
|
189875
|
+
if (import_typescript8.default.isArrayTypeNode(typeNode)) {
|
|
189816
189876
|
return { kind: "array", raw, elementType: recurse(typeNode.elementType) };
|
|
189817
189877
|
}
|
|
189818
|
-
if (
|
|
189878
|
+
if (import_typescript8.default.isLiteralTypeNode(typeNode)) {
|
|
189819
189879
|
const lit = typeNode.literal;
|
|
189820
|
-
if (
|
|
189880
|
+
if (import_typescript8.default.isStringLiteral(lit) || import_typescript8.default.isNoSubstitutionTemplateLiteral(lit)) {
|
|
189821
189881
|
return { kind: "primitive", raw, primitive: "string", literalValue: lit.text };
|
|
189822
189882
|
}
|
|
189823
|
-
if (
|
|
189883
|
+
if (import_typescript8.default.isNumericLiteral(lit)) {
|
|
189824
189884
|
return { kind: "primitive", raw, primitive: "number", literalValue: lit.text };
|
|
189825
189885
|
}
|
|
189826
|
-
if (
|
|
189886
|
+
if (import_typescript8.default.isPrefixUnaryExpression(lit) && lit.operator === import_typescript8.default.SyntaxKind.MinusToken && import_typescript8.default.isNumericLiteral(lit.operand)) {
|
|
189827
189887
|
return { kind: "primitive", raw, primitive: "number", literalValue: `-${lit.operand.text}` };
|
|
189828
189888
|
}
|
|
189829
|
-
if (lit.kind ===
|
|
189889
|
+
if (lit.kind === import_typescript8.default.SyntaxKind.TrueKeyword || lit.kind === import_typescript8.default.SyntaxKind.FalseKeyword) {
|
|
189830
189890
|
return {
|
|
189831
189891
|
kind: "primitive",
|
|
189832
189892
|
raw,
|
|
189833
189893
|
primitive: "boolean",
|
|
189834
|
-
literalValue: lit.kind ===
|
|
189894
|
+
literalValue: lit.kind === import_typescript8.default.SyntaxKind.TrueKeyword ? "true" : "false"
|
|
189835
189895
|
};
|
|
189836
189896
|
}
|
|
189837
|
-
if (lit.kind ===
|
|
189897
|
+
if (lit.kind === import_typescript8.default.SyntaxKind.NullKeyword) {
|
|
189838
189898
|
return { kind: "primitive", raw, primitive: "null" };
|
|
189839
189899
|
}
|
|
189840
189900
|
return { kind: "unknown", raw };
|
|
189841
189901
|
}
|
|
189842
|
-
if (
|
|
189902
|
+
if (import_typescript8.default.isUnionTypeNode(typeNode)) {
|
|
189843
189903
|
return { kind: "union", raw, unionTypes: typeNode.types.map(recurse) };
|
|
189844
189904
|
}
|
|
189845
|
-
if (
|
|
189905
|
+
if (import_typescript8.default.isTypeLiteralNode(typeNode)) {
|
|
189846
189906
|
return {
|
|
189847
189907
|
kind: "object",
|
|
189848
189908
|
raw,
|
|
189849
189909
|
...synthetic ? {} : { properties: membersToProperties(typeNode.members, sourceFile) }
|
|
189850
189910
|
};
|
|
189851
189911
|
}
|
|
189852
|
-
if (
|
|
189853
|
-
const refName =
|
|
189912
|
+
if (import_typescript8.default.isTypeReferenceNode(typeNode)) {
|
|
189913
|
+
const refName = import_typescript8.default.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : "";
|
|
189854
189914
|
if ((refName === "Array" || refName === "ReadonlyArray") && typeNode.typeArguments?.length === 1) {
|
|
189855
189915
|
return { kind: "array", raw, elementType: recurse(typeNode.typeArguments[0]) };
|
|
189856
189916
|
}
|
|
@@ -189859,7 +189919,7 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
|
|
|
189859
189919
|
raw
|
|
189860
189920
|
};
|
|
189861
189921
|
}
|
|
189862
|
-
if (
|
|
189922
|
+
if (import_typescript8.default.isFunctionTypeNode(typeNode)) {
|
|
189863
189923
|
if (synthetic)
|
|
189864
189924
|
return { kind: "function", raw };
|
|
189865
189925
|
return {
|
|
@@ -189879,15 +189939,15 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
|
|
|
189879
189939
|
}
|
|
189880
189940
|
return { kind: "unknown", raw };
|
|
189881
189941
|
}
|
|
189882
|
-
var _typePrinter =
|
|
189883
|
-
var _blankTypeSourceFile =
|
|
189942
|
+
var _typePrinter = import_typescript8.default.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
|
|
189943
|
+
var _blankTypeSourceFile = import_typescript8.default.createSourceFile("__bf_types__.ts", "", import_typescript8.default.ScriptTarget.Latest);
|
|
189884
189944
|
function tsTypeToTypeInfo(type2, checker) {
|
|
189885
|
-
const node = checker.typeToTypeNode(type2, undefined,
|
|
189945
|
+
const node = checker.typeToTypeNode(type2, undefined, import_typescript8.default.NodeBuilderFlags.NoTruncation);
|
|
189886
189946
|
if (!node)
|
|
189887
189947
|
return null;
|
|
189888
189948
|
const rawOf = (n) => {
|
|
189889
189949
|
try {
|
|
189890
|
-
return _typePrinter.printNode(
|
|
189950
|
+
return _typePrinter.printNode(import_typescript8.default.EmitHint.Unspecified, n, _blankTypeSourceFile);
|
|
189891
189951
|
} catch {
|
|
189892
189952
|
return "unknown";
|
|
189893
189953
|
}
|
|
@@ -189898,16 +189958,16 @@ function isPascalCase(name) {
|
|
|
189898
189958
|
return /^[A-Z][a-zA-Z0-9]*$/.test(name);
|
|
189899
189959
|
}
|
|
189900
189960
|
function isComponentFunction(node) {
|
|
189901
|
-
return
|
|
189961
|
+
return import_typescript8.default.isFunctionDeclaration(node) && !!node.name && isPascalCase(node.name.text) && !!node.body;
|
|
189902
189962
|
}
|
|
189903
189963
|
function isArrowComponentFunction(node) {
|
|
189904
|
-
if (!
|
|
189964
|
+
if (!import_typescript8.default.isVariableDeclaration(node))
|
|
189905
189965
|
return false;
|
|
189906
|
-
if (!
|
|
189966
|
+
if (!import_typescript8.default.isIdentifier(node.name))
|
|
189907
189967
|
return false;
|
|
189908
189968
|
if (!isPascalCase(node.name.text))
|
|
189909
189969
|
return false;
|
|
189910
|
-
if (!node.initializer || !
|
|
189970
|
+
if (!node.initializer || !import_typescript8.default.isArrowFunction(node.initializer))
|
|
189911
189971
|
return false;
|
|
189912
189972
|
return true;
|
|
189913
189973
|
}
|
|
@@ -189935,6 +189995,7 @@ var ErrorCodes = {
|
|
|
189935
189995
|
JSX_IN_LOCAL_FUNCTION: "BF045",
|
|
189936
189996
|
COMPONENT_REQUIRED_PROP_MISSING: "BF046",
|
|
189937
189997
|
JSX_BRANCH_LOCAL_IN_CALLBACK: "BF047",
|
|
189998
|
+
SIBLING_COMPONENT_NOT_COMPILED: "BF048",
|
|
189938
189999
|
SHARED_PROGRAM_REQUIRED: "BF050",
|
|
189939
190000
|
WRONG_PACKAGE_IMPORT: "BF051",
|
|
189940
190001
|
BUILTIN_REQUIRES_IMPORT: "BF054",
|
|
@@ -189964,6 +190025,7 @@ var errorMessages = {
|
|
|
189964
190025
|
[ErrorCodes.JSX_IN_LOCAL_FUNCTION]: "Local function returns JSX but cannot be inlined. Extract it as a top-level PascalCase component or use a single return statement.",
|
|
189965
190026
|
[ErrorCodes.COMPONENT_REQUIRED_PROP_MISSING]: "Built-in component is missing a required prop.",
|
|
189966
190027
|
[ErrorCodes.JSX_BRANCH_LOCAL_IN_CALLBACK]: "JSX-typed local declared inside an `if`-block cannot be referenced from a callback body (ref / event handler). " + "Render it as a child instead: `<div ref={...}>{local}</div>`.",
|
|
190028
|
+
[ErrorCodes.SIBLING_COMPONENT_NOT_COMPILED]: "Referenced component did not compile to a template, so this reference would throw " + "`ReferenceError` at render time. Multi-return JSX dispatch (a `switch` or `if`/`else` " + "chain across multiple JSX-returning branches) cannot compile as a component in a " + `'use client' file. Extract it to a separate non-"use client" file (where it is preserved ` + "verbatim, see #932), or rewrite it as a single-return ternary/conditional chain so the " + "component pipeline can compile it.",
|
|
189967
190029
|
[ErrorCodes.SHARED_PROGRAM_REQUIRED]: "Shared ts.Program required for type-based reactivity classification. This source imports a Reactive<T>-branded library (e.g. @barefootjs/form) whose getters cannot be classified by regex alone. Pass `options.program` (built via `createProgramForCorpus`) so the analyzer can resolve the brand through the TypeChecker.",
|
|
189968
190030
|
[ErrorCodes.WRONG_PACKAGE_IMPORT]: "Import from wrong package.",
|
|
189969
190031
|
[ErrorCodes.BUILTIN_REQUIRES_IMPORT]: "Built-in <Async> / <Region> must be imported from '@barefootjs/client'. " + "The compiler recognises these tags by their import (not by tag name), " + "so an unimported tag with this name is treated as an undeclared component.",
|
|
@@ -190151,9 +190213,9 @@ function needsTypeBasedDetection(source) {
|
|
|
190151
190213
|
}
|
|
190152
190214
|
function findBrandPackageImportLoc(sourceFile, filePath) {
|
|
190153
190215
|
for (const stmt of sourceFile.statements) {
|
|
190154
|
-
if (!
|
|
190216
|
+
if (!import_typescript9.default.isImportDeclaration(stmt))
|
|
190155
190217
|
continue;
|
|
190156
|
-
if (!
|
|
190218
|
+
if (!import_typescript9.default.isStringLiteral(stmt.moduleSpecifier))
|
|
190157
190219
|
continue;
|
|
190158
190220
|
if (!REACTIVE_BRAND_PACKAGES.includes(stmt.moduleSpecifier.text))
|
|
190159
190221
|
continue;
|
|
@@ -190172,21 +190234,21 @@ function createProgramForFile(source, filePath) {
|
|
|
190172
190234
|
try {
|
|
190173
190235
|
const normalizedPath = path_default.resolve(filePath);
|
|
190174
190236
|
const compilerOptions = {
|
|
190175
|
-
target:
|
|
190176
|
-
module:
|
|
190177
|
-
moduleResolution:
|
|
190178
|
-
jsx:
|
|
190237
|
+
target: import_typescript9.default.ScriptTarget.Latest,
|
|
190238
|
+
module: import_typescript9.default.ModuleKind.ESNext,
|
|
190239
|
+
moduleResolution: import_typescript9.default.ModuleResolutionKind.Bundler,
|
|
190240
|
+
jsx: import_typescript9.default.JsxEmit.ReactJSX,
|
|
190179
190241
|
strict: true,
|
|
190180
190242
|
skipLibCheck: true,
|
|
190181
190243
|
noEmit: true,
|
|
190182
190244
|
baseUrl: path_default.dirname(normalizedPath)
|
|
190183
190245
|
};
|
|
190184
|
-
const defaultHost =
|
|
190246
|
+
const defaultHost = import_typescript9.default.createCompilerHost(compilerOptions);
|
|
190185
190247
|
const virtualHost = {
|
|
190186
190248
|
...defaultHost,
|
|
190187
190249
|
getSourceFile(fileName, languageVersion) {
|
|
190188
190250
|
if (path_default.resolve(fileName) === normalizedPath) {
|
|
190189
|
-
return
|
|
190251
|
+
return import_typescript9.default.createSourceFile(fileName, source, languageVersion, true, import_typescript9.default.ScriptKind.TSX);
|
|
190190
190252
|
}
|
|
190191
190253
|
return defaultHost.getSourceFile(fileName, languageVersion);
|
|
190192
190254
|
},
|
|
@@ -190201,7 +190263,7 @@ function createProgramForFile(source, filePath) {
|
|
|
190201
190263
|
return defaultHost.readFile(fileName);
|
|
190202
190264
|
}
|
|
190203
190265
|
};
|
|
190204
|
-
const program =
|
|
190266
|
+
const program = import_typescript9.default.createProgram([normalizedPath], compilerOptions, virtualHost);
|
|
190205
190267
|
const sourceFile = program.getSourceFile(normalizedPath);
|
|
190206
190268
|
if (!sourceFile)
|
|
190207
190269
|
return null;
|
|
@@ -190234,7 +190296,7 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
|
|
|
190234
190296
|
}
|
|
190235
190297
|
}
|
|
190236
190298
|
if (!sourceFile) {
|
|
190237
|
-
sourceFile =
|
|
190299
|
+
sourceFile = import_typescript9.default.createSourceFile(filePath, source, import_typescript9.default.ScriptTarget.Latest, true, import_typescript9.default.ScriptKind.TSX);
|
|
190238
190300
|
}
|
|
190239
190301
|
if (!checker && needsTypeBasedDetection(source)) {
|
|
190240
190302
|
const result = createProgramForFile(source, filePath);
|
|
@@ -190280,23 +190342,23 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
|
|
|
190280
190342
|
function findDefaultExportedComponent(sourceFile) {
|
|
190281
190343
|
let defaultExportName;
|
|
190282
190344
|
function findDefaultExport(node) {
|
|
190283
|
-
if (
|
|
190284
|
-
if (
|
|
190345
|
+
if (import_typescript9.default.isExportAssignment(node) && !node.isExportEquals) {
|
|
190346
|
+
if (import_typescript9.default.isIdentifier(node.expression)) {
|
|
190285
190347
|
defaultExportName = node.expression.text;
|
|
190286
190348
|
}
|
|
190287
190349
|
}
|
|
190288
|
-
if (
|
|
190350
|
+
if (import_typescript9.default.isFunctionDeclaration(node) && node.name && node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.DefaultKeyword)) {
|
|
190289
190351
|
defaultExportName = node.name.text;
|
|
190290
190352
|
}
|
|
190291
|
-
|
|
190353
|
+
import_typescript9.default.forEachChild(node, findDefaultExport);
|
|
190292
190354
|
}
|
|
190293
|
-
|
|
190355
|
+
import_typescript9.default.forEachChild(sourceFile, findDefaultExport);
|
|
190294
190356
|
return defaultExportName;
|
|
190295
190357
|
}
|
|
190296
190358
|
function collectNamedExports(sourceFile) {
|
|
190297
190359
|
const exported = new Set;
|
|
190298
190360
|
for (const stmt of sourceFile.statements) {
|
|
190299
|
-
if (
|
|
190361
|
+
if (import_typescript9.default.isExportDeclaration(stmt) && stmt.exportClause && import_typescript9.default.isNamedExports(stmt.exportClause)) {
|
|
190300
190362
|
for (const spec of stmt.exportClause.elements) {
|
|
190301
190363
|
const local = (spec.propertyName ?? spec.name).text;
|
|
190302
190364
|
exported.add(local);
|
|
@@ -190306,22 +190368,22 @@ function collectNamedExports(sourceFile) {
|
|
|
190306
190368
|
return exported;
|
|
190307
190369
|
}
|
|
190308
190370
|
function visit(node, ctx, targetComponentName, namedExports) {
|
|
190309
|
-
if (
|
|
190371
|
+
if (import_typescript9.default.isExpressionStatement(node) && import_typescript9.default.isStringLiteral(node.expression)) {
|
|
190310
190372
|
if (node.expression.text === "use client" || node.expression.text === "'use client'") {
|
|
190311
190373
|
ctx.hasUseClientDirective = true;
|
|
190312
190374
|
}
|
|
190313
190375
|
}
|
|
190314
|
-
if (
|
|
190376
|
+
if (import_typescript9.default.isImportDeclaration(node)) {
|
|
190315
190377
|
collectImport(node, ctx);
|
|
190316
190378
|
}
|
|
190317
|
-
if (
|
|
190379
|
+
if (import_typescript9.default.isInterfaceDeclaration(node)) {
|
|
190318
190380
|
collectInterfaceDefinition(node, ctx);
|
|
190319
190381
|
}
|
|
190320
|
-
if (
|
|
190382
|
+
if (import_typescript9.default.isTypeAliasDeclaration(node)) {
|
|
190321
190383
|
collectTypeAliasDefinition(node, ctx);
|
|
190322
190384
|
}
|
|
190323
|
-
if (!ctx.hasUseClientDirective &&
|
|
190324
|
-
const hasInlineExport = node.modifiers?.some((m) => m.kind ===
|
|
190385
|
+
if (!ctx.hasUseClientDirective && import_typescript9.default.isFunctionDeclaration(node) && node.name && node.body && isMultiReturnJsxFunctionBody(node.body)) {
|
|
190386
|
+
const hasInlineExport = node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190325
190387
|
const hasNamedExport = namedExports?.has(node.name.text) ?? false;
|
|
190326
190388
|
if (!hasInlineExport && !hasNamedExport) {
|
|
190327
190389
|
collectFunction(node, ctx, true, false);
|
|
@@ -190336,9 +190398,9 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190336
190398
|
if (!ctx.componentName) {
|
|
190337
190399
|
ctx.componentName = node.name.text;
|
|
190338
190400
|
ctx.componentNode = node;
|
|
190339
|
-
ctx.isExported = node.modifiers?.some((m) => m.kind ===
|
|
190401
|
+
ctx.isExported = node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190340
190402
|
analyzeComponentBody(node, ctx);
|
|
190341
|
-
if (node.modifiers?.some((m) => m.kind ===
|
|
190403
|
+
if (node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.DefaultKeyword)) {
|
|
190342
190404
|
ctx.hasDefaultExport = true;
|
|
190343
190405
|
}
|
|
190344
190406
|
}
|
|
@@ -190352,10 +190414,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190352
190414
|
ctx.componentName = node.name.text;
|
|
190353
190415
|
ctx.componentNode = node.initializer;
|
|
190354
190416
|
const parentStatement = node.parent;
|
|
190355
|
-
if (
|
|
190417
|
+
if (import_typescript9.default.isVariableDeclarationList(parentStatement)) {
|
|
190356
190418
|
const varStatement = parentStatement.parent;
|
|
190357
|
-
if (
|
|
190358
|
-
ctx.isExported = varStatement.modifiers?.some((m) => m.kind ===
|
|
190419
|
+
if (import_typescript9.default.isVariableStatement(varStatement)) {
|
|
190420
|
+
ctx.isExported = varStatement.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190359
190421
|
}
|
|
190360
190422
|
}
|
|
190361
190423
|
analyzeComponentBody(node.initializer, ctx);
|
|
@@ -190367,9 +190429,9 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190367
190429
|
if (!ctx.componentNode) {
|
|
190368
190430
|
collectAmbientGlobals(node, ctx);
|
|
190369
190431
|
}
|
|
190370
|
-
if (
|
|
190371
|
-
const isExported = node.modifiers?.some((m) => m.kind ===
|
|
190372
|
-
const isLet = (node.declarationList.flags &
|
|
190432
|
+
if (import_typescript9.default.isVariableStatement(node) && !ctx.componentNode) {
|
|
190433
|
+
const isExported = node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190434
|
+
const isLet = (node.declarationList.flags & import_typescript9.default.NodeFlags.Let) !== 0;
|
|
190373
190435
|
const isModuleClientDirective = hasLeadingClientDirectiveOnStatement(node, ctx.sourceFile);
|
|
190374
190436
|
for (const decl of node.declarationList.declarations) {
|
|
190375
190437
|
if (declarationIsReactiveFactoryCall(decl, ctx)) {
|
|
@@ -190380,19 +190442,19 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190380
190442
|
}
|
|
190381
190443
|
continue;
|
|
190382
190444
|
}
|
|
190383
|
-
if (
|
|
190445
|
+
if (import_typescript9.default.isIdentifier(decl.name) && decl.initializer && !isArrowComponentFunction(decl)) {
|
|
190384
190446
|
collectConstant(decl, ctx, true, isLet ? "let" : "const", isExported);
|
|
190385
190447
|
}
|
|
190386
190448
|
}
|
|
190387
190449
|
}
|
|
190388
|
-
if (
|
|
190389
|
-
const isExported = node.modifiers?.some((m) => m.kind ===
|
|
190450
|
+
if (import_typescript9.default.isFunctionDeclaration(node) && node.name && !isComponentFunction(node)) {
|
|
190451
|
+
const isExported = node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190390
190452
|
collectFunction(node, ctx, true, isExported);
|
|
190391
190453
|
return;
|
|
190392
190454
|
}
|
|
190393
|
-
if (
|
|
190455
|
+
if (import_typescript9.default.isExportDeclaration(node) && node.exportClause && import_typescript9.default.isNamedExports(node.exportClause)) {
|
|
190394
190456
|
const isFromReexport = !!node.moduleSpecifier;
|
|
190395
|
-
const sourceSpec = node.moduleSpecifier &&
|
|
190457
|
+
const sourceSpec = node.moduleSpecifier && import_typescript9.default.isStringLiteral(node.moduleSpecifier) ? node.moduleSpecifier.text : null;
|
|
190396
190458
|
const exportSpecifiers = node.exportClause.elements.map((spec) => ({
|
|
190397
190459
|
name: (spec.propertyName ?? spec.name).text,
|
|
190398
190460
|
alias: spec.propertyName ? spec.name.text : null,
|
|
@@ -190420,24 +190482,24 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190420
190482
|
}
|
|
190421
190483
|
}
|
|
190422
190484
|
}
|
|
190423
|
-
if (
|
|
190485
|
+
if (import_typescript9.default.isExportAssignment(node) && !node.isExportEquals) {
|
|
190424
190486
|
const expr = node.expression;
|
|
190425
|
-
if (
|
|
190487
|
+
if (import_typescript9.default.isIdentifier(expr)) {
|
|
190426
190488
|
if (ctx.componentName && expr.text === ctx.componentName) {
|
|
190427
190489
|
ctx.hasDefaultExport = true;
|
|
190428
190490
|
ctx.isExported = true;
|
|
190429
190491
|
}
|
|
190430
190492
|
}
|
|
190431
190493
|
}
|
|
190432
|
-
|
|
190494
|
+
import_typescript9.default.forEachChild(node, (child) => visit(child, ctx, targetComponentName, namedExports));
|
|
190433
190495
|
}
|
|
190434
190496
|
function analyzeComponentBody(node, ctx) {
|
|
190435
190497
|
if (node.parameters.length > 0) {
|
|
190436
190498
|
extractProps(node.parameters[0], ctx);
|
|
190437
190499
|
}
|
|
190438
|
-
const body =
|
|
190500
|
+
const body = import_typescript9.default.isFunctionDeclaration(node) ? node.body : getArrowFunctionBody(node);
|
|
190439
190501
|
if (body) {
|
|
190440
|
-
ctx.componentBodyBlock =
|
|
190502
|
+
ctx.componentBodyBlock = import_typescript9.default.isBlock(body) ? body : null;
|
|
190441
190503
|
if (!ctx.componentBodyBlock) {
|
|
190442
190504
|
ctx.jsxReturn = unwrapJsxTransparent(body);
|
|
190443
190505
|
}
|
|
@@ -190447,14 +190509,14 @@ function analyzeComponentBody(node, ctx) {
|
|
|
190447
190509
|
}
|
|
190448
190510
|
}
|
|
190449
190511
|
function getArrowFunctionBody(node) {
|
|
190450
|
-
if (
|
|
190512
|
+
if (import_typescript9.default.isBlock(node.body)) {
|
|
190451
190513
|
return node.body;
|
|
190452
190514
|
}
|
|
190453
190515
|
return node.body;
|
|
190454
190516
|
}
|
|
190455
190517
|
function visitComponentBody(node, ctx) {
|
|
190456
190518
|
const isTopLevel = ctx.componentBodyBlock !== null && node.parent === ctx.componentBodyBlock;
|
|
190457
|
-
if (
|
|
190519
|
+
if (import_typescript9.default.isVariableStatement(node)) {
|
|
190458
190520
|
for (const decl of node.declarationList.declarations) {
|
|
190459
190521
|
if (isSignalDeclaration(decl, ctx)) {
|
|
190460
190522
|
collectSignal(decl, ctx);
|
|
@@ -190477,16 +190539,16 @@ function visitComponentBody(node, ctx) {
|
|
|
190477
190539
|
collectEffect(decl.initializer, ctx, decl.name.text);
|
|
190478
190540
|
continue;
|
|
190479
190541
|
}
|
|
190480
|
-
if (
|
|
190481
|
-
const isLet = (node.declarationList.flags &
|
|
190542
|
+
if (import_typescript9.default.isIdentifier(decl.name)) {
|
|
190543
|
+
const isLet = (node.declarationList.flags & import_typescript9.default.NodeFlags.Let) !== 0;
|
|
190482
190544
|
collectConstant(decl, ctx, false, isLet ? "let" : "const");
|
|
190483
|
-
} else if (
|
|
190484
|
-
const isLet = (node.declarationList.flags &
|
|
190545
|
+
} else if (import_typescript9.default.isObjectBindingPattern(decl.name) && decl.initializer && import_typescript9.default.isIdentifier(decl.initializer) && ctx.propsObjectName === decl.initializer.text) {
|
|
190546
|
+
const isLet = (node.declarationList.flags & import_typescript9.default.NodeFlags.Let) !== 0;
|
|
190485
190547
|
collectConstant(decl, ctx, false, isLet ? "let" : "const");
|
|
190486
190548
|
}
|
|
190487
190549
|
}
|
|
190488
190550
|
}
|
|
190489
|
-
if (
|
|
190551
|
+
if (import_typescript9.default.isExpressionStatement(node)) {
|
|
190490
190552
|
if (isEffectCall(node.expression, ctx)) {
|
|
190491
190553
|
collectEffect(node.expression, ctx);
|
|
190492
190554
|
return;
|
|
@@ -190500,10 +190562,10 @@ function visitComponentBody(node, ctx) {
|
|
|
190500
190562
|
return;
|
|
190501
190563
|
}
|
|
190502
190564
|
}
|
|
190503
|
-
if (
|
|
190565
|
+
if (import_typescript9.default.isFunctionDeclaration(node) && node.name) {
|
|
190504
190566
|
collectFunction(node, ctx, false);
|
|
190505
190567
|
}
|
|
190506
|
-
if (
|
|
190568
|
+
if (import_typescript9.default.isIfStatement(node)) {
|
|
190507
190569
|
const jsxReturn = findJsxReturnInBlock(node.thenStatement);
|
|
190508
190570
|
if (jsxReturn) {
|
|
190509
190571
|
const scopeVars = collectScopeVariables(node.thenStatement, ctx);
|
|
@@ -190522,54 +190584,54 @@ function visitComponentBody(node, ctx) {
|
|
|
190522
190584
|
return;
|
|
190523
190585
|
}
|
|
190524
190586
|
}
|
|
190525
|
-
if (isTopLevel && (
|
|
190587
|
+
if (isTopLevel && (import_typescript9.default.isTryStatement(node) || import_typescript9.default.isSwitchStatement(node) || import_typescript9.default.isForStatement(node) || import_typescript9.default.isForInStatement(node) || import_typescript9.default.isForOfStatement(node) || import_typescript9.default.isWhileStatement(node) || import_typescript9.default.isDoStatement(node) || import_typescript9.default.isThrowStatement(node) || import_typescript9.default.isBlock(node) && node.parent === ctx.componentBodyBlock)) {
|
|
190526
190588
|
collectInitStatement(node, ctx);
|
|
190527
190589
|
return;
|
|
190528
190590
|
}
|
|
190529
|
-
if (
|
|
190591
|
+
if (import_typescript9.default.isReturnStatement(node) && node.expression) {
|
|
190530
190592
|
ctx.jsxReturn = unwrapJsxTransparent(node.expression);
|
|
190531
190593
|
}
|
|
190532
|
-
|
|
190533
|
-
if (
|
|
190594
|
+
import_typescript9.default.forEachChild(node, (child) => {
|
|
190595
|
+
if (import_typescript9.default.isArrowFunction(child) || import_typescript9.default.isFunctionExpression(child) || import_typescript9.default.isFunctionDeclaration(child)) {
|
|
190534
190596
|
return;
|
|
190535
190597
|
}
|
|
190536
190598
|
visitComponentBody(child, ctx);
|
|
190537
190599
|
});
|
|
190538
190600
|
}
|
|
190539
190601
|
function findJsxReturnInBlock(node) {
|
|
190540
|
-
if (
|
|
190602
|
+
if (import_typescript9.default.isBlock(node)) {
|
|
190541
190603
|
for (const stmt of node.statements) {
|
|
190542
|
-
if (
|
|
190604
|
+
if (import_typescript9.default.isReturnStatement(stmt) && stmt.expression) {
|
|
190543
190605
|
const jsx = extractJsxFromExpression(stmt.expression);
|
|
190544
190606
|
if (jsx)
|
|
190545
190607
|
return jsx;
|
|
190546
190608
|
}
|
|
190547
190609
|
}
|
|
190548
190610
|
}
|
|
190549
|
-
if (
|
|
190611
|
+
if (import_typescript9.default.isReturnStatement(node) && node.expression) {
|
|
190550
190612
|
return extractJsxFromExpression(node.expression);
|
|
190551
190613
|
}
|
|
190552
190614
|
return null;
|
|
190553
190615
|
}
|
|
190554
190616
|
function unwrapJsxTransparent(expr) {
|
|
190555
190617
|
let current = expr;
|
|
190556
|
-
while (
|
|
190618
|
+
while (import_typescript9.default.isParenthesizedExpression(current) || import_typescript9.default.isAsExpression(current) || import_typescript9.default.isSatisfiesExpression(current) || import_typescript9.default.isNonNullExpression(current) || import_typescript9.default.isTypeAssertionExpression(current) || current.kind === import_typescript9.default.SyntaxKind.PartiallyEmittedExpression) {
|
|
190557
190619
|
current = current.expression;
|
|
190558
190620
|
}
|
|
190559
190621
|
return current;
|
|
190560
190622
|
}
|
|
190561
190623
|
function extractJsxFromExpression(expr) {
|
|
190562
190624
|
const inner = unwrapJsxTransparent(expr);
|
|
190563
|
-
if (
|
|
190625
|
+
if (import_typescript9.default.isJsxElement(inner) || import_typescript9.default.isJsxFragment(inner) || import_typescript9.default.isJsxSelfClosingElement(inner)) {
|
|
190564
190626
|
return inner;
|
|
190565
190627
|
}
|
|
190566
190628
|
return null;
|
|
190567
190629
|
}
|
|
190568
190630
|
function collectScopeVariables(node, ctx) {
|
|
190569
190631
|
const variables = [];
|
|
190570
|
-
if (
|
|
190632
|
+
if (import_typescript9.default.isBlock(node)) {
|
|
190571
190633
|
for (const stmt of node.statements) {
|
|
190572
|
-
if (
|
|
190634
|
+
if (import_typescript9.default.isVariableStatement(stmt)) {
|
|
190573
190635
|
for (const decl of stmt.declarationList.declarations) {
|
|
190574
190636
|
variables.push(decl);
|
|
190575
190637
|
}
|
|
@@ -190581,13 +190643,13 @@ function collectScopeVariables(node, ctx) {
|
|
|
190581
190643
|
function collectParamBindingNames(params) {
|
|
190582
190644
|
const out = new Set;
|
|
190583
190645
|
const addBindingNames = (name) => {
|
|
190584
|
-
if (
|
|
190646
|
+
if (import_typescript9.default.isIdentifier(name)) {
|
|
190585
190647
|
out.add(name.text);
|
|
190586
|
-
} else if (
|
|
190648
|
+
} else if (import_typescript9.default.isObjectBindingPattern(name)) {
|
|
190587
190649
|
name.elements.forEach((e) => addBindingNames(e.name));
|
|
190588
|
-
} else if (
|
|
190650
|
+
} else if (import_typescript9.default.isArrayBindingPattern(name)) {
|
|
190589
190651
|
name.elements.forEach((e) => {
|
|
190590
|
-
if (!
|
|
190652
|
+
if (!import_typescript9.default.isOmittedExpression(e))
|
|
190591
190653
|
addBindingNames(e.name);
|
|
190592
190654
|
});
|
|
190593
190655
|
}
|
|
@@ -190604,7 +190666,7 @@ function collectEnclosingBranchVars(node, ctx) {
|
|
|
190604
190666
|
if (cr.ifStatement.thenStatement !== current)
|
|
190605
190667
|
continue;
|
|
190606
190668
|
for (const decl of cr.scopeVariables) {
|
|
190607
|
-
if (!
|
|
190669
|
+
if (!import_typescript9.default.isIdentifier(decl.name) || !decl.initializer)
|
|
190608
190670
|
continue;
|
|
190609
190671
|
const varName = decl.name.text;
|
|
190610
190672
|
if (result.has(varName))
|
|
@@ -190619,10 +190681,10 @@ function collectEnclosingBranchVars(node, ctx) {
|
|
|
190619
190681
|
return result;
|
|
190620
190682
|
}
|
|
190621
190683
|
function collectBranchSignals(thenStatement, ctx, branchCondition) {
|
|
190622
|
-
if (!
|
|
190684
|
+
if (!import_typescript9.default.isBlock(thenStatement))
|
|
190623
190685
|
return;
|
|
190624
190686
|
for (const stmt of thenStatement.statements) {
|
|
190625
|
-
if (!
|
|
190687
|
+
if (!import_typescript9.default.isVariableStatement(stmt))
|
|
190626
190688
|
continue;
|
|
190627
190689
|
for (const decl of stmt.declarationList.declarations) {
|
|
190628
190690
|
if (!isSignalDeclaration(decl, ctx))
|
|
@@ -190648,13 +190710,13 @@ var ENV_SIGNAL_FACTORIES = {
|
|
|
190648
190710
|
createSearchParams: "search"
|
|
190649
190711
|
};
|
|
190650
190712
|
function resolvePrimitiveKind(callExpr, ctx) {
|
|
190651
|
-
if (
|
|
190713
|
+
if (import_typescript9.default.isIdentifier(callExpr.expression)) {
|
|
190652
190714
|
const hit = PRIMITIVE_CANONICAL_NAMES[callExpr.expression.text];
|
|
190653
190715
|
if (hit)
|
|
190654
190716
|
return hit;
|
|
190655
190717
|
return resolveCalleeViaChecker(callExpr.expression, ctx);
|
|
190656
190718
|
}
|
|
190657
|
-
if (
|
|
190719
|
+
if (import_typescript9.default.isPropertyAccessExpression(callExpr.expression)) {
|
|
190658
190720
|
const propName = callExpr.expression.name.text;
|
|
190659
190721
|
const hit = PRIMITIVE_CANONICAL_NAMES[propName];
|
|
190660
190722
|
if (!hit)
|
|
@@ -190681,7 +190743,7 @@ function resolveCanonicalClientExportName(ident, ctx) {
|
|
|
190681
190743
|
if (!symbol)
|
|
190682
190744
|
return null;
|
|
190683
190745
|
let target = symbol;
|
|
190684
|
-
if (symbol.flags &
|
|
190746
|
+
if (symbol.flags & import_typescript9.default.SymbolFlags.Alias) {
|
|
190685
190747
|
try {
|
|
190686
190748
|
target = ctx.checker.getAliasedSymbol(symbol);
|
|
190687
190749
|
} catch {
|
|
@@ -190697,14 +190759,14 @@ function resolveCanonicalClientExportName(ident, ctx) {
|
|
|
190697
190759
|
return null;
|
|
190698
190760
|
}
|
|
190699
190761
|
function resolveEnvSignalKey(callExpr, ctx) {
|
|
190700
|
-
if (
|
|
190762
|
+
if (import_typescript9.default.isIdentifier(callExpr.expression)) {
|
|
190701
190763
|
const key = ENV_SIGNAL_FACTORIES[callExpr.expression.text];
|
|
190702
190764
|
if (key)
|
|
190703
190765
|
return key;
|
|
190704
190766
|
const canonical = resolveCanonicalClientExportName(callExpr.expression, ctx);
|
|
190705
190767
|
return canonical ? ENV_SIGNAL_FACTORIES[canonical] ?? null : null;
|
|
190706
190768
|
}
|
|
190707
|
-
if (
|
|
190769
|
+
if (import_typescript9.default.isPropertyAccessExpression(callExpr.expression)) {
|
|
190708
190770
|
const key = ENV_SIGNAL_FACTORIES[callExpr.expression.name.text];
|
|
190709
190771
|
if (key && isBarefootClientNamespace(callExpr.expression.expression, ctx))
|
|
190710
190772
|
return key;
|
|
@@ -190712,7 +190774,7 @@ function resolveEnvSignalKey(callExpr, ctx) {
|
|
|
190712
190774
|
return null;
|
|
190713
190775
|
}
|
|
190714
190776
|
function isBarefootClientNamespace(expr, ctx) {
|
|
190715
|
-
if (!
|
|
190777
|
+
if (!import_typescript9.default.isIdentifier(expr))
|
|
190716
190778
|
return false;
|
|
190717
190779
|
if (!ctx.checker)
|
|
190718
190780
|
return false;
|
|
@@ -190725,22 +190787,22 @@ function isBarefootClientNamespace(expr, ctx) {
|
|
|
190725
190787
|
if (!symbol)
|
|
190726
190788
|
return false;
|
|
190727
190789
|
for (const decl of symbol.declarations ?? []) {
|
|
190728
|
-
if (!
|
|
190790
|
+
if (!import_typescript9.default.isNamespaceImport(decl))
|
|
190729
190791
|
continue;
|
|
190730
190792
|
const importDecl = decl.parent.parent;
|
|
190731
|
-
if (!
|
|
190793
|
+
if (!import_typescript9.default.isImportDeclaration(importDecl))
|
|
190732
190794
|
continue;
|
|
190733
190795
|
const mod = importDecl.moduleSpecifier;
|
|
190734
|
-
if (
|
|
190796
|
+
if (import_typescript9.default.isStringLiteral(mod) && mod.text === "@barefootjs/client") {
|
|
190735
190797
|
return true;
|
|
190736
190798
|
}
|
|
190737
190799
|
}
|
|
190738
190800
|
return false;
|
|
190739
190801
|
}
|
|
190740
190802
|
function isSignalDeclaration(node, ctx) {
|
|
190741
|
-
if (!
|
|
190803
|
+
if (!import_typescript9.default.isArrayBindingPattern(node.name))
|
|
190742
190804
|
return false;
|
|
190743
|
-
if (!node.initializer || !
|
|
190805
|
+
if (!node.initializer || !import_typescript9.default.isCallExpression(node.initializer))
|
|
190744
190806
|
return false;
|
|
190745
190807
|
return resolvePrimitiveKind(node.initializer, ctx) === "signal";
|
|
190746
190808
|
}
|
|
@@ -190748,14 +190810,14 @@ function collectSignal(node, ctx) {
|
|
|
190748
190810
|
const pattern = node.name;
|
|
190749
190811
|
const callExpr = node.initializer;
|
|
190750
190812
|
const elements = pattern.elements;
|
|
190751
|
-
const getterElided = elements.length === 2 &&
|
|
190752
|
-
if (elements.length < 1 || elements.length > 2 || !getterElided && (!
|
|
190813
|
+
const getterElided = elements.length === 2 && import_typescript9.default.isOmittedExpression(elements[0]);
|
|
190814
|
+
if (elements.length < 1 || elements.length > 2 || !getterElided && (!import_typescript9.default.isBindingElement(elements[0]) || !import_typescript9.default.isIdentifier(elements[0].name))) {
|
|
190753
190815
|
return;
|
|
190754
190816
|
}
|
|
190755
|
-
if (elements.length === 2 && (!
|
|
190817
|
+
if (elements.length === 2 && (!import_typescript9.default.isBindingElement(elements[1]) || !import_typescript9.default.isIdentifier(elements[1].name))) {
|
|
190756
190818
|
return;
|
|
190757
190819
|
}
|
|
190758
|
-
const setter = elements.length === 2 &&
|
|
190820
|
+
const setter = elements.length === 2 && import_typescript9.default.isBindingElement(elements[1]) && import_typescript9.default.isIdentifier(elements[1].name) ? elements[1].name.text : null;
|
|
190759
190821
|
if (getterElided && !setter)
|
|
190760
190822
|
return;
|
|
190761
190823
|
const getter = getterElided ? `__bfGet_${setter}` : elements[0].name.text;
|
|
@@ -190773,7 +190835,8 @@ function collectSignal(node, ctx) {
|
|
|
190773
190835
|
if (!ctx.propsObjectName && callExpr.arguments[0]) {
|
|
190774
190836
|
const propNames = new Set(ctx.propsParams.map((p) => p.name));
|
|
190775
190837
|
if (propNames.size > 0) {
|
|
190776
|
-
|
|
190838
|
+
const propAliases = buildPropAliasMap(ctx.propsParams);
|
|
190839
|
+
templateInitialValue = rewriteBarePropRefs(initialValue, callExpr.arguments[0], propNames, undefined, propAliases);
|
|
190777
190840
|
}
|
|
190778
190841
|
}
|
|
190779
190842
|
ctx.signals.push({
|
|
@@ -190791,33 +190854,33 @@ function collectSignal(node, ctx) {
|
|
|
190791
190854
|
});
|
|
190792
190855
|
}
|
|
190793
190856
|
function isSignalTupleDeclaration(node) {
|
|
190794
|
-
if (!
|
|
190857
|
+
if (!import_typescript9.default.isIdentifier(node.name))
|
|
190795
190858
|
return false;
|
|
190796
|
-
if (!node.initializer || !
|
|
190859
|
+
if (!node.initializer || !import_typescript9.default.isCallExpression(node.initializer))
|
|
190797
190860
|
return false;
|
|
190798
190861
|
const callExpr = node.initializer;
|
|
190799
|
-
return
|
|
190862
|
+
return import_typescript9.default.isIdentifier(callExpr.expression) && callExpr.expression.text === "createSignal";
|
|
190800
190863
|
}
|
|
190801
190864
|
function isSignalIndexAccess(node, ctx) {
|
|
190802
|
-
if (!
|
|
190865
|
+
if (!import_typescript9.default.isIdentifier(node.name))
|
|
190803
190866
|
return null;
|
|
190804
|
-
if (!node.initializer || !
|
|
190867
|
+
if (!node.initializer || !import_typescript9.default.isElementAccessExpression(node.initializer))
|
|
190805
190868
|
return null;
|
|
190806
190869
|
const access = node.initializer;
|
|
190807
|
-
if (!
|
|
190870
|
+
if (!import_typescript9.default.isNumericLiteral(access.argumentExpression))
|
|
190808
190871
|
return null;
|
|
190809
190872
|
const indexValue = Number(access.argumentExpression.text);
|
|
190810
190873
|
if (indexValue !== 0 && indexValue !== 1)
|
|
190811
190874
|
return null;
|
|
190812
190875
|
const index = indexValue;
|
|
190813
|
-
if (
|
|
190876
|
+
if (import_typescript9.default.isCallExpression(access.expression)) {
|
|
190814
190877
|
const call = access.expression;
|
|
190815
|
-
if (
|
|
190878
|
+
if (import_typescript9.default.isIdentifier(call.expression) && call.expression.text === "createSignal") {
|
|
190816
190879
|
return { kind: "direct", index, callExpr: call };
|
|
190817
190880
|
}
|
|
190818
190881
|
return null;
|
|
190819
190882
|
}
|
|
190820
|
-
if (
|
|
190883
|
+
if (import_typescript9.default.isIdentifier(access.expression)) {
|
|
190821
190884
|
const tupleName = access.expression.text;
|
|
190822
190885
|
if (ctx.signalTupleRefs.has(tupleName)) {
|
|
190823
190886
|
return { kind: "tupleRef", index, tupleName };
|
|
@@ -190912,30 +190975,30 @@ function flushPendingSignalTuples(ctx) {
|
|
|
190912
190975
|
ctx.signalTupleRefs.clear();
|
|
190913
190976
|
}
|
|
190914
190977
|
function isMemoDeclaration(node, ctx) {
|
|
190915
|
-
if (!
|
|
190978
|
+
if (!import_typescript9.default.isIdentifier(node.name))
|
|
190916
190979
|
return false;
|
|
190917
|
-
if (!node.initializer || !
|
|
190980
|
+
if (!node.initializer || !import_typescript9.default.isCallExpression(node.initializer))
|
|
190918
190981
|
return false;
|
|
190919
190982
|
return resolvePrimitiveKind(node.initializer, ctx) === "memo";
|
|
190920
190983
|
}
|
|
190921
190984
|
function memoBodyIsTemplateLiteral(memoArrow) {
|
|
190922
190985
|
let node = memoArrow;
|
|
190923
|
-
while (node &&
|
|
190986
|
+
while (node && import_typescript9.default.isParenthesizedExpression(node))
|
|
190924
190987
|
node = node.expression;
|
|
190925
|
-
if (!node || !
|
|
190988
|
+
if (!node || !import_typescript9.default.isArrowFunction(node))
|
|
190926
190989
|
return false;
|
|
190927
190990
|
let body = node.body;
|
|
190928
|
-
while (
|
|
190991
|
+
while (import_typescript9.default.isParenthesizedExpression(body))
|
|
190929
190992
|
body = body.expression;
|
|
190930
|
-
if (
|
|
190931
|
-
const ret = body.statements.find(
|
|
190993
|
+
if (import_typescript9.default.isBlock(body)) {
|
|
190994
|
+
const ret = body.statements.find(import_typescript9.default.isReturnStatement);
|
|
190932
190995
|
if (!ret || !ret.expression)
|
|
190933
190996
|
return false;
|
|
190934
190997
|
body = ret.expression;
|
|
190935
|
-
while (
|
|
190998
|
+
while (import_typescript9.default.isParenthesizedExpression(body))
|
|
190936
190999
|
body = body.expression;
|
|
190937
191000
|
}
|
|
190938
|
-
return
|
|
191001
|
+
return import_typescript9.default.isTemplateExpression(body) || import_typescript9.default.isNoSubstitutionTemplateLiteral(body);
|
|
190939
191002
|
}
|
|
190940
191003
|
function collectMemo(node, ctx) {
|
|
190941
191004
|
const name = node.name.text;
|
|
@@ -190952,7 +191015,7 @@ function collectMemo(node, ctx) {
|
|
|
190952
191015
|
type2 = inferTypeFromValue(arrowBody);
|
|
190953
191016
|
}
|
|
190954
191017
|
}
|
|
190955
|
-
if (ctx.checker && (type2.kind === "unknown" || type2.kind === "object") && callExpr.arguments[0] && (
|
|
191018
|
+
if (ctx.checker && (type2.kind === "unknown" || type2.kind === "object") && callExpr.arguments[0] && (import_typescript9.default.isArrowFunction(callExpr.arguments[0]) || import_typescript9.default.isFunctionExpression(callExpr.arguments[0]))) {
|
|
190956
191019
|
const fnType = ctx.checker.getTypeAtLocation(callExpr.arguments[0]);
|
|
190957
191020
|
const sig = fnType.getCallSignatures()[0];
|
|
190958
191021
|
if (sig) {
|
|
@@ -190962,19 +191025,20 @@ function collectMemo(node, ctx) {
|
|
|
190962
191025
|
}
|
|
190963
191026
|
}
|
|
190964
191027
|
const memoArrow = callExpr.arguments[0];
|
|
190965
|
-
const parsedBody = memoArrow &&
|
|
191028
|
+
const parsedBody = memoArrow && import_typescript9.default.isArrowFunction(memoArrow) && !import_typescript9.default.isBlock(memoArrow.body) ? parseExpression(ctx.getJS(memoArrow.body)) : undefined;
|
|
190966
191029
|
const parsed = parsedBody && parsedBody.kind !== "unsupported" && parsedBody.kind !== "object-literal" ? parsedBody : undefined;
|
|
190967
191030
|
let arrowNode = memoArrow;
|
|
190968
|
-
while (arrowNode &&
|
|
191031
|
+
while (arrowNode && import_typescript9.default.isParenthesizedExpression(arrowNode))
|
|
190969
191032
|
arrowNode = arrowNode.expression;
|
|
190970
|
-
const blockBody = arrowNode &&
|
|
191033
|
+
const blockBody = arrowNode && import_typescript9.default.isArrowFunction(arrowNode) && import_typescript9.default.isBlock(arrowNode.body) ? arrowNode.body : undefined;
|
|
190971
191034
|
const parsedBlock = blockBody ? parseBlockBodyTolerant(blockBody, ctx.sourceFile, (node2) => ctx.getJS(node2)) : undefined;
|
|
190972
191035
|
const parsedBlockComplete = parsedBlock && blockBody ? parsedBlock.length === blockBody.statements.length : undefined;
|
|
190973
191036
|
let templateComputation;
|
|
190974
191037
|
if (!ctx.propsObjectName && callExpr.arguments[0]) {
|
|
190975
191038
|
const propNames = new Set(ctx.propsParams.map((p) => p.name));
|
|
190976
191039
|
if (propNames.size > 0) {
|
|
190977
|
-
|
|
191040
|
+
const propAliases = buildPropAliasMap(ctx.propsParams);
|
|
191041
|
+
templateComputation = rewriteBarePropRefs(computation, callExpr.arguments[0], propNames, undefined, propAliases);
|
|
190978
191042
|
}
|
|
190979
191043
|
}
|
|
190980
191044
|
ctx.memos.push({
|
|
@@ -190993,14 +191057,14 @@ function collectMemo(node, ctx) {
|
|
|
190993
191057
|
});
|
|
190994
191058
|
}
|
|
190995
191059
|
function isEffectCall(node, ctx) {
|
|
190996
|
-
if (!
|
|
191060
|
+
if (!import_typescript9.default.isCallExpression(node))
|
|
190997
191061
|
return false;
|
|
190998
191062
|
return resolvePrimitiveKind(node, ctx) === "effect";
|
|
190999
191063
|
}
|
|
191000
191064
|
function isEffectDisposerCapture(node, ctx) {
|
|
191001
|
-
if (!
|
|
191065
|
+
if (!import_typescript9.default.isIdentifier(node.name))
|
|
191002
191066
|
return false;
|
|
191003
|
-
if (!node.initializer || !
|
|
191067
|
+
if (!node.initializer || !import_typescript9.default.isCallExpression(node.initializer))
|
|
191004
191068
|
return false;
|
|
191005
191069
|
return resolvePrimitiveKind(node.initializer, ctx) === "effect";
|
|
191006
191070
|
}
|
|
@@ -191015,7 +191079,7 @@ function collectEffect(node, ctx, captureName) {
|
|
|
191015
191079
|
});
|
|
191016
191080
|
}
|
|
191017
191081
|
function isOnMountCall(node, ctx) {
|
|
191018
|
-
if (!
|
|
191082
|
+
if (!import_typescript9.default.isCallExpression(node))
|
|
191019
191083
|
return false;
|
|
191020
191084
|
return resolvePrimitiveKind(node, ctx) === "onMount";
|
|
191021
191085
|
}
|
|
@@ -191050,19 +191114,19 @@ function leadsWithAsiHazard(body) {
|
|
|
191050
191114
|
function extractAssignedIdentifiersFromNode(node) {
|
|
191051
191115
|
const ids = new Set;
|
|
191052
191116
|
function addFromTarget(target) {
|
|
191053
|
-
if (
|
|
191117
|
+
if (import_typescript9.default.isIdentifier(target)) {
|
|
191054
191118
|
ids.add(target.text);
|
|
191055
191119
|
return;
|
|
191056
191120
|
}
|
|
191057
|
-
if (
|
|
191121
|
+
if (import_typescript9.default.isParenthesizedExpression(target)) {
|
|
191058
191122
|
addFromTarget(target.expression);
|
|
191059
191123
|
return;
|
|
191060
191124
|
}
|
|
191061
|
-
if (
|
|
191125
|
+
if (import_typescript9.default.isArrayLiteralExpression(target)) {
|
|
191062
191126
|
for (const el of target.elements) {
|
|
191063
|
-
if (
|
|
191127
|
+
if (import_typescript9.default.isOmittedExpression(el))
|
|
191064
191128
|
continue;
|
|
191065
|
-
if (
|
|
191129
|
+
if (import_typescript9.default.isSpreadElement(el)) {
|
|
191066
191130
|
addFromTarget(el.expression);
|
|
191067
191131
|
continue;
|
|
191068
191132
|
}
|
|
@@ -191070,17 +191134,17 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191070
191134
|
}
|
|
191071
191135
|
return;
|
|
191072
191136
|
}
|
|
191073
|
-
if (
|
|
191137
|
+
if (import_typescript9.default.isObjectLiteralExpression(target)) {
|
|
191074
191138
|
for (const prop of target.properties) {
|
|
191075
|
-
if (
|
|
191139
|
+
if (import_typescript9.default.isShorthandPropertyAssignment(prop)) {
|
|
191076
191140
|
ids.add(prop.name.text);
|
|
191077
191141
|
continue;
|
|
191078
191142
|
}
|
|
191079
|
-
if (
|
|
191143
|
+
if (import_typescript9.default.isPropertyAssignment(prop)) {
|
|
191080
191144
|
addFromTarget(prop.initializer);
|
|
191081
191145
|
continue;
|
|
191082
191146
|
}
|
|
191083
|
-
if (
|
|
191147
|
+
if (import_typescript9.default.isSpreadAssignment(prop)) {
|
|
191084
191148
|
addFromTarget(prop.expression);
|
|
191085
191149
|
continue;
|
|
191086
191150
|
}
|
|
@@ -191089,21 +191153,21 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191089
191153
|
}
|
|
191090
191154
|
}
|
|
191091
191155
|
function visit2(n) {
|
|
191092
|
-
if (
|
|
191156
|
+
if (import_typescript9.default.isArrowFunction(n) || import_typescript9.default.isFunctionExpression(n) || import_typescript9.default.isFunctionDeclaration(n) || import_typescript9.default.isMethodDeclaration(n) || import_typescript9.default.isGetAccessorDeclaration(n) || import_typescript9.default.isSetAccessorDeclaration(n) || import_typescript9.default.isConstructorDeclaration(n)) {
|
|
191093
191157
|
return;
|
|
191094
191158
|
}
|
|
191095
|
-
if (
|
|
191159
|
+
if (import_typescript9.default.isBinaryExpression(n)) {
|
|
191096
191160
|
const op = n.operatorToken.kind;
|
|
191097
|
-
if (op ===
|
|
191161
|
+
if (op === import_typescript9.default.SyntaxKind.EqualsToken || op === import_typescript9.default.SyntaxKind.PlusEqualsToken || op === import_typescript9.default.SyntaxKind.MinusEqualsToken || op === import_typescript9.default.SyntaxKind.AsteriskEqualsToken || op === import_typescript9.default.SyntaxKind.SlashEqualsToken || op === import_typescript9.default.SyntaxKind.PercentEqualsToken || op === import_typescript9.default.SyntaxKind.AsteriskAsteriskEqualsToken || op === import_typescript9.default.SyntaxKind.AmpersandEqualsToken || op === import_typescript9.default.SyntaxKind.BarEqualsToken || op === import_typescript9.default.SyntaxKind.CaretEqualsToken || op === import_typescript9.default.SyntaxKind.LessThanLessThanEqualsToken || op === import_typescript9.default.SyntaxKind.GreaterThanGreaterThanEqualsToken || op === import_typescript9.default.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken || op === import_typescript9.default.SyntaxKind.AmpersandAmpersandEqualsToken || op === import_typescript9.default.SyntaxKind.BarBarEqualsToken || op === import_typescript9.default.SyntaxKind.QuestionQuestionEqualsToken) {
|
|
191098
191162
|
addFromTarget(n.left);
|
|
191099
191163
|
}
|
|
191100
191164
|
}
|
|
191101
|
-
if (
|
|
191102
|
-
if (n.operator ===
|
|
191165
|
+
if (import_typescript9.default.isPrefixUnaryExpression(n) || import_typescript9.default.isPostfixUnaryExpression(n)) {
|
|
191166
|
+
if (n.operator === import_typescript9.default.SyntaxKind.PlusPlusToken || n.operator === import_typescript9.default.SyntaxKind.MinusMinusToken) {
|
|
191103
191167
|
addFromTarget(n.operand);
|
|
191104
191168
|
}
|
|
191105
191169
|
}
|
|
191106
|
-
|
|
191170
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191107
191171
|
}
|
|
191108
191172
|
visit2(node);
|
|
191109
191173
|
const localDecls = collectLocalDeclarations(node);
|
|
@@ -191114,30 +191178,30 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191114
191178
|
function collectLocalDeclarations(root) {
|
|
191115
191179
|
const names = new Set;
|
|
191116
191180
|
function addBindingName(name) {
|
|
191117
|
-
if (
|
|
191181
|
+
if (import_typescript9.default.isIdentifier(name)) {
|
|
191118
191182
|
names.add(name.text);
|
|
191119
191183
|
return;
|
|
191120
191184
|
}
|
|
191121
|
-
if (
|
|
191185
|
+
if (import_typescript9.default.isArrayBindingPattern(name)) {
|
|
191122
191186
|
for (const el of name.elements) {
|
|
191123
|
-
if (
|
|
191187
|
+
if (import_typescript9.default.isBindingElement(el))
|
|
191124
191188
|
addBindingName(el.name);
|
|
191125
191189
|
}
|
|
191126
191190
|
return;
|
|
191127
191191
|
}
|
|
191128
|
-
if (
|
|
191192
|
+
if (import_typescript9.default.isObjectBindingPattern(name)) {
|
|
191129
191193
|
for (const el of name.elements) {
|
|
191130
191194
|
addBindingName(el.name);
|
|
191131
191195
|
}
|
|
191132
191196
|
}
|
|
191133
191197
|
}
|
|
191134
191198
|
function visit2(n) {
|
|
191135
|
-
if (
|
|
191199
|
+
if (import_typescript9.default.isArrowFunction(n) || import_typescript9.default.isFunctionExpression(n) || import_typescript9.default.isFunctionDeclaration(n))
|
|
191136
191200
|
return;
|
|
191137
|
-
if (
|
|
191201
|
+
if (import_typescript9.default.isVariableDeclaration(n)) {
|
|
191138
191202
|
addBindingName(n.name);
|
|
191139
191203
|
}
|
|
191140
|
-
|
|
191204
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191141
191205
|
}
|
|
191142
191206
|
visit2(root);
|
|
191143
191207
|
return names;
|
|
@@ -191171,35 +191235,35 @@ var CLIENT_EXPORTS = new Set([
|
|
|
191171
191235
|
"Region"
|
|
191172
191236
|
]);
|
|
191173
191237
|
function collectAmbientGlobals(node, ctx) {
|
|
191174
|
-
if (
|
|
191175
|
-
const isDeclare = node.modifiers?.some((m) => m.kind ===
|
|
191238
|
+
if (import_typescript9.default.isVariableStatement(node)) {
|
|
191239
|
+
const isDeclare = node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.DeclareKeyword) ?? false;
|
|
191176
191240
|
if (!isDeclare)
|
|
191177
191241
|
return;
|
|
191178
191242
|
for (const decl of node.declarationList.declarations) {
|
|
191179
|
-
if (
|
|
191243
|
+
if (import_typescript9.default.isIdentifier(decl.name))
|
|
191180
191244
|
ctx.ambientGlobals.add(decl.name.text);
|
|
191181
191245
|
}
|
|
191182
191246
|
return;
|
|
191183
191247
|
}
|
|
191184
|
-
if (
|
|
191185
|
-
const isDeclare = node.modifiers?.some((m) => m.kind ===
|
|
191248
|
+
if (import_typescript9.default.isFunctionDeclaration(node) && node.name) {
|
|
191249
|
+
const isDeclare = node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.DeclareKeyword) ?? false;
|
|
191186
191250
|
if (isDeclare)
|
|
191187
191251
|
ctx.ambientGlobals.add(node.name.text);
|
|
191188
191252
|
return;
|
|
191189
191253
|
}
|
|
191190
|
-
if (
|
|
191191
|
-
const isGlobalAugmentation = (node.flags &
|
|
191254
|
+
if (import_typescript9.default.isModuleDeclaration(node)) {
|
|
191255
|
+
const isGlobalAugmentation = (node.flags & import_typescript9.default.NodeFlags.GlobalAugmentation) !== 0;
|
|
191192
191256
|
if (!isGlobalAugmentation)
|
|
191193
191257
|
return;
|
|
191194
|
-
if (!node.body || !
|
|
191258
|
+
if (!node.body || !import_typescript9.default.isModuleBlock(node.body))
|
|
191195
191259
|
return;
|
|
191196
191260
|
for (const inner of node.body.statements) {
|
|
191197
|
-
if (
|
|
191261
|
+
if (import_typescript9.default.isVariableStatement(inner)) {
|
|
191198
191262
|
for (const decl of inner.declarationList.declarations) {
|
|
191199
|
-
if (
|
|
191263
|
+
if (import_typescript9.default.isIdentifier(decl.name))
|
|
191200
191264
|
ctx.ambientGlobals.add(decl.name.text);
|
|
191201
191265
|
}
|
|
191202
|
-
} else if (
|
|
191266
|
+
} else if (import_typescript9.default.isFunctionDeclaration(inner) && inner.name) {
|
|
191203
191267
|
ctx.ambientGlobals.add(inner.name.text);
|
|
191204
191268
|
}
|
|
191205
191269
|
}
|
|
@@ -191210,7 +191274,7 @@ function collectImport(node, ctx) {
|
|
|
191210
191274
|
const specifiers = [];
|
|
191211
191275
|
const isTypeOnly = !!node.importClause?.isTypeOnly;
|
|
191212
191276
|
const loc = getSourceLocation(node, ctx.sourceFile, ctx.filePath);
|
|
191213
|
-
if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings &&
|
|
191277
|
+
if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings && import_typescript9.default.isNamedImports(node.importClause.namedBindings)) {
|
|
191214
191278
|
const wrongImports = [];
|
|
191215
191279
|
for (const element of node.importClause.namedBindings.elements) {
|
|
191216
191280
|
const name = element.propertyName?.text ?? element.name.text;
|
|
@@ -191238,7 +191302,7 @@ function collectImport(node, ctx) {
|
|
|
191238
191302
|
});
|
|
191239
191303
|
}
|
|
191240
191304
|
if (node.importClause.namedBindings) {
|
|
191241
|
-
if (
|
|
191305
|
+
if (import_typescript9.default.isNamedImports(node.importClause.namedBindings)) {
|
|
191242
191306
|
for (const element of node.importClause.namedBindings.elements) {
|
|
191243
191307
|
specifiers.push({
|
|
191244
191308
|
name: element.propertyName?.text ?? element.name.text,
|
|
@@ -191249,7 +191313,7 @@ function collectImport(node, ctx) {
|
|
|
191249
191313
|
});
|
|
191250
191314
|
}
|
|
191251
191315
|
}
|
|
191252
|
-
if (
|
|
191316
|
+
if (import_typescript9.default.isNamespaceImport(node.importClause.namedBindings)) {
|
|
191253
191317
|
specifiers.push({
|
|
191254
191318
|
name: node.importClause.namedBindings.name.text,
|
|
191255
191319
|
alias: null,
|
|
@@ -191276,7 +191340,7 @@ function collectInterfaceDefinition(node, ctx) {
|
|
|
191276
191340
|
});
|
|
191277
191341
|
}
|
|
191278
191342
|
function collectTypeAliasDefinition(node, ctx) {
|
|
191279
|
-
const properties =
|
|
191343
|
+
const properties = import_typescript9.default.isTypeLiteralNode(node.type) ? membersToProperties(node.type.members, ctx.sourceFile) : undefined;
|
|
191280
191344
|
ctx.typeDefinitions.push({
|
|
191281
191345
|
kind: "type",
|
|
191282
191346
|
name: node.name.text,
|
|
@@ -191289,20 +191353,20 @@ function extractSingleJsxReturn(body) {
|
|
|
191289
191353
|
let jsxReturn = null;
|
|
191290
191354
|
let returnCount = 0;
|
|
191291
191355
|
function visit2(node) {
|
|
191292
|
-
if (
|
|
191356
|
+
if (import_typescript9.default.isFunctionDeclaration(node) || import_typescript9.default.isFunctionExpression(node) || import_typescript9.default.isArrowFunction(node))
|
|
191293
191357
|
return;
|
|
191294
|
-
if (
|
|
191358
|
+
if (import_typescript9.default.isReturnStatement(node)) {
|
|
191295
191359
|
returnCount++;
|
|
191296
191360
|
if (node.expression) {
|
|
191297
191361
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191298
|
-
if (
|
|
191362
|
+
if (import_typescript9.default.isJsxElement(expr) || import_typescript9.default.isJsxSelfClosingElement(expr) || import_typescript9.default.isJsxFragment(expr)) {
|
|
191299
191363
|
jsxReturn = expr;
|
|
191300
191364
|
}
|
|
191301
191365
|
}
|
|
191302
191366
|
}
|
|
191303
|
-
|
|
191367
|
+
import_typescript9.default.forEachChild(node, visit2);
|
|
191304
191368
|
}
|
|
191305
|
-
|
|
191369
|
+
import_typescript9.default.forEachChild(body, visit2);
|
|
191306
191370
|
if (returnCount !== 1)
|
|
191307
191371
|
return null;
|
|
191308
191372
|
return jsxReturn;
|
|
@@ -191319,9 +191383,9 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191319
191383
|
const stmts = body.statements;
|
|
191320
191384
|
for (let i2 = 0;i2 < stmts.length; i2++) {
|
|
191321
191385
|
const stmt = stmts[i2];
|
|
191322
|
-
if (
|
|
191386
|
+
if (import_typescript9.default.isIfStatement(stmt)) {
|
|
191323
191387
|
let current = stmt;
|
|
191324
|
-
while (
|
|
191388
|
+
while (import_typescript9.default.isIfStatement(current)) {
|
|
191325
191389
|
const ifStmt = current;
|
|
191326
191390
|
if (!isDirectReturnBlock(ifStmt.thenStatement))
|
|
191327
191391
|
return null;
|
|
@@ -191331,7 +191395,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191331
191395
|
return null;
|
|
191332
191396
|
branches.push({ condition: ifStmt.expression, jsxReturn: jsxReturn ?? null });
|
|
191333
191397
|
if (ifStmt.elseStatement) {
|
|
191334
|
-
if (
|
|
191398
|
+
if (import_typescript9.default.isIfStatement(ifStmt.elseStatement)) {
|
|
191335
191399
|
current = ifStmt.elseStatement;
|
|
191336
191400
|
continue;
|
|
191337
191401
|
}
|
|
@@ -191353,18 +191417,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191353
191417
|
}
|
|
191354
191418
|
continue;
|
|
191355
191419
|
}
|
|
191356
|
-
if (
|
|
191420
|
+
if (import_typescript9.default.isSwitchStatement(stmt)) {
|
|
191357
191421
|
if (branches.length > 0)
|
|
191358
191422
|
return null;
|
|
191359
|
-
if (!
|
|
191423
|
+
if (!import_typescript9.default.isIdentifier(stmt.expression) && !import_typescript9.default.isPropertyAccessExpression(stmt.expression)) {
|
|
191360
191424
|
return null;
|
|
191361
191425
|
}
|
|
191362
|
-
const hasDefault = stmt.caseBlock.clauses.some((c) =>
|
|
191426
|
+
const hasDefault = stmt.caseBlock.clauses.some((c) => import_typescript9.default.isDefaultClause(c));
|
|
191363
191427
|
if (!hasDefault)
|
|
191364
191428
|
return null;
|
|
191365
191429
|
let pendingCases = [];
|
|
191366
191430
|
for (const clause of stmt.caseBlock.clauses) {
|
|
191367
|
-
if (
|
|
191431
|
+
if (import_typescript9.default.isCaseClause(clause) && clause.statements.length === 0) {
|
|
191368
191432
|
pendingCases.push(clause.expression);
|
|
191369
191433
|
continue;
|
|
191370
191434
|
}
|
|
@@ -191374,7 +191438,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191374
191438
|
return null;
|
|
191375
191439
|
if (!caseClauseIsDirectReturn(clause))
|
|
191376
191440
|
return null;
|
|
191377
|
-
if (
|
|
191441
|
+
if (import_typescript9.default.isCaseClause(clause)) {
|
|
191378
191442
|
branches.push({
|
|
191379
191443
|
condition: clause.expression,
|
|
191380
191444
|
jsxReturn: jsxReturn ?? null,
|
|
@@ -191395,18 +191459,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191395
191459
|
return null;
|
|
191396
191460
|
return { branches, fallback, switchDiscriminant: stmt.expression, preamble };
|
|
191397
191461
|
}
|
|
191398
|
-
if (
|
|
191462
|
+
if (import_typescript9.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191399
191463
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191400
|
-
if (
|
|
191464
|
+
if (import_typescript9.default.isJsxElement(expr) || import_typescript9.default.isJsxSelfClosingElement(expr) || import_typescript9.default.isJsxFragment(expr)) {
|
|
191401
191465
|
fallback = expr;
|
|
191402
|
-
} else if (expr.kind ===
|
|
191466
|
+
} else if (expr.kind === import_typescript9.default.SyntaxKind.NullKeyword) {} else {
|
|
191403
191467
|
return null;
|
|
191404
191468
|
}
|
|
191405
191469
|
continue;
|
|
191406
191470
|
}
|
|
191407
|
-
if (
|
|
191471
|
+
if (import_typescript9.default.isVariableStatement(stmt)) {
|
|
191408
191472
|
const declFlags = stmt.declarationList.flags;
|
|
191409
|
-
const isConstOrLet = (declFlags &
|
|
191473
|
+
const isConstOrLet = (declFlags & import_typescript9.default.NodeFlags.Const) !== 0 || (declFlags & import_typescript9.default.NodeFlags.Let) !== 0;
|
|
191410
191474
|
if (allowPreamble && isConstOrLet && branches.length === 0 && fallback === null) {
|
|
191411
191475
|
preamble.push(stmt);
|
|
191412
191476
|
continue;
|
|
@@ -191422,12 +191486,12 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191422
191486
|
return { branches, fallback, preamble };
|
|
191423
191487
|
}
|
|
191424
191488
|
function isDirectReturnBlock(node) {
|
|
191425
|
-
if (
|
|
191489
|
+
if (import_typescript9.default.isReturnStatement(node))
|
|
191426
191490
|
return true;
|
|
191427
|
-
if (
|
|
191491
|
+
if (import_typescript9.default.isBlock(node)) {
|
|
191428
191492
|
let returnCount = 0;
|
|
191429
191493
|
for (const stmt of node.statements) {
|
|
191430
|
-
if (
|
|
191494
|
+
if (import_typescript9.default.isReturnStatement(stmt)) {
|
|
191431
191495
|
returnCount++;
|
|
191432
191496
|
continue;
|
|
191433
191497
|
}
|
|
@@ -191438,25 +191502,25 @@ function isDirectReturnBlock(node) {
|
|
|
191438
191502
|
return false;
|
|
191439
191503
|
}
|
|
191440
191504
|
function findNullReturnInBlock(node) {
|
|
191441
|
-
if (
|
|
191505
|
+
if (import_typescript9.default.isBlock(node)) {
|
|
191442
191506
|
for (const stmt of node.statements) {
|
|
191443
|
-
if (
|
|
191507
|
+
if (import_typescript9.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191444
191508
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191445
|
-
if (expr.kind ===
|
|
191509
|
+
if (expr.kind === import_typescript9.default.SyntaxKind.NullKeyword)
|
|
191446
191510
|
return true;
|
|
191447
191511
|
}
|
|
191448
191512
|
}
|
|
191449
191513
|
}
|
|
191450
|
-
if (
|
|
191514
|
+
if (import_typescript9.default.isReturnStatement(node) && node.expression) {
|
|
191451
191515
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191452
|
-
if (expr.kind ===
|
|
191516
|
+
if (expr.kind === import_typescript9.default.SyntaxKind.NullKeyword)
|
|
191453
191517
|
return true;
|
|
191454
191518
|
}
|
|
191455
191519
|
return false;
|
|
191456
191520
|
}
|
|
191457
191521
|
function findJsxReturnInCaseClause(clause) {
|
|
191458
191522
|
for (const stmt of clause.statements) {
|
|
191459
|
-
if (
|
|
191523
|
+
if (import_typescript9.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191460
191524
|
return extractJsxFromExpression(stmt.expression);
|
|
191461
191525
|
}
|
|
191462
191526
|
}
|
|
@@ -191466,12 +191530,12 @@ function caseClauseIsDirectReturn(clause) {
|
|
|
191466
191530
|
let returnCount = 0;
|
|
191467
191531
|
let seenReturn = false;
|
|
191468
191532
|
for (const stmt of clause.statements) {
|
|
191469
|
-
if (
|
|
191533
|
+
if (import_typescript9.default.isReturnStatement(stmt)) {
|
|
191470
191534
|
returnCount++;
|
|
191471
191535
|
seenReturn = true;
|
|
191472
191536
|
continue;
|
|
191473
191537
|
}
|
|
191474
|
-
if (
|
|
191538
|
+
if (import_typescript9.default.isBreakStatement(stmt)) {
|
|
191475
191539
|
if (!seenReturn)
|
|
191476
191540
|
return false;
|
|
191477
191541
|
continue;
|
|
@@ -191482,9 +191546,9 @@ function caseClauseIsDirectReturn(clause) {
|
|
|
191482
191546
|
}
|
|
191483
191547
|
function findNullReturnInCaseClause(clause) {
|
|
191484
191548
|
for (const stmt of clause.statements) {
|
|
191485
|
-
if (
|
|
191549
|
+
if (import_typescript9.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191486
191550
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191487
|
-
if (expr.kind ===
|
|
191551
|
+
if (expr.kind === import_typescript9.default.SyntaxKind.NullKeyword)
|
|
191488
191552
|
return true;
|
|
191489
191553
|
}
|
|
191490
191554
|
}
|
|
@@ -191495,26 +191559,26 @@ function isMultiReturnJsxFunctionBody(body) {
|
|
|
191495
191559
|
let hasJsxReturn = false;
|
|
191496
191560
|
let allReturnsAreJsxOrNull = true;
|
|
191497
191561
|
function visit2(node) {
|
|
191498
|
-
if (
|
|
191562
|
+
if (import_typescript9.default.isFunctionDeclaration(node) || import_typescript9.default.isFunctionExpression(node) || import_typescript9.default.isArrowFunction(node))
|
|
191499
191563
|
return;
|
|
191500
|
-
if (
|
|
191564
|
+
if (import_typescript9.default.isReturnStatement(node)) {
|
|
191501
191565
|
returnCount++;
|
|
191502
191566
|
if (!node.expression) {
|
|
191503
191567
|
allReturnsAreJsxOrNull = false;
|
|
191504
191568
|
return;
|
|
191505
191569
|
}
|
|
191506
191570
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191507
|
-
const isJsx =
|
|
191508
|
-
const isNull2 = expr.kind ===
|
|
191571
|
+
const isJsx = import_typescript9.default.isJsxElement(expr) || import_typescript9.default.isJsxSelfClosingElement(expr) || import_typescript9.default.isJsxFragment(expr);
|
|
191572
|
+
const isNull2 = expr.kind === import_typescript9.default.SyntaxKind.NullKeyword;
|
|
191509
191573
|
if (isJsx)
|
|
191510
191574
|
hasJsxReturn = true;
|
|
191511
191575
|
if (!isJsx && !isNull2)
|
|
191512
191576
|
allReturnsAreJsxOrNull = false;
|
|
191513
191577
|
return;
|
|
191514
191578
|
}
|
|
191515
|
-
|
|
191579
|
+
import_typescript9.default.forEachChild(node, visit2);
|
|
191516
191580
|
}
|
|
191517
|
-
|
|
191581
|
+
import_typescript9.default.forEachChild(body, visit2);
|
|
191518
191582
|
return returnCount > 1 && hasJsxReturn && allReturnsAreJsxOrNull;
|
|
191519
191583
|
}
|
|
191520
191584
|
function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
@@ -191584,7 +191648,7 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
|
191584
191648
|
}
|
|
191585
191649
|
}
|
|
191586
191650
|
}
|
|
191587
|
-
const isAsync = node.modifiers?.some((m) => m.kind ===
|
|
191651
|
+
const isAsync = node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.AsyncKeyword) ?? false;
|
|
191588
191652
|
const isGenerator = !!node.asteriskToken;
|
|
191589
191653
|
ctx.localFunctions.push({
|
|
191590
191654
|
name,
|
|
@@ -191605,10 +191669,10 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
|
191605
191669
|
});
|
|
191606
191670
|
}
|
|
191607
191671
|
function extractValueBranches(node, ctx) {
|
|
191608
|
-
if (
|
|
191672
|
+
if (import_typescript9.default.isParenthesizedExpression(node)) {
|
|
191609
191673
|
return extractValueBranches(node.expression, ctx);
|
|
191610
191674
|
}
|
|
191611
|
-
if (
|
|
191675
|
+
if (import_typescript9.default.isConditionalExpression(node)) {
|
|
191612
191676
|
return [
|
|
191613
191677
|
...extractValueBranches(node.whenTrue, ctx),
|
|
191614
191678
|
...extractValueBranches(node.whenFalse, ctx)
|
|
@@ -191620,46 +191684,46 @@ function extractFreeIdentifiersFromNode(node) {
|
|
|
191620
191684
|
const ids = new Set;
|
|
191621
191685
|
const boundNames = new Set;
|
|
191622
191686
|
function addBindingNames(name, out) {
|
|
191623
|
-
if (
|
|
191687
|
+
if (import_typescript9.default.isIdentifier(name))
|
|
191624
191688
|
out.push(name.text);
|
|
191625
|
-
else if (
|
|
191689
|
+
else if (import_typescript9.default.isObjectBindingPattern(name))
|
|
191626
191690
|
name.elements.forEach((e) => addBindingNames(e.name, out));
|
|
191627
|
-
else if (
|
|
191691
|
+
else if (import_typescript9.default.isArrayBindingPattern(name))
|
|
191628
191692
|
name.elements.forEach((e) => {
|
|
191629
|
-
if (!
|
|
191693
|
+
if (!import_typescript9.default.isOmittedExpression(e))
|
|
191630
191694
|
addBindingNames(e.name, out);
|
|
191631
191695
|
});
|
|
191632
191696
|
}
|
|
191633
191697
|
function visit2(n) {
|
|
191634
|
-
if (
|
|
191698
|
+
if (import_typescript9.default.isTypeNode(n))
|
|
191635
191699
|
return;
|
|
191636
|
-
if (
|
|
191700
|
+
if (import_typescript9.default.isIdentifier(n)) {
|
|
191637
191701
|
const parent = n.parent;
|
|
191638
|
-
if (parent &&
|
|
191702
|
+
if (parent && import_typescript9.default.isPropertyAccessExpression(parent) && parent.name === n)
|
|
191639
191703
|
return;
|
|
191640
|
-
if (parent &&
|
|
191704
|
+
if (parent && import_typescript9.default.isPropertyAssignment(parent) && parent.name === n)
|
|
191641
191705
|
return;
|
|
191642
|
-
if (parent &&
|
|
191706
|
+
if (parent && import_typescript9.default.isParameter(parent) && parent.name === n)
|
|
191643
191707
|
return;
|
|
191644
|
-
if (parent &&
|
|
191708
|
+
if (parent && import_typescript9.default.isVariableDeclaration(parent) && parent.name === n)
|
|
191645
191709
|
return;
|
|
191646
191710
|
if (boundNames.has(n.text))
|
|
191647
191711
|
return;
|
|
191648
191712
|
ids.add(n.text);
|
|
191649
191713
|
return;
|
|
191650
191714
|
}
|
|
191651
|
-
if (
|
|
191715
|
+
if (import_typescript9.default.isArrowFunction(n)) {
|
|
191652
191716
|
const params = [];
|
|
191653
191717
|
for (const p of n.parameters)
|
|
191654
191718
|
addBindingNames(p.name, params);
|
|
191655
191719
|
for (const name of params)
|
|
191656
191720
|
boundNames.add(name);
|
|
191657
|
-
|
|
191721
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191658
191722
|
for (const name of params)
|
|
191659
191723
|
boundNames.delete(name);
|
|
191660
191724
|
return;
|
|
191661
191725
|
}
|
|
191662
|
-
|
|
191726
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191663
191727
|
}
|
|
191664
191728
|
visit2(node);
|
|
191665
191729
|
return ids;
|
|
@@ -191668,29 +191732,29 @@ function extractFreeTypeIdentifiersFromNode(node) {
|
|
|
191668
191732
|
const ids = new Set;
|
|
191669
191733
|
const boundTypeParams = new Set;
|
|
191670
191734
|
function rootName(name) {
|
|
191671
|
-
return
|
|
191735
|
+
return import_typescript9.default.isQualifiedName(name) ? rootName(name.left) : name;
|
|
191672
191736
|
}
|
|
191673
191737
|
function visit2(n) {
|
|
191674
|
-
if (
|
|
191738
|
+
if (import_typescript9.default.isTypeReferenceNode(n)) {
|
|
191675
191739
|
const name = rootName(n.typeName).text;
|
|
191676
191740
|
if (!boundTypeParams.has(name))
|
|
191677
191741
|
ids.add(name);
|
|
191678
191742
|
}
|
|
191679
|
-
if (
|
|
191743
|
+
if (import_typescript9.default.isTypeQueryNode(n)) {
|
|
191680
191744
|
const name = rootName(n.exprName).text;
|
|
191681
191745
|
if (!boundTypeParams.has(name))
|
|
191682
191746
|
ids.add(name);
|
|
191683
191747
|
}
|
|
191684
|
-
if (
|
|
191748
|
+
if (import_typescript9.default.isFunctionLike(n) && n.typeParameters && n.typeParameters.length > 0) {
|
|
191685
191749
|
const names = n.typeParameters.map((p) => p.name.text);
|
|
191686
191750
|
for (const p of names)
|
|
191687
191751
|
boundTypeParams.add(p);
|
|
191688
|
-
|
|
191752
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191689
191753
|
for (const p of names)
|
|
191690
191754
|
boundTypeParams.delete(p);
|
|
191691
191755
|
return;
|
|
191692
191756
|
}
|
|
191693
|
-
|
|
191757
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191694
191758
|
}
|
|
191695
191759
|
visit2(node);
|
|
191696
191760
|
return ids;
|
|
@@ -191700,22 +191764,22 @@ function initializerShapeContainsJsx(node) {
|
|
|
191700
191764
|
function visit2(n) {
|
|
191701
191765
|
if (found)
|
|
191702
191766
|
return;
|
|
191703
|
-
if (
|
|
191767
|
+
if (import_typescript9.default.isJsxElement(n) || import_typescript9.default.isJsxSelfClosingElement(n) || import_typescript9.default.isJsxFragment(n)) {
|
|
191704
191768
|
found = true;
|
|
191705
191769
|
return;
|
|
191706
191770
|
}
|
|
191707
|
-
if (
|
|
191771
|
+
if (import_typescript9.default.isFunctionDeclaration(n) || import_typescript9.default.isFunctionExpression(n) || import_typescript9.default.isArrowFunction(n)) {
|
|
191708
191772
|
return;
|
|
191709
191773
|
}
|
|
191710
|
-
|
|
191774
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191711
191775
|
}
|
|
191712
191776
|
visit2(node);
|
|
191713
191777
|
return found;
|
|
191714
191778
|
}
|
|
191715
191779
|
function isMapLikeCallWithJsx(node) {
|
|
191716
|
-
if (!
|
|
191780
|
+
if (!import_typescript9.default.isCallExpression(node))
|
|
191717
191781
|
return false;
|
|
191718
|
-
if (!
|
|
191782
|
+
if (!import_typescript9.default.isPropertyAccessExpression(node.expression))
|
|
191719
191783
|
return false;
|
|
191720
191784
|
const method = node.expression.name.text;
|
|
191721
191785
|
if (method !== "map" && method !== "flatMap")
|
|
@@ -191723,12 +191787,12 @@ function isMapLikeCallWithJsx(node) {
|
|
|
191723
191787
|
const callback = node.arguments[0];
|
|
191724
191788
|
if (!callback)
|
|
191725
191789
|
return false;
|
|
191726
|
-
if (!
|
|
191790
|
+
if (!import_typescript9.default.isArrowFunction(callback) && !import_typescript9.default.isFunctionExpression(callback))
|
|
191727
191791
|
return false;
|
|
191728
191792
|
return containsJsxDeep(callback.body);
|
|
191729
191793
|
}
|
|
191730
191794
|
function containsJsxDeep(node) {
|
|
191731
|
-
if (
|
|
191795
|
+
if (import_typescript9.default.isJsxElement(node) || import_typescript9.default.isJsxSelfClosingElement(node) || import_typescript9.default.isJsxFragment(node))
|
|
191732
191796
|
return true;
|
|
191733
191797
|
let found = false;
|
|
191734
191798
|
node.forEachChild((child) => {
|
|
@@ -191742,11 +191806,11 @@ function nodeContainsArrow(node) {
|
|
|
191742
191806
|
function visit2(n) {
|
|
191743
191807
|
if (found)
|
|
191744
191808
|
return;
|
|
191745
|
-
if (
|
|
191809
|
+
if (import_typescript9.default.isArrowFunction(n) || import_typescript9.default.isFunctionExpression(n)) {
|
|
191746
191810
|
found = true;
|
|
191747
191811
|
return;
|
|
191748
191812
|
}
|
|
191749
|
-
|
|
191813
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191750
191814
|
}
|
|
191751
191815
|
visit2(node);
|
|
191752
191816
|
return found;
|
|
@@ -191794,20 +191858,20 @@ function collectModuleScopeReactive(decl, ctx, isExported) {
|
|
|
191794
191858
|
}));
|
|
191795
191859
|
}
|
|
191796
191860
|
function getSystemConstructKind(node) {
|
|
191797
|
-
if (
|
|
191861
|
+
if (import_typescript9.default.isCallExpression(node) && import_typescript9.default.isIdentifier(node.expression) && node.expression.text === "createContext")
|
|
191798
191862
|
return "createContext";
|
|
191799
|
-
if (
|
|
191863
|
+
if (import_typescript9.default.isNewExpression(node) && import_typescript9.default.isIdentifier(node.expression) && node.expression.text === "WeakMap")
|
|
191800
191864
|
return "weakMap";
|
|
191801
191865
|
return;
|
|
191802
191866
|
}
|
|
191803
191867
|
function collectConstant(node, ctx, _isModule, declarationKind = "const", isExported = false) {
|
|
191804
|
-
if (!_isModule &&
|
|
191868
|
+
if (!_isModule && import_typescript9.default.isObjectBindingPattern(node.name) && node.initializer && import_typescript9.default.isIdentifier(node.initializer) && ctx.propsObjectName === node.initializer.text) {
|
|
191805
191869
|
const propsName = node.initializer.text;
|
|
191806
191870
|
for (const el of node.name.elements) {
|
|
191807
|
-
if (!
|
|
191871
|
+
if (!import_typescript9.default.isBindingElement(el) || !import_typescript9.default.isIdentifier(el.name) || el.dotDotDotToken)
|
|
191808
191872
|
continue;
|
|
191809
191873
|
const localName = el.name.text;
|
|
191810
|
-
const sourceKey = el.propertyName &&
|
|
191874
|
+
const sourceKey = el.propertyName && import_typescript9.default.isIdentifier(el.propertyName) ? el.propertyName.text : localName;
|
|
191811
191875
|
const defaultValueExpr = el.initializer ? ctx.getJS(el.initializer) : undefined;
|
|
191812
191876
|
const baseValue = `${propsName}.${sourceKey}`;
|
|
191813
191877
|
const value2 = defaultValueExpr ? `${baseValue} ?? ${defaultValueExpr}` : baseValue;
|
|
@@ -191827,7 +191891,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191827
191891
|
}
|
|
191828
191892
|
return;
|
|
191829
191893
|
}
|
|
191830
|
-
if (!
|
|
191894
|
+
if (!import_typescript9.default.isIdentifier(node.name))
|
|
191831
191895
|
return;
|
|
191832
191896
|
if (isSignalDeclaration(node, ctx) || isMemoDeclaration(node, ctx))
|
|
191833
191897
|
return;
|
|
@@ -191845,9 +191909,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191845
191909
|
let isJsxFunction = false;
|
|
191846
191910
|
if (node.initializer) {
|
|
191847
191911
|
let init = node.initializer;
|
|
191848
|
-
while (
|
|
191912
|
+
while (import_typescript9.default.isParenthesizedExpression(init))
|
|
191849
191913
|
init = init.expression;
|
|
191850
|
-
if (
|
|
191914
|
+
if (import_typescript9.default.isJsxElement(init) || import_typescript9.default.isJsxSelfClosingElement(init) || import_typescript9.default.isJsxFragment(init)) {
|
|
191851
191915
|
isJsx = true;
|
|
191852
191916
|
ctx.jsxConstants.set(name, init);
|
|
191853
191917
|
} else if (initializerShapeContainsJsx(init)) {
|
|
@@ -191855,9 +191919,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191855
191919
|
} else if (isMapLikeCallWithJsx(init)) {
|
|
191856
191920
|
ctx.inlineableJsxConsts.set(name, init);
|
|
191857
191921
|
}
|
|
191858
|
-
if (
|
|
191922
|
+
if (import_typescript9.default.isArrowFunction(init)) {
|
|
191859
191923
|
const arrowBody = init.body;
|
|
191860
|
-
if (
|
|
191924
|
+
if (import_typescript9.default.isBlock(arrowBody)) {
|
|
191861
191925
|
const jsxReturn = extractSingleJsxReturn(arrowBody);
|
|
191862
191926
|
if (jsxReturn) {
|
|
191863
191927
|
isJsxFunction = true;
|
|
@@ -191877,9 +191941,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191877
191941
|
}
|
|
191878
191942
|
} else {
|
|
191879
191943
|
let body = arrowBody;
|
|
191880
|
-
while (
|
|
191944
|
+
while (import_typescript9.default.isParenthesizedExpression(body))
|
|
191881
191945
|
body = body.expression;
|
|
191882
|
-
if (
|
|
191946
|
+
if (import_typescript9.default.isJsxElement(body) || import_typescript9.default.isJsxSelfClosingElement(body) || import_typescript9.default.isJsxFragment(body)) {
|
|
191883
191947
|
isJsxFunction = true;
|
|
191884
191948
|
ctx.jsxFunctions.set(name, {
|
|
191885
191949
|
jsxReturn: body,
|
|
@@ -191892,9 +191956,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191892
191956
|
let valueBranches;
|
|
191893
191957
|
if (node.initializer) {
|
|
191894
191958
|
let inner = node.initializer;
|
|
191895
|
-
while (
|
|
191959
|
+
while (import_typescript9.default.isParenthesizedExpression(inner))
|
|
191896
191960
|
inner = inner.expression;
|
|
191897
|
-
if (
|
|
191961
|
+
if (import_typescript9.default.isConditionalExpression(inner)) {
|
|
191898
191962
|
valueBranches = extractValueBranches(node.initializer, ctx);
|
|
191899
191963
|
}
|
|
191900
191964
|
}
|
|
@@ -191910,8 +191974,10 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191910
191974
|
let templateValue;
|
|
191911
191975
|
if (value && ctx.propsParams.length > 0 && node.initializer) {
|
|
191912
191976
|
let propNames;
|
|
191977
|
+
let propAliases;
|
|
191913
191978
|
if (!ctx.propsObjectName) {
|
|
191914
191979
|
propNames = new Set(ctx.propsParams.map((p) => p.name));
|
|
191980
|
+
propAliases = buildPropAliasMap(ctx.propsParams);
|
|
191915
191981
|
} else {
|
|
191916
191982
|
const shadowedByNonAlias = new Set;
|
|
191917
191983
|
for (const s of ctx.signals) {
|
|
@@ -191932,7 +191998,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191932
191998
|
propNames = new Set([...aliases].filter((n) => !shadowedByNonAlias.has(n)));
|
|
191933
191999
|
}
|
|
191934
192000
|
if (propNames.size > 0) {
|
|
191935
|
-
const rewritten = rewriteBarePropRefs(value, node.initializer, propNames);
|
|
192001
|
+
const rewritten = rewriteBarePropRefs(value, node.initializer, propNames, undefined, propAliases);
|
|
191936
192002
|
if (rewritten !== undefined) {
|
|
191937
192003
|
templateValue = rewritten;
|
|
191938
192004
|
if (ctx.propsObjectName) {
|
|
@@ -191969,7 +192035,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191969
192035
|
function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
191970
192036
|
const checkComments = (targetNode) => {
|
|
191971
192037
|
const fullStart = targetNode.getFullStart();
|
|
191972
|
-
const leadingComments =
|
|
192038
|
+
const leadingComments = import_typescript9.default.getLeadingCommentRanges(sourceFile.getFullText(), fullStart);
|
|
191973
192039
|
if (!leadingComments)
|
|
191974
192040
|
return false;
|
|
191975
192041
|
for (const range of leadingComments) {
|
|
@@ -191982,10 +192048,10 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
|
191982
192048
|
};
|
|
191983
192049
|
if (checkComments(node))
|
|
191984
192050
|
return true;
|
|
191985
|
-
if (
|
|
192051
|
+
if (import_typescript9.default.isArrowFunction(node)) {
|
|
191986
192052
|
let current = node.parent;
|
|
191987
192053
|
while (current) {
|
|
191988
|
-
if (
|
|
192054
|
+
if (import_typescript9.default.isVariableStatement(current)) {
|
|
191989
192055
|
if (checkComments(current))
|
|
191990
192056
|
return true;
|
|
191991
192057
|
break;
|
|
@@ -191996,7 +192062,7 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
|
191996
192062
|
return false;
|
|
191997
192063
|
}
|
|
191998
192064
|
function extractProps(param, ctx) {
|
|
191999
|
-
if (
|
|
192065
|
+
if (import_typescript9.default.isObjectBindingPattern(param.name)) {
|
|
192000
192066
|
const componentNode = ctx.componentNode;
|
|
192001
192067
|
const ignored = !!(componentNode && hasIgnoreDirective(componentNode, ctx.sourceFile, "props-destructuring"));
|
|
192002
192068
|
ctx.propsDestructuring = {
|
|
@@ -192005,22 +192071,24 @@ function extractProps(param, ctx) {
|
|
|
192005
192071
|
};
|
|
192006
192072
|
const memberTypes = param.type ? collectMemberTypes(param.type, ctx) : null;
|
|
192007
192073
|
for (const element of param.name.elements) {
|
|
192008
|
-
if (
|
|
192074
|
+
if (import_typescript9.default.isBindingElement(element) && import_typescript9.default.isIdentifier(element.name)) {
|
|
192009
192075
|
const localName = element.name.text;
|
|
192010
192076
|
const defaultValue = element.initializer ? ctx.getJS(element.initializer) : undefined;
|
|
192011
192077
|
if (element.dotDotDotToken) {
|
|
192012
192078
|
ctx.restPropsName = localName;
|
|
192013
192079
|
continue;
|
|
192014
192080
|
}
|
|
192015
|
-
const sourcePropName = element.propertyName &&
|
|
192081
|
+
const sourcePropName = element.propertyName && import_typescript9.default.isIdentifier(element.propertyName) ? element.propertyName.text : localName;
|
|
192016
192082
|
const member = memberTypes?.get(sourcePropName);
|
|
192017
192083
|
const resolvedType = member?.type ?? { kind: "unknown", raw: "unknown" };
|
|
192018
192084
|
const defaultContainsArrow = element.initializer ? nodeContainsArrow(element.initializer) : false;
|
|
192085
|
+
const parsedDefault = element.initializer ? tsNodeToParsedExpr(element.initializer) : undefined;
|
|
192019
192086
|
ctx.propsParams.push({
|
|
192020
192087
|
name: localName,
|
|
192021
192088
|
type: resolvedType,
|
|
192022
192089
|
optional: !!member?.optional || !!element.initializer,
|
|
192023
192090
|
defaultValue,
|
|
192091
|
+
...parsedDefault && parsedDefault.kind !== "unsupported" && { parsed: parsedDefault },
|
|
192024
192092
|
defaultContainsArrow: defaultContainsArrow || undefined,
|
|
192025
192093
|
...sourcePropName !== localName && { sourceName: sourcePropName }
|
|
192026
192094
|
});
|
|
@@ -192034,7 +192102,7 @@ function extractProps(param, ctx) {
|
|
|
192034
192102
|
}
|
|
192035
192103
|
}
|
|
192036
192104
|
}
|
|
192037
|
-
if (
|
|
192105
|
+
if (import_typescript9.default.isIdentifier(param.name)) {
|
|
192038
192106
|
ctx.propsObjectName = param.name.text;
|
|
192039
192107
|
if (param.type) {
|
|
192040
192108
|
extractPropsFromType(param.type, ctx);
|
|
@@ -192045,24 +192113,24 @@ function extractProps(param, ctx) {
|
|
|
192045
192113
|
}
|
|
192046
192114
|
}
|
|
192047
192115
|
function collectTypeKeys(typeNode, ctx) {
|
|
192048
|
-
if (
|
|
192116
|
+
if (import_typescript9.default.isTypeLiteralNode(typeNode)) {
|
|
192049
192117
|
return collectKeysFromMembers(typeNode.members, ctx);
|
|
192050
192118
|
}
|
|
192051
|
-
if (
|
|
192119
|
+
if (import_typescript9.default.isTypeReferenceNode(typeNode)) {
|
|
192052
192120
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192053
192121
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192054
192122
|
if (!typeDecl)
|
|
192055
192123
|
return null;
|
|
192056
|
-
if (
|
|
192124
|
+
if (import_typescript9.default.isInterfaceDeclaration(typeDecl)) {
|
|
192057
192125
|
if (typeDecl.heritageClauses && typeDecl.heritageClauses.length > 0)
|
|
192058
192126
|
return null;
|
|
192059
192127
|
return collectKeysFromMembers(typeDecl.members, ctx);
|
|
192060
192128
|
}
|
|
192061
|
-
if (
|
|
192062
|
-
if (
|
|
192129
|
+
if (import_typescript9.default.isTypeAliasDeclaration(typeDecl)) {
|
|
192130
|
+
if (import_typescript9.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192063
192131
|
return collectKeysFromMembers(typeDecl.type.members, ctx);
|
|
192064
192132
|
}
|
|
192065
|
-
if (
|
|
192133
|
+
if (import_typescript9.default.isIntersectionTypeNode(typeDecl.type)) {
|
|
192066
192134
|
return null;
|
|
192067
192135
|
}
|
|
192068
192136
|
}
|
|
@@ -192072,9 +192140,9 @@ function collectTypeKeys(typeNode, ctx) {
|
|
|
192072
192140
|
function collectKeysFromMembers(members, ctx) {
|
|
192073
192141
|
const keys = [];
|
|
192074
192142
|
for (const member of members) {
|
|
192075
|
-
if (
|
|
192143
|
+
if (import_typescript9.default.isIndexSignatureDeclaration(member))
|
|
192076
192144
|
return null;
|
|
192077
|
-
if (
|
|
192145
|
+
if (import_typescript9.default.isPropertySignature(member) && member.name) {
|
|
192078
192146
|
keys.push(member.name.getText(ctx.sourceFile));
|
|
192079
192147
|
}
|
|
192080
192148
|
}
|
|
@@ -192085,7 +192153,7 @@ function collectMemberTypes(typeNode, ctx) {
|
|
|
192085
192153
|
const fromMembers = (members) => {
|
|
192086
192154
|
const map = new Map;
|
|
192087
192155
|
for (const member of members) {
|
|
192088
|
-
if (
|
|
192156
|
+
if (import_typescript9.default.isPropertySignature(member) && member.name) {
|
|
192089
192157
|
const info = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : null;
|
|
192090
192158
|
map.set(member.name.getText(ctx.sourceFile), {
|
|
192091
192159
|
type: info && isResolvablePrimitive(info) ? info : null,
|
|
@@ -192095,35 +192163,35 @@ function collectMemberTypes(typeNode, ctx) {
|
|
|
192095
192163
|
}
|
|
192096
192164
|
return map;
|
|
192097
192165
|
};
|
|
192098
|
-
if (
|
|
192166
|
+
if (import_typescript9.default.isTypeLiteralNode(typeNode)) {
|
|
192099
192167
|
return fromMembers(typeNode.members);
|
|
192100
192168
|
}
|
|
192101
|
-
if (
|
|
192169
|
+
if (import_typescript9.default.isTypeReferenceNode(typeNode)) {
|
|
192102
192170
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192103
192171
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192104
192172
|
if (!typeDecl)
|
|
192105
192173
|
return null;
|
|
192106
|
-
if (
|
|
192174
|
+
if (import_typescript9.default.isInterfaceDeclaration(typeDecl)) {
|
|
192107
192175
|
return fromMembers(typeDecl.members);
|
|
192108
192176
|
}
|
|
192109
|
-
if (
|
|
192177
|
+
if (import_typescript9.default.isTypeAliasDeclaration(typeDecl) && import_typescript9.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192110
192178
|
return fromMembers(typeDecl.type.members);
|
|
192111
192179
|
}
|
|
192112
192180
|
}
|
|
192113
192181
|
return null;
|
|
192114
192182
|
}
|
|
192115
192183
|
function extractPropsFromType(typeNode, ctx) {
|
|
192116
|
-
if (
|
|
192184
|
+
if (import_typescript9.default.isTypeLiteralNode(typeNode)) {
|
|
192117
192185
|
extractPropsFromTypeMembers(typeNode.members, ctx);
|
|
192118
192186
|
return;
|
|
192119
192187
|
}
|
|
192120
|
-
if (
|
|
192188
|
+
if (import_typescript9.default.isTypeReferenceNode(typeNode)) {
|
|
192121
192189
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192122
192190
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192123
192191
|
if (typeDecl) {
|
|
192124
|
-
if (
|
|
192192
|
+
if (import_typescript9.default.isInterfaceDeclaration(typeDecl)) {
|
|
192125
192193
|
extractPropsFromTypeMembers(typeDecl.members, ctx);
|
|
192126
|
-
} else if (
|
|
192194
|
+
} else if (import_typescript9.default.isTypeAliasDeclaration(typeDecl) && import_typescript9.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192127
192195
|
extractPropsFromTypeMembers(typeDecl.type.members, ctx);
|
|
192128
192196
|
}
|
|
192129
192197
|
}
|
|
@@ -192131,7 +192199,7 @@ function extractPropsFromType(typeNode, ctx) {
|
|
|
192131
192199
|
}
|
|
192132
192200
|
function extractPropsFromTypeMembers(members, ctx) {
|
|
192133
192201
|
for (const member of members) {
|
|
192134
|
-
if (
|
|
192202
|
+
if (import_typescript9.default.isPropertySignature(member) && member.name) {
|
|
192135
192203
|
const propName = member.name.getText(ctx.sourceFile);
|
|
192136
192204
|
const isOptional = !!member.questionToken;
|
|
192137
192205
|
const propType = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : { kind: "unknown", raw: "unknown" };
|
|
@@ -192147,17 +192215,17 @@ function extractPropsFromTypeMembers(members, ctx) {
|
|
|
192147
192215
|
function findTypeDeclaration(typeName, sourceFile) {
|
|
192148
192216
|
let result;
|
|
192149
192217
|
function visit2(node) {
|
|
192150
|
-
if (
|
|
192218
|
+
if (import_typescript9.default.isInterfaceDeclaration(node) && node.name.text === typeName) {
|
|
192151
192219
|
result = node;
|
|
192152
192220
|
return;
|
|
192153
192221
|
}
|
|
192154
|
-
if (
|
|
192222
|
+
if (import_typescript9.default.isTypeAliasDeclaration(node) && node.name.text === typeName) {
|
|
192155
192223
|
result = node;
|
|
192156
192224
|
return;
|
|
192157
192225
|
}
|
|
192158
|
-
|
|
192226
|
+
import_typescript9.default.forEachChild(node, visit2);
|
|
192159
192227
|
}
|
|
192160
|
-
|
|
192228
|
+
import_typescript9.default.forEachChild(sourceFile, visit2);
|
|
192161
192229
|
return result;
|
|
192162
192230
|
}
|
|
192163
192231
|
function inferTypeFromValue(value) {
|
|
@@ -192201,17 +192269,28 @@ function inferTypeFromValue(value) {
|
|
|
192201
192269
|
}
|
|
192202
192270
|
return { kind: "unknown", raw: "unknown" };
|
|
192203
192271
|
}
|
|
192272
|
+
function collectCalledIdentifiers(code2) {
|
|
192273
|
+
const called = new Set;
|
|
192274
|
+
const sf = import_typescript9.default.createSourceFile("__deps__.tsx", code2, import_typescript9.default.ScriptTarget.Latest, false, import_typescript9.default.ScriptKind.TSX);
|
|
192275
|
+
const visit2 = (node) => {
|
|
192276
|
+
if (import_typescript9.default.isCallExpression(node) && import_typescript9.default.isIdentifier(node.expression)) {
|
|
192277
|
+
called.add(node.expression.text);
|
|
192278
|
+
}
|
|
192279
|
+
import_typescript9.default.forEachChild(node, visit2);
|
|
192280
|
+
};
|
|
192281
|
+
visit2(sf);
|
|
192282
|
+
return called;
|
|
192283
|
+
}
|
|
192204
192284
|
function extractDependencies(code2, ctx) {
|
|
192285
|
+
const called = collectCalledIdentifiers(code2);
|
|
192205
192286
|
const deps = [];
|
|
192206
192287
|
for (const signal of ctx.signals) {
|
|
192207
|
-
|
|
192208
|
-
if (pattern.test(code2)) {
|
|
192288
|
+
if (called.has(signal.getter)) {
|
|
192209
192289
|
deps.push(signal.getter);
|
|
192210
192290
|
}
|
|
192211
192291
|
}
|
|
192212
192292
|
for (const memo of ctx.memos) {
|
|
192213
|
-
|
|
192214
|
-
if (pattern.test(code2)) {
|
|
192293
|
+
if (called.has(memo.name)) {
|
|
192215
192294
|
deps.push(memo.name);
|
|
192216
192295
|
}
|
|
192217
192296
|
}
|
|
@@ -192294,16 +192373,16 @@ function isResolvableComponentSource(source) {
|
|
|
192294
192373
|
function collectJsxComponentTags(sourceFile) {
|
|
192295
192374
|
const tags = new Set;
|
|
192296
192375
|
function visit2(node) {
|
|
192297
|
-
if (
|
|
192376
|
+
if (import_typescript9.default.isJsxOpeningElement(node) || import_typescript9.default.isJsxSelfClosingElement(node)) {
|
|
192298
192377
|
const tagName = node.tagName;
|
|
192299
|
-
if (
|
|
192378
|
+
if (import_typescript9.default.isIdentifier(tagName)) {
|
|
192300
192379
|
const first = tagName.text.charAt(0);
|
|
192301
192380
|
if (first >= "A" && first <= "Z") {
|
|
192302
192381
|
tags.add(tagName.text);
|
|
192303
192382
|
}
|
|
192304
192383
|
}
|
|
192305
192384
|
}
|
|
192306
|
-
|
|
192385
|
+
import_typescript9.default.forEachChild(node, visit2);
|
|
192307
192386
|
}
|
|
192308
192387
|
visit2(sourceFile);
|
|
192309
192388
|
return tags;
|
|
@@ -192382,18 +192461,18 @@ function fileHasUseClientDirective(filePath) {
|
|
|
192382
192461
|
} catch {
|
|
192383
192462
|
return true;
|
|
192384
192463
|
}
|
|
192385
|
-
const sf =
|
|
192464
|
+
const sf = import_typescript9.default.createSourceFile(filePath, content, import_typescript9.default.ScriptTarget.Latest, false, import_typescript9.default.ScriptKind.TSX);
|
|
192386
192465
|
let found = false;
|
|
192387
192466
|
function visit2(node) {
|
|
192388
192467
|
if (found)
|
|
192389
192468
|
return;
|
|
192390
|
-
if (
|
|
192469
|
+
if (import_typescript9.default.isExpressionStatement(node) && import_typescript9.default.isStringLiteral(node.expression)) {
|
|
192391
192470
|
if (node.expression.text === "use client") {
|
|
192392
192471
|
found = true;
|
|
192393
192472
|
return;
|
|
192394
192473
|
}
|
|
192395
192474
|
}
|
|
192396
|
-
|
|
192475
|
+
import_typescript9.default.forEachChild(node, visit2);
|
|
192397
192476
|
}
|
|
192398
192477
|
visit2(sf);
|
|
192399
192478
|
return found;
|
|
@@ -192478,13 +192557,13 @@ var REACTIVE_PRIMITIVES = new Set([
|
|
|
192478
192557
|
"onCleanup"
|
|
192479
192558
|
]);
|
|
192480
192559
|
function prescanReactiveFactoriesInSource(source, filePath) {
|
|
192481
|
-
const sourceFile =
|
|
192560
|
+
const sourceFile = import_typescript9.default.createSourceFile(filePath + ".prescan", source, import_typescript9.default.ScriptTarget.Latest, true, import_typescript9.default.ScriptKind.TSX);
|
|
192482
192561
|
const factories = new Map;
|
|
192483
192562
|
const declined = new Map;
|
|
192484
192563
|
const reactiveShaped = new Set;
|
|
192485
192564
|
const cleanFactoryImports = new Set;
|
|
192486
192565
|
function visitTop(node) {
|
|
192487
|
-
if (
|
|
192566
|
+
if (import_typescript9.default.isFunctionDeclaration(node) && node.name && node.body) {
|
|
192488
192567
|
const det = detectReactiveFactory(node, sourceFile, filePath);
|
|
192489
192568
|
if (!det)
|
|
192490
192569
|
return;
|
|
@@ -192501,7 +192580,7 @@ function prescanReactiveFactoriesInSource(source, filePath) {
|
|
|
192501
192580
|
}
|
|
192502
192581
|
}
|
|
192503
192582
|
}
|
|
192504
|
-
|
|
192583
|
+
import_typescript9.default.forEachChild(sourceFile, visitTop);
|
|
192505
192584
|
const result = { factories, declined, reactiveShaped, cleanFactoryImports, sourceFile };
|
|
192506
192585
|
prescanImportedReactiveFactories(sourceFile, filePath, result);
|
|
192507
192586
|
return result;
|
|
@@ -192518,15 +192597,15 @@ function toComponentRelativeSpecifier(resolvedAbs, componentFilePath) {
|
|
|
192518
192597
|
function buildEntryImportIndex(sf, filePath) {
|
|
192519
192598
|
const index = new Map;
|
|
192520
192599
|
for (const stmt of sf.statements) {
|
|
192521
|
-
if (!
|
|
192600
|
+
if (!import_typescript9.default.isImportDeclaration(stmt))
|
|
192522
192601
|
continue;
|
|
192523
|
-
if (!
|
|
192602
|
+
if (!import_typescript9.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192524
192603
|
continue;
|
|
192525
192604
|
const src = stmt.moduleSpecifier.text;
|
|
192526
192605
|
const targetKey = src.startsWith("./") || src.startsWith("../") ? resolveRelativeImportToFile(src, filePath) ?? "unresolved:" + src : src;
|
|
192527
192606
|
const wholeTypeOnly = stmt.importClause?.isTypeOnly === true;
|
|
192528
192607
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
192529
|
-
if (namedBindings &&
|
|
192608
|
+
if (namedBindings && import_typescript9.default.isNamedImports(namedBindings)) {
|
|
192530
192609
|
for (const el of namedBindings.elements) {
|
|
192531
192610
|
index.set(el.name.text, {
|
|
192532
192611
|
targetKey,
|
|
@@ -192541,31 +192620,31 @@ function buildEntryImportIndex(sf, filePath) {
|
|
|
192541
192620
|
function collectEntryBindingNames(sf) {
|
|
192542
192621
|
const names = new Set;
|
|
192543
192622
|
function visit2(node) {
|
|
192544
|
-
if (
|
|
192623
|
+
if (import_typescript9.default.isImportDeclaration(node) && node.importClause) {
|
|
192545
192624
|
if (node.importClause.name)
|
|
192546
192625
|
names.add(node.importClause.name.text);
|
|
192547
192626
|
const namedBindings = node.importClause.namedBindings;
|
|
192548
|
-
if (namedBindings &&
|
|
192627
|
+
if (namedBindings && import_typescript9.default.isNamedImports(namedBindings)) {
|
|
192549
192628
|
for (const el of namedBindings.elements)
|
|
192550
192629
|
names.add(el.name.text);
|
|
192551
192630
|
}
|
|
192552
|
-
if (namedBindings &&
|
|
192631
|
+
if (namedBindings && import_typescript9.default.isNamespaceImport(namedBindings)) {
|
|
192553
192632
|
names.add(namedBindings.name.text);
|
|
192554
192633
|
}
|
|
192555
192634
|
}
|
|
192556
|
-
if (
|
|
192635
|
+
if (import_typescript9.default.isVariableDeclaration(node)) {
|
|
192557
192636
|
const out = [];
|
|
192558
192637
|
addBindingNames(node.name, out);
|
|
192559
192638
|
for (const n of out)
|
|
192560
192639
|
names.add(n);
|
|
192561
192640
|
}
|
|
192562
|
-
if ((
|
|
192641
|
+
if ((import_typescript9.default.isFunctionDeclaration(node) || import_typescript9.default.isClassDeclaration(node) || import_typescript9.default.isEnumDeclaration(node)) && node.name) {
|
|
192563
192642
|
names.add(node.name.text);
|
|
192564
192643
|
}
|
|
192565
|
-
if ((
|
|
192644
|
+
if ((import_typescript9.default.isTypeAliasDeclaration(node) || import_typescript9.default.isInterfaceDeclaration(node)) && node.name) {
|
|
192566
192645
|
names.add(node.name.text);
|
|
192567
192646
|
}
|
|
192568
|
-
if (
|
|
192647
|
+
if (import_typescript9.default.isFunctionLike(node)) {
|
|
192569
192648
|
for (const p of node.parameters) {
|
|
192570
192649
|
const out = [];
|
|
192571
192650
|
addBindingNames(p.name, out);
|
|
@@ -192573,7 +192652,7 @@ function collectEntryBindingNames(sf) {
|
|
|
192573
192652
|
names.add(n);
|
|
192574
192653
|
}
|
|
192575
192654
|
}
|
|
192576
|
-
|
|
192655
|
+
import_typescript9.default.forEachChild(node, visit2);
|
|
192577
192656
|
}
|
|
192578
192657
|
visit2(sf);
|
|
192579
192658
|
return names;
|
|
@@ -192582,19 +192661,19 @@ var MAX_REEXPORT_HOPS = 1;
|
|
|
192582
192661
|
function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
192583
192662
|
const candidateCallees = new Set;
|
|
192584
192663
|
function collectCandidates(node) {
|
|
192585
|
-
if (
|
|
192664
|
+
if (import_typescript9.default.isVariableDeclaration(node) && (import_typescript9.default.isArrayBindingPattern(node.name) || import_typescript9.default.isObjectBindingPattern(node.name)) && node.initializer && import_typescript9.default.isCallExpression(node.initializer) && import_typescript9.default.isIdentifier(node.initializer.expression)) {
|
|
192586
192665
|
candidateCallees.add(node.initializer.expression.text);
|
|
192587
192666
|
}
|
|
192588
|
-
|
|
192667
|
+
import_typescript9.default.forEachChild(node, collectCandidates);
|
|
192589
192668
|
}
|
|
192590
192669
|
collectCandidates(entrySourceFile);
|
|
192591
192670
|
if (candidateCallees.size === 0)
|
|
192592
192671
|
return;
|
|
192593
192672
|
const importsToCheck = [];
|
|
192594
192673
|
for (const stmt of entrySourceFile.statements) {
|
|
192595
|
-
if (!
|
|
192674
|
+
if (!import_typescript9.default.isImportDeclaration(stmt))
|
|
192596
192675
|
continue;
|
|
192597
|
-
if (!
|
|
192676
|
+
if (!import_typescript9.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192598
192677
|
continue;
|
|
192599
192678
|
const src = stmt.moduleSpecifier.text;
|
|
192600
192679
|
if (!src.startsWith("./") && !src.startsWith("../"))
|
|
@@ -192602,7 +192681,7 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192602
192681
|
if (stmt.importClause?.isTypeOnly)
|
|
192603
192682
|
continue;
|
|
192604
192683
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
192605
|
-
if (!namedBindings || !
|
|
192684
|
+
if (!namedBindings || !import_typescript9.default.isNamedImports(namedBindings))
|
|
192606
192685
|
continue;
|
|
192607
192686
|
const specs = [];
|
|
192608
192687
|
for (const el of namedBindings.elements) {
|
|
@@ -192640,14 +192719,14 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192640
192719
|
helperCache.set(abs, "clean");
|
|
192641
192720
|
return "clean";
|
|
192642
192721
|
}
|
|
192643
|
-
const sf =
|
|
192722
|
+
const sf = import_typescript9.default.createSourceFile(abs + ".prescan", content, import_typescript9.default.ScriptTarget.Latest, true, import_typescript9.default.ScriptKind.TSX);
|
|
192644
192723
|
const localFns = new Map;
|
|
192645
192724
|
const exportedFns = new Map;
|
|
192646
192725
|
for (const stmt of sf.statements) {
|
|
192647
|
-
if (
|
|
192726
|
+
if (import_typescript9.default.isFunctionDeclaration(stmt) && stmt.name && stmt.body) {
|
|
192648
192727
|
localFns.set(stmt.name.text, stmt);
|
|
192649
|
-
const hasExportModifier = stmt.modifiers?.some((m) => m.kind ===
|
|
192650
|
-
const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind ===
|
|
192728
|
+
const hasExportModifier = stmt.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.ExportKeyword) ?? false;
|
|
192729
|
+
const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.DefaultKeyword) ?? false;
|
|
192651
192730
|
if (hasExportModifier && !hasDefaultModifier) {
|
|
192652
192731
|
exportedFns.set(stmt.name.text, stmt);
|
|
192653
192732
|
}
|
|
@@ -192656,10 +192735,10 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192656
192735
|
const reexports = new Map;
|
|
192657
192736
|
let hasStarReexport = false;
|
|
192658
192737
|
for (const stmt of sf.statements) {
|
|
192659
|
-
if (!
|
|
192738
|
+
if (!import_typescript9.default.isExportDeclaration(stmt) || stmt.isTypeOnly)
|
|
192660
192739
|
continue;
|
|
192661
192740
|
if (!stmt.moduleSpecifier) {
|
|
192662
|
-
if (stmt.exportClause &&
|
|
192741
|
+
if (stmt.exportClause && import_typescript9.default.isNamedExports(stmt.exportClause)) {
|
|
192663
192742
|
for (const el of stmt.exportClause.elements) {
|
|
192664
192743
|
if (el.isTypeOnly)
|
|
192665
192744
|
continue;
|
|
@@ -192670,9 +192749,9 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192670
192749
|
}
|
|
192671
192750
|
continue;
|
|
192672
192751
|
}
|
|
192673
|
-
if (!
|
|
192752
|
+
if (!import_typescript9.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192674
192753
|
continue;
|
|
192675
|
-
if (stmt.exportClause &&
|
|
192754
|
+
if (stmt.exportClause && import_typescript9.default.isNamedExports(stmt.exportClause)) {
|
|
192676
192755
|
for (const el of stmt.exportClause.elements) {
|
|
192677
192756
|
if (el.isTypeOnly)
|
|
192678
192757
|
continue;
|
|
@@ -192822,7 +192901,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
192822
192901
|
const importedTypes = new Map;
|
|
192823
192902
|
const imported = new Map;
|
|
192824
192903
|
for (const stmt of sf.statements) {
|
|
192825
|
-
if (
|
|
192904
|
+
if (import_typescript9.default.isVariableStatement(stmt)) {
|
|
192826
192905
|
const out = [];
|
|
192827
192906
|
for (const decl of stmt.declarationList.declarations) {
|
|
192828
192907
|
addBindingNames(decl.name, out);
|
|
@@ -192831,16 +192910,16 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
192831
192910
|
local.add(n);
|
|
192832
192911
|
continue;
|
|
192833
192912
|
}
|
|
192834
|
-
if ((
|
|
192913
|
+
if ((import_typescript9.default.isFunctionDeclaration(stmt) || import_typescript9.default.isClassDeclaration(stmt) || import_typescript9.default.isEnumDeclaration(stmt)) && stmt.name) {
|
|
192835
192914
|
local.add(stmt.name.text);
|
|
192836
192915
|
continue;
|
|
192837
192916
|
}
|
|
192838
|
-
if ((
|
|
192917
|
+
if ((import_typescript9.default.isTypeAliasDeclaration(stmt) || import_typescript9.default.isInterfaceDeclaration(stmt)) && stmt.name) {
|
|
192839
192918
|
localTypes.add(stmt.name.text);
|
|
192840
192919
|
continue;
|
|
192841
192920
|
}
|
|
192842
|
-
if (
|
|
192843
|
-
if (!
|
|
192921
|
+
if (import_typescript9.default.isImportDeclaration(stmt)) {
|
|
192922
|
+
if (!import_typescript9.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192844
192923
|
continue;
|
|
192845
192924
|
const src = stmt.moduleSpecifier.text;
|
|
192846
192925
|
if (src === "@barefootjs/client" || src === "@barefootjs/client/runtime")
|
|
@@ -192849,7 +192928,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
192849
192928
|
if (stmt.importClause?.name)
|
|
192850
192929
|
(wholeTypeOnly ? localTypes : local).add(stmt.importClause.name.text);
|
|
192851
192930
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
192852
|
-
if (namedBindings &&
|
|
192931
|
+
if (namedBindings && import_typescript9.default.isNamedImports(namedBindings)) {
|
|
192853
192932
|
for (const el of namedBindings.elements) {
|
|
192854
192933
|
const entry = { source: src, exportedName: (el.propertyName ?? el.name).text };
|
|
192855
192934
|
if (wholeTypeOnly || el.isTypeOnly)
|
|
@@ -192858,7 +192937,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
192858
192937
|
imported.set(el.name.text, entry);
|
|
192859
192938
|
}
|
|
192860
192939
|
}
|
|
192861
|
-
if (namedBindings &&
|
|
192940
|
+
if (namedBindings && import_typescript9.default.isNamespaceImport(namedBindings)) {
|
|
192862
192941
|
(wholeTypeOnly ? localTypes : local).add(namedBindings.name.text);
|
|
192863
192942
|
}
|
|
192864
192943
|
}
|
|
@@ -192925,11 +193004,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
192925
193004
|
function checkForReactive(n) {
|
|
192926
193005
|
if (hasReactiveCall)
|
|
192927
193006
|
return;
|
|
192928
|
-
if (
|
|
193007
|
+
if (import_typescript9.default.isCallExpression(n) && import_typescript9.default.isIdentifier(n.expression) && REACTIVE_PRIMITIVES.has(n.expression.text)) {
|
|
192929
193008
|
hasReactiveCall = true;
|
|
192930
193009
|
return;
|
|
192931
193010
|
}
|
|
192932
|
-
|
|
193011
|
+
import_typescript9.default.forEachChild(n, checkForReactive);
|
|
192933
193012
|
}
|
|
192934
193013
|
checkForReactive(node.body);
|
|
192935
193014
|
if (!hasReactiveCall)
|
|
@@ -192937,29 +193016,29 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
192937
193016
|
const loc = getSourceLocation(node, sourceFile, filePath);
|
|
192938
193017
|
let totalReturnCount = 0;
|
|
192939
193018
|
function countReturns(n) {
|
|
192940
|
-
if (
|
|
193019
|
+
if (import_typescript9.default.isFunctionLike(n))
|
|
192941
193020
|
return;
|
|
192942
|
-
if (
|
|
193021
|
+
if (import_typescript9.default.isReturnStatement(n)) {
|
|
192943
193022
|
totalReturnCount++;
|
|
192944
193023
|
return;
|
|
192945
193024
|
}
|
|
192946
|
-
|
|
193025
|
+
import_typescript9.default.forEachChild(n, countReturns);
|
|
192947
193026
|
}
|
|
192948
|
-
|
|
193027
|
+
import_typescript9.default.forEachChild(node.body, countReturns);
|
|
192949
193028
|
let returnExpr = null;
|
|
192950
193029
|
let returnCount = 0;
|
|
192951
193030
|
for (const stmt of node.body.statements) {
|
|
192952
|
-
if (!
|
|
193031
|
+
if (!import_typescript9.default.isReturnStatement(stmt))
|
|
192953
193032
|
continue;
|
|
192954
193033
|
returnCount++;
|
|
192955
193034
|
if (!stmt.expression)
|
|
192956
193035
|
return { kind: "reactive-shaped" };
|
|
192957
193036
|
let expr = stmt.expression;
|
|
192958
|
-
while (
|
|
193037
|
+
while (import_typescript9.default.isParenthesizedExpression(expr))
|
|
192959
193038
|
expr = expr.expression;
|
|
192960
|
-
if (
|
|
193039
|
+
if (import_typescript9.default.isAsExpression(expr))
|
|
192961
193040
|
expr = expr.expression;
|
|
192962
|
-
if (
|
|
193041
|
+
if (import_typescript9.default.isTypeAssertionExpression(expr))
|
|
192963
193042
|
expr = expr.expression;
|
|
192964
193043
|
returnExpr = expr;
|
|
192965
193044
|
}
|
|
@@ -192967,18 +193046,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
192967
193046
|
return { kind: "reactive-shaped" };
|
|
192968
193047
|
const returnTupleIdentifiers = [];
|
|
192969
193048
|
let returnKind;
|
|
192970
|
-
if (
|
|
193049
|
+
if (import_typescript9.default.isArrayLiteralExpression(returnExpr)) {
|
|
192971
193050
|
returnKind = "tuple";
|
|
192972
193051
|
for (const el of returnExpr.elements) {
|
|
192973
|
-
if (!
|
|
193052
|
+
if (!import_typescript9.default.isIdentifier(el))
|
|
192974
193053
|
return { kind: "reactive-shaped" };
|
|
192975
193054
|
returnTupleIdentifiers.push(el.text);
|
|
192976
193055
|
}
|
|
192977
193056
|
if (returnTupleIdentifiers.length === 0)
|
|
192978
193057
|
return { kind: "reactive-shaped" };
|
|
192979
|
-
} else if (
|
|
193058
|
+
} else if (import_typescript9.default.isObjectLiteralExpression(returnExpr)) {
|
|
192980
193059
|
returnKind = "object";
|
|
192981
|
-
const hasNonShorthand = returnExpr.properties.some((p) => !
|
|
193060
|
+
const hasNonShorthand = returnExpr.properties.some((p) => !import_typescript9.default.isShorthandPropertyAssignment(p));
|
|
192982
193061
|
if (hasNonShorthand) {
|
|
192983
193062
|
return {
|
|
192984
193063
|
kind: "declined",
|
|
@@ -192999,7 +193078,7 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
192999
193078
|
}
|
|
193000
193079
|
const params = [];
|
|
193001
193080
|
for (const p of node.parameters) {
|
|
193002
|
-
if (
|
|
193081
|
+
if (import_typescript9.default.isIdentifier(p.name)) {
|
|
193003
193082
|
params.push(p.name.text);
|
|
193004
193083
|
continue;
|
|
193005
193084
|
}
|
|
@@ -193007,11 +193086,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193007
193086
|
}
|
|
193008
193087
|
const localBindings = [];
|
|
193009
193088
|
for (const stmt of node.body.statements) {
|
|
193010
|
-
if (
|
|
193089
|
+
if (import_typescript9.default.isVariableStatement(stmt)) {
|
|
193011
193090
|
for (const decl of stmt.declarationList.declarations) {
|
|
193012
193091
|
addBindingNames(decl.name, localBindings);
|
|
193013
193092
|
}
|
|
193014
|
-
} else if (
|
|
193093
|
+
} else if (import_typescript9.default.isFunctionDeclaration(stmt) && stmt.name) {
|
|
193015
193094
|
localBindings.push(stmt.name.text);
|
|
193016
193095
|
}
|
|
193017
193096
|
}
|
|
@@ -193031,47 +193110,47 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193031
193110
|
if (!relevantNames.has(id.text))
|
|
193032
193111
|
return;
|
|
193033
193112
|
const p = id.parent;
|
|
193034
|
-
if (
|
|
193113
|
+
if (import_typescript9.default.isPropertyAccessExpression(p) && p.name === id)
|
|
193035
193114
|
return;
|
|
193036
|
-
if (
|
|
193115
|
+
if (import_typescript9.default.isPropertyAssignment(p) && p.name === id)
|
|
193037
193116
|
return;
|
|
193038
|
-
if (
|
|
193117
|
+
if (import_typescript9.default.isBindingElement(p) && p.propertyName === id)
|
|
193039
193118
|
return;
|
|
193040
|
-
if ((
|
|
193119
|
+
if ((import_typescript9.default.isMethodDeclaration(p) || import_typescript9.default.isGetAccessorDeclaration(p) || import_typescript9.default.isSetAccessorDeclaration(p) || import_typescript9.default.isPropertyDeclaration(p) || import_typescript9.default.isEnumMember(p)) && p.name === id)
|
|
193041
193120
|
return;
|
|
193042
|
-
if (
|
|
193121
|
+
if (import_typescript9.default.isJsxAttribute(p) && p.name === id)
|
|
193043
193122
|
return;
|
|
193044
|
-
if (
|
|
193123
|
+
if (import_typescript9.default.isLabeledStatement(p) && p.label === id || (import_typescript9.default.isBreakStatement(p) || import_typescript9.default.isContinueStatement(p)) && p.label === id)
|
|
193045
193124
|
return;
|
|
193046
|
-
if ((
|
|
193125
|
+
if ((import_typescript9.default.isJsxOpeningElement(p) || import_typescript9.default.isJsxSelfClosingElement(p) || import_typescript9.default.isJsxClosingElement(p)) && p.tagName === id && /^[a-z]/.test(id.text))
|
|
193047
193126
|
return;
|
|
193048
|
-
if (
|
|
193127
|
+
if (import_typescript9.default.isShorthandPropertyAssignment(p) && p.name === id) {
|
|
193049
193128
|
push(id, "shorthand");
|
|
193050
193129
|
return;
|
|
193051
193130
|
}
|
|
193052
|
-
if (
|
|
193131
|
+
if (import_typescript9.default.isBindingElement(p) && p.name === id && !p.propertyName && import_typescript9.default.isObjectBindingPattern(p.parent)) {
|
|
193053
193132
|
if (params.includes(id.text))
|
|
193054
193133
|
shadowedParam = id.text;
|
|
193055
193134
|
push(id, "shorthand");
|
|
193056
193135
|
return;
|
|
193057
193136
|
}
|
|
193058
|
-
const isDecl = (
|
|
193137
|
+
const isDecl = (import_typescript9.default.isVariableDeclaration(p) || import_typescript9.default.isParameter(p) || import_typescript9.default.isBindingElement(p) || import_typescript9.default.isFunctionDeclaration(p) || import_typescript9.default.isFunctionExpression(p) || import_typescript9.default.isClassDeclaration(p) || import_typescript9.default.isClassExpression(p)) && p.name === id;
|
|
193059
193138
|
if (isDecl && params.includes(id.text))
|
|
193060
193139
|
shadowedParam = id.text;
|
|
193061
193140
|
push(id, "plain");
|
|
193062
193141
|
}
|
|
193063
193142
|
function visit2(n) {
|
|
193064
|
-
if (
|
|
193143
|
+
if (import_typescript9.default.isTypeNode(n) || import_typescript9.default.isTypeParameterDeclaration(n) || import_typescript9.default.isTypeAliasDeclaration(n) || import_typescript9.default.isInterfaceDeclaration(n))
|
|
193065
193144
|
return;
|
|
193066
|
-
if (
|
|
193145
|
+
if (import_typescript9.default.isIdentifier(n)) {
|
|
193067
193146
|
classify(n);
|
|
193068
193147
|
return;
|
|
193069
193148
|
}
|
|
193070
|
-
|
|
193149
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
193071
193150
|
}
|
|
193072
193151
|
visit2(root);
|
|
193073
193152
|
}
|
|
193074
|
-
const keptStatements = node.body.statements.filter((s) => !
|
|
193153
|
+
const keptStatements = node.body.statements.filter((s) => !import_typescript9.default.isReturnStatement(s));
|
|
193075
193154
|
const pieces = [];
|
|
193076
193155
|
let base = 0;
|
|
193077
193156
|
for (const stmt of keptStatements) {
|
|
@@ -193119,18 +193198,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193119
193198
|
};
|
|
193120
193199
|
}
|
|
193121
193200
|
function addBindingNames(name, out) {
|
|
193122
|
-
if (
|
|
193201
|
+
if (import_typescript9.default.isIdentifier(name)) {
|
|
193123
193202
|
out.push(name.text);
|
|
193124
193203
|
return;
|
|
193125
193204
|
}
|
|
193126
|
-
if (
|
|
193205
|
+
if (import_typescript9.default.isObjectBindingPattern(name)) {
|
|
193127
193206
|
for (const el of name.elements)
|
|
193128
193207
|
addBindingNames(el.name, out);
|
|
193129
193208
|
return;
|
|
193130
193209
|
}
|
|
193131
|
-
if (
|
|
193210
|
+
if (import_typescript9.default.isArrayBindingPattern(name)) {
|
|
193132
193211
|
for (const el of name.elements) {
|
|
193133
|
-
if (
|
|
193212
|
+
if (import_typescript9.default.isOmittedExpression(el))
|
|
193134
193213
|
continue;
|
|
193135
193214
|
addBindingNames(el.name, out);
|
|
193136
193215
|
}
|
|
@@ -193142,33 +193221,33 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193142
193221
|
let callSiteIndex = 0;
|
|
193143
193222
|
const inlinedFactories = new Set;
|
|
193144
193223
|
function visitStmt(node, inComponent) {
|
|
193145
|
-
if (
|
|
193224
|
+
if (import_typescript9.default.isVariableStatement(node) && inComponent) {
|
|
193146
193225
|
for (const decl of node.declarationList.declarations) {
|
|
193147
193226
|
maybeRewriteDecl(node, decl);
|
|
193148
193227
|
}
|
|
193149
193228
|
}
|
|
193150
|
-
|
|
193151
|
-
if (
|
|
193229
|
+
import_typescript9.default.forEachChild(node, (child) => {
|
|
193230
|
+
if (import_typescript9.default.isFunctionDeclaration(child) && child.name && factories.has(child.name.text))
|
|
193152
193231
|
return;
|
|
193153
193232
|
visitStmt(child, inComponent || isPascalCaseComponentFn(child));
|
|
193154
193233
|
});
|
|
193155
193234
|
}
|
|
193156
193235
|
function maybeRewriteDecl(stmt, decl) {
|
|
193157
|
-
if (!decl.initializer || !
|
|
193236
|
+
if (!decl.initializer || !import_typescript9.default.isCallExpression(decl.initializer))
|
|
193158
193237
|
return;
|
|
193159
|
-
if (!
|
|
193238
|
+
if (!import_typescript9.default.isIdentifier(decl.initializer.expression))
|
|
193160
193239
|
return;
|
|
193161
193240
|
const factoryName = decl.initializer.expression.text;
|
|
193162
193241
|
const factory = factories.get(factoryName);
|
|
193163
193242
|
if (!factory)
|
|
193164
193243
|
return;
|
|
193165
|
-
if (
|
|
193244
|
+
if (import_typescript9.default.isArrayBindingPattern(decl.name)) {
|
|
193166
193245
|
if (factory.returnKind !== "tuple")
|
|
193167
193246
|
return;
|
|
193168
193247
|
rewriteTupleDecl(stmt, decl.name, decl.initializer, factory);
|
|
193169
193248
|
return;
|
|
193170
193249
|
}
|
|
193171
|
-
if (
|
|
193250
|
+
if (import_typescript9.default.isObjectBindingPattern(decl.name)) {
|
|
193172
193251
|
if (factory.returnKind !== "object")
|
|
193173
193252
|
return;
|
|
193174
193253
|
rewriteObjectDecl(stmt, decl.name, decl.initializer, factory);
|
|
@@ -193181,7 +193260,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193181
193260
|
return;
|
|
193182
193261
|
const callerNames = [];
|
|
193183
193262
|
for (const el of elements) {
|
|
193184
|
-
if (
|
|
193263
|
+
if (import_typescript9.default.isOmittedExpression(el) || !import_typescript9.default.isIdentifier(el.name))
|
|
193185
193264
|
return;
|
|
193186
193265
|
callerNames.push(el.name.text);
|
|
193187
193266
|
}
|
|
@@ -193203,7 +193282,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193203
193282
|
return;
|
|
193204
193283
|
if (el.initializer)
|
|
193205
193284
|
return;
|
|
193206
|
-
if (!
|
|
193285
|
+
if (!import_typescript9.default.isIdentifier(el.name))
|
|
193207
193286
|
return;
|
|
193208
193287
|
if (!factory.returnTupleIdentifiers.includes(el.name.text))
|
|
193209
193288
|
return;
|
|
@@ -193312,21 +193391,21 @@ function factoryImportInsertionOffset(sf) {
|
|
|
193312
193391
|
let lastImportEnd = -1;
|
|
193313
193392
|
let directiveEnd = -1;
|
|
193314
193393
|
for (const stmt of sf.statements) {
|
|
193315
|
-
if (
|
|
193394
|
+
if (import_typescript9.default.isImportDeclaration(stmt)) {
|
|
193316
193395
|
lastImportEnd = stmt.getEnd();
|
|
193317
193396
|
continue;
|
|
193318
193397
|
}
|
|
193319
|
-
if (directiveEnd === -1 &&
|
|
193398
|
+
if (directiveEnd === -1 && import_typescript9.default.isExpressionStatement(stmt) && import_typescript9.default.isStringLiteral(stmt.expression) && stmt.expression.text === "use client") {
|
|
193320
193399
|
directiveEnd = stmt.getEnd();
|
|
193321
193400
|
}
|
|
193322
193401
|
}
|
|
193323
193402
|
return lastImportEnd >= 0 ? lastImportEnd : directiveEnd >= 0 ? directiveEnd : 0;
|
|
193324
193403
|
}
|
|
193325
193404
|
function isPascalCaseComponentFn(node) {
|
|
193326
|
-
if (
|
|
193405
|
+
if (import_typescript9.default.isFunctionDeclaration(node) && node.name) {
|
|
193327
193406
|
return /^[A-Z]/.test(node.name.text);
|
|
193328
193407
|
}
|
|
193329
|
-
if (
|
|
193408
|
+
if (import_typescript9.default.isVariableDeclaration(node) && import_typescript9.default.isIdentifier(node.name) && node.initializer && import_typescript9.default.isArrowFunction(node.initializer)) {
|
|
193330
193409
|
return /^[A-Z]/.test(node.name.text);
|
|
193331
193410
|
}
|
|
193332
193411
|
return false;
|
|
@@ -193355,20 +193434,20 @@ function declinedFactoryErrorCode(code2) {
|
|
|
193355
193434
|
function validateReactiveFactoryCalls(ctx) {
|
|
193356
193435
|
if (!ctx.componentNode)
|
|
193357
193436
|
return;
|
|
193358
|
-
const body =
|
|
193437
|
+
const body = import_typescript9.default.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : import_typescript9.default.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
|
|
193359
193438
|
if (!body)
|
|
193360
193439
|
return;
|
|
193361
193440
|
for (const stmt of body.statements) {
|
|
193362
|
-
if (!
|
|
193441
|
+
if (!import_typescript9.default.isVariableStatement(stmt))
|
|
193363
193442
|
continue;
|
|
193364
193443
|
for (const decl of stmt.declarationList.declarations) {
|
|
193365
|
-
if (!decl.initializer || !
|
|
193444
|
+
if (!decl.initializer || !import_typescript9.default.isCallExpression(decl.initializer))
|
|
193366
193445
|
continue;
|
|
193367
|
-
if (!
|
|
193446
|
+
if (!import_typescript9.default.isIdentifier(decl.initializer.expression))
|
|
193368
193447
|
continue;
|
|
193369
193448
|
const callee = decl.initializer.expression.text;
|
|
193370
193449
|
const loc = getSourceLocation(stmt, ctx.sourceFile, ctx.filePath);
|
|
193371
|
-
if (
|
|
193450
|
+
if (import_typescript9.default.isArrayBindingPattern(decl.name)) {
|
|
193372
193451
|
if (callee === "createSignal" || callee === "createMemo")
|
|
193373
193452
|
continue;
|
|
193374
193453
|
if (resolveEnvSignalKey(decl.initializer, ctx))
|
|
@@ -193395,7 +193474,7 @@ function validateReactiveFactoryCalls(ctx) {
|
|
|
193395
193474
|
}));
|
|
193396
193475
|
continue;
|
|
193397
193476
|
}
|
|
193398
|
-
if (
|
|
193477
|
+
if (import_typescript9.default.isObjectBindingPattern(decl.name)) {
|
|
193399
193478
|
validateObjectFactoryDestructure(ctx, decl.name, callee, loc);
|
|
193400
193479
|
}
|
|
193401
193480
|
}
|
|
@@ -193411,7 +193490,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
193411
193490
|
}));
|
|
193412
193491
|
return;
|
|
193413
193492
|
}
|
|
193414
|
-
const hasUnsupportedElement = pattern.elements.some((el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !
|
|
193493
|
+
const hasUnsupportedElement = pattern.elements.some((el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !import_typescript9.default.isIdentifier(el.name));
|
|
193415
193494
|
if (hasUnsupportedElement) {
|
|
193416
193495
|
ctx.errors.push(createError(ErrorCodes.REACTIVE_FACTORY_RENAME_UNSUPPORTED, loc, {
|
|
193417
193496
|
severity: "error",
|
|
@@ -193419,7 +193498,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
193419
193498
|
}));
|
|
193420
193499
|
return;
|
|
193421
193500
|
}
|
|
193422
|
-
const unknown = pattern.elements.map((el) =>
|
|
193501
|
+
const unknown = pattern.elements.map((el) => import_typescript9.default.isIdentifier(el.name) ? el.name.text : "").filter((name) => name && !factory.returnTupleIdentifiers.includes(name));
|
|
193423
193502
|
if (unknown.length > 0) {
|
|
193424
193503
|
const label = unknown.length === 1 ? "property" : "properties";
|
|
193425
193504
|
ctx.errors.push(createError(ErrorCodes.UNRECOGNIZED_REACTIVE_FACTORY, loc, {
|
|
@@ -193463,7 +193542,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
193463
193542
|
}
|
|
193464
193543
|
|
|
193465
193544
|
// ../jsx/src/jsx-to-ir.ts
|
|
193466
|
-
var
|
|
193545
|
+
var import_typescript12 = __toESM(require_typescript(), 1);
|
|
193467
193546
|
|
|
193468
193547
|
// ../jsx/src/types.ts
|
|
193469
193548
|
var SCOPE_FORBIDDEN = {
|
|
@@ -193577,7 +193656,7 @@ function isClientBuiltinName(name) {
|
|
|
193577
193656
|
}
|
|
193578
193657
|
|
|
193579
193658
|
// ../jsx/src/reactivity-checker.ts
|
|
193580
|
-
var
|
|
193659
|
+
var import_typescript10 = __toESM(require_typescript(), 1);
|
|
193581
193660
|
var REACTIVE_BRAND = "__reactive";
|
|
193582
193661
|
function queryType(checker, node) {
|
|
193583
193662
|
incrementCounter("typeCheckerQueries");
|
|
@@ -193595,7 +193674,7 @@ function safeGetText(node) {
|
|
|
193595
193674
|
}
|
|
193596
193675
|
}
|
|
193597
193676
|
function analyze(node, checker) {
|
|
193598
|
-
if (
|
|
193677
|
+
if (import_typescript10.default.isPropertyAccessExpression(node)) {
|
|
193599
193678
|
try {
|
|
193600
193679
|
const type2 = queryType(checker, node);
|
|
193601
193680
|
if (isReactiveType(type2)) {
|
|
@@ -193619,7 +193698,7 @@ function analyze(node, checker) {
|
|
|
193619
193698
|
}
|
|
193620
193699
|
return NOT_REACTIVE;
|
|
193621
193700
|
}
|
|
193622
|
-
if (
|
|
193701
|
+
if (import_typescript10.default.isIdentifier(node)) {
|
|
193623
193702
|
try {
|
|
193624
193703
|
const type2 = queryType(checker, node);
|
|
193625
193704
|
if (isReactiveType(type2)) {
|
|
@@ -193631,7 +193710,7 @@ function analyze(node, checker) {
|
|
|
193631
193710
|
} catch {}
|
|
193632
193711
|
return NOT_REACTIVE;
|
|
193633
193712
|
}
|
|
193634
|
-
if (
|
|
193713
|
+
if (import_typescript10.default.isCallExpression(node)) {
|
|
193635
193714
|
try {
|
|
193636
193715
|
const calleeType = queryType(checker, node.expression);
|
|
193637
193716
|
if (isReactiveType(calleeType)) {
|
|
@@ -193644,7 +193723,7 @@ function analyze(node, checker) {
|
|
|
193644
193723
|
}
|
|
193645
193724
|
let foundChild;
|
|
193646
193725
|
let foundChildText = "";
|
|
193647
|
-
|
|
193726
|
+
import_typescript10.default.forEachChild(node, (child) => {
|
|
193648
193727
|
if (foundChild?.isReactive)
|
|
193649
193728
|
return;
|
|
193650
193729
|
const result = analyze(child, checker);
|
|
@@ -193673,7 +193752,7 @@ function containsReactiveExpression(node, checker) {
|
|
|
193673
193752
|
}
|
|
193674
193753
|
|
|
193675
193754
|
// ../jsx/src/free-refs.ts
|
|
193676
|
-
var
|
|
193755
|
+
var import_typescript11 = __toESM(require_typescript(), 1);
|
|
193677
193756
|
var _bindingMapCache = new WeakMap;
|
|
193678
193757
|
function buildBindingMap(env) {
|
|
193679
193758
|
const cached = _bindingMapCache.get(env);
|
|
@@ -193741,20 +193820,20 @@ function defaultBindingScope(kind) {
|
|
|
193741
193820
|
function collectIdentifiers2(node) {
|
|
193742
193821
|
const out = [];
|
|
193743
193822
|
const visit2 = (n, parent) => {
|
|
193744
|
-
if (
|
|
193745
|
-
if (parent &&
|
|
193823
|
+
if (import_typescript11.default.isIdentifier(n)) {
|
|
193824
|
+
if (parent && import_typescript11.default.isPropertyAccessExpression(parent) && parent.name === n)
|
|
193746
193825
|
return;
|
|
193747
|
-
if (parent &&
|
|
193826
|
+
if (parent && import_typescript11.default.isPropertyAssignment(parent) && parent.name === n)
|
|
193748
193827
|
return;
|
|
193749
|
-
if (parent && (
|
|
193828
|
+
if (parent && (import_typescript11.default.isJsxOpeningElement(parent) || import_typescript11.default.isJsxClosingElement(parent) || import_typescript11.default.isJsxSelfClosingElement(parent)) && parent.tagName === n) {
|
|
193750
193829
|
return;
|
|
193751
193830
|
}
|
|
193752
|
-
if (parent &&
|
|
193831
|
+
if (parent && import_typescript11.default.isJsxAttribute(parent) && parent.name === n)
|
|
193753
193832
|
return;
|
|
193754
193833
|
out.push(n);
|
|
193755
193834
|
return;
|
|
193756
193835
|
}
|
|
193757
|
-
|
|
193836
|
+
import_typescript11.default.forEachChild(n, (child) => visit2(child, n));
|
|
193758
193837
|
};
|
|
193759
193838
|
visit2(node);
|
|
193760
193839
|
return out;
|
|
@@ -193763,7 +193842,7 @@ function collectReactiveBrandRefs(node, checker) {
|
|
|
193763
193842
|
const out = [];
|
|
193764
193843
|
const seen = new Set;
|
|
193765
193844
|
const visit2 = (n) => {
|
|
193766
|
-
if (
|
|
193845
|
+
if (import_typescript11.default.isPropertyAccessExpression(n)) {
|
|
193767
193846
|
try {
|
|
193768
193847
|
const type2 = checker.getTypeAtLocation(n);
|
|
193769
193848
|
if (isReactiveType(type2)) {
|
|
@@ -193781,7 +193860,7 @@ function collectReactiveBrandRefs(node, checker) {
|
|
|
193781
193860
|
incrementCounter("freeRefsTypeLookupFailures");
|
|
193782
193861
|
}
|
|
193783
193862
|
}
|
|
193784
|
-
|
|
193863
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
193785
193864
|
};
|
|
193786
193865
|
visit2(node);
|
|
193787
193866
|
return out;
|
|
@@ -193791,14 +193870,14 @@ function resolveConstantInitializerRefs(c, env, visited) {
|
|
|
193791
193870
|
return [];
|
|
193792
193871
|
if (c.containsArrow)
|
|
193793
193872
|
return [];
|
|
193794
|
-
const sf =
|
|
193873
|
+
const sf = import_typescript11.default.createSourceFile("__const_init.ts", `const __probe = (${c.value});`, import_typescript11.default.ScriptTarget.Latest, true);
|
|
193795
193874
|
const stmt = sf.statements[0];
|
|
193796
|
-
if (!stmt || !
|
|
193875
|
+
if (!stmt || !import_typescript11.default.isVariableStatement(stmt))
|
|
193797
193876
|
return [];
|
|
193798
193877
|
const decl = stmt.declarationList.declarations[0];
|
|
193799
193878
|
if (!decl || !decl.initializer)
|
|
193800
193879
|
return [];
|
|
193801
|
-
const expr =
|
|
193880
|
+
const expr = import_typescript11.default.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
193802
193881
|
return resolveFreeRefsInternal(expr, env, visited);
|
|
193803
193882
|
}
|
|
193804
193883
|
function resolveFreeRefsInternal(node, env, visited) {
|
|
@@ -193810,7 +193889,7 @@ function resolveFreeRefsInternal(node, env, visited) {
|
|
|
193810
193889
|
const name = ident.text;
|
|
193811
193890
|
if (env.propsObjectName === name) {
|
|
193812
193891
|
const parent = ident.parent;
|
|
193813
|
-
if (parent &&
|
|
193892
|
+
if (parent && import_typescript11.default.isPropertyAccessExpression(parent) && parent.expression === ident && parent.name.text === "children") {
|
|
193814
193893
|
continue;
|
|
193815
193894
|
}
|
|
193816
193895
|
}
|
|
@@ -194238,13 +194317,13 @@ function exprCallsReactiveGetters(expr, ctx) {
|
|
|
194238
194317
|
function visit2(n) {
|
|
194239
194318
|
if (found)
|
|
194240
194319
|
return;
|
|
194241
|
-
if (
|
|
194320
|
+
if (import_typescript12.default.isCallExpression(n) && import_typescript12.default.isIdentifier(n.expression)) {
|
|
194242
194321
|
if (names.has(n.expression.text)) {
|
|
194243
194322
|
found = true;
|
|
194244
194323
|
return;
|
|
194245
194324
|
}
|
|
194246
194325
|
}
|
|
194247
|
-
|
|
194326
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
194248
194327
|
}
|
|
194249
194328
|
visit2(expr);
|
|
194250
194329
|
return found;
|
|
@@ -194271,11 +194350,11 @@ function exprReferencesModuleClientSignal(expr, ctx) {
|
|
|
194271
194350
|
function visit2(n) {
|
|
194272
194351
|
if (found)
|
|
194273
194352
|
return;
|
|
194274
|
-
if (
|
|
194353
|
+
if (import_typescript12.default.isCallExpression(n) && import_typescript12.default.isIdentifier(n.expression) && names.has(n.expression.text)) {
|
|
194275
194354
|
found = true;
|
|
194276
194355
|
return;
|
|
194277
194356
|
}
|
|
194278
|
-
|
|
194357
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
194279
194358
|
}
|
|
194280
194359
|
visit2(expr);
|
|
194281
194360
|
return found;
|
|
@@ -194285,11 +194364,11 @@ function exprHasFunctionCalls(expr) {
|
|
|
194285
194364
|
function visit2(n) {
|
|
194286
194365
|
if (found)
|
|
194287
194366
|
return;
|
|
194288
|
-
if (
|
|
194367
|
+
if (import_typescript12.default.isCallExpression(n)) {
|
|
194289
194368
|
found = true;
|
|
194290
194369
|
return;
|
|
194291
194370
|
}
|
|
194292
|
-
|
|
194371
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
194293
194372
|
}
|
|
194294
194373
|
visit2(expr);
|
|
194295
194374
|
return found;
|
|
@@ -194326,10 +194405,10 @@ function lowerDateCalls(text, expr, ctx) {
|
|
|
194326
194405
|
return text;
|
|
194327
194406
|
const candidates = [];
|
|
194328
194407
|
function visit2(n) {
|
|
194329
|
-
if (
|
|
194408
|
+
if (import_typescript12.default.isCallExpression(n) && n.arguments.length === 0 && import_typescript12.default.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && DATE_METHODS.has(n.expression.name.text)) {
|
|
194330
194409
|
candidates.push(n);
|
|
194331
194410
|
}
|
|
194332
|
-
|
|
194411
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
194333
194412
|
}
|
|
194334
194413
|
visit2(expr);
|
|
194335
194414
|
if (candidates.length === 0)
|
|
@@ -194354,10 +194433,10 @@ function lowerToLocaleDateCalls(text, expr, ctx) {
|
|
|
194354
194433
|
return text;
|
|
194355
194434
|
const candidates = [];
|
|
194356
194435
|
function visit2(n) {
|
|
194357
|
-
if (
|
|
194436
|
+
if (import_typescript12.default.isCallExpression(n) && n.arguments.length === 2 && import_typescript12.default.isPropertyAccessExpression(n.expression) && !n.expression.questionDotToken && n.expression.name.text === "toLocaleDateString") {
|
|
194358
194437
|
candidates.push(n);
|
|
194359
194438
|
}
|
|
194360
|
-
|
|
194439
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
194361
194440
|
}
|
|
194362
194441
|
visit2(expr);
|
|
194363
194442
|
if (candidates.length === 0)
|
|
@@ -194400,7 +194479,8 @@ function rewriteBarePropRefs2(text, expr, ctx) {
|
|
|
194400
194479
|
propNames = filtered;
|
|
194401
194480
|
}
|
|
194402
194481
|
const extraPropRefs = collectBranchLocalPropRefsViaSubstitution(expr, ctx);
|
|
194403
|
-
|
|
194482
|
+
const propAliases = getDestructuredPropAliases(ctx);
|
|
194483
|
+
return rewriteBarePropRefs(dateLowered, expr, propNames, extraPropRefs, propAliases ?? undefined);
|
|
194404
194484
|
}
|
|
194405
194485
|
function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
194406
194486
|
const propDepsMap = ctx._branchScopePropDeps;
|
|
@@ -194409,10 +194489,10 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
194409
194489
|
return;
|
|
194410
194490
|
let acc;
|
|
194411
194491
|
function visit2(n, parent) {
|
|
194412
|
-
if (
|
|
194413
|
-
const isObjectKey = parent &&
|
|
194414
|
-
const isShorthand = parent &&
|
|
194415
|
-
const isAccessName = parent &&
|
|
194492
|
+
if (import_typescript12.default.isIdentifier(n) && propDepsMap.has(n.text)) {
|
|
194493
|
+
const isObjectKey = parent && import_typescript12.default.isPropertyAssignment(parent) && parent.name === n;
|
|
194494
|
+
const isShorthand = parent && import_typescript12.default.isShorthandPropertyAssignment(parent) && parent.name === n;
|
|
194495
|
+
const isAccessName = parent && import_typescript12.default.isPropertyAccessExpression(parent) && parent.name === n;
|
|
194416
194496
|
if (!isObjectKey && !isShorthand && !isAccessName) {
|
|
194417
194497
|
const deps = propDepsMap.get(n.text);
|
|
194418
194498
|
if (deps && deps.size > 0) {
|
|
@@ -194423,7 +194503,7 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
194423
194503
|
}
|
|
194424
194504
|
}
|
|
194425
194505
|
}
|
|
194426
|
-
|
|
194506
|
+
import_typescript12.default.forEachChild(n, (child) => visit2(child, n));
|
|
194427
194507
|
}
|
|
194428
194508
|
visit2(node);
|
|
194429
194509
|
return acc;
|
|
@@ -194445,11 +194525,18 @@ function getDestructuredPropNames(ctx) {
|
|
|
194445
194525
|
shadowed.add(c.name);
|
|
194446
194526
|
}
|
|
194447
194527
|
}
|
|
194448
|
-
const
|
|
194528
|
+
const eligible = ctx.analyzer.propsParams.filter((p) => !shadowed.has(p.name));
|
|
194529
|
+
const names = eligible.map((p) => p.name);
|
|
194449
194530
|
ctx._destructuredPropNames = names.length > 0 ? new Set(names) : null;
|
|
194531
|
+
ctx._destructuredPropAliases = buildPropAliasMap(eligible) ?? null;
|
|
194450
194532
|
}
|
|
194451
194533
|
return ctx._destructuredPropNames ?? null;
|
|
194452
194534
|
}
|
|
194535
|
+
function getDestructuredPropAliases(ctx) {
|
|
194536
|
+
if (ctx._destructuredPropNames === undefined)
|
|
194537
|
+
getDestructuredPropNames(ctx);
|
|
194538
|
+
return ctx._destructuredPropAliases ?? null;
|
|
194539
|
+
}
|
|
194453
194540
|
function createTransformContext(analyzer) {
|
|
194454
194541
|
return {
|
|
194455
194542
|
analyzer,
|
|
@@ -194492,21 +194579,21 @@ function createTransformContext(analyzer) {
|
|
|
194492
194579
|
function buildComponentNamespaces(ctx) {
|
|
194493
194580
|
const result = new Map;
|
|
194494
194581
|
for (const stmt of ctx.sourceFile.statements) {
|
|
194495
|
-
if (!
|
|
194582
|
+
if (!import_typescript12.default.isVariableStatement(stmt))
|
|
194496
194583
|
continue;
|
|
194497
194584
|
for (const decl of stmt.declarationList.declarations) {
|
|
194498
|
-
if (!decl.initializer || !
|
|
194585
|
+
if (!decl.initializer || !import_typescript12.default.isIdentifier(decl.name))
|
|
194499
194586
|
continue;
|
|
194500
194587
|
let init = decl.initializer;
|
|
194501
|
-
while (
|
|
194588
|
+
while (import_typescript12.default.isParenthesizedExpression(init))
|
|
194502
194589
|
init = init.expression;
|
|
194503
|
-
if (!
|
|
194590
|
+
if (!import_typescript12.default.isObjectLiteralExpression(init))
|
|
194504
194591
|
continue;
|
|
194505
194592
|
const members = new Map;
|
|
194506
194593
|
for (const prop of init.properties) {
|
|
194507
|
-
if (
|
|
194594
|
+
if (import_typescript12.default.isShorthandPropertyAssignment(prop)) {
|
|
194508
194595
|
members.set(prop.name.text, prop.name.text);
|
|
194509
|
-
} else if (
|
|
194596
|
+
} else if (import_typescript12.default.isPropertyAssignment(prop) && (import_typescript12.default.isIdentifier(prop.name) || import_typescript12.default.isStringLiteral(prop.name)) && import_typescript12.default.isIdentifier(prop.initializer)) {
|
|
194510
194597
|
members.set(prop.name.text, prop.initializer.text);
|
|
194511
194598
|
}
|
|
194512
194599
|
}
|
|
@@ -194518,11 +194605,11 @@ function buildComponentNamespaces(ctx) {
|
|
|
194518
194605
|
return result;
|
|
194519
194606
|
}
|
|
194520
194607
|
function resolveMemberExpressionTag(tagNode, ctx) {
|
|
194521
|
-
if (!
|
|
194608
|
+
if (!import_typescript12.default.isPropertyAccessExpression(tagNode))
|
|
194522
194609
|
return null;
|
|
194523
|
-
if (!
|
|
194610
|
+
if (!import_typescript12.default.isIdentifier(tagNode.expression))
|
|
194524
194611
|
return null;
|
|
194525
|
-
if (!
|
|
194612
|
+
if (!import_typescript12.default.isIdentifier(tagNode.name))
|
|
194526
194613
|
return null;
|
|
194527
194614
|
if (!ctx._componentNamespaces) {
|
|
194528
194615
|
ctx._componentNamespaces = buildComponentNamespaces(ctx);
|
|
@@ -194678,7 +194765,7 @@ function buildIRRoot(analyzer) {
|
|
|
194678
194765
|
return null;
|
|
194679
194766
|
const ctx = createTransformContext(analyzer);
|
|
194680
194767
|
const jsxReturn = analyzer.jsxReturn;
|
|
194681
|
-
if (
|
|
194768
|
+
if (import_typescript12.default.isJsxElement(jsxReturn) || import_typescript12.default.isJsxSelfClosingElement(jsxReturn) || import_typescript12.default.isJsxFragment(jsxReturn)) {
|
|
194682
194769
|
const ir2 = transformNode(jsxReturn, ctx);
|
|
194683
194770
|
if (ir2 && needsScopeWrapper(ir2)) {
|
|
194684
194771
|
return wrapInScopeElement(ir2);
|
|
@@ -194734,22 +194821,22 @@ function wrapInScopeElement(node) {
|
|
|
194734
194821
|
};
|
|
194735
194822
|
}
|
|
194736
194823
|
function transformNode(node, ctx) {
|
|
194737
|
-
if (
|
|
194824
|
+
if (import_typescript12.default.isJsxElement(node)) {
|
|
194738
194825
|
return transformJsxElement(node, ctx);
|
|
194739
194826
|
}
|
|
194740
|
-
if (
|
|
194827
|
+
if (import_typescript12.default.isJsxSelfClosingElement(node)) {
|
|
194741
194828
|
return transformSelfClosingElement(node, ctx);
|
|
194742
194829
|
}
|
|
194743
|
-
if (
|
|
194830
|
+
if (import_typescript12.default.isJsxFragment(node)) {
|
|
194744
194831
|
return transformFragment(node, ctx);
|
|
194745
194832
|
}
|
|
194746
|
-
if (
|
|
194833
|
+
if (import_typescript12.default.isJsxText(node)) {
|
|
194747
194834
|
return transformText(node, ctx);
|
|
194748
194835
|
}
|
|
194749
|
-
if (
|
|
194836
|
+
if (import_typescript12.default.isJsxExpression(node)) {
|
|
194750
194837
|
return transformExpression(node, ctx);
|
|
194751
194838
|
}
|
|
194752
|
-
if (
|
|
194839
|
+
if (import_typescript12.default.isConditionalExpression(node)) {
|
|
194753
194840
|
return transformConditional(node, ctx);
|
|
194754
194841
|
}
|
|
194755
194842
|
return null;
|
|
@@ -194850,17 +194937,23 @@ function lowerFormControlValueSsr(tagName, attrs, children) {
|
|
|
194850
194937
|
});
|
|
194851
194938
|
return;
|
|
194852
194939
|
}
|
|
194853
|
-
const
|
|
194940
|
+
const selectedForLiteral = (optValue) => AttrValueOf.expression(`(${expr}) === ${JSON.stringify(optValue)}`, templateExpr !== undefined ? { templateExpr: `(${templateExpr}) === ${JSON.stringify(optValue)}` } : undefined);
|
|
194941
|
+
const selectedForExpr = (optExpr, optTemplateExpr) => AttrValueOf.expression(`(${expr}) === (${optExpr})`, templateExpr !== undefined || optTemplateExpr !== undefined ? { templateExpr: `(${templateExpr ?? expr}) === (${optTemplateExpr ?? optExpr})` } : undefined);
|
|
194854
194942
|
const distribute = (nodes) => {
|
|
194855
194943
|
for (const n of nodes) {
|
|
194856
194944
|
if (n.type === "element" && n.tag === "option") {
|
|
194857
194945
|
if (n.attrs.some((a) => a.name === "selected"))
|
|
194858
194946
|
continue;
|
|
194859
194947
|
const optValue = n.attrs.find((a) => a.name === "value");
|
|
194860
|
-
if (!optValue
|
|
194948
|
+
if (!optValue)
|
|
194861
194949
|
continue;
|
|
194862
|
-
|
|
194863
|
-
|
|
194950
|
+
if (optValue.value.kind === "literal") {
|
|
194951
|
+
n.attrs.push({ name: "selected", value: selectedForLiteral(optValue.value.value), loc: n.loc });
|
|
194952
|
+
} else if (optValue.value.kind === "expression") {
|
|
194953
|
+
const selected = selectedForExpr(optValue.value.expr, optValue.value.templateExpr);
|
|
194954
|
+
n.attrs.push({ name: "selected", value: selected, loc: n.loc });
|
|
194955
|
+
}
|
|
194956
|
+
} else if (n.type === "fragment" || n.type === "loop" || n.type === "element" && n.tag === "optgroup") {
|
|
194864
194957
|
distribute(n.children);
|
|
194865
194958
|
}
|
|
194866
194959
|
}
|
|
@@ -195100,7 +195193,7 @@ function transformSelfClosingComponent(node, ctx, name) {
|
|
|
195100
195193
|
}
|
|
195101
195194
|
function isTransparentFragment(node, ctx) {
|
|
195102
195195
|
const children = node.children.filter((child2) => {
|
|
195103
|
-
if (
|
|
195196
|
+
if (import_typescript12.default.isJsxText(child2)) {
|
|
195104
195197
|
return child2.text.trim() !== "";
|
|
195105
195198
|
}
|
|
195106
195199
|
return true;
|
|
@@ -195108,7 +195201,7 @@ function isTransparentFragment(node, ctx) {
|
|
|
195108
195201
|
if (children.length !== 1)
|
|
195109
195202
|
return false;
|
|
195110
195203
|
const child = children[0];
|
|
195111
|
-
if (!
|
|
195204
|
+
if (!import_typescript12.default.isJsxExpression(child))
|
|
195112
195205
|
return false;
|
|
195113
195206
|
if (!child.expression)
|
|
195114
195207
|
return false;
|
|
@@ -195152,7 +195245,7 @@ function transformChildren(children, ctx) {
|
|
|
195152
195245
|
const result = [];
|
|
195153
195246
|
for (let i2 = 0;i2 < children.length; i2++) {
|
|
195154
195247
|
const child = children[i2];
|
|
195155
|
-
if (
|
|
195248
|
+
if (import_typescript12.default.isJsxExpression(child) && !child.expression) {
|
|
195156
195249
|
continue;
|
|
195157
195250
|
}
|
|
195158
195251
|
const transformed = transformNode(child, ctx);
|
|
@@ -195167,10 +195260,10 @@ function transformChildren(children, ctx) {
|
|
|
195167
195260
|
}
|
|
195168
195261
|
function isRenderNothingLiteral(expr, ctx) {
|
|
195169
195262
|
let e = expr;
|
|
195170
|
-
while (
|
|
195263
|
+
while (import_typescript12.default.isParenthesizedExpression(e) || import_typescript12.default.isAsExpression(e) || import_typescript12.default.isSatisfiesExpression(e) || import_typescript12.default.isNonNullExpression(e)) {
|
|
195171
195264
|
e = e.expression;
|
|
195172
195265
|
}
|
|
195173
|
-
return e.kind ===
|
|
195266
|
+
return e.kind === import_typescript12.default.SyntaxKind.NullKeyword || e.kind === import_typescript12.default.SyntaxKind.TrueKeyword || e.kind === import_typescript12.default.SyntaxKind.FalseKeyword || import_typescript12.default.isIdentifier(e) && e.text === "undefined" && !isNameBound("undefined", makeBindingEnv(ctx));
|
|
195174
195267
|
}
|
|
195175
195268
|
function transformText(node, ctx) {
|
|
195176
195269
|
const text = node.text.replace(/\s+/g, " ");
|
|
@@ -195196,7 +195289,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
|
|
|
195196
195289
|
return null;
|
|
195197
195290
|
}
|
|
195198
195291
|
checkBareSignalOrMemoIdentifier(expr, ctx);
|
|
195199
|
-
if (
|
|
195292
|
+
if (import_typescript12.default.isIdentifier(expr)) {
|
|
195200
195293
|
const jsxNode = ctx.analyzer.jsxConstants.get(expr.text);
|
|
195201
195294
|
if (jsxNode) {
|
|
195202
195295
|
return transformNode(jsxNode, ctx);
|
|
@@ -195474,38 +195567,38 @@ function transformLogicalAnd(node, ctx) {
|
|
|
195474
195567
|
};
|
|
195475
195568
|
}
|
|
195476
195569
|
function containsJsxInExpression(node) {
|
|
195477
|
-
if (
|
|
195570
|
+
if (import_typescript12.default.isJsxElement(node) || import_typescript12.default.isJsxSelfClosingElement(node) || import_typescript12.default.isJsxFragment(node)) {
|
|
195478
195571
|
return true;
|
|
195479
195572
|
}
|
|
195480
|
-
return
|
|
195573
|
+
return import_typescript12.default.forEachChild(node, containsJsxInExpression) ?? false;
|
|
195481
195574
|
}
|
|
195482
195575
|
function callsJsxHelper(node, ctx) {
|
|
195483
195576
|
let found = false;
|
|
195484
195577
|
const visit2 = (n) => {
|
|
195485
195578
|
if (found)
|
|
195486
195579
|
return;
|
|
195487
|
-
if (
|
|
195580
|
+
if (import_typescript12.default.isCallExpression(n) && import_typescript12.default.isIdentifier(n.expression)) {
|
|
195488
195581
|
const name = n.expression.text;
|
|
195489
195582
|
if (ctx.analyzer.jsxFunctions.has(name) || ctx.analyzer.jsxMultiReturnFunctions.has(name)) {
|
|
195490
195583
|
found = true;
|
|
195491
195584
|
return;
|
|
195492
195585
|
}
|
|
195493
195586
|
}
|
|
195494
|
-
|
|
195587
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
195495
195588
|
};
|
|
195496
195589
|
visit2(node);
|
|
195497
195590
|
return found;
|
|
195498
195591
|
}
|
|
195499
195592
|
function containsAwaitExpression(node) {
|
|
195500
|
-
if (
|
|
195593
|
+
if (import_typescript12.default.isAwaitExpression(node))
|
|
195501
195594
|
return true;
|
|
195502
|
-
if (
|
|
195595
|
+
if (import_typescript12.default.isFunctionDeclaration(node) || import_typescript12.default.isFunctionExpression(node) || import_typescript12.default.isArrowFunction(node))
|
|
195503
195596
|
return false;
|
|
195504
|
-
return
|
|
195597
|
+
return import_typescript12.default.forEachChild(node, containsAwaitExpression) ?? false;
|
|
195505
195598
|
}
|
|
195506
195599
|
function transformNullishCoalescing(node, ctx) {
|
|
195507
195600
|
const leftText = ctx.getJS(node.left);
|
|
195508
|
-
const isNullish = node.operatorToken.kind ===
|
|
195601
|
+
const isNullish = node.operatorToken.kind === import_typescript12.default.SyntaxKind.QuestionQuestionToken;
|
|
195509
195602
|
const condition = isNullish ? `${leftText} != null` : leftText;
|
|
195510
195603
|
const leftOrigin = {
|
|
195511
195604
|
phase: "tick",
|
|
@@ -195551,36 +195644,36 @@ function transformNullishCoalescing(node, ctx) {
|
|
|
195551
195644
|
}
|
|
195552
195645
|
function assertNever2(expr) {
|
|
195553
195646
|
const kind = expr?.kind;
|
|
195554
|
-
throw new Error(`transformJsxExpression: unhandled ts.SyntaxKind ${kind !== undefined ?
|
|
195647
|
+
throw new Error(`transformJsxExpression: unhandled ts.SyntaxKind ${kind !== undefined ? import_typescript12.default.SyntaxKind[kind] : "unknown"} ` + `(kind=${kind}). Update spec/compiler.md Appendix A and the switch in jsx-to-ir.ts.`);
|
|
195555
195648
|
}
|
|
195556
195649
|
function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
195557
195650
|
const node = expr;
|
|
195558
195651
|
switch (node.kind) {
|
|
195559
|
-
case
|
|
195560
|
-
case
|
|
195561
|
-
case
|
|
195562
|
-
case
|
|
195563
|
-
case
|
|
195564
|
-
case
|
|
195652
|
+
case import_typescript12.default.SyntaxKind.ParenthesizedExpression:
|
|
195653
|
+
case import_typescript12.default.SyntaxKind.AsExpression:
|
|
195654
|
+
case import_typescript12.default.SyntaxKind.SatisfiesExpression:
|
|
195655
|
+
case import_typescript12.default.SyntaxKind.NonNullExpression:
|
|
195656
|
+
case import_typescript12.default.SyntaxKind.TypeAssertionExpression:
|
|
195657
|
+
case import_typescript12.default.SyntaxKind.PartiallyEmittedExpression:
|
|
195565
195658
|
return transformJsxExpression(node.expression, ctx, isClientOnly);
|
|
195566
|
-
case
|
|
195659
|
+
case import_typescript12.default.SyntaxKind.JsxElement:
|
|
195567
195660
|
return transformJsxElement(node, ctx);
|
|
195568
|
-
case
|
|
195661
|
+
case import_typescript12.default.SyntaxKind.JsxFragment:
|
|
195569
195662
|
return transformFragment(node, ctx);
|
|
195570
|
-
case
|
|
195663
|
+
case import_typescript12.default.SyntaxKind.JsxSelfClosingElement:
|
|
195571
195664
|
return transformSelfClosingElement(node, ctx);
|
|
195572
|
-
case
|
|
195665
|
+
case import_typescript12.default.SyntaxKind.ConditionalExpression:
|
|
195573
195666
|
return transformConditional(node, ctx);
|
|
195574
|
-
case
|
|
195575
|
-
if (node.operatorToken.kind ===
|
|
195667
|
+
case import_typescript12.default.SyntaxKind.BinaryExpression: {
|
|
195668
|
+
if (node.operatorToken.kind === import_typescript12.default.SyntaxKind.AmpersandAmpersandToken) {
|
|
195576
195669
|
return transformLogicalAnd(node, ctx);
|
|
195577
195670
|
}
|
|
195578
|
-
if ((node.operatorToken.kind ===
|
|
195671
|
+
if ((node.operatorToken.kind === import_typescript12.default.SyntaxKind.QuestionQuestionToken || node.operatorToken.kind === import_typescript12.default.SyntaxKind.BarBarToken) && (containsJsxInExpression(node.right) || callsJsxHelper(node.right, ctx))) {
|
|
195579
195672
|
return transformNullishCoalescing(node, ctx);
|
|
195580
195673
|
}
|
|
195581
195674
|
return null;
|
|
195582
195675
|
}
|
|
195583
|
-
case
|
|
195676
|
+
case import_typescript12.default.SyntaxKind.CallExpression: {
|
|
195584
195677
|
const mapMethod = getMapLikeMethod(node);
|
|
195585
195678
|
if (mapMethod) {
|
|
195586
195679
|
const mapResult = transformMapCall(node, ctx, isClientOnly, mapMethod);
|
|
@@ -195588,7 +195681,7 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
195588
195681
|
return mapResult;
|
|
195589
195682
|
}
|
|
195590
195683
|
const callee = node.expression;
|
|
195591
|
-
if (
|
|
195684
|
+
if (import_typescript12.default.isIdentifier(callee)) {
|
|
195592
195685
|
const jsxFunc = ctx.analyzer.jsxFunctions.get(callee.text);
|
|
195593
195686
|
if (jsxFunc) {
|
|
195594
195687
|
return transformJsxFunctionCall(node, jsxFunc, ctx, isClientOnly);
|
|
@@ -195600,39 +195693,39 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
195600
195693
|
}
|
|
195601
195694
|
return null;
|
|
195602
195695
|
}
|
|
195603
|
-
case
|
|
195604
|
-
case
|
|
195605
|
-
case
|
|
195606
|
-
case
|
|
195607
|
-
case
|
|
195608
|
-
case
|
|
195609
|
-
case
|
|
195610
|
-
case
|
|
195611
|
-
case
|
|
195612
|
-
case
|
|
195613
|
-
case
|
|
195614
|
-
case
|
|
195615
|
-
case
|
|
195616
|
-
case
|
|
195617
|
-
case
|
|
195618
|
-
case
|
|
195619
|
-
case
|
|
195620
|
-
case
|
|
195621
|
-
case
|
|
195622
|
-
case
|
|
195623
|
-
case
|
|
195624
|
-
case
|
|
195625
|
-
case
|
|
195626
|
-
case
|
|
195627
|
-
case
|
|
195628
|
-
case
|
|
195629
|
-
case
|
|
195630
|
-
case
|
|
195631
|
-
case
|
|
195632
|
-
case
|
|
195633
|
-
case
|
|
195696
|
+
case import_typescript12.default.SyntaxKind.Identifier:
|
|
195697
|
+
case import_typescript12.default.SyntaxKind.StringLiteral:
|
|
195698
|
+
case import_typescript12.default.SyntaxKind.NumericLiteral:
|
|
195699
|
+
case import_typescript12.default.SyntaxKind.BigIntLiteral:
|
|
195700
|
+
case import_typescript12.default.SyntaxKind.RegularExpressionLiteral:
|
|
195701
|
+
case import_typescript12.default.SyntaxKind.NoSubstitutionTemplateLiteral:
|
|
195702
|
+
case import_typescript12.default.SyntaxKind.TemplateExpression:
|
|
195703
|
+
case import_typescript12.default.SyntaxKind.TaggedTemplateExpression:
|
|
195704
|
+
case import_typescript12.default.SyntaxKind.TrueKeyword:
|
|
195705
|
+
case import_typescript12.default.SyntaxKind.FalseKeyword:
|
|
195706
|
+
case import_typescript12.default.SyntaxKind.NullKeyword:
|
|
195707
|
+
case import_typescript12.default.SyntaxKind.ThisKeyword:
|
|
195708
|
+
case import_typescript12.default.SyntaxKind.SuperKeyword:
|
|
195709
|
+
case import_typescript12.default.SyntaxKind.ImportKeyword:
|
|
195710
|
+
case import_typescript12.default.SyntaxKind.PropertyAccessExpression:
|
|
195711
|
+
case import_typescript12.default.SyntaxKind.ElementAccessExpression:
|
|
195712
|
+
case import_typescript12.default.SyntaxKind.PrefixUnaryExpression:
|
|
195713
|
+
case import_typescript12.default.SyntaxKind.PostfixUnaryExpression:
|
|
195714
|
+
case import_typescript12.default.SyntaxKind.TypeOfExpression:
|
|
195715
|
+
case import_typescript12.default.SyntaxKind.VoidExpression:
|
|
195716
|
+
case import_typescript12.default.SyntaxKind.DeleteExpression:
|
|
195717
|
+
case import_typescript12.default.SyntaxKind.NewExpression:
|
|
195718
|
+
case import_typescript12.default.SyntaxKind.ObjectLiteralExpression:
|
|
195719
|
+
case import_typescript12.default.SyntaxKind.ArrowFunction:
|
|
195720
|
+
case import_typescript12.default.SyntaxKind.FunctionExpression:
|
|
195721
|
+
case import_typescript12.default.SyntaxKind.ClassExpression:
|
|
195722
|
+
case import_typescript12.default.SyntaxKind.MetaProperty:
|
|
195723
|
+
case import_typescript12.default.SyntaxKind.ExpressionWithTypeArguments:
|
|
195724
|
+
case import_typescript12.default.SyntaxKind.CommaListExpression:
|
|
195725
|
+
case import_typescript12.default.SyntaxKind.SyntheticExpression:
|
|
195726
|
+
case import_typescript12.default.SyntaxKind.ArrayLiteralExpression:
|
|
195634
195727
|
return null;
|
|
195635
|
-
case
|
|
195728
|
+
case import_typescript12.default.SyntaxKind.AwaitExpression:
|
|
195636
195729
|
ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(node, ctx.sourceFile, ctx.filePath)));
|
|
195637
195730
|
return {
|
|
195638
195731
|
type: "expression",
|
|
@@ -195643,16 +195736,16 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
195643
195736
|
loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
|
|
195644
195737
|
origin: { phase: "tick", scope: "template", effect: "pure", freeRefs: [] }
|
|
195645
195738
|
};
|
|
195646
|
-
case
|
|
195739
|
+
case import_typescript12.default.SyntaxKind.YieldExpression:
|
|
195647
195740
|
return null;
|
|
195648
|
-
case
|
|
195649
|
-
case
|
|
195650
|
-
case
|
|
195651
|
-
case
|
|
195652
|
-
case
|
|
195653
|
-
case
|
|
195654
|
-
case
|
|
195655
|
-
case
|
|
195741
|
+
case import_typescript12.default.SyntaxKind.SpreadElement:
|
|
195742
|
+
case import_typescript12.default.SyntaxKind.OmittedExpression:
|
|
195743
|
+
case import_typescript12.default.SyntaxKind.JsxExpression:
|
|
195744
|
+
case import_typescript12.default.SyntaxKind.JsxOpeningElement:
|
|
195745
|
+
case import_typescript12.default.SyntaxKind.JsxOpeningFragment:
|
|
195746
|
+
case import_typescript12.default.SyntaxKind.JsxClosingFragment:
|
|
195747
|
+
case import_typescript12.default.SyntaxKind.JsxAttributes:
|
|
195748
|
+
case import_typescript12.default.SyntaxKind.MissingDeclaration:
|
|
195656
195749
|
return null;
|
|
195657
195750
|
default:
|
|
195658
195751
|
return assertNever2(node);
|
|
@@ -195689,7 +195782,7 @@ function transformConditionalBranch(node, ctx) {
|
|
|
195689
195782
|
};
|
|
195690
195783
|
}
|
|
195691
195784
|
function getMapLikeMethod(node) {
|
|
195692
|
-
if (!
|
|
195785
|
+
if (!import_typescript12.default.isPropertyAccessExpression(node.expression))
|
|
195693
195786
|
return null;
|
|
195694
195787
|
const name = node.expression.name.text;
|
|
195695
195788
|
if (name === "map")
|
|
@@ -195699,9 +195792,9 @@ function getMapLikeMethod(node) {
|
|
|
195699
195792
|
return null;
|
|
195700
195793
|
}
|
|
195701
195794
|
function isFilterCall(node) {
|
|
195702
|
-
if (!
|
|
195795
|
+
if (!import_typescript12.default.isCallExpression(node))
|
|
195703
195796
|
return null;
|
|
195704
|
-
if (!
|
|
195797
|
+
if (!import_typescript12.default.isPropertyAccessExpression(node.expression))
|
|
195705
195798
|
return null;
|
|
195706
195799
|
if (node.expression.name.text !== "filter")
|
|
195707
195800
|
return null;
|
|
@@ -195713,9 +195806,9 @@ function isFilterCall(node) {
|
|
|
195713
195806
|
};
|
|
195714
195807
|
}
|
|
195715
195808
|
function isSortCall(node) {
|
|
195716
|
-
if (!
|
|
195809
|
+
if (!import_typescript12.default.isCallExpression(node))
|
|
195717
195810
|
return null;
|
|
195718
|
-
if (!
|
|
195811
|
+
if (!import_typescript12.default.isPropertyAccessExpression(node.expression))
|
|
195719
195812
|
return null;
|
|
195720
195813
|
const methodName = node.expression.name.text;
|
|
195721
195814
|
if (methodName !== "sort" && methodName !== "toSorted")
|
|
@@ -195729,9 +195822,9 @@ function isSortCall(node) {
|
|
|
195729
195822
|
};
|
|
195730
195823
|
}
|
|
195731
195824
|
function isIteratorShapeCall(node) {
|
|
195732
|
-
if (!
|
|
195825
|
+
if (!import_typescript12.default.isCallExpression(node))
|
|
195733
195826
|
return null;
|
|
195734
|
-
if (!
|
|
195827
|
+
if (!import_typescript12.default.isPropertyAccessExpression(node.expression))
|
|
195735
195828
|
return null;
|
|
195736
195829
|
if (node.arguments.length !== 0)
|
|
195737
195830
|
return null;
|
|
@@ -195741,11 +195834,11 @@ function isIteratorShapeCall(node) {
|
|
|
195741
195834
|
return { array: node.expression.expression, shape: name };
|
|
195742
195835
|
}
|
|
195743
195836
|
function isObjectIteratorCall(node) {
|
|
195744
|
-
if (!
|
|
195837
|
+
if (!import_typescript12.default.isCallExpression(node))
|
|
195745
195838
|
return null;
|
|
195746
|
-
if (!
|
|
195839
|
+
if (!import_typescript12.default.isPropertyAccessExpression(node.expression))
|
|
195747
195840
|
return null;
|
|
195748
|
-
if (!
|
|
195841
|
+
if (!import_typescript12.default.isIdentifier(node.expression.expression))
|
|
195749
195842
|
return null;
|
|
195750
195843
|
if (node.expression.expression.text !== "Object")
|
|
195751
195844
|
return null;
|
|
@@ -195770,7 +195863,7 @@ function extractSortComparator(callback, _method, ctx) {
|
|
|
195770
195863
|
` + `(reverse the operands for descending order).`
|
|
195771
195864
|
});
|
|
195772
195865
|
let resolvedNode = callback;
|
|
195773
|
-
if (
|
|
195866
|
+
if (import_typescript12.default.isIdentifier(callback)) {
|
|
195774
195867
|
const resolved = resolveSortComparatorIdentifier(callback.text, ctx);
|
|
195775
195868
|
if (!resolved) {
|
|
195776
195869
|
return {
|
|
@@ -195780,7 +195873,7 @@ function extractSortComparator(callback, _method, ctx) {
|
|
|
195780
195873
|
}
|
|
195781
195874
|
resolvedNode = resolved;
|
|
195782
195875
|
}
|
|
195783
|
-
if (!
|
|
195876
|
+
if (!import_typescript12.default.isArrowFunction(resolvedNode) && !import_typescript12.default.isFunctionExpression(resolvedNode)) {
|
|
195784
195877
|
return {
|
|
195785
195878
|
result: null,
|
|
195786
195879
|
unsupportedReason: "Sort comparator must be an arrow function or function expression"
|
|
@@ -195807,11 +195900,11 @@ function resolveSortComparatorIdentifier(name, ctx) {
|
|
|
195807
195900
|
return null;
|
|
195808
195901
|
if (constInfo) {
|
|
195809
195902
|
const ast = parseConstInitializer(constInfo);
|
|
195810
|
-
return ast && (
|
|
195903
|
+
return ast && (import_typescript12.default.isArrowFunction(ast) || import_typescript12.default.isFunctionExpression(ast)) ? ast : null;
|
|
195811
195904
|
}
|
|
195812
195905
|
if (fnInfo) {
|
|
195813
195906
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
195814
|
-
return ast && (
|
|
195907
|
+
return ast && (import_typescript12.default.isArrowFunction(ast) || import_typescript12.default.isFunctionExpression(ast)) ? ast : null;
|
|
195815
195908
|
}
|
|
195816
195909
|
return null;
|
|
195817
195910
|
}
|
|
@@ -195822,11 +195915,11 @@ function resolveCallbackMethodFunctionReferenceIdentifier(name, analyzer) {
|
|
|
195822
195915
|
return null;
|
|
195823
195916
|
if (constInfo) {
|
|
195824
195917
|
const ast = parseConstInitializer(constInfo);
|
|
195825
|
-
return ast && (
|
|
195918
|
+
return ast && (import_typescript12.default.isArrowFunction(ast) || import_typescript12.default.isFunctionExpression(ast)) ? ast : null;
|
|
195826
195919
|
}
|
|
195827
195920
|
if (fnInfo) {
|
|
195828
195921
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
195829
|
-
return ast && (
|
|
195922
|
+
return ast && (import_typescript12.default.isArrowFunction(ast) || import_typescript12.default.isFunctionExpression(ast)) ? ast : null;
|
|
195830
195923
|
}
|
|
195831
195924
|
return null;
|
|
195832
195925
|
}
|
|
@@ -195882,13 +195975,13 @@ function resolveCallbackMethodFunctionReferences(expr, analyzer, bound = EMPTY_B
|
|
|
195882
195975
|
return visit2(expr, bound);
|
|
195883
195976
|
}
|
|
195884
195977
|
function extractFilterPredicate(callback, ctx) {
|
|
195885
|
-
if (!
|
|
195978
|
+
if (!import_typescript12.default.isArrowFunction(callback))
|
|
195886
195979
|
return { result: null };
|
|
195887
195980
|
if (callback.parameters.length < 1)
|
|
195888
195981
|
return { result: null };
|
|
195889
195982
|
const firstParam = callback.parameters[0];
|
|
195890
|
-
if (!
|
|
195891
|
-
if (
|
|
195983
|
+
if (!import_typescript12.default.isIdentifier(firstParam.name)) {
|
|
195984
|
+
if (import_typescript12.default.isBlock(callback.body)) {
|
|
195892
195985
|
return {
|
|
195893
195986
|
result: null,
|
|
195894
195987
|
unsupportedReason: "Block body in a destructured filter param is not supported. Workaround: use an expression-body arrow, or add /* @client */."
|
|
@@ -195908,7 +196001,7 @@ function extractFilterPredicate(callback, ctx) {
|
|
|
195908
196001
|
return { result: null };
|
|
195909
196002
|
}
|
|
195910
196003
|
const param = firstParam.name.getText(ctx.sourceFile);
|
|
195911
|
-
if (
|
|
196004
|
+
if (import_typescript12.default.isBlock(callback.body)) {
|
|
195912
196005
|
const raw2 = ctx.getJS(callback.body);
|
|
195913
196006
|
const statements = parseBlockBody(callback.body, ctx.sourceFile, (n) => ctx.getJS(n));
|
|
195914
196007
|
if (!statements) {
|
|
@@ -195934,7 +196027,7 @@ function extractFilterPredicate(callback, ctx) {
|
|
|
195934
196027
|
return { result: { param, predicate, raw } };
|
|
195935
196028
|
}
|
|
195936
196029
|
function extractLoopParamBindings(pattern) {
|
|
195937
|
-
if (
|
|
196030
|
+
if (import_typescript12.default.isIdentifier(pattern))
|
|
195938
196031
|
return null;
|
|
195939
196032
|
const bindings = [];
|
|
195940
196033
|
let unsupported = false;
|
|
@@ -195943,7 +196036,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
195943
196036
|
return false;
|
|
195944
196037
|
for (let i2 = 0;i2 < key.length; ) {
|
|
195945
196038
|
const cp = key.codePointAt(i2);
|
|
195946
|
-
const ok = i2 === 0 ?
|
|
196039
|
+
const ok = i2 === 0 ? import_typescript12.default.isIdentifierStart(cp, import_typescript12.default.ScriptTarget.Latest) : import_typescript12.default.isIdentifierPart(cp, import_typescript12.default.ScriptTarget.Latest);
|
|
195947
196040
|
if (!ok)
|
|
195948
196041
|
return false;
|
|
195949
196042
|
i2 += cp > 65535 ? 2 : 1;
|
|
@@ -195956,17 +196049,17 @@ function extractLoopParamBindings(pattern) {
|
|
|
195956
196049
|
const walk = (p, prefix, segments) => {
|
|
195957
196050
|
if (unsupported)
|
|
195958
196051
|
return;
|
|
195959
|
-
if (
|
|
196052
|
+
if (import_typescript12.default.isArrayBindingPattern(p)) {
|
|
195960
196053
|
const elements2 = p.elements;
|
|
195961
196054
|
for (let index = 0;index < elements2.length; index++) {
|
|
195962
196055
|
if (unsupported)
|
|
195963
196056
|
return;
|
|
195964
196057
|
const el = elements2[index];
|
|
195965
|
-
if (
|
|
196058
|
+
if (import_typescript12.default.isOmittedExpression(el))
|
|
195966
196059
|
continue;
|
|
195967
196060
|
if (el.dotDotDotToken) {
|
|
195968
196061
|
internalInvariant(index === elements2.length - 1, "extractLoopParamBindings: array rest token in non-final position (parser should reject)");
|
|
195969
|
-
internalInvariant(
|
|
196062
|
+
internalInvariant(import_typescript12.default.isIdentifier(el.name), "extractLoopParamBindings: array rest target is not an identifier (parser should reject)");
|
|
195970
196063
|
bindings.push({
|
|
195971
196064
|
name: el.name.text,
|
|
195972
196065
|
path: prefix,
|
|
@@ -195977,7 +196070,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
195977
196070
|
}
|
|
195978
196071
|
const path = `${prefix}[${index}]`;
|
|
195979
196072
|
const nextSegments = [...segments, { kind: "index", index }];
|
|
195980
|
-
if (
|
|
196073
|
+
if (import_typescript12.default.isIdentifier(el.name)) {
|
|
195981
196074
|
bindings.push({ name: el.name.text, path, segments: nextSegments });
|
|
195982
196075
|
} else {
|
|
195983
196076
|
walk(el.name, path, nextSegments);
|
|
@@ -195993,7 +196086,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
195993
196086
|
const el = elements[i2];
|
|
195994
196087
|
if (el.dotDotDotToken) {
|
|
195995
196088
|
internalInvariant(i2 === elements.length - 1, "extractLoopParamBindings: object rest token in non-final position (parser should reject)");
|
|
195996
|
-
internalInvariant(
|
|
196089
|
+
internalInvariant(import_typescript12.default.isIdentifier(el.name), "extractLoopParamBindings: object rest target is not an identifier (parser should reject)");
|
|
195997
196090
|
bindings.push({
|
|
195998
196091
|
name: el.name.text,
|
|
195999
196092
|
path: prefix,
|
|
@@ -196005,17 +196098,17 @@ function extractLoopParamBindings(pattern) {
|
|
|
196005
196098
|
let keyText = null;
|
|
196006
196099
|
if (el.propertyName) {
|
|
196007
196100
|
const pn = el.propertyName;
|
|
196008
|
-
if (
|
|
196101
|
+
if (import_typescript12.default.isIdentifier(pn))
|
|
196009
196102
|
keyText = pn.text;
|
|
196010
|
-
else if (
|
|
196103
|
+
else if (import_typescript12.default.isStringLiteral(pn))
|
|
196011
196104
|
keyText = pn.text;
|
|
196012
|
-
else if (
|
|
196105
|
+
else if (import_typescript12.default.isNumericLiteral(pn))
|
|
196013
196106
|
keyText = pn.text;
|
|
196014
196107
|
else {
|
|
196015
196108
|
unsupported = true;
|
|
196016
196109
|
return;
|
|
196017
196110
|
}
|
|
196018
|
-
} else if (
|
|
196111
|
+
} else if (import_typescript12.default.isIdentifier(el.name)) {
|
|
196019
196112
|
keyText = el.name.text;
|
|
196020
196113
|
} else {
|
|
196021
196114
|
unsupported = true;
|
|
@@ -196025,14 +196118,14 @@ function extractLoopParamBindings(pattern) {
|
|
|
196025
196118
|
collectedKeys.push({ key: keyText, isIdent: keyIsIdent });
|
|
196026
196119
|
const path = appendDotAccess(prefix, keyText);
|
|
196027
196120
|
const nextSegments = [...segments, { kind: "field", key: keyText, isIdent: keyIsIdent }];
|
|
196028
|
-
if (
|
|
196121
|
+
if (import_typescript12.default.isIdentifier(el.name)) {
|
|
196029
196122
|
bindings.push({ name: el.name.text, path, segments: nextSegments });
|
|
196030
196123
|
} else {
|
|
196031
196124
|
walk(el.name, path, nextSegments);
|
|
196032
196125
|
}
|
|
196033
196126
|
}
|
|
196034
196127
|
};
|
|
196035
|
-
if (
|
|
196128
|
+
if (import_typescript12.default.isArrayBindingPattern(pattern) || import_typescript12.default.isObjectBindingPattern(pattern)) {
|
|
196036
196129
|
walk(pattern, "", []);
|
|
196037
196130
|
if (unsupported)
|
|
196038
196131
|
return { unsupported: true };
|
|
@@ -196042,7 +196135,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
196042
196135
|
}
|
|
196043
196136
|
function findKeyJsxAttribute(opening) {
|
|
196044
196137
|
for (const prop of opening.attributes.properties) {
|
|
196045
|
-
if (
|
|
196138
|
+
if (import_typescript12.default.isJsxAttribute(prop) && prop.name.getText() === "key") {
|
|
196046
196139
|
return prop;
|
|
196047
196140
|
}
|
|
196048
196141
|
}
|
|
@@ -196087,7 +196180,7 @@ function keyAttrValueToExpr(v) {
|
|
|
196087
196180
|
function normalizeKeyExpr(expr) {
|
|
196088
196181
|
let out = "";
|
|
196089
196182
|
for (const tok of iterateJsTokens(expr)) {
|
|
196090
|
-
if (tok.kind ===
|
|
196183
|
+
if (tok.kind === import_typescript12.default.SyntaxKind.WhitespaceTrivia || tok.kind === import_typescript12.default.SyntaxKind.NewLineTrivia) {
|
|
196091
196184
|
continue;
|
|
196092
196185
|
}
|
|
196093
196186
|
out += expr.slice(tok.pos, tok.end);
|
|
@@ -196099,13 +196192,13 @@ function conditionalHasExplicitNullishBranch(cond) {
|
|
|
196099
196192
|
}
|
|
196100
196193
|
function branchHasExplicitNullish(branch) {
|
|
196101
196194
|
let b = branch;
|
|
196102
|
-
while (
|
|
196195
|
+
while (import_typescript12.default.isParenthesizedExpression(b))
|
|
196103
196196
|
b = b.expression;
|
|
196104
|
-
if (b.kind ===
|
|
196197
|
+
if (b.kind === import_typescript12.default.SyntaxKind.NullKeyword)
|
|
196105
196198
|
return true;
|
|
196106
|
-
if (
|
|
196199
|
+
if (import_typescript12.default.isIdentifier(b) && b.text === "undefined")
|
|
196107
196200
|
return true;
|
|
196108
|
-
if (
|
|
196201
|
+
if (import_typescript12.default.isConditionalExpression(b))
|
|
196109
196202
|
return conditionalHasExplicitNullishBranch(b);
|
|
196110
196203
|
return false;
|
|
196111
196204
|
}
|
|
@@ -196114,26 +196207,26 @@ function classifyKeyProblem(keyAttr, checker) {
|
|
|
196114
196207
|
return "missing";
|
|
196115
196208
|
if (!keyAttr.initializer)
|
|
196116
196209
|
return "missing";
|
|
196117
|
-
if (
|
|
196210
|
+
if (import_typescript12.default.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
|
|
196118
196211
|
return "missing";
|
|
196119
196212
|
}
|
|
196120
196213
|
let expr;
|
|
196121
|
-
if (
|
|
196214
|
+
if (import_typescript12.default.isStringLiteral(keyAttr.initializer)) {
|
|
196122
196215
|
return null;
|
|
196123
|
-
} else if (
|
|
196216
|
+
} else if (import_typescript12.default.isJsxExpression(keyAttr.initializer)) {
|
|
196124
196217
|
expr = keyAttr.initializer.expression;
|
|
196125
196218
|
}
|
|
196126
196219
|
if (!expr)
|
|
196127
196220
|
return null;
|
|
196128
|
-
if (expr.kind ===
|
|
196221
|
+
if (expr.kind === import_typescript12.default.SyntaxKind.NullKeyword)
|
|
196129
196222
|
return null;
|
|
196130
|
-
if (
|
|
196223
|
+
if (import_typescript12.default.isIdentifier(expr) && expr.text === "undefined")
|
|
196131
196224
|
return null;
|
|
196132
|
-
if (
|
|
196225
|
+
if (import_typescript12.default.isConditionalExpression(expr) && conditionalHasExplicitNullishBranch(expr))
|
|
196133
196226
|
return null;
|
|
196134
196227
|
if (checker) {
|
|
196135
196228
|
const type2 = checker.getTypeAtLocation(expr);
|
|
196136
|
-
const isNullable = type2.isUnion() ? type2.types.some((t) => (t.flags & (
|
|
196229
|
+
const isNullable = type2.isUnion() ? type2.types.some((t) => (t.flags & (import_typescript12.default.TypeFlags.Null | import_typescript12.default.TypeFlags.Undefined | import_typescript12.default.TypeFlags.Void)) !== 0) : (type2.flags & (import_typescript12.default.TypeFlags.Null | import_typescript12.default.TypeFlags.Undefined | import_typescript12.default.TypeFlags.Void)) !== 0;
|
|
196137
196230
|
if (isNullable)
|
|
196138
196231
|
return "nullable-type";
|
|
196139
196232
|
}
|
|
@@ -196159,81 +196252,81 @@ function checkLoopKey(callback, ctx, isNested) {
|
|
|
196159
196252
|
ctx.analyzer.errors.push(createError(errorCode, getSourceLocation(locNode, ctx.sourceFile, ctx.filePath), { suggestion: { message: keyErrorSuggestion(problem) } }));
|
|
196160
196253
|
}
|
|
196161
196254
|
let body = callback.body;
|
|
196162
|
-
if (
|
|
196163
|
-
const ret = body.statements.find((s) =>
|
|
196255
|
+
if (import_typescript12.default.isBlock(body)) {
|
|
196256
|
+
const ret = body.statements.find((s) => import_typescript12.default.isReturnStatement(s) && s.expression != null);
|
|
196164
196257
|
if (!ret?.expression)
|
|
196165
196258
|
return;
|
|
196166
196259
|
body = ret.expression;
|
|
196167
196260
|
}
|
|
196168
|
-
while (
|
|
196261
|
+
while (import_typescript12.default.isParenthesizedExpression(body))
|
|
196169
196262
|
body = body.expression;
|
|
196170
196263
|
function checkJsxOperand(node) {
|
|
196171
196264
|
let n = node;
|
|
196172
|
-
while (
|
|
196265
|
+
while (import_typescript12.default.isParenthesizedExpression(n))
|
|
196173
196266
|
n = n.expression;
|
|
196174
|
-
if (
|
|
196267
|
+
if (import_typescript12.default.isJsxElement(n))
|
|
196175
196268
|
checkOpening(n.openingElement);
|
|
196176
|
-
else if (
|
|
196269
|
+
else if (import_typescript12.default.isJsxSelfClosingElement(n))
|
|
196177
196270
|
checkOpening(n);
|
|
196178
196271
|
}
|
|
196179
|
-
if (
|
|
196272
|
+
if (import_typescript12.default.isConditionalExpression(body)) {
|
|
196180
196273
|
checkJsxOperand(body.whenTrue);
|
|
196181
196274
|
checkJsxOperand(body.whenFalse);
|
|
196182
196275
|
return;
|
|
196183
196276
|
}
|
|
196184
|
-
if (
|
|
196277
|
+
if (import_typescript12.default.isBinaryExpression(body) && (body.operatorToken.kind === import_typescript12.default.SyntaxKind.AmpersandAmpersandToken || body.operatorToken.kind === import_typescript12.default.SyntaxKind.BarBarToken || body.operatorToken.kind === import_typescript12.default.SyntaxKind.QuestionQuestionToken)) {
|
|
196185
196278
|
checkJsxOperand(body.left);
|
|
196186
196279
|
checkJsxOperand(body.right);
|
|
196187
196280
|
return;
|
|
196188
196281
|
}
|
|
196189
|
-
if (
|
|
196282
|
+
if (import_typescript12.default.isJsxElement(body)) {
|
|
196190
196283
|
checkOpening(body.openingElement);
|
|
196191
196284
|
return;
|
|
196192
196285
|
}
|
|
196193
|
-
if (
|
|
196286
|
+
if (import_typescript12.default.isJsxSelfClosingElement(body)) {
|
|
196194
196287
|
checkOpening(body);
|
|
196195
196288
|
return;
|
|
196196
196289
|
}
|
|
196197
196290
|
}
|
|
196198
196291
|
function flatMapProjectionCall(body) {
|
|
196199
196292
|
let expr;
|
|
196200
|
-
if (
|
|
196293
|
+
if (import_typescript12.default.isBlock(body)) {
|
|
196201
196294
|
const real = body.statements;
|
|
196202
|
-
if (real.length !== 1 || !
|
|
196295
|
+
if (real.length !== 1 || !import_typescript12.default.isReturnStatement(real[0]) || !real[0].expression)
|
|
196203
196296
|
return null;
|
|
196204
196297
|
expr = real[0].expression;
|
|
196205
196298
|
} else {
|
|
196206
196299
|
expr = body;
|
|
196207
196300
|
}
|
|
196208
|
-
while (
|
|
196301
|
+
while (import_typescript12.default.isParenthesizedExpression(expr))
|
|
196209
196302
|
expr = expr.expression;
|
|
196210
|
-
if (!
|
|
196303
|
+
if (!import_typescript12.default.isCallExpression(expr))
|
|
196211
196304
|
return null;
|
|
196212
196305
|
if (!getMapLikeMethod(expr))
|
|
196213
196306
|
return null;
|
|
196214
196307
|
const cb = expr.arguments[0];
|
|
196215
|
-
if (!cb || !
|
|
196308
|
+
if (!cb || !import_typescript12.default.isArrowFunction(cb) && !import_typescript12.default.isFunctionExpression(cb))
|
|
196216
196309
|
return null;
|
|
196217
196310
|
for (const p of cb.parameters) {
|
|
196218
|
-
if (!
|
|
196311
|
+
if (!import_typescript12.default.isIdentifier(p.name))
|
|
196219
196312
|
return null;
|
|
196220
196313
|
}
|
|
196221
196314
|
let innerBody = cb.body;
|
|
196222
|
-
if (
|
|
196223
|
-
const ret = innerBody.statements.find((s) =>
|
|
196315
|
+
if (import_typescript12.default.isBlock(innerBody)) {
|
|
196316
|
+
const ret = innerBody.statements.find((s) => import_typescript12.default.isReturnStatement(s) && s.expression != null);
|
|
196224
196317
|
if (innerBody.statements.length !== 1 || !ret?.expression)
|
|
196225
196318
|
return null;
|
|
196226
196319
|
innerBody = ret.expression;
|
|
196227
196320
|
}
|
|
196228
|
-
while (
|
|
196321
|
+
while (import_typescript12.default.isParenthesizedExpression(innerBody))
|
|
196229
196322
|
innerBody = innerBody.expression;
|
|
196230
196323
|
const isElementish = (n) => {
|
|
196231
196324
|
let m = n;
|
|
196232
|
-
while (
|
|
196325
|
+
while (import_typescript12.default.isParenthesizedExpression(m))
|
|
196233
196326
|
m = m.expression;
|
|
196234
|
-
if (
|
|
196327
|
+
if (import_typescript12.default.isJsxElement(m) || import_typescript12.default.isJsxSelfClosingElement(m))
|
|
196235
196328
|
return leafIsWirelessElement(m);
|
|
196236
|
-
if (
|
|
196329
|
+
if (import_typescript12.default.isConditionalExpression(m))
|
|
196237
196330
|
return isElementish(m.whenTrue) && isElementish(m.whenFalse);
|
|
196238
196331
|
return false;
|
|
196239
196332
|
};
|
|
@@ -196246,19 +196339,19 @@ function leafIsWirelessElement(el) {
|
|
|
196246
196339
|
const visit2 = (n) => {
|
|
196247
196340
|
if (!ok)
|
|
196248
196341
|
return;
|
|
196249
|
-
if (
|
|
196342
|
+
if (import_typescript12.default.isJsxOpeningElement(n) || import_typescript12.default.isJsxSelfClosingElement(n)) {
|
|
196250
196343
|
const tagNode = n.tagName;
|
|
196251
|
-
const isIntrinsic =
|
|
196344
|
+
const isIntrinsic = import_typescript12.default.isIdentifier(tagNode) ? !/^[A-Z]/.test(tagNode.text) : import_typescript12.default.isJsxNamespacedName(tagNode);
|
|
196252
196345
|
if (!isIntrinsic) {
|
|
196253
196346
|
ok = false;
|
|
196254
196347
|
return;
|
|
196255
196348
|
}
|
|
196256
196349
|
for (const attr of n.attributes.properties) {
|
|
196257
|
-
if (
|
|
196350
|
+
if (import_typescript12.default.isJsxSpreadAttribute(attr)) {
|
|
196258
196351
|
ok = false;
|
|
196259
196352
|
return;
|
|
196260
196353
|
}
|
|
196261
|
-
if (
|
|
196354
|
+
if (import_typescript12.default.isJsxAttribute(attr)) {
|
|
196262
196355
|
const name = attr.name.getText();
|
|
196263
196356
|
if (/^on[A-Z]/.test(name)) {
|
|
196264
196357
|
ok = false;
|
|
@@ -196267,11 +196360,11 @@ function leafIsWirelessElement(el) {
|
|
|
196267
196360
|
}
|
|
196268
196361
|
}
|
|
196269
196362
|
}
|
|
196270
|
-
if (
|
|
196363
|
+
if (import_typescript12.default.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
|
|
196271
196364
|
ok = false;
|
|
196272
196365
|
return;
|
|
196273
196366
|
}
|
|
196274
|
-
|
|
196367
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
196275
196368
|
};
|
|
196276
196369
|
visit2(el);
|
|
196277
196370
|
return ok;
|
|
@@ -196451,7 +196544,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196451
196544
|
let children = [];
|
|
196452
196545
|
let paramBindings;
|
|
196453
196546
|
let flatMapCallback;
|
|
196454
|
-
if (
|
|
196547
|
+
if (import_typescript12.default.isArrowFunction(callback)) {
|
|
196455
196548
|
if (callback.parameters.length > 0) {
|
|
196456
196549
|
const firstParam = callback.parameters[0];
|
|
196457
196550
|
param = firstParam.name.getText(ctx.sourceFile);
|
|
@@ -196459,9 +196552,9 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196459
196552
|
paramType = firstParam.type.getText(ctx.sourceFile);
|
|
196460
196553
|
}
|
|
196461
196554
|
const isEntriesShape = iterationShape === "entries" || objectIteration === "entries";
|
|
196462
|
-
if (isEntriesShape &&
|
|
196463
|
-
const elements = firstParam.name.elements.filter((el) => !
|
|
196464
|
-
if (elements.length === 2 &&
|
|
196555
|
+
if (isEntriesShape && import_typescript12.default.isArrayBindingPattern(firstParam.name)) {
|
|
196556
|
+
const elements = firstParam.name.elements.filter((el) => !import_typescript12.default.isOmittedExpression(el));
|
|
196557
|
+
if (elements.length === 2 && import_typescript12.default.isBindingElement(elements[0]) && import_typescript12.default.isIdentifier(elements[0].name) && import_typescript12.default.isBindingElement(elements[1]) && import_typescript12.default.isIdentifier(elements[1].name)) {
|
|
196465
196558
|
index = elements[0].name.text;
|
|
196466
196559
|
param = elements[1].name.text;
|
|
196467
196560
|
} else {
|
|
@@ -196498,10 +196591,10 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196498
196591
|
ctx.loopParams.add(index);
|
|
196499
196592
|
ctx.loopDepth++;
|
|
196500
196593
|
const tryTransformRenderableBody = (expr) => {
|
|
196501
|
-
if (!
|
|
196594
|
+
if (!import_typescript12.default.isBinaryExpression(expr))
|
|
196502
196595
|
return;
|
|
196503
196596
|
const op = expr.operatorToken.kind;
|
|
196504
|
-
if (op !==
|
|
196597
|
+
if (op !== import_typescript12.default.SyntaxKind.AmpersandAmpersandToken && op !== import_typescript12.default.SyntaxKind.BarBarToken && op !== import_typescript12.default.SyntaxKind.QuestionQuestionToken) {
|
|
196505
196598
|
return;
|
|
196506
196599
|
}
|
|
196507
196600
|
if (!containsJsxInExpression(expr) && !callsJsxHelper(expr, ctx))
|
|
@@ -196511,33 +196604,33 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196511
196604
|
children = [transformed];
|
|
196512
196605
|
};
|
|
196513
196606
|
const body = callback.body;
|
|
196514
|
-
if (
|
|
196607
|
+
if (import_typescript12.default.isJsxElement(body) || import_typescript12.default.isJsxSelfClosingElement(body) || import_typescript12.default.isJsxFragment(body)) {
|
|
196515
196608
|
const transformed = transformNode(body, ctx);
|
|
196516
196609
|
if (transformed) {
|
|
196517
196610
|
children = [transformed];
|
|
196518
196611
|
}
|
|
196519
|
-
} else if (
|
|
196612
|
+
} else if (import_typescript12.default.isConditionalExpression(body)) {
|
|
196520
196613
|
children = [transformConditional(body, ctx)];
|
|
196521
|
-
} else if (
|
|
196614
|
+
} else if (import_typescript12.default.isParenthesizedExpression(body)) {
|
|
196522
196615
|
let inner = body.expression;
|
|
196523
|
-
while (
|
|
196616
|
+
while (import_typescript12.default.isParenthesizedExpression(inner)) {
|
|
196524
196617
|
inner = inner.expression;
|
|
196525
196618
|
}
|
|
196526
|
-
if (
|
|
196619
|
+
if (import_typescript12.default.isJsxElement(inner) || import_typescript12.default.isJsxSelfClosingElement(inner) || import_typescript12.default.isJsxFragment(inner)) {
|
|
196527
196620
|
const transformed = transformNode(inner, ctx);
|
|
196528
196621
|
if (transformed) {
|
|
196529
196622
|
children = [transformed];
|
|
196530
196623
|
}
|
|
196531
|
-
} else if (
|
|
196624
|
+
} else if (import_typescript12.default.isConditionalExpression(inner)) {
|
|
196532
196625
|
children = [transformConditional(inner, ctx)];
|
|
196533
|
-
} else if (method === "flatMap" &&
|
|
196626
|
+
} else if (method === "flatMap" && import_typescript12.default.isArrayLiteralExpression(inner)) {
|
|
196534
196627
|
children = transformArrayLiteralChildren(inner, ctx);
|
|
196535
196628
|
} else {
|
|
196536
196629
|
tryTransformRenderableBody(inner);
|
|
196537
196630
|
}
|
|
196538
|
-
} else if (method === "flatMap" &&
|
|
196631
|
+
} else if (method === "flatMap" && import_typescript12.default.isArrayLiteralExpression(body)) {
|
|
196539
196632
|
children = transformArrayLiteralChildren(body, ctx);
|
|
196540
|
-
} else if (
|
|
196633
|
+
} else if (import_typescript12.default.isBlock(body)) {
|
|
196541
196634
|
const multiReturn = method !== "flatMap" ? extractMultiReturnJsxBranches(body, true) : null;
|
|
196542
196635
|
if (multiReturn && multiReturn.branches.length > 0) {
|
|
196543
196636
|
const loc = getSourceLocation(body, ctx.sourceFile, ctx.filePath);
|
|
@@ -196555,13 +196648,13 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196555
196648
|
}
|
|
196556
196649
|
}
|
|
196557
196650
|
}
|
|
196558
|
-
const returnStmt = children.length === 0 ? body.statements.find((s) =>
|
|
196651
|
+
const returnStmt = children.length === 0 ? body.statements.find((s) => import_typescript12.default.isReturnStatement(s) && s.expression != null) : undefined;
|
|
196559
196652
|
if (returnStmt && returnStmt.expression) {
|
|
196560
196653
|
let returnExpr = returnStmt.expression;
|
|
196561
|
-
while (
|
|
196654
|
+
while (import_typescript12.default.isParenthesizedExpression(returnExpr)) {
|
|
196562
196655
|
returnExpr = returnExpr.expression;
|
|
196563
196656
|
}
|
|
196564
|
-
if (
|
|
196657
|
+
if (import_typescript12.default.isJsxElement(returnExpr) || import_typescript12.default.isJsxSelfClosingElement(returnExpr) || import_typescript12.default.isJsxFragment(returnExpr)) {
|
|
196565
196658
|
const transformed = transformNode(returnExpr, ctx);
|
|
196566
196659
|
if (transformed) {
|
|
196567
196660
|
children = [transformed];
|
|
@@ -196640,7 +196733,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196640
196733
|
}
|
|
196641
196734
|
}
|
|
196642
196735
|
}
|
|
196643
|
-
if (method === "flatMap" && children.length === 0 && !flatMapCallback && !
|
|
196736
|
+
if (method === "flatMap" && children.length === 0 && !flatMapCallback && !import_typescript12.default.isBlock(body)) {
|
|
196644
196737
|
flatMapCallback = buildFlatMapCallback(callback, body, ctx);
|
|
196645
196738
|
}
|
|
196646
196739
|
if (flatMapCallback)
|
|
@@ -196665,7 +196758,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196665
196758
|
}
|
|
196666
196759
|
if (children.length === 0 && !flatMapCallback) {
|
|
196667
196760
|
const cb = node.arguments[0];
|
|
196668
|
-
const cbBody = cb && (
|
|
196761
|
+
const cbBody = cb && (import_typescript12.default.isArrowFunction(cb) || import_typescript12.default.isFunctionExpression(cb)) ? cb.body : undefined;
|
|
196669
196762
|
if (cbBody && containsJsxInExpression(cbBody) && ctx.analyzer.errors.length === diagCountAtEntry) {
|
|
196670
196763
|
ctx.analyzer.errors.push(createError(ErrorCodes.UNSUPPORTED_JSX_PATTERN, getSourceLocation(cbBody, ctx.sourceFile, ctx.filePath), {
|
|
196671
196764
|
message: `A .${method}() callback that builds JSX in this shape cannot be ` + "compiled — the JSX would leak verbatim into the client bundle. " + "Recognized bodies: a JSX element/fragment, a ternary or " + "&& / || / ?? expression, an array literal (flatMap), or a block " + "body whose return the compiler can lower.",
|
|
@@ -196676,7 +196769,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196676
196769
|
}
|
|
196677
196770
|
return null;
|
|
196678
196771
|
}
|
|
196679
|
-
if (
|
|
196772
|
+
if (import_typescript12.default.isArrowFunction(node.arguments[0]) && children.length > 0) {
|
|
196680
196773
|
checkLoopKey(node.arguments[0], ctx, isNested);
|
|
196681
196774
|
}
|
|
196682
196775
|
const itemConditional = children.length > 0 ? loopBodyItemConditional(children) : null;
|
|
@@ -196773,12 +196866,12 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196773
196866
|
function transformArrayLiteralChildren(arrayLiteral, ctx) {
|
|
196774
196867
|
const children = [];
|
|
196775
196868
|
for (const element of arrayLiteral.elements) {
|
|
196776
|
-
if (
|
|
196869
|
+
if (import_typescript12.default.isSpreadElement(element))
|
|
196777
196870
|
continue;
|
|
196778
196871
|
let inner = element;
|
|
196779
|
-
while (
|
|
196872
|
+
while (import_typescript12.default.isParenthesizedExpression(inner))
|
|
196780
196873
|
inner = inner.expression;
|
|
196781
|
-
if (
|
|
196874
|
+
if (import_typescript12.default.isJsxElement(inner) || import_typescript12.default.isJsxSelfClosingElement(inner) || import_typescript12.default.isJsxFragment(inner)) {
|
|
196782
196875
|
const transformed = transformNode(inner, ctx);
|
|
196783
196876
|
if (transformed)
|
|
196784
196877
|
children.push(transformed);
|
|
@@ -196787,7 +196880,7 @@ function transformArrayLiteralChildren(arrayLiteral, ctx) {
|
|
|
196787
196880
|
return children;
|
|
196788
196881
|
}
|
|
196789
196882
|
function containsJsx(node) {
|
|
196790
|
-
if (
|
|
196883
|
+
if (import_typescript12.default.isJsxElement(node) || import_typescript12.default.isJsxSelfClosingElement(node) || import_typescript12.default.isJsxFragment(node))
|
|
196791
196884
|
return true;
|
|
196792
196885
|
let found = false;
|
|
196793
196886
|
node.forEachChild((child) => {
|
|
@@ -196803,7 +196896,7 @@ function buildFlatMapCallback(callback, body, ctx) {
|
|
|
196803
196896
|
const leafIrs = [];
|
|
196804
196897
|
let refusalNode;
|
|
196805
196898
|
const collectJsx = (n, underTemplate) => {
|
|
196806
|
-
if (
|
|
196899
|
+
if (import_typescript12.default.isJsxElement(n) || import_typescript12.default.isJsxSelfClosingElement(n) || import_typescript12.default.isJsxFragment(n)) {
|
|
196807
196900
|
if (underTemplate)
|
|
196808
196901
|
refusalNode ??= n;
|
|
196809
196902
|
leafSpans.push({ start: n.getStart(ctx.sourceFile), end: n.getEnd() });
|
|
@@ -196811,7 +196904,7 @@ function buildFlatMapCallback(callback, body, ctx) {
|
|
|
196811
196904
|
leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx.sourceFile, ctx.filePath) });
|
|
196812
196905
|
return;
|
|
196813
196906
|
}
|
|
196814
|
-
const inTemplate = underTemplate ||
|
|
196907
|
+
const inTemplate = underTemplate || import_typescript12.default.isTemplateExpression(n) || import_typescript12.default.isTaggedTemplateExpression(n);
|
|
196815
196908
|
n.forEachChild((c) => collectJsx(c, inTemplate));
|
|
196816
196909
|
};
|
|
196817
196910
|
collectJsx(body, false);
|
|
@@ -197002,21 +197095,21 @@ function attrValueText(value) {
|
|
|
197002
197095
|
return out.join(" ");
|
|
197003
197096
|
}
|
|
197004
197097
|
function collectBindingNames2(name, out) {
|
|
197005
|
-
if (
|
|
197098
|
+
if (import_typescript12.default.isIdentifier(name)) {
|
|
197006
197099
|
out.add(name.text);
|
|
197007
197100
|
return;
|
|
197008
197101
|
}
|
|
197009
197102
|
for (const el of name.elements) {
|
|
197010
|
-
if (
|
|
197103
|
+
if (import_typescript12.default.isBindingElement(el))
|
|
197011
197104
|
collectBindingNames2(el.name, out);
|
|
197012
197105
|
}
|
|
197013
197106
|
}
|
|
197014
197107
|
function collectPreambleDeclaredNames(stmt, out) {
|
|
197015
|
-
if (
|
|
197108
|
+
if (import_typescript12.default.isVariableStatement(stmt)) {
|
|
197016
197109
|
for (const decl of stmt.declarationList.declarations) {
|
|
197017
197110
|
collectBindingNames2(decl.name, out);
|
|
197018
197111
|
}
|
|
197019
|
-
} else if (
|
|
197112
|
+
} else if (import_typescript12.default.isFunctionDeclaration(stmt) && stmt.name) {
|
|
197020
197113
|
out.add(stmt.name.text);
|
|
197021
197114
|
}
|
|
197022
197115
|
}
|
|
@@ -197045,10 +197138,10 @@ function preambleFromValueStatements(statements, ctx) {
|
|
|
197045
197138
|
function neutralPreambleDeclarations(statements, ctx) {
|
|
197046
197139
|
const out = [];
|
|
197047
197140
|
for (const stmt of statements) {
|
|
197048
|
-
if (!
|
|
197141
|
+
if (!import_typescript12.default.isVariableStatement(stmt))
|
|
197049
197142
|
return null;
|
|
197050
197143
|
for (const decl of stmt.declarationList.declarations) {
|
|
197051
|
-
if (!
|
|
197144
|
+
if (!import_typescript12.default.isIdentifier(decl.name))
|
|
197052
197145
|
return null;
|
|
197053
197146
|
if (!decl.initializer)
|
|
197054
197147
|
return null;
|
|
@@ -197081,11 +197174,11 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
197081
197174
|
let refusalNode;
|
|
197082
197175
|
const recordBuilderTarget = (leaf, stmt) => {
|
|
197083
197176
|
for (let n = leaf.parent;n && n !== stmt.parent; n = n.parent) {
|
|
197084
|
-
if (
|
|
197177
|
+
if (import_typescript12.default.isCallExpression(n) && import_typescript12.default.isPropertyAccessExpression(n.expression) && (n.expression.name.text === "push" || n.expression.name.text === "unshift") && import_typescript12.default.isIdentifier(n.expression.expression)) {
|
|
197085
197178
|
builders.add(n.expression.expression.text);
|
|
197086
197179
|
return;
|
|
197087
197180
|
}
|
|
197088
|
-
if (
|
|
197181
|
+
if (import_typescript12.default.isVariableDeclaration(n) && import_typescript12.default.isIdentifier(n.name)) {
|
|
197089
197182
|
builders.add(n.name.text);
|
|
197090
197183
|
return;
|
|
197091
197184
|
}
|
|
@@ -197098,7 +197191,7 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
197098
197191
|
const leafSpans = [];
|
|
197099
197192
|
const leafIrs = [];
|
|
197100
197193
|
const collect = (n, underTemplate) => {
|
|
197101
|
-
if (
|
|
197194
|
+
if (import_typescript12.default.isJsxElement(n) || import_typescript12.default.isJsxSelfClosingElement(n) || import_typescript12.default.isJsxFragment(n)) {
|
|
197102
197195
|
if (underTemplate)
|
|
197103
197196
|
refusalNode ??= n;
|
|
197104
197197
|
recordBuilderTarget(n, stmt);
|
|
@@ -197109,7 +197202,7 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
197109
197202
|
leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx.sourceFile, ctx.filePath) });
|
|
197110
197203
|
return;
|
|
197111
197204
|
}
|
|
197112
|
-
const inTemplate = underTemplate ||
|
|
197205
|
+
const inTemplate = underTemplate || import_typescript12.default.isTemplateExpression(n) || import_typescript12.default.isTaggedTemplateExpression(n);
|
|
197113
197206
|
n.forEachChild((c) => collect(c, inTemplate));
|
|
197114
197207
|
};
|
|
197115
197208
|
collect(stmt, false);
|
|
@@ -197213,13 +197306,13 @@ function expandSpreadAttribute(attr, ctx) {
|
|
|
197213
197306
|
}];
|
|
197214
197307
|
}
|
|
197215
197308
|
function attrFreeIdentifiers(attr) {
|
|
197216
|
-
if (!attr.initializer || !
|
|
197309
|
+
if (!attr.initializer || !import_typescript12.default.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
|
|
197217
197310
|
return;
|
|
197218
197311
|
}
|
|
197219
197312
|
return extractFreeIdentifiersFromNode(attr.initializer.expression);
|
|
197220
197313
|
}
|
|
197221
197314
|
function computeReactivityFlags(attr, ctx) {
|
|
197222
|
-
if (!attr.initializer || !
|
|
197315
|
+
if (!attr.initializer || !import_typescript12.default.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
|
|
197223
197316
|
return {};
|
|
197224
197317
|
}
|
|
197225
197318
|
const expr = attr.initializer.expression;
|
|
@@ -197245,22 +197338,22 @@ function processAttributes(attributes, ctx) {
|
|
|
197245
197338
|
const events = [];
|
|
197246
197339
|
let ref = null;
|
|
197247
197340
|
for (const attr of attributes.properties) {
|
|
197248
|
-
if (
|
|
197341
|
+
if (import_typescript12.default.isJsxSpreadAttribute(attr)) {
|
|
197249
197342
|
attrs.push(...expandSpreadAttribute(attr, ctx));
|
|
197250
197343
|
continue;
|
|
197251
197344
|
}
|
|
197252
|
-
if (!
|
|
197345
|
+
if (!import_typescript12.default.isJsxAttribute(attr))
|
|
197253
197346
|
continue;
|
|
197254
197347
|
const rawName = attr.name.getText(ctx.sourceFile);
|
|
197255
197348
|
if (rawName === "ref") {
|
|
197256
|
-
if (attr.initializer &&
|
|
197349
|
+
if (attr.initializer && import_typescript12.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197257
197350
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
|
|
197258
197351
|
ref = ctx.getJS(attr.initializer.expression);
|
|
197259
197352
|
}
|
|
197260
197353
|
continue;
|
|
197261
197354
|
}
|
|
197262
197355
|
if (/^on[A-Z]/.test(rawName)) {
|
|
197263
|
-
if (attr.initializer &&
|
|
197356
|
+
if (attr.initializer && import_typescript12.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197264
197357
|
const eventName = rawName.slice(2).toLowerCase();
|
|
197265
197358
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
|
|
197266
197359
|
events.push({
|
|
@@ -197275,7 +197368,7 @@ function processAttributes(attributes, ctx) {
|
|
|
197275
197368
|
const name = toHTMLAttrName(rawName);
|
|
197276
197369
|
let value = getAttributeValue(attr, ctx);
|
|
197277
197370
|
let clientOnly;
|
|
197278
|
-
if (attr.initializer &&
|
|
197371
|
+
if (attr.initializer && import_typescript12.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197279
197372
|
if (value.kind === "expression" && value.templateExpr === undefined) {
|
|
197280
197373
|
const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
|
|
197281
197374
|
if (rewritten !== value.expr) {
|
|
@@ -197302,55 +197395,55 @@ function getAttributeValue(attr, ctx) {
|
|
|
197302
197395
|
if (!attr.initializer) {
|
|
197303
197396
|
return AttrValueOf.booleanAttr();
|
|
197304
197397
|
}
|
|
197305
|
-
if (
|
|
197398
|
+
if (import_typescript12.default.isStringLiteral(attr.initializer)) {
|
|
197306
197399
|
return AttrValueOf.literal(decodeEntities(attr.initializer.text));
|
|
197307
197400
|
}
|
|
197308
|
-
if (
|
|
197401
|
+
if (import_typescript12.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197309
197402
|
let expr = attr.initializer.expression;
|
|
197310
|
-
if (
|
|
197403
|
+
if (import_typescript12.default.isIdentifier(expr)) {
|
|
197311
197404
|
const branchInit = ctx._branchScopeVars?.get(expr.text);
|
|
197312
197405
|
if (branchInit && !initializerShapeContainsJsx(branchInit)) {
|
|
197313
197406
|
expr = branchInit;
|
|
197314
197407
|
}
|
|
197315
197408
|
}
|
|
197316
197409
|
expr = tryDesugarInterleaveTaggedTemplate(expr, ctx);
|
|
197317
|
-
if (
|
|
197410
|
+
if (import_typescript12.default.isAwaitExpression(expr)) {
|
|
197318
197411
|
ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(expr, ctx.sourceFile, ctx.filePath)));
|
|
197319
197412
|
return AttrValueOf.expression("undefined");
|
|
197320
197413
|
}
|
|
197321
197414
|
checkBareSignalOrMemoIdentifier(expr, ctx);
|
|
197322
|
-
if (attr.name.getText(ctx.sourceFile) === "style" &&
|
|
197415
|
+
if (attr.name.getText(ctx.sourceFile) === "style" && import_typescript12.default.isObjectLiteralExpression(expr)) {
|
|
197323
197416
|
const cssString = tryStaticStyleObjectToCss(expr);
|
|
197324
197417
|
if (cssString !== null) {
|
|
197325
197418
|
return AttrValueOf.literal(cssString);
|
|
197326
197419
|
}
|
|
197327
197420
|
}
|
|
197328
|
-
if (
|
|
197421
|
+
if (import_typescript12.default.isTemplateExpression(expr)) {
|
|
197329
197422
|
const parts = parseTemplateLiteral(expr, ctx);
|
|
197330
197423
|
if (parts.some((p) => p.type === "ternary" || p.type === "lookup")) {
|
|
197331
197424
|
return AttrValueOf.template(parts);
|
|
197332
197425
|
}
|
|
197333
197426
|
}
|
|
197334
|
-
if (
|
|
197427
|
+
if (import_typescript12.default.isElementAccessExpression(expr) && !import_typescript12.default.isStringLiteralLike(expr.argumentExpression) && !import_typescript12.default.isNumericLiteral(expr.argumentExpression)) {
|
|
197335
197428
|
const parts = tryResolveTemplateSpanFromConst(expr, ctx);
|
|
197336
197429
|
if (parts) {
|
|
197337
197430
|
return AttrValueOf.template(parts);
|
|
197338
197431
|
}
|
|
197339
197432
|
}
|
|
197340
|
-
if (
|
|
197433
|
+
if (import_typescript12.default.isIdentifier(expr)) {
|
|
197341
197434
|
const resolved = tryResolveIdentifierAsTemplateLiteral(expr, ctx);
|
|
197342
197435
|
if (resolved) {
|
|
197343
197436
|
return AttrValueOf.template(resolved);
|
|
197344
197437
|
}
|
|
197345
197438
|
}
|
|
197346
|
-
if (
|
|
197439
|
+
if (import_typescript12.default.isConditionalExpression(expr)) {
|
|
197347
197440
|
const ternary = parseTernary(expr, ctx);
|
|
197348
197441
|
if (ternary) {
|
|
197349
197442
|
return AttrValueOf.template([ternary]);
|
|
197350
197443
|
}
|
|
197351
197444
|
}
|
|
197352
|
-
if (
|
|
197353
|
-
if (
|
|
197445
|
+
if (import_typescript12.default.isBinaryExpression(expr) && expr.operatorToken.kind === import_typescript12.default.SyntaxKind.BarBarToken) {
|
|
197446
|
+
if (import_typescript12.default.isIdentifier(expr.right) && expr.right.text === "undefined") {
|
|
197354
197447
|
const baseExpr = ctx.getJS(expr.left);
|
|
197355
197448
|
return AttrValueOf.expression(baseExpr, { presenceOrUndefined: true });
|
|
197356
197449
|
}
|
|
@@ -197363,11 +197456,11 @@ function getAttributeValue(attr, ctx) {
|
|
|
197363
197456
|
function tryStaticStyleObjectToCss(expr) {
|
|
197364
197457
|
const parts = [];
|
|
197365
197458
|
for (const prop of expr.properties) {
|
|
197366
|
-
if (!
|
|
197459
|
+
if (!import_typescript12.default.isPropertyAssignment(prop))
|
|
197367
197460
|
return null;
|
|
197368
|
-
if (!
|
|
197461
|
+
if (!import_typescript12.default.isIdentifier(prop.name) && !import_typescript12.default.isStringLiteral(prop.name))
|
|
197369
197462
|
return null;
|
|
197370
|
-
if (!
|
|
197463
|
+
if (!import_typescript12.default.isStringLiteral(prop.initializer))
|
|
197371
197464
|
return null;
|
|
197372
197465
|
const key = cssKebabCase(prop.name.text);
|
|
197373
197466
|
parts.push(`${key}:${prop.initializer.text}`);
|
|
@@ -197380,7 +197473,7 @@ function parseTemplateLiteral(expr, ctx) {
|
|
|
197380
197473
|
parts.push({ type: "string", value: expr.head.text });
|
|
197381
197474
|
}
|
|
197382
197475
|
for (const span of expr.templateSpans) {
|
|
197383
|
-
if (
|
|
197476
|
+
if (import_typescript12.default.isConditionalExpression(span.expression)) {
|
|
197384
197477
|
const ternary = parseTernary(span.expression, ctx);
|
|
197385
197478
|
if (ternary) {
|
|
197386
197479
|
parts.push(ternary);
|
|
@@ -197406,7 +197499,7 @@ function parseTemplateLiteral(expr, ctx) {
|
|
|
197406
197499
|
return parts;
|
|
197407
197500
|
}
|
|
197408
197501
|
function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
197409
|
-
if (
|
|
197502
|
+
if (import_typescript12.default.isIdentifier(expr)) {
|
|
197410
197503
|
if (ctx.loopParams.has(expr.text))
|
|
197411
197504
|
return null;
|
|
197412
197505
|
const constInfo = findLocalConst(expr.text, ctx.analyzer);
|
|
@@ -197415,13 +197508,13 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
|
197415
197508
|
const ast = parseConstInitializer(constInfo);
|
|
197416
197509
|
if (!ast)
|
|
197417
197510
|
return null;
|
|
197418
|
-
if (
|
|
197511
|
+
if (import_typescript12.default.isStringLiteral(ast) || import_typescript12.default.isNoSubstitutionTemplateLiteral(ast)) {
|
|
197419
197512
|
return [{ type: "string", value: ast.text }];
|
|
197420
197513
|
}
|
|
197421
197514
|
return null;
|
|
197422
197515
|
}
|
|
197423
|
-
if (
|
|
197424
|
-
if (!
|
|
197516
|
+
if (import_typescript12.default.isElementAccessExpression(expr)) {
|
|
197517
|
+
if (!import_typescript12.default.isIdentifier(expr.expression))
|
|
197425
197518
|
return null;
|
|
197426
197519
|
if (ctx.loopParams.has(expr.expression.text))
|
|
197427
197520
|
return null;
|
|
@@ -197429,17 +197522,17 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
|
197429
197522
|
if (!constInfo)
|
|
197430
197523
|
return null;
|
|
197431
197524
|
const ast = parseConstInitializer(constInfo);
|
|
197432
|
-
if (!ast || !
|
|
197525
|
+
if (!ast || !import_typescript12.default.isObjectLiteralExpression(ast))
|
|
197433
197526
|
return null;
|
|
197434
197527
|
const cases = {};
|
|
197435
197528
|
for (const prop of ast.properties) {
|
|
197436
|
-
if (!
|
|
197529
|
+
if (!import_typescript12.default.isPropertyAssignment(prop))
|
|
197437
197530
|
return null;
|
|
197438
|
-
const keyName = prop.name && (
|
|
197531
|
+
const keyName = prop.name && (import_typescript12.default.isStringLiteral(prop.name) || import_typescript12.default.isIdentifier(prop.name)) ? prop.name.text : null;
|
|
197439
197532
|
if (!keyName)
|
|
197440
197533
|
return null;
|
|
197441
197534
|
const value = prop.initializer;
|
|
197442
|
-
if (
|
|
197535
|
+
if (import_typescript12.default.isStringLiteral(value) || import_typescript12.default.isNoSubstitutionTemplateLiteral(value)) {
|
|
197443
197536
|
cases[keyName] = value.text;
|
|
197444
197537
|
} else {
|
|
197445
197538
|
return null;
|
|
@@ -197486,17 +197579,17 @@ function hasDynamicTagBinding(name, sourceFile) {
|
|
|
197486
197579
|
const visit2 = (node) => {
|
|
197487
197580
|
if (found)
|
|
197488
197581
|
return;
|
|
197489
|
-
if (
|
|
197582
|
+
if (import_typescript12.default.isVariableDeclaration(node) && import_typescript12.default.isIdentifier(node.name) && node.name.text === name && node.initializer) {
|
|
197490
197583
|
let init = node.initializer;
|
|
197491
|
-
while (
|
|
197584
|
+
while (import_typescript12.default.isAsExpression(init) || import_typescript12.default.isSatisfiesExpression(init) || import_typescript12.default.isParenthesizedExpression(init) || import_typescript12.default.isNonNullExpression(init)) {
|
|
197492
197585
|
init = init.expression;
|
|
197493
197586
|
}
|
|
197494
|
-
if (
|
|
197587
|
+
if (import_typescript12.default.isPropertyAccessExpression(init) && init.name.text === "tag") {
|
|
197495
197588
|
found = true;
|
|
197496
197589
|
return;
|
|
197497
197590
|
}
|
|
197498
197591
|
}
|
|
197499
|
-
|
|
197592
|
+
import_typescript12.default.forEachChild(node, visit2);
|
|
197500
197593
|
};
|
|
197501
197594
|
visit2(sourceFile);
|
|
197502
197595
|
return found;
|
|
@@ -197510,13 +197603,13 @@ function tryResolveIdentifierAsTemplateLiteral(ident, ctx) {
|
|
|
197510
197603
|
const ast = parseConstInitializer(constInfo);
|
|
197511
197604
|
if (!ast)
|
|
197512
197605
|
return null;
|
|
197513
|
-
if (
|
|
197606
|
+
if (import_typescript12.default.isNoSubstitutionTemplateLiteral(ast) || import_typescript12.default.isStringLiteral(ast)) {
|
|
197514
197607
|
return [{ type: "string", value: ast.text }];
|
|
197515
197608
|
}
|
|
197516
|
-
if (
|
|
197609
|
+
if (import_typescript12.default.isElementAccessExpression(ast) && !import_typescript12.default.isStringLiteralLike(ast.argumentExpression) && !import_typescript12.default.isNumericLiteral(ast.argumentExpression)) {
|
|
197517
197610
|
return tryResolveTemplateSpanFromConst(ast, ctx);
|
|
197518
197611
|
}
|
|
197519
|
-
if (!
|
|
197612
|
+
if (!import_typescript12.default.isTemplateExpression(ast))
|
|
197520
197613
|
return null;
|
|
197521
197614
|
let resolvedAny = false;
|
|
197522
197615
|
const parts = [];
|
|
@@ -197554,14 +197647,14 @@ function parseConstInitializerImpl(c) {
|
|
|
197554
197647
|
if (!c.value)
|
|
197555
197648
|
return null;
|
|
197556
197649
|
const wrapped = `const __bf_resolve__ = (${c.value})`;
|
|
197557
|
-
const sf =
|
|
197650
|
+
const sf = import_typescript12.default.createSourceFile("__bf_resolve.ts", wrapped, import_typescript12.default.ScriptTarget.Latest, true, import_typescript12.default.ScriptKind.TS);
|
|
197558
197651
|
const stmt = sf.statements[0];
|
|
197559
|
-
if (!stmt || !
|
|
197652
|
+
if (!stmt || !import_typescript12.default.isVariableStatement(stmt))
|
|
197560
197653
|
return null;
|
|
197561
197654
|
const decl = stmt.declarationList.declarations[0];
|
|
197562
197655
|
if (!decl?.initializer)
|
|
197563
197656
|
return null;
|
|
197564
|
-
return
|
|
197657
|
+
return import_typescript12.default.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
197565
197658
|
}
|
|
197566
197659
|
function astText(node) {
|
|
197567
197660
|
return node.getText(node.getSourceFile());
|
|
@@ -197581,9 +197674,9 @@ function parseFunctionInfoAsExprImpl(fn) {
|
|
|
197581
197674
|
const params = fn.typedParams !== undefined ? fn.typedParams : fn.params.map(formatParamWithType).join(", ");
|
|
197582
197675
|
const body = fn.typedBody ?? fn.body;
|
|
197583
197676
|
const wrapped = `const __bf_resolve_fn__ = function(${params}) ${body}`;
|
|
197584
|
-
const sf =
|
|
197677
|
+
const sf = import_typescript12.default.createSourceFile("__bf_resolve_fn.ts", wrapped, import_typescript12.default.ScriptTarget.Latest, true, import_typescript12.default.ScriptKind.TS);
|
|
197585
197678
|
const stmt = sf.statements[0];
|
|
197586
|
-
if (!stmt || !
|
|
197679
|
+
if (!stmt || !import_typescript12.default.isVariableStatement(stmt))
|
|
197587
197680
|
return null;
|
|
197588
197681
|
const decl = stmt.declarationList.declarations[0];
|
|
197589
197682
|
if (!decl?.initializer)
|
|
@@ -197591,9 +197684,9 @@ function parseFunctionInfoAsExprImpl(fn) {
|
|
|
197591
197684
|
return decl.initializer;
|
|
197592
197685
|
}
|
|
197593
197686
|
function tryDesugarInterleaveTaggedTemplate(expr, ctx) {
|
|
197594
|
-
if (!
|
|
197687
|
+
if (!import_typescript12.default.isTaggedTemplateExpression(expr))
|
|
197595
197688
|
return expr;
|
|
197596
|
-
if (!
|
|
197689
|
+
if (!import_typescript12.default.isIdentifier(expr.tag))
|
|
197597
197690
|
return expr;
|
|
197598
197691
|
const resolvedTag = resolveInterleaveTagIdentifier(expr.tag.text, ctx);
|
|
197599
197692
|
if (!resolvedTag)
|
|
@@ -197610,23 +197703,23 @@ function resolveInterleaveTagIdentifier(name, ctx) {
|
|
|
197610
197703
|
return null;
|
|
197611
197704
|
if (constInfo) {
|
|
197612
197705
|
const ast = parseConstInitializer(constInfo);
|
|
197613
|
-
return ast && (
|
|
197706
|
+
return ast && (import_typescript12.default.isArrowFunction(ast) || import_typescript12.default.isFunctionExpression(ast)) ? ast : null;
|
|
197614
197707
|
}
|
|
197615
197708
|
if (fnInfo) {
|
|
197616
197709
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
197617
|
-
return ast && (
|
|
197710
|
+
return ast && (import_typescript12.default.isArrowFunction(ast) || import_typescript12.default.isFunctionExpression(ast)) ? ast : null;
|
|
197618
197711
|
}
|
|
197619
197712
|
return null;
|
|
197620
197713
|
}
|
|
197621
197714
|
function isInterleaveTagFunction(fn) {
|
|
197622
|
-
if (!
|
|
197715
|
+
if (!import_typescript12.default.isArrowFunction(fn) && !import_typescript12.default.isFunctionExpression(fn))
|
|
197623
197716
|
return false;
|
|
197624
197717
|
if (fn.parameters.length !== 2)
|
|
197625
197718
|
return false;
|
|
197626
197719
|
const [partsParam, argsParam] = fn.parameters;
|
|
197627
|
-
if (!
|
|
197720
|
+
if (!import_typescript12.default.isIdentifier(partsParam.name) || partsParam.dotDotDotToken)
|
|
197628
197721
|
return false;
|
|
197629
|
-
if (!
|
|
197722
|
+
if (!import_typescript12.default.isIdentifier(argsParam.name) || !argsParam.dotDotDotToken)
|
|
197630
197723
|
return false;
|
|
197631
197724
|
const parsed = tsNodeToParsedExpr(fn);
|
|
197632
197725
|
if (parsed.kind !== "arrow")
|
|
@@ -197683,7 +197776,7 @@ function isInterleaveSpanExpr(expr, i2, argsName) {
|
|
|
197683
197776
|
function buildUntaggedTemplateLiteral(node, ctx) {
|
|
197684
197777
|
const template = node.template;
|
|
197685
197778
|
let text;
|
|
197686
|
-
if (
|
|
197779
|
+
if (import_typescript12.default.isNoSubstitutionTemplateLiteral(template)) {
|
|
197687
197780
|
text = "`" + (template.rawText ?? template.text) + "`";
|
|
197688
197781
|
} else {
|
|
197689
197782
|
let body = template.head.rawText ?? template.head.text;
|
|
@@ -197695,15 +197788,15 @@ function buildUntaggedTemplateLiteral(node, ctx) {
|
|
|
197695
197788
|
text = "`" + body + "`";
|
|
197696
197789
|
}
|
|
197697
197790
|
const wrapped = `const __bf_resolve_tagged__ = (${text})`;
|
|
197698
|
-
const sf =
|
|
197791
|
+
const sf = import_typescript12.default.createSourceFile("__bf_resolve_tagged.tsx", wrapped, import_typescript12.default.ScriptTarget.Latest, true, import_typescript12.default.ScriptKind.TSX);
|
|
197699
197792
|
const stmt = sf.statements[0];
|
|
197700
|
-
if (!stmt || !
|
|
197793
|
+
if (!stmt || !import_typescript12.default.isVariableStatement(stmt))
|
|
197701
197794
|
return null;
|
|
197702
197795
|
const decl = stmt.declarationList.declarations[0];
|
|
197703
197796
|
if (!decl?.initializer)
|
|
197704
197797
|
return null;
|
|
197705
|
-
const result =
|
|
197706
|
-
if (!
|
|
197798
|
+
const result = import_typescript12.default.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
197799
|
+
if (!import_typescript12.default.isTemplateExpression(result) && !import_typescript12.default.isNoSubstitutionTemplateLiteral(result))
|
|
197707
197800
|
return null;
|
|
197708
197801
|
return result;
|
|
197709
197802
|
}
|
|
@@ -197723,10 +197816,10 @@ function parseTernary(expr, ctx) {
|
|
|
197723
197816
|
return null;
|
|
197724
197817
|
}
|
|
197725
197818
|
function getStringValue(node) {
|
|
197726
|
-
if (
|
|
197819
|
+
if (import_typescript12.default.isStringLiteral(node)) {
|
|
197727
197820
|
return node.text;
|
|
197728
197821
|
}
|
|
197729
|
-
if (
|
|
197822
|
+
if (import_typescript12.default.isNoSubstitutionTemplateLiteral(node)) {
|
|
197730
197823
|
return node.text;
|
|
197731
197824
|
}
|
|
197732
197825
|
return null;
|
|
@@ -197734,19 +197827,19 @@ function getStringValue(node) {
|
|
|
197734
197827
|
function processComponentProps(attributes, ctx) {
|
|
197735
197828
|
const props = [];
|
|
197736
197829
|
for (const attr of attributes.properties) {
|
|
197737
|
-
if (
|
|
197830
|
+
if (import_typescript12.default.isJsxSpreadAttribute(attr)) {
|
|
197738
197831
|
props.push(...expandSpreadAttribute(attr, ctx));
|
|
197739
197832
|
continue;
|
|
197740
197833
|
}
|
|
197741
|
-
if (!
|
|
197834
|
+
if (!import_typescript12.default.isJsxAttribute(attr))
|
|
197742
197835
|
continue;
|
|
197743
197836
|
const name = attr.name.getText(ctx.sourceFile);
|
|
197744
|
-
if (attr.initializer &&
|
|
197837
|
+
if (attr.initializer && import_typescript12.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197745
197838
|
let jsxExpr = attr.initializer.expression;
|
|
197746
|
-
while (
|
|
197839
|
+
while (import_typescript12.default.isParenthesizedExpression(jsxExpr)) {
|
|
197747
197840
|
jsxExpr = jsxExpr.expression;
|
|
197748
197841
|
}
|
|
197749
|
-
if (
|
|
197842
|
+
if (import_typescript12.default.isJsxElement(jsxExpr) || import_typescript12.default.isJsxSelfClosingElement(jsxExpr) || import_typescript12.default.isJsxFragment(jsxExpr)) {
|
|
197750
197843
|
const prevInsideComponentChildren = ctx.insideComponentChildren;
|
|
197751
197844
|
ctx.insideComponentChildren = true;
|
|
197752
197845
|
const irNode = transformNode(jsxExpr, ctx);
|
|
@@ -197763,8 +197856,8 @@ function processComponentProps(attributes, ctx) {
|
|
|
197763
197856
|
}
|
|
197764
197857
|
let value = getAttributeValue(attr, ctx);
|
|
197765
197858
|
if (value.kind === "template") {
|
|
197766
|
-
const collapsed =
|
|
197767
|
-
const collapsedTemplate =
|
|
197859
|
+
const collapsed = templatePartsToJsExpr(value.parts);
|
|
197860
|
+
const collapsedTemplate = templatePartsToJsExpr(value.parts, { useTemplate: true });
|
|
197768
197861
|
value = AttrValueOf.expression(collapsed, {
|
|
197769
197862
|
parts: value.parts,
|
|
197770
197863
|
...collapsedTemplate !== collapsed && { templateExpr: collapsedTemplate }
|
|
@@ -197773,7 +197866,7 @@ function processComponentProps(attributes, ctx) {
|
|
|
197773
197866
|
value = AttrValueOf.booleanShorthand();
|
|
197774
197867
|
}
|
|
197775
197868
|
let clientOnly;
|
|
197776
|
-
if (attr.initializer &&
|
|
197869
|
+
if (attr.initializer && import_typescript12.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197777
197870
|
if (value.kind === "expression" && value.templateExpr === undefined) {
|
|
197778
197871
|
const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
|
|
197779
197872
|
if (rewritten !== value.expr) {
|
|
@@ -197796,25 +197889,8 @@ function processComponentProps(attributes, ctx) {
|
|
|
197796
197889
|
}
|
|
197797
197890
|
return props;
|
|
197798
197891
|
}
|
|
197799
|
-
function templatePartsToJsString(parts, opts) {
|
|
197800
|
-
let result = "`";
|
|
197801
|
-
for (const part of parts) {
|
|
197802
|
-
if (part.type === "string") {
|
|
197803
|
-
result += opts?.useTemplate && part.templateValue ? part.templateValue : part.value;
|
|
197804
|
-
} else if (part.type === "ternary") {
|
|
197805
|
-
const cond = opts?.useTemplate && part.templateCondition ? part.templateCondition : part.condition;
|
|
197806
|
-
result += `\${${cond} ? '${part.whenTrue}' : '${part.whenFalse}'}`;
|
|
197807
|
-
} else if (part.type === "lookup") {
|
|
197808
|
-
const key = opts?.useTemplate && part.templateKey ? part.templateKey : part.key;
|
|
197809
|
-
const obj = "{" + Object.entries(part.cases).map(([k, v]) => `${JSON.stringify(k)}: ${JSON.stringify(v)}`).join(", ") + "}";
|
|
197810
|
-
result += `\${(${obj})[${key}]}`;
|
|
197811
|
-
}
|
|
197812
|
-
}
|
|
197813
|
-
result += "`";
|
|
197814
|
-
return result;
|
|
197815
|
-
}
|
|
197816
197892
|
function checkBareSignalOrMemoIdentifier(expr, ctx) {
|
|
197817
|
-
if (!
|
|
197893
|
+
if (!import_typescript12.default.isIdentifier(expr))
|
|
197818
197894
|
return;
|
|
197819
197895
|
const name = expr.text;
|
|
197820
197896
|
for (const signal of ctx.analyzer.signals) {
|
|
@@ -197845,12 +197921,12 @@ function checkBareSignalOrMemoIdentifier(expr, ctx) {
|
|
|
197845
197921
|
function isArrayExprDirectPropRef(arrayExpr, ctx) {
|
|
197846
197922
|
const propNames = new Set(ctx.patterns.props.map((p) => p.name));
|
|
197847
197923
|
const propsObjName = ctx.analyzer.propsObjectName;
|
|
197848
|
-
if (
|
|
197924
|
+
if (import_typescript12.default.isIdentifier(arrayExpr)) {
|
|
197849
197925
|
return propNames.has(arrayExpr.text);
|
|
197850
197926
|
}
|
|
197851
|
-
if (
|
|
197927
|
+
if (import_typescript12.default.isPropertyAccessExpression(arrayExpr) && propsObjName) {
|
|
197852
197928
|
const obj = arrayExpr.expression;
|
|
197853
|
-
if (
|
|
197929
|
+
if (import_typescript12.default.isIdentifier(obj) && obj.text === propsObjName) {
|
|
197854
197930
|
return true;
|
|
197855
197931
|
}
|
|
197856
197932
|
}
|
|
@@ -198043,7 +198119,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
|
|
|
198043
198119
|
jsxBranchLocalNames.add(n);
|
|
198044
198120
|
}
|
|
198045
198121
|
for (const decl of condReturn.scopeVariables) {
|
|
198046
|
-
if (
|
|
198122
|
+
if (import_typescript12.default.isIdentifier(decl.name) && decl.initializer) {
|
|
198047
198123
|
branchScopeVars.set(decl.name.text, decl.initializer);
|
|
198048
198124
|
if (initializerShapeContainsJsx(decl.initializer)) {
|
|
198049
198125
|
jsxBranchLocalNames.add(decl.name.text);
|
|
@@ -198110,7 +198186,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
|
|
|
198110
198186
|
}
|
|
198111
198187
|
const scopeVariables = [];
|
|
198112
198188
|
for (const decl of condReturn.scopeVariables) {
|
|
198113
|
-
if (
|
|
198189
|
+
if (import_typescript12.default.isIdentifier(decl.name) && decl.initializer) {
|
|
198114
198190
|
const init = ctx.getJS(decl.initializer);
|
|
198115
198191
|
const typedInit = decl.initializer.getText(ctx.sourceFile);
|
|
198116
198192
|
scopeVariables.push({
|
|
@@ -198248,13 +198324,13 @@ var KEYWORDS_AND_GLOBALS = new Set([
|
|
|
198248
198324
|
]);
|
|
198249
198325
|
|
|
198250
198326
|
// ../jsx/src/ir-to-client-js/walk-prop-accesses.ts
|
|
198251
|
-
var
|
|
198327
|
+
var import_typescript13 = __toESM(require_typescript(), 1);
|
|
198252
198328
|
|
|
198253
198329
|
// ../jsx/src/value-references.ts
|
|
198254
|
-
var
|
|
198330
|
+
var import_typescript14 = __toESM(require_typescript(), 1);
|
|
198255
198331
|
|
|
198256
198332
|
// ../jsx/src/relocate.ts
|
|
198257
|
-
var
|
|
198333
|
+
var import_typescript15 = __toESM(require_typescript(), 1);
|
|
198258
198334
|
|
|
198259
198335
|
// ../jsx/src/lowering-registry.ts
|
|
198260
198336
|
var plugins = [];
|
|
@@ -198433,10 +198509,10 @@ function formatDateLocalNames(metadata) {
|
|
|
198433
198509
|
}
|
|
198434
198510
|
|
|
198435
198511
|
// ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
|
|
198436
|
-
var
|
|
198512
|
+
var import_typescript16 = __toESM(require_typescript(), 1);
|
|
198437
198513
|
|
|
198438
198514
|
// ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
|
|
198439
|
-
var
|
|
198515
|
+
var import_typescript17 = __toESM(require_typescript(), 1);
|
|
198440
198516
|
var NO_PREAMBLE = {
|
|
198441
198517
|
lazySafe: true,
|
|
198442
198518
|
facts: { declaredNames: new Set, freeNames: new Set }
|
|
@@ -198486,7 +198562,7 @@ var INERT_BINDING_GLOBALS = new Set([
|
|
|
198486
198562
|
]);
|
|
198487
198563
|
|
|
198488
198564
|
// ../jsx/src/ir-to-client-js/emit-reactive.ts
|
|
198489
|
-
var
|
|
198565
|
+
var import_typescript18 = __toESM(require_typescript(), 1);
|
|
198490
198566
|
|
|
198491
198567
|
// ../jsx/src/ir-to-client-js/control-flow/stringify/event-delegation.ts
|
|
198492
198568
|
var NON_BUBBLING_EVENTS = new Set([
|
|
@@ -198501,7 +198577,7 @@ var NON_BUBBLING_EVENTS = new Set([
|
|
|
198501
198577
|
]);
|
|
198502
198578
|
|
|
198503
198579
|
// ../jsx/src/ir-to-client-js/rewrite-props-object.ts
|
|
198504
|
-
var
|
|
198580
|
+
var import_typescript19 = __toESM(require_typescript(), 1);
|
|
198505
198581
|
|
|
198506
198582
|
// ../jsx/src/ir-to-client-js/source-map.ts
|
|
198507
198583
|
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -198592,21 +198668,21 @@ class SourceMapGenerator {
|
|
|
198592
198668
|
}
|
|
198593
198669
|
|
|
198594
198670
|
// ../jsx/src/preprocess-inline-jsx-callbacks.ts
|
|
198595
|
-
var
|
|
198671
|
+
var import_typescript20 = __toESM(require_typescript(), 1);
|
|
198596
198672
|
|
|
198597
198673
|
// ../jsx/src/ssr-defaults.ts
|
|
198598
|
-
var
|
|
198674
|
+
var import_typescript21 = __toESM(require_typescript(), 1);
|
|
198599
198675
|
var UNRESOLVED = Symbol("unresolved");
|
|
198600
198676
|
var NO_RETURN = Symbol("no-return");
|
|
198601
198677
|
|
|
198602
198678
|
// ../jsx/src/augment-inherited-props.ts
|
|
198603
|
-
var
|
|
198679
|
+
var import_typescript22 = __toESM(require_typescript(), 1);
|
|
198604
198680
|
|
|
198605
198681
|
// ../jsx/src/rich-type-refusal.ts
|
|
198606
198682
|
var EMPTY_BINDINGS2 = new Map;
|
|
198607
198683
|
// ../jsx/src/shared-program.ts
|
|
198608
198684
|
init_path();
|
|
198609
|
-
var
|
|
198685
|
+
var import_typescript24 = __toESM(require_typescript(), 1);
|
|
198610
198686
|
// ../jsx/src/adapters/interface.ts
|
|
198611
198687
|
class BaseAdapter {
|
|
198612
198688
|
renderChildren(children) {
|
|
@@ -198682,7 +198758,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
198682
198758
|
}
|
|
198683
198759
|
const rawInitialValue = preserveTypes ? signal.typedInitialValue ?? signal.initialValue : signal.initialValue;
|
|
198684
198760
|
const initialValue = rawInitialValue.trim().startsWith("{") ? `(${rawInitialValue})` : rawInitialValue;
|
|
198685
|
-
const needsTypeAssertion = preserveTypes && !signal.typedInitialValue && signal.type.kind !== "unknown" && signal.type.kind !== "primitive";
|
|
198761
|
+
const needsTypeAssertion = preserveTypes && !signal.typedInitialValue && signal.type.kind !== "unknown" && signal.type.kind !== "primitive" && signal.type.raw !== "object";
|
|
198686
198762
|
if (needsTypeAssertion) {
|
|
198687
198763
|
lines.push(` const ${signal.getter} = () => ${initialValue} as ${signal.type.raw}`);
|
|
198688
198764
|
} else {
|
|
@@ -198701,12 +198777,16 @@ class JsxAdapter extends BaseAdapter {
|
|
|
198701
198777
|
const computation = preserveTypes ? memo.typedComputation ?? memo.computation : memo.computation;
|
|
198702
198778
|
lines.push(` const ${memo.name} = ${computation}`);
|
|
198703
198779
|
}
|
|
198780
|
+
const moduleScopeNames = this.moduleScopeDeclarationNames(ir);
|
|
198704
198781
|
for (const constant of ir.metadata.localConstants) {
|
|
198705
198782
|
if (constant.isExported)
|
|
198706
198783
|
continue;
|
|
198784
|
+
if (moduleScopeNames.has(constant.name))
|
|
198785
|
+
continue;
|
|
198707
198786
|
const keyword = constant.declarationKind ?? "const";
|
|
198708
198787
|
if (!constant.value) {
|
|
198709
|
-
|
|
198788
|
+
const typeAnnotation = preserveTypes && constant.type ? `: ${constant.type.raw}` : "";
|
|
198789
|
+
lines.push(` ${keyword} ${constant.name}${typeAnnotation}`);
|
|
198710
198790
|
continue;
|
|
198711
198791
|
}
|
|
198712
198792
|
const value = constant.value.trim();
|
|
@@ -198718,6 +198798,8 @@ class JsxAdapter extends BaseAdapter {
|
|
|
198718
198798
|
lines.push(` ${keyword} ${constant.name} = ${constValue}`);
|
|
198719
198799
|
}
|
|
198720
198800
|
for (const func of localFunctions) {
|
|
198801
|
+
if (moduleScopeNames.has(func.name))
|
|
198802
|
+
continue;
|
|
198721
198803
|
if (!reachable.has(func.name))
|
|
198722
198804
|
continue;
|
|
198723
198805
|
const params = preserveTypes && func.typedParams !== undefined ? func.typedParams : func.params.map(formatParamWithType).join(", ");
|
|
@@ -198727,6 +198809,125 @@ class JsxAdapter extends BaseAdapter {
|
|
|
198727
198809
|
lines.push(` ${asyncKw}function ${func.name}(${params})${returnAnnotation} ${body}`);
|
|
198728
198810
|
}
|
|
198729
198811
|
return lines.join(`
|
|
198812
|
+
`);
|
|
198813
|
+
}
|
|
198814
|
+
moduleScopeNamesCache = new WeakMap;
|
|
198815
|
+
moduleScopeDeclarationNames(ir) {
|
|
198816
|
+
const cached = this.moduleScopeNamesCache.get(ir);
|
|
198817
|
+
if (cached)
|
|
198818
|
+
return cached;
|
|
198819
|
+
const componentScope = new Set;
|
|
198820
|
+
for (const sig of ir.metadata.signals) {
|
|
198821
|
+
if (sig.isModule)
|
|
198822
|
+
continue;
|
|
198823
|
+
componentScope.add(sig.getter);
|
|
198824
|
+
if (sig.setter)
|
|
198825
|
+
componentScope.add(sig.setter);
|
|
198826
|
+
}
|
|
198827
|
+
for (const memo of ir.metadata.memos) {
|
|
198828
|
+
if (!memo.isModule)
|
|
198829
|
+
componentScope.add(memo.name);
|
|
198830
|
+
}
|
|
198831
|
+
for (const p of ir.metadata.propsParams)
|
|
198832
|
+
componentScope.add(p.name);
|
|
198833
|
+
if (ir.metadata.propsObjectName)
|
|
198834
|
+
componentScope.add(ir.metadata.propsObjectName);
|
|
198835
|
+
if (ir.metadata.restPropsName)
|
|
198836
|
+
componentScope.add(ir.metadata.restPropsName);
|
|
198837
|
+
for (const c of ir.metadata.localConstants) {
|
|
198838
|
+
if (!c.isModule)
|
|
198839
|
+
componentScope.add(c.name);
|
|
198840
|
+
}
|
|
198841
|
+
for (const f of ir.metadata.localFunctions) {
|
|
198842
|
+
if (!f.isModule)
|
|
198843
|
+
componentScope.add(f.name);
|
|
198844
|
+
}
|
|
198845
|
+
const exported = new Set;
|
|
198846
|
+
const candidates = new Map;
|
|
198847
|
+
for (const c of ir.metadata.localConstants) {
|
|
198848
|
+
if (!c.isModule)
|
|
198849
|
+
continue;
|
|
198850
|
+
if (c.isJsx || c.isJsxFunction)
|
|
198851
|
+
continue;
|
|
198852
|
+
if (c.isExported) {
|
|
198853
|
+
exported.add(c.name);
|
|
198854
|
+
continue;
|
|
198855
|
+
}
|
|
198856
|
+
candidates.set(c.name, c.freeIdentifiers ?? extractFreeIdentifiersFromText(c.value ?? ""));
|
|
198857
|
+
}
|
|
198858
|
+
for (const f of ir.metadata.localFunctions) {
|
|
198859
|
+
if (!f.isModule)
|
|
198860
|
+
continue;
|
|
198861
|
+
if (f.isJsxFunction || f.isMultiReturnJsxHelper)
|
|
198862
|
+
continue;
|
|
198863
|
+
if (f.isExported) {
|
|
198864
|
+
exported.add(f.name);
|
|
198865
|
+
continue;
|
|
198866
|
+
}
|
|
198867
|
+
const params = f.typedParams !== undefined ? f.typedParams : f.params.map(formatParamWithType).join(", ");
|
|
198868
|
+
candidates.set(f.name, extractFreeIdentifiersFromText(`(${params}) => ${f.body}`));
|
|
198869
|
+
}
|
|
198870
|
+
const referencesAny = (refs, names) => {
|
|
198871
|
+
for (const ref of refs) {
|
|
198872
|
+
if (names.has(ref))
|
|
198873
|
+
return true;
|
|
198874
|
+
}
|
|
198875
|
+
return false;
|
|
198876
|
+
};
|
|
198877
|
+
let changed = true;
|
|
198878
|
+
while (changed) {
|
|
198879
|
+
changed = false;
|
|
198880
|
+
for (const [name, refs] of candidates) {
|
|
198881
|
+
if (referencesAny(refs, componentScope)) {
|
|
198882
|
+
candidates.delete(name);
|
|
198883
|
+
componentScope.add(name);
|
|
198884
|
+
changed = true;
|
|
198885
|
+
}
|
|
198886
|
+
}
|
|
198887
|
+
}
|
|
198888
|
+
const result = new Set([...exported, ...candidates.keys()]);
|
|
198889
|
+
this.moduleScopeNamesCache.set(ir, result);
|
|
198890
|
+
return result;
|
|
198891
|
+
}
|
|
198892
|
+
generateModuleScopeDeclarations(ir) {
|
|
198893
|
+
const { preserveTypes } = this.jsxConfig;
|
|
198894
|
+
const moduleNames = this.moduleScopeDeclarationNames(ir);
|
|
198895
|
+
const entries = [];
|
|
198896
|
+
for (const t of ir.metadata.typeDefinitions) {
|
|
198897
|
+
entries.push({ line: t.loc.start.line, text: t.definition });
|
|
198898
|
+
}
|
|
198899
|
+
for (const c of ir.metadata.localConstants) {
|
|
198900
|
+
if (!c.isModule || !moduleNames.has(c.name))
|
|
198901
|
+
continue;
|
|
198902
|
+
const keyword = c.declarationKind ?? "const";
|
|
198903
|
+
const exportKw = c.isExported ? "export " : "";
|
|
198904
|
+
if (!c.value) {
|
|
198905
|
+
entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}` });
|
|
198906
|
+
continue;
|
|
198907
|
+
}
|
|
198908
|
+
const trimmed = c.value.trim();
|
|
198909
|
+
if (/^new WeakMap\b/.test(trimmed))
|
|
198910
|
+
continue;
|
|
198911
|
+
if (c.isExported && /^createContext\b/.test(trimmed))
|
|
198912
|
+
continue;
|
|
198913
|
+
const value = preserveTypes ? c.typedValue ?? c.value : c.value;
|
|
198914
|
+
entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name} = ${value}` });
|
|
198915
|
+
}
|
|
198916
|
+
for (const f of ir.metadata.localFunctions) {
|
|
198917
|
+
if (!f.isModule || !moduleNames.has(f.name))
|
|
198918
|
+
continue;
|
|
198919
|
+
const params = preserveTypes && f.typedParams !== undefined ? f.typedParams : f.params.map(formatParamWithType).join(", ");
|
|
198920
|
+
const returnAnnotation = preserveTypes && f.typedReturnType ? `: ${f.typedReturnType}` : "";
|
|
198921
|
+
const body = preserveTypes ? f.typedBody ?? f.body : f.body;
|
|
198922
|
+
const asyncKw = f.isAsync ? "async " : "";
|
|
198923
|
+
const exportKw = f.isExported ? "export " : "";
|
|
198924
|
+
entries.push({
|
|
198925
|
+
line: f.loc.start.line,
|
|
198926
|
+
text: `${exportKw}${asyncKw}function ${f.name}(${params})${returnAnnotation} ${body}`
|
|
198927
|
+
});
|
|
198928
|
+
}
|
|
198929
|
+
entries.sort((a, b) => a.line - b.line);
|
|
198930
|
+
return entries.map((e) => e.text).join(`
|
|
198730
198931
|
`);
|
|
198731
198932
|
}
|
|
198732
198933
|
renderNodeRaw(node) {
|
|
@@ -198738,6 +198939,15 @@ class JsxAdapter extends BaseAdapter {
|
|
|
198738
198939
|
}
|
|
198739
198940
|
return this.renderNode(node);
|
|
198740
198941
|
}
|
|
198942
|
+
renderTemplatePartsAsJs(parts) {
|
|
198943
|
+
return templatePartsToJsExpr(parts, { typed: this.jsxConfig.preserveTypes });
|
|
198944
|
+
}
|
|
198945
|
+
expressionValueToJs(value) {
|
|
198946
|
+
if (this.jsxConfig.preserveTypes && value.parts && value.expr === templatePartsToJsExpr(value.parts)) {
|
|
198947
|
+
return this.renderTemplatePartsAsJs(value.parts);
|
|
198948
|
+
}
|
|
198949
|
+
return value.expr;
|
|
198950
|
+
}
|
|
198741
198951
|
renderScopeMarker(instanceIdExpr) {
|
|
198742
198952
|
return `${BF_SCOPE}={${instanceIdExpr}}`;
|
|
198743
198953
|
}
|
|
@@ -198805,6 +199015,7 @@ class TestAdapter extends JsxAdapter {
|
|
|
198805
199015
|
generate(ir) {
|
|
198806
199016
|
this.componentName = ir.metadata.componentName;
|
|
198807
199017
|
const imports = this.generateImports(ir);
|
|
199018
|
+
const moduleConstants = this.generateModuleScopeDeclarations(ir);
|
|
198808
199019
|
const types2 = this.generateTypes(ir);
|
|
198809
199020
|
const component = this.generateComponent(ir);
|
|
198810
199021
|
const defaultExport = ir.metadata.hasDefaultExport ? `
|
|
@@ -198813,9 +199024,11 @@ export default ${this.componentName}` : "";
|
|
|
198813
199024
|
imports,
|
|
198814
199025
|
types: types2 || "",
|
|
198815
199026
|
component,
|
|
198816
|
-
defaultExport
|
|
199027
|
+
defaultExport,
|
|
199028
|
+
moduleConstants,
|
|
199029
|
+
moduleConstantsIncludeExports: true
|
|
198817
199030
|
};
|
|
198818
|
-
const template = [imports, types2, component].filter(Boolean).join(`
|
|
199031
|
+
const template = [imports, moduleConstants, types2, component].filter(Boolean).join(`
|
|
198819
199032
|
|
|
198820
199033
|
`) + defaultExport;
|
|
198821
199034
|
return {
|
|
@@ -198846,9 +199059,6 @@ export default ${this.componentName}` : "";
|
|
|
198846
199059
|
}
|
|
198847
199060
|
generateTypes(ir) {
|
|
198848
199061
|
const lines = [];
|
|
198849
|
-
for (const typeDef of ir.metadata.typeDefinitions) {
|
|
198850
|
-
lines.push(typeDef.definition);
|
|
198851
|
-
}
|
|
198852
199062
|
const propsTypeName = ir.metadata.propsType?.raw;
|
|
198853
199063
|
if (propsTypeName && !ir.metadata.propsObjectName) {
|
|
198854
199064
|
lines.push("");
|
|
@@ -198871,7 +199081,7 @@ export default ${this.componentName}` : "";
|
|
|
198871
199081
|
const bodyRefText = [jsxBody, signalInits, scopeIdLine].join(`
|
|
198872
199082
|
`);
|
|
198873
199083
|
const bfScopeAlias = /\b__bfScope\b/.test(bodyRefText) ? "__bfScope" : "__bfScope: _bfScope";
|
|
198874
|
-
const propsParams = ir.metadata.propsParams.map((p) => p
|
|
199084
|
+
const propsParams = ir.metadata.propsParams.map((p) => propsDestructureBinding(p)).join(", ");
|
|
198875
199085
|
const restPropsName = ir.metadata.restPropsName;
|
|
198876
199086
|
const hydrationProps = `__instanceId, ${bfScopeAlias}`;
|
|
198877
199087
|
const parts = [];
|
|
@@ -199018,13 +199228,7 @@ export default ${this.componentName}` : "";
|
|
|
199018
199228
|
}
|
|
199019
199229
|
flattenTemplate(value) {
|
|
199020
199230
|
const v = value;
|
|
199021
|
-
return
|
|
199022
|
-
if (p.type === "string")
|
|
199023
|
-
return p.value;
|
|
199024
|
-
if (p.type === "ternary")
|
|
199025
|
-
return `\${${p.condition} ? '${p.whenTrue}' : '${p.whenFalse}'}`;
|
|
199026
|
-
return `\${(${JSON.stringify(p.cases)})[${p.key}]}`;
|
|
199027
|
-
}).join("") + "`";
|
|
199231
|
+
return this.renderTemplatePartsAsJs(v.parts);
|
|
199028
199232
|
}
|
|
199029
199233
|
renderComponentProps(comp) {
|
|
199030
199234
|
const parts = [];
|
|
@@ -199145,9 +199349,9 @@ function registerBuiltinLoweringPlugins() {
|
|
|
199145
199349
|
registerLoweringPlugin(plugin);
|
|
199146
199350
|
}
|
|
199147
199351
|
// ../jsx/src/combine-client-js.ts
|
|
199148
|
-
var
|
|
199352
|
+
var import_typescript25 = __toESM(require_typescript(), 1);
|
|
199149
199353
|
// ../jsx/src/debug.ts
|
|
199150
|
-
var
|
|
199354
|
+
var import_typescript26 = __toESM(require_typescript(), 1);
|
|
199151
199355
|
function escapeForIdBoundary(name) {
|
|
199152
199356
|
return name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
199153
199357
|
}
|
|
@@ -199239,7 +199443,7 @@ function resolveSetters(handler, setterToSignal, fnSetters) {
|
|
|
199239
199443
|
return refs;
|
|
199240
199444
|
}
|
|
199241
199445
|
// ../jsx/src/profiler.ts
|
|
199242
|
-
var
|
|
199446
|
+
var import_typescript27 = __toESM(require_typescript(), 1);
|
|
199243
199447
|
|
|
199244
199448
|
// ../jsx/src/index.ts
|
|
199245
199449
|
registerBuiltinLoweringPlugins();
|