@barefootjs/test 0.31.1 → 0.31.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1097 -798
- 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,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190367
190429
|
if (!ctx.componentNode) {
|
|
190368
190430
|
collectAmbientGlobals(node, ctx);
|
|
190369
190431
|
}
|
|
190370
|
-
|
|
190371
|
-
|
|
190372
|
-
const
|
|
190432
|
+
const isDeclareStatement = import_typescript9.default.isVariableStatement(node) && (node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.DeclareKeyword) ?? false);
|
|
190433
|
+
if (import_typescript9.default.isVariableStatement(node) && !ctx.componentNode && !isDeclareStatement) {
|
|
190434
|
+
const isExported = node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190435
|
+
const isLet = (node.declarationList.flags & import_typescript9.default.NodeFlags.Let) !== 0;
|
|
190373
190436
|
const isModuleClientDirective = hasLeadingClientDirectiveOnStatement(node, ctx.sourceFile);
|
|
190374
190437
|
for (const decl of node.declarationList.declarations) {
|
|
190375
190438
|
if (declarationIsReactiveFactoryCall(decl, ctx)) {
|
|
@@ -190380,19 +190443,19 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190380
190443
|
}
|
|
190381
190444
|
continue;
|
|
190382
190445
|
}
|
|
190383
|
-
if (
|
|
190446
|
+
if (import_typescript9.default.isIdentifier(decl.name) && (decl.initializer || isLet) && !isArrowComponentFunction(decl)) {
|
|
190384
190447
|
collectConstant(decl, ctx, true, isLet ? "let" : "const", isExported);
|
|
190385
190448
|
}
|
|
190386
190449
|
}
|
|
190387
190450
|
}
|
|
190388
|
-
if (
|
|
190389
|
-
const isExported = node.modifiers?.some((m) => m.kind ===
|
|
190451
|
+
if (import_typescript9.default.isFunctionDeclaration(node) && node.name && !isComponentFunction(node)) {
|
|
190452
|
+
const isExported = node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190390
190453
|
collectFunction(node, ctx, true, isExported);
|
|
190391
190454
|
return;
|
|
190392
190455
|
}
|
|
190393
|
-
if (
|
|
190456
|
+
if (import_typescript9.default.isExportDeclaration(node) && node.exportClause && import_typescript9.default.isNamedExports(node.exportClause)) {
|
|
190394
190457
|
const isFromReexport = !!node.moduleSpecifier;
|
|
190395
|
-
const sourceSpec = node.moduleSpecifier &&
|
|
190458
|
+
const sourceSpec = node.moduleSpecifier && import_typescript9.default.isStringLiteral(node.moduleSpecifier) ? node.moduleSpecifier.text : null;
|
|
190396
190459
|
const exportSpecifiers = node.exportClause.elements.map((spec) => ({
|
|
190397
190460
|
name: (spec.propertyName ?? spec.name).text,
|
|
190398
190461
|
alias: spec.propertyName ? spec.name.text : null,
|
|
@@ -190420,24 +190483,24 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190420
190483
|
}
|
|
190421
190484
|
}
|
|
190422
190485
|
}
|
|
190423
|
-
if (
|
|
190486
|
+
if (import_typescript9.default.isExportAssignment(node) && !node.isExportEquals) {
|
|
190424
190487
|
const expr = node.expression;
|
|
190425
|
-
if (
|
|
190488
|
+
if (import_typescript9.default.isIdentifier(expr)) {
|
|
190426
190489
|
if (ctx.componentName && expr.text === ctx.componentName) {
|
|
190427
190490
|
ctx.hasDefaultExport = true;
|
|
190428
190491
|
ctx.isExported = true;
|
|
190429
190492
|
}
|
|
190430
190493
|
}
|
|
190431
190494
|
}
|
|
190432
|
-
|
|
190495
|
+
import_typescript9.default.forEachChild(node, (child) => visit(child, ctx, targetComponentName, namedExports));
|
|
190433
190496
|
}
|
|
190434
190497
|
function analyzeComponentBody(node, ctx) {
|
|
190435
190498
|
if (node.parameters.length > 0) {
|
|
190436
190499
|
extractProps(node.parameters[0], ctx);
|
|
190437
190500
|
}
|
|
190438
|
-
const body =
|
|
190501
|
+
const body = import_typescript9.default.isFunctionDeclaration(node) ? node.body : getArrowFunctionBody(node);
|
|
190439
190502
|
if (body) {
|
|
190440
|
-
ctx.componentBodyBlock =
|
|
190503
|
+
ctx.componentBodyBlock = import_typescript9.default.isBlock(body) ? body : null;
|
|
190441
190504
|
if (!ctx.componentBodyBlock) {
|
|
190442
190505
|
ctx.jsxReturn = unwrapJsxTransparent(body);
|
|
190443
190506
|
}
|
|
@@ -190447,14 +190510,14 @@ function analyzeComponentBody(node, ctx) {
|
|
|
190447
190510
|
}
|
|
190448
190511
|
}
|
|
190449
190512
|
function getArrowFunctionBody(node) {
|
|
190450
|
-
if (
|
|
190513
|
+
if (import_typescript9.default.isBlock(node.body)) {
|
|
190451
190514
|
return node.body;
|
|
190452
190515
|
}
|
|
190453
190516
|
return node.body;
|
|
190454
190517
|
}
|
|
190455
190518
|
function visitComponentBody(node, ctx) {
|
|
190456
190519
|
const isTopLevel = ctx.componentBodyBlock !== null && node.parent === ctx.componentBodyBlock;
|
|
190457
|
-
if (
|
|
190520
|
+
if (import_typescript9.default.isVariableStatement(node)) {
|
|
190458
190521
|
for (const decl of node.declarationList.declarations) {
|
|
190459
190522
|
if (isSignalDeclaration(decl, ctx)) {
|
|
190460
190523
|
collectSignal(decl, ctx);
|
|
@@ -190477,16 +190540,16 @@ function visitComponentBody(node, ctx) {
|
|
|
190477
190540
|
collectEffect(decl.initializer, ctx, decl.name.text);
|
|
190478
190541
|
continue;
|
|
190479
190542
|
}
|
|
190480
|
-
if (
|
|
190481
|
-
const isLet = (node.declarationList.flags &
|
|
190543
|
+
if (import_typescript9.default.isIdentifier(decl.name)) {
|
|
190544
|
+
const isLet = (node.declarationList.flags & import_typescript9.default.NodeFlags.Let) !== 0;
|
|
190482
190545
|
collectConstant(decl, ctx, false, isLet ? "let" : "const");
|
|
190483
|
-
} else if (
|
|
190484
|
-
const isLet = (node.declarationList.flags &
|
|
190546
|
+
} else if (import_typescript9.default.isObjectBindingPattern(decl.name) && decl.initializer && import_typescript9.default.isIdentifier(decl.initializer) && ctx.propsObjectName === decl.initializer.text) {
|
|
190547
|
+
const isLet = (node.declarationList.flags & import_typescript9.default.NodeFlags.Let) !== 0;
|
|
190485
190548
|
collectConstant(decl, ctx, false, isLet ? "let" : "const");
|
|
190486
190549
|
}
|
|
190487
190550
|
}
|
|
190488
190551
|
}
|
|
190489
|
-
if (
|
|
190552
|
+
if (import_typescript9.default.isExpressionStatement(node)) {
|
|
190490
190553
|
if (isEffectCall(node.expression, ctx)) {
|
|
190491
190554
|
collectEffect(node.expression, ctx);
|
|
190492
190555
|
return;
|
|
@@ -190500,10 +190563,10 @@ function visitComponentBody(node, ctx) {
|
|
|
190500
190563
|
return;
|
|
190501
190564
|
}
|
|
190502
190565
|
}
|
|
190503
|
-
if (
|
|
190566
|
+
if (import_typescript9.default.isFunctionDeclaration(node) && node.name) {
|
|
190504
190567
|
collectFunction(node, ctx, false);
|
|
190505
190568
|
}
|
|
190506
|
-
if (
|
|
190569
|
+
if (import_typescript9.default.isIfStatement(node)) {
|
|
190507
190570
|
const jsxReturn = findJsxReturnInBlock(node.thenStatement);
|
|
190508
190571
|
if (jsxReturn) {
|
|
190509
190572
|
const scopeVars = collectScopeVariables(node.thenStatement, ctx);
|
|
@@ -190522,54 +190585,54 @@ function visitComponentBody(node, ctx) {
|
|
|
190522
190585
|
return;
|
|
190523
190586
|
}
|
|
190524
190587
|
}
|
|
190525
|
-
if (isTopLevel && (
|
|
190588
|
+
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
190589
|
collectInitStatement(node, ctx);
|
|
190527
190590
|
return;
|
|
190528
190591
|
}
|
|
190529
|
-
if (
|
|
190592
|
+
if (import_typescript9.default.isReturnStatement(node) && node.expression) {
|
|
190530
190593
|
ctx.jsxReturn = unwrapJsxTransparent(node.expression);
|
|
190531
190594
|
}
|
|
190532
|
-
|
|
190533
|
-
if (
|
|
190595
|
+
import_typescript9.default.forEachChild(node, (child) => {
|
|
190596
|
+
if (import_typescript9.default.isArrowFunction(child) || import_typescript9.default.isFunctionExpression(child) || import_typescript9.default.isFunctionDeclaration(child)) {
|
|
190534
190597
|
return;
|
|
190535
190598
|
}
|
|
190536
190599
|
visitComponentBody(child, ctx);
|
|
190537
190600
|
});
|
|
190538
190601
|
}
|
|
190539
190602
|
function findJsxReturnInBlock(node) {
|
|
190540
|
-
if (
|
|
190603
|
+
if (import_typescript9.default.isBlock(node)) {
|
|
190541
190604
|
for (const stmt of node.statements) {
|
|
190542
|
-
if (
|
|
190605
|
+
if (import_typescript9.default.isReturnStatement(stmt) && stmt.expression) {
|
|
190543
190606
|
const jsx = extractJsxFromExpression(stmt.expression);
|
|
190544
190607
|
if (jsx)
|
|
190545
190608
|
return jsx;
|
|
190546
190609
|
}
|
|
190547
190610
|
}
|
|
190548
190611
|
}
|
|
190549
|
-
if (
|
|
190612
|
+
if (import_typescript9.default.isReturnStatement(node) && node.expression) {
|
|
190550
190613
|
return extractJsxFromExpression(node.expression);
|
|
190551
190614
|
}
|
|
190552
190615
|
return null;
|
|
190553
190616
|
}
|
|
190554
190617
|
function unwrapJsxTransparent(expr) {
|
|
190555
190618
|
let current = expr;
|
|
190556
|
-
while (
|
|
190619
|
+
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
190620
|
current = current.expression;
|
|
190558
190621
|
}
|
|
190559
190622
|
return current;
|
|
190560
190623
|
}
|
|
190561
190624
|
function extractJsxFromExpression(expr) {
|
|
190562
190625
|
const inner = unwrapJsxTransparent(expr);
|
|
190563
|
-
if (
|
|
190626
|
+
if (import_typescript9.default.isJsxElement(inner) || import_typescript9.default.isJsxFragment(inner) || import_typescript9.default.isJsxSelfClosingElement(inner)) {
|
|
190564
190627
|
return inner;
|
|
190565
190628
|
}
|
|
190566
190629
|
return null;
|
|
190567
190630
|
}
|
|
190568
190631
|
function collectScopeVariables(node, ctx) {
|
|
190569
190632
|
const variables = [];
|
|
190570
|
-
if (
|
|
190633
|
+
if (import_typescript9.default.isBlock(node)) {
|
|
190571
190634
|
for (const stmt of node.statements) {
|
|
190572
|
-
if (
|
|
190635
|
+
if (import_typescript9.default.isVariableStatement(stmt)) {
|
|
190573
190636
|
for (const decl of stmt.declarationList.declarations) {
|
|
190574
190637
|
variables.push(decl);
|
|
190575
190638
|
}
|
|
@@ -190581,13 +190644,13 @@ function collectScopeVariables(node, ctx) {
|
|
|
190581
190644
|
function collectParamBindingNames(params) {
|
|
190582
190645
|
const out = new Set;
|
|
190583
190646
|
const addBindingNames = (name) => {
|
|
190584
|
-
if (
|
|
190647
|
+
if (import_typescript9.default.isIdentifier(name)) {
|
|
190585
190648
|
out.add(name.text);
|
|
190586
|
-
} else if (
|
|
190649
|
+
} else if (import_typescript9.default.isObjectBindingPattern(name)) {
|
|
190587
190650
|
name.elements.forEach((e) => addBindingNames(e.name));
|
|
190588
|
-
} else if (
|
|
190651
|
+
} else if (import_typescript9.default.isArrayBindingPattern(name)) {
|
|
190589
190652
|
name.elements.forEach((e) => {
|
|
190590
|
-
if (!
|
|
190653
|
+
if (!import_typescript9.default.isOmittedExpression(e))
|
|
190591
190654
|
addBindingNames(e.name);
|
|
190592
190655
|
});
|
|
190593
190656
|
}
|
|
@@ -190604,7 +190667,7 @@ function collectEnclosingBranchVars(node, ctx) {
|
|
|
190604
190667
|
if (cr.ifStatement.thenStatement !== current)
|
|
190605
190668
|
continue;
|
|
190606
190669
|
for (const decl of cr.scopeVariables) {
|
|
190607
|
-
if (!
|
|
190670
|
+
if (!import_typescript9.default.isIdentifier(decl.name) || !decl.initializer)
|
|
190608
190671
|
continue;
|
|
190609
190672
|
const varName = decl.name.text;
|
|
190610
190673
|
if (result.has(varName))
|
|
@@ -190619,10 +190682,10 @@ function collectEnclosingBranchVars(node, ctx) {
|
|
|
190619
190682
|
return result;
|
|
190620
190683
|
}
|
|
190621
190684
|
function collectBranchSignals(thenStatement, ctx, branchCondition) {
|
|
190622
|
-
if (!
|
|
190685
|
+
if (!import_typescript9.default.isBlock(thenStatement))
|
|
190623
190686
|
return;
|
|
190624
190687
|
for (const stmt of thenStatement.statements) {
|
|
190625
|
-
if (!
|
|
190688
|
+
if (!import_typescript9.default.isVariableStatement(stmt))
|
|
190626
190689
|
continue;
|
|
190627
190690
|
for (const decl of stmt.declarationList.declarations) {
|
|
190628
190691
|
if (!isSignalDeclaration(decl, ctx))
|
|
@@ -190648,13 +190711,13 @@ var ENV_SIGNAL_FACTORIES = {
|
|
|
190648
190711
|
createSearchParams: "search"
|
|
190649
190712
|
};
|
|
190650
190713
|
function resolvePrimitiveKind(callExpr, ctx) {
|
|
190651
|
-
if (
|
|
190714
|
+
if (import_typescript9.default.isIdentifier(callExpr.expression)) {
|
|
190652
190715
|
const hit = PRIMITIVE_CANONICAL_NAMES[callExpr.expression.text];
|
|
190653
190716
|
if (hit)
|
|
190654
190717
|
return hit;
|
|
190655
190718
|
return resolveCalleeViaChecker(callExpr.expression, ctx);
|
|
190656
190719
|
}
|
|
190657
|
-
if (
|
|
190720
|
+
if (import_typescript9.default.isPropertyAccessExpression(callExpr.expression)) {
|
|
190658
190721
|
const propName = callExpr.expression.name.text;
|
|
190659
190722
|
const hit = PRIMITIVE_CANONICAL_NAMES[propName];
|
|
190660
190723
|
if (!hit)
|
|
@@ -190681,7 +190744,7 @@ function resolveCanonicalClientExportName(ident, ctx) {
|
|
|
190681
190744
|
if (!symbol)
|
|
190682
190745
|
return null;
|
|
190683
190746
|
let target = symbol;
|
|
190684
|
-
if (symbol.flags &
|
|
190747
|
+
if (symbol.flags & import_typescript9.default.SymbolFlags.Alias) {
|
|
190685
190748
|
try {
|
|
190686
190749
|
target = ctx.checker.getAliasedSymbol(symbol);
|
|
190687
190750
|
} catch {
|
|
@@ -190697,14 +190760,14 @@ function resolveCanonicalClientExportName(ident, ctx) {
|
|
|
190697
190760
|
return null;
|
|
190698
190761
|
}
|
|
190699
190762
|
function resolveEnvSignalKey(callExpr, ctx) {
|
|
190700
|
-
if (
|
|
190763
|
+
if (import_typescript9.default.isIdentifier(callExpr.expression)) {
|
|
190701
190764
|
const key = ENV_SIGNAL_FACTORIES[callExpr.expression.text];
|
|
190702
190765
|
if (key)
|
|
190703
190766
|
return key;
|
|
190704
190767
|
const canonical = resolveCanonicalClientExportName(callExpr.expression, ctx);
|
|
190705
190768
|
return canonical ? ENV_SIGNAL_FACTORIES[canonical] ?? null : null;
|
|
190706
190769
|
}
|
|
190707
|
-
if (
|
|
190770
|
+
if (import_typescript9.default.isPropertyAccessExpression(callExpr.expression)) {
|
|
190708
190771
|
const key = ENV_SIGNAL_FACTORIES[callExpr.expression.name.text];
|
|
190709
190772
|
if (key && isBarefootClientNamespace(callExpr.expression.expression, ctx))
|
|
190710
190773
|
return key;
|
|
@@ -190712,7 +190775,7 @@ function resolveEnvSignalKey(callExpr, ctx) {
|
|
|
190712
190775
|
return null;
|
|
190713
190776
|
}
|
|
190714
190777
|
function isBarefootClientNamespace(expr, ctx) {
|
|
190715
|
-
if (!
|
|
190778
|
+
if (!import_typescript9.default.isIdentifier(expr))
|
|
190716
190779
|
return false;
|
|
190717
190780
|
if (!ctx.checker)
|
|
190718
190781
|
return false;
|
|
@@ -190725,22 +190788,22 @@ function isBarefootClientNamespace(expr, ctx) {
|
|
|
190725
190788
|
if (!symbol)
|
|
190726
190789
|
return false;
|
|
190727
190790
|
for (const decl of symbol.declarations ?? []) {
|
|
190728
|
-
if (!
|
|
190791
|
+
if (!import_typescript9.default.isNamespaceImport(decl))
|
|
190729
190792
|
continue;
|
|
190730
190793
|
const importDecl = decl.parent.parent;
|
|
190731
|
-
if (!
|
|
190794
|
+
if (!import_typescript9.default.isImportDeclaration(importDecl))
|
|
190732
190795
|
continue;
|
|
190733
190796
|
const mod = importDecl.moduleSpecifier;
|
|
190734
|
-
if (
|
|
190797
|
+
if (import_typescript9.default.isStringLiteral(mod) && mod.text === "@barefootjs/client") {
|
|
190735
190798
|
return true;
|
|
190736
190799
|
}
|
|
190737
190800
|
}
|
|
190738
190801
|
return false;
|
|
190739
190802
|
}
|
|
190740
190803
|
function isSignalDeclaration(node, ctx) {
|
|
190741
|
-
if (!
|
|
190804
|
+
if (!import_typescript9.default.isArrayBindingPattern(node.name))
|
|
190742
190805
|
return false;
|
|
190743
|
-
if (!node.initializer || !
|
|
190806
|
+
if (!node.initializer || !import_typescript9.default.isCallExpression(node.initializer))
|
|
190744
190807
|
return false;
|
|
190745
190808
|
return resolvePrimitiveKind(node.initializer, ctx) === "signal";
|
|
190746
190809
|
}
|
|
@@ -190748,14 +190811,14 @@ function collectSignal(node, ctx) {
|
|
|
190748
190811
|
const pattern = node.name;
|
|
190749
190812
|
const callExpr = node.initializer;
|
|
190750
190813
|
const elements = pattern.elements;
|
|
190751
|
-
const getterElided = elements.length === 2 &&
|
|
190752
|
-
if (elements.length < 1 || elements.length > 2 || !getterElided && (!
|
|
190814
|
+
const getterElided = elements.length === 2 && import_typescript9.default.isOmittedExpression(elements[0]);
|
|
190815
|
+
if (elements.length < 1 || elements.length > 2 || !getterElided && (!import_typescript9.default.isBindingElement(elements[0]) || !import_typescript9.default.isIdentifier(elements[0].name))) {
|
|
190753
190816
|
return;
|
|
190754
190817
|
}
|
|
190755
|
-
if (elements.length === 2 && (!
|
|
190818
|
+
if (elements.length === 2 && (!import_typescript9.default.isBindingElement(elements[1]) || !import_typescript9.default.isIdentifier(elements[1].name))) {
|
|
190756
190819
|
return;
|
|
190757
190820
|
}
|
|
190758
|
-
const setter = elements.length === 2 &&
|
|
190821
|
+
const setter = elements.length === 2 && import_typescript9.default.isBindingElement(elements[1]) && import_typescript9.default.isIdentifier(elements[1].name) ? elements[1].name.text : null;
|
|
190759
190822
|
if (getterElided && !setter)
|
|
190760
190823
|
return;
|
|
190761
190824
|
const getter = getterElided ? `__bfGet_${setter}` : elements[0].name.text;
|
|
@@ -190773,7 +190836,8 @@ function collectSignal(node, ctx) {
|
|
|
190773
190836
|
if (!ctx.propsObjectName && callExpr.arguments[0]) {
|
|
190774
190837
|
const propNames = new Set(ctx.propsParams.map((p) => p.name));
|
|
190775
190838
|
if (propNames.size > 0) {
|
|
190776
|
-
|
|
190839
|
+
const propAliases = buildPropAliasMap(ctx.propsParams);
|
|
190840
|
+
templateInitialValue = rewriteBarePropRefs(initialValue, callExpr.arguments[0], propNames, undefined, propAliases);
|
|
190777
190841
|
}
|
|
190778
190842
|
}
|
|
190779
190843
|
ctx.signals.push({
|
|
@@ -190791,33 +190855,33 @@ function collectSignal(node, ctx) {
|
|
|
190791
190855
|
});
|
|
190792
190856
|
}
|
|
190793
190857
|
function isSignalTupleDeclaration(node) {
|
|
190794
|
-
if (!
|
|
190858
|
+
if (!import_typescript9.default.isIdentifier(node.name))
|
|
190795
190859
|
return false;
|
|
190796
|
-
if (!node.initializer || !
|
|
190860
|
+
if (!node.initializer || !import_typescript9.default.isCallExpression(node.initializer))
|
|
190797
190861
|
return false;
|
|
190798
190862
|
const callExpr = node.initializer;
|
|
190799
|
-
return
|
|
190863
|
+
return import_typescript9.default.isIdentifier(callExpr.expression) && callExpr.expression.text === "createSignal";
|
|
190800
190864
|
}
|
|
190801
190865
|
function isSignalIndexAccess(node, ctx) {
|
|
190802
|
-
if (!
|
|
190866
|
+
if (!import_typescript9.default.isIdentifier(node.name))
|
|
190803
190867
|
return null;
|
|
190804
|
-
if (!node.initializer || !
|
|
190868
|
+
if (!node.initializer || !import_typescript9.default.isElementAccessExpression(node.initializer))
|
|
190805
190869
|
return null;
|
|
190806
190870
|
const access = node.initializer;
|
|
190807
|
-
if (!
|
|
190871
|
+
if (!import_typescript9.default.isNumericLiteral(access.argumentExpression))
|
|
190808
190872
|
return null;
|
|
190809
190873
|
const indexValue = Number(access.argumentExpression.text);
|
|
190810
190874
|
if (indexValue !== 0 && indexValue !== 1)
|
|
190811
190875
|
return null;
|
|
190812
190876
|
const index = indexValue;
|
|
190813
|
-
if (
|
|
190877
|
+
if (import_typescript9.default.isCallExpression(access.expression)) {
|
|
190814
190878
|
const call = access.expression;
|
|
190815
|
-
if (
|
|
190879
|
+
if (import_typescript9.default.isIdentifier(call.expression) && call.expression.text === "createSignal") {
|
|
190816
190880
|
return { kind: "direct", index, callExpr: call };
|
|
190817
190881
|
}
|
|
190818
190882
|
return null;
|
|
190819
190883
|
}
|
|
190820
|
-
if (
|
|
190884
|
+
if (import_typescript9.default.isIdentifier(access.expression)) {
|
|
190821
190885
|
const tupleName = access.expression.text;
|
|
190822
190886
|
if (ctx.signalTupleRefs.has(tupleName)) {
|
|
190823
190887
|
return { kind: "tupleRef", index, tupleName };
|
|
@@ -190912,30 +190976,30 @@ function flushPendingSignalTuples(ctx) {
|
|
|
190912
190976
|
ctx.signalTupleRefs.clear();
|
|
190913
190977
|
}
|
|
190914
190978
|
function isMemoDeclaration(node, ctx) {
|
|
190915
|
-
if (!
|
|
190979
|
+
if (!import_typescript9.default.isIdentifier(node.name))
|
|
190916
190980
|
return false;
|
|
190917
|
-
if (!node.initializer || !
|
|
190981
|
+
if (!node.initializer || !import_typescript9.default.isCallExpression(node.initializer))
|
|
190918
190982
|
return false;
|
|
190919
190983
|
return resolvePrimitiveKind(node.initializer, ctx) === "memo";
|
|
190920
190984
|
}
|
|
190921
190985
|
function memoBodyIsTemplateLiteral(memoArrow) {
|
|
190922
190986
|
let node = memoArrow;
|
|
190923
|
-
while (node &&
|
|
190987
|
+
while (node && import_typescript9.default.isParenthesizedExpression(node))
|
|
190924
190988
|
node = node.expression;
|
|
190925
|
-
if (!node || !
|
|
190989
|
+
if (!node || !import_typescript9.default.isArrowFunction(node))
|
|
190926
190990
|
return false;
|
|
190927
190991
|
let body = node.body;
|
|
190928
|
-
while (
|
|
190992
|
+
while (import_typescript9.default.isParenthesizedExpression(body))
|
|
190929
190993
|
body = body.expression;
|
|
190930
|
-
if (
|
|
190931
|
-
const ret = body.statements.find(
|
|
190994
|
+
if (import_typescript9.default.isBlock(body)) {
|
|
190995
|
+
const ret = body.statements.find(import_typescript9.default.isReturnStatement);
|
|
190932
190996
|
if (!ret || !ret.expression)
|
|
190933
190997
|
return false;
|
|
190934
190998
|
body = ret.expression;
|
|
190935
|
-
while (
|
|
190999
|
+
while (import_typescript9.default.isParenthesizedExpression(body))
|
|
190936
191000
|
body = body.expression;
|
|
190937
191001
|
}
|
|
190938
|
-
return
|
|
191002
|
+
return import_typescript9.default.isTemplateExpression(body) || import_typescript9.default.isNoSubstitutionTemplateLiteral(body);
|
|
190939
191003
|
}
|
|
190940
191004
|
function collectMemo(node, ctx) {
|
|
190941
191005
|
const name = node.name.text;
|
|
@@ -190952,7 +191016,7 @@ function collectMemo(node, ctx) {
|
|
|
190952
191016
|
type2 = inferTypeFromValue(arrowBody);
|
|
190953
191017
|
}
|
|
190954
191018
|
}
|
|
190955
|
-
if (ctx.checker && (type2.kind === "unknown" || type2.kind === "object") && callExpr.arguments[0] && (
|
|
191019
|
+
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
191020
|
const fnType = ctx.checker.getTypeAtLocation(callExpr.arguments[0]);
|
|
190957
191021
|
const sig = fnType.getCallSignatures()[0];
|
|
190958
191022
|
if (sig) {
|
|
@@ -190962,19 +191026,20 @@ function collectMemo(node, ctx) {
|
|
|
190962
191026
|
}
|
|
190963
191027
|
}
|
|
190964
191028
|
const memoArrow = callExpr.arguments[0];
|
|
190965
|
-
const parsedBody = memoArrow &&
|
|
191029
|
+
const parsedBody = memoArrow && import_typescript9.default.isArrowFunction(memoArrow) && !import_typescript9.default.isBlock(memoArrow.body) ? parseExpression(ctx.getJS(memoArrow.body)) : undefined;
|
|
190966
191030
|
const parsed = parsedBody && parsedBody.kind !== "unsupported" && parsedBody.kind !== "object-literal" ? parsedBody : undefined;
|
|
190967
191031
|
let arrowNode = memoArrow;
|
|
190968
|
-
while (arrowNode &&
|
|
191032
|
+
while (arrowNode && import_typescript9.default.isParenthesizedExpression(arrowNode))
|
|
190969
191033
|
arrowNode = arrowNode.expression;
|
|
190970
|
-
const blockBody = arrowNode &&
|
|
191034
|
+
const blockBody = arrowNode && import_typescript9.default.isArrowFunction(arrowNode) && import_typescript9.default.isBlock(arrowNode.body) ? arrowNode.body : undefined;
|
|
190971
191035
|
const parsedBlock = blockBody ? parseBlockBodyTolerant(blockBody, ctx.sourceFile, (node2) => ctx.getJS(node2)) : undefined;
|
|
190972
191036
|
const parsedBlockComplete = parsedBlock && blockBody ? parsedBlock.length === blockBody.statements.length : undefined;
|
|
190973
191037
|
let templateComputation;
|
|
190974
191038
|
if (!ctx.propsObjectName && callExpr.arguments[0]) {
|
|
190975
191039
|
const propNames = new Set(ctx.propsParams.map((p) => p.name));
|
|
190976
191040
|
if (propNames.size > 0) {
|
|
190977
|
-
|
|
191041
|
+
const propAliases = buildPropAliasMap(ctx.propsParams);
|
|
191042
|
+
templateComputation = rewriteBarePropRefs(computation, callExpr.arguments[0], propNames, undefined, propAliases);
|
|
190978
191043
|
}
|
|
190979
191044
|
}
|
|
190980
191045
|
ctx.memos.push({
|
|
@@ -190993,14 +191058,14 @@ function collectMemo(node, ctx) {
|
|
|
190993
191058
|
});
|
|
190994
191059
|
}
|
|
190995
191060
|
function isEffectCall(node, ctx) {
|
|
190996
|
-
if (!
|
|
191061
|
+
if (!import_typescript9.default.isCallExpression(node))
|
|
190997
191062
|
return false;
|
|
190998
191063
|
return resolvePrimitiveKind(node, ctx) === "effect";
|
|
190999
191064
|
}
|
|
191000
191065
|
function isEffectDisposerCapture(node, ctx) {
|
|
191001
|
-
if (!
|
|
191066
|
+
if (!import_typescript9.default.isIdentifier(node.name))
|
|
191002
191067
|
return false;
|
|
191003
|
-
if (!node.initializer || !
|
|
191068
|
+
if (!node.initializer || !import_typescript9.default.isCallExpression(node.initializer))
|
|
191004
191069
|
return false;
|
|
191005
191070
|
return resolvePrimitiveKind(node.initializer, ctx) === "effect";
|
|
191006
191071
|
}
|
|
@@ -191015,7 +191080,7 @@ function collectEffect(node, ctx, captureName) {
|
|
|
191015
191080
|
});
|
|
191016
191081
|
}
|
|
191017
191082
|
function isOnMountCall(node, ctx) {
|
|
191018
|
-
if (!
|
|
191083
|
+
if (!import_typescript9.default.isCallExpression(node))
|
|
191019
191084
|
return false;
|
|
191020
191085
|
return resolvePrimitiveKind(node, ctx) === "onMount";
|
|
191021
191086
|
}
|
|
@@ -191050,19 +191115,19 @@ function leadsWithAsiHazard(body) {
|
|
|
191050
191115
|
function extractAssignedIdentifiersFromNode(node) {
|
|
191051
191116
|
const ids = new Set;
|
|
191052
191117
|
function addFromTarget(target) {
|
|
191053
|
-
if (
|
|
191118
|
+
if (import_typescript9.default.isIdentifier(target)) {
|
|
191054
191119
|
ids.add(target.text);
|
|
191055
191120
|
return;
|
|
191056
191121
|
}
|
|
191057
|
-
if (
|
|
191122
|
+
if (import_typescript9.default.isParenthesizedExpression(target)) {
|
|
191058
191123
|
addFromTarget(target.expression);
|
|
191059
191124
|
return;
|
|
191060
191125
|
}
|
|
191061
|
-
if (
|
|
191126
|
+
if (import_typescript9.default.isArrayLiteralExpression(target)) {
|
|
191062
191127
|
for (const el of target.elements) {
|
|
191063
|
-
if (
|
|
191128
|
+
if (import_typescript9.default.isOmittedExpression(el))
|
|
191064
191129
|
continue;
|
|
191065
|
-
if (
|
|
191130
|
+
if (import_typescript9.default.isSpreadElement(el)) {
|
|
191066
191131
|
addFromTarget(el.expression);
|
|
191067
191132
|
continue;
|
|
191068
191133
|
}
|
|
@@ -191070,17 +191135,17 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191070
191135
|
}
|
|
191071
191136
|
return;
|
|
191072
191137
|
}
|
|
191073
|
-
if (
|
|
191138
|
+
if (import_typescript9.default.isObjectLiteralExpression(target)) {
|
|
191074
191139
|
for (const prop of target.properties) {
|
|
191075
|
-
if (
|
|
191140
|
+
if (import_typescript9.default.isShorthandPropertyAssignment(prop)) {
|
|
191076
191141
|
ids.add(prop.name.text);
|
|
191077
191142
|
continue;
|
|
191078
191143
|
}
|
|
191079
|
-
if (
|
|
191144
|
+
if (import_typescript9.default.isPropertyAssignment(prop)) {
|
|
191080
191145
|
addFromTarget(prop.initializer);
|
|
191081
191146
|
continue;
|
|
191082
191147
|
}
|
|
191083
|
-
if (
|
|
191148
|
+
if (import_typescript9.default.isSpreadAssignment(prop)) {
|
|
191084
191149
|
addFromTarget(prop.expression);
|
|
191085
191150
|
continue;
|
|
191086
191151
|
}
|
|
@@ -191089,21 +191154,21 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191089
191154
|
}
|
|
191090
191155
|
}
|
|
191091
191156
|
function visit2(n) {
|
|
191092
|
-
if (
|
|
191157
|
+
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
191158
|
return;
|
|
191094
191159
|
}
|
|
191095
|
-
if (
|
|
191160
|
+
if (import_typescript9.default.isBinaryExpression(n)) {
|
|
191096
191161
|
const op = n.operatorToken.kind;
|
|
191097
|
-
if (op ===
|
|
191162
|
+
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
191163
|
addFromTarget(n.left);
|
|
191099
191164
|
}
|
|
191100
191165
|
}
|
|
191101
|
-
if (
|
|
191102
|
-
if (n.operator ===
|
|
191166
|
+
if (import_typescript9.default.isPrefixUnaryExpression(n) || import_typescript9.default.isPostfixUnaryExpression(n)) {
|
|
191167
|
+
if (n.operator === import_typescript9.default.SyntaxKind.PlusPlusToken || n.operator === import_typescript9.default.SyntaxKind.MinusMinusToken) {
|
|
191103
191168
|
addFromTarget(n.operand);
|
|
191104
191169
|
}
|
|
191105
191170
|
}
|
|
191106
|
-
|
|
191171
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191107
191172
|
}
|
|
191108
191173
|
visit2(node);
|
|
191109
191174
|
const localDecls = collectLocalDeclarations(node);
|
|
@@ -191114,30 +191179,30 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191114
191179
|
function collectLocalDeclarations(root) {
|
|
191115
191180
|
const names = new Set;
|
|
191116
191181
|
function addBindingName(name) {
|
|
191117
|
-
if (
|
|
191182
|
+
if (import_typescript9.default.isIdentifier(name)) {
|
|
191118
191183
|
names.add(name.text);
|
|
191119
191184
|
return;
|
|
191120
191185
|
}
|
|
191121
|
-
if (
|
|
191186
|
+
if (import_typescript9.default.isArrayBindingPattern(name)) {
|
|
191122
191187
|
for (const el of name.elements) {
|
|
191123
|
-
if (
|
|
191188
|
+
if (import_typescript9.default.isBindingElement(el))
|
|
191124
191189
|
addBindingName(el.name);
|
|
191125
191190
|
}
|
|
191126
191191
|
return;
|
|
191127
191192
|
}
|
|
191128
|
-
if (
|
|
191193
|
+
if (import_typescript9.default.isObjectBindingPattern(name)) {
|
|
191129
191194
|
for (const el of name.elements) {
|
|
191130
191195
|
addBindingName(el.name);
|
|
191131
191196
|
}
|
|
191132
191197
|
}
|
|
191133
191198
|
}
|
|
191134
191199
|
function visit2(n) {
|
|
191135
|
-
if (
|
|
191200
|
+
if (import_typescript9.default.isArrowFunction(n) || import_typescript9.default.isFunctionExpression(n) || import_typescript9.default.isFunctionDeclaration(n))
|
|
191136
191201
|
return;
|
|
191137
|
-
if (
|
|
191202
|
+
if (import_typescript9.default.isVariableDeclaration(n)) {
|
|
191138
191203
|
addBindingName(n.name);
|
|
191139
191204
|
}
|
|
191140
|
-
|
|
191205
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191141
191206
|
}
|
|
191142
191207
|
visit2(root);
|
|
191143
191208
|
return names;
|
|
@@ -191171,35 +191236,35 @@ var CLIENT_EXPORTS = new Set([
|
|
|
191171
191236
|
"Region"
|
|
191172
191237
|
]);
|
|
191173
191238
|
function collectAmbientGlobals(node, ctx) {
|
|
191174
|
-
if (
|
|
191175
|
-
const isDeclare = node.modifiers?.some((m) => m.kind ===
|
|
191239
|
+
if (import_typescript9.default.isVariableStatement(node)) {
|
|
191240
|
+
const isDeclare = node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.DeclareKeyword) ?? false;
|
|
191176
191241
|
if (!isDeclare)
|
|
191177
191242
|
return;
|
|
191178
191243
|
for (const decl of node.declarationList.declarations) {
|
|
191179
|
-
if (
|
|
191244
|
+
if (import_typescript9.default.isIdentifier(decl.name))
|
|
191180
191245
|
ctx.ambientGlobals.add(decl.name.text);
|
|
191181
191246
|
}
|
|
191182
191247
|
return;
|
|
191183
191248
|
}
|
|
191184
|
-
if (
|
|
191185
|
-
const isDeclare = node.modifiers?.some((m) => m.kind ===
|
|
191249
|
+
if (import_typescript9.default.isFunctionDeclaration(node) && node.name) {
|
|
191250
|
+
const isDeclare = node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.DeclareKeyword) ?? false;
|
|
191186
191251
|
if (isDeclare)
|
|
191187
191252
|
ctx.ambientGlobals.add(node.name.text);
|
|
191188
191253
|
return;
|
|
191189
191254
|
}
|
|
191190
|
-
if (
|
|
191191
|
-
const isGlobalAugmentation = (node.flags &
|
|
191255
|
+
if (import_typescript9.default.isModuleDeclaration(node)) {
|
|
191256
|
+
const isGlobalAugmentation = (node.flags & import_typescript9.default.NodeFlags.GlobalAugmentation) !== 0;
|
|
191192
191257
|
if (!isGlobalAugmentation)
|
|
191193
191258
|
return;
|
|
191194
|
-
if (!node.body || !
|
|
191259
|
+
if (!node.body || !import_typescript9.default.isModuleBlock(node.body))
|
|
191195
191260
|
return;
|
|
191196
191261
|
for (const inner of node.body.statements) {
|
|
191197
|
-
if (
|
|
191262
|
+
if (import_typescript9.default.isVariableStatement(inner)) {
|
|
191198
191263
|
for (const decl of inner.declarationList.declarations) {
|
|
191199
|
-
if (
|
|
191264
|
+
if (import_typescript9.default.isIdentifier(decl.name))
|
|
191200
191265
|
ctx.ambientGlobals.add(decl.name.text);
|
|
191201
191266
|
}
|
|
191202
|
-
} else if (
|
|
191267
|
+
} else if (import_typescript9.default.isFunctionDeclaration(inner) && inner.name) {
|
|
191203
191268
|
ctx.ambientGlobals.add(inner.name.text);
|
|
191204
191269
|
}
|
|
191205
191270
|
}
|
|
@@ -191210,7 +191275,7 @@ function collectImport(node, ctx) {
|
|
|
191210
191275
|
const specifiers = [];
|
|
191211
191276
|
const isTypeOnly = !!node.importClause?.isTypeOnly;
|
|
191212
191277
|
const loc = getSourceLocation(node, ctx.sourceFile, ctx.filePath);
|
|
191213
|
-
if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings &&
|
|
191278
|
+
if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings && import_typescript9.default.isNamedImports(node.importClause.namedBindings)) {
|
|
191214
191279
|
const wrongImports = [];
|
|
191215
191280
|
for (const element of node.importClause.namedBindings.elements) {
|
|
191216
191281
|
const name = element.propertyName?.text ?? element.name.text;
|
|
@@ -191238,7 +191303,7 @@ function collectImport(node, ctx) {
|
|
|
191238
191303
|
});
|
|
191239
191304
|
}
|
|
191240
191305
|
if (node.importClause.namedBindings) {
|
|
191241
|
-
if (
|
|
191306
|
+
if (import_typescript9.default.isNamedImports(node.importClause.namedBindings)) {
|
|
191242
191307
|
for (const element of node.importClause.namedBindings.elements) {
|
|
191243
191308
|
specifiers.push({
|
|
191244
191309
|
name: element.propertyName?.text ?? element.name.text,
|
|
@@ -191249,7 +191314,7 @@ function collectImport(node, ctx) {
|
|
|
191249
191314
|
});
|
|
191250
191315
|
}
|
|
191251
191316
|
}
|
|
191252
|
-
if (
|
|
191317
|
+
if (import_typescript9.default.isNamespaceImport(node.importClause.namedBindings)) {
|
|
191253
191318
|
specifiers.push({
|
|
191254
191319
|
name: node.importClause.namedBindings.name.text,
|
|
191255
191320
|
alias: null,
|
|
@@ -191276,7 +191341,7 @@ function collectInterfaceDefinition(node, ctx) {
|
|
|
191276
191341
|
});
|
|
191277
191342
|
}
|
|
191278
191343
|
function collectTypeAliasDefinition(node, ctx) {
|
|
191279
|
-
const properties =
|
|
191344
|
+
const properties = import_typescript9.default.isTypeLiteralNode(node.type) ? membersToProperties(node.type.members, ctx.sourceFile) : undefined;
|
|
191280
191345
|
ctx.typeDefinitions.push({
|
|
191281
191346
|
kind: "type",
|
|
191282
191347
|
name: node.name.text,
|
|
@@ -191289,20 +191354,20 @@ function extractSingleJsxReturn(body) {
|
|
|
191289
191354
|
let jsxReturn = null;
|
|
191290
191355
|
let returnCount = 0;
|
|
191291
191356
|
function visit2(node) {
|
|
191292
|
-
if (
|
|
191357
|
+
if (import_typescript9.default.isFunctionDeclaration(node) || import_typescript9.default.isFunctionExpression(node) || import_typescript9.default.isArrowFunction(node))
|
|
191293
191358
|
return;
|
|
191294
|
-
if (
|
|
191359
|
+
if (import_typescript9.default.isReturnStatement(node)) {
|
|
191295
191360
|
returnCount++;
|
|
191296
191361
|
if (node.expression) {
|
|
191297
191362
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191298
|
-
if (
|
|
191363
|
+
if (import_typescript9.default.isJsxElement(expr) || import_typescript9.default.isJsxSelfClosingElement(expr) || import_typescript9.default.isJsxFragment(expr)) {
|
|
191299
191364
|
jsxReturn = expr;
|
|
191300
191365
|
}
|
|
191301
191366
|
}
|
|
191302
191367
|
}
|
|
191303
|
-
|
|
191368
|
+
import_typescript9.default.forEachChild(node, visit2);
|
|
191304
191369
|
}
|
|
191305
|
-
|
|
191370
|
+
import_typescript9.default.forEachChild(body, visit2);
|
|
191306
191371
|
if (returnCount !== 1)
|
|
191307
191372
|
return null;
|
|
191308
191373
|
return jsxReturn;
|
|
@@ -191319,9 +191384,9 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191319
191384
|
const stmts = body.statements;
|
|
191320
191385
|
for (let i2 = 0;i2 < stmts.length; i2++) {
|
|
191321
191386
|
const stmt = stmts[i2];
|
|
191322
|
-
if (
|
|
191387
|
+
if (import_typescript9.default.isIfStatement(stmt)) {
|
|
191323
191388
|
let current = stmt;
|
|
191324
|
-
while (
|
|
191389
|
+
while (import_typescript9.default.isIfStatement(current)) {
|
|
191325
191390
|
const ifStmt = current;
|
|
191326
191391
|
if (!isDirectReturnBlock(ifStmt.thenStatement))
|
|
191327
191392
|
return null;
|
|
@@ -191331,7 +191396,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191331
191396
|
return null;
|
|
191332
191397
|
branches.push({ condition: ifStmt.expression, jsxReturn: jsxReturn ?? null });
|
|
191333
191398
|
if (ifStmt.elseStatement) {
|
|
191334
|
-
if (
|
|
191399
|
+
if (import_typescript9.default.isIfStatement(ifStmt.elseStatement)) {
|
|
191335
191400
|
current = ifStmt.elseStatement;
|
|
191336
191401
|
continue;
|
|
191337
191402
|
}
|
|
@@ -191353,18 +191418,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191353
191418
|
}
|
|
191354
191419
|
continue;
|
|
191355
191420
|
}
|
|
191356
|
-
if (
|
|
191421
|
+
if (import_typescript9.default.isSwitchStatement(stmt)) {
|
|
191357
191422
|
if (branches.length > 0)
|
|
191358
191423
|
return null;
|
|
191359
|
-
if (!
|
|
191424
|
+
if (!import_typescript9.default.isIdentifier(stmt.expression) && !import_typescript9.default.isPropertyAccessExpression(stmt.expression)) {
|
|
191360
191425
|
return null;
|
|
191361
191426
|
}
|
|
191362
|
-
const hasDefault = stmt.caseBlock.clauses.some((c) =>
|
|
191427
|
+
const hasDefault = stmt.caseBlock.clauses.some((c) => import_typescript9.default.isDefaultClause(c));
|
|
191363
191428
|
if (!hasDefault)
|
|
191364
191429
|
return null;
|
|
191365
191430
|
let pendingCases = [];
|
|
191366
191431
|
for (const clause of stmt.caseBlock.clauses) {
|
|
191367
|
-
if (
|
|
191432
|
+
if (import_typescript9.default.isCaseClause(clause) && clause.statements.length === 0) {
|
|
191368
191433
|
pendingCases.push(clause.expression);
|
|
191369
191434
|
continue;
|
|
191370
191435
|
}
|
|
@@ -191374,7 +191439,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191374
191439
|
return null;
|
|
191375
191440
|
if (!caseClauseIsDirectReturn(clause))
|
|
191376
191441
|
return null;
|
|
191377
|
-
if (
|
|
191442
|
+
if (import_typescript9.default.isCaseClause(clause)) {
|
|
191378
191443
|
branches.push({
|
|
191379
191444
|
condition: clause.expression,
|
|
191380
191445
|
jsxReturn: jsxReturn ?? null,
|
|
@@ -191395,18 +191460,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191395
191460
|
return null;
|
|
191396
191461
|
return { branches, fallback, switchDiscriminant: stmt.expression, preamble };
|
|
191397
191462
|
}
|
|
191398
|
-
if (
|
|
191463
|
+
if (import_typescript9.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191399
191464
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191400
|
-
if (
|
|
191465
|
+
if (import_typescript9.default.isJsxElement(expr) || import_typescript9.default.isJsxSelfClosingElement(expr) || import_typescript9.default.isJsxFragment(expr)) {
|
|
191401
191466
|
fallback = expr;
|
|
191402
|
-
} else if (expr.kind ===
|
|
191467
|
+
} else if (expr.kind === import_typescript9.default.SyntaxKind.NullKeyword) {} else {
|
|
191403
191468
|
return null;
|
|
191404
191469
|
}
|
|
191405
191470
|
continue;
|
|
191406
191471
|
}
|
|
191407
|
-
if (
|
|
191472
|
+
if (import_typescript9.default.isVariableStatement(stmt)) {
|
|
191408
191473
|
const declFlags = stmt.declarationList.flags;
|
|
191409
|
-
const isConstOrLet = (declFlags &
|
|
191474
|
+
const isConstOrLet = (declFlags & import_typescript9.default.NodeFlags.Const) !== 0 || (declFlags & import_typescript9.default.NodeFlags.Let) !== 0;
|
|
191410
191475
|
if (allowPreamble && isConstOrLet && branches.length === 0 && fallback === null) {
|
|
191411
191476
|
preamble.push(stmt);
|
|
191412
191477
|
continue;
|
|
@@ -191422,12 +191487,12 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191422
191487
|
return { branches, fallback, preamble };
|
|
191423
191488
|
}
|
|
191424
191489
|
function isDirectReturnBlock(node) {
|
|
191425
|
-
if (
|
|
191490
|
+
if (import_typescript9.default.isReturnStatement(node))
|
|
191426
191491
|
return true;
|
|
191427
|
-
if (
|
|
191492
|
+
if (import_typescript9.default.isBlock(node)) {
|
|
191428
191493
|
let returnCount = 0;
|
|
191429
191494
|
for (const stmt of node.statements) {
|
|
191430
|
-
if (
|
|
191495
|
+
if (import_typescript9.default.isReturnStatement(stmt)) {
|
|
191431
191496
|
returnCount++;
|
|
191432
191497
|
continue;
|
|
191433
191498
|
}
|
|
@@ -191438,25 +191503,25 @@ function isDirectReturnBlock(node) {
|
|
|
191438
191503
|
return false;
|
|
191439
191504
|
}
|
|
191440
191505
|
function findNullReturnInBlock(node) {
|
|
191441
|
-
if (
|
|
191506
|
+
if (import_typescript9.default.isBlock(node)) {
|
|
191442
191507
|
for (const stmt of node.statements) {
|
|
191443
|
-
if (
|
|
191508
|
+
if (import_typescript9.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191444
191509
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191445
|
-
if (expr.kind ===
|
|
191510
|
+
if (expr.kind === import_typescript9.default.SyntaxKind.NullKeyword)
|
|
191446
191511
|
return true;
|
|
191447
191512
|
}
|
|
191448
191513
|
}
|
|
191449
191514
|
}
|
|
191450
|
-
if (
|
|
191515
|
+
if (import_typescript9.default.isReturnStatement(node) && node.expression) {
|
|
191451
191516
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191452
|
-
if (expr.kind ===
|
|
191517
|
+
if (expr.kind === import_typescript9.default.SyntaxKind.NullKeyword)
|
|
191453
191518
|
return true;
|
|
191454
191519
|
}
|
|
191455
191520
|
return false;
|
|
191456
191521
|
}
|
|
191457
191522
|
function findJsxReturnInCaseClause(clause) {
|
|
191458
191523
|
for (const stmt of clause.statements) {
|
|
191459
|
-
if (
|
|
191524
|
+
if (import_typescript9.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191460
191525
|
return extractJsxFromExpression(stmt.expression);
|
|
191461
191526
|
}
|
|
191462
191527
|
}
|
|
@@ -191466,12 +191531,12 @@ function caseClauseIsDirectReturn(clause) {
|
|
|
191466
191531
|
let returnCount = 0;
|
|
191467
191532
|
let seenReturn = false;
|
|
191468
191533
|
for (const stmt of clause.statements) {
|
|
191469
|
-
if (
|
|
191534
|
+
if (import_typescript9.default.isReturnStatement(stmt)) {
|
|
191470
191535
|
returnCount++;
|
|
191471
191536
|
seenReturn = true;
|
|
191472
191537
|
continue;
|
|
191473
191538
|
}
|
|
191474
|
-
if (
|
|
191539
|
+
if (import_typescript9.default.isBreakStatement(stmt)) {
|
|
191475
191540
|
if (!seenReturn)
|
|
191476
191541
|
return false;
|
|
191477
191542
|
continue;
|
|
@@ -191482,9 +191547,9 @@ function caseClauseIsDirectReturn(clause) {
|
|
|
191482
191547
|
}
|
|
191483
191548
|
function findNullReturnInCaseClause(clause) {
|
|
191484
191549
|
for (const stmt of clause.statements) {
|
|
191485
|
-
if (
|
|
191550
|
+
if (import_typescript9.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191486
191551
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191487
|
-
if (expr.kind ===
|
|
191552
|
+
if (expr.kind === import_typescript9.default.SyntaxKind.NullKeyword)
|
|
191488
191553
|
return true;
|
|
191489
191554
|
}
|
|
191490
191555
|
}
|
|
@@ -191495,26 +191560,26 @@ function isMultiReturnJsxFunctionBody(body) {
|
|
|
191495
191560
|
let hasJsxReturn = false;
|
|
191496
191561
|
let allReturnsAreJsxOrNull = true;
|
|
191497
191562
|
function visit2(node) {
|
|
191498
|
-
if (
|
|
191563
|
+
if (import_typescript9.default.isFunctionDeclaration(node) || import_typescript9.default.isFunctionExpression(node) || import_typescript9.default.isArrowFunction(node))
|
|
191499
191564
|
return;
|
|
191500
|
-
if (
|
|
191565
|
+
if (import_typescript9.default.isReturnStatement(node)) {
|
|
191501
191566
|
returnCount++;
|
|
191502
191567
|
if (!node.expression) {
|
|
191503
191568
|
allReturnsAreJsxOrNull = false;
|
|
191504
191569
|
return;
|
|
191505
191570
|
}
|
|
191506
191571
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191507
|
-
const isJsx =
|
|
191508
|
-
const isNull2 = expr.kind ===
|
|
191572
|
+
const isJsx = import_typescript9.default.isJsxElement(expr) || import_typescript9.default.isJsxSelfClosingElement(expr) || import_typescript9.default.isJsxFragment(expr);
|
|
191573
|
+
const isNull2 = expr.kind === import_typescript9.default.SyntaxKind.NullKeyword;
|
|
191509
191574
|
if (isJsx)
|
|
191510
191575
|
hasJsxReturn = true;
|
|
191511
191576
|
if (!isJsx && !isNull2)
|
|
191512
191577
|
allReturnsAreJsxOrNull = false;
|
|
191513
191578
|
return;
|
|
191514
191579
|
}
|
|
191515
|
-
|
|
191580
|
+
import_typescript9.default.forEachChild(node, visit2);
|
|
191516
191581
|
}
|
|
191517
|
-
|
|
191582
|
+
import_typescript9.default.forEachChild(body, visit2);
|
|
191518
191583
|
return returnCount > 1 && hasJsxReturn && allReturnsAreJsxOrNull;
|
|
191519
191584
|
}
|
|
191520
191585
|
function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
@@ -191584,7 +191649,7 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
|
191584
191649
|
}
|
|
191585
191650
|
}
|
|
191586
191651
|
}
|
|
191587
|
-
const isAsync = node.modifiers?.some((m) => m.kind ===
|
|
191652
|
+
const isAsync = node.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.AsyncKeyword) ?? false;
|
|
191588
191653
|
const isGenerator = !!node.asteriskToken;
|
|
191589
191654
|
ctx.localFunctions.push({
|
|
191590
191655
|
name,
|
|
@@ -191605,10 +191670,10 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
|
191605
191670
|
});
|
|
191606
191671
|
}
|
|
191607
191672
|
function extractValueBranches(node, ctx) {
|
|
191608
|
-
if (
|
|
191673
|
+
if (import_typescript9.default.isParenthesizedExpression(node)) {
|
|
191609
191674
|
return extractValueBranches(node.expression, ctx);
|
|
191610
191675
|
}
|
|
191611
|
-
if (
|
|
191676
|
+
if (import_typescript9.default.isConditionalExpression(node)) {
|
|
191612
191677
|
return [
|
|
191613
191678
|
...extractValueBranches(node.whenTrue, ctx),
|
|
191614
191679
|
...extractValueBranches(node.whenFalse, ctx)
|
|
@@ -191620,46 +191685,46 @@ function extractFreeIdentifiersFromNode(node) {
|
|
|
191620
191685
|
const ids = new Set;
|
|
191621
191686
|
const boundNames = new Set;
|
|
191622
191687
|
function addBindingNames(name, out) {
|
|
191623
|
-
if (
|
|
191688
|
+
if (import_typescript9.default.isIdentifier(name))
|
|
191624
191689
|
out.push(name.text);
|
|
191625
|
-
else if (
|
|
191690
|
+
else if (import_typescript9.default.isObjectBindingPattern(name))
|
|
191626
191691
|
name.elements.forEach((e) => addBindingNames(e.name, out));
|
|
191627
|
-
else if (
|
|
191692
|
+
else if (import_typescript9.default.isArrayBindingPattern(name))
|
|
191628
191693
|
name.elements.forEach((e) => {
|
|
191629
|
-
if (!
|
|
191694
|
+
if (!import_typescript9.default.isOmittedExpression(e))
|
|
191630
191695
|
addBindingNames(e.name, out);
|
|
191631
191696
|
});
|
|
191632
191697
|
}
|
|
191633
191698
|
function visit2(n) {
|
|
191634
|
-
if (
|
|
191699
|
+
if (import_typescript9.default.isTypeNode(n))
|
|
191635
191700
|
return;
|
|
191636
|
-
if (
|
|
191701
|
+
if (import_typescript9.default.isIdentifier(n)) {
|
|
191637
191702
|
const parent = n.parent;
|
|
191638
|
-
if (parent &&
|
|
191703
|
+
if (parent && import_typescript9.default.isPropertyAccessExpression(parent) && parent.name === n)
|
|
191639
191704
|
return;
|
|
191640
|
-
if (parent &&
|
|
191705
|
+
if (parent && import_typescript9.default.isPropertyAssignment(parent) && parent.name === n)
|
|
191641
191706
|
return;
|
|
191642
|
-
if (parent &&
|
|
191707
|
+
if (parent && import_typescript9.default.isParameter(parent) && parent.name === n)
|
|
191643
191708
|
return;
|
|
191644
|
-
if (parent &&
|
|
191709
|
+
if (parent && import_typescript9.default.isVariableDeclaration(parent) && parent.name === n)
|
|
191645
191710
|
return;
|
|
191646
191711
|
if (boundNames.has(n.text))
|
|
191647
191712
|
return;
|
|
191648
191713
|
ids.add(n.text);
|
|
191649
191714
|
return;
|
|
191650
191715
|
}
|
|
191651
|
-
if (
|
|
191716
|
+
if (import_typescript9.default.isArrowFunction(n)) {
|
|
191652
191717
|
const params = [];
|
|
191653
191718
|
for (const p of n.parameters)
|
|
191654
191719
|
addBindingNames(p.name, params);
|
|
191655
191720
|
for (const name of params)
|
|
191656
191721
|
boundNames.add(name);
|
|
191657
|
-
|
|
191722
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191658
191723
|
for (const name of params)
|
|
191659
191724
|
boundNames.delete(name);
|
|
191660
191725
|
return;
|
|
191661
191726
|
}
|
|
191662
|
-
|
|
191727
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191663
191728
|
}
|
|
191664
191729
|
visit2(node);
|
|
191665
191730
|
return ids;
|
|
@@ -191668,29 +191733,29 @@ function extractFreeTypeIdentifiersFromNode(node) {
|
|
|
191668
191733
|
const ids = new Set;
|
|
191669
191734
|
const boundTypeParams = new Set;
|
|
191670
191735
|
function rootName(name) {
|
|
191671
|
-
return
|
|
191736
|
+
return import_typescript9.default.isQualifiedName(name) ? rootName(name.left) : name;
|
|
191672
191737
|
}
|
|
191673
191738
|
function visit2(n) {
|
|
191674
|
-
if (
|
|
191739
|
+
if (import_typescript9.default.isTypeReferenceNode(n)) {
|
|
191675
191740
|
const name = rootName(n.typeName).text;
|
|
191676
191741
|
if (!boundTypeParams.has(name))
|
|
191677
191742
|
ids.add(name);
|
|
191678
191743
|
}
|
|
191679
|
-
if (
|
|
191744
|
+
if (import_typescript9.default.isTypeQueryNode(n)) {
|
|
191680
191745
|
const name = rootName(n.exprName).text;
|
|
191681
191746
|
if (!boundTypeParams.has(name))
|
|
191682
191747
|
ids.add(name);
|
|
191683
191748
|
}
|
|
191684
|
-
if (
|
|
191749
|
+
if (import_typescript9.default.isFunctionLike(n) && n.typeParameters && n.typeParameters.length > 0) {
|
|
191685
191750
|
const names = n.typeParameters.map((p) => p.name.text);
|
|
191686
191751
|
for (const p of names)
|
|
191687
191752
|
boundTypeParams.add(p);
|
|
191688
|
-
|
|
191753
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191689
191754
|
for (const p of names)
|
|
191690
191755
|
boundTypeParams.delete(p);
|
|
191691
191756
|
return;
|
|
191692
191757
|
}
|
|
191693
|
-
|
|
191758
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191694
191759
|
}
|
|
191695
191760
|
visit2(node);
|
|
191696
191761
|
return ids;
|
|
@@ -191700,22 +191765,22 @@ function initializerShapeContainsJsx(node) {
|
|
|
191700
191765
|
function visit2(n) {
|
|
191701
191766
|
if (found)
|
|
191702
191767
|
return;
|
|
191703
|
-
if (
|
|
191768
|
+
if (import_typescript9.default.isJsxElement(n) || import_typescript9.default.isJsxSelfClosingElement(n) || import_typescript9.default.isJsxFragment(n)) {
|
|
191704
191769
|
found = true;
|
|
191705
191770
|
return;
|
|
191706
191771
|
}
|
|
191707
|
-
if (
|
|
191772
|
+
if (import_typescript9.default.isFunctionDeclaration(n) || import_typescript9.default.isFunctionExpression(n) || import_typescript9.default.isArrowFunction(n)) {
|
|
191708
191773
|
return;
|
|
191709
191774
|
}
|
|
191710
|
-
|
|
191775
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191711
191776
|
}
|
|
191712
191777
|
visit2(node);
|
|
191713
191778
|
return found;
|
|
191714
191779
|
}
|
|
191715
191780
|
function isMapLikeCallWithJsx(node) {
|
|
191716
|
-
if (!
|
|
191781
|
+
if (!import_typescript9.default.isCallExpression(node))
|
|
191717
191782
|
return false;
|
|
191718
|
-
if (!
|
|
191783
|
+
if (!import_typescript9.default.isPropertyAccessExpression(node.expression))
|
|
191719
191784
|
return false;
|
|
191720
191785
|
const method = node.expression.name.text;
|
|
191721
191786
|
if (method !== "map" && method !== "flatMap")
|
|
@@ -191723,12 +191788,12 @@ function isMapLikeCallWithJsx(node) {
|
|
|
191723
191788
|
const callback = node.arguments[0];
|
|
191724
191789
|
if (!callback)
|
|
191725
191790
|
return false;
|
|
191726
|
-
if (!
|
|
191791
|
+
if (!import_typescript9.default.isArrowFunction(callback) && !import_typescript9.default.isFunctionExpression(callback))
|
|
191727
191792
|
return false;
|
|
191728
191793
|
return containsJsxDeep(callback.body);
|
|
191729
191794
|
}
|
|
191730
191795
|
function containsJsxDeep(node) {
|
|
191731
|
-
if (
|
|
191796
|
+
if (import_typescript9.default.isJsxElement(node) || import_typescript9.default.isJsxSelfClosingElement(node) || import_typescript9.default.isJsxFragment(node))
|
|
191732
191797
|
return true;
|
|
191733
191798
|
let found = false;
|
|
191734
191799
|
node.forEachChild((child) => {
|
|
@@ -191742,11 +191807,11 @@ function nodeContainsArrow(node) {
|
|
|
191742
191807
|
function visit2(n) {
|
|
191743
191808
|
if (found)
|
|
191744
191809
|
return;
|
|
191745
|
-
if (
|
|
191810
|
+
if (import_typescript9.default.isArrowFunction(n) || import_typescript9.default.isFunctionExpression(n)) {
|
|
191746
191811
|
found = true;
|
|
191747
191812
|
return;
|
|
191748
191813
|
}
|
|
191749
|
-
|
|
191814
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
191750
191815
|
}
|
|
191751
191816
|
visit2(node);
|
|
191752
191817
|
return found;
|
|
@@ -191794,20 +191859,20 @@ function collectModuleScopeReactive(decl, ctx, isExported) {
|
|
|
191794
191859
|
}));
|
|
191795
191860
|
}
|
|
191796
191861
|
function getSystemConstructKind(node) {
|
|
191797
|
-
if (
|
|
191862
|
+
if (import_typescript9.default.isCallExpression(node) && import_typescript9.default.isIdentifier(node.expression) && node.expression.text === "createContext")
|
|
191798
191863
|
return "createContext";
|
|
191799
|
-
if (
|
|
191864
|
+
if (import_typescript9.default.isNewExpression(node) && import_typescript9.default.isIdentifier(node.expression) && node.expression.text === "WeakMap")
|
|
191800
191865
|
return "weakMap";
|
|
191801
191866
|
return;
|
|
191802
191867
|
}
|
|
191803
191868
|
function collectConstant(node, ctx, _isModule, declarationKind = "const", isExported = false) {
|
|
191804
|
-
if (!_isModule &&
|
|
191869
|
+
if (!_isModule && import_typescript9.default.isObjectBindingPattern(node.name) && node.initializer && import_typescript9.default.isIdentifier(node.initializer) && ctx.propsObjectName === node.initializer.text) {
|
|
191805
191870
|
const propsName = node.initializer.text;
|
|
191806
191871
|
for (const el of node.name.elements) {
|
|
191807
|
-
if (!
|
|
191872
|
+
if (!import_typescript9.default.isBindingElement(el) || !import_typescript9.default.isIdentifier(el.name) || el.dotDotDotToken)
|
|
191808
191873
|
continue;
|
|
191809
191874
|
const localName = el.name.text;
|
|
191810
|
-
const sourceKey = el.propertyName &&
|
|
191875
|
+
const sourceKey = el.propertyName && import_typescript9.default.isIdentifier(el.propertyName) ? el.propertyName.text : localName;
|
|
191811
191876
|
const defaultValueExpr = el.initializer ? ctx.getJS(el.initializer) : undefined;
|
|
191812
191877
|
const baseValue = `${propsName}.${sourceKey}`;
|
|
191813
191878
|
const value2 = defaultValueExpr ? `${baseValue} ?? ${defaultValueExpr}` : baseValue;
|
|
@@ -191827,7 +191892,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191827
191892
|
}
|
|
191828
191893
|
return;
|
|
191829
191894
|
}
|
|
191830
|
-
if (!
|
|
191895
|
+
if (!import_typescript9.default.isIdentifier(node.name))
|
|
191831
191896
|
return;
|
|
191832
191897
|
if (isSignalDeclaration(node, ctx) || isMemoDeclaration(node, ctx))
|
|
191833
191898
|
return;
|
|
@@ -191845,9 +191910,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191845
191910
|
let isJsxFunction = false;
|
|
191846
191911
|
if (node.initializer) {
|
|
191847
191912
|
let init = node.initializer;
|
|
191848
|
-
while (
|
|
191913
|
+
while (import_typescript9.default.isParenthesizedExpression(init))
|
|
191849
191914
|
init = init.expression;
|
|
191850
|
-
if (
|
|
191915
|
+
if (import_typescript9.default.isJsxElement(init) || import_typescript9.default.isJsxSelfClosingElement(init) || import_typescript9.default.isJsxFragment(init)) {
|
|
191851
191916
|
isJsx = true;
|
|
191852
191917
|
ctx.jsxConstants.set(name, init);
|
|
191853
191918
|
} else if (initializerShapeContainsJsx(init)) {
|
|
@@ -191855,9 +191920,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191855
191920
|
} else if (isMapLikeCallWithJsx(init)) {
|
|
191856
191921
|
ctx.inlineableJsxConsts.set(name, init);
|
|
191857
191922
|
}
|
|
191858
|
-
if (
|
|
191923
|
+
if (import_typescript9.default.isArrowFunction(init)) {
|
|
191859
191924
|
const arrowBody = init.body;
|
|
191860
|
-
if (
|
|
191925
|
+
if (import_typescript9.default.isBlock(arrowBody)) {
|
|
191861
191926
|
const jsxReturn = extractSingleJsxReturn(arrowBody);
|
|
191862
191927
|
if (jsxReturn) {
|
|
191863
191928
|
isJsxFunction = true;
|
|
@@ -191877,9 +191942,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191877
191942
|
}
|
|
191878
191943
|
} else {
|
|
191879
191944
|
let body = arrowBody;
|
|
191880
|
-
while (
|
|
191945
|
+
while (import_typescript9.default.isParenthesizedExpression(body))
|
|
191881
191946
|
body = body.expression;
|
|
191882
|
-
if (
|
|
191947
|
+
if (import_typescript9.default.isJsxElement(body) || import_typescript9.default.isJsxSelfClosingElement(body) || import_typescript9.default.isJsxFragment(body)) {
|
|
191883
191948
|
isJsxFunction = true;
|
|
191884
191949
|
ctx.jsxFunctions.set(name, {
|
|
191885
191950
|
jsxReturn: body,
|
|
@@ -191892,9 +191957,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191892
191957
|
let valueBranches;
|
|
191893
191958
|
if (node.initializer) {
|
|
191894
191959
|
let inner = node.initializer;
|
|
191895
|
-
while (
|
|
191960
|
+
while (import_typescript9.default.isParenthesizedExpression(inner))
|
|
191896
191961
|
inner = inner.expression;
|
|
191897
|
-
if (
|
|
191962
|
+
if (import_typescript9.default.isConditionalExpression(inner)) {
|
|
191898
191963
|
valueBranches = extractValueBranches(node.initializer, ctx);
|
|
191899
191964
|
}
|
|
191900
191965
|
}
|
|
@@ -191910,8 +191975,10 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191910
191975
|
let templateValue;
|
|
191911
191976
|
if (value && ctx.propsParams.length > 0 && node.initializer) {
|
|
191912
191977
|
let propNames;
|
|
191978
|
+
let propAliases;
|
|
191913
191979
|
if (!ctx.propsObjectName) {
|
|
191914
191980
|
propNames = new Set(ctx.propsParams.map((p) => p.name));
|
|
191981
|
+
propAliases = buildPropAliasMap(ctx.propsParams);
|
|
191915
191982
|
} else {
|
|
191916
191983
|
const shadowedByNonAlias = new Set;
|
|
191917
191984
|
for (const s of ctx.signals) {
|
|
@@ -191932,7 +191999,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191932
191999
|
propNames = new Set([...aliases].filter((n) => !shadowedByNonAlias.has(n)));
|
|
191933
192000
|
}
|
|
191934
192001
|
if (propNames.size > 0) {
|
|
191935
|
-
const rewritten = rewriteBarePropRefs(value, node.initializer, propNames);
|
|
192002
|
+
const rewritten = rewriteBarePropRefs(value, node.initializer, propNames, undefined, propAliases);
|
|
191936
192003
|
if (rewritten !== undefined) {
|
|
191937
192004
|
templateValue = rewritten;
|
|
191938
192005
|
if (ctx.propsObjectName) {
|
|
@@ -191947,6 +192014,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191947
192014
|
value,
|
|
191948
192015
|
parsed,
|
|
191949
192016
|
typedValue: typedValue !== value ? typedValue : undefined,
|
|
192017
|
+
typeAnnotation: node.type ? node.type.getText(ctx.sourceFile) : undefined,
|
|
191950
192018
|
valueBranches,
|
|
191951
192019
|
declarationKind,
|
|
191952
192020
|
isExported,
|
|
@@ -191969,7 +192037,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
191969
192037
|
function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
191970
192038
|
const checkComments = (targetNode) => {
|
|
191971
192039
|
const fullStart = targetNode.getFullStart();
|
|
191972
|
-
const leadingComments =
|
|
192040
|
+
const leadingComments = import_typescript9.default.getLeadingCommentRanges(sourceFile.getFullText(), fullStart);
|
|
191973
192041
|
if (!leadingComments)
|
|
191974
192042
|
return false;
|
|
191975
192043
|
for (const range of leadingComments) {
|
|
@@ -191982,10 +192050,10 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
|
191982
192050
|
};
|
|
191983
192051
|
if (checkComments(node))
|
|
191984
192052
|
return true;
|
|
191985
|
-
if (
|
|
192053
|
+
if (import_typescript9.default.isArrowFunction(node)) {
|
|
191986
192054
|
let current = node.parent;
|
|
191987
192055
|
while (current) {
|
|
191988
|
-
if (
|
|
192056
|
+
if (import_typescript9.default.isVariableStatement(current)) {
|
|
191989
192057
|
if (checkComments(current))
|
|
191990
192058
|
return true;
|
|
191991
192059
|
break;
|
|
@@ -191996,7 +192064,7 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
|
191996
192064
|
return false;
|
|
191997
192065
|
}
|
|
191998
192066
|
function extractProps(param, ctx) {
|
|
191999
|
-
if (
|
|
192067
|
+
if (import_typescript9.default.isObjectBindingPattern(param.name)) {
|
|
192000
192068
|
const componentNode = ctx.componentNode;
|
|
192001
192069
|
const ignored = !!(componentNode && hasIgnoreDirective(componentNode, ctx.sourceFile, "props-destructuring"));
|
|
192002
192070
|
ctx.propsDestructuring = {
|
|
@@ -192005,22 +192073,24 @@ function extractProps(param, ctx) {
|
|
|
192005
192073
|
};
|
|
192006
192074
|
const memberTypes = param.type ? collectMemberTypes(param.type, ctx) : null;
|
|
192007
192075
|
for (const element of param.name.elements) {
|
|
192008
|
-
if (
|
|
192076
|
+
if (import_typescript9.default.isBindingElement(element) && import_typescript9.default.isIdentifier(element.name)) {
|
|
192009
192077
|
const localName = element.name.text;
|
|
192010
192078
|
const defaultValue = element.initializer ? ctx.getJS(element.initializer) : undefined;
|
|
192011
192079
|
if (element.dotDotDotToken) {
|
|
192012
192080
|
ctx.restPropsName = localName;
|
|
192013
192081
|
continue;
|
|
192014
192082
|
}
|
|
192015
|
-
const sourcePropName = element.propertyName &&
|
|
192083
|
+
const sourcePropName = element.propertyName && import_typescript9.default.isIdentifier(element.propertyName) ? element.propertyName.text : localName;
|
|
192016
192084
|
const member = memberTypes?.get(sourcePropName);
|
|
192017
192085
|
const resolvedType = member?.type ?? { kind: "unknown", raw: "unknown" };
|
|
192018
192086
|
const defaultContainsArrow = element.initializer ? nodeContainsArrow(element.initializer) : false;
|
|
192087
|
+
const parsedDefault = element.initializer ? tsNodeToParsedExpr(element.initializer) : undefined;
|
|
192019
192088
|
ctx.propsParams.push({
|
|
192020
192089
|
name: localName,
|
|
192021
192090
|
type: resolvedType,
|
|
192022
192091
|
optional: !!member?.optional || !!element.initializer,
|
|
192023
192092
|
defaultValue,
|
|
192093
|
+
...parsedDefault && parsedDefault.kind !== "unsupported" && { parsed: parsedDefault },
|
|
192024
192094
|
defaultContainsArrow: defaultContainsArrow || undefined,
|
|
192025
192095
|
...sourcePropName !== localName && { sourceName: sourcePropName }
|
|
192026
192096
|
});
|
|
@@ -192034,7 +192104,7 @@ function extractProps(param, ctx) {
|
|
|
192034
192104
|
}
|
|
192035
192105
|
}
|
|
192036
192106
|
}
|
|
192037
|
-
if (
|
|
192107
|
+
if (import_typescript9.default.isIdentifier(param.name)) {
|
|
192038
192108
|
ctx.propsObjectName = param.name.text;
|
|
192039
192109
|
if (param.type) {
|
|
192040
192110
|
extractPropsFromType(param.type, ctx);
|
|
@@ -192045,24 +192115,24 @@ function extractProps(param, ctx) {
|
|
|
192045
192115
|
}
|
|
192046
192116
|
}
|
|
192047
192117
|
function collectTypeKeys(typeNode, ctx) {
|
|
192048
|
-
if (
|
|
192118
|
+
if (import_typescript9.default.isTypeLiteralNode(typeNode)) {
|
|
192049
192119
|
return collectKeysFromMembers(typeNode.members, ctx);
|
|
192050
192120
|
}
|
|
192051
|
-
if (
|
|
192121
|
+
if (import_typescript9.default.isTypeReferenceNode(typeNode)) {
|
|
192052
192122
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192053
192123
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192054
192124
|
if (!typeDecl)
|
|
192055
192125
|
return null;
|
|
192056
|
-
if (
|
|
192126
|
+
if (import_typescript9.default.isInterfaceDeclaration(typeDecl)) {
|
|
192057
192127
|
if (typeDecl.heritageClauses && typeDecl.heritageClauses.length > 0)
|
|
192058
192128
|
return null;
|
|
192059
192129
|
return collectKeysFromMembers(typeDecl.members, ctx);
|
|
192060
192130
|
}
|
|
192061
|
-
if (
|
|
192062
|
-
if (
|
|
192131
|
+
if (import_typescript9.default.isTypeAliasDeclaration(typeDecl)) {
|
|
192132
|
+
if (import_typescript9.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192063
192133
|
return collectKeysFromMembers(typeDecl.type.members, ctx);
|
|
192064
192134
|
}
|
|
192065
|
-
if (
|
|
192135
|
+
if (import_typescript9.default.isIntersectionTypeNode(typeDecl.type)) {
|
|
192066
192136
|
return null;
|
|
192067
192137
|
}
|
|
192068
192138
|
}
|
|
@@ -192072,9 +192142,9 @@ function collectTypeKeys(typeNode, ctx) {
|
|
|
192072
192142
|
function collectKeysFromMembers(members, ctx) {
|
|
192073
192143
|
const keys = [];
|
|
192074
192144
|
for (const member of members) {
|
|
192075
|
-
if (
|
|
192145
|
+
if (import_typescript9.default.isIndexSignatureDeclaration(member))
|
|
192076
192146
|
return null;
|
|
192077
|
-
if (
|
|
192147
|
+
if (import_typescript9.default.isPropertySignature(member) && member.name) {
|
|
192078
192148
|
keys.push(member.name.getText(ctx.sourceFile));
|
|
192079
192149
|
}
|
|
192080
192150
|
}
|
|
@@ -192085,7 +192155,7 @@ function collectMemberTypes(typeNode, ctx) {
|
|
|
192085
192155
|
const fromMembers = (members) => {
|
|
192086
192156
|
const map = new Map;
|
|
192087
192157
|
for (const member of members) {
|
|
192088
|
-
if (
|
|
192158
|
+
if (import_typescript9.default.isPropertySignature(member) && member.name) {
|
|
192089
192159
|
const info = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : null;
|
|
192090
192160
|
map.set(member.name.getText(ctx.sourceFile), {
|
|
192091
192161
|
type: info && isResolvablePrimitive(info) ? info : null,
|
|
@@ -192095,35 +192165,35 @@ function collectMemberTypes(typeNode, ctx) {
|
|
|
192095
192165
|
}
|
|
192096
192166
|
return map;
|
|
192097
192167
|
};
|
|
192098
|
-
if (
|
|
192168
|
+
if (import_typescript9.default.isTypeLiteralNode(typeNode)) {
|
|
192099
192169
|
return fromMembers(typeNode.members);
|
|
192100
192170
|
}
|
|
192101
|
-
if (
|
|
192171
|
+
if (import_typescript9.default.isTypeReferenceNode(typeNode)) {
|
|
192102
192172
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192103
192173
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192104
192174
|
if (!typeDecl)
|
|
192105
192175
|
return null;
|
|
192106
|
-
if (
|
|
192176
|
+
if (import_typescript9.default.isInterfaceDeclaration(typeDecl)) {
|
|
192107
192177
|
return fromMembers(typeDecl.members);
|
|
192108
192178
|
}
|
|
192109
|
-
if (
|
|
192179
|
+
if (import_typescript9.default.isTypeAliasDeclaration(typeDecl) && import_typescript9.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192110
192180
|
return fromMembers(typeDecl.type.members);
|
|
192111
192181
|
}
|
|
192112
192182
|
}
|
|
192113
192183
|
return null;
|
|
192114
192184
|
}
|
|
192115
192185
|
function extractPropsFromType(typeNode, ctx) {
|
|
192116
|
-
if (
|
|
192186
|
+
if (import_typescript9.default.isTypeLiteralNode(typeNode)) {
|
|
192117
192187
|
extractPropsFromTypeMembers(typeNode.members, ctx);
|
|
192118
192188
|
return;
|
|
192119
192189
|
}
|
|
192120
|
-
if (
|
|
192190
|
+
if (import_typescript9.default.isTypeReferenceNode(typeNode)) {
|
|
192121
192191
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192122
192192
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192123
192193
|
if (typeDecl) {
|
|
192124
|
-
if (
|
|
192194
|
+
if (import_typescript9.default.isInterfaceDeclaration(typeDecl)) {
|
|
192125
192195
|
extractPropsFromTypeMembers(typeDecl.members, ctx);
|
|
192126
|
-
} else if (
|
|
192196
|
+
} else if (import_typescript9.default.isTypeAliasDeclaration(typeDecl) && import_typescript9.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192127
192197
|
extractPropsFromTypeMembers(typeDecl.type.members, ctx);
|
|
192128
192198
|
}
|
|
192129
192199
|
}
|
|
@@ -192131,7 +192201,7 @@ function extractPropsFromType(typeNode, ctx) {
|
|
|
192131
192201
|
}
|
|
192132
192202
|
function extractPropsFromTypeMembers(members, ctx) {
|
|
192133
192203
|
for (const member of members) {
|
|
192134
|
-
if (
|
|
192204
|
+
if (import_typescript9.default.isPropertySignature(member) && member.name) {
|
|
192135
192205
|
const propName = member.name.getText(ctx.sourceFile);
|
|
192136
192206
|
const isOptional = !!member.questionToken;
|
|
192137
192207
|
const propType = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : { kind: "unknown", raw: "unknown" };
|
|
@@ -192147,17 +192217,17 @@ function extractPropsFromTypeMembers(members, ctx) {
|
|
|
192147
192217
|
function findTypeDeclaration(typeName, sourceFile) {
|
|
192148
192218
|
let result;
|
|
192149
192219
|
function visit2(node) {
|
|
192150
|
-
if (
|
|
192220
|
+
if (import_typescript9.default.isInterfaceDeclaration(node) && node.name.text === typeName) {
|
|
192151
192221
|
result = node;
|
|
192152
192222
|
return;
|
|
192153
192223
|
}
|
|
192154
|
-
if (
|
|
192224
|
+
if (import_typescript9.default.isTypeAliasDeclaration(node) && node.name.text === typeName) {
|
|
192155
192225
|
result = node;
|
|
192156
192226
|
return;
|
|
192157
192227
|
}
|
|
192158
|
-
|
|
192228
|
+
import_typescript9.default.forEachChild(node, visit2);
|
|
192159
192229
|
}
|
|
192160
|
-
|
|
192230
|
+
import_typescript9.default.forEachChild(sourceFile, visit2);
|
|
192161
192231
|
return result;
|
|
192162
192232
|
}
|
|
192163
192233
|
function inferTypeFromValue(value) {
|
|
@@ -192201,17 +192271,28 @@ function inferTypeFromValue(value) {
|
|
|
192201
192271
|
}
|
|
192202
192272
|
return { kind: "unknown", raw: "unknown" };
|
|
192203
192273
|
}
|
|
192274
|
+
function collectCalledIdentifiers(code2) {
|
|
192275
|
+
const called = new Set;
|
|
192276
|
+
const sf = import_typescript9.default.createSourceFile("__deps__.tsx", code2, import_typescript9.default.ScriptTarget.Latest, false, import_typescript9.default.ScriptKind.TSX);
|
|
192277
|
+
const visit2 = (node) => {
|
|
192278
|
+
if (import_typescript9.default.isCallExpression(node) && import_typescript9.default.isIdentifier(node.expression)) {
|
|
192279
|
+
called.add(node.expression.text);
|
|
192280
|
+
}
|
|
192281
|
+
import_typescript9.default.forEachChild(node, visit2);
|
|
192282
|
+
};
|
|
192283
|
+
visit2(sf);
|
|
192284
|
+
return called;
|
|
192285
|
+
}
|
|
192204
192286
|
function extractDependencies(code2, ctx) {
|
|
192287
|
+
const called = collectCalledIdentifiers(code2);
|
|
192205
192288
|
const deps = [];
|
|
192206
192289
|
for (const signal of ctx.signals) {
|
|
192207
|
-
|
|
192208
|
-
if (pattern.test(code2)) {
|
|
192290
|
+
if (called.has(signal.getter)) {
|
|
192209
192291
|
deps.push(signal.getter);
|
|
192210
192292
|
}
|
|
192211
192293
|
}
|
|
192212
192294
|
for (const memo of ctx.memos) {
|
|
192213
|
-
|
|
192214
|
-
if (pattern.test(code2)) {
|
|
192295
|
+
if (called.has(memo.name)) {
|
|
192215
192296
|
deps.push(memo.name);
|
|
192216
192297
|
}
|
|
192217
192298
|
}
|
|
@@ -192294,16 +192375,16 @@ function isResolvableComponentSource(source) {
|
|
|
192294
192375
|
function collectJsxComponentTags(sourceFile) {
|
|
192295
192376
|
const tags = new Set;
|
|
192296
192377
|
function visit2(node) {
|
|
192297
|
-
if (
|
|
192378
|
+
if (import_typescript9.default.isJsxOpeningElement(node) || import_typescript9.default.isJsxSelfClosingElement(node)) {
|
|
192298
192379
|
const tagName = node.tagName;
|
|
192299
|
-
if (
|
|
192380
|
+
if (import_typescript9.default.isIdentifier(tagName)) {
|
|
192300
192381
|
const first = tagName.text.charAt(0);
|
|
192301
192382
|
if (first >= "A" && first <= "Z") {
|
|
192302
192383
|
tags.add(tagName.text);
|
|
192303
192384
|
}
|
|
192304
192385
|
}
|
|
192305
192386
|
}
|
|
192306
|
-
|
|
192387
|
+
import_typescript9.default.forEachChild(node, visit2);
|
|
192307
192388
|
}
|
|
192308
192389
|
visit2(sourceFile);
|
|
192309
192390
|
return tags;
|
|
@@ -192382,18 +192463,18 @@ function fileHasUseClientDirective(filePath) {
|
|
|
192382
192463
|
} catch {
|
|
192383
192464
|
return true;
|
|
192384
192465
|
}
|
|
192385
|
-
const sf =
|
|
192466
|
+
const sf = import_typescript9.default.createSourceFile(filePath, content, import_typescript9.default.ScriptTarget.Latest, false, import_typescript9.default.ScriptKind.TSX);
|
|
192386
192467
|
let found = false;
|
|
192387
192468
|
function visit2(node) {
|
|
192388
192469
|
if (found)
|
|
192389
192470
|
return;
|
|
192390
|
-
if (
|
|
192471
|
+
if (import_typescript9.default.isExpressionStatement(node) && import_typescript9.default.isStringLiteral(node.expression)) {
|
|
192391
192472
|
if (node.expression.text === "use client") {
|
|
192392
192473
|
found = true;
|
|
192393
192474
|
return;
|
|
192394
192475
|
}
|
|
192395
192476
|
}
|
|
192396
|
-
|
|
192477
|
+
import_typescript9.default.forEachChild(node, visit2);
|
|
192397
192478
|
}
|
|
192398
192479
|
visit2(sf);
|
|
192399
192480
|
return found;
|
|
@@ -192478,13 +192559,13 @@ var REACTIVE_PRIMITIVES = new Set([
|
|
|
192478
192559
|
"onCleanup"
|
|
192479
192560
|
]);
|
|
192480
192561
|
function prescanReactiveFactoriesInSource(source, filePath) {
|
|
192481
|
-
const sourceFile =
|
|
192562
|
+
const sourceFile = import_typescript9.default.createSourceFile(filePath + ".prescan", source, import_typescript9.default.ScriptTarget.Latest, true, import_typescript9.default.ScriptKind.TSX);
|
|
192482
192563
|
const factories = new Map;
|
|
192483
192564
|
const declined = new Map;
|
|
192484
192565
|
const reactiveShaped = new Set;
|
|
192485
192566
|
const cleanFactoryImports = new Set;
|
|
192486
192567
|
function visitTop(node) {
|
|
192487
|
-
if (
|
|
192568
|
+
if (import_typescript9.default.isFunctionDeclaration(node) && node.name && node.body) {
|
|
192488
192569
|
const det = detectReactiveFactory(node, sourceFile, filePath);
|
|
192489
192570
|
if (!det)
|
|
192490
192571
|
return;
|
|
@@ -192501,7 +192582,7 @@ function prescanReactiveFactoriesInSource(source, filePath) {
|
|
|
192501
192582
|
}
|
|
192502
192583
|
}
|
|
192503
192584
|
}
|
|
192504
|
-
|
|
192585
|
+
import_typescript9.default.forEachChild(sourceFile, visitTop);
|
|
192505
192586
|
const result = { factories, declined, reactiveShaped, cleanFactoryImports, sourceFile };
|
|
192506
192587
|
prescanImportedReactiveFactories(sourceFile, filePath, result);
|
|
192507
192588
|
return result;
|
|
@@ -192518,15 +192599,15 @@ function toComponentRelativeSpecifier(resolvedAbs, componentFilePath) {
|
|
|
192518
192599
|
function buildEntryImportIndex(sf, filePath) {
|
|
192519
192600
|
const index = new Map;
|
|
192520
192601
|
for (const stmt of sf.statements) {
|
|
192521
|
-
if (!
|
|
192602
|
+
if (!import_typescript9.default.isImportDeclaration(stmt))
|
|
192522
192603
|
continue;
|
|
192523
|
-
if (!
|
|
192604
|
+
if (!import_typescript9.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192524
192605
|
continue;
|
|
192525
192606
|
const src = stmt.moduleSpecifier.text;
|
|
192526
192607
|
const targetKey = src.startsWith("./") || src.startsWith("../") ? resolveRelativeImportToFile(src, filePath) ?? "unresolved:" + src : src;
|
|
192527
192608
|
const wholeTypeOnly = stmt.importClause?.isTypeOnly === true;
|
|
192528
192609
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
192529
|
-
if (namedBindings &&
|
|
192610
|
+
if (namedBindings && import_typescript9.default.isNamedImports(namedBindings)) {
|
|
192530
192611
|
for (const el of namedBindings.elements) {
|
|
192531
192612
|
index.set(el.name.text, {
|
|
192532
192613
|
targetKey,
|
|
@@ -192541,31 +192622,31 @@ function buildEntryImportIndex(sf, filePath) {
|
|
|
192541
192622
|
function collectEntryBindingNames(sf) {
|
|
192542
192623
|
const names = new Set;
|
|
192543
192624
|
function visit2(node) {
|
|
192544
|
-
if (
|
|
192625
|
+
if (import_typescript9.default.isImportDeclaration(node) && node.importClause) {
|
|
192545
192626
|
if (node.importClause.name)
|
|
192546
192627
|
names.add(node.importClause.name.text);
|
|
192547
192628
|
const namedBindings = node.importClause.namedBindings;
|
|
192548
|
-
if (namedBindings &&
|
|
192629
|
+
if (namedBindings && import_typescript9.default.isNamedImports(namedBindings)) {
|
|
192549
192630
|
for (const el of namedBindings.elements)
|
|
192550
192631
|
names.add(el.name.text);
|
|
192551
192632
|
}
|
|
192552
|
-
if (namedBindings &&
|
|
192633
|
+
if (namedBindings && import_typescript9.default.isNamespaceImport(namedBindings)) {
|
|
192553
192634
|
names.add(namedBindings.name.text);
|
|
192554
192635
|
}
|
|
192555
192636
|
}
|
|
192556
|
-
if (
|
|
192637
|
+
if (import_typescript9.default.isVariableDeclaration(node)) {
|
|
192557
192638
|
const out = [];
|
|
192558
192639
|
addBindingNames(node.name, out);
|
|
192559
192640
|
for (const n of out)
|
|
192560
192641
|
names.add(n);
|
|
192561
192642
|
}
|
|
192562
|
-
if ((
|
|
192643
|
+
if ((import_typescript9.default.isFunctionDeclaration(node) || import_typescript9.default.isClassDeclaration(node) || import_typescript9.default.isEnumDeclaration(node)) && node.name) {
|
|
192563
192644
|
names.add(node.name.text);
|
|
192564
192645
|
}
|
|
192565
|
-
if ((
|
|
192646
|
+
if ((import_typescript9.default.isTypeAliasDeclaration(node) || import_typescript9.default.isInterfaceDeclaration(node)) && node.name) {
|
|
192566
192647
|
names.add(node.name.text);
|
|
192567
192648
|
}
|
|
192568
|
-
if (
|
|
192649
|
+
if (import_typescript9.default.isFunctionLike(node)) {
|
|
192569
192650
|
for (const p of node.parameters) {
|
|
192570
192651
|
const out = [];
|
|
192571
192652
|
addBindingNames(p.name, out);
|
|
@@ -192573,7 +192654,7 @@ function collectEntryBindingNames(sf) {
|
|
|
192573
192654
|
names.add(n);
|
|
192574
192655
|
}
|
|
192575
192656
|
}
|
|
192576
|
-
|
|
192657
|
+
import_typescript9.default.forEachChild(node, visit2);
|
|
192577
192658
|
}
|
|
192578
192659
|
visit2(sf);
|
|
192579
192660
|
return names;
|
|
@@ -192582,19 +192663,19 @@ var MAX_REEXPORT_HOPS = 1;
|
|
|
192582
192663
|
function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
192583
192664
|
const candidateCallees = new Set;
|
|
192584
192665
|
function collectCandidates(node) {
|
|
192585
|
-
if (
|
|
192666
|
+
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
192667
|
candidateCallees.add(node.initializer.expression.text);
|
|
192587
192668
|
}
|
|
192588
|
-
|
|
192669
|
+
import_typescript9.default.forEachChild(node, collectCandidates);
|
|
192589
192670
|
}
|
|
192590
192671
|
collectCandidates(entrySourceFile);
|
|
192591
192672
|
if (candidateCallees.size === 0)
|
|
192592
192673
|
return;
|
|
192593
192674
|
const importsToCheck = [];
|
|
192594
192675
|
for (const stmt of entrySourceFile.statements) {
|
|
192595
|
-
if (!
|
|
192676
|
+
if (!import_typescript9.default.isImportDeclaration(stmt))
|
|
192596
192677
|
continue;
|
|
192597
|
-
if (!
|
|
192678
|
+
if (!import_typescript9.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192598
192679
|
continue;
|
|
192599
192680
|
const src = stmt.moduleSpecifier.text;
|
|
192600
192681
|
if (!src.startsWith("./") && !src.startsWith("../"))
|
|
@@ -192602,7 +192683,7 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192602
192683
|
if (stmt.importClause?.isTypeOnly)
|
|
192603
192684
|
continue;
|
|
192604
192685
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
192605
|
-
if (!namedBindings || !
|
|
192686
|
+
if (!namedBindings || !import_typescript9.default.isNamedImports(namedBindings))
|
|
192606
192687
|
continue;
|
|
192607
192688
|
const specs = [];
|
|
192608
192689
|
for (const el of namedBindings.elements) {
|
|
@@ -192640,14 +192721,14 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192640
192721
|
helperCache.set(abs, "clean");
|
|
192641
192722
|
return "clean";
|
|
192642
192723
|
}
|
|
192643
|
-
const sf =
|
|
192724
|
+
const sf = import_typescript9.default.createSourceFile(abs + ".prescan", content, import_typescript9.default.ScriptTarget.Latest, true, import_typescript9.default.ScriptKind.TSX);
|
|
192644
192725
|
const localFns = new Map;
|
|
192645
192726
|
const exportedFns = new Map;
|
|
192646
192727
|
for (const stmt of sf.statements) {
|
|
192647
|
-
if (
|
|
192728
|
+
if (import_typescript9.default.isFunctionDeclaration(stmt) && stmt.name && stmt.body) {
|
|
192648
192729
|
localFns.set(stmt.name.text, stmt);
|
|
192649
|
-
const hasExportModifier = stmt.modifiers?.some((m) => m.kind ===
|
|
192650
|
-
const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind ===
|
|
192730
|
+
const hasExportModifier = stmt.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.ExportKeyword) ?? false;
|
|
192731
|
+
const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind === import_typescript9.default.SyntaxKind.DefaultKeyword) ?? false;
|
|
192651
192732
|
if (hasExportModifier && !hasDefaultModifier) {
|
|
192652
192733
|
exportedFns.set(stmt.name.text, stmt);
|
|
192653
192734
|
}
|
|
@@ -192656,10 +192737,10 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192656
192737
|
const reexports = new Map;
|
|
192657
192738
|
let hasStarReexport = false;
|
|
192658
192739
|
for (const stmt of sf.statements) {
|
|
192659
|
-
if (!
|
|
192740
|
+
if (!import_typescript9.default.isExportDeclaration(stmt) || stmt.isTypeOnly)
|
|
192660
192741
|
continue;
|
|
192661
192742
|
if (!stmt.moduleSpecifier) {
|
|
192662
|
-
if (stmt.exportClause &&
|
|
192743
|
+
if (stmt.exportClause && import_typescript9.default.isNamedExports(stmt.exportClause)) {
|
|
192663
192744
|
for (const el of stmt.exportClause.elements) {
|
|
192664
192745
|
if (el.isTypeOnly)
|
|
192665
192746
|
continue;
|
|
@@ -192670,9 +192751,9 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192670
192751
|
}
|
|
192671
192752
|
continue;
|
|
192672
192753
|
}
|
|
192673
|
-
if (!
|
|
192754
|
+
if (!import_typescript9.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192674
192755
|
continue;
|
|
192675
|
-
if (stmt.exportClause &&
|
|
192756
|
+
if (stmt.exportClause && import_typescript9.default.isNamedExports(stmt.exportClause)) {
|
|
192676
192757
|
for (const el of stmt.exportClause.elements) {
|
|
192677
192758
|
if (el.isTypeOnly)
|
|
192678
192759
|
continue;
|
|
@@ -192822,7 +192903,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
192822
192903
|
const importedTypes = new Map;
|
|
192823
192904
|
const imported = new Map;
|
|
192824
192905
|
for (const stmt of sf.statements) {
|
|
192825
|
-
if (
|
|
192906
|
+
if (import_typescript9.default.isVariableStatement(stmt)) {
|
|
192826
192907
|
const out = [];
|
|
192827
192908
|
for (const decl of stmt.declarationList.declarations) {
|
|
192828
192909
|
addBindingNames(decl.name, out);
|
|
@@ -192831,16 +192912,16 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
192831
192912
|
local.add(n);
|
|
192832
192913
|
continue;
|
|
192833
192914
|
}
|
|
192834
|
-
if ((
|
|
192915
|
+
if ((import_typescript9.default.isFunctionDeclaration(stmt) || import_typescript9.default.isClassDeclaration(stmt) || import_typescript9.default.isEnumDeclaration(stmt)) && stmt.name) {
|
|
192835
192916
|
local.add(stmt.name.text);
|
|
192836
192917
|
continue;
|
|
192837
192918
|
}
|
|
192838
|
-
if ((
|
|
192919
|
+
if ((import_typescript9.default.isTypeAliasDeclaration(stmt) || import_typescript9.default.isInterfaceDeclaration(stmt)) && stmt.name) {
|
|
192839
192920
|
localTypes.add(stmt.name.text);
|
|
192840
192921
|
continue;
|
|
192841
192922
|
}
|
|
192842
|
-
if (
|
|
192843
|
-
if (!
|
|
192923
|
+
if (import_typescript9.default.isImportDeclaration(stmt)) {
|
|
192924
|
+
if (!import_typescript9.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192844
192925
|
continue;
|
|
192845
192926
|
const src = stmt.moduleSpecifier.text;
|
|
192846
192927
|
if (src === "@barefootjs/client" || src === "@barefootjs/client/runtime")
|
|
@@ -192849,7 +192930,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
192849
192930
|
if (stmt.importClause?.name)
|
|
192850
192931
|
(wholeTypeOnly ? localTypes : local).add(stmt.importClause.name.text);
|
|
192851
192932
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
192852
|
-
if (namedBindings &&
|
|
192933
|
+
if (namedBindings && import_typescript9.default.isNamedImports(namedBindings)) {
|
|
192853
192934
|
for (const el of namedBindings.elements) {
|
|
192854
192935
|
const entry = { source: src, exportedName: (el.propertyName ?? el.name).text };
|
|
192855
192936
|
if (wholeTypeOnly || el.isTypeOnly)
|
|
@@ -192858,7 +192939,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
192858
192939
|
imported.set(el.name.text, entry);
|
|
192859
192940
|
}
|
|
192860
192941
|
}
|
|
192861
|
-
if (namedBindings &&
|
|
192942
|
+
if (namedBindings && import_typescript9.default.isNamespaceImport(namedBindings)) {
|
|
192862
192943
|
(wholeTypeOnly ? localTypes : local).add(namedBindings.name.text);
|
|
192863
192944
|
}
|
|
192864
192945
|
}
|
|
@@ -192925,11 +193006,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
192925
193006
|
function checkForReactive(n) {
|
|
192926
193007
|
if (hasReactiveCall)
|
|
192927
193008
|
return;
|
|
192928
|
-
if (
|
|
193009
|
+
if (import_typescript9.default.isCallExpression(n) && import_typescript9.default.isIdentifier(n.expression) && REACTIVE_PRIMITIVES.has(n.expression.text)) {
|
|
192929
193010
|
hasReactiveCall = true;
|
|
192930
193011
|
return;
|
|
192931
193012
|
}
|
|
192932
|
-
|
|
193013
|
+
import_typescript9.default.forEachChild(n, checkForReactive);
|
|
192933
193014
|
}
|
|
192934
193015
|
checkForReactive(node.body);
|
|
192935
193016
|
if (!hasReactiveCall)
|
|
@@ -192937,29 +193018,29 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
192937
193018
|
const loc = getSourceLocation(node, sourceFile, filePath);
|
|
192938
193019
|
let totalReturnCount = 0;
|
|
192939
193020
|
function countReturns(n) {
|
|
192940
|
-
if (
|
|
193021
|
+
if (import_typescript9.default.isFunctionLike(n))
|
|
192941
193022
|
return;
|
|
192942
|
-
if (
|
|
193023
|
+
if (import_typescript9.default.isReturnStatement(n)) {
|
|
192943
193024
|
totalReturnCount++;
|
|
192944
193025
|
return;
|
|
192945
193026
|
}
|
|
192946
|
-
|
|
193027
|
+
import_typescript9.default.forEachChild(n, countReturns);
|
|
192947
193028
|
}
|
|
192948
|
-
|
|
193029
|
+
import_typescript9.default.forEachChild(node.body, countReturns);
|
|
192949
193030
|
let returnExpr = null;
|
|
192950
193031
|
let returnCount = 0;
|
|
192951
193032
|
for (const stmt of node.body.statements) {
|
|
192952
|
-
if (!
|
|
193033
|
+
if (!import_typescript9.default.isReturnStatement(stmt))
|
|
192953
193034
|
continue;
|
|
192954
193035
|
returnCount++;
|
|
192955
193036
|
if (!stmt.expression)
|
|
192956
193037
|
return { kind: "reactive-shaped" };
|
|
192957
193038
|
let expr = stmt.expression;
|
|
192958
|
-
while (
|
|
193039
|
+
while (import_typescript9.default.isParenthesizedExpression(expr))
|
|
192959
193040
|
expr = expr.expression;
|
|
192960
|
-
if (
|
|
193041
|
+
if (import_typescript9.default.isAsExpression(expr))
|
|
192961
193042
|
expr = expr.expression;
|
|
192962
|
-
if (
|
|
193043
|
+
if (import_typescript9.default.isTypeAssertionExpression(expr))
|
|
192963
193044
|
expr = expr.expression;
|
|
192964
193045
|
returnExpr = expr;
|
|
192965
193046
|
}
|
|
@@ -192967,18 +193048,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
192967
193048
|
return { kind: "reactive-shaped" };
|
|
192968
193049
|
const returnTupleIdentifiers = [];
|
|
192969
193050
|
let returnKind;
|
|
192970
|
-
if (
|
|
193051
|
+
if (import_typescript9.default.isArrayLiteralExpression(returnExpr)) {
|
|
192971
193052
|
returnKind = "tuple";
|
|
192972
193053
|
for (const el of returnExpr.elements) {
|
|
192973
|
-
if (!
|
|
193054
|
+
if (!import_typescript9.default.isIdentifier(el))
|
|
192974
193055
|
return { kind: "reactive-shaped" };
|
|
192975
193056
|
returnTupleIdentifiers.push(el.text);
|
|
192976
193057
|
}
|
|
192977
193058
|
if (returnTupleIdentifiers.length === 0)
|
|
192978
193059
|
return { kind: "reactive-shaped" };
|
|
192979
|
-
} else if (
|
|
193060
|
+
} else if (import_typescript9.default.isObjectLiteralExpression(returnExpr)) {
|
|
192980
193061
|
returnKind = "object";
|
|
192981
|
-
const hasNonShorthand = returnExpr.properties.some((p) => !
|
|
193062
|
+
const hasNonShorthand = returnExpr.properties.some((p) => !import_typescript9.default.isShorthandPropertyAssignment(p));
|
|
192982
193063
|
if (hasNonShorthand) {
|
|
192983
193064
|
return {
|
|
192984
193065
|
kind: "declined",
|
|
@@ -192999,7 +193080,7 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
192999
193080
|
}
|
|
193000
193081
|
const params = [];
|
|
193001
193082
|
for (const p of node.parameters) {
|
|
193002
|
-
if (
|
|
193083
|
+
if (import_typescript9.default.isIdentifier(p.name)) {
|
|
193003
193084
|
params.push(p.name.text);
|
|
193004
193085
|
continue;
|
|
193005
193086
|
}
|
|
@@ -193007,11 +193088,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193007
193088
|
}
|
|
193008
193089
|
const localBindings = [];
|
|
193009
193090
|
for (const stmt of node.body.statements) {
|
|
193010
|
-
if (
|
|
193091
|
+
if (import_typescript9.default.isVariableStatement(stmt)) {
|
|
193011
193092
|
for (const decl of stmt.declarationList.declarations) {
|
|
193012
193093
|
addBindingNames(decl.name, localBindings);
|
|
193013
193094
|
}
|
|
193014
|
-
} else if (
|
|
193095
|
+
} else if (import_typescript9.default.isFunctionDeclaration(stmt) && stmt.name) {
|
|
193015
193096
|
localBindings.push(stmt.name.text);
|
|
193016
193097
|
}
|
|
193017
193098
|
}
|
|
@@ -193031,47 +193112,47 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193031
193112
|
if (!relevantNames.has(id.text))
|
|
193032
193113
|
return;
|
|
193033
193114
|
const p = id.parent;
|
|
193034
|
-
if (
|
|
193115
|
+
if (import_typescript9.default.isPropertyAccessExpression(p) && p.name === id)
|
|
193035
193116
|
return;
|
|
193036
|
-
if (
|
|
193117
|
+
if (import_typescript9.default.isPropertyAssignment(p) && p.name === id)
|
|
193037
193118
|
return;
|
|
193038
|
-
if (
|
|
193119
|
+
if (import_typescript9.default.isBindingElement(p) && p.propertyName === id)
|
|
193039
193120
|
return;
|
|
193040
|
-
if ((
|
|
193121
|
+
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
193122
|
return;
|
|
193042
|
-
if (
|
|
193123
|
+
if (import_typescript9.default.isJsxAttribute(p) && p.name === id)
|
|
193043
193124
|
return;
|
|
193044
|
-
if (
|
|
193125
|
+
if (import_typescript9.default.isLabeledStatement(p) && p.label === id || (import_typescript9.default.isBreakStatement(p) || import_typescript9.default.isContinueStatement(p)) && p.label === id)
|
|
193045
193126
|
return;
|
|
193046
|
-
if ((
|
|
193127
|
+
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
193128
|
return;
|
|
193048
|
-
if (
|
|
193129
|
+
if (import_typescript9.default.isShorthandPropertyAssignment(p) && p.name === id) {
|
|
193049
193130
|
push(id, "shorthand");
|
|
193050
193131
|
return;
|
|
193051
193132
|
}
|
|
193052
|
-
if (
|
|
193133
|
+
if (import_typescript9.default.isBindingElement(p) && p.name === id && !p.propertyName && import_typescript9.default.isObjectBindingPattern(p.parent)) {
|
|
193053
193134
|
if (params.includes(id.text))
|
|
193054
193135
|
shadowedParam = id.text;
|
|
193055
193136
|
push(id, "shorthand");
|
|
193056
193137
|
return;
|
|
193057
193138
|
}
|
|
193058
|
-
const isDecl = (
|
|
193139
|
+
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
193140
|
if (isDecl && params.includes(id.text))
|
|
193060
193141
|
shadowedParam = id.text;
|
|
193061
193142
|
push(id, "plain");
|
|
193062
193143
|
}
|
|
193063
193144
|
function visit2(n) {
|
|
193064
|
-
if (
|
|
193145
|
+
if (import_typescript9.default.isTypeNode(n) || import_typescript9.default.isTypeParameterDeclaration(n) || import_typescript9.default.isTypeAliasDeclaration(n) || import_typescript9.default.isInterfaceDeclaration(n))
|
|
193065
193146
|
return;
|
|
193066
|
-
if (
|
|
193147
|
+
if (import_typescript9.default.isIdentifier(n)) {
|
|
193067
193148
|
classify(n);
|
|
193068
193149
|
return;
|
|
193069
193150
|
}
|
|
193070
|
-
|
|
193151
|
+
import_typescript9.default.forEachChild(n, visit2);
|
|
193071
193152
|
}
|
|
193072
193153
|
visit2(root);
|
|
193073
193154
|
}
|
|
193074
|
-
const keptStatements = node.body.statements.filter((s) => !
|
|
193155
|
+
const keptStatements = node.body.statements.filter((s) => !import_typescript9.default.isReturnStatement(s));
|
|
193075
193156
|
const pieces = [];
|
|
193076
193157
|
let base = 0;
|
|
193077
193158
|
for (const stmt of keptStatements) {
|
|
@@ -193119,18 +193200,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193119
193200
|
};
|
|
193120
193201
|
}
|
|
193121
193202
|
function addBindingNames(name, out) {
|
|
193122
|
-
if (
|
|
193203
|
+
if (import_typescript9.default.isIdentifier(name)) {
|
|
193123
193204
|
out.push(name.text);
|
|
193124
193205
|
return;
|
|
193125
193206
|
}
|
|
193126
|
-
if (
|
|
193207
|
+
if (import_typescript9.default.isObjectBindingPattern(name)) {
|
|
193127
193208
|
for (const el of name.elements)
|
|
193128
193209
|
addBindingNames(el.name, out);
|
|
193129
193210
|
return;
|
|
193130
193211
|
}
|
|
193131
|
-
if (
|
|
193212
|
+
if (import_typescript9.default.isArrayBindingPattern(name)) {
|
|
193132
193213
|
for (const el of name.elements) {
|
|
193133
|
-
if (
|
|
193214
|
+
if (import_typescript9.default.isOmittedExpression(el))
|
|
193134
193215
|
continue;
|
|
193135
193216
|
addBindingNames(el.name, out);
|
|
193136
193217
|
}
|
|
@@ -193142,33 +193223,33 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193142
193223
|
let callSiteIndex = 0;
|
|
193143
193224
|
const inlinedFactories = new Set;
|
|
193144
193225
|
function visitStmt(node, inComponent) {
|
|
193145
|
-
if (
|
|
193226
|
+
if (import_typescript9.default.isVariableStatement(node) && inComponent) {
|
|
193146
193227
|
for (const decl of node.declarationList.declarations) {
|
|
193147
193228
|
maybeRewriteDecl(node, decl);
|
|
193148
193229
|
}
|
|
193149
193230
|
}
|
|
193150
|
-
|
|
193151
|
-
if (
|
|
193231
|
+
import_typescript9.default.forEachChild(node, (child) => {
|
|
193232
|
+
if (import_typescript9.default.isFunctionDeclaration(child) && child.name && factories.has(child.name.text))
|
|
193152
193233
|
return;
|
|
193153
193234
|
visitStmt(child, inComponent || isPascalCaseComponentFn(child));
|
|
193154
193235
|
});
|
|
193155
193236
|
}
|
|
193156
193237
|
function maybeRewriteDecl(stmt, decl) {
|
|
193157
|
-
if (!decl.initializer || !
|
|
193238
|
+
if (!decl.initializer || !import_typescript9.default.isCallExpression(decl.initializer))
|
|
193158
193239
|
return;
|
|
193159
|
-
if (!
|
|
193240
|
+
if (!import_typescript9.default.isIdentifier(decl.initializer.expression))
|
|
193160
193241
|
return;
|
|
193161
193242
|
const factoryName = decl.initializer.expression.text;
|
|
193162
193243
|
const factory = factories.get(factoryName);
|
|
193163
193244
|
if (!factory)
|
|
193164
193245
|
return;
|
|
193165
|
-
if (
|
|
193246
|
+
if (import_typescript9.default.isArrayBindingPattern(decl.name)) {
|
|
193166
193247
|
if (factory.returnKind !== "tuple")
|
|
193167
193248
|
return;
|
|
193168
193249
|
rewriteTupleDecl(stmt, decl.name, decl.initializer, factory);
|
|
193169
193250
|
return;
|
|
193170
193251
|
}
|
|
193171
|
-
if (
|
|
193252
|
+
if (import_typescript9.default.isObjectBindingPattern(decl.name)) {
|
|
193172
193253
|
if (factory.returnKind !== "object")
|
|
193173
193254
|
return;
|
|
193174
193255
|
rewriteObjectDecl(stmt, decl.name, decl.initializer, factory);
|
|
@@ -193181,7 +193262,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193181
193262
|
return;
|
|
193182
193263
|
const callerNames = [];
|
|
193183
193264
|
for (const el of elements) {
|
|
193184
|
-
if (
|
|
193265
|
+
if (import_typescript9.default.isOmittedExpression(el) || !import_typescript9.default.isIdentifier(el.name))
|
|
193185
193266
|
return;
|
|
193186
193267
|
callerNames.push(el.name.text);
|
|
193187
193268
|
}
|
|
@@ -193203,7 +193284,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193203
193284
|
return;
|
|
193204
193285
|
if (el.initializer)
|
|
193205
193286
|
return;
|
|
193206
|
-
if (!
|
|
193287
|
+
if (!import_typescript9.default.isIdentifier(el.name))
|
|
193207
193288
|
return;
|
|
193208
193289
|
if (!factory.returnTupleIdentifiers.includes(el.name.text))
|
|
193209
193290
|
return;
|
|
@@ -193312,21 +193393,21 @@ function factoryImportInsertionOffset(sf) {
|
|
|
193312
193393
|
let lastImportEnd = -1;
|
|
193313
193394
|
let directiveEnd = -1;
|
|
193314
193395
|
for (const stmt of sf.statements) {
|
|
193315
|
-
if (
|
|
193396
|
+
if (import_typescript9.default.isImportDeclaration(stmt)) {
|
|
193316
193397
|
lastImportEnd = stmt.getEnd();
|
|
193317
193398
|
continue;
|
|
193318
193399
|
}
|
|
193319
|
-
if (directiveEnd === -1 &&
|
|
193400
|
+
if (directiveEnd === -1 && import_typescript9.default.isExpressionStatement(stmt) && import_typescript9.default.isStringLiteral(stmt.expression) && stmt.expression.text === "use client") {
|
|
193320
193401
|
directiveEnd = stmt.getEnd();
|
|
193321
193402
|
}
|
|
193322
193403
|
}
|
|
193323
193404
|
return lastImportEnd >= 0 ? lastImportEnd : directiveEnd >= 0 ? directiveEnd : 0;
|
|
193324
193405
|
}
|
|
193325
193406
|
function isPascalCaseComponentFn(node) {
|
|
193326
|
-
if (
|
|
193407
|
+
if (import_typescript9.default.isFunctionDeclaration(node) && node.name) {
|
|
193327
193408
|
return /^[A-Z]/.test(node.name.text);
|
|
193328
193409
|
}
|
|
193329
|
-
if (
|
|
193410
|
+
if (import_typescript9.default.isVariableDeclaration(node) && import_typescript9.default.isIdentifier(node.name) && node.initializer && import_typescript9.default.isArrowFunction(node.initializer)) {
|
|
193330
193411
|
return /^[A-Z]/.test(node.name.text);
|
|
193331
193412
|
}
|
|
193332
193413
|
return false;
|
|
@@ -193355,20 +193436,20 @@ function declinedFactoryErrorCode(code2) {
|
|
|
193355
193436
|
function validateReactiveFactoryCalls(ctx) {
|
|
193356
193437
|
if (!ctx.componentNode)
|
|
193357
193438
|
return;
|
|
193358
|
-
const body =
|
|
193439
|
+
const body = import_typescript9.default.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : import_typescript9.default.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
|
|
193359
193440
|
if (!body)
|
|
193360
193441
|
return;
|
|
193361
193442
|
for (const stmt of body.statements) {
|
|
193362
|
-
if (!
|
|
193443
|
+
if (!import_typescript9.default.isVariableStatement(stmt))
|
|
193363
193444
|
continue;
|
|
193364
193445
|
for (const decl of stmt.declarationList.declarations) {
|
|
193365
|
-
if (!decl.initializer || !
|
|
193446
|
+
if (!decl.initializer || !import_typescript9.default.isCallExpression(decl.initializer))
|
|
193366
193447
|
continue;
|
|
193367
|
-
if (!
|
|
193448
|
+
if (!import_typescript9.default.isIdentifier(decl.initializer.expression))
|
|
193368
193449
|
continue;
|
|
193369
193450
|
const callee = decl.initializer.expression.text;
|
|
193370
193451
|
const loc = getSourceLocation(stmt, ctx.sourceFile, ctx.filePath);
|
|
193371
|
-
if (
|
|
193452
|
+
if (import_typescript9.default.isArrayBindingPattern(decl.name)) {
|
|
193372
193453
|
if (callee === "createSignal" || callee === "createMemo")
|
|
193373
193454
|
continue;
|
|
193374
193455
|
if (resolveEnvSignalKey(decl.initializer, ctx))
|
|
@@ -193395,7 +193476,7 @@ function validateReactiveFactoryCalls(ctx) {
|
|
|
193395
193476
|
}));
|
|
193396
193477
|
continue;
|
|
193397
193478
|
}
|
|
193398
|
-
if (
|
|
193479
|
+
if (import_typescript9.default.isObjectBindingPattern(decl.name)) {
|
|
193399
193480
|
validateObjectFactoryDestructure(ctx, decl.name, callee, loc);
|
|
193400
193481
|
}
|
|
193401
193482
|
}
|
|
@@ -193411,7 +193492,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
193411
193492
|
}));
|
|
193412
193493
|
return;
|
|
193413
193494
|
}
|
|
193414
|
-
const hasUnsupportedElement = pattern.elements.some((el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !
|
|
193495
|
+
const hasUnsupportedElement = pattern.elements.some((el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !import_typescript9.default.isIdentifier(el.name));
|
|
193415
193496
|
if (hasUnsupportedElement) {
|
|
193416
193497
|
ctx.errors.push(createError(ErrorCodes.REACTIVE_FACTORY_RENAME_UNSUPPORTED, loc, {
|
|
193417
193498
|
severity: "error",
|
|
@@ -193419,7 +193500,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
193419
193500
|
}));
|
|
193420
193501
|
return;
|
|
193421
193502
|
}
|
|
193422
|
-
const unknown = pattern.elements.map((el) =>
|
|
193503
|
+
const unknown = pattern.elements.map((el) => import_typescript9.default.isIdentifier(el.name) ? el.name.text : "").filter((name) => name && !factory.returnTupleIdentifiers.includes(name));
|
|
193423
193504
|
if (unknown.length > 0) {
|
|
193424
193505
|
const label = unknown.length === 1 ? "property" : "properties";
|
|
193425
193506
|
ctx.errors.push(createError(ErrorCodes.UNRECOGNIZED_REACTIVE_FACTORY, loc, {
|
|
@@ -193463,7 +193544,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
193463
193544
|
}
|
|
193464
193545
|
|
|
193465
193546
|
// ../jsx/src/jsx-to-ir.ts
|
|
193466
|
-
var
|
|
193547
|
+
var import_typescript12 = __toESM(require_typescript(), 1);
|
|
193467
193548
|
|
|
193468
193549
|
// ../jsx/src/types.ts
|
|
193469
193550
|
var SCOPE_FORBIDDEN = {
|
|
@@ -193577,7 +193658,7 @@ function isClientBuiltinName(name) {
|
|
|
193577
193658
|
}
|
|
193578
193659
|
|
|
193579
193660
|
// ../jsx/src/reactivity-checker.ts
|
|
193580
|
-
var
|
|
193661
|
+
var import_typescript10 = __toESM(require_typescript(), 1);
|
|
193581
193662
|
var REACTIVE_BRAND = "__reactive";
|
|
193582
193663
|
function queryType(checker, node) {
|
|
193583
193664
|
incrementCounter("typeCheckerQueries");
|
|
@@ -193595,7 +193676,7 @@ function safeGetText(node) {
|
|
|
193595
193676
|
}
|
|
193596
193677
|
}
|
|
193597
193678
|
function analyze(node, checker) {
|
|
193598
|
-
if (
|
|
193679
|
+
if (import_typescript10.default.isPropertyAccessExpression(node)) {
|
|
193599
193680
|
try {
|
|
193600
193681
|
const type2 = queryType(checker, node);
|
|
193601
193682
|
if (isReactiveType(type2)) {
|
|
@@ -193619,7 +193700,7 @@ function analyze(node, checker) {
|
|
|
193619
193700
|
}
|
|
193620
193701
|
return NOT_REACTIVE;
|
|
193621
193702
|
}
|
|
193622
|
-
if (
|
|
193703
|
+
if (import_typescript10.default.isIdentifier(node)) {
|
|
193623
193704
|
try {
|
|
193624
193705
|
const type2 = queryType(checker, node);
|
|
193625
193706
|
if (isReactiveType(type2)) {
|
|
@@ -193631,7 +193712,7 @@ function analyze(node, checker) {
|
|
|
193631
193712
|
} catch {}
|
|
193632
193713
|
return NOT_REACTIVE;
|
|
193633
193714
|
}
|
|
193634
|
-
if (
|
|
193715
|
+
if (import_typescript10.default.isCallExpression(node)) {
|
|
193635
193716
|
try {
|
|
193636
193717
|
const calleeType = queryType(checker, node.expression);
|
|
193637
193718
|
if (isReactiveType(calleeType)) {
|
|
@@ -193644,7 +193725,7 @@ function analyze(node, checker) {
|
|
|
193644
193725
|
}
|
|
193645
193726
|
let foundChild;
|
|
193646
193727
|
let foundChildText = "";
|
|
193647
|
-
|
|
193728
|
+
import_typescript10.default.forEachChild(node, (child) => {
|
|
193648
193729
|
if (foundChild?.isReactive)
|
|
193649
193730
|
return;
|
|
193650
193731
|
const result = analyze(child, checker);
|
|
@@ -193673,7 +193754,7 @@ function containsReactiveExpression(node, checker) {
|
|
|
193673
193754
|
}
|
|
193674
193755
|
|
|
193675
193756
|
// ../jsx/src/free-refs.ts
|
|
193676
|
-
var
|
|
193757
|
+
var import_typescript11 = __toESM(require_typescript(), 1);
|
|
193677
193758
|
var _bindingMapCache = new WeakMap;
|
|
193678
193759
|
function buildBindingMap(env) {
|
|
193679
193760
|
const cached = _bindingMapCache.get(env);
|
|
@@ -193741,20 +193822,20 @@ function defaultBindingScope(kind) {
|
|
|
193741
193822
|
function collectIdentifiers2(node) {
|
|
193742
193823
|
const out = [];
|
|
193743
193824
|
const visit2 = (n, parent) => {
|
|
193744
|
-
if (
|
|
193745
|
-
if (parent &&
|
|
193825
|
+
if (import_typescript11.default.isIdentifier(n)) {
|
|
193826
|
+
if (parent && import_typescript11.default.isPropertyAccessExpression(parent) && parent.name === n)
|
|
193746
193827
|
return;
|
|
193747
|
-
if (parent &&
|
|
193828
|
+
if (parent && import_typescript11.default.isPropertyAssignment(parent) && parent.name === n)
|
|
193748
193829
|
return;
|
|
193749
|
-
if (parent && (
|
|
193830
|
+
if (parent && (import_typescript11.default.isJsxOpeningElement(parent) || import_typescript11.default.isJsxClosingElement(parent) || import_typescript11.default.isJsxSelfClosingElement(parent)) && parent.tagName === n) {
|
|
193750
193831
|
return;
|
|
193751
193832
|
}
|
|
193752
|
-
if (parent &&
|
|
193833
|
+
if (parent && import_typescript11.default.isJsxAttribute(parent) && parent.name === n)
|
|
193753
193834
|
return;
|
|
193754
193835
|
out.push(n);
|
|
193755
193836
|
return;
|
|
193756
193837
|
}
|
|
193757
|
-
|
|
193838
|
+
import_typescript11.default.forEachChild(n, (child) => visit2(child, n));
|
|
193758
193839
|
};
|
|
193759
193840
|
visit2(node);
|
|
193760
193841
|
return out;
|
|
@@ -193763,7 +193844,7 @@ function collectReactiveBrandRefs(node, checker) {
|
|
|
193763
193844
|
const out = [];
|
|
193764
193845
|
const seen = new Set;
|
|
193765
193846
|
const visit2 = (n) => {
|
|
193766
|
-
if (
|
|
193847
|
+
if (import_typescript11.default.isPropertyAccessExpression(n)) {
|
|
193767
193848
|
try {
|
|
193768
193849
|
const type2 = checker.getTypeAtLocation(n);
|
|
193769
193850
|
if (isReactiveType(type2)) {
|
|
@@ -193781,7 +193862,7 @@ function collectReactiveBrandRefs(node, checker) {
|
|
|
193781
193862
|
incrementCounter("freeRefsTypeLookupFailures");
|
|
193782
193863
|
}
|
|
193783
193864
|
}
|
|
193784
|
-
|
|
193865
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
193785
193866
|
};
|
|
193786
193867
|
visit2(node);
|
|
193787
193868
|
return out;
|
|
@@ -193791,14 +193872,14 @@ function resolveConstantInitializerRefs(c, env, visited) {
|
|
|
193791
193872
|
return [];
|
|
193792
193873
|
if (c.containsArrow)
|
|
193793
193874
|
return [];
|
|
193794
|
-
const sf =
|
|
193875
|
+
const sf = import_typescript11.default.createSourceFile("__const_init.ts", `const __probe = (${c.value});`, import_typescript11.default.ScriptTarget.Latest, true);
|
|
193795
193876
|
const stmt = sf.statements[0];
|
|
193796
|
-
if (!stmt || !
|
|
193877
|
+
if (!stmt || !import_typescript11.default.isVariableStatement(stmt))
|
|
193797
193878
|
return [];
|
|
193798
193879
|
const decl = stmt.declarationList.declarations[0];
|
|
193799
193880
|
if (!decl || !decl.initializer)
|
|
193800
193881
|
return [];
|
|
193801
|
-
const expr =
|
|
193882
|
+
const expr = import_typescript11.default.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
193802
193883
|
return resolveFreeRefsInternal(expr, env, visited);
|
|
193803
193884
|
}
|
|
193804
193885
|
function resolveFreeRefsInternal(node, env, visited) {
|
|
@@ -193810,7 +193891,7 @@ function resolveFreeRefsInternal(node, env, visited) {
|
|
|
193810
193891
|
const name = ident.text;
|
|
193811
193892
|
if (env.propsObjectName === name) {
|
|
193812
193893
|
const parent = ident.parent;
|
|
193813
|
-
if (parent &&
|
|
193894
|
+
if (parent && import_typescript11.default.isPropertyAccessExpression(parent) && parent.expression === ident && parent.name.text === "children") {
|
|
193814
193895
|
continue;
|
|
193815
193896
|
}
|
|
193816
193897
|
}
|
|
@@ -194213,6 +194294,83 @@ var toLocaleDatePlugin = {
|
|
|
194213
194294
|
}
|
|
194214
194295
|
};
|
|
194215
194296
|
|
|
194297
|
+
// ../jsx/src/scope/binding-scope.ts
|
|
194298
|
+
class BindingScope {
|
|
194299
|
+
frames;
|
|
194300
|
+
static EMPTY = new BindingScope([]);
|
|
194301
|
+
constructor(frames) {
|
|
194302
|
+
this.frames = frames;
|
|
194303
|
+
}
|
|
194304
|
+
enterLoopRow(loop) {
|
|
194305
|
+
const bindings = new Map;
|
|
194306
|
+
if (loop.paramBindings && loop.paramBindings.length > 0) {
|
|
194307
|
+
for (const b of loop.paramBindings)
|
|
194308
|
+
bindings.set(b.name, { source: "destructure" });
|
|
194309
|
+
} else {
|
|
194310
|
+
bindings.set(loop.param, { source: "item" });
|
|
194311
|
+
}
|
|
194312
|
+
if (loop.index != null)
|
|
194313
|
+
bindings.set(loop.index, { source: "index" });
|
|
194314
|
+
for (const name of loop.preamble?.declaredNames ?? [])
|
|
194315
|
+
bindings.set(name, { source: "preamble" });
|
|
194316
|
+
const frame = { kind: "loop-row", bindings };
|
|
194317
|
+
return new BindingScope([frame, ...this.frames]);
|
|
194318
|
+
}
|
|
194319
|
+
enterCallback(params) {
|
|
194320
|
+
const bindings = new Map;
|
|
194321
|
+
for (const name of params)
|
|
194322
|
+
bindings.set(name, { source: "param" });
|
|
194323
|
+
const frame = { kind: "callback", bindings };
|
|
194324
|
+
return new BindingScope([frame, ...this.frames]);
|
|
194325
|
+
}
|
|
194326
|
+
isBound(name) {
|
|
194327
|
+
for (const frame of this.frames) {
|
|
194328
|
+
if (frame.bindings.has(name))
|
|
194329
|
+
return true;
|
|
194330
|
+
}
|
|
194331
|
+
return false;
|
|
194332
|
+
}
|
|
194333
|
+
lookup(name) {
|
|
194334
|
+
for (let depth = 0;depth < this.frames.length; depth++) {
|
|
194335
|
+
const frame = this.frames[depth];
|
|
194336
|
+
const binding = frame.bindings.get(name);
|
|
194337
|
+
if (binding)
|
|
194338
|
+
return { depth, frame, binding };
|
|
194339
|
+
}
|
|
194340
|
+
return null;
|
|
194341
|
+
}
|
|
194342
|
+
boundNames() {
|
|
194343
|
+
if (this.boundNamesCache)
|
|
194344
|
+
return this.boundNamesCache;
|
|
194345
|
+
const names = new Set;
|
|
194346
|
+
for (const frame of this.frames) {
|
|
194347
|
+
for (const name of frame.bindings.keys())
|
|
194348
|
+
names.add(name);
|
|
194349
|
+
}
|
|
194350
|
+
this.boundNamesCache = names;
|
|
194351
|
+
return names;
|
|
194352
|
+
}
|
|
194353
|
+
boundNamesCache;
|
|
194354
|
+
valueBoundNamesCache;
|
|
194355
|
+
valueBoundNames() {
|
|
194356
|
+
if (this.valueBoundNamesCache)
|
|
194357
|
+
return this.valueBoundNamesCache;
|
|
194358
|
+
const names = new Set;
|
|
194359
|
+
for (const frame of this.frames) {
|
|
194360
|
+
for (const [name, binding] of frame.bindings) {
|
|
194361
|
+
if (binding.source === "item" || binding.source === "index" || binding.source === "destructure") {
|
|
194362
|
+
names.add(name);
|
|
194363
|
+
}
|
|
194364
|
+
}
|
|
194365
|
+
}
|
|
194366
|
+
this.valueBoundNamesCache = names;
|
|
194367
|
+
return names;
|
|
194368
|
+
}
|
|
194369
|
+
asShadowPredicate() {
|
|
194370
|
+
return (name) => this.isBound(name);
|
|
194371
|
+
}
|
|
194372
|
+
}
|
|
194373
|
+
|
|
194216
194374
|
// ../jsx/src/jsx-to-ir.ts
|
|
194217
194375
|
var CLIENT_DIRECTIVE_INTERIOR_RE2 = /^\s*@client\s*$/;
|
|
194218
194376
|
var BLOCK_COMMENT_RE2 = /\/\*([\s\S]*?)\*\//g;
|
|
@@ -194238,13 +194396,13 @@ function exprCallsReactiveGetters(expr, ctx) {
|
|
|
194238
194396
|
function visit2(n) {
|
|
194239
194397
|
if (found)
|
|
194240
194398
|
return;
|
|
194241
|
-
if (
|
|
194399
|
+
if (import_typescript12.default.isCallExpression(n) && import_typescript12.default.isIdentifier(n.expression)) {
|
|
194242
194400
|
if (names.has(n.expression.text)) {
|
|
194243
194401
|
found = true;
|
|
194244
194402
|
return;
|
|
194245
194403
|
}
|
|
194246
194404
|
}
|
|
194247
|
-
|
|
194405
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
194248
194406
|
}
|
|
194249
194407
|
visit2(expr);
|
|
194250
194408
|
return found;
|
|
@@ -194271,11 +194429,11 @@ function exprReferencesModuleClientSignal(expr, ctx) {
|
|
|
194271
194429
|
function visit2(n) {
|
|
194272
194430
|
if (found)
|
|
194273
194431
|
return;
|
|
194274
|
-
if (
|
|
194432
|
+
if (import_typescript12.default.isCallExpression(n) && import_typescript12.default.isIdentifier(n.expression) && names.has(n.expression.text)) {
|
|
194275
194433
|
found = true;
|
|
194276
194434
|
return;
|
|
194277
194435
|
}
|
|
194278
|
-
|
|
194436
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
194279
194437
|
}
|
|
194280
194438
|
visit2(expr);
|
|
194281
194439
|
return found;
|
|
@@ -194285,11 +194443,11 @@ function exprHasFunctionCalls(expr) {
|
|
|
194285
194443
|
function visit2(n) {
|
|
194286
194444
|
if (found)
|
|
194287
194445
|
return;
|
|
194288
|
-
if (
|
|
194446
|
+
if (import_typescript12.default.isCallExpression(n)) {
|
|
194289
194447
|
found = true;
|
|
194290
194448
|
return;
|
|
194291
194449
|
}
|
|
194292
|
-
|
|
194450
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
194293
194451
|
}
|
|
194294
194452
|
visit2(expr);
|
|
194295
194453
|
return found;
|
|
@@ -194326,10 +194484,10 @@ function lowerDateCalls(text, expr, ctx) {
|
|
|
194326
194484
|
return text;
|
|
194327
194485
|
const candidates = [];
|
|
194328
194486
|
function visit2(n) {
|
|
194329
|
-
if (
|
|
194487
|
+
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
194488
|
candidates.push(n);
|
|
194331
194489
|
}
|
|
194332
|
-
|
|
194490
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
194333
194491
|
}
|
|
194334
194492
|
visit2(expr);
|
|
194335
194493
|
if (candidates.length === 0)
|
|
@@ -194354,10 +194512,10 @@ function lowerToLocaleDateCalls(text, expr, ctx) {
|
|
|
194354
194512
|
return text;
|
|
194355
194513
|
const candidates = [];
|
|
194356
194514
|
function visit2(n) {
|
|
194357
|
-
if (
|
|
194515
|
+
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
194516
|
candidates.push(n);
|
|
194359
194517
|
}
|
|
194360
|
-
|
|
194518
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
194361
194519
|
}
|
|
194362
194520
|
visit2(expr);
|
|
194363
194521
|
if (candidates.length === 0)
|
|
@@ -194393,14 +194551,16 @@ function rewriteBarePropRefs2(text, expr, ctx) {
|
|
|
194393
194551
|
let propNames = getDestructuredPropNames(ctx);
|
|
194394
194552
|
if (!propNames)
|
|
194395
194553
|
return dateLowered === text ? undefined : dateLowered;
|
|
194396
|
-
|
|
194397
|
-
|
|
194554
|
+
const shadowingNames = ctx.scope.boundNames();
|
|
194555
|
+
if (shadowingNames.size > 0) {
|
|
194556
|
+
const filtered = new Set([...propNames].filter((n) => !shadowingNames.has(n)));
|
|
194398
194557
|
if (filtered.size === 0)
|
|
194399
194558
|
return dateLowered === text ? undefined : dateLowered;
|
|
194400
194559
|
propNames = filtered;
|
|
194401
194560
|
}
|
|
194402
194561
|
const extraPropRefs = collectBranchLocalPropRefsViaSubstitution(expr, ctx);
|
|
194403
|
-
|
|
194562
|
+
const propAliases = getDestructuredPropAliases(ctx);
|
|
194563
|
+
return rewriteBarePropRefs(dateLowered, expr, propNames, extraPropRefs, propAliases ?? undefined);
|
|
194404
194564
|
}
|
|
194405
194565
|
function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
194406
194566
|
const propDepsMap = ctx._branchScopePropDeps;
|
|
@@ -194409,10 +194569,10 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
194409
194569
|
return;
|
|
194410
194570
|
let acc;
|
|
194411
194571
|
function visit2(n, parent) {
|
|
194412
|
-
if (
|
|
194413
|
-
const isObjectKey = parent &&
|
|
194414
|
-
const isShorthand = parent &&
|
|
194415
|
-
const isAccessName = parent &&
|
|
194572
|
+
if (import_typescript12.default.isIdentifier(n) && propDepsMap.has(n.text)) {
|
|
194573
|
+
const isObjectKey = parent && import_typescript12.default.isPropertyAssignment(parent) && parent.name === n;
|
|
194574
|
+
const isShorthand = parent && import_typescript12.default.isShorthandPropertyAssignment(parent) && parent.name === n;
|
|
194575
|
+
const isAccessName = parent && import_typescript12.default.isPropertyAccessExpression(parent) && parent.name === n;
|
|
194416
194576
|
if (!isObjectKey && !isShorthand && !isAccessName) {
|
|
194417
194577
|
const deps = propDepsMap.get(n.text);
|
|
194418
194578
|
if (deps && deps.size > 0) {
|
|
@@ -194423,7 +194583,7 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
194423
194583
|
}
|
|
194424
194584
|
}
|
|
194425
194585
|
}
|
|
194426
|
-
|
|
194586
|
+
import_typescript12.default.forEachChild(n, (child) => visit2(child, n));
|
|
194427
194587
|
}
|
|
194428
194588
|
visit2(node);
|
|
194429
194589
|
return acc;
|
|
@@ -194445,11 +194605,18 @@ function getDestructuredPropNames(ctx) {
|
|
|
194445
194605
|
shadowed.add(c.name);
|
|
194446
194606
|
}
|
|
194447
194607
|
}
|
|
194448
|
-
const
|
|
194608
|
+
const eligible = ctx.analyzer.propsParams.filter((p) => !shadowed.has(p.name));
|
|
194609
|
+
const names = eligible.map((p) => p.name);
|
|
194449
194610
|
ctx._destructuredPropNames = names.length > 0 ? new Set(names) : null;
|
|
194611
|
+
ctx._destructuredPropAliases = buildPropAliasMap(eligible) ?? null;
|
|
194450
194612
|
}
|
|
194451
194613
|
return ctx._destructuredPropNames ?? null;
|
|
194452
194614
|
}
|
|
194615
|
+
function getDestructuredPropAliases(ctx) {
|
|
194616
|
+
if (ctx._destructuredPropNames === undefined)
|
|
194617
|
+
getDestructuredPropNames(ctx);
|
|
194618
|
+
return ctx._destructuredPropAliases ?? null;
|
|
194619
|
+
}
|
|
194453
194620
|
function createTransformContext(analyzer) {
|
|
194454
194621
|
return {
|
|
194455
194622
|
analyzer,
|
|
@@ -194462,7 +194629,7 @@ function createTransformContext(analyzer) {
|
|
|
194462
194629
|
spreadIdCounter: 0,
|
|
194463
194630
|
isRoot: true,
|
|
194464
194631
|
insideComponentChildren: false,
|
|
194465
|
-
|
|
194632
|
+
scope: BindingScope.EMPTY,
|
|
194466
194633
|
loopDepth: 0,
|
|
194467
194634
|
patterns: {
|
|
194468
194635
|
signals: analyzer.signals.map((s) => ({
|
|
@@ -194492,21 +194659,21 @@ function createTransformContext(analyzer) {
|
|
|
194492
194659
|
function buildComponentNamespaces(ctx) {
|
|
194493
194660
|
const result = new Map;
|
|
194494
194661
|
for (const stmt of ctx.sourceFile.statements) {
|
|
194495
|
-
if (!
|
|
194662
|
+
if (!import_typescript12.default.isVariableStatement(stmt))
|
|
194496
194663
|
continue;
|
|
194497
194664
|
for (const decl of stmt.declarationList.declarations) {
|
|
194498
|
-
if (!decl.initializer || !
|
|
194665
|
+
if (!decl.initializer || !import_typescript12.default.isIdentifier(decl.name))
|
|
194499
194666
|
continue;
|
|
194500
194667
|
let init = decl.initializer;
|
|
194501
|
-
while (
|
|
194668
|
+
while (import_typescript12.default.isParenthesizedExpression(init))
|
|
194502
194669
|
init = init.expression;
|
|
194503
|
-
if (!
|
|
194670
|
+
if (!import_typescript12.default.isObjectLiteralExpression(init))
|
|
194504
194671
|
continue;
|
|
194505
194672
|
const members = new Map;
|
|
194506
194673
|
for (const prop of init.properties) {
|
|
194507
|
-
if (
|
|
194674
|
+
if (import_typescript12.default.isShorthandPropertyAssignment(prop)) {
|
|
194508
194675
|
members.set(prop.name.text, prop.name.text);
|
|
194509
|
-
} else if (
|
|
194676
|
+
} 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
194677
|
members.set(prop.name.text, prop.initializer.text);
|
|
194511
194678
|
}
|
|
194512
194679
|
}
|
|
@@ -194518,11 +194685,11 @@ function buildComponentNamespaces(ctx) {
|
|
|
194518
194685
|
return result;
|
|
194519
194686
|
}
|
|
194520
194687
|
function resolveMemberExpressionTag(tagNode, ctx) {
|
|
194521
|
-
if (!
|
|
194688
|
+
if (!import_typescript12.default.isPropertyAccessExpression(tagNode))
|
|
194522
194689
|
return null;
|
|
194523
|
-
if (!
|
|
194690
|
+
if (!import_typescript12.default.isIdentifier(tagNode.expression))
|
|
194524
194691
|
return null;
|
|
194525
|
-
if (!
|
|
194692
|
+
if (!import_typescript12.default.isIdentifier(tagNode.name))
|
|
194526
194693
|
return null;
|
|
194527
194694
|
if (!ctx._componentNamespaces) {
|
|
194528
194695
|
ctx._componentNamespaces = buildComponentNamespaces(ctx);
|
|
@@ -194539,7 +194706,8 @@ function generateSpreadSlotId(ctx) {
|
|
|
194539
194706
|
return `Spread_${ctx.spreadIdCounter++}`;
|
|
194540
194707
|
}
|
|
194541
194708
|
function makeBindingEnv(ctx) {
|
|
194542
|
-
const
|
|
194709
|
+
const boundNames = ctx.scope.valueBoundNames();
|
|
194710
|
+
const loopKey = boundNames.size === 0 ? "" : Array.from(boundNames).sort().join("\x00");
|
|
194543
194711
|
if (ctx._bindingEnv && ctx._bindingEnvLoopKey === loopKey) {
|
|
194544
194712
|
return ctx._bindingEnv;
|
|
194545
194713
|
}
|
|
@@ -194554,7 +194722,7 @@ function makeBindingEnv(ctx) {
|
|
|
194554
194722
|
localFunctions: a.localFunctions,
|
|
194555
194723
|
imports: a.imports,
|
|
194556
194724
|
ambientGlobals: a.ambientGlobals,
|
|
194557
|
-
loopParams:
|
|
194725
|
+
loopParams: boundNames,
|
|
194558
194726
|
checker: a.checker
|
|
194559
194727
|
};
|
|
194560
194728
|
ctx._bindingEnv = env;
|
|
@@ -194678,7 +194846,7 @@ function buildIRRoot(analyzer) {
|
|
|
194678
194846
|
return null;
|
|
194679
194847
|
const ctx = createTransformContext(analyzer);
|
|
194680
194848
|
const jsxReturn = analyzer.jsxReturn;
|
|
194681
|
-
if (
|
|
194849
|
+
if (import_typescript12.default.isJsxElement(jsxReturn) || import_typescript12.default.isJsxSelfClosingElement(jsxReturn) || import_typescript12.default.isJsxFragment(jsxReturn)) {
|
|
194682
194850
|
const ir2 = transformNode(jsxReturn, ctx);
|
|
194683
194851
|
if (ir2 && needsScopeWrapper(ir2)) {
|
|
194684
194852
|
return wrapInScopeElement(ir2);
|
|
@@ -194734,22 +194902,22 @@ function wrapInScopeElement(node) {
|
|
|
194734
194902
|
};
|
|
194735
194903
|
}
|
|
194736
194904
|
function transformNode(node, ctx) {
|
|
194737
|
-
if (
|
|
194905
|
+
if (import_typescript12.default.isJsxElement(node)) {
|
|
194738
194906
|
return transformJsxElement(node, ctx);
|
|
194739
194907
|
}
|
|
194740
|
-
if (
|
|
194908
|
+
if (import_typescript12.default.isJsxSelfClosingElement(node)) {
|
|
194741
194909
|
return transformSelfClosingElement(node, ctx);
|
|
194742
194910
|
}
|
|
194743
|
-
if (
|
|
194911
|
+
if (import_typescript12.default.isJsxFragment(node)) {
|
|
194744
194912
|
return transformFragment(node, ctx);
|
|
194745
194913
|
}
|
|
194746
|
-
if (
|
|
194914
|
+
if (import_typescript12.default.isJsxText(node)) {
|
|
194747
194915
|
return transformText(node, ctx);
|
|
194748
194916
|
}
|
|
194749
|
-
if (
|
|
194917
|
+
if (import_typescript12.default.isJsxExpression(node)) {
|
|
194750
194918
|
return transformExpression(node, ctx);
|
|
194751
194919
|
}
|
|
194752
|
-
if (
|
|
194920
|
+
if (import_typescript12.default.isConditionalExpression(node)) {
|
|
194753
194921
|
return transformConditional(node, ctx);
|
|
194754
194922
|
}
|
|
194755
194923
|
return null;
|
|
@@ -194850,17 +195018,23 @@ function lowerFormControlValueSsr(tagName, attrs, children) {
|
|
|
194850
195018
|
});
|
|
194851
195019
|
return;
|
|
194852
195020
|
}
|
|
194853
|
-
const
|
|
195021
|
+
const selectedForLiteral = (optValue) => AttrValueOf.expression(`(${expr}) === ${JSON.stringify(optValue)}`, templateExpr !== undefined ? { templateExpr: `(${templateExpr}) === ${JSON.stringify(optValue)}` } : undefined);
|
|
195022
|
+
const selectedForExpr = (optExpr, optTemplateExpr) => AttrValueOf.expression(`(${expr}) === (${optExpr})`, templateExpr !== undefined || optTemplateExpr !== undefined ? { templateExpr: `(${templateExpr ?? expr}) === (${optTemplateExpr ?? optExpr})` } : undefined);
|
|
194854
195023
|
const distribute = (nodes) => {
|
|
194855
195024
|
for (const n of nodes) {
|
|
194856
195025
|
if (n.type === "element" && n.tag === "option") {
|
|
194857
195026
|
if (n.attrs.some((a) => a.name === "selected"))
|
|
194858
195027
|
continue;
|
|
194859
195028
|
const optValue = n.attrs.find((a) => a.name === "value");
|
|
194860
|
-
if (!optValue
|
|
195029
|
+
if (!optValue)
|
|
194861
195030
|
continue;
|
|
194862
|
-
|
|
194863
|
-
|
|
195031
|
+
if (optValue.value.kind === "literal") {
|
|
195032
|
+
n.attrs.push({ name: "selected", value: selectedForLiteral(optValue.value.value), loc: n.loc });
|
|
195033
|
+
} else if (optValue.value.kind === "expression") {
|
|
195034
|
+
const selected = selectedForExpr(optValue.value.expr, optValue.value.templateExpr);
|
|
195035
|
+
n.attrs.push({ name: "selected", value: selected, loc: n.loc });
|
|
195036
|
+
}
|
|
195037
|
+
} else if (n.type === "fragment" || n.type === "loop" || n.type === "element" && n.tag === "optgroup") {
|
|
194864
195038
|
distribute(n.children);
|
|
194865
195039
|
}
|
|
194866
195040
|
}
|
|
@@ -195100,7 +195274,7 @@ function transformSelfClosingComponent(node, ctx, name) {
|
|
|
195100
195274
|
}
|
|
195101
195275
|
function isTransparentFragment(node, ctx) {
|
|
195102
195276
|
const children = node.children.filter((child2) => {
|
|
195103
|
-
if (
|
|
195277
|
+
if (import_typescript12.default.isJsxText(child2)) {
|
|
195104
195278
|
return child2.text.trim() !== "";
|
|
195105
195279
|
}
|
|
195106
195280
|
return true;
|
|
@@ -195108,7 +195282,7 @@ function isTransparentFragment(node, ctx) {
|
|
|
195108
195282
|
if (children.length !== 1)
|
|
195109
195283
|
return false;
|
|
195110
195284
|
const child = children[0];
|
|
195111
|
-
if (!
|
|
195285
|
+
if (!import_typescript12.default.isJsxExpression(child))
|
|
195112
195286
|
return false;
|
|
195113
195287
|
if (!child.expression)
|
|
195114
195288
|
return false;
|
|
@@ -195152,7 +195326,7 @@ function transformChildren(children, ctx) {
|
|
|
195152
195326
|
const result = [];
|
|
195153
195327
|
for (let i2 = 0;i2 < children.length; i2++) {
|
|
195154
195328
|
const child = children[i2];
|
|
195155
|
-
if (
|
|
195329
|
+
if (import_typescript12.default.isJsxExpression(child) && !child.expression) {
|
|
195156
195330
|
continue;
|
|
195157
195331
|
}
|
|
195158
195332
|
const transformed = transformNode(child, ctx);
|
|
@@ -195167,10 +195341,10 @@ function transformChildren(children, ctx) {
|
|
|
195167
195341
|
}
|
|
195168
195342
|
function isRenderNothingLiteral(expr, ctx) {
|
|
195169
195343
|
let e = expr;
|
|
195170
|
-
while (
|
|
195344
|
+
while (import_typescript12.default.isParenthesizedExpression(e) || import_typescript12.default.isAsExpression(e) || import_typescript12.default.isSatisfiesExpression(e) || import_typescript12.default.isNonNullExpression(e)) {
|
|
195171
195345
|
e = e.expression;
|
|
195172
195346
|
}
|
|
195173
|
-
return e.kind ===
|
|
195347
|
+
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
195348
|
}
|
|
195175
195349
|
function transformText(node, ctx) {
|
|
195176
195350
|
const text = node.text.replace(/\s+/g, " ");
|
|
@@ -195196,7 +195370,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
|
|
|
195196
195370
|
return null;
|
|
195197
195371
|
}
|
|
195198
195372
|
checkBareSignalOrMemoIdentifier(expr, ctx);
|
|
195199
|
-
if (
|
|
195373
|
+
if (import_typescript12.default.isIdentifier(expr)) {
|
|
195200
195374
|
const jsxNode = ctx.analyzer.jsxConstants.get(expr.text);
|
|
195201
195375
|
if (jsxNode) {
|
|
195202
195376
|
return transformNode(jsxNode, ctx);
|
|
@@ -195241,7 +195415,8 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
|
|
|
195241
195415
|
freeRefs
|
|
195242
195416
|
};
|
|
195243
195417
|
const reactive = isReactiveExpression(exprText, ctx, expr) || isReactiveOrigin(origin);
|
|
195244
|
-
const
|
|
195418
|
+
const scopeValueNames = ctx.scope.valueBoundNames();
|
|
195419
|
+
const refsLoopParam = scopeValueNames.size > 0 && Array.from(scopeValueNames).some((p) => new RegExp(`\\b${p}\\b`).test(exprText));
|
|
195245
195420
|
const callsReactive = exprCallsReactiveGetters(expr, ctx);
|
|
195246
195421
|
const hasCalls = exprHasFunctionCalls(expr);
|
|
195247
195422
|
const needsSlot = reactive || isClientOnly || refsLoopParam || callsReactive || hasCalls;
|
|
@@ -195474,38 +195649,38 @@ function transformLogicalAnd(node, ctx) {
|
|
|
195474
195649
|
};
|
|
195475
195650
|
}
|
|
195476
195651
|
function containsJsxInExpression(node) {
|
|
195477
|
-
if (
|
|
195652
|
+
if (import_typescript12.default.isJsxElement(node) || import_typescript12.default.isJsxSelfClosingElement(node) || import_typescript12.default.isJsxFragment(node)) {
|
|
195478
195653
|
return true;
|
|
195479
195654
|
}
|
|
195480
|
-
return
|
|
195655
|
+
return import_typescript12.default.forEachChild(node, containsJsxInExpression) ?? false;
|
|
195481
195656
|
}
|
|
195482
195657
|
function callsJsxHelper(node, ctx) {
|
|
195483
195658
|
let found = false;
|
|
195484
195659
|
const visit2 = (n) => {
|
|
195485
195660
|
if (found)
|
|
195486
195661
|
return;
|
|
195487
|
-
if (
|
|
195662
|
+
if (import_typescript12.default.isCallExpression(n) && import_typescript12.default.isIdentifier(n.expression)) {
|
|
195488
195663
|
const name = n.expression.text;
|
|
195489
195664
|
if (ctx.analyzer.jsxFunctions.has(name) || ctx.analyzer.jsxMultiReturnFunctions.has(name)) {
|
|
195490
195665
|
found = true;
|
|
195491
195666
|
return;
|
|
195492
195667
|
}
|
|
195493
195668
|
}
|
|
195494
|
-
|
|
195669
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
195495
195670
|
};
|
|
195496
195671
|
visit2(node);
|
|
195497
195672
|
return found;
|
|
195498
195673
|
}
|
|
195499
195674
|
function containsAwaitExpression(node) {
|
|
195500
|
-
if (
|
|
195675
|
+
if (import_typescript12.default.isAwaitExpression(node))
|
|
195501
195676
|
return true;
|
|
195502
|
-
if (
|
|
195677
|
+
if (import_typescript12.default.isFunctionDeclaration(node) || import_typescript12.default.isFunctionExpression(node) || import_typescript12.default.isArrowFunction(node))
|
|
195503
195678
|
return false;
|
|
195504
|
-
return
|
|
195679
|
+
return import_typescript12.default.forEachChild(node, containsAwaitExpression) ?? false;
|
|
195505
195680
|
}
|
|
195506
195681
|
function transformNullishCoalescing(node, ctx) {
|
|
195507
195682
|
const leftText = ctx.getJS(node.left);
|
|
195508
|
-
const isNullish = node.operatorToken.kind ===
|
|
195683
|
+
const isNullish = node.operatorToken.kind === import_typescript12.default.SyntaxKind.QuestionQuestionToken;
|
|
195509
195684
|
const condition = isNullish ? `${leftText} != null` : leftText;
|
|
195510
195685
|
const leftOrigin = {
|
|
195511
195686
|
phase: "tick",
|
|
@@ -195551,36 +195726,36 @@ function transformNullishCoalescing(node, ctx) {
|
|
|
195551
195726
|
}
|
|
195552
195727
|
function assertNever2(expr) {
|
|
195553
195728
|
const kind = expr?.kind;
|
|
195554
|
-
throw new Error(`transformJsxExpression: unhandled ts.SyntaxKind ${kind !== undefined ?
|
|
195729
|
+
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
195730
|
}
|
|
195556
195731
|
function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
195557
195732
|
const node = expr;
|
|
195558
195733
|
switch (node.kind) {
|
|
195559
|
-
case
|
|
195560
|
-
case
|
|
195561
|
-
case
|
|
195562
|
-
case
|
|
195563
|
-
case
|
|
195564
|
-
case
|
|
195734
|
+
case import_typescript12.default.SyntaxKind.ParenthesizedExpression:
|
|
195735
|
+
case import_typescript12.default.SyntaxKind.AsExpression:
|
|
195736
|
+
case import_typescript12.default.SyntaxKind.SatisfiesExpression:
|
|
195737
|
+
case import_typescript12.default.SyntaxKind.NonNullExpression:
|
|
195738
|
+
case import_typescript12.default.SyntaxKind.TypeAssertionExpression:
|
|
195739
|
+
case import_typescript12.default.SyntaxKind.PartiallyEmittedExpression:
|
|
195565
195740
|
return transformJsxExpression(node.expression, ctx, isClientOnly);
|
|
195566
|
-
case
|
|
195741
|
+
case import_typescript12.default.SyntaxKind.JsxElement:
|
|
195567
195742
|
return transformJsxElement(node, ctx);
|
|
195568
|
-
case
|
|
195743
|
+
case import_typescript12.default.SyntaxKind.JsxFragment:
|
|
195569
195744
|
return transformFragment(node, ctx);
|
|
195570
|
-
case
|
|
195745
|
+
case import_typescript12.default.SyntaxKind.JsxSelfClosingElement:
|
|
195571
195746
|
return transformSelfClosingElement(node, ctx);
|
|
195572
|
-
case
|
|
195747
|
+
case import_typescript12.default.SyntaxKind.ConditionalExpression:
|
|
195573
195748
|
return transformConditional(node, ctx);
|
|
195574
|
-
case
|
|
195575
|
-
if (node.operatorToken.kind ===
|
|
195749
|
+
case import_typescript12.default.SyntaxKind.BinaryExpression: {
|
|
195750
|
+
if (node.operatorToken.kind === import_typescript12.default.SyntaxKind.AmpersandAmpersandToken) {
|
|
195576
195751
|
return transformLogicalAnd(node, ctx);
|
|
195577
195752
|
}
|
|
195578
|
-
if ((node.operatorToken.kind ===
|
|
195753
|
+
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
195754
|
return transformNullishCoalescing(node, ctx);
|
|
195580
195755
|
}
|
|
195581
195756
|
return null;
|
|
195582
195757
|
}
|
|
195583
|
-
case
|
|
195758
|
+
case import_typescript12.default.SyntaxKind.CallExpression: {
|
|
195584
195759
|
const mapMethod = getMapLikeMethod(node);
|
|
195585
195760
|
if (mapMethod) {
|
|
195586
195761
|
const mapResult = transformMapCall(node, ctx, isClientOnly, mapMethod);
|
|
@@ -195588,7 +195763,7 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
195588
195763
|
return mapResult;
|
|
195589
195764
|
}
|
|
195590
195765
|
const callee = node.expression;
|
|
195591
|
-
if (
|
|
195766
|
+
if (import_typescript12.default.isIdentifier(callee)) {
|
|
195592
195767
|
const jsxFunc = ctx.analyzer.jsxFunctions.get(callee.text);
|
|
195593
195768
|
if (jsxFunc) {
|
|
195594
195769
|
return transformJsxFunctionCall(node, jsxFunc, ctx, isClientOnly);
|
|
@@ -195600,39 +195775,39 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
195600
195775
|
}
|
|
195601
195776
|
return null;
|
|
195602
195777
|
}
|
|
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
|
|
195778
|
+
case import_typescript12.default.SyntaxKind.Identifier:
|
|
195779
|
+
case import_typescript12.default.SyntaxKind.StringLiteral:
|
|
195780
|
+
case import_typescript12.default.SyntaxKind.NumericLiteral:
|
|
195781
|
+
case import_typescript12.default.SyntaxKind.BigIntLiteral:
|
|
195782
|
+
case import_typescript12.default.SyntaxKind.RegularExpressionLiteral:
|
|
195783
|
+
case import_typescript12.default.SyntaxKind.NoSubstitutionTemplateLiteral:
|
|
195784
|
+
case import_typescript12.default.SyntaxKind.TemplateExpression:
|
|
195785
|
+
case import_typescript12.default.SyntaxKind.TaggedTemplateExpression:
|
|
195786
|
+
case import_typescript12.default.SyntaxKind.TrueKeyword:
|
|
195787
|
+
case import_typescript12.default.SyntaxKind.FalseKeyword:
|
|
195788
|
+
case import_typescript12.default.SyntaxKind.NullKeyword:
|
|
195789
|
+
case import_typescript12.default.SyntaxKind.ThisKeyword:
|
|
195790
|
+
case import_typescript12.default.SyntaxKind.SuperKeyword:
|
|
195791
|
+
case import_typescript12.default.SyntaxKind.ImportKeyword:
|
|
195792
|
+
case import_typescript12.default.SyntaxKind.PropertyAccessExpression:
|
|
195793
|
+
case import_typescript12.default.SyntaxKind.ElementAccessExpression:
|
|
195794
|
+
case import_typescript12.default.SyntaxKind.PrefixUnaryExpression:
|
|
195795
|
+
case import_typescript12.default.SyntaxKind.PostfixUnaryExpression:
|
|
195796
|
+
case import_typescript12.default.SyntaxKind.TypeOfExpression:
|
|
195797
|
+
case import_typescript12.default.SyntaxKind.VoidExpression:
|
|
195798
|
+
case import_typescript12.default.SyntaxKind.DeleteExpression:
|
|
195799
|
+
case import_typescript12.default.SyntaxKind.NewExpression:
|
|
195800
|
+
case import_typescript12.default.SyntaxKind.ObjectLiteralExpression:
|
|
195801
|
+
case import_typescript12.default.SyntaxKind.ArrowFunction:
|
|
195802
|
+
case import_typescript12.default.SyntaxKind.FunctionExpression:
|
|
195803
|
+
case import_typescript12.default.SyntaxKind.ClassExpression:
|
|
195804
|
+
case import_typescript12.default.SyntaxKind.MetaProperty:
|
|
195805
|
+
case import_typescript12.default.SyntaxKind.ExpressionWithTypeArguments:
|
|
195806
|
+
case import_typescript12.default.SyntaxKind.CommaListExpression:
|
|
195807
|
+
case import_typescript12.default.SyntaxKind.SyntheticExpression:
|
|
195808
|
+
case import_typescript12.default.SyntaxKind.ArrayLiteralExpression:
|
|
195634
195809
|
return null;
|
|
195635
|
-
case
|
|
195810
|
+
case import_typescript12.default.SyntaxKind.AwaitExpression:
|
|
195636
195811
|
ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(node, ctx.sourceFile, ctx.filePath)));
|
|
195637
195812
|
return {
|
|
195638
195813
|
type: "expression",
|
|
@@ -195643,16 +195818,16 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
195643
195818
|
loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
|
|
195644
195819
|
origin: { phase: "tick", scope: "template", effect: "pure", freeRefs: [] }
|
|
195645
195820
|
};
|
|
195646
|
-
case
|
|
195821
|
+
case import_typescript12.default.SyntaxKind.YieldExpression:
|
|
195647
195822
|
return null;
|
|
195648
|
-
case
|
|
195649
|
-
case
|
|
195650
|
-
case
|
|
195651
|
-
case
|
|
195652
|
-
case
|
|
195653
|
-
case
|
|
195654
|
-
case
|
|
195655
|
-
case
|
|
195823
|
+
case import_typescript12.default.SyntaxKind.SpreadElement:
|
|
195824
|
+
case import_typescript12.default.SyntaxKind.OmittedExpression:
|
|
195825
|
+
case import_typescript12.default.SyntaxKind.JsxExpression:
|
|
195826
|
+
case import_typescript12.default.SyntaxKind.JsxOpeningElement:
|
|
195827
|
+
case import_typescript12.default.SyntaxKind.JsxOpeningFragment:
|
|
195828
|
+
case import_typescript12.default.SyntaxKind.JsxClosingFragment:
|
|
195829
|
+
case import_typescript12.default.SyntaxKind.JsxAttributes:
|
|
195830
|
+
case import_typescript12.default.SyntaxKind.MissingDeclaration:
|
|
195656
195831
|
return null;
|
|
195657
195832
|
default:
|
|
195658
195833
|
return assertNever2(node);
|
|
@@ -195689,7 +195864,7 @@ function transformConditionalBranch(node, ctx) {
|
|
|
195689
195864
|
};
|
|
195690
195865
|
}
|
|
195691
195866
|
function getMapLikeMethod(node) {
|
|
195692
|
-
if (!
|
|
195867
|
+
if (!import_typescript12.default.isPropertyAccessExpression(node.expression))
|
|
195693
195868
|
return null;
|
|
195694
195869
|
const name = node.expression.name.text;
|
|
195695
195870
|
if (name === "map")
|
|
@@ -195699,9 +195874,9 @@ function getMapLikeMethod(node) {
|
|
|
195699
195874
|
return null;
|
|
195700
195875
|
}
|
|
195701
195876
|
function isFilterCall(node) {
|
|
195702
|
-
if (!
|
|
195877
|
+
if (!import_typescript12.default.isCallExpression(node))
|
|
195703
195878
|
return null;
|
|
195704
|
-
if (!
|
|
195879
|
+
if (!import_typescript12.default.isPropertyAccessExpression(node.expression))
|
|
195705
195880
|
return null;
|
|
195706
195881
|
if (node.expression.name.text !== "filter")
|
|
195707
195882
|
return null;
|
|
@@ -195713,9 +195888,9 @@ function isFilterCall(node) {
|
|
|
195713
195888
|
};
|
|
195714
195889
|
}
|
|
195715
195890
|
function isSortCall(node) {
|
|
195716
|
-
if (!
|
|
195891
|
+
if (!import_typescript12.default.isCallExpression(node))
|
|
195717
195892
|
return null;
|
|
195718
|
-
if (!
|
|
195893
|
+
if (!import_typescript12.default.isPropertyAccessExpression(node.expression))
|
|
195719
195894
|
return null;
|
|
195720
195895
|
const methodName = node.expression.name.text;
|
|
195721
195896
|
if (methodName !== "sort" && methodName !== "toSorted")
|
|
@@ -195729,9 +195904,9 @@ function isSortCall(node) {
|
|
|
195729
195904
|
};
|
|
195730
195905
|
}
|
|
195731
195906
|
function isIteratorShapeCall(node) {
|
|
195732
|
-
if (!
|
|
195907
|
+
if (!import_typescript12.default.isCallExpression(node))
|
|
195733
195908
|
return null;
|
|
195734
|
-
if (!
|
|
195909
|
+
if (!import_typescript12.default.isPropertyAccessExpression(node.expression))
|
|
195735
195910
|
return null;
|
|
195736
195911
|
if (node.arguments.length !== 0)
|
|
195737
195912
|
return null;
|
|
@@ -195741,11 +195916,11 @@ function isIteratorShapeCall(node) {
|
|
|
195741
195916
|
return { array: node.expression.expression, shape: name };
|
|
195742
195917
|
}
|
|
195743
195918
|
function isObjectIteratorCall(node) {
|
|
195744
|
-
if (!
|
|
195919
|
+
if (!import_typescript12.default.isCallExpression(node))
|
|
195745
195920
|
return null;
|
|
195746
|
-
if (!
|
|
195921
|
+
if (!import_typescript12.default.isPropertyAccessExpression(node.expression))
|
|
195747
195922
|
return null;
|
|
195748
|
-
if (!
|
|
195923
|
+
if (!import_typescript12.default.isIdentifier(node.expression.expression))
|
|
195749
195924
|
return null;
|
|
195750
195925
|
if (node.expression.expression.text !== "Object")
|
|
195751
195926
|
return null;
|
|
@@ -195770,7 +195945,7 @@ function extractSortComparator(callback, _method, ctx) {
|
|
|
195770
195945
|
` + `(reverse the operands for descending order).`
|
|
195771
195946
|
});
|
|
195772
195947
|
let resolvedNode = callback;
|
|
195773
|
-
if (
|
|
195948
|
+
if (import_typescript12.default.isIdentifier(callback)) {
|
|
195774
195949
|
const resolved = resolveSortComparatorIdentifier(callback.text, ctx);
|
|
195775
195950
|
if (!resolved) {
|
|
195776
195951
|
return {
|
|
@@ -195780,7 +195955,7 @@ function extractSortComparator(callback, _method, ctx) {
|
|
|
195780
195955
|
}
|
|
195781
195956
|
resolvedNode = resolved;
|
|
195782
195957
|
}
|
|
195783
|
-
if (!
|
|
195958
|
+
if (!import_typescript12.default.isArrowFunction(resolvedNode) && !import_typescript12.default.isFunctionExpression(resolvedNode)) {
|
|
195784
195959
|
return {
|
|
195785
195960
|
result: null,
|
|
195786
195961
|
unsupportedReason: "Sort comparator must be an arrow function or function expression"
|
|
@@ -195807,11 +195982,11 @@ function resolveSortComparatorIdentifier(name, ctx) {
|
|
|
195807
195982
|
return null;
|
|
195808
195983
|
if (constInfo) {
|
|
195809
195984
|
const ast = parseConstInitializer(constInfo);
|
|
195810
|
-
return ast && (
|
|
195985
|
+
return ast && (import_typescript12.default.isArrowFunction(ast) || import_typescript12.default.isFunctionExpression(ast)) ? ast : null;
|
|
195811
195986
|
}
|
|
195812
195987
|
if (fnInfo) {
|
|
195813
195988
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
195814
|
-
return ast && (
|
|
195989
|
+
return ast && (import_typescript12.default.isArrowFunction(ast) || import_typescript12.default.isFunctionExpression(ast)) ? ast : null;
|
|
195815
195990
|
}
|
|
195816
195991
|
return null;
|
|
195817
195992
|
}
|
|
@@ -195822,11 +195997,11 @@ function resolveCallbackMethodFunctionReferenceIdentifier(name, analyzer) {
|
|
|
195822
195997
|
return null;
|
|
195823
195998
|
if (constInfo) {
|
|
195824
195999
|
const ast = parseConstInitializer(constInfo);
|
|
195825
|
-
return ast && (
|
|
196000
|
+
return ast && (import_typescript12.default.isArrowFunction(ast) || import_typescript12.default.isFunctionExpression(ast)) ? ast : null;
|
|
195826
196001
|
}
|
|
195827
196002
|
if (fnInfo) {
|
|
195828
196003
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
195829
|
-
return ast && (
|
|
196004
|
+
return ast && (import_typescript12.default.isArrowFunction(ast) || import_typescript12.default.isFunctionExpression(ast)) ? ast : null;
|
|
195830
196005
|
}
|
|
195831
196006
|
return null;
|
|
195832
196007
|
}
|
|
@@ -195882,13 +196057,13 @@ function resolveCallbackMethodFunctionReferences(expr, analyzer, bound = EMPTY_B
|
|
|
195882
196057
|
return visit2(expr, bound);
|
|
195883
196058
|
}
|
|
195884
196059
|
function extractFilterPredicate(callback, ctx) {
|
|
195885
|
-
if (!
|
|
196060
|
+
if (!import_typescript12.default.isArrowFunction(callback))
|
|
195886
196061
|
return { result: null };
|
|
195887
196062
|
if (callback.parameters.length < 1)
|
|
195888
196063
|
return { result: null };
|
|
195889
196064
|
const firstParam = callback.parameters[0];
|
|
195890
|
-
if (!
|
|
195891
|
-
if (
|
|
196065
|
+
if (!import_typescript12.default.isIdentifier(firstParam.name)) {
|
|
196066
|
+
if (import_typescript12.default.isBlock(callback.body)) {
|
|
195892
196067
|
return {
|
|
195893
196068
|
result: null,
|
|
195894
196069
|
unsupportedReason: "Block body in a destructured filter param is not supported. Workaround: use an expression-body arrow, or add /* @client */."
|
|
@@ -195908,7 +196083,7 @@ function extractFilterPredicate(callback, ctx) {
|
|
|
195908
196083
|
return { result: null };
|
|
195909
196084
|
}
|
|
195910
196085
|
const param = firstParam.name.getText(ctx.sourceFile);
|
|
195911
|
-
if (
|
|
196086
|
+
if (import_typescript12.default.isBlock(callback.body)) {
|
|
195912
196087
|
const raw2 = ctx.getJS(callback.body);
|
|
195913
196088
|
const statements = parseBlockBody(callback.body, ctx.sourceFile, (n) => ctx.getJS(n));
|
|
195914
196089
|
if (!statements) {
|
|
@@ -195934,7 +196109,7 @@ function extractFilterPredicate(callback, ctx) {
|
|
|
195934
196109
|
return { result: { param, predicate, raw } };
|
|
195935
196110
|
}
|
|
195936
196111
|
function extractLoopParamBindings(pattern) {
|
|
195937
|
-
if (
|
|
196112
|
+
if (import_typescript12.default.isIdentifier(pattern))
|
|
195938
196113
|
return null;
|
|
195939
196114
|
const bindings = [];
|
|
195940
196115
|
let unsupported = false;
|
|
@@ -195943,7 +196118,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
195943
196118
|
return false;
|
|
195944
196119
|
for (let i2 = 0;i2 < key.length; ) {
|
|
195945
196120
|
const cp = key.codePointAt(i2);
|
|
195946
|
-
const ok = i2 === 0 ?
|
|
196121
|
+
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
196122
|
if (!ok)
|
|
195948
196123
|
return false;
|
|
195949
196124
|
i2 += cp > 65535 ? 2 : 1;
|
|
@@ -195956,17 +196131,17 @@ function extractLoopParamBindings(pattern) {
|
|
|
195956
196131
|
const walk = (p, prefix, segments) => {
|
|
195957
196132
|
if (unsupported)
|
|
195958
196133
|
return;
|
|
195959
|
-
if (
|
|
196134
|
+
if (import_typescript12.default.isArrayBindingPattern(p)) {
|
|
195960
196135
|
const elements2 = p.elements;
|
|
195961
196136
|
for (let index = 0;index < elements2.length; index++) {
|
|
195962
196137
|
if (unsupported)
|
|
195963
196138
|
return;
|
|
195964
196139
|
const el = elements2[index];
|
|
195965
|
-
if (
|
|
196140
|
+
if (import_typescript12.default.isOmittedExpression(el))
|
|
195966
196141
|
continue;
|
|
195967
196142
|
if (el.dotDotDotToken) {
|
|
195968
196143
|
internalInvariant(index === elements2.length - 1, "extractLoopParamBindings: array rest token in non-final position (parser should reject)");
|
|
195969
|
-
internalInvariant(
|
|
196144
|
+
internalInvariant(import_typescript12.default.isIdentifier(el.name), "extractLoopParamBindings: array rest target is not an identifier (parser should reject)");
|
|
195970
196145
|
bindings.push({
|
|
195971
196146
|
name: el.name.text,
|
|
195972
196147
|
path: prefix,
|
|
@@ -195977,7 +196152,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
195977
196152
|
}
|
|
195978
196153
|
const path = `${prefix}[${index}]`;
|
|
195979
196154
|
const nextSegments = [...segments, { kind: "index", index }];
|
|
195980
|
-
if (
|
|
196155
|
+
if (import_typescript12.default.isIdentifier(el.name)) {
|
|
195981
196156
|
bindings.push({ name: el.name.text, path, segments: nextSegments });
|
|
195982
196157
|
} else {
|
|
195983
196158
|
walk(el.name, path, nextSegments);
|
|
@@ -195993,7 +196168,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
195993
196168
|
const el = elements[i2];
|
|
195994
196169
|
if (el.dotDotDotToken) {
|
|
195995
196170
|
internalInvariant(i2 === elements.length - 1, "extractLoopParamBindings: object rest token in non-final position (parser should reject)");
|
|
195996
|
-
internalInvariant(
|
|
196171
|
+
internalInvariant(import_typescript12.default.isIdentifier(el.name), "extractLoopParamBindings: object rest target is not an identifier (parser should reject)");
|
|
195997
196172
|
bindings.push({
|
|
195998
196173
|
name: el.name.text,
|
|
195999
196174
|
path: prefix,
|
|
@@ -196005,17 +196180,17 @@ function extractLoopParamBindings(pattern) {
|
|
|
196005
196180
|
let keyText = null;
|
|
196006
196181
|
if (el.propertyName) {
|
|
196007
196182
|
const pn = el.propertyName;
|
|
196008
|
-
if (
|
|
196183
|
+
if (import_typescript12.default.isIdentifier(pn))
|
|
196009
196184
|
keyText = pn.text;
|
|
196010
|
-
else if (
|
|
196185
|
+
else if (import_typescript12.default.isStringLiteral(pn))
|
|
196011
196186
|
keyText = pn.text;
|
|
196012
|
-
else if (
|
|
196187
|
+
else if (import_typescript12.default.isNumericLiteral(pn))
|
|
196013
196188
|
keyText = pn.text;
|
|
196014
196189
|
else {
|
|
196015
196190
|
unsupported = true;
|
|
196016
196191
|
return;
|
|
196017
196192
|
}
|
|
196018
|
-
} else if (
|
|
196193
|
+
} else if (import_typescript12.default.isIdentifier(el.name)) {
|
|
196019
196194
|
keyText = el.name.text;
|
|
196020
196195
|
} else {
|
|
196021
196196
|
unsupported = true;
|
|
@@ -196025,14 +196200,14 @@ function extractLoopParamBindings(pattern) {
|
|
|
196025
196200
|
collectedKeys.push({ key: keyText, isIdent: keyIsIdent });
|
|
196026
196201
|
const path = appendDotAccess(prefix, keyText);
|
|
196027
196202
|
const nextSegments = [...segments, { kind: "field", key: keyText, isIdent: keyIsIdent }];
|
|
196028
|
-
if (
|
|
196203
|
+
if (import_typescript12.default.isIdentifier(el.name)) {
|
|
196029
196204
|
bindings.push({ name: el.name.text, path, segments: nextSegments });
|
|
196030
196205
|
} else {
|
|
196031
196206
|
walk(el.name, path, nextSegments);
|
|
196032
196207
|
}
|
|
196033
196208
|
}
|
|
196034
196209
|
};
|
|
196035
|
-
if (
|
|
196210
|
+
if (import_typescript12.default.isArrayBindingPattern(pattern) || import_typescript12.default.isObjectBindingPattern(pattern)) {
|
|
196036
196211
|
walk(pattern, "", []);
|
|
196037
196212
|
if (unsupported)
|
|
196038
196213
|
return { unsupported: true };
|
|
@@ -196042,7 +196217,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
196042
196217
|
}
|
|
196043
196218
|
function findKeyJsxAttribute(opening) {
|
|
196044
196219
|
for (const prop of opening.attributes.properties) {
|
|
196045
|
-
if (
|
|
196220
|
+
if (import_typescript12.default.isJsxAttribute(prop) && prop.name.getText() === "key") {
|
|
196046
196221
|
return prop;
|
|
196047
196222
|
}
|
|
196048
196223
|
}
|
|
@@ -196087,7 +196262,7 @@ function keyAttrValueToExpr(v) {
|
|
|
196087
196262
|
function normalizeKeyExpr(expr) {
|
|
196088
196263
|
let out = "";
|
|
196089
196264
|
for (const tok of iterateJsTokens(expr)) {
|
|
196090
|
-
if (tok.kind ===
|
|
196265
|
+
if (tok.kind === import_typescript12.default.SyntaxKind.WhitespaceTrivia || tok.kind === import_typescript12.default.SyntaxKind.NewLineTrivia) {
|
|
196091
196266
|
continue;
|
|
196092
196267
|
}
|
|
196093
196268
|
out += expr.slice(tok.pos, tok.end);
|
|
@@ -196099,13 +196274,13 @@ function conditionalHasExplicitNullishBranch(cond) {
|
|
|
196099
196274
|
}
|
|
196100
196275
|
function branchHasExplicitNullish(branch) {
|
|
196101
196276
|
let b = branch;
|
|
196102
|
-
while (
|
|
196277
|
+
while (import_typescript12.default.isParenthesizedExpression(b))
|
|
196103
196278
|
b = b.expression;
|
|
196104
|
-
if (b.kind ===
|
|
196279
|
+
if (b.kind === import_typescript12.default.SyntaxKind.NullKeyword)
|
|
196105
196280
|
return true;
|
|
196106
|
-
if (
|
|
196281
|
+
if (import_typescript12.default.isIdentifier(b) && b.text === "undefined")
|
|
196107
196282
|
return true;
|
|
196108
|
-
if (
|
|
196283
|
+
if (import_typescript12.default.isConditionalExpression(b))
|
|
196109
196284
|
return conditionalHasExplicitNullishBranch(b);
|
|
196110
196285
|
return false;
|
|
196111
196286
|
}
|
|
@@ -196114,26 +196289,26 @@ function classifyKeyProblem(keyAttr, checker) {
|
|
|
196114
196289
|
return "missing";
|
|
196115
196290
|
if (!keyAttr.initializer)
|
|
196116
196291
|
return "missing";
|
|
196117
|
-
if (
|
|
196292
|
+
if (import_typescript12.default.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
|
|
196118
196293
|
return "missing";
|
|
196119
196294
|
}
|
|
196120
196295
|
let expr;
|
|
196121
|
-
if (
|
|
196296
|
+
if (import_typescript12.default.isStringLiteral(keyAttr.initializer)) {
|
|
196122
196297
|
return null;
|
|
196123
|
-
} else if (
|
|
196298
|
+
} else if (import_typescript12.default.isJsxExpression(keyAttr.initializer)) {
|
|
196124
196299
|
expr = keyAttr.initializer.expression;
|
|
196125
196300
|
}
|
|
196126
196301
|
if (!expr)
|
|
196127
196302
|
return null;
|
|
196128
|
-
if (expr.kind ===
|
|
196303
|
+
if (expr.kind === import_typescript12.default.SyntaxKind.NullKeyword)
|
|
196129
196304
|
return null;
|
|
196130
|
-
if (
|
|
196305
|
+
if (import_typescript12.default.isIdentifier(expr) && expr.text === "undefined")
|
|
196131
196306
|
return null;
|
|
196132
|
-
if (
|
|
196307
|
+
if (import_typescript12.default.isConditionalExpression(expr) && conditionalHasExplicitNullishBranch(expr))
|
|
196133
196308
|
return null;
|
|
196134
196309
|
if (checker) {
|
|
196135
196310
|
const type2 = checker.getTypeAtLocation(expr);
|
|
196136
|
-
const isNullable = type2.isUnion() ? type2.types.some((t) => (t.flags & (
|
|
196311
|
+
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
196312
|
if (isNullable)
|
|
196138
196313
|
return "nullable-type";
|
|
196139
196314
|
}
|
|
@@ -196159,81 +196334,81 @@ function checkLoopKey(callback, ctx, isNested) {
|
|
|
196159
196334
|
ctx.analyzer.errors.push(createError(errorCode, getSourceLocation(locNode, ctx.sourceFile, ctx.filePath), { suggestion: { message: keyErrorSuggestion(problem) } }));
|
|
196160
196335
|
}
|
|
196161
196336
|
let body = callback.body;
|
|
196162
|
-
if (
|
|
196163
|
-
const ret = body.statements.find((s) =>
|
|
196337
|
+
if (import_typescript12.default.isBlock(body)) {
|
|
196338
|
+
const ret = body.statements.find((s) => import_typescript12.default.isReturnStatement(s) && s.expression != null);
|
|
196164
196339
|
if (!ret?.expression)
|
|
196165
196340
|
return;
|
|
196166
196341
|
body = ret.expression;
|
|
196167
196342
|
}
|
|
196168
|
-
while (
|
|
196343
|
+
while (import_typescript12.default.isParenthesizedExpression(body))
|
|
196169
196344
|
body = body.expression;
|
|
196170
196345
|
function checkJsxOperand(node) {
|
|
196171
196346
|
let n = node;
|
|
196172
|
-
while (
|
|
196347
|
+
while (import_typescript12.default.isParenthesizedExpression(n))
|
|
196173
196348
|
n = n.expression;
|
|
196174
|
-
if (
|
|
196349
|
+
if (import_typescript12.default.isJsxElement(n))
|
|
196175
196350
|
checkOpening(n.openingElement);
|
|
196176
|
-
else if (
|
|
196351
|
+
else if (import_typescript12.default.isJsxSelfClosingElement(n))
|
|
196177
196352
|
checkOpening(n);
|
|
196178
196353
|
}
|
|
196179
|
-
if (
|
|
196354
|
+
if (import_typescript12.default.isConditionalExpression(body)) {
|
|
196180
196355
|
checkJsxOperand(body.whenTrue);
|
|
196181
196356
|
checkJsxOperand(body.whenFalse);
|
|
196182
196357
|
return;
|
|
196183
196358
|
}
|
|
196184
|
-
if (
|
|
196359
|
+
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
196360
|
checkJsxOperand(body.left);
|
|
196186
196361
|
checkJsxOperand(body.right);
|
|
196187
196362
|
return;
|
|
196188
196363
|
}
|
|
196189
|
-
if (
|
|
196364
|
+
if (import_typescript12.default.isJsxElement(body)) {
|
|
196190
196365
|
checkOpening(body.openingElement);
|
|
196191
196366
|
return;
|
|
196192
196367
|
}
|
|
196193
|
-
if (
|
|
196368
|
+
if (import_typescript12.default.isJsxSelfClosingElement(body)) {
|
|
196194
196369
|
checkOpening(body);
|
|
196195
196370
|
return;
|
|
196196
196371
|
}
|
|
196197
196372
|
}
|
|
196198
196373
|
function flatMapProjectionCall(body) {
|
|
196199
196374
|
let expr;
|
|
196200
|
-
if (
|
|
196375
|
+
if (import_typescript12.default.isBlock(body)) {
|
|
196201
196376
|
const real = body.statements;
|
|
196202
|
-
if (real.length !== 1 || !
|
|
196377
|
+
if (real.length !== 1 || !import_typescript12.default.isReturnStatement(real[0]) || !real[0].expression)
|
|
196203
196378
|
return null;
|
|
196204
196379
|
expr = real[0].expression;
|
|
196205
196380
|
} else {
|
|
196206
196381
|
expr = body;
|
|
196207
196382
|
}
|
|
196208
|
-
while (
|
|
196383
|
+
while (import_typescript12.default.isParenthesizedExpression(expr))
|
|
196209
196384
|
expr = expr.expression;
|
|
196210
|
-
if (!
|
|
196385
|
+
if (!import_typescript12.default.isCallExpression(expr))
|
|
196211
196386
|
return null;
|
|
196212
196387
|
if (!getMapLikeMethod(expr))
|
|
196213
196388
|
return null;
|
|
196214
196389
|
const cb = expr.arguments[0];
|
|
196215
|
-
if (!cb || !
|
|
196390
|
+
if (!cb || !import_typescript12.default.isArrowFunction(cb) && !import_typescript12.default.isFunctionExpression(cb))
|
|
196216
196391
|
return null;
|
|
196217
196392
|
for (const p of cb.parameters) {
|
|
196218
|
-
if (!
|
|
196393
|
+
if (!import_typescript12.default.isIdentifier(p.name))
|
|
196219
196394
|
return null;
|
|
196220
196395
|
}
|
|
196221
196396
|
let innerBody = cb.body;
|
|
196222
|
-
if (
|
|
196223
|
-
const ret = innerBody.statements.find((s) =>
|
|
196397
|
+
if (import_typescript12.default.isBlock(innerBody)) {
|
|
196398
|
+
const ret = innerBody.statements.find((s) => import_typescript12.default.isReturnStatement(s) && s.expression != null);
|
|
196224
196399
|
if (innerBody.statements.length !== 1 || !ret?.expression)
|
|
196225
196400
|
return null;
|
|
196226
196401
|
innerBody = ret.expression;
|
|
196227
196402
|
}
|
|
196228
|
-
while (
|
|
196403
|
+
while (import_typescript12.default.isParenthesizedExpression(innerBody))
|
|
196229
196404
|
innerBody = innerBody.expression;
|
|
196230
196405
|
const isElementish = (n) => {
|
|
196231
196406
|
let m = n;
|
|
196232
|
-
while (
|
|
196407
|
+
while (import_typescript12.default.isParenthesizedExpression(m))
|
|
196233
196408
|
m = m.expression;
|
|
196234
|
-
if (
|
|
196409
|
+
if (import_typescript12.default.isJsxElement(m) || import_typescript12.default.isJsxSelfClosingElement(m))
|
|
196235
196410
|
return leafIsWirelessElement(m);
|
|
196236
|
-
if (
|
|
196411
|
+
if (import_typescript12.default.isConditionalExpression(m))
|
|
196237
196412
|
return isElementish(m.whenTrue) && isElementish(m.whenFalse);
|
|
196238
196413
|
return false;
|
|
196239
196414
|
};
|
|
@@ -196246,19 +196421,19 @@ function leafIsWirelessElement(el) {
|
|
|
196246
196421
|
const visit2 = (n) => {
|
|
196247
196422
|
if (!ok)
|
|
196248
196423
|
return;
|
|
196249
|
-
if (
|
|
196424
|
+
if (import_typescript12.default.isJsxOpeningElement(n) || import_typescript12.default.isJsxSelfClosingElement(n)) {
|
|
196250
196425
|
const tagNode = n.tagName;
|
|
196251
|
-
const isIntrinsic =
|
|
196426
|
+
const isIntrinsic = import_typescript12.default.isIdentifier(tagNode) ? !/^[A-Z]/.test(tagNode.text) : import_typescript12.default.isJsxNamespacedName(tagNode);
|
|
196252
196427
|
if (!isIntrinsic) {
|
|
196253
196428
|
ok = false;
|
|
196254
196429
|
return;
|
|
196255
196430
|
}
|
|
196256
196431
|
for (const attr of n.attributes.properties) {
|
|
196257
|
-
if (
|
|
196432
|
+
if (import_typescript12.default.isJsxSpreadAttribute(attr)) {
|
|
196258
196433
|
ok = false;
|
|
196259
196434
|
return;
|
|
196260
196435
|
}
|
|
196261
|
-
if (
|
|
196436
|
+
if (import_typescript12.default.isJsxAttribute(attr)) {
|
|
196262
196437
|
const name = attr.name.getText();
|
|
196263
196438
|
if (/^on[A-Z]/.test(name)) {
|
|
196264
196439
|
ok = false;
|
|
@@ -196267,11 +196442,11 @@ function leafIsWirelessElement(el) {
|
|
|
196267
196442
|
}
|
|
196268
196443
|
}
|
|
196269
196444
|
}
|
|
196270
|
-
if (
|
|
196445
|
+
if (import_typescript12.default.isCallExpression(n) && getMapLikeMethod(n) && containsJsxInExpression(n)) {
|
|
196271
196446
|
ok = false;
|
|
196272
196447
|
return;
|
|
196273
196448
|
}
|
|
196274
|
-
|
|
196449
|
+
import_typescript12.default.forEachChild(n, visit2);
|
|
196275
196450
|
};
|
|
196276
196451
|
visit2(el);
|
|
196277
196452
|
return ok;
|
|
@@ -196329,7 +196504,7 @@ function extractItemConditionalKey(cond) {
|
|
|
196329
196504
|
return a ?? b;
|
|
196330
196505
|
}
|
|
196331
196506
|
function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
196332
|
-
const isNested = ctx.
|
|
196507
|
+
const isNested = ctx.scope.valueBoundNames().size > 0;
|
|
196333
196508
|
const diagCountAtEntry = ctx.analyzer.errors.length;
|
|
196334
196509
|
const depth = ctx.loopDepth;
|
|
196335
196510
|
const propAccess = node.expression;
|
|
@@ -196451,7 +196626,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196451
196626
|
let children = [];
|
|
196452
196627
|
let paramBindings;
|
|
196453
196628
|
let flatMapCallback;
|
|
196454
|
-
if (
|
|
196629
|
+
if (import_typescript12.default.isArrowFunction(callback)) {
|
|
196455
196630
|
if (callback.parameters.length > 0) {
|
|
196456
196631
|
const firstParam = callback.parameters[0];
|
|
196457
196632
|
param = firstParam.name.getText(ctx.sourceFile);
|
|
@@ -196459,9 +196634,9 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196459
196634
|
paramType = firstParam.type.getText(ctx.sourceFile);
|
|
196460
196635
|
}
|
|
196461
196636
|
const isEntriesShape = iterationShape === "entries" || objectIteration === "entries";
|
|
196462
|
-
if (isEntriesShape &&
|
|
196463
|
-
const elements = firstParam.name.elements.filter((el) => !
|
|
196464
|
-
if (elements.length === 2 &&
|
|
196637
|
+
if (isEntriesShape && import_typescript12.default.isArrayBindingPattern(firstParam.name)) {
|
|
196638
|
+
const elements = firstParam.name.elements.filter((el) => !import_typescript12.default.isOmittedExpression(el));
|
|
196639
|
+
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
196640
|
index = elements[0].name.text;
|
|
196466
196641
|
param = elements[1].name.text;
|
|
196467
196642
|
} else {
|
|
@@ -196488,20 +196663,14 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196488
196663
|
indexType = secondParam.type.getText(ctx.sourceFile);
|
|
196489
196664
|
}
|
|
196490
196665
|
}
|
|
196491
|
-
|
|
196492
|
-
|
|
196493
|
-
ctx.loopParams.add(b.name);
|
|
196494
|
-
} else {
|
|
196495
|
-
ctx.loopParams.add(param);
|
|
196496
|
-
}
|
|
196497
|
-
if (index)
|
|
196498
|
-
ctx.loopParams.add(index);
|
|
196666
|
+
const savedScope = ctx.scope;
|
|
196667
|
+
ctx.scope = ctx.scope.enterLoopRow({ param, index, paramBindings });
|
|
196499
196668
|
ctx.loopDepth++;
|
|
196500
196669
|
const tryTransformRenderableBody = (expr) => {
|
|
196501
|
-
if (!
|
|
196670
|
+
if (!import_typescript12.default.isBinaryExpression(expr))
|
|
196502
196671
|
return;
|
|
196503
196672
|
const op = expr.operatorToken.kind;
|
|
196504
|
-
if (op !==
|
|
196673
|
+
if (op !== import_typescript12.default.SyntaxKind.AmpersandAmpersandToken && op !== import_typescript12.default.SyntaxKind.BarBarToken && op !== import_typescript12.default.SyntaxKind.QuestionQuestionToken) {
|
|
196505
196674
|
return;
|
|
196506
196675
|
}
|
|
196507
196676
|
if (!containsJsxInExpression(expr) && !callsJsxHelper(expr, ctx))
|
|
@@ -196511,33 +196680,33 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196511
196680
|
children = [transformed];
|
|
196512
196681
|
};
|
|
196513
196682
|
const body = callback.body;
|
|
196514
|
-
if (
|
|
196683
|
+
if (import_typescript12.default.isJsxElement(body) || import_typescript12.default.isJsxSelfClosingElement(body) || import_typescript12.default.isJsxFragment(body)) {
|
|
196515
196684
|
const transformed = transformNode(body, ctx);
|
|
196516
196685
|
if (transformed) {
|
|
196517
196686
|
children = [transformed];
|
|
196518
196687
|
}
|
|
196519
|
-
} else if (
|
|
196688
|
+
} else if (import_typescript12.default.isConditionalExpression(body)) {
|
|
196520
196689
|
children = [transformConditional(body, ctx)];
|
|
196521
|
-
} else if (
|
|
196690
|
+
} else if (import_typescript12.default.isParenthesizedExpression(body)) {
|
|
196522
196691
|
let inner = body.expression;
|
|
196523
|
-
while (
|
|
196692
|
+
while (import_typescript12.default.isParenthesizedExpression(inner)) {
|
|
196524
196693
|
inner = inner.expression;
|
|
196525
196694
|
}
|
|
196526
|
-
if (
|
|
196695
|
+
if (import_typescript12.default.isJsxElement(inner) || import_typescript12.default.isJsxSelfClosingElement(inner) || import_typescript12.default.isJsxFragment(inner)) {
|
|
196527
196696
|
const transformed = transformNode(inner, ctx);
|
|
196528
196697
|
if (transformed) {
|
|
196529
196698
|
children = [transformed];
|
|
196530
196699
|
}
|
|
196531
|
-
} else if (
|
|
196700
|
+
} else if (import_typescript12.default.isConditionalExpression(inner)) {
|
|
196532
196701
|
children = [transformConditional(inner, ctx)];
|
|
196533
|
-
} else if (method === "flatMap" &&
|
|
196702
|
+
} else if (method === "flatMap" && import_typescript12.default.isArrayLiteralExpression(inner)) {
|
|
196534
196703
|
children = transformArrayLiteralChildren(inner, ctx);
|
|
196535
196704
|
} else {
|
|
196536
196705
|
tryTransformRenderableBody(inner);
|
|
196537
196706
|
}
|
|
196538
|
-
} else if (method === "flatMap" &&
|
|
196707
|
+
} else if (method === "flatMap" && import_typescript12.default.isArrayLiteralExpression(body)) {
|
|
196539
196708
|
children = transformArrayLiteralChildren(body, ctx);
|
|
196540
|
-
} else if (
|
|
196709
|
+
} else if (import_typescript12.default.isBlock(body)) {
|
|
196541
196710
|
const multiReturn = method !== "flatMap" ? extractMultiReturnJsxBranches(body, true) : null;
|
|
196542
196711
|
if (multiReturn && multiReturn.branches.length > 0) {
|
|
196543
196712
|
const loc = getSourceLocation(body, ctx.sourceFile, ctx.filePath);
|
|
@@ -196555,13 +196724,31 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196555
196724
|
}
|
|
196556
196725
|
}
|
|
196557
196726
|
}
|
|
196558
|
-
const returnStmt = children.length === 0 ? body.statements.find((s) =>
|
|
196727
|
+
const returnStmt = children.length === 0 ? body.statements.find((s) => import_typescript12.default.isReturnStatement(s) && s.expression != null) : undefined;
|
|
196728
|
+
let rowScopeBeforePreamble = null;
|
|
196729
|
+
if (returnStmt) {
|
|
196730
|
+
const preambleNames = new Set;
|
|
196731
|
+
for (const stmt of body.statements) {
|
|
196732
|
+
if (stmt === returnStmt)
|
|
196733
|
+
break;
|
|
196734
|
+
collectPreambleDeclaredNames(stmt, preambleNames);
|
|
196735
|
+
}
|
|
196736
|
+
if (preambleNames.size > 0) {
|
|
196737
|
+
rowScopeBeforePreamble = ctx.scope;
|
|
196738
|
+
ctx.scope = savedScope.enterLoopRow({
|
|
196739
|
+
param,
|
|
196740
|
+
index,
|
|
196741
|
+
paramBindings,
|
|
196742
|
+
preamble: { declaredNames: [...preambleNames] }
|
|
196743
|
+
});
|
|
196744
|
+
}
|
|
196745
|
+
}
|
|
196559
196746
|
if (returnStmt && returnStmt.expression) {
|
|
196560
196747
|
let returnExpr = returnStmt.expression;
|
|
196561
|
-
while (
|
|
196748
|
+
while (import_typescript12.default.isParenthesizedExpression(returnExpr)) {
|
|
196562
196749
|
returnExpr = returnExpr.expression;
|
|
196563
196750
|
}
|
|
196564
|
-
if (
|
|
196751
|
+
if (import_typescript12.default.isJsxElement(returnExpr) || import_typescript12.default.isJsxSelfClosingElement(returnExpr) || import_typescript12.default.isJsxFragment(returnExpr)) {
|
|
196565
196752
|
const transformed = transformNode(returnExpr, ctx);
|
|
196566
196753
|
if (transformed) {
|
|
196567
196754
|
children = [transformed];
|
|
@@ -196625,6 +196812,9 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196625
196812
|
}
|
|
196626
196813
|
}
|
|
196627
196814
|
}
|
|
196815
|
+
if (rowScopeBeforePreamble) {
|
|
196816
|
+
ctx.scope = rowScopeBeforePreamble;
|
|
196817
|
+
}
|
|
196628
196818
|
if (method === "flatMap" && children.length === 0 && !flatMapProjectionCall(body)) {
|
|
196629
196819
|
flatMapCallback = buildFlatMapCallback(callback, body, ctx);
|
|
196630
196820
|
}
|
|
@@ -196640,7 +196830,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196640
196830
|
}
|
|
196641
196831
|
}
|
|
196642
196832
|
}
|
|
196643
|
-
if (method === "flatMap" && children.length === 0 && !flatMapCallback && !
|
|
196833
|
+
if (method === "flatMap" && children.length === 0 && !flatMapCallback && !import_typescript12.default.isBlock(body)) {
|
|
196644
196834
|
flatMapCallback = buildFlatMapCallback(callback, body, ctx);
|
|
196645
196835
|
}
|
|
196646
196836
|
if (flatMapCallback)
|
|
@@ -196653,19 +196843,12 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196653
196843
|
}
|
|
196654
196844
|
}));
|
|
196655
196845
|
}
|
|
196656
|
-
|
|
196657
|
-
for (const b of paramBindings)
|
|
196658
|
-
ctx.loopParams.delete(b.name);
|
|
196659
|
-
} else {
|
|
196660
|
-
ctx.loopParams.delete(param);
|
|
196661
|
-
}
|
|
196662
|
-
if (index)
|
|
196663
|
-
ctx.loopParams.delete(index);
|
|
196846
|
+
ctx.scope = savedScope;
|
|
196664
196847
|
ctx.loopDepth--;
|
|
196665
196848
|
}
|
|
196666
196849
|
if (children.length === 0 && !flatMapCallback) {
|
|
196667
196850
|
const cb = node.arguments[0];
|
|
196668
|
-
const cbBody = cb && (
|
|
196851
|
+
const cbBody = cb && (import_typescript12.default.isArrowFunction(cb) || import_typescript12.default.isFunctionExpression(cb)) ? cb.body : undefined;
|
|
196669
196852
|
if (cbBody && containsJsxInExpression(cbBody) && ctx.analyzer.errors.length === diagCountAtEntry) {
|
|
196670
196853
|
ctx.analyzer.errors.push(createError(ErrorCodes.UNSUPPORTED_JSX_PATTERN, getSourceLocation(cbBody, ctx.sourceFile, ctx.filePath), {
|
|
196671
196854
|
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 +196859,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196676
196859
|
}
|
|
196677
196860
|
return null;
|
|
196678
196861
|
}
|
|
196679
|
-
if (
|
|
196862
|
+
if (import_typescript12.default.isArrowFunction(node.arguments[0]) && children.length > 0) {
|
|
196680
196863
|
checkLoopKey(node.arguments[0], ctx, isNested);
|
|
196681
196864
|
}
|
|
196682
196865
|
const itemConditional = children.length > 0 ? loopBodyItemConditional(children) : null;
|
|
@@ -196773,12 +196956,12 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
196773
196956
|
function transformArrayLiteralChildren(arrayLiteral, ctx) {
|
|
196774
196957
|
const children = [];
|
|
196775
196958
|
for (const element of arrayLiteral.elements) {
|
|
196776
|
-
if (
|
|
196959
|
+
if (import_typescript12.default.isSpreadElement(element))
|
|
196777
196960
|
continue;
|
|
196778
196961
|
let inner = element;
|
|
196779
|
-
while (
|
|
196962
|
+
while (import_typescript12.default.isParenthesizedExpression(inner))
|
|
196780
196963
|
inner = inner.expression;
|
|
196781
|
-
if (
|
|
196964
|
+
if (import_typescript12.default.isJsxElement(inner) || import_typescript12.default.isJsxSelfClosingElement(inner) || import_typescript12.default.isJsxFragment(inner)) {
|
|
196782
196965
|
const transformed = transformNode(inner, ctx);
|
|
196783
196966
|
if (transformed)
|
|
196784
196967
|
children.push(transformed);
|
|
@@ -196787,7 +196970,7 @@ function transformArrayLiteralChildren(arrayLiteral, ctx) {
|
|
|
196787
196970
|
return children;
|
|
196788
196971
|
}
|
|
196789
196972
|
function containsJsx(node) {
|
|
196790
|
-
if (
|
|
196973
|
+
if (import_typescript12.default.isJsxElement(node) || import_typescript12.default.isJsxSelfClosingElement(node) || import_typescript12.default.isJsxFragment(node))
|
|
196791
196974
|
return true;
|
|
196792
196975
|
let found = false;
|
|
196793
196976
|
node.forEachChild((child) => {
|
|
@@ -196803,7 +196986,7 @@ function buildFlatMapCallback(callback, body, ctx) {
|
|
|
196803
196986
|
const leafIrs = [];
|
|
196804
196987
|
let refusalNode;
|
|
196805
196988
|
const collectJsx = (n, underTemplate) => {
|
|
196806
|
-
if (
|
|
196989
|
+
if (import_typescript12.default.isJsxElement(n) || import_typescript12.default.isJsxSelfClosingElement(n) || import_typescript12.default.isJsxFragment(n)) {
|
|
196807
196990
|
if (underTemplate)
|
|
196808
196991
|
refusalNode ??= n;
|
|
196809
196992
|
leafSpans.push({ start: n.getStart(ctx.sourceFile), end: n.getEnd() });
|
|
@@ -196811,7 +196994,7 @@ function buildFlatMapCallback(callback, body, ctx) {
|
|
|
196811
196994
|
leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx.sourceFile, ctx.filePath) });
|
|
196812
196995
|
return;
|
|
196813
196996
|
}
|
|
196814
|
-
const inTemplate = underTemplate ||
|
|
196997
|
+
const inTemplate = underTemplate || import_typescript12.default.isTemplateExpression(n) || import_typescript12.default.isTaggedTemplateExpression(n);
|
|
196815
196998
|
n.forEachChild((c) => collectJsx(c, inTemplate));
|
|
196816
196999
|
};
|
|
196817
197000
|
collectJsx(body, false);
|
|
@@ -197002,21 +197185,21 @@ function attrValueText(value) {
|
|
|
197002
197185
|
return out.join(" ");
|
|
197003
197186
|
}
|
|
197004
197187
|
function collectBindingNames2(name, out) {
|
|
197005
|
-
if (
|
|
197188
|
+
if (import_typescript12.default.isIdentifier(name)) {
|
|
197006
197189
|
out.add(name.text);
|
|
197007
197190
|
return;
|
|
197008
197191
|
}
|
|
197009
197192
|
for (const el of name.elements) {
|
|
197010
|
-
if (
|
|
197193
|
+
if (import_typescript12.default.isBindingElement(el))
|
|
197011
197194
|
collectBindingNames2(el.name, out);
|
|
197012
197195
|
}
|
|
197013
197196
|
}
|
|
197014
197197
|
function collectPreambleDeclaredNames(stmt, out) {
|
|
197015
|
-
if (
|
|
197198
|
+
if (import_typescript12.default.isVariableStatement(stmt)) {
|
|
197016
197199
|
for (const decl of stmt.declarationList.declarations) {
|
|
197017
197200
|
collectBindingNames2(decl.name, out);
|
|
197018
197201
|
}
|
|
197019
|
-
} else if (
|
|
197202
|
+
} else if (import_typescript12.default.isFunctionDeclaration(stmt) && stmt.name) {
|
|
197020
197203
|
out.add(stmt.name.text);
|
|
197021
197204
|
}
|
|
197022
197205
|
}
|
|
@@ -197045,10 +197228,10 @@ function preambleFromValueStatements(statements, ctx) {
|
|
|
197045
197228
|
function neutralPreambleDeclarations(statements, ctx) {
|
|
197046
197229
|
const out = [];
|
|
197047
197230
|
for (const stmt of statements) {
|
|
197048
|
-
if (!
|
|
197231
|
+
if (!import_typescript12.default.isVariableStatement(stmt))
|
|
197049
197232
|
return null;
|
|
197050
197233
|
for (const decl of stmt.declarationList.declarations) {
|
|
197051
|
-
if (!
|
|
197234
|
+
if (!import_typescript12.default.isIdentifier(decl.name))
|
|
197052
197235
|
return null;
|
|
197053
197236
|
if (!decl.initializer)
|
|
197054
197237
|
return null;
|
|
@@ -197081,11 +197264,11 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
197081
197264
|
let refusalNode;
|
|
197082
197265
|
const recordBuilderTarget = (leaf, stmt) => {
|
|
197083
197266
|
for (let n = leaf.parent;n && n !== stmt.parent; n = n.parent) {
|
|
197084
|
-
if (
|
|
197267
|
+
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
197268
|
builders.add(n.expression.expression.text);
|
|
197086
197269
|
return;
|
|
197087
197270
|
}
|
|
197088
|
-
if (
|
|
197271
|
+
if (import_typescript12.default.isVariableDeclaration(n) && import_typescript12.default.isIdentifier(n.name)) {
|
|
197089
197272
|
builders.add(n.name.text);
|
|
197090
197273
|
return;
|
|
197091
197274
|
}
|
|
@@ -197098,7 +197281,7 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
197098
197281
|
const leafSpans = [];
|
|
197099
197282
|
const leafIrs = [];
|
|
197100
197283
|
const collect = (n, underTemplate) => {
|
|
197101
|
-
if (
|
|
197284
|
+
if (import_typescript12.default.isJsxElement(n) || import_typescript12.default.isJsxSelfClosingElement(n) || import_typescript12.default.isJsxFragment(n)) {
|
|
197102
197285
|
if (underTemplate)
|
|
197103
197286
|
refusalNode ??= n;
|
|
197104
197287
|
recordBuilderTarget(n, stmt);
|
|
@@ -197109,7 +197292,7 @@ function buildPreambleSegments(statements, returnStmt, ctx) {
|
|
|
197109
197292
|
leafIrs.push(ir ?? { type: "text", value: "", loc: getSourceLocation(n, ctx.sourceFile, ctx.filePath) });
|
|
197110
197293
|
return;
|
|
197111
197294
|
}
|
|
197112
|
-
const inTemplate = underTemplate ||
|
|
197295
|
+
const inTemplate = underTemplate || import_typescript12.default.isTemplateExpression(n) || import_typescript12.default.isTaggedTemplateExpression(n);
|
|
197113
197296
|
n.forEachChild((c) => collect(c, inTemplate));
|
|
197114
197297
|
};
|
|
197115
197298
|
collect(stmt, false);
|
|
@@ -197213,13 +197396,13 @@ function expandSpreadAttribute(attr, ctx) {
|
|
|
197213
197396
|
}];
|
|
197214
197397
|
}
|
|
197215
197398
|
function attrFreeIdentifiers(attr) {
|
|
197216
|
-
if (!attr.initializer || !
|
|
197399
|
+
if (!attr.initializer || !import_typescript12.default.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
|
|
197217
197400
|
return;
|
|
197218
197401
|
}
|
|
197219
197402
|
return extractFreeIdentifiersFromNode(attr.initializer.expression);
|
|
197220
197403
|
}
|
|
197221
197404
|
function computeReactivityFlags(attr, ctx) {
|
|
197222
|
-
if (!attr.initializer || !
|
|
197405
|
+
if (!attr.initializer || !import_typescript12.default.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
|
|
197223
197406
|
return {};
|
|
197224
197407
|
}
|
|
197225
197408
|
const expr = attr.initializer.expression;
|
|
@@ -197245,22 +197428,22 @@ function processAttributes(attributes, ctx) {
|
|
|
197245
197428
|
const events = [];
|
|
197246
197429
|
let ref = null;
|
|
197247
197430
|
for (const attr of attributes.properties) {
|
|
197248
|
-
if (
|
|
197431
|
+
if (import_typescript12.default.isJsxSpreadAttribute(attr)) {
|
|
197249
197432
|
attrs.push(...expandSpreadAttribute(attr, ctx));
|
|
197250
197433
|
continue;
|
|
197251
197434
|
}
|
|
197252
|
-
if (!
|
|
197435
|
+
if (!import_typescript12.default.isJsxAttribute(attr))
|
|
197253
197436
|
continue;
|
|
197254
197437
|
const rawName = attr.name.getText(ctx.sourceFile);
|
|
197255
197438
|
if (rawName === "ref") {
|
|
197256
|
-
if (attr.initializer &&
|
|
197439
|
+
if (attr.initializer && import_typescript12.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197257
197440
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
|
|
197258
197441
|
ref = ctx.getJS(attr.initializer.expression);
|
|
197259
197442
|
}
|
|
197260
197443
|
continue;
|
|
197261
197444
|
}
|
|
197262
197445
|
if (/^on[A-Z]/.test(rawName)) {
|
|
197263
|
-
if (attr.initializer &&
|
|
197446
|
+
if (attr.initializer && import_typescript12.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197264
197447
|
const eventName = rawName.slice(2).toLowerCase();
|
|
197265
197448
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
|
|
197266
197449
|
events.push({
|
|
@@ -197275,7 +197458,7 @@ function processAttributes(attributes, ctx) {
|
|
|
197275
197458
|
const name = toHTMLAttrName(rawName);
|
|
197276
197459
|
let value = getAttributeValue(attr, ctx);
|
|
197277
197460
|
let clientOnly;
|
|
197278
|
-
if (attr.initializer &&
|
|
197461
|
+
if (attr.initializer && import_typescript12.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197279
197462
|
if (value.kind === "expression" && value.templateExpr === undefined) {
|
|
197280
197463
|
const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
|
|
197281
197464
|
if (rewritten !== value.expr) {
|
|
@@ -197302,55 +197485,55 @@ function getAttributeValue(attr, ctx) {
|
|
|
197302
197485
|
if (!attr.initializer) {
|
|
197303
197486
|
return AttrValueOf.booleanAttr();
|
|
197304
197487
|
}
|
|
197305
|
-
if (
|
|
197488
|
+
if (import_typescript12.default.isStringLiteral(attr.initializer)) {
|
|
197306
197489
|
return AttrValueOf.literal(decodeEntities(attr.initializer.text));
|
|
197307
197490
|
}
|
|
197308
|
-
if (
|
|
197491
|
+
if (import_typescript12.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197309
197492
|
let expr = attr.initializer.expression;
|
|
197310
|
-
if (
|
|
197493
|
+
if (import_typescript12.default.isIdentifier(expr)) {
|
|
197311
197494
|
const branchInit = ctx._branchScopeVars?.get(expr.text);
|
|
197312
197495
|
if (branchInit && !initializerShapeContainsJsx(branchInit)) {
|
|
197313
197496
|
expr = branchInit;
|
|
197314
197497
|
}
|
|
197315
197498
|
}
|
|
197316
197499
|
expr = tryDesugarInterleaveTaggedTemplate(expr, ctx);
|
|
197317
|
-
if (
|
|
197500
|
+
if (import_typescript12.default.isAwaitExpression(expr)) {
|
|
197318
197501
|
ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(expr, ctx.sourceFile, ctx.filePath)));
|
|
197319
197502
|
return AttrValueOf.expression("undefined");
|
|
197320
197503
|
}
|
|
197321
197504
|
checkBareSignalOrMemoIdentifier(expr, ctx);
|
|
197322
|
-
if (attr.name.getText(ctx.sourceFile) === "style" &&
|
|
197505
|
+
if (attr.name.getText(ctx.sourceFile) === "style" && import_typescript12.default.isObjectLiteralExpression(expr)) {
|
|
197323
197506
|
const cssString = tryStaticStyleObjectToCss(expr);
|
|
197324
197507
|
if (cssString !== null) {
|
|
197325
197508
|
return AttrValueOf.literal(cssString);
|
|
197326
197509
|
}
|
|
197327
197510
|
}
|
|
197328
|
-
if (
|
|
197511
|
+
if (import_typescript12.default.isTemplateExpression(expr)) {
|
|
197329
197512
|
const parts = parseTemplateLiteral(expr, ctx);
|
|
197330
197513
|
if (parts.some((p) => p.type === "ternary" || p.type === "lookup")) {
|
|
197331
197514
|
return AttrValueOf.template(parts);
|
|
197332
197515
|
}
|
|
197333
197516
|
}
|
|
197334
|
-
if (
|
|
197517
|
+
if (import_typescript12.default.isElementAccessExpression(expr) && !import_typescript12.default.isStringLiteralLike(expr.argumentExpression) && !import_typescript12.default.isNumericLiteral(expr.argumentExpression)) {
|
|
197335
197518
|
const parts = tryResolveTemplateSpanFromConst(expr, ctx);
|
|
197336
197519
|
if (parts) {
|
|
197337
197520
|
return AttrValueOf.template(parts);
|
|
197338
197521
|
}
|
|
197339
197522
|
}
|
|
197340
|
-
if (
|
|
197523
|
+
if (import_typescript12.default.isIdentifier(expr)) {
|
|
197341
197524
|
const resolved = tryResolveIdentifierAsTemplateLiteral(expr, ctx);
|
|
197342
197525
|
if (resolved) {
|
|
197343
197526
|
return AttrValueOf.template(resolved);
|
|
197344
197527
|
}
|
|
197345
197528
|
}
|
|
197346
|
-
if (
|
|
197529
|
+
if (import_typescript12.default.isConditionalExpression(expr)) {
|
|
197347
197530
|
const ternary = parseTernary(expr, ctx);
|
|
197348
197531
|
if (ternary) {
|
|
197349
197532
|
return AttrValueOf.template([ternary]);
|
|
197350
197533
|
}
|
|
197351
197534
|
}
|
|
197352
|
-
if (
|
|
197353
|
-
if (
|
|
197535
|
+
if (import_typescript12.default.isBinaryExpression(expr) && expr.operatorToken.kind === import_typescript12.default.SyntaxKind.BarBarToken) {
|
|
197536
|
+
if (import_typescript12.default.isIdentifier(expr.right) && expr.right.text === "undefined") {
|
|
197354
197537
|
const baseExpr = ctx.getJS(expr.left);
|
|
197355
197538
|
return AttrValueOf.expression(baseExpr, { presenceOrUndefined: true });
|
|
197356
197539
|
}
|
|
@@ -197363,11 +197546,11 @@ function getAttributeValue(attr, ctx) {
|
|
|
197363
197546
|
function tryStaticStyleObjectToCss(expr) {
|
|
197364
197547
|
const parts = [];
|
|
197365
197548
|
for (const prop of expr.properties) {
|
|
197366
|
-
if (!
|
|
197549
|
+
if (!import_typescript12.default.isPropertyAssignment(prop))
|
|
197367
197550
|
return null;
|
|
197368
|
-
if (!
|
|
197551
|
+
if (!import_typescript12.default.isIdentifier(prop.name) && !import_typescript12.default.isStringLiteral(prop.name))
|
|
197369
197552
|
return null;
|
|
197370
|
-
if (!
|
|
197553
|
+
if (!import_typescript12.default.isStringLiteral(prop.initializer))
|
|
197371
197554
|
return null;
|
|
197372
197555
|
const key = cssKebabCase(prop.name.text);
|
|
197373
197556
|
parts.push(`${key}:${prop.initializer.text}`);
|
|
@@ -197380,7 +197563,7 @@ function parseTemplateLiteral(expr, ctx) {
|
|
|
197380
197563
|
parts.push({ type: "string", value: expr.head.text });
|
|
197381
197564
|
}
|
|
197382
197565
|
for (const span of expr.templateSpans) {
|
|
197383
|
-
if (
|
|
197566
|
+
if (import_typescript12.default.isConditionalExpression(span.expression)) {
|
|
197384
197567
|
const ternary = parseTernary(span.expression, ctx);
|
|
197385
197568
|
if (ternary) {
|
|
197386
197569
|
parts.push(ternary);
|
|
@@ -197406,8 +197589,8 @@ function parseTemplateLiteral(expr, ctx) {
|
|
|
197406
197589
|
return parts;
|
|
197407
197590
|
}
|
|
197408
197591
|
function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
197409
|
-
if (
|
|
197410
|
-
if (ctx.
|
|
197592
|
+
if (import_typescript12.default.isIdentifier(expr)) {
|
|
197593
|
+
if (ctx.scope.isBound(expr.text))
|
|
197411
197594
|
return null;
|
|
197412
197595
|
const constInfo = findLocalConst(expr.text, ctx.analyzer);
|
|
197413
197596
|
if (!constInfo)
|
|
@@ -197415,31 +197598,31 @@ function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
|
197415
197598
|
const ast = parseConstInitializer(constInfo);
|
|
197416
197599
|
if (!ast)
|
|
197417
197600
|
return null;
|
|
197418
|
-
if (
|
|
197601
|
+
if (import_typescript12.default.isStringLiteral(ast) || import_typescript12.default.isNoSubstitutionTemplateLiteral(ast)) {
|
|
197419
197602
|
return [{ type: "string", value: ast.text }];
|
|
197420
197603
|
}
|
|
197421
197604
|
return null;
|
|
197422
197605
|
}
|
|
197423
|
-
if (
|
|
197424
|
-
if (!
|
|
197606
|
+
if (import_typescript12.default.isElementAccessExpression(expr)) {
|
|
197607
|
+
if (!import_typescript12.default.isIdentifier(expr.expression))
|
|
197425
197608
|
return null;
|
|
197426
|
-
if (ctx.
|
|
197609
|
+
if (ctx.scope.isBound(expr.expression.text))
|
|
197427
197610
|
return null;
|
|
197428
197611
|
const constInfo = findLocalConst(expr.expression.text, ctx.analyzer);
|
|
197429
197612
|
if (!constInfo)
|
|
197430
197613
|
return null;
|
|
197431
197614
|
const ast = parseConstInitializer(constInfo);
|
|
197432
|
-
if (!ast || !
|
|
197615
|
+
if (!ast || !import_typescript12.default.isObjectLiteralExpression(ast))
|
|
197433
197616
|
return null;
|
|
197434
197617
|
const cases = {};
|
|
197435
197618
|
for (const prop of ast.properties) {
|
|
197436
|
-
if (!
|
|
197619
|
+
if (!import_typescript12.default.isPropertyAssignment(prop))
|
|
197437
197620
|
return null;
|
|
197438
|
-
const keyName = prop.name && (
|
|
197621
|
+
const keyName = prop.name && (import_typescript12.default.isStringLiteral(prop.name) || import_typescript12.default.isIdentifier(prop.name)) ? prop.name.text : null;
|
|
197439
197622
|
if (!keyName)
|
|
197440
197623
|
return null;
|
|
197441
197624
|
const value = prop.initializer;
|
|
197442
|
-
if (
|
|
197625
|
+
if (import_typescript12.default.isStringLiteral(value) || import_typescript12.default.isNoSubstitutionTemplateLiteral(value)) {
|
|
197443
197626
|
cases[keyName] = value.text;
|
|
197444
197627
|
} else {
|
|
197445
197628
|
return null;
|
|
@@ -197486,23 +197669,23 @@ function hasDynamicTagBinding(name, sourceFile) {
|
|
|
197486
197669
|
const visit2 = (node) => {
|
|
197487
197670
|
if (found)
|
|
197488
197671
|
return;
|
|
197489
|
-
if (
|
|
197672
|
+
if (import_typescript12.default.isVariableDeclaration(node) && import_typescript12.default.isIdentifier(node.name) && node.name.text === name && node.initializer) {
|
|
197490
197673
|
let init = node.initializer;
|
|
197491
|
-
while (
|
|
197674
|
+
while (import_typescript12.default.isAsExpression(init) || import_typescript12.default.isSatisfiesExpression(init) || import_typescript12.default.isParenthesizedExpression(init) || import_typescript12.default.isNonNullExpression(init)) {
|
|
197492
197675
|
init = init.expression;
|
|
197493
197676
|
}
|
|
197494
|
-
if (
|
|
197677
|
+
if (import_typescript12.default.isPropertyAccessExpression(init) && init.name.text === "tag") {
|
|
197495
197678
|
found = true;
|
|
197496
197679
|
return;
|
|
197497
197680
|
}
|
|
197498
197681
|
}
|
|
197499
|
-
|
|
197682
|
+
import_typescript12.default.forEachChild(node, visit2);
|
|
197500
197683
|
};
|
|
197501
197684
|
visit2(sourceFile);
|
|
197502
197685
|
return found;
|
|
197503
197686
|
}
|
|
197504
197687
|
function tryResolveIdentifierAsTemplateLiteral(ident, ctx) {
|
|
197505
|
-
if (ctx.
|
|
197688
|
+
if (ctx.scope.isBound(ident.text))
|
|
197506
197689
|
return null;
|
|
197507
197690
|
const constInfo = findLocalConst(ident.text, ctx.analyzer);
|
|
197508
197691
|
if (!constInfo)
|
|
@@ -197510,13 +197693,13 @@ function tryResolveIdentifierAsTemplateLiteral(ident, ctx) {
|
|
|
197510
197693
|
const ast = parseConstInitializer(constInfo);
|
|
197511
197694
|
if (!ast)
|
|
197512
197695
|
return null;
|
|
197513
|
-
if (
|
|
197696
|
+
if (import_typescript12.default.isNoSubstitutionTemplateLiteral(ast) || import_typescript12.default.isStringLiteral(ast)) {
|
|
197514
197697
|
return [{ type: "string", value: ast.text }];
|
|
197515
197698
|
}
|
|
197516
|
-
if (
|
|
197699
|
+
if (import_typescript12.default.isElementAccessExpression(ast) && !import_typescript12.default.isStringLiteralLike(ast.argumentExpression) && !import_typescript12.default.isNumericLiteral(ast.argumentExpression)) {
|
|
197517
197700
|
return tryResolveTemplateSpanFromConst(ast, ctx);
|
|
197518
197701
|
}
|
|
197519
|
-
if (!
|
|
197702
|
+
if (!import_typescript12.default.isTemplateExpression(ast))
|
|
197520
197703
|
return null;
|
|
197521
197704
|
let resolvedAny = false;
|
|
197522
197705
|
const parts = [];
|
|
@@ -197554,14 +197737,14 @@ function parseConstInitializerImpl(c) {
|
|
|
197554
197737
|
if (!c.value)
|
|
197555
197738
|
return null;
|
|
197556
197739
|
const wrapped = `const __bf_resolve__ = (${c.value})`;
|
|
197557
|
-
const sf =
|
|
197740
|
+
const sf = import_typescript12.default.createSourceFile("__bf_resolve.ts", wrapped, import_typescript12.default.ScriptTarget.Latest, true, import_typescript12.default.ScriptKind.TS);
|
|
197558
197741
|
const stmt = sf.statements[0];
|
|
197559
|
-
if (!stmt || !
|
|
197742
|
+
if (!stmt || !import_typescript12.default.isVariableStatement(stmt))
|
|
197560
197743
|
return null;
|
|
197561
197744
|
const decl = stmt.declarationList.declarations[0];
|
|
197562
197745
|
if (!decl?.initializer)
|
|
197563
197746
|
return null;
|
|
197564
|
-
return
|
|
197747
|
+
return import_typescript12.default.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
197565
197748
|
}
|
|
197566
197749
|
function astText(node) {
|
|
197567
197750
|
return node.getText(node.getSourceFile());
|
|
@@ -197581,9 +197764,9 @@ function parseFunctionInfoAsExprImpl(fn) {
|
|
|
197581
197764
|
const params = fn.typedParams !== undefined ? fn.typedParams : fn.params.map(formatParamWithType).join(", ");
|
|
197582
197765
|
const body = fn.typedBody ?? fn.body;
|
|
197583
197766
|
const wrapped = `const __bf_resolve_fn__ = function(${params}) ${body}`;
|
|
197584
|
-
const sf =
|
|
197767
|
+
const sf = import_typescript12.default.createSourceFile("__bf_resolve_fn.ts", wrapped, import_typescript12.default.ScriptTarget.Latest, true, import_typescript12.default.ScriptKind.TS);
|
|
197585
197768
|
const stmt = sf.statements[0];
|
|
197586
|
-
if (!stmt || !
|
|
197769
|
+
if (!stmt || !import_typescript12.default.isVariableStatement(stmt))
|
|
197587
197770
|
return null;
|
|
197588
197771
|
const decl = stmt.declarationList.declarations[0];
|
|
197589
197772
|
if (!decl?.initializer)
|
|
@@ -197591,9 +197774,9 @@ function parseFunctionInfoAsExprImpl(fn) {
|
|
|
197591
197774
|
return decl.initializer;
|
|
197592
197775
|
}
|
|
197593
197776
|
function tryDesugarInterleaveTaggedTemplate(expr, ctx) {
|
|
197594
|
-
if (!
|
|
197777
|
+
if (!import_typescript12.default.isTaggedTemplateExpression(expr))
|
|
197595
197778
|
return expr;
|
|
197596
|
-
if (!
|
|
197779
|
+
if (!import_typescript12.default.isIdentifier(expr.tag))
|
|
197597
197780
|
return expr;
|
|
197598
197781
|
const resolvedTag = resolveInterleaveTagIdentifier(expr.tag.text, ctx);
|
|
197599
197782
|
if (!resolvedTag)
|
|
@@ -197610,23 +197793,23 @@ function resolveInterleaveTagIdentifier(name, ctx) {
|
|
|
197610
197793
|
return null;
|
|
197611
197794
|
if (constInfo) {
|
|
197612
197795
|
const ast = parseConstInitializer(constInfo);
|
|
197613
|
-
return ast && (
|
|
197796
|
+
return ast && (import_typescript12.default.isArrowFunction(ast) || import_typescript12.default.isFunctionExpression(ast)) ? ast : null;
|
|
197614
197797
|
}
|
|
197615
197798
|
if (fnInfo) {
|
|
197616
197799
|
const ast = parseFunctionInfoAsExpr(fnInfo);
|
|
197617
|
-
return ast && (
|
|
197800
|
+
return ast && (import_typescript12.default.isArrowFunction(ast) || import_typescript12.default.isFunctionExpression(ast)) ? ast : null;
|
|
197618
197801
|
}
|
|
197619
197802
|
return null;
|
|
197620
197803
|
}
|
|
197621
197804
|
function isInterleaveTagFunction(fn) {
|
|
197622
|
-
if (!
|
|
197805
|
+
if (!import_typescript12.default.isArrowFunction(fn) && !import_typescript12.default.isFunctionExpression(fn))
|
|
197623
197806
|
return false;
|
|
197624
197807
|
if (fn.parameters.length !== 2)
|
|
197625
197808
|
return false;
|
|
197626
197809
|
const [partsParam, argsParam] = fn.parameters;
|
|
197627
|
-
if (!
|
|
197810
|
+
if (!import_typescript12.default.isIdentifier(partsParam.name) || partsParam.dotDotDotToken)
|
|
197628
197811
|
return false;
|
|
197629
|
-
if (!
|
|
197812
|
+
if (!import_typescript12.default.isIdentifier(argsParam.name) || !argsParam.dotDotDotToken)
|
|
197630
197813
|
return false;
|
|
197631
197814
|
const parsed = tsNodeToParsedExpr(fn);
|
|
197632
197815
|
if (parsed.kind !== "arrow")
|
|
@@ -197683,7 +197866,7 @@ function isInterleaveSpanExpr(expr, i2, argsName) {
|
|
|
197683
197866
|
function buildUntaggedTemplateLiteral(node, ctx) {
|
|
197684
197867
|
const template = node.template;
|
|
197685
197868
|
let text;
|
|
197686
|
-
if (
|
|
197869
|
+
if (import_typescript12.default.isNoSubstitutionTemplateLiteral(template)) {
|
|
197687
197870
|
text = "`" + (template.rawText ?? template.text) + "`";
|
|
197688
197871
|
} else {
|
|
197689
197872
|
let body = template.head.rawText ?? template.head.text;
|
|
@@ -197695,15 +197878,15 @@ function buildUntaggedTemplateLiteral(node, ctx) {
|
|
|
197695
197878
|
text = "`" + body + "`";
|
|
197696
197879
|
}
|
|
197697
197880
|
const wrapped = `const __bf_resolve_tagged__ = (${text})`;
|
|
197698
|
-
const sf =
|
|
197881
|
+
const sf = import_typescript12.default.createSourceFile("__bf_resolve_tagged.tsx", wrapped, import_typescript12.default.ScriptTarget.Latest, true, import_typescript12.default.ScriptKind.TSX);
|
|
197699
197882
|
const stmt = sf.statements[0];
|
|
197700
|
-
if (!stmt || !
|
|
197883
|
+
if (!stmt || !import_typescript12.default.isVariableStatement(stmt))
|
|
197701
197884
|
return null;
|
|
197702
197885
|
const decl = stmt.declarationList.declarations[0];
|
|
197703
197886
|
if (!decl?.initializer)
|
|
197704
197887
|
return null;
|
|
197705
|
-
const result =
|
|
197706
|
-
if (!
|
|
197888
|
+
const result = import_typescript12.default.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
197889
|
+
if (!import_typescript12.default.isTemplateExpression(result) && !import_typescript12.default.isNoSubstitutionTemplateLiteral(result))
|
|
197707
197890
|
return null;
|
|
197708
197891
|
return result;
|
|
197709
197892
|
}
|
|
@@ -197723,10 +197906,10 @@ function parseTernary(expr, ctx) {
|
|
|
197723
197906
|
return null;
|
|
197724
197907
|
}
|
|
197725
197908
|
function getStringValue(node) {
|
|
197726
|
-
if (
|
|
197909
|
+
if (import_typescript12.default.isStringLiteral(node)) {
|
|
197727
197910
|
return node.text;
|
|
197728
197911
|
}
|
|
197729
|
-
if (
|
|
197912
|
+
if (import_typescript12.default.isNoSubstitutionTemplateLiteral(node)) {
|
|
197730
197913
|
return node.text;
|
|
197731
197914
|
}
|
|
197732
197915
|
return null;
|
|
@@ -197734,19 +197917,19 @@ function getStringValue(node) {
|
|
|
197734
197917
|
function processComponentProps(attributes, ctx) {
|
|
197735
197918
|
const props = [];
|
|
197736
197919
|
for (const attr of attributes.properties) {
|
|
197737
|
-
if (
|
|
197920
|
+
if (import_typescript12.default.isJsxSpreadAttribute(attr)) {
|
|
197738
197921
|
props.push(...expandSpreadAttribute(attr, ctx));
|
|
197739
197922
|
continue;
|
|
197740
197923
|
}
|
|
197741
|
-
if (!
|
|
197924
|
+
if (!import_typescript12.default.isJsxAttribute(attr))
|
|
197742
197925
|
continue;
|
|
197743
197926
|
const name = attr.name.getText(ctx.sourceFile);
|
|
197744
|
-
if (attr.initializer &&
|
|
197927
|
+
if (attr.initializer && import_typescript12.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197745
197928
|
let jsxExpr = attr.initializer.expression;
|
|
197746
|
-
while (
|
|
197929
|
+
while (import_typescript12.default.isParenthesizedExpression(jsxExpr)) {
|
|
197747
197930
|
jsxExpr = jsxExpr.expression;
|
|
197748
197931
|
}
|
|
197749
|
-
if (
|
|
197932
|
+
if (import_typescript12.default.isJsxElement(jsxExpr) || import_typescript12.default.isJsxSelfClosingElement(jsxExpr) || import_typescript12.default.isJsxFragment(jsxExpr)) {
|
|
197750
197933
|
const prevInsideComponentChildren = ctx.insideComponentChildren;
|
|
197751
197934
|
ctx.insideComponentChildren = true;
|
|
197752
197935
|
const irNode = transformNode(jsxExpr, ctx);
|
|
@@ -197763,8 +197946,8 @@ function processComponentProps(attributes, ctx) {
|
|
|
197763
197946
|
}
|
|
197764
197947
|
let value = getAttributeValue(attr, ctx);
|
|
197765
197948
|
if (value.kind === "template") {
|
|
197766
|
-
const collapsed =
|
|
197767
|
-
const collapsedTemplate =
|
|
197949
|
+
const collapsed = templatePartsToJsExpr(value.parts);
|
|
197950
|
+
const collapsedTemplate = templatePartsToJsExpr(value.parts, { useTemplate: true });
|
|
197768
197951
|
value = AttrValueOf.expression(collapsed, {
|
|
197769
197952
|
parts: value.parts,
|
|
197770
197953
|
...collapsedTemplate !== collapsed && { templateExpr: collapsedTemplate }
|
|
@@ -197773,7 +197956,7 @@ function processComponentProps(attributes, ctx) {
|
|
|
197773
197956
|
value = AttrValueOf.booleanShorthand();
|
|
197774
197957
|
}
|
|
197775
197958
|
let clientOnly;
|
|
197776
|
-
if (attr.initializer &&
|
|
197959
|
+
if (attr.initializer && import_typescript12.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
197777
197960
|
if (value.kind === "expression" && value.templateExpr === undefined) {
|
|
197778
197961
|
const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
|
|
197779
197962
|
if (rewritten !== value.expr) {
|
|
@@ -197796,25 +197979,8 @@ function processComponentProps(attributes, ctx) {
|
|
|
197796
197979
|
}
|
|
197797
197980
|
return props;
|
|
197798
197981
|
}
|
|
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
197982
|
function checkBareSignalOrMemoIdentifier(expr, ctx) {
|
|
197817
|
-
if (!
|
|
197983
|
+
if (!import_typescript12.default.isIdentifier(expr))
|
|
197818
197984
|
return;
|
|
197819
197985
|
const name = expr.text;
|
|
197820
197986
|
for (const signal of ctx.analyzer.signals) {
|
|
@@ -197845,12 +198011,12 @@ function checkBareSignalOrMemoIdentifier(expr, ctx) {
|
|
|
197845
198011
|
function isArrayExprDirectPropRef(arrayExpr, ctx) {
|
|
197846
198012
|
const propNames = new Set(ctx.patterns.props.map((p) => p.name));
|
|
197847
198013
|
const propsObjName = ctx.analyzer.propsObjectName;
|
|
197848
|
-
if (
|
|
198014
|
+
if (import_typescript12.default.isIdentifier(arrayExpr)) {
|
|
197849
198015
|
return propNames.has(arrayExpr.text);
|
|
197850
198016
|
}
|
|
197851
|
-
if (
|
|
198017
|
+
if (import_typescript12.default.isPropertyAccessExpression(arrayExpr) && propsObjName) {
|
|
197852
198018
|
const obj = arrayExpr.expression;
|
|
197853
|
-
if (
|
|
198019
|
+
if (import_typescript12.default.isIdentifier(obj) && obj.text === propsObjName) {
|
|
197854
198020
|
return true;
|
|
197855
198021
|
}
|
|
197856
198022
|
}
|
|
@@ -197868,9 +198034,10 @@ function isSignalOrMemoArray(array, ctx) {
|
|
|
197868
198034
|
return false;
|
|
197869
198035
|
}
|
|
197870
198036
|
function referencesLoopParam(expr, ctx) {
|
|
197871
|
-
|
|
198037
|
+
const boundNames = ctx.scope.valueBoundNames();
|
|
198038
|
+
if (boundNames.size === 0)
|
|
197872
198039
|
return false;
|
|
197873
|
-
for (const p of
|
|
198040
|
+
for (const p of boundNames) {
|
|
197874
198041
|
if (new RegExp(`\\b${p}\\b`).test(expr))
|
|
197875
198042
|
return true;
|
|
197876
198043
|
}
|
|
@@ -197950,8 +198117,9 @@ function hasReactiveAttributes(attrs, ctx) {
|
|
|
197950
198117
|
if (isSignalOrMemoReference(valueToCheck, ctx) || isPropsReference(valueToCheck, ctx)) {
|
|
197951
198118
|
return true;
|
|
197952
198119
|
}
|
|
197953
|
-
|
|
197954
|
-
|
|
198120
|
+
const scopeValueNames = ctx.scope.valueBoundNames();
|
|
198121
|
+
if (scopeValueNames.size > 0) {
|
|
198122
|
+
for (const p of scopeValueNames) {
|
|
197955
198123
|
if (new RegExp(`\\b${p}\\b`).test(valueToCheck))
|
|
197956
198124
|
return true;
|
|
197957
198125
|
}
|
|
@@ -198043,7 +198211,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
|
|
|
198043
198211
|
jsxBranchLocalNames.add(n);
|
|
198044
198212
|
}
|
|
198045
198213
|
for (const decl of condReturn.scopeVariables) {
|
|
198046
|
-
if (
|
|
198214
|
+
if (import_typescript12.default.isIdentifier(decl.name) && decl.initializer) {
|
|
198047
198215
|
branchScopeVars.set(decl.name.text, decl.initializer);
|
|
198048
198216
|
if (initializerShapeContainsJsx(decl.initializer)) {
|
|
198049
198217
|
jsxBranchLocalNames.add(decl.name.text);
|
|
@@ -198110,7 +198278,7 @@ function buildIfStatementChain(analyzer, ctx, opts) {
|
|
|
198110
198278
|
}
|
|
198111
198279
|
const scopeVariables = [];
|
|
198112
198280
|
for (const decl of condReturn.scopeVariables) {
|
|
198113
|
-
if (
|
|
198281
|
+
if (import_typescript12.default.isIdentifier(decl.name) && decl.initializer) {
|
|
198114
198282
|
const init = ctx.getJS(decl.initializer);
|
|
198115
198283
|
const typedInit = decl.initializer.getText(ctx.sourceFile);
|
|
198116
198284
|
scopeVariables.push({
|
|
@@ -198248,13 +198416,13 @@ var KEYWORDS_AND_GLOBALS = new Set([
|
|
|
198248
198416
|
]);
|
|
198249
198417
|
|
|
198250
198418
|
// ../jsx/src/ir-to-client-js/walk-prop-accesses.ts
|
|
198251
|
-
var
|
|
198419
|
+
var import_typescript13 = __toESM(require_typescript(), 1);
|
|
198252
198420
|
|
|
198253
198421
|
// ../jsx/src/value-references.ts
|
|
198254
|
-
var
|
|
198422
|
+
var import_typescript14 = __toESM(require_typescript(), 1);
|
|
198255
198423
|
|
|
198256
198424
|
// ../jsx/src/relocate.ts
|
|
198257
|
-
var
|
|
198425
|
+
var import_typescript15 = __toESM(require_typescript(), 1);
|
|
198258
198426
|
|
|
198259
198427
|
// ../jsx/src/lowering-registry.ts
|
|
198260
198428
|
var plugins = [];
|
|
@@ -198433,10 +198601,10 @@ function formatDateLocalNames(metadata) {
|
|
|
198433
198601
|
}
|
|
198434
198602
|
|
|
198435
198603
|
// ../jsx/src/ir-to-client-js/prune-unused-prop-extractions.ts
|
|
198436
|
-
var
|
|
198604
|
+
var import_typescript16 = __toESM(require_typescript(), 1);
|
|
198437
198605
|
|
|
198438
198606
|
// ../jsx/src/ir-to-client-js/control-flow/plan/lazy-preamble.ts
|
|
198439
|
-
var
|
|
198607
|
+
var import_typescript17 = __toESM(require_typescript(), 1);
|
|
198440
198608
|
var NO_PREAMBLE = {
|
|
198441
198609
|
lazySafe: true,
|
|
198442
198610
|
facts: { declaredNames: new Set, freeNames: new Set }
|
|
@@ -198486,7 +198654,7 @@ var INERT_BINDING_GLOBALS = new Set([
|
|
|
198486
198654
|
]);
|
|
198487
198655
|
|
|
198488
198656
|
// ../jsx/src/ir-to-client-js/emit-reactive.ts
|
|
198489
|
-
var
|
|
198657
|
+
var import_typescript18 = __toESM(require_typescript(), 1);
|
|
198490
198658
|
|
|
198491
198659
|
// ../jsx/src/ir-to-client-js/control-flow/stringify/event-delegation.ts
|
|
198492
198660
|
var NON_BUBBLING_EVENTS = new Set([
|
|
@@ -198501,7 +198669,7 @@ var NON_BUBBLING_EVENTS = new Set([
|
|
|
198501
198669
|
]);
|
|
198502
198670
|
|
|
198503
198671
|
// ../jsx/src/ir-to-client-js/rewrite-props-object.ts
|
|
198504
|
-
var
|
|
198672
|
+
var import_typescript19 = __toESM(require_typescript(), 1);
|
|
198505
198673
|
|
|
198506
198674
|
// ../jsx/src/ir-to-client-js/source-map.ts
|
|
198507
198675
|
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -198592,21 +198760,21 @@ class SourceMapGenerator {
|
|
|
198592
198760
|
}
|
|
198593
198761
|
|
|
198594
198762
|
// ../jsx/src/preprocess-inline-jsx-callbacks.ts
|
|
198595
|
-
var
|
|
198763
|
+
var import_typescript20 = __toESM(require_typescript(), 1);
|
|
198596
198764
|
|
|
198597
198765
|
// ../jsx/src/ssr-defaults.ts
|
|
198598
|
-
var
|
|
198766
|
+
var import_typescript21 = __toESM(require_typescript(), 1);
|
|
198599
198767
|
var UNRESOLVED = Symbol("unresolved");
|
|
198600
198768
|
var NO_RETURN = Symbol("no-return");
|
|
198601
198769
|
|
|
198602
198770
|
// ../jsx/src/augment-inherited-props.ts
|
|
198603
|
-
var
|
|
198771
|
+
var import_typescript22 = __toESM(require_typescript(), 1);
|
|
198604
198772
|
|
|
198605
198773
|
// ../jsx/src/rich-type-refusal.ts
|
|
198606
198774
|
var EMPTY_BINDINGS2 = new Map;
|
|
198607
198775
|
// ../jsx/src/shared-program.ts
|
|
198608
198776
|
init_path();
|
|
198609
|
-
var
|
|
198777
|
+
var import_typescript24 = __toESM(require_typescript(), 1);
|
|
198610
198778
|
// ../jsx/src/adapters/interface.ts
|
|
198611
198779
|
class BaseAdapter {
|
|
198612
198780
|
renderChildren(children) {
|
|
@@ -198682,7 +198850,7 @@ class JsxAdapter extends BaseAdapter {
|
|
|
198682
198850
|
}
|
|
198683
198851
|
const rawInitialValue = preserveTypes ? signal.typedInitialValue ?? signal.initialValue : signal.initialValue;
|
|
198684
198852
|
const initialValue = rawInitialValue.trim().startsWith("{") ? `(${rawInitialValue})` : rawInitialValue;
|
|
198685
|
-
const needsTypeAssertion = preserveTypes && !signal.typedInitialValue && signal.type.kind !== "unknown" && signal.type.kind !== "primitive";
|
|
198853
|
+
const needsTypeAssertion = preserveTypes && !signal.typedInitialValue && signal.type.kind !== "unknown" && signal.type.kind !== "primitive" && signal.type.raw !== "object";
|
|
198686
198854
|
if (needsTypeAssertion) {
|
|
198687
198855
|
lines.push(` const ${signal.getter} = () => ${initialValue} as ${signal.type.raw}`);
|
|
198688
198856
|
} else {
|
|
@@ -198701,12 +198869,16 @@ class JsxAdapter extends BaseAdapter {
|
|
|
198701
198869
|
const computation = preserveTypes ? memo.typedComputation ?? memo.computation : memo.computation;
|
|
198702
198870
|
lines.push(` const ${memo.name} = ${computation}`);
|
|
198703
198871
|
}
|
|
198872
|
+
const moduleScopeNames = this.moduleScopeDeclarationNames(ir);
|
|
198704
198873
|
for (const constant of ir.metadata.localConstants) {
|
|
198705
198874
|
if (constant.isExported)
|
|
198706
198875
|
continue;
|
|
198876
|
+
if (moduleScopeNames.has(constant.name))
|
|
198877
|
+
continue;
|
|
198707
198878
|
const keyword = constant.declarationKind ?? "const";
|
|
198708
198879
|
if (!constant.value) {
|
|
198709
|
-
|
|
198880
|
+
const typeAnnotation = preserveTypes && (constant.typeAnnotation ?? constant.type) ? `: ${constant.typeAnnotation ?? constant.type?.raw}` : "";
|
|
198881
|
+
lines.push(` ${keyword} ${constant.name}${typeAnnotation}`);
|
|
198710
198882
|
continue;
|
|
198711
198883
|
}
|
|
198712
198884
|
const value = constant.value.trim();
|
|
@@ -198715,9 +198887,12 @@ class JsxAdapter extends BaseAdapter {
|
|
|
198715
198887
|
if (!reachable.has(constant.name))
|
|
198716
198888
|
continue;
|
|
198717
198889
|
const constValue = preserveTypes ? constant.typedValue ?? constant.value : constant.value;
|
|
198718
|
-
|
|
198890
|
+
const letTypeAnnotation = preserveTypes && keyword === "let" && constant.typeAnnotation ? `: ${constant.typeAnnotation}` : "";
|
|
198891
|
+
lines.push(` ${keyword} ${constant.name}${letTypeAnnotation} = ${constValue}`);
|
|
198719
198892
|
}
|
|
198720
198893
|
for (const func of localFunctions) {
|
|
198894
|
+
if (moduleScopeNames.has(func.name))
|
|
198895
|
+
continue;
|
|
198721
198896
|
if (!reachable.has(func.name))
|
|
198722
198897
|
continue;
|
|
198723
198898
|
const params = preserveTypes && func.typedParams !== undefined ? func.typedParams : func.params.map(formatParamWithType).join(", ");
|
|
@@ -198727,6 +198902,127 @@ class JsxAdapter extends BaseAdapter {
|
|
|
198727
198902
|
lines.push(` ${asyncKw}function ${func.name}(${params})${returnAnnotation} ${body}`);
|
|
198728
198903
|
}
|
|
198729
198904
|
return lines.join(`
|
|
198905
|
+
`);
|
|
198906
|
+
}
|
|
198907
|
+
moduleScopeNamesCache = new WeakMap;
|
|
198908
|
+
moduleScopeDeclarationNames(ir) {
|
|
198909
|
+
const cached = this.moduleScopeNamesCache.get(ir);
|
|
198910
|
+
if (cached)
|
|
198911
|
+
return cached;
|
|
198912
|
+
const componentScope = new Set;
|
|
198913
|
+
for (const sig of ir.metadata.signals) {
|
|
198914
|
+
if (sig.isModule)
|
|
198915
|
+
continue;
|
|
198916
|
+
componentScope.add(sig.getter);
|
|
198917
|
+
if (sig.setter)
|
|
198918
|
+
componentScope.add(sig.setter);
|
|
198919
|
+
}
|
|
198920
|
+
for (const memo of ir.metadata.memos) {
|
|
198921
|
+
if (!memo.isModule)
|
|
198922
|
+
componentScope.add(memo.name);
|
|
198923
|
+
}
|
|
198924
|
+
for (const p of ir.metadata.propsParams)
|
|
198925
|
+
componentScope.add(p.name);
|
|
198926
|
+
if (ir.metadata.propsObjectName)
|
|
198927
|
+
componentScope.add(ir.metadata.propsObjectName);
|
|
198928
|
+
if (ir.metadata.restPropsName)
|
|
198929
|
+
componentScope.add(ir.metadata.restPropsName);
|
|
198930
|
+
for (const c of ir.metadata.localConstants) {
|
|
198931
|
+
if (!c.isModule)
|
|
198932
|
+
componentScope.add(c.name);
|
|
198933
|
+
}
|
|
198934
|
+
for (const f of ir.metadata.localFunctions) {
|
|
198935
|
+
if (!f.isModule)
|
|
198936
|
+
componentScope.add(f.name);
|
|
198937
|
+
}
|
|
198938
|
+
const exported = new Set;
|
|
198939
|
+
const candidates = new Map;
|
|
198940
|
+
for (const c of ir.metadata.localConstants) {
|
|
198941
|
+
if (!c.isModule)
|
|
198942
|
+
continue;
|
|
198943
|
+
if (c.isJsx || c.isJsxFunction)
|
|
198944
|
+
continue;
|
|
198945
|
+
if (c.isExported) {
|
|
198946
|
+
exported.add(c.name);
|
|
198947
|
+
continue;
|
|
198948
|
+
}
|
|
198949
|
+
candidates.set(c.name, c.freeIdentifiers ?? extractFreeIdentifiersFromText(c.value ?? ""));
|
|
198950
|
+
}
|
|
198951
|
+
for (const f of ir.metadata.localFunctions) {
|
|
198952
|
+
if (!f.isModule)
|
|
198953
|
+
continue;
|
|
198954
|
+
if (f.isJsxFunction || f.isMultiReturnJsxHelper)
|
|
198955
|
+
continue;
|
|
198956
|
+
if (f.isExported) {
|
|
198957
|
+
exported.add(f.name);
|
|
198958
|
+
continue;
|
|
198959
|
+
}
|
|
198960
|
+
const params = f.typedParams !== undefined ? f.typedParams : f.params.map(formatParamWithType).join(", ");
|
|
198961
|
+
candidates.set(f.name, extractFreeIdentifiersFromText(`(${params}) => ${f.body}`));
|
|
198962
|
+
}
|
|
198963
|
+
const referencesAny = (refs, names) => {
|
|
198964
|
+
for (const ref of refs) {
|
|
198965
|
+
if (names.has(ref))
|
|
198966
|
+
return true;
|
|
198967
|
+
}
|
|
198968
|
+
return false;
|
|
198969
|
+
};
|
|
198970
|
+
let changed = true;
|
|
198971
|
+
while (changed) {
|
|
198972
|
+
changed = false;
|
|
198973
|
+
for (const [name, refs] of candidates) {
|
|
198974
|
+
if (referencesAny(refs, componentScope)) {
|
|
198975
|
+
candidates.delete(name);
|
|
198976
|
+
componentScope.add(name);
|
|
198977
|
+
changed = true;
|
|
198978
|
+
}
|
|
198979
|
+
}
|
|
198980
|
+
}
|
|
198981
|
+
const result = new Set([...exported, ...candidates.keys()]);
|
|
198982
|
+
this.moduleScopeNamesCache.set(ir, result);
|
|
198983
|
+
return result;
|
|
198984
|
+
}
|
|
198985
|
+
generateModuleScopeDeclarations(ir) {
|
|
198986
|
+
const { preserveTypes } = this.jsxConfig;
|
|
198987
|
+
const moduleNames = this.moduleScopeDeclarationNames(ir);
|
|
198988
|
+
const entries = [];
|
|
198989
|
+
for (const t of ir.metadata.typeDefinitions) {
|
|
198990
|
+
entries.push({ line: t.loc.start.line, text: t.definition });
|
|
198991
|
+
}
|
|
198992
|
+
for (const c of ir.metadata.localConstants) {
|
|
198993
|
+
if (!c.isModule || !moduleNames.has(c.name))
|
|
198994
|
+
continue;
|
|
198995
|
+
const keyword = c.declarationKind ?? "const";
|
|
198996
|
+
const exportKw = c.isExported ? "export " : "";
|
|
198997
|
+
if (!c.value) {
|
|
198998
|
+
const typeAnnotation = preserveTypes && (c.typeAnnotation ?? c.type) ? `: ${c.typeAnnotation ?? c.type?.raw}` : "";
|
|
198999
|
+
entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${typeAnnotation}` });
|
|
199000
|
+
continue;
|
|
199001
|
+
}
|
|
199002
|
+
const trimmed = c.value.trim();
|
|
199003
|
+
if (/^new WeakMap\b/.test(trimmed))
|
|
199004
|
+
continue;
|
|
199005
|
+
if (c.isExported && /^createContext\b/.test(trimmed))
|
|
199006
|
+
continue;
|
|
199007
|
+
const value = preserveTypes ? c.typedValue ?? c.value : c.value;
|
|
199008
|
+
const letTypeAnnotation = preserveTypes && keyword === "let" && c.typeAnnotation ? `: ${c.typeAnnotation}` : "";
|
|
199009
|
+
entries.push({ line: c.loc.start.line, text: `${exportKw}${keyword} ${c.name}${letTypeAnnotation} = ${value}` });
|
|
199010
|
+
}
|
|
199011
|
+
for (const f of ir.metadata.localFunctions) {
|
|
199012
|
+
if (!f.isModule || !moduleNames.has(f.name))
|
|
199013
|
+
continue;
|
|
199014
|
+
const params = preserveTypes && f.typedParams !== undefined ? f.typedParams : f.params.map(formatParamWithType).join(", ");
|
|
199015
|
+
const returnAnnotation = preserveTypes && f.typedReturnType ? `: ${f.typedReturnType}` : "";
|
|
199016
|
+
const body = preserveTypes ? f.typedBody ?? f.body : f.body;
|
|
199017
|
+
const asyncKw = f.isAsync ? "async " : "";
|
|
199018
|
+
const exportKw = f.isExported ? "export " : "";
|
|
199019
|
+
entries.push({
|
|
199020
|
+
line: f.loc.start.line,
|
|
199021
|
+
text: `${exportKw}${asyncKw}function ${f.name}(${params})${returnAnnotation} ${body}`
|
|
199022
|
+
});
|
|
199023
|
+
}
|
|
199024
|
+
entries.sort((a, b) => a.line - b.line);
|
|
199025
|
+
return entries.map((e) => e.text).join(`
|
|
198730
199026
|
`);
|
|
198731
199027
|
}
|
|
198732
199028
|
renderNodeRaw(node) {
|
|
@@ -198738,6 +199034,15 @@ class JsxAdapter extends BaseAdapter {
|
|
|
198738
199034
|
}
|
|
198739
199035
|
return this.renderNode(node);
|
|
198740
199036
|
}
|
|
199037
|
+
renderTemplatePartsAsJs(parts) {
|
|
199038
|
+
return templatePartsToJsExpr(parts, { typed: this.jsxConfig.preserveTypes });
|
|
199039
|
+
}
|
|
199040
|
+
expressionValueToJs(value) {
|
|
199041
|
+
if (this.jsxConfig.preserveTypes && value.parts && value.expr === templatePartsToJsExpr(value.parts)) {
|
|
199042
|
+
return this.renderTemplatePartsAsJs(value.parts);
|
|
199043
|
+
}
|
|
199044
|
+
return value.expr;
|
|
199045
|
+
}
|
|
198741
199046
|
renderScopeMarker(instanceIdExpr) {
|
|
198742
199047
|
return `${BF_SCOPE}={${instanceIdExpr}}`;
|
|
198743
199048
|
}
|
|
@@ -198805,6 +199110,7 @@ class TestAdapter extends JsxAdapter {
|
|
|
198805
199110
|
generate(ir) {
|
|
198806
199111
|
this.componentName = ir.metadata.componentName;
|
|
198807
199112
|
const imports = this.generateImports(ir);
|
|
199113
|
+
const moduleConstants = this.generateModuleScopeDeclarations(ir);
|
|
198808
199114
|
const types2 = this.generateTypes(ir);
|
|
198809
199115
|
const component = this.generateComponent(ir);
|
|
198810
199116
|
const defaultExport = ir.metadata.hasDefaultExport ? `
|
|
@@ -198813,9 +199119,11 @@ export default ${this.componentName}` : "";
|
|
|
198813
199119
|
imports,
|
|
198814
199120
|
types: types2 || "",
|
|
198815
199121
|
component,
|
|
198816
|
-
defaultExport
|
|
199122
|
+
defaultExport,
|
|
199123
|
+
moduleConstants,
|
|
199124
|
+
moduleConstantsIncludeExports: true
|
|
198817
199125
|
};
|
|
198818
|
-
const template = [imports, types2, component].filter(Boolean).join(`
|
|
199126
|
+
const template = [imports, moduleConstants, types2, component].filter(Boolean).join(`
|
|
198819
199127
|
|
|
198820
199128
|
`) + defaultExport;
|
|
198821
199129
|
return {
|
|
@@ -198846,9 +199154,6 @@ export default ${this.componentName}` : "";
|
|
|
198846
199154
|
}
|
|
198847
199155
|
generateTypes(ir) {
|
|
198848
199156
|
const lines = [];
|
|
198849
|
-
for (const typeDef of ir.metadata.typeDefinitions) {
|
|
198850
|
-
lines.push(typeDef.definition);
|
|
198851
|
-
}
|
|
198852
199157
|
const propsTypeName = ir.metadata.propsType?.raw;
|
|
198853
199158
|
if (propsTypeName && !ir.metadata.propsObjectName) {
|
|
198854
199159
|
lines.push("");
|
|
@@ -198871,7 +199176,7 @@ export default ${this.componentName}` : "";
|
|
|
198871
199176
|
const bodyRefText = [jsxBody, signalInits, scopeIdLine].join(`
|
|
198872
199177
|
`);
|
|
198873
199178
|
const bfScopeAlias = /\b__bfScope\b/.test(bodyRefText) ? "__bfScope" : "__bfScope: _bfScope";
|
|
198874
|
-
const propsParams = ir.metadata.propsParams.map((p) => p
|
|
199179
|
+
const propsParams = ir.metadata.propsParams.map((p) => propsDestructureBinding(p)).join(", ");
|
|
198875
199180
|
const restPropsName = ir.metadata.restPropsName;
|
|
198876
199181
|
const hydrationProps = `__instanceId, ${bfScopeAlias}`;
|
|
198877
199182
|
const parts = [];
|
|
@@ -199018,13 +199323,7 @@ export default ${this.componentName}` : "";
|
|
|
199018
199323
|
}
|
|
199019
199324
|
flattenTemplate(value) {
|
|
199020
199325
|
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("") + "`";
|
|
199326
|
+
return this.renderTemplatePartsAsJs(v.parts);
|
|
199028
199327
|
}
|
|
199029
199328
|
renderComponentProps(comp) {
|
|
199030
199329
|
const parts = [];
|
|
@@ -199145,9 +199444,9 @@ function registerBuiltinLoweringPlugins() {
|
|
|
199145
199444
|
registerLoweringPlugin(plugin);
|
|
199146
199445
|
}
|
|
199147
199446
|
// ../jsx/src/combine-client-js.ts
|
|
199148
|
-
var
|
|
199447
|
+
var import_typescript25 = __toESM(require_typescript(), 1);
|
|
199149
199448
|
// ../jsx/src/debug.ts
|
|
199150
|
-
var
|
|
199449
|
+
var import_typescript26 = __toESM(require_typescript(), 1);
|
|
199151
199450
|
function escapeForIdBoundary(name) {
|
|
199152
199451
|
return name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
199153
199452
|
}
|
|
@@ -199239,7 +199538,7 @@ function resolveSetters(handler, setterToSignal, fnSetters) {
|
|
|
199239
199538
|
return refs;
|
|
199240
199539
|
}
|
|
199241
199540
|
// ../jsx/src/profiler.ts
|
|
199242
|
-
var
|
|
199541
|
+
var import_typescript27 = __toESM(require_typescript(), 1);
|
|
199243
199542
|
|
|
199244
199543
|
// ../jsx/src/index.ts
|
|
199245
199544
|
registerBuiltinLoweringPlugins();
|