@barefootjs/test 0.1.3 → 0.3.0
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.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1022 -696
- package/dist/ir-to-test-node.d.ts +2 -2
- package/dist/ir-to-test-node.d.ts.map +1 -1
- package/dist/test-node.d.ts +11 -0
- package/dist/test-node.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/ir-to-test-node.ts +94 -33
- package/src/render.ts +2 -1
- package/src/test-node.ts +17 -0
package/dist/index.js
CHANGED
|
@@ -187288,10 +187288,10 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
187288
187288
|
});
|
|
187289
187289
|
|
|
187290
187290
|
// ../jsx/src/analyzer.ts
|
|
187291
|
-
var
|
|
187291
|
+
var import_typescript7 = __toESM(require_typescript(), 1);
|
|
187292
187292
|
|
|
187293
187293
|
// ../jsx/src/prop-rewrite.ts
|
|
187294
|
-
var
|
|
187294
|
+
var import_typescript4 = __toESM(require_typescript(), 1);
|
|
187295
187295
|
|
|
187296
187296
|
// ../jsx/src/ir-to-client-js/utils.ts
|
|
187297
187297
|
var import_typescript2 = __toESM(require_typescript(), 1);
|
|
@@ -187396,27 +187396,182 @@ function applyReplacement(slice, re, replacement) {
|
|
|
187396
187396
|
re.lastIndex = 0;
|
|
187397
187397
|
return typeof replacement === "string" ? slice.replace(re, replacement) : slice.replace(re, replacement);
|
|
187398
187398
|
}
|
|
187399
|
+
// ../shared/src/dom-prop.ts
|
|
187400
|
+
var BOOLEAN_ATTRS = new Set([
|
|
187401
|
+
"checked",
|
|
187402
|
+
"disabled",
|
|
187403
|
+
"readonly",
|
|
187404
|
+
"selected",
|
|
187405
|
+
"required",
|
|
187406
|
+
"hidden",
|
|
187407
|
+
"autofocus",
|
|
187408
|
+
"autoplay",
|
|
187409
|
+
"controls",
|
|
187410
|
+
"loop",
|
|
187411
|
+
"muted",
|
|
187412
|
+
"open",
|
|
187413
|
+
"multiple",
|
|
187414
|
+
"novalidate",
|
|
187415
|
+
"formnovalidate"
|
|
187416
|
+
]);
|
|
187417
|
+
var SVG_XML_CAMEL_ATTRS = new Set([
|
|
187418
|
+
"allowReorder",
|
|
187419
|
+
"attributeName",
|
|
187420
|
+
"attributeType",
|
|
187421
|
+
"autoReverse",
|
|
187422
|
+
"baseFrequency",
|
|
187423
|
+
"baseProfile",
|
|
187424
|
+
"calcMode",
|
|
187425
|
+
"clipPathUnits",
|
|
187426
|
+
"contentScriptType",
|
|
187427
|
+
"contentStyleType",
|
|
187428
|
+
"diffuseConstant",
|
|
187429
|
+
"edgeMode",
|
|
187430
|
+
"externalResourcesRequired",
|
|
187431
|
+
"filterRes",
|
|
187432
|
+
"filterUnits",
|
|
187433
|
+
"glyphRef",
|
|
187434
|
+
"gradientTransform",
|
|
187435
|
+
"gradientUnits",
|
|
187436
|
+
"kernelMatrix",
|
|
187437
|
+
"kernelUnitLength",
|
|
187438
|
+
"keyPoints",
|
|
187439
|
+
"keySplines",
|
|
187440
|
+
"keyTimes",
|
|
187441
|
+
"lengthAdjust",
|
|
187442
|
+
"limitingConeAngle",
|
|
187443
|
+
"markerHeight",
|
|
187444
|
+
"markerUnits",
|
|
187445
|
+
"markerWidth",
|
|
187446
|
+
"maskContentUnits",
|
|
187447
|
+
"maskUnits",
|
|
187448
|
+
"numOctaves",
|
|
187449
|
+
"pathLength",
|
|
187450
|
+
"patternContentUnits",
|
|
187451
|
+
"patternTransform",
|
|
187452
|
+
"patternUnits",
|
|
187453
|
+
"pointsAtX",
|
|
187454
|
+
"pointsAtY",
|
|
187455
|
+
"pointsAtZ",
|
|
187456
|
+
"preserveAlpha",
|
|
187457
|
+
"preserveAspectRatio",
|
|
187458
|
+
"primitiveUnits",
|
|
187459
|
+
"refX",
|
|
187460
|
+
"refY",
|
|
187461
|
+
"repeatCount",
|
|
187462
|
+
"repeatDur",
|
|
187463
|
+
"requiredExtensions",
|
|
187464
|
+
"requiredFeatures",
|
|
187465
|
+
"specularConstant",
|
|
187466
|
+
"specularExponent",
|
|
187467
|
+
"spreadMethod",
|
|
187468
|
+
"startOffset",
|
|
187469
|
+
"stdDeviation",
|
|
187470
|
+
"stitchTiles",
|
|
187471
|
+
"surfaceScale",
|
|
187472
|
+
"systemLanguage",
|
|
187473
|
+
"tableValues",
|
|
187474
|
+
"targetX",
|
|
187475
|
+
"targetY",
|
|
187476
|
+
"textLength",
|
|
187477
|
+
"viewBox",
|
|
187478
|
+
"viewTarget",
|
|
187479
|
+
"xChannelSelector",
|
|
187480
|
+
"yChannelSelector",
|
|
187481
|
+
"zoomAndPan"
|
|
187482
|
+
]);
|
|
187399
187483
|
// ../jsx/src/ir-to-client-js/utils.ts
|
|
187400
187484
|
var PROPS_PARAM = "_p";
|
|
187485
|
+
// ../jsx/src/ir-to-client-js/csr-substitute.ts
|
|
187486
|
+
var import_typescript3 = __toESM(require_typescript(), 1);
|
|
187487
|
+
|
|
187488
|
+
// ../jsx/src/ir-to-client-js/html-template.ts
|
|
187489
|
+
function splitTemplateInterpolations(inner) {
|
|
187490
|
+
const parts = [];
|
|
187491
|
+
let i2 = 0;
|
|
187492
|
+
let segStart = 0;
|
|
187493
|
+
while (i2 < inner.length) {
|
|
187494
|
+
if (inner[i2] === "$" && inner[i2 + 1] === "{") {
|
|
187495
|
+
if (i2 > segStart)
|
|
187496
|
+
parts.push(inner.slice(segStart, i2));
|
|
187497
|
+
let depth = 1;
|
|
187498
|
+
let j = i2 + 2;
|
|
187499
|
+
while (j < inner.length && depth > 0) {
|
|
187500
|
+
if (inner[j] === "{")
|
|
187501
|
+
depth++;
|
|
187502
|
+
else if (inner[j] === "}")
|
|
187503
|
+
depth--;
|
|
187504
|
+
if (depth > 0)
|
|
187505
|
+
j++;
|
|
187506
|
+
}
|
|
187507
|
+
j++;
|
|
187508
|
+
parts.push(inner.slice(i2, j));
|
|
187509
|
+
i2 = j;
|
|
187510
|
+
segStart = j;
|
|
187511
|
+
} else {
|
|
187512
|
+
i2++;
|
|
187513
|
+
}
|
|
187514
|
+
}
|
|
187515
|
+
if (segStart < inner.length)
|
|
187516
|
+
parts.push(inner.slice(segStart));
|
|
187517
|
+
return parts;
|
|
187518
|
+
}
|
|
187519
|
+
function createTemplateAwareStringProtector() {
|
|
187520
|
+
const stash = [];
|
|
187521
|
+
const save = (s) => {
|
|
187522
|
+
const i2 = stash.length;
|
|
187523
|
+
stash.push(s);
|
|
187524
|
+
return `__STRLIT_${i2}__`;
|
|
187525
|
+
};
|
|
187526
|
+
const protect = (s) => {
|
|
187527
|
+
s = s.replace(/`([^`]*)`/g, (_full, inner) => {
|
|
187528
|
+
const parts = splitTemplateInterpolations(inner);
|
|
187529
|
+
return "`" + parts.map((p) => p.startsWith("${") ? p : save(p)).join("") + "`";
|
|
187530
|
+
});
|
|
187531
|
+
s = s.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g, (m) => save(m));
|
|
187532
|
+
return s;
|
|
187533
|
+
};
|
|
187534
|
+
const restore = (s) => {
|
|
187535
|
+
return s.replace(/__STRLIT_(\d+)__/g, (_, i2) => stash[Number(i2)]);
|
|
187536
|
+
};
|
|
187537
|
+
return { protect, restore };
|
|
187538
|
+
}
|
|
187539
|
+
var VOID_ELEMENTS = new Set([
|
|
187540
|
+
"area",
|
|
187541
|
+
"base",
|
|
187542
|
+
"br",
|
|
187543
|
+
"col",
|
|
187544
|
+
"embed",
|
|
187545
|
+
"hr",
|
|
187546
|
+
"img",
|
|
187547
|
+
"input",
|
|
187548
|
+
"link",
|
|
187549
|
+
"meta",
|
|
187550
|
+
"param",
|
|
187551
|
+
"source",
|
|
187552
|
+
"track",
|
|
187553
|
+
"wbr"
|
|
187554
|
+
]);
|
|
187401
187555
|
|
|
187402
187556
|
// ../jsx/src/prop-rewrite.ts
|
|
187403
187557
|
function collectAstPropRefs(node, propNames, out) {
|
|
187404
187558
|
function visit(n, parent) {
|
|
187405
|
-
if (
|
|
187406
|
-
if (parent &&
|
|
187559
|
+
if (import_typescript4.default.isIdentifier(n) && propNames.has(n.text)) {
|
|
187560
|
+
if (parent && import_typescript4.default.isPropertyAssignment(parent) && parent.name === n)
|
|
187407
187561
|
return;
|
|
187408
|
-
if (parent &&
|
|
187562
|
+
if (parent && import_typescript4.default.isShorthandPropertyAssignment(parent) && parent.name === n)
|
|
187409
187563
|
return;
|
|
187410
|
-
if (parent &&
|
|
187564
|
+
if (parent && import_typescript4.default.isPropertyAccessExpression(parent) && parent.name === n)
|
|
187411
187565
|
return;
|
|
187412
187566
|
out.add(n.text);
|
|
187413
187567
|
}
|
|
187414
|
-
|
|
187568
|
+
import_typescript4.default.forEachChild(n, (child) => visit(child, n));
|
|
187415
187569
|
}
|
|
187416
187570
|
visit(node);
|
|
187417
187571
|
}
|
|
187418
187572
|
function applyRegexPropRefRewrite(text, propRefs) {
|
|
187419
|
-
|
|
187573
|
+
const { protect, restore } = createTemplateAwareStringProtector();
|
|
187574
|
+
let result = protect(text);
|
|
187420
187575
|
for (const propName of propRefs) {
|
|
187421
187576
|
const pattern = new RegExp(`(?<!${PROPS_PARAM}\\.)(?<!['"\\w.-])\\b${propName}\\b(?![a-zA-Z0-9_$])`, "g");
|
|
187422
187577
|
result = result.replace(pattern, (match, offset, str) => {
|
|
@@ -187429,7 +187584,7 @@ function applyRegexPropRefRewrite(text, propRefs) {
|
|
|
187429
187584
|
return `${PROPS_PARAM}.${propName}`;
|
|
187430
187585
|
});
|
|
187431
187586
|
}
|
|
187432
|
-
return result;
|
|
187587
|
+
return restore(result);
|
|
187433
187588
|
}
|
|
187434
187589
|
function rewriteBarePropRefs(text, node, propNames, extraPropRefs) {
|
|
187435
187590
|
const foundPropRefs = new Set;
|
|
@@ -187463,10 +187618,10 @@ function incrementCounter(key) {
|
|
|
187463
187618
|
}
|
|
187464
187619
|
|
|
187465
187620
|
// ../jsx/src/analyzer-context.ts
|
|
187466
|
-
var
|
|
187621
|
+
var import_typescript6 = __toESM(require_typescript(), 1);
|
|
187467
187622
|
|
|
187468
187623
|
// ../jsx/src/strip-types.ts
|
|
187469
|
-
var
|
|
187624
|
+
var import_typescript5 = __toESM(require_typescript(), 1);
|
|
187470
187625
|
function collectAllTypeRanges(sourceFile) {
|
|
187471
187626
|
const ranges = [];
|
|
187472
187627
|
collectTypeRanges(sourceFile, sourceFile, sourceFile.text, ranges);
|
|
@@ -187518,7 +187673,7 @@ function mergeRanges(ranges) {
|
|
|
187518
187673
|
return merged;
|
|
187519
187674
|
}
|
|
187520
187675
|
function collectTypeRanges(node, sourceFile, fullText, ranges) {
|
|
187521
|
-
if (
|
|
187676
|
+
if (import_typescript5.default.isParameter(node)) {
|
|
187522
187677
|
const hasQuestion = !!node.questionToken;
|
|
187523
187678
|
const hasType = !!node.type;
|
|
187524
187679
|
if (hasQuestion && hasType) {
|
|
@@ -187532,72 +187687,72 @@ function collectTypeRanges(node, sourceFile, fullText, ranges) {
|
|
|
187532
187687
|
}
|
|
187533
187688
|
}
|
|
187534
187689
|
}
|
|
187535
|
-
if (
|
|
187690
|
+
if (import_typescript5.default.isVariableDeclaration(node) && node.type) {
|
|
187536
187691
|
const colonPos = findColonBefore(node.type, fullText, node.name.getEnd());
|
|
187537
187692
|
if (colonPos >= 0) {
|
|
187538
187693
|
ranges.push({ start: colonPos, end: node.type.getEnd() });
|
|
187539
187694
|
}
|
|
187540
187695
|
}
|
|
187541
|
-
if (
|
|
187696
|
+
if (import_typescript5.default.isArrowFunction(node) && node.type) {
|
|
187542
187697
|
const colonPos = findColonBefore(node.type, fullText, node.parameters.end);
|
|
187543
187698
|
if (colonPos >= 0) {
|
|
187544
187699
|
ranges.push({ start: colonPos, end: node.type.getEnd() });
|
|
187545
187700
|
}
|
|
187546
187701
|
}
|
|
187547
|
-
if ((
|
|
187702
|
+
if ((import_typescript5.default.isFunctionDeclaration(node) || import_typescript5.default.isFunctionExpression(node)) && node.type) {
|
|
187548
187703
|
const colonPos = findColonBefore(node.type, fullText, node.parameters.end);
|
|
187549
187704
|
if (colonPos >= 0) {
|
|
187550
187705
|
ranges.push({ start: colonPos, end: node.type.getEnd() });
|
|
187551
187706
|
}
|
|
187552
187707
|
}
|
|
187553
|
-
if (
|
|
187708
|
+
if (import_typescript5.default.isAsExpression(node)) {
|
|
187554
187709
|
const exprEnd = node.expression.getEnd();
|
|
187555
187710
|
ranges.push({ start: exprEnd, end: node.getEnd() });
|
|
187556
187711
|
collectTypeRanges(node.expression, sourceFile, fullText, ranges);
|
|
187557
187712
|
return;
|
|
187558
187713
|
}
|
|
187559
|
-
if (
|
|
187714
|
+
if (import_typescript5.default.isSatisfiesExpression(node)) {
|
|
187560
187715
|
const exprEnd = node.expression.getEnd();
|
|
187561
187716
|
ranges.push({ start: exprEnd, end: node.getEnd() });
|
|
187562
187717
|
collectTypeRanges(node.expression, sourceFile, fullText, ranges);
|
|
187563
187718
|
return;
|
|
187564
187719
|
}
|
|
187565
|
-
if (
|
|
187720
|
+
if (import_typescript5.default.isNonNullExpression(node)) {
|
|
187566
187721
|
const exprEnd = node.expression.getEnd();
|
|
187567
187722
|
ranges.push({ start: exprEnd, end: node.getEnd() });
|
|
187568
187723
|
collectTypeRanges(node.expression, sourceFile, fullText, ranges);
|
|
187569
187724
|
return;
|
|
187570
187725
|
}
|
|
187571
|
-
if (
|
|
187726
|
+
if (import_typescript5.default.isTypeAssertionExpression(node)) {
|
|
187572
187727
|
const exprStart = node.expression.getStart(sourceFile);
|
|
187573
187728
|
ranges.push({ start: node.getStart(sourceFile), end: exprStart });
|
|
187574
187729
|
collectTypeRanges(node.expression, sourceFile, fullText, ranges);
|
|
187575
187730
|
return;
|
|
187576
187731
|
}
|
|
187577
|
-
if (
|
|
187732
|
+
if (import_typescript5.default.isCallExpression(node) && node.typeArguments) {
|
|
187578
187733
|
const typeArgsStart = findAngleBracketBefore(node.typeArguments[0], fullText, node.expression.getEnd());
|
|
187579
187734
|
const typeArgsEnd = findAngleBracketAfter(node.typeArguments[node.typeArguments.length - 1], fullText);
|
|
187580
187735
|
if (typeArgsStart >= 0 && typeArgsEnd >= 0) {
|
|
187581
187736
|
ranges.push({ start: typeArgsStart, end: typeArgsEnd });
|
|
187582
187737
|
}
|
|
187583
187738
|
}
|
|
187584
|
-
if (
|
|
187739
|
+
if (import_typescript5.default.isNewExpression(node) && node.typeArguments) {
|
|
187585
187740
|
const typeArgsStart = findAngleBracketBefore(node.typeArguments[0], fullText, node.expression.getEnd());
|
|
187586
187741
|
const typeArgsEnd = findAngleBracketAfter(node.typeArguments[node.typeArguments.length - 1], fullText);
|
|
187587
187742
|
if (typeArgsStart >= 0 && typeArgsEnd >= 0) {
|
|
187588
187743
|
ranges.push({ start: typeArgsStart, end: typeArgsEnd });
|
|
187589
187744
|
}
|
|
187590
187745
|
}
|
|
187591
|
-
if (
|
|
187746
|
+
if (import_typescript5.default.isTypeAliasDeclaration(node) || import_typescript5.default.isInterfaceDeclaration(node)) {
|
|
187592
187747
|
ranges.push({
|
|
187593
187748
|
start: expandToLineStart(node.getStart(sourceFile), fullText),
|
|
187594
187749
|
end: expandThroughLineEnd(node.getEnd(), fullText)
|
|
187595
187750
|
});
|
|
187596
187751
|
return;
|
|
187597
187752
|
}
|
|
187598
|
-
if (
|
|
187753
|
+
if (import_typescript5.default.isTypeNode(node))
|
|
187599
187754
|
return;
|
|
187600
|
-
|
|
187755
|
+
import_typescript5.default.forEachChild(node, (child) => {
|
|
187601
187756
|
collectTypeRanges(child, sourceFile, fullText, ranges);
|
|
187602
187757
|
});
|
|
187603
187758
|
}
|
|
@@ -187712,18 +187867,18 @@ function typeNodeToTypeInfo(typeNode, sourceFile) {
|
|
|
187712
187867
|
return null;
|
|
187713
187868
|
const raw = typeNode.getText(sourceFile);
|
|
187714
187869
|
switch (typeNode.kind) {
|
|
187715
|
-
case
|
|
187870
|
+
case import_typescript6.default.SyntaxKind.StringKeyword:
|
|
187716
187871
|
return { kind: "primitive", raw, primitive: "string" };
|
|
187717
|
-
case
|
|
187872
|
+
case import_typescript6.default.SyntaxKind.NumberKeyword:
|
|
187718
187873
|
return { kind: "primitive", raw, primitive: "number" };
|
|
187719
|
-
case
|
|
187874
|
+
case import_typescript6.default.SyntaxKind.BooleanKeyword:
|
|
187720
187875
|
return { kind: "primitive", raw, primitive: "boolean" };
|
|
187721
|
-
case
|
|
187876
|
+
case import_typescript6.default.SyntaxKind.NullKeyword:
|
|
187722
187877
|
return { kind: "primitive", raw, primitive: "null" };
|
|
187723
|
-
case
|
|
187878
|
+
case import_typescript6.default.SyntaxKind.UndefinedKeyword:
|
|
187724
187879
|
return { kind: "primitive", raw, primitive: "undefined" };
|
|
187725
187880
|
}
|
|
187726
|
-
if (
|
|
187881
|
+
if (import_typescript6.default.isArrayTypeNode(typeNode)) {
|
|
187727
187882
|
return {
|
|
187728
187883
|
kind: "array",
|
|
187729
187884
|
raw,
|
|
@@ -187733,35 +187888,35 @@ function typeNodeToTypeInfo(typeNode, sourceFile) {
|
|
|
187733
187888
|
}
|
|
187734
187889
|
};
|
|
187735
187890
|
}
|
|
187736
|
-
if (
|
|
187891
|
+
if (import_typescript6.default.isUnionTypeNode(typeNode)) {
|
|
187737
187892
|
return {
|
|
187738
187893
|
kind: "union",
|
|
187739
187894
|
raw,
|
|
187740
187895
|
unionTypes: typeNode.types.map((t) => typeNodeToTypeInfo(t, sourceFile) ?? { kind: "unknown", raw: "unknown" })
|
|
187741
187896
|
};
|
|
187742
187897
|
}
|
|
187743
|
-
if (
|
|
187898
|
+
if (import_typescript6.default.isTypeLiteralNode(typeNode)) {
|
|
187744
187899
|
return {
|
|
187745
187900
|
kind: "object",
|
|
187746
187901
|
raw,
|
|
187747
|
-
properties: typeNode.members.filter(
|
|
187902
|
+
properties: typeNode.members.filter(import_typescript6.default.isPropertySignature).map((member) => ({
|
|
187748
187903
|
name: member.name?.getText(sourceFile) ?? "",
|
|
187749
187904
|
type: typeNodeToTypeInfo(member.type, sourceFile) ?? {
|
|
187750
187905
|
kind: "unknown",
|
|
187751
187906
|
raw: "unknown"
|
|
187752
187907
|
},
|
|
187753
187908
|
optional: !!member.questionToken,
|
|
187754
|
-
readonly: !!member.modifiers?.some((m) => m.kind ===
|
|
187909
|
+
readonly: !!member.modifiers?.some((m) => m.kind === import_typescript6.default.SyntaxKind.ReadonlyKeyword)
|
|
187755
187910
|
}))
|
|
187756
187911
|
};
|
|
187757
187912
|
}
|
|
187758
|
-
if (
|
|
187913
|
+
if (import_typescript6.default.isTypeReferenceNode(typeNode)) {
|
|
187759
187914
|
return {
|
|
187760
187915
|
kind: "interface",
|
|
187761
187916
|
raw
|
|
187762
187917
|
};
|
|
187763
187918
|
}
|
|
187764
|
-
if (
|
|
187919
|
+
if (import_typescript6.default.isFunctionTypeNode(typeNode)) {
|
|
187765
187920
|
return {
|
|
187766
187921
|
kind: "function",
|
|
187767
187922
|
raw,
|
|
@@ -187783,16 +187938,16 @@ function isPascalCase(name) {
|
|
|
187783
187938
|
return /^[A-Z][a-zA-Z0-9]*$/.test(name);
|
|
187784
187939
|
}
|
|
187785
187940
|
function isComponentFunction(node) {
|
|
187786
|
-
return
|
|
187941
|
+
return import_typescript6.default.isFunctionDeclaration(node) && !!node.name && isPascalCase(node.name.text) && !!node.body;
|
|
187787
187942
|
}
|
|
187788
187943
|
function isArrowComponentFunction(node) {
|
|
187789
|
-
if (!
|
|
187944
|
+
if (!import_typescript6.default.isVariableDeclaration(node))
|
|
187790
187945
|
return false;
|
|
187791
|
-
if (!
|
|
187946
|
+
if (!import_typescript6.default.isIdentifier(node.name))
|
|
187792
187947
|
return false;
|
|
187793
187948
|
if (!isPascalCase(node.name.text))
|
|
187794
187949
|
return false;
|
|
187795
|
-
if (!node.initializer || !
|
|
187950
|
+
if (!node.initializer || !import_typescript6.default.isArrowFunction(node.initializer))
|
|
187796
187951
|
return false;
|
|
187797
187952
|
return true;
|
|
187798
187953
|
}
|
|
@@ -187887,9 +188042,9 @@ function needsTypeBasedDetection(source) {
|
|
|
187887
188042
|
}
|
|
187888
188043
|
function findBrandPackageImportLoc(sourceFile, filePath) {
|
|
187889
188044
|
for (const stmt of sourceFile.statements) {
|
|
187890
|
-
if (!
|
|
188045
|
+
if (!import_typescript7.default.isImportDeclaration(stmt))
|
|
187891
188046
|
continue;
|
|
187892
|
-
if (!
|
|
188047
|
+
if (!import_typescript7.default.isStringLiteral(stmt.moduleSpecifier))
|
|
187893
188048
|
continue;
|
|
187894
188049
|
if (!REACTIVE_BRAND_PACKAGES.includes(stmt.moduleSpecifier.text))
|
|
187895
188050
|
continue;
|
|
@@ -187908,21 +188063,21 @@ function createProgramForFile(source, filePath) {
|
|
|
187908
188063
|
try {
|
|
187909
188064
|
const normalizedPath = path_default.resolve(filePath);
|
|
187910
188065
|
const compilerOptions = {
|
|
187911
|
-
target:
|
|
187912
|
-
module:
|
|
187913
|
-
moduleResolution:
|
|
187914
|
-
jsx:
|
|
188066
|
+
target: import_typescript7.default.ScriptTarget.Latest,
|
|
188067
|
+
module: import_typescript7.default.ModuleKind.ESNext,
|
|
188068
|
+
moduleResolution: import_typescript7.default.ModuleResolutionKind.Bundler,
|
|
188069
|
+
jsx: import_typescript7.default.JsxEmit.ReactJSX,
|
|
187915
188070
|
strict: true,
|
|
187916
188071
|
skipLibCheck: true,
|
|
187917
188072
|
noEmit: true,
|
|
187918
188073
|
baseUrl: path_default.dirname(normalizedPath)
|
|
187919
188074
|
};
|
|
187920
|
-
const defaultHost =
|
|
188075
|
+
const defaultHost = import_typescript7.default.createCompilerHost(compilerOptions);
|
|
187921
188076
|
const virtualHost = {
|
|
187922
188077
|
...defaultHost,
|
|
187923
188078
|
getSourceFile(fileName, languageVersion) {
|
|
187924
188079
|
if (path_default.resolve(fileName) === normalizedPath) {
|
|
187925
|
-
return
|
|
188080
|
+
return import_typescript7.default.createSourceFile(fileName, source, languageVersion, true, import_typescript7.default.ScriptKind.TSX);
|
|
187926
188081
|
}
|
|
187927
188082
|
return defaultHost.getSourceFile(fileName, languageVersion);
|
|
187928
188083
|
},
|
|
@@ -187937,7 +188092,7 @@ function createProgramForFile(source, filePath) {
|
|
|
187937
188092
|
return defaultHost.readFile(fileName);
|
|
187938
188093
|
}
|
|
187939
188094
|
};
|
|
187940
|
-
const program =
|
|
188095
|
+
const program = import_typescript7.default.createProgram([normalizedPath], compilerOptions, virtualHost);
|
|
187941
188096
|
const sourceFile = program.getSourceFile(normalizedPath);
|
|
187942
188097
|
if (!sourceFile)
|
|
187943
188098
|
return null;
|
|
@@ -187970,7 +188125,7 @@ function analyzeComponent(source, filePath, targetComponentName, program) {
|
|
|
187970
188125
|
}
|
|
187971
188126
|
}
|
|
187972
188127
|
if (!sourceFile) {
|
|
187973
|
-
sourceFile =
|
|
188128
|
+
sourceFile = import_typescript7.default.createSourceFile(filePath, source, import_typescript7.default.ScriptTarget.Latest, true, import_typescript7.default.ScriptKind.TSX);
|
|
187974
188129
|
}
|
|
187975
188130
|
if (!checker && needsTypeBasedDetection(source)) {
|
|
187976
188131
|
const result = createProgramForFile(source, filePath);
|
|
@@ -187997,23 +188152,23 @@ function analyzeComponent(source, filePath, targetComponentName, program) {
|
|
|
187997
188152
|
function findDefaultExportedComponent(sourceFile) {
|
|
187998
188153
|
let defaultExportName;
|
|
187999
188154
|
function findDefaultExport(node) {
|
|
188000
|
-
if (
|
|
188001
|
-
if (
|
|
188155
|
+
if (import_typescript7.default.isExportAssignment(node) && !node.isExportEquals) {
|
|
188156
|
+
if (import_typescript7.default.isIdentifier(node.expression)) {
|
|
188002
188157
|
defaultExportName = node.expression.text;
|
|
188003
188158
|
}
|
|
188004
188159
|
}
|
|
188005
|
-
if (
|
|
188160
|
+
if (import_typescript7.default.isFunctionDeclaration(node) && node.name && node.modifiers?.some((m) => m.kind === import_typescript7.default.SyntaxKind.DefaultKeyword)) {
|
|
188006
188161
|
defaultExportName = node.name.text;
|
|
188007
188162
|
}
|
|
188008
|
-
|
|
188163
|
+
import_typescript7.default.forEachChild(node, findDefaultExport);
|
|
188009
188164
|
}
|
|
188010
|
-
|
|
188165
|
+
import_typescript7.default.forEachChild(sourceFile, findDefaultExport);
|
|
188011
188166
|
return defaultExportName;
|
|
188012
188167
|
}
|
|
188013
188168
|
function collectNamedExports(sourceFile) {
|
|
188014
188169
|
const exported = new Set;
|
|
188015
188170
|
for (const stmt of sourceFile.statements) {
|
|
188016
|
-
if (
|
|
188171
|
+
if (import_typescript7.default.isExportDeclaration(stmt) && stmt.exportClause && import_typescript7.default.isNamedExports(stmt.exportClause)) {
|
|
188017
188172
|
for (const spec of stmt.exportClause.elements) {
|
|
188018
188173
|
const local = (spec.propertyName ?? spec.name).text;
|
|
188019
188174
|
exported.add(local);
|
|
@@ -188023,22 +188178,22 @@ function collectNamedExports(sourceFile) {
|
|
|
188023
188178
|
return exported;
|
|
188024
188179
|
}
|
|
188025
188180
|
function visit(node, ctx, targetComponentName, namedExports) {
|
|
188026
|
-
if (
|
|
188181
|
+
if (import_typescript7.default.isExpressionStatement(node) && import_typescript7.default.isStringLiteral(node.expression)) {
|
|
188027
188182
|
if (node.expression.text === "use client" || node.expression.text === "'use client'") {
|
|
188028
188183
|
ctx.hasUseClientDirective = true;
|
|
188029
188184
|
}
|
|
188030
188185
|
}
|
|
188031
|
-
if (
|
|
188186
|
+
if (import_typescript7.default.isImportDeclaration(node)) {
|
|
188032
188187
|
collectImport(node, ctx);
|
|
188033
188188
|
}
|
|
188034
|
-
if (
|
|
188189
|
+
if (import_typescript7.default.isInterfaceDeclaration(node)) {
|
|
188035
188190
|
collectInterfaceDefinition(node, ctx);
|
|
188036
188191
|
}
|
|
188037
|
-
if (
|
|
188192
|
+
if (import_typescript7.default.isTypeAliasDeclaration(node)) {
|
|
188038
188193
|
collectTypeAliasDefinition(node, ctx);
|
|
188039
188194
|
}
|
|
188040
|
-
if (!ctx.hasUseClientDirective &&
|
|
188041
|
-
const hasInlineExport = node.modifiers?.some((m) => m.kind ===
|
|
188195
|
+
if (!ctx.hasUseClientDirective && import_typescript7.default.isFunctionDeclaration(node) && node.name && node.body && isMultiReturnJsxFunctionBody(node.body)) {
|
|
188196
|
+
const hasInlineExport = node.modifiers?.some((m) => m.kind === import_typescript7.default.SyntaxKind.ExportKeyword) ?? false;
|
|
188042
188197
|
const hasNamedExport = namedExports?.has(node.name.text) ?? false;
|
|
188043
188198
|
if (!hasInlineExport && !hasNamedExport) {
|
|
188044
188199
|
collectFunction(node, ctx, true, false);
|
|
@@ -188053,9 +188208,9 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
188053
188208
|
if (!ctx.componentName) {
|
|
188054
188209
|
ctx.componentName = node.name.text;
|
|
188055
188210
|
ctx.componentNode = node;
|
|
188056
|
-
ctx.isExported = node.modifiers?.some((m) => m.kind ===
|
|
188211
|
+
ctx.isExported = node.modifiers?.some((m) => m.kind === import_typescript7.default.SyntaxKind.ExportKeyword) ?? false;
|
|
188057
188212
|
analyzeComponentBody(node, ctx);
|
|
188058
|
-
if (node.modifiers?.some((m) => m.kind ===
|
|
188213
|
+
if (node.modifiers?.some((m) => m.kind === import_typescript7.default.SyntaxKind.DefaultKeyword)) {
|
|
188059
188214
|
ctx.hasDefaultExport = true;
|
|
188060
188215
|
}
|
|
188061
188216
|
}
|
|
@@ -188069,10 +188224,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
188069
188224
|
ctx.componentName = node.name.text;
|
|
188070
188225
|
ctx.componentNode = node.initializer;
|
|
188071
188226
|
const parentStatement = node.parent;
|
|
188072
|
-
if (
|
|
188227
|
+
if (import_typescript7.default.isVariableDeclarationList(parentStatement)) {
|
|
188073
188228
|
const varStatement = parentStatement.parent;
|
|
188074
|
-
if (
|
|
188075
|
-
ctx.isExported = varStatement.modifiers?.some((m) => m.kind ===
|
|
188229
|
+
if (import_typescript7.default.isVariableStatement(varStatement)) {
|
|
188230
|
+
ctx.isExported = varStatement.modifiers?.some((m) => m.kind === import_typescript7.default.SyntaxKind.ExportKeyword) ?? false;
|
|
188076
188231
|
}
|
|
188077
188232
|
}
|
|
188078
188233
|
analyzeComponentBody(node.initializer, ctx);
|
|
@@ -188084,9 +188239,9 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
188084
188239
|
if (!ctx.componentNode) {
|
|
188085
188240
|
collectAmbientGlobals(node, ctx);
|
|
188086
188241
|
}
|
|
188087
|
-
if (
|
|
188088
|
-
const isExported = node.modifiers?.some((m) => m.kind ===
|
|
188089
|
-
const isLet = (node.declarationList.flags &
|
|
188242
|
+
if (import_typescript7.default.isVariableStatement(node) && !ctx.componentNode) {
|
|
188243
|
+
const isExported = node.modifiers?.some((m) => m.kind === import_typescript7.default.SyntaxKind.ExportKeyword) ?? false;
|
|
188244
|
+
const isLet = (node.declarationList.flags & import_typescript7.default.NodeFlags.Let) !== 0;
|
|
188090
188245
|
const isModuleClientDirective = hasLeadingClientDirectiveOnStatement(node, ctx.sourceFile);
|
|
188091
188246
|
for (const decl of node.declarationList.declarations) {
|
|
188092
188247
|
if (declarationIsReactiveFactoryCall(decl, ctx)) {
|
|
@@ -188097,19 +188252,19 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
188097
188252
|
}
|
|
188098
188253
|
continue;
|
|
188099
188254
|
}
|
|
188100
|
-
if (
|
|
188255
|
+
if (import_typescript7.default.isIdentifier(decl.name) && decl.initializer && !isArrowComponentFunction(decl)) {
|
|
188101
188256
|
collectConstant(decl, ctx, true, isLet ? "let" : "const", isExported);
|
|
188102
188257
|
}
|
|
188103
188258
|
}
|
|
188104
188259
|
}
|
|
188105
|
-
if (
|
|
188106
|
-
const isExported = node.modifiers?.some((m) => m.kind ===
|
|
188260
|
+
if (import_typescript7.default.isFunctionDeclaration(node) && node.name && !isComponentFunction(node)) {
|
|
188261
|
+
const isExported = node.modifiers?.some((m) => m.kind === import_typescript7.default.SyntaxKind.ExportKeyword) ?? false;
|
|
188107
188262
|
collectFunction(node, ctx, true, isExported);
|
|
188108
188263
|
return;
|
|
188109
188264
|
}
|
|
188110
|
-
if (
|
|
188265
|
+
if (import_typescript7.default.isExportDeclaration(node) && node.exportClause && import_typescript7.default.isNamedExports(node.exportClause)) {
|
|
188111
188266
|
const isFromReexport = !!node.moduleSpecifier;
|
|
188112
|
-
const sourceSpec = node.moduleSpecifier &&
|
|
188267
|
+
const sourceSpec = node.moduleSpecifier && import_typescript7.default.isStringLiteral(node.moduleSpecifier) ? node.moduleSpecifier.text : null;
|
|
188113
188268
|
const exportSpecifiers = node.exportClause.elements.map((spec) => ({
|
|
188114
188269
|
name: (spec.propertyName ?? spec.name).text,
|
|
188115
188270
|
alias: spec.propertyName ? spec.name.text : null,
|
|
@@ -188137,24 +188292,24 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
188137
188292
|
}
|
|
188138
188293
|
}
|
|
188139
188294
|
}
|
|
188140
|
-
if (
|
|
188295
|
+
if (import_typescript7.default.isExportAssignment(node) && !node.isExportEquals) {
|
|
188141
188296
|
const expr = node.expression;
|
|
188142
|
-
if (
|
|
188297
|
+
if (import_typescript7.default.isIdentifier(expr)) {
|
|
188143
188298
|
if (ctx.componentName && expr.text === ctx.componentName) {
|
|
188144
188299
|
ctx.hasDefaultExport = true;
|
|
188145
188300
|
ctx.isExported = true;
|
|
188146
188301
|
}
|
|
188147
188302
|
}
|
|
188148
188303
|
}
|
|
188149
|
-
|
|
188304
|
+
import_typescript7.default.forEachChild(node, (child) => visit(child, ctx, targetComponentName, namedExports));
|
|
188150
188305
|
}
|
|
188151
188306
|
function analyzeComponentBody(node, ctx) {
|
|
188152
188307
|
if (node.parameters.length > 0) {
|
|
188153
188308
|
extractProps(node.parameters[0], ctx);
|
|
188154
188309
|
}
|
|
188155
|
-
const body =
|
|
188310
|
+
const body = import_typescript7.default.isFunctionDeclaration(node) ? node.body : getArrowFunctionBody(node);
|
|
188156
188311
|
if (body) {
|
|
188157
|
-
ctx.componentBodyBlock =
|
|
188312
|
+
ctx.componentBodyBlock = import_typescript7.default.isBlock(body) ? body : null;
|
|
188158
188313
|
if (!ctx.componentBodyBlock) {
|
|
188159
188314
|
ctx.jsxReturn = unwrapJsxTransparent(body);
|
|
188160
188315
|
}
|
|
@@ -188164,14 +188319,14 @@ function analyzeComponentBody(node, ctx) {
|
|
|
188164
188319
|
}
|
|
188165
188320
|
}
|
|
188166
188321
|
function getArrowFunctionBody(node) {
|
|
188167
|
-
if (
|
|
188322
|
+
if (import_typescript7.default.isBlock(node.body)) {
|
|
188168
188323
|
return node.body;
|
|
188169
188324
|
}
|
|
188170
188325
|
return node.body;
|
|
188171
188326
|
}
|
|
188172
188327
|
function visitComponentBody(node, ctx) {
|
|
188173
188328
|
const isTopLevel = ctx.componentBodyBlock !== null && node.parent === ctx.componentBodyBlock;
|
|
188174
|
-
if (
|
|
188329
|
+
if (import_typescript7.default.isVariableStatement(node)) {
|
|
188175
188330
|
for (const decl of node.declarationList.declarations) {
|
|
188176
188331
|
if (isSignalDeclaration(decl, ctx)) {
|
|
188177
188332
|
collectSignal(decl, ctx);
|
|
@@ -188194,16 +188349,16 @@ function visitComponentBody(node, ctx) {
|
|
|
188194
188349
|
collectEffect(decl.initializer, ctx, decl.name.text);
|
|
188195
188350
|
continue;
|
|
188196
188351
|
}
|
|
188197
|
-
if (
|
|
188198
|
-
const isLet = (node.declarationList.flags &
|
|
188352
|
+
if (import_typescript7.default.isIdentifier(decl.name)) {
|
|
188353
|
+
const isLet = (node.declarationList.flags & import_typescript7.default.NodeFlags.Let) !== 0;
|
|
188199
188354
|
collectConstant(decl, ctx, false, isLet ? "let" : "const");
|
|
188200
|
-
} else if (
|
|
188201
|
-
const isLet = (node.declarationList.flags &
|
|
188355
|
+
} else if (import_typescript7.default.isObjectBindingPattern(decl.name) && decl.initializer && import_typescript7.default.isIdentifier(decl.initializer) && ctx.propsObjectName === decl.initializer.text) {
|
|
188356
|
+
const isLet = (node.declarationList.flags & import_typescript7.default.NodeFlags.Let) !== 0;
|
|
188202
188357
|
collectConstant(decl, ctx, false, isLet ? "let" : "const");
|
|
188203
188358
|
}
|
|
188204
188359
|
}
|
|
188205
188360
|
}
|
|
188206
|
-
if (
|
|
188361
|
+
if (import_typescript7.default.isExpressionStatement(node)) {
|
|
188207
188362
|
if (isEffectCall(node.expression, ctx)) {
|
|
188208
188363
|
collectEffect(node.expression, ctx);
|
|
188209
188364
|
return;
|
|
@@ -188217,10 +188372,10 @@ function visitComponentBody(node, ctx) {
|
|
|
188217
188372
|
return;
|
|
188218
188373
|
}
|
|
188219
188374
|
}
|
|
188220
|
-
if (
|
|
188375
|
+
if (import_typescript7.default.isFunctionDeclaration(node) && node.name) {
|
|
188221
188376
|
collectFunction(node, ctx, false);
|
|
188222
188377
|
}
|
|
188223
|
-
if (
|
|
188378
|
+
if (import_typescript7.default.isIfStatement(node)) {
|
|
188224
188379
|
const jsxReturn = findJsxReturnInBlock(node.thenStatement);
|
|
188225
188380
|
if (jsxReturn) {
|
|
188226
188381
|
const scopeVars = collectScopeVariables(node.thenStatement, ctx);
|
|
@@ -188239,54 +188394,54 @@ function visitComponentBody(node, ctx) {
|
|
|
188239
188394
|
return;
|
|
188240
188395
|
}
|
|
188241
188396
|
}
|
|
188242
|
-
if (isTopLevel && (
|
|
188397
|
+
if (isTopLevel && (import_typescript7.default.isTryStatement(node) || import_typescript7.default.isSwitchStatement(node) || import_typescript7.default.isForStatement(node) || import_typescript7.default.isForInStatement(node) || import_typescript7.default.isForOfStatement(node) || import_typescript7.default.isWhileStatement(node) || import_typescript7.default.isDoStatement(node) || import_typescript7.default.isThrowStatement(node) || import_typescript7.default.isBlock(node) && node.parent === ctx.componentBodyBlock)) {
|
|
188243
188398
|
collectInitStatement(node, ctx);
|
|
188244
188399
|
return;
|
|
188245
188400
|
}
|
|
188246
|
-
if (
|
|
188401
|
+
if (import_typescript7.default.isReturnStatement(node) && node.expression) {
|
|
188247
188402
|
ctx.jsxReturn = unwrapJsxTransparent(node.expression);
|
|
188248
188403
|
}
|
|
188249
|
-
|
|
188250
|
-
if (
|
|
188404
|
+
import_typescript7.default.forEachChild(node, (child) => {
|
|
188405
|
+
if (import_typescript7.default.isArrowFunction(child) || import_typescript7.default.isFunctionExpression(child) || import_typescript7.default.isFunctionDeclaration(child)) {
|
|
188251
188406
|
return;
|
|
188252
188407
|
}
|
|
188253
188408
|
visitComponentBody(child, ctx);
|
|
188254
188409
|
});
|
|
188255
188410
|
}
|
|
188256
188411
|
function findJsxReturnInBlock(node) {
|
|
188257
|
-
if (
|
|
188412
|
+
if (import_typescript7.default.isBlock(node)) {
|
|
188258
188413
|
for (const stmt of node.statements) {
|
|
188259
|
-
if (
|
|
188414
|
+
if (import_typescript7.default.isReturnStatement(stmt) && stmt.expression) {
|
|
188260
188415
|
const jsx = extractJsxFromExpression(stmt.expression);
|
|
188261
188416
|
if (jsx)
|
|
188262
188417
|
return jsx;
|
|
188263
188418
|
}
|
|
188264
188419
|
}
|
|
188265
188420
|
}
|
|
188266
|
-
if (
|
|
188421
|
+
if (import_typescript7.default.isReturnStatement(node) && node.expression) {
|
|
188267
188422
|
return extractJsxFromExpression(node.expression);
|
|
188268
188423
|
}
|
|
188269
188424
|
return null;
|
|
188270
188425
|
}
|
|
188271
188426
|
function unwrapJsxTransparent(expr) {
|
|
188272
188427
|
let current = expr;
|
|
188273
|
-
while (
|
|
188428
|
+
while (import_typescript7.default.isParenthesizedExpression(current) || import_typescript7.default.isAsExpression(current) || import_typescript7.default.isSatisfiesExpression(current) || import_typescript7.default.isNonNullExpression(current) || import_typescript7.default.isTypeAssertionExpression(current) || current.kind === import_typescript7.default.SyntaxKind.PartiallyEmittedExpression) {
|
|
188274
188429
|
current = current.expression;
|
|
188275
188430
|
}
|
|
188276
188431
|
return current;
|
|
188277
188432
|
}
|
|
188278
188433
|
function extractJsxFromExpression(expr) {
|
|
188279
188434
|
const inner = unwrapJsxTransparent(expr);
|
|
188280
|
-
if (
|
|
188435
|
+
if (import_typescript7.default.isJsxElement(inner) || import_typescript7.default.isJsxFragment(inner) || import_typescript7.default.isJsxSelfClosingElement(inner)) {
|
|
188281
188436
|
return inner;
|
|
188282
188437
|
}
|
|
188283
188438
|
return null;
|
|
188284
188439
|
}
|
|
188285
188440
|
function collectScopeVariables(node, ctx) {
|
|
188286
188441
|
const variables = [];
|
|
188287
|
-
if (
|
|
188442
|
+
if (import_typescript7.default.isBlock(node)) {
|
|
188288
188443
|
for (const stmt of node.statements) {
|
|
188289
|
-
if (
|
|
188444
|
+
if (import_typescript7.default.isVariableStatement(stmt)) {
|
|
188290
188445
|
for (const decl of stmt.declarationList.declarations) {
|
|
188291
188446
|
variables.push(decl);
|
|
188292
188447
|
}
|
|
@@ -188298,13 +188453,13 @@ function collectScopeVariables(node, ctx) {
|
|
|
188298
188453
|
function collectParamBindingNames(params) {
|
|
188299
188454
|
const out = new Set;
|
|
188300
188455
|
const addBindingNames = (name) => {
|
|
188301
|
-
if (
|
|
188456
|
+
if (import_typescript7.default.isIdentifier(name)) {
|
|
188302
188457
|
out.add(name.text);
|
|
188303
|
-
} else if (
|
|
188458
|
+
} else if (import_typescript7.default.isObjectBindingPattern(name)) {
|
|
188304
188459
|
name.elements.forEach((e) => addBindingNames(e.name));
|
|
188305
|
-
} else if (
|
|
188460
|
+
} else if (import_typescript7.default.isArrayBindingPattern(name)) {
|
|
188306
188461
|
name.elements.forEach((e) => {
|
|
188307
|
-
if (!
|
|
188462
|
+
if (!import_typescript7.default.isOmittedExpression(e))
|
|
188308
188463
|
addBindingNames(e.name);
|
|
188309
188464
|
});
|
|
188310
188465
|
}
|
|
@@ -188321,7 +188476,7 @@ function collectEnclosingBranchVars(node, ctx) {
|
|
|
188321
188476
|
if (cr.ifStatement.thenStatement !== current)
|
|
188322
188477
|
continue;
|
|
188323
188478
|
for (const decl of cr.scopeVariables) {
|
|
188324
|
-
if (!
|
|
188479
|
+
if (!import_typescript7.default.isIdentifier(decl.name) || !decl.initializer)
|
|
188325
188480
|
continue;
|
|
188326
188481
|
const varName = decl.name.text;
|
|
188327
188482
|
if (result.has(varName))
|
|
@@ -188336,10 +188491,10 @@ function collectEnclosingBranchVars(node, ctx) {
|
|
|
188336
188491
|
return result;
|
|
188337
188492
|
}
|
|
188338
188493
|
function collectBranchSignals(thenStatement, ctx, branchCondition) {
|
|
188339
|
-
if (!
|
|
188494
|
+
if (!import_typescript7.default.isBlock(thenStatement))
|
|
188340
188495
|
return;
|
|
188341
188496
|
for (const stmt of thenStatement.statements) {
|
|
188342
|
-
if (!
|
|
188497
|
+
if (!import_typescript7.default.isVariableStatement(stmt))
|
|
188343
188498
|
continue;
|
|
188344
188499
|
for (const decl of stmt.declarationList.declarations) {
|
|
188345
188500
|
if (!isSignalDeclaration(decl, ctx))
|
|
@@ -188361,13 +188516,13 @@ var PRIMITIVE_CANONICAL_NAMES = {
|
|
|
188361
188516
|
onCleanup: "onCleanup"
|
|
188362
188517
|
};
|
|
188363
188518
|
function resolvePrimitiveKind(callExpr, ctx) {
|
|
188364
|
-
if (
|
|
188519
|
+
if (import_typescript7.default.isIdentifier(callExpr.expression)) {
|
|
188365
188520
|
const hit = PRIMITIVE_CANONICAL_NAMES[callExpr.expression.text];
|
|
188366
188521
|
if (hit)
|
|
188367
188522
|
return hit;
|
|
188368
188523
|
return resolveCalleeViaChecker(callExpr.expression, ctx);
|
|
188369
188524
|
}
|
|
188370
|
-
if (
|
|
188525
|
+
if (import_typescript7.default.isPropertyAccessExpression(callExpr.expression)) {
|
|
188371
188526
|
const propName = callExpr.expression.name.text;
|
|
188372
188527
|
const hit = PRIMITIVE_CANONICAL_NAMES[propName];
|
|
188373
188528
|
if (!hit)
|
|
@@ -188390,7 +188545,7 @@ function resolveCalleeViaChecker(ident, ctx) {
|
|
|
188390
188545
|
if (!symbol)
|
|
188391
188546
|
return null;
|
|
188392
188547
|
let target = symbol;
|
|
188393
|
-
if (symbol.flags &
|
|
188548
|
+
if (symbol.flags & import_typescript7.default.SymbolFlags.Alias) {
|
|
188394
188549
|
try {
|
|
188395
188550
|
target = ctx.checker.getAliasedSymbol(symbol);
|
|
188396
188551
|
} catch {
|
|
@@ -188410,7 +188565,7 @@ function resolveCalleeViaChecker(ident, ctx) {
|
|
|
188410
188565
|
return null;
|
|
188411
188566
|
}
|
|
188412
188567
|
function isBarefootClientNamespace(expr, ctx) {
|
|
188413
|
-
if (!
|
|
188568
|
+
if (!import_typescript7.default.isIdentifier(expr))
|
|
188414
188569
|
return false;
|
|
188415
188570
|
if (!ctx.checker)
|
|
188416
188571
|
return false;
|
|
@@ -188423,22 +188578,22 @@ function isBarefootClientNamespace(expr, ctx) {
|
|
|
188423
188578
|
if (!symbol)
|
|
188424
188579
|
return false;
|
|
188425
188580
|
for (const decl of symbol.declarations ?? []) {
|
|
188426
|
-
if (!
|
|
188581
|
+
if (!import_typescript7.default.isNamespaceImport(decl))
|
|
188427
188582
|
continue;
|
|
188428
188583
|
const importDecl = decl.parent.parent;
|
|
188429
|
-
if (!
|
|
188584
|
+
if (!import_typescript7.default.isImportDeclaration(importDecl))
|
|
188430
188585
|
continue;
|
|
188431
188586
|
const mod = importDecl.moduleSpecifier;
|
|
188432
|
-
if (
|
|
188587
|
+
if (import_typescript7.default.isStringLiteral(mod) && mod.text === "@barefootjs/client") {
|
|
188433
188588
|
return true;
|
|
188434
188589
|
}
|
|
188435
188590
|
}
|
|
188436
188591
|
return false;
|
|
188437
188592
|
}
|
|
188438
188593
|
function isSignalDeclaration(node, ctx) {
|
|
188439
|
-
if (!
|
|
188594
|
+
if (!import_typescript7.default.isArrayBindingPattern(node.name))
|
|
188440
188595
|
return false;
|
|
188441
|
-
if (!node.initializer || !
|
|
188596
|
+
if (!node.initializer || !import_typescript7.default.isCallExpression(node.initializer))
|
|
188442
188597
|
return false;
|
|
188443
188598
|
return resolvePrimitiveKind(node.initializer, ctx) === "signal";
|
|
188444
188599
|
}
|
|
@@ -188446,14 +188601,14 @@ function collectSignal(node, ctx) {
|
|
|
188446
188601
|
const pattern = node.name;
|
|
188447
188602
|
const callExpr = node.initializer;
|
|
188448
188603
|
const elements = pattern.elements;
|
|
188449
|
-
if (elements.length < 1 || elements.length > 2 || !
|
|
188604
|
+
if (elements.length < 1 || elements.length > 2 || !import_typescript7.default.isBindingElement(elements[0]) || !import_typescript7.default.isIdentifier(elements[0].name)) {
|
|
188450
188605
|
return;
|
|
188451
188606
|
}
|
|
188452
|
-
if (elements.length === 2 && (!
|
|
188607
|
+
if (elements.length === 2 && (!import_typescript7.default.isBindingElement(elements[1]) || !import_typescript7.default.isIdentifier(elements[1].name))) {
|
|
188453
188608
|
return;
|
|
188454
188609
|
}
|
|
188455
188610
|
const getter = elements[0].name.text;
|
|
188456
|
-
const setter = elements.length === 2 &&
|
|
188611
|
+
const setter = elements.length === 2 && import_typescript7.default.isBindingElement(elements[1]) && import_typescript7.default.isIdentifier(elements[1].name) ? elements[1].name.text : null;
|
|
188457
188612
|
const initialValue = callExpr.arguments[0] ? ctx.getJS(callExpr.arguments[0]) : "";
|
|
188458
188613
|
const typedInitialValue = callExpr.arguments[0] ? callExpr.arguments[0].getText(ctx.sourceFile) : undefined;
|
|
188459
188614
|
let type2 = { kind: "unknown", raw: "unknown" };
|
|
@@ -188473,33 +188628,33 @@ function collectSignal(node, ctx) {
|
|
|
188473
188628
|
});
|
|
188474
188629
|
}
|
|
188475
188630
|
function isSignalTupleDeclaration(node) {
|
|
188476
|
-
if (!
|
|
188631
|
+
if (!import_typescript7.default.isIdentifier(node.name))
|
|
188477
188632
|
return false;
|
|
188478
|
-
if (!node.initializer || !
|
|
188633
|
+
if (!node.initializer || !import_typescript7.default.isCallExpression(node.initializer))
|
|
188479
188634
|
return false;
|
|
188480
188635
|
const callExpr = node.initializer;
|
|
188481
|
-
return
|
|
188636
|
+
return import_typescript7.default.isIdentifier(callExpr.expression) && callExpr.expression.text === "createSignal";
|
|
188482
188637
|
}
|
|
188483
188638
|
function isSignalIndexAccess(node, ctx) {
|
|
188484
|
-
if (!
|
|
188639
|
+
if (!import_typescript7.default.isIdentifier(node.name))
|
|
188485
188640
|
return null;
|
|
188486
|
-
if (!node.initializer || !
|
|
188641
|
+
if (!node.initializer || !import_typescript7.default.isElementAccessExpression(node.initializer))
|
|
188487
188642
|
return null;
|
|
188488
188643
|
const access = node.initializer;
|
|
188489
|
-
if (!
|
|
188644
|
+
if (!import_typescript7.default.isNumericLiteral(access.argumentExpression))
|
|
188490
188645
|
return null;
|
|
188491
188646
|
const indexValue = Number(access.argumentExpression.text);
|
|
188492
188647
|
if (indexValue !== 0 && indexValue !== 1)
|
|
188493
188648
|
return null;
|
|
188494
188649
|
const index = indexValue;
|
|
188495
|
-
if (
|
|
188650
|
+
if (import_typescript7.default.isCallExpression(access.expression)) {
|
|
188496
188651
|
const call = access.expression;
|
|
188497
|
-
if (
|
|
188652
|
+
if (import_typescript7.default.isIdentifier(call.expression) && call.expression.text === "createSignal") {
|
|
188498
188653
|
return { kind: "direct", index, callExpr: call };
|
|
188499
188654
|
}
|
|
188500
188655
|
return null;
|
|
188501
188656
|
}
|
|
188502
|
-
if (
|
|
188657
|
+
if (import_typescript7.default.isIdentifier(access.expression)) {
|
|
188503
188658
|
const tupleName = access.expression.text;
|
|
188504
188659
|
if (ctx.signalTupleRefs.has(tupleName)) {
|
|
188505
188660
|
return { kind: "tupleRef", index, tupleName };
|
|
@@ -188594,9 +188749,9 @@ function flushPendingSignalTuples(ctx) {
|
|
|
188594
188749
|
ctx.signalTupleRefs.clear();
|
|
188595
188750
|
}
|
|
188596
188751
|
function isMemoDeclaration(node, ctx) {
|
|
188597
|
-
if (!
|
|
188752
|
+
if (!import_typescript7.default.isIdentifier(node.name))
|
|
188598
188753
|
return false;
|
|
188599
|
-
if (!node.initializer || !
|
|
188754
|
+
if (!node.initializer || !import_typescript7.default.isCallExpression(node.initializer))
|
|
188600
188755
|
return false;
|
|
188601
188756
|
return resolvePrimitiveKind(node.initializer, ctx) === "memo";
|
|
188602
188757
|
}
|
|
@@ -188626,14 +188781,14 @@ function collectMemo(node, ctx) {
|
|
|
188626
188781
|
});
|
|
188627
188782
|
}
|
|
188628
188783
|
function isEffectCall(node, ctx) {
|
|
188629
|
-
if (!
|
|
188784
|
+
if (!import_typescript7.default.isCallExpression(node))
|
|
188630
188785
|
return false;
|
|
188631
188786
|
return resolvePrimitiveKind(node, ctx) === "effect";
|
|
188632
188787
|
}
|
|
188633
188788
|
function isEffectDisposerCapture(node, ctx) {
|
|
188634
|
-
if (!
|
|
188789
|
+
if (!import_typescript7.default.isIdentifier(node.name))
|
|
188635
188790
|
return false;
|
|
188636
|
-
if (!node.initializer || !
|
|
188791
|
+
if (!node.initializer || !import_typescript7.default.isCallExpression(node.initializer))
|
|
188637
188792
|
return false;
|
|
188638
188793
|
return resolvePrimitiveKind(node.initializer, ctx) === "effect";
|
|
188639
188794
|
}
|
|
@@ -188648,7 +188803,7 @@ function collectEffect(node, ctx, captureName) {
|
|
|
188648
188803
|
});
|
|
188649
188804
|
}
|
|
188650
188805
|
function isOnMountCall(node, ctx) {
|
|
188651
|
-
if (!
|
|
188806
|
+
if (!import_typescript7.default.isCallExpression(node))
|
|
188652
188807
|
return false;
|
|
188653
188808
|
return resolvePrimitiveKind(node, ctx) === "onMount";
|
|
188654
188809
|
}
|
|
@@ -188683,19 +188838,19 @@ function leadsWithAsiHazard(body) {
|
|
|
188683
188838
|
function extractAssignedIdentifiersFromNode(node) {
|
|
188684
188839
|
const ids = new Set;
|
|
188685
188840
|
function addFromTarget(target) {
|
|
188686
|
-
if (
|
|
188841
|
+
if (import_typescript7.default.isIdentifier(target)) {
|
|
188687
188842
|
ids.add(target.text);
|
|
188688
188843
|
return;
|
|
188689
188844
|
}
|
|
188690
|
-
if (
|
|
188845
|
+
if (import_typescript7.default.isParenthesizedExpression(target)) {
|
|
188691
188846
|
addFromTarget(target.expression);
|
|
188692
188847
|
return;
|
|
188693
188848
|
}
|
|
188694
|
-
if (
|
|
188849
|
+
if (import_typescript7.default.isArrayLiteralExpression(target)) {
|
|
188695
188850
|
for (const el of target.elements) {
|
|
188696
|
-
if (
|
|
188851
|
+
if (import_typescript7.default.isOmittedExpression(el))
|
|
188697
188852
|
continue;
|
|
188698
|
-
if (
|
|
188853
|
+
if (import_typescript7.default.isSpreadElement(el)) {
|
|
188699
188854
|
addFromTarget(el.expression);
|
|
188700
188855
|
continue;
|
|
188701
188856
|
}
|
|
@@ -188703,17 +188858,17 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
188703
188858
|
}
|
|
188704
188859
|
return;
|
|
188705
188860
|
}
|
|
188706
|
-
if (
|
|
188861
|
+
if (import_typescript7.default.isObjectLiteralExpression(target)) {
|
|
188707
188862
|
for (const prop of target.properties) {
|
|
188708
|
-
if (
|
|
188863
|
+
if (import_typescript7.default.isShorthandPropertyAssignment(prop)) {
|
|
188709
188864
|
ids.add(prop.name.text);
|
|
188710
188865
|
continue;
|
|
188711
188866
|
}
|
|
188712
|
-
if (
|
|
188867
|
+
if (import_typescript7.default.isPropertyAssignment(prop)) {
|
|
188713
188868
|
addFromTarget(prop.initializer);
|
|
188714
188869
|
continue;
|
|
188715
188870
|
}
|
|
188716
|
-
if (
|
|
188871
|
+
if (import_typescript7.default.isSpreadAssignment(prop)) {
|
|
188717
188872
|
addFromTarget(prop.expression);
|
|
188718
188873
|
continue;
|
|
188719
188874
|
}
|
|
@@ -188722,21 +188877,21 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
188722
188877
|
}
|
|
188723
188878
|
}
|
|
188724
188879
|
function visit2(n) {
|
|
188725
|
-
if (
|
|
188880
|
+
if (import_typescript7.default.isArrowFunction(n) || import_typescript7.default.isFunctionExpression(n) || import_typescript7.default.isFunctionDeclaration(n) || import_typescript7.default.isMethodDeclaration(n) || import_typescript7.default.isGetAccessorDeclaration(n) || import_typescript7.default.isSetAccessorDeclaration(n) || import_typescript7.default.isConstructorDeclaration(n)) {
|
|
188726
188881
|
return;
|
|
188727
188882
|
}
|
|
188728
|
-
if (
|
|
188883
|
+
if (import_typescript7.default.isBinaryExpression(n)) {
|
|
188729
188884
|
const op = n.operatorToken.kind;
|
|
188730
|
-
if (op ===
|
|
188885
|
+
if (op === import_typescript7.default.SyntaxKind.EqualsToken || op === import_typescript7.default.SyntaxKind.PlusEqualsToken || op === import_typescript7.default.SyntaxKind.MinusEqualsToken || op === import_typescript7.default.SyntaxKind.AsteriskEqualsToken || op === import_typescript7.default.SyntaxKind.SlashEqualsToken || op === import_typescript7.default.SyntaxKind.PercentEqualsToken || op === import_typescript7.default.SyntaxKind.AsteriskAsteriskEqualsToken || op === import_typescript7.default.SyntaxKind.AmpersandEqualsToken || op === import_typescript7.default.SyntaxKind.BarEqualsToken || op === import_typescript7.default.SyntaxKind.CaretEqualsToken || op === import_typescript7.default.SyntaxKind.LessThanLessThanEqualsToken || op === import_typescript7.default.SyntaxKind.GreaterThanGreaterThanEqualsToken || op === import_typescript7.default.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken || op === import_typescript7.default.SyntaxKind.AmpersandAmpersandEqualsToken || op === import_typescript7.default.SyntaxKind.BarBarEqualsToken || op === import_typescript7.default.SyntaxKind.QuestionQuestionEqualsToken) {
|
|
188731
188886
|
addFromTarget(n.left);
|
|
188732
188887
|
}
|
|
188733
188888
|
}
|
|
188734
|
-
if (
|
|
188735
|
-
if (n.operator ===
|
|
188889
|
+
if (import_typescript7.default.isPrefixUnaryExpression(n) || import_typescript7.default.isPostfixUnaryExpression(n)) {
|
|
188890
|
+
if (n.operator === import_typescript7.default.SyntaxKind.PlusPlusToken || n.operator === import_typescript7.default.SyntaxKind.MinusMinusToken) {
|
|
188736
188891
|
addFromTarget(n.operand);
|
|
188737
188892
|
}
|
|
188738
188893
|
}
|
|
188739
|
-
|
|
188894
|
+
import_typescript7.default.forEachChild(n, visit2);
|
|
188740
188895
|
}
|
|
188741
188896
|
visit2(node);
|
|
188742
188897
|
const localDecls = collectLocalDeclarations(node);
|
|
@@ -188747,30 +188902,30 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
188747
188902
|
function collectLocalDeclarations(root) {
|
|
188748
188903
|
const names = new Set;
|
|
188749
188904
|
function addBindingName(name) {
|
|
188750
|
-
if (
|
|
188905
|
+
if (import_typescript7.default.isIdentifier(name)) {
|
|
188751
188906
|
names.add(name.text);
|
|
188752
188907
|
return;
|
|
188753
188908
|
}
|
|
188754
|
-
if (
|
|
188909
|
+
if (import_typescript7.default.isArrayBindingPattern(name)) {
|
|
188755
188910
|
for (const el of name.elements) {
|
|
188756
|
-
if (
|
|
188911
|
+
if (import_typescript7.default.isBindingElement(el))
|
|
188757
188912
|
addBindingName(el.name);
|
|
188758
188913
|
}
|
|
188759
188914
|
return;
|
|
188760
188915
|
}
|
|
188761
|
-
if (
|
|
188916
|
+
if (import_typescript7.default.isObjectBindingPattern(name)) {
|
|
188762
188917
|
for (const el of name.elements) {
|
|
188763
188918
|
addBindingName(el.name);
|
|
188764
188919
|
}
|
|
188765
188920
|
}
|
|
188766
188921
|
}
|
|
188767
188922
|
function visit2(n) {
|
|
188768
|
-
if (
|
|
188923
|
+
if (import_typescript7.default.isArrowFunction(n) || import_typescript7.default.isFunctionExpression(n) || import_typescript7.default.isFunctionDeclaration(n))
|
|
188769
188924
|
return;
|
|
188770
|
-
if (
|
|
188925
|
+
if (import_typescript7.default.isVariableDeclaration(n)) {
|
|
188771
188926
|
addBindingName(n.name);
|
|
188772
188927
|
}
|
|
188773
|
-
|
|
188928
|
+
import_typescript7.default.forEachChild(n, visit2);
|
|
188774
188929
|
}
|
|
188775
188930
|
visit2(root);
|
|
188776
188931
|
return names;
|
|
@@ -188798,35 +188953,35 @@ var CLIENT_EXPORTS = new Set([
|
|
|
188798
188953
|
"cleanupPortalPlaceholder"
|
|
188799
188954
|
]);
|
|
188800
188955
|
function collectAmbientGlobals(node, ctx) {
|
|
188801
|
-
if (
|
|
188802
|
-
const isDeclare = node.modifiers?.some((m) => m.kind ===
|
|
188956
|
+
if (import_typescript7.default.isVariableStatement(node)) {
|
|
188957
|
+
const isDeclare = node.modifiers?.some((m) => m.kind === import_typescript7.default.SyntaxKind.DeclareKeyword) ?? false;
|
|
188803
188958
|
if (!isDeclare)
|
|
188804
188959
|
return;
|
|
188805
188960
|
for (const decl of node.declarationList.declarations) {
|
|
188806
|
-
if (
|
|
188961
|
+
if (import_typescript7.default.isIdentifier(decl.name))
|
|
188807
188962
|
ctx.ambientGlobals.add(decl.name.text);
|
|
188808
188963
|
}
|
|
188809
188964
|
return;
|
|
188810
188965
|
}
|
|
188811
|
-
if (
|
|
188812
|
-
const isDeclare = node.modifiers?.some((m) => m.kind ===
|
|
188966
|
+
if (import_typescript7.default.isFunctionDeclaration(node) && node.name) {
|
|
188967
|
+
const isDeclare = node.modifiers?.some((m) => m.kind === import_typescript7.default.SyntaxKind.DeclareKeyword) ?? false;
|
|
188813
188968
|
if (isDeclare)
|
|
188814
188969
|
ctx.ambientGlobals.add(node.name.text);
|
|
188815
188970
|
return;
|
|
188816
188971
|
}
|
|
188817
|
-
if (
|
|
188818
|
-
const isGlobalAugmentation = (node.flags &
|
|
188972
|
+
if (import_typescript7.default.isModuleDeclaration(node)) {
|
|
188973
|
+
const isGlobalAugmentation = (node.flags & import_typescript7.default.NodeFlags.GlobalAugmentation) !== 0;
|
|
188819
188974
|
if (!isGlobalAugmentation)
|
|
188820
188975
|
return;
|
|
188821
|
-
if (!node.body || !
|
|
188976
|
+
if (!node.body || !import_typescript7.default.isModuleBlock(node.body))
|
|
188822
188977
|
return;
|
|
188823
188978
|
for (const inner of node.body.statements) {
|
|
188824
|
-
if (
|
|
188979
|
+
if (import_typescript7.default.isVariableStatement(inner)) {
|
|
188825
188980
|
for (const decl of inner.declarationList.declarations) {
|
|
188826
|
-
if (
|
|
188981
|
+
if (import_typescript7.default.isIdentifier(decl.name))
|
|
188827
188982
|
ctx.ambientGlobals.add(decl.name.text);
|
|
188828
188983
|
}
|
|
188829
|
-
} else if (
|
|
188984
|
+
} else if (import_typescript7.default.isFunctionDeclaration(inner) && inner.name) {
|
|
188830
188985
|
ctx.ambientGlobals.add(inner.name.text);
|
|
188831
188986
|
}
|
|
188832
188987
|
}
|
|
@@ -188837,7 +188992,7 @@ function collectImport(node, ctx) {
|
|
|
188837
188992
|
const specifiers = [];
|
|
188838
188993
|
const isTypeOnly = !!node.importClause?.isTypeOnly;
|
|
188839
188994
|
const loc = getSourceLocation(node, ctx.sourceFile, ctx.filePath);
|
|
188840
|
-
if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings &&
|
|
188995
|
+
if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings && import_typescript7.default.isNamedImports(node.importClause.namedBindings)) {
|
|
188841
188996
|
const wrongImports = [];
|
|
188842
188997
|
for (const element of node.importClause.namedBindings.elements) {
|
|
188843
188998
|
const name = element.propertyName?.text ?? element.name.text;
|
|
@@ -188865,7 +189020,7 @@ function collectImport(node, ctx) {
|
|
|
188865
189020
|
});
|
|
188866
189021
|
}
|
|
188867
189022
|
if (node.importClause.namedBindings) {
|
|
188868
|
-
if (
|
|
189023
|
+
if (import_typescript7.default.isNamedImports(node.importClause.namedBindings)) {
|
|
188869
189024
|
for (const element of node.importClause.namedBindings.elements) {
|
|
188870
189025
|
specifiers.push({
|
|
188871
189026
|
name: element.propertyName?.text ?? element.name.text,
|
|
@@ -188875,7 +189030,7 @@ function collectImport(node, ctx) {
|
|
|
188875
189030
|
});
|
|
188876
189031
|
}
|
|
188877
189032
|
}
|
|
188878
|
-
if (
|
|
189033
|
+
if (import_typescript7.default.isNamespaceImport(node.importClause.namedBindings)) {
|
|
188879
189034
|
specifiers.push({
|
|
188880
189035
|
name: node.importClause.namedBindings.name.text,
|
|
188881
189036
|
alias: null,
|
|
@@ -188912,20 +189067,20 @@ function extractSingleJsxReturn(body) {
|
|
|
188912
189067
|
let jsxReturn = null;
|
|
188913
189068
|
let returnCount = 0;
|
|
188914
189069
|
function visit2(node) {
|
|
188915
|
-
if (
|
|
189070
|
+
if (import_typescript7.default.isFunctionDeclaration(node) || import_typescript7.default.isFunctionExpression(node) || import_typescript7.default.isArrowFunction(node))
|
|
188916
189071
|
return;
|
|
188917
|
-
if (
|
|
189072
|
+
if (import_typescript7.default.isReturnStatement(node)) {
|
|
188918
189073
|
returnCount++;
|
|
188919
189074
|
if (node.expression) {
|
|
188920
189075
|
const expr = unwrapJsxTransparent(node.expression);
|
|
188921
|
-
if (
|
|
189076
|
+
if (import_typescript7.default.isJsxElement(expr) || import_typescript7.default.isJsxSelfClosingElement(expr) || import_typescript7.default.isJsxFragment(expr)) {
|
|
188922
189077
|
jsxReturn = expr;
|
|
188923
189078
|
}
|
|
188924
189079
|
}
|
|
188925
189080
|
}
|
|
188926
|
-
|
|
189081
|
+
import_typescript7.default.forEachChild(node, visit2);
|
|
188927
189082
|
}
|
|
188928
|
-
|
|
189083
|
+
import_typescript7.default.forEachChild(body, visit2);
|
|
188929
189084
|
if (returnCount !== 1)
|
|
188930
189085
|
return null;
|
|
188931
189086
|
return jsxReturn;
|
|
@@ -188936,9 +189091,9 @@ function extractMultiReturnJsxBranches(body) {
|
|
|
188936
189091
|
const stmts = body.statements;
|
|
188937
189092
|
for (let i2 = 0;i2 < stmts.length; i2++) {
|
|
188938
189093
|
const stmt = stmts[i2];
|
|
188939
|
-
if (
|
|
189094
|
+
if (import_typescript7.default.isIfStatement(stmt)) {
|
|
188940
189095
|
let current = stmt;
|
|
188941
|
-
while (
|
|
189096
|
+
while (import_typescript7.default.isIfStatement(current)) {
|
|
188942
189097
|
const ifStmt = current;
|
|
188943
189098
|
if (!isDirectReturnBlock(ifStmt.thenStatement))
|
|
188944
189099
|
return null;
|
|
@@ -188948,7 +189103,7 @@ function extractMultiReturnJsxBranches(body) {
|
|
|
188948
189103
|
return null;
|
|
188949
189104
|
branches.push({ condition: ifStmt.expression, jsxReturn: jsxReturn ?? null });
|
|
188950
189105
|
if (ifStmt.elseStatement) {
|
|
188951
|
-
if (
|
|
189106
|
+
if (import_typescript7.default.isIfStatement(ifStmt.elseStatement)) {
|
|
188952
189107
|
current = ifStmt.elseStatement;
|
|
188953
189108
|
continue;
|
|
188954
189109
|
}
|
|
@@ -188968,13 +189123,13 @@ function extractMultiReturnJsxBranches(body) {
|
|
|
188968
189123
|
}
|
|
188969
189124
|
continue;
|
|
188970
189125
|
}
|
|
188971
|
-
if (
|
|
189126
|
+
if (import_typescript7.default.isSwitchStatement(stmt)) {
|
|
188972
189127
|
if (branches.length > 0)
|
|
188973
189128
|
return null;
|
|
188974
|
-
if (!
|
|
189129
|
+
if (!import_typescript7.default.isIdentifier(stmt.expression) && !import_typescript7.default.isPropertyAccessExpression(stmt.expression)) {
|
|
188975
189130
|
return null;
|
|
188976
189131
|
}
|
|
188977
|
-
const hasDefault = stmt.caseBlock.clauses.some((c) =>
|
|
189132
|
+
const hasDefault = stmt.caseBlock.clauses.some((c) => import_typescript7.default.isDefaultClause(c));
|
|
188978
189133
|
if (!hasDefault)
|
|
188979
189134
|
return null;
|
|
188980
189135
|
for (const clause of stmt.caseBlock.clauses) {
|
|
@@ -188982,7 +189137,7 @@ function extractMultiReturnJsxBranches(body) {
|
|
|
188982
189137
|
const nullReturn = findNullReturnInCaseClause(clause);
|
|
188983
189138
|
if (!jsxReturn && !nullReturn)
|
|
188984
189139
|
return null;
|
|
188985
|
-
if (
|
|
189140
|
+
if (import_typescript7.default.isCaseClause(clause)) {
|
|
188986
189141
|
branches.push({
|
|
188987
189142
|
condition: clause.expression,
|
|
188988
189143
|
jsxReturn: jsxReturn ?? null
|
|
@@ -188995,16 +189150,16 @@ function extractMultiReturnJsxBranches(body) {
|
|
|
188995
189150
|
return null;
|
|
188996
189151
|
return { branches, fallback, switchDiscriminant: stmt.expression };
|
|
188997
189152
|
}
|
|
188998
|
-
if (
|
|
189153
|
+
if (import_typescript7.default.isReturnStatement(stmt) && stmt.expression) {
|
|
188999
189154
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
189000
|
-
if (
|
|
189155
|
+
if (import_typescript7.default.isJsxElement(expr) || import_typescript7.default.isJsxSelfClosingElement(expr) || import_typescript7.default.isJsxFragment(expr)) {
|
|
189001
189156
|
fallback = expr;
|
|
189002
|
-
} else if (expr.kind ===
|
|
189157
|
+
} else if (expr.kind === import_typescript7.default.SyntaxKind.NullKeyword) {} else {
|
|
189003
189158
|
return null;
|
|
189004
189159
|
}
|
|
189005
189160
|
continue;
|
|
189006
189161
|
}
|
|
189007
|
-
if (
|
|
189162
|
+
if (import_typescript7.default.isVariableStatement(stmt))
|
|
189008
189163
|
return null;
|
|
189009
189164
|
return null;
|
|
189010
189165
|
}
|
|
@@ -189013,14 +189168,14 @@ function extractMultiReturnJsxBranches(body) {
|
|
|
189013
189168
|
return { branches, fallback };
|
|
189014
189169
|
}
|
|
189015
189170
|
function isDirectReturnBlock(node) {
|
|
189016
|
-
if (
|
|
189171
|
+
if (import_typescript7.default.isReturnStatement(node))
|
|
189017
189172
|
return true;
|
|
189018
|
-
if (
|
|
189173
|
+
if (import_typescript7.default.isBlock(node)) {
|
|
189019
189174
|
let returnCount = 0;
|
|
189020
189175
|
for (const stmt of node.statements) {
|
|
189021
|
-
if (
|
|
189176
|
+
if (import_typescript7.default.isReturnStatement(stmt)) {
|
|
189022
189177
|
returnCount++;
|
|
189023
|
-
} else if (
|
|
189178
|
+
} else if (import_typescript7.default.isIfStatement(stmt) || import_typescript7.default.isSwitchStatement(stmt) || import_typescript7.default.isForStatement(stmt) || import_typescript7.default.isForOfStatement(stmt) || import_typescript7.default.isForInStatement(stmt) || import_typescript7.default.isWhileStatement(stmt) || import_typescript7.default.isDoStatement(stmt) || import_typescript7.default.isTryStatement(stmt)) {
|
|
189024
189179
|
return false;
|
|
189025
189180
|
}
|
|
189026
189181
|
}
|
|
@@ -189029,25 +189184,25 @@ function isDirectReturnBlock(node) {
|
|
|
189029
189184
|
return false;
|
|
189030
189185
|
}
|
|
189031
189186
|
function findNullReturnInBlock(node) {
|
|
189032
|
-
if (
|
|
189187
|
+
if (import_typescript7.default.isBlock(node)) {
|
|
189033
189188
|
for (const stmt of node.statements) {
|
|
189034
|
-
if (
|
|
189189
|
+
if (import_typescript7.default.isReturnStatement(stmt) && stmt.expression) {
|
|
189035
189190
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
189036
|
-
if (expr.kind ===
|
|
189191
|
+
if (expr.kind === import_typescript7.default.SyntaxKind.NullKeyword)
|
|
189037
189192
|
return true;
|
|
189038
189193
|
}
|
|
189039
189194
|
}
|
|
189040
189195
|
}
|
|
189041
|
-
if (
|
|
189196
|
+
if (import_typescript7.default.isReturnStatement(node) && node.expression) {
|
|
189042
189197
|
const expr = unwrapJsxTransparent(node.expression);
|
|
189043
|
-
if (expr.kind ===
|
|
189198
|
+
if (expr.kind === import_typescript7.default.SyntaxKind.NullKeyword)
|
|
189044
189199
|
return true;
|
|
189045
189200
|
}
|
|
189046
189201
|
return false;
|
|
189047
189202
|
}
|
|
189048
189203
|
function findJsxReturnInCaseClause(clause) {
|
|
189049
189204
|
for (const stmt of clause.statements) {
|
|
189050
|
-
if (
|
|
189205
|
+
if (import_typescript7.default.isReturnStatement(stmt) && stmt.expression) {
|
|
189051
189206
|
return extractJsxFromExpression(stmt.expression);
|
|
189052
189207
|
}
|
|
189053
189208
|
}
|
|
@@ -189055,9 +189210,9 @@ function findJsxReturnInCaseClause(clause) {
|
|
|
189055
189210
|
}
|
|
189056
189211
|
function findNullReturnInCaseClause(clause) {
|
|
189057
189212
|
for (const stmt of clause.statements) {
|
|
189058
|
-
if (
|
|
189213
|
+
if (import_typescript7.default.isReturnStatement(stmt) && stmt.expression) {
|
|
189059
189214
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
189060
|
-
if (expr.kind ===
|
|
189215
|
+
if (expr.kind === import_typescript7.default.SyntaxKind.NullKeyword)
|
|
189061
189216
|
return true;
|
|
189062
189217
|
}
|
|
189063
189218
|
}
|
|
@@ -189068,26 +189223,26 @@ function isMultiReturnJsxFunctionBody(body) {
|
|
|
189068
189223
|
let hasJsxReturn = false;
|
|
189069
189224
|
let allReturnsAreJsxOrNull = true;
|
|
189070
189225
|
function visit2(node) {
|
|
189071
|
-
if (
|
|
189226
|
+
if (import_typescript7.default.isFunctionDeclaration(node) || import_typescript7.default.isFunctionExpression(node) || import_typescript7.default.isArrowFunction(node))
|
|
189072
189227
|
return;
|
|
189073
|
-
if (
|
|
189228
|
+
if (import_typescript7.default.isReturnStatement(node)) {
|
|
189074
189229
|
returnCount++;
|
|
189075
189230
|
if (!node.expression) {
|
|
189076
189231
|
allReturnsAreJsxOrNull = false;
|
|
189077
189232
|
return;
|
|
189078
189233
|
}
|
|
189079
189234
|
const expr = unwrapJsxTransparent(node.expression);
|
|
189080
|
-
const isJsx =
|
|
189081
|
-
const isNull2 = expr.kind ===
|
|
189235
|
+
const isJsx = import_typescript7.default.isJsxElement(expr) || import_typescript7.default.isJsxSelfClosingElement(expr) || import_typescript7.default.isJsxFragment(expr);
|
|
189236
|
+
const isNull2 = expr.kind === import_typescript7.default.SyntaxKind.NullKeyword;
|
|
189082
189237
|
if (isJsx)
|
|
189083
189238
|
hasJsxReturn = true;
|
|
189084
189239
|
if (!isJsx && !isNull2)
|
|
189085
189240
|
allReturnsAreJsxOrNull = false;
|
|
189086
189241
|
return;
|
|
189087
189242
|
}
|
|
189088
|
-
|
|
189243
|
+
import_typescript7.default.forEachChild(node, visit2);
|
|
189089
189244
|
}
|
|
189090
|
-
|
|
189245
|
+
import_typescript7.default.forEachChild(body, visit2);
|
|
189091
189246
|
return returnCount > 1 && hasJsxReturn && allReturnsAreJsxOrNull;
|
|
189092
189247
|
}
|
|
189093
189248
|
function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
@@ -189157,7 +189312,7 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
|
189157
189312
|
}
|
|
189158
189313
|
}
|
|
189159
189314
|
}
|
|
189160
|
-
const isAsync = node.modifiers?.some((m) => m.kind ===
|
|
189315
|
+
const isAsync = node.modifiers?.some((m) => m.kind === import_typescript7.default.SyntaxKind.AsyncKeyword) ?? false;
|
|
189161
189316
|
const isGenerator = !!node.asteriskToken;
|
|
189162
189317
|
ctx.localFunctions.push({
|
|
189163
189318
|
name,
|
|
@@ -189178,10 +189333,10 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
|
189178
189333
|
});
|
|
189179
189334
|
}
|
|
189180
189335
|
function extractValueBranches(node, ctx) {
|
|
189181
|
-
if (
|
|
189336
|
+
if (import_typescript7.default.isParenthesizedExpression(node)) {
|
|
189182
189337
|
return extractValueBranches(node.expression, ctx);
|
|
189183
189338
|
}
|
|
189184
|
-
if (
|
|
189339
|
+
if (import_typescript7.default.isConditionalExpression(node)) {
|
|
189185
189340
|
return [
|
|
189186
189341
|
...extractValueBranches(node.whenTrue, ctx),
|
|
189187
189342
|
...extractValueBranches(node.whenFalse, ctx)
|
|
@@ -189193,46 +189348,46 @@ function extractFreeIdentifiersFromNode(node) {
|
|
|
189193
189348
|
const ids = new Set;
|
|
189194
189349
|
const boundNames = new Set;
|
|
189195
189350
|
function addBindingNames(name, out) {
|
|
189196
|
-
if (
|
|
189351
|
+
if (import_typescript7.default.isIdentifier(name))
|
|
189197
189352
|
out.push(name.text);
|
|
189198
|
-
else if (
|
|
189353
|
+
else if (import_typescript7.default.isObjectBindingPattern(name))
|
|
189199
189354
|
name.elements.forEach((e) => addBindingNames(e.name, out));
|
|
189200
|
-
else if (
|
|
189355
|
+
else if (import_typescript7.default.isArrayBindingPattern(name))
|
|
189201
189356
|
name.elements.forEach((e) => {
|
|
189202
|
-
if (!
|
|
189357
|
+
if (!import_typescript7.default.isOmittedExpression(e))
|
|
189203
189358
|
addBindingNames(e.name, out);
|
|
189204
189359
|
});
|
|
189205
189360
|
}
|
|
189206
189361
|
function visit2(n) {
|
|
189207
|
-
if (
|
|
189362
|
+
if (import_typescript7.default.isTypeNode(n))
|
|
189208
189363
|
return;
|
|
189209
|
-
if (
|
|
189364
|
+
if (import_typescript7.default.isIdentifier(n)) {
|
|
189210
189365
|
const parent = n.parent;
|
|
189211
|
-
if (parent &&
|
|
189366
|
+
if (parent && import_typescript7.default.isPropertyAccessExpression(parent) && parent.name === n)
|
|
189212
189367
|
return;
|
|
189213
|
-
if (parent &&
|
|
189368
|
+
if (parent && import_typescript7.default.isPropertyAssignment(parent) && parent.name === n)
|
|
189214
189369
|
return;
|
|
189215
|
-
if (parent &&
|
|
189370
|
+
if (parent && import_typescript7.default.isParameter(parent) && parent.name === n)
|
|
189216
189371
|
return;
|
|
189217
|
-
if (parent &&
|
|
189372
|
+
if (parent && import_typescript7.default.isVariableDeclaration(parent) && parent.name === n)
|
|
189218
189373
|
return;
|
|
189219
189374
|
if (boundNames.has(n.text))
|
|
189220
189375
|
return;
|
|
189221
189376
|
ids.add(n.text);
|
|
189222
189377
|
return;
|
|
189223
189378
|
}
|
|
189224
|
-
if (
|
|
189379
|
+
if (import_typescript7.default.isArrowFunction(n)) {
|
|
189225
189380
|
const params = [];
|
|
189226
189381
|
for (const p of n.parameters)
|
|
189227
189382
|
addBindingNames(p.name, params);
|
|
189228
189383
|
for (const name of params)
|
|
189229
189384
|
boundNames.add(name);
|
|
189230
|
-
|
|
189385
|
+
import_typescript7.default.forEachChild(n, visit2);
|
|
189231
189386
|
for (const name of params)
|
|
189232
189387
|
boundNames.delete(name);
|
|
189233
189388
|
return;
|
|
189234
189389
|
}
|
|
189235
|
-
|
|
189390
|
+
import_typescript7.default.forEachChild(n, visit2);
|
|
189236
189391
|
}
|
|
189237
189392
|
visit2(node);
|
|
189238
189393
|
return ids;
|
|
@@ -189242,22 +189397,22 @@ function initializerShapeContainsJsx(node) {
|
|
|
189242
189397
|
function visit2(n) {
|
|
189243
189398
|
if (found)
|
|
189244
189399
|
return;
|
|
189245
|
-
if (
|
|
189400
|
+
if (import_typescript7.default.isJsxElement(n) || import_typescript7.default.isJsxSelfClosingElement(n) || import_typescript7.default.isJsxFragment(n)) {
|
|
189246
189401
|
found = true;
|
|
189247
189402
|
return;
|
|
189248
189403
|
}
|
|
189249
|
-
if (
|
|
189404
|
+
if (import_typescript7.default.isFunctionDeclaration(n) || import_typescript7.default.isFunctionExpression(n) || import_typescript7.default.isArrowFunction(n)) {
|
|
189250
189405
|
return;
|
|
189251
189406
|
}
|
|
189252
|
-
|
|
189407
|
+
import_typescript7.default.forEachChild(n, visit2);
|
|
189253
189408
|
}
|
|
189254
189409
|
visit2(node);
|
|
189255
189410
|
return found;
|
|
189256
189411
|
}
|
|
189257
189412
|
function isMapLikeCallWithJsx(node) {
|
|
189258
|
-
if (!
|
|
189413
|
+
if (!import_typescript7.default.isCallExpression(node))
|
|
189259
189414
|
return false;
|
|
189260
|
-
if (!
|
|
189415
|
+
if (!import_typescript7.default.isPropertyAccessExpression(node.expression))
|
|
189261
189416
|
return false;
|
|
189262
189417
|
const method = node.expression.name.text;
|
|
189263
189418
|
if (method !== "map" && method !== "flatMap")
|
|
@@ -189265,12 +189420,12 @@ function isMapLikeCallWithJsx(node) {
|
|
|
189265
189420
|
const callback = node.arguments[0];
|
|
189266
189421
|
if (!callback)
|
|
189267
189422
|
return false;
|
|
189268
|
-
if (!
|
|
189423
|
+
if (!import_typescript7.default.isArrowFunction(callback) && !import_typescript7.default.isFunctionExpression(callback))
|
|
189269
189424
|
return false;
|
|
189270
189425
|
return containsJsxDeep(callback.body);
|
|
189271
189426
|
}
|
|
189272
189427
|
function containsJsxDeep(node) {
|
|
189273
|
-
if (
|
|
189428
|
+
if (import_typescript7.default.isJsxElement(node) || import_typescript7.default.isJsxSelfClosingElement(node) || import_typescript7.default.isJsxFragment(node))
|
|
189274
189429
|
return true;
|
|
189275
189430
|
let found = false;
|
|
189276
189431
|
node.forEachChild((child) => {
|
|
@@ -189284,11 +189439,11 @@ function nodeContainsArrow(node) {
|
|
|
189284
189439
|
function visit2(n) {
|
|
189285
189440
|
if (found)
|
|
189286
189441
|
return;
|
|
189287
|
-
if (
|
|
189442
|
+
if (import_typescript7.default.isArrowFunction(n) || import_typescript7.default.isFunctionExpression(n)) {
|
|
189288
189443
|
found = true;
|
|
189289
189444
|
return;
|
|
189290
189445
|
}
|
|
189291
|
-
|
|
189446
|
+
import_typescript7.default.forEachChild(n, visit2);
|
|
189292
189447
|
}
|
|
189293
189448
|
visit2(node);
|
|
189294
189449
|
return found;
|
|
@@ -189336,20 +189491,20 @@ function collectModuleScopeReactive(decl, ctx, isExported) {
|
|
|
189336
189491
|
}));
|
|
189337
189492
|
}
|
|
189338
189493
|
function getSystemConstructKind(node) {
|
|
189339
|
-
if (
|
|
189494
|
+
if (import_typescript7.default.isCallExpression(node) && import_typescript7.default.isIdentifier(node.expression) && node.expression.text === "createContext")
|
|
189340
189495
|
return "createContext";
|
|
189341
|
-
if (
|
|
189496
|
+
if (import_typescript7.default.isNewExpression(node) && import_typescript7.default.isIdentifier(node.expression) && node.expression.text === "WeakMap")
|
|
189342
189497
|
return "weakMap";
|
|
189343
189498
|
return;
|
|
189344
189499
|
}
|
|
189345
189500
|
function collectConstant(node, ctx, _isModule, declarationKind = "const", isExported = false) {
|
|
189346
|
-
if (!_isModule &&
|
|
189501
|
+
if (!_isModule && import_typescript7.default.isObjectBindingPattern(node.name) && node.initializer && import_typescript7.default.isIdentifier(node.initializer) && ctx.propsObjectName === node.initializer.text) {
|
|
189347
189502
|
const propsName = node.initializer.text;
|
|
189348
189503
|
for (const el of node.name.elements) {
|
|
189349
|
-
if (!
|
|
189504
|
+
if (!import_typescript7.default.isBindingElement(el) || !import_typescript7.default.isIdentifier(el.name) || el.dotDotDotToken)
|
|
189350
189505
|
continue;
|
|
189351
189506
|
const localName = el.name.text;
|
|
189352
|
-
const sourceKey = el.propertyName &&
|
|
189507
|
+
const sourceKey = el.propertyName && import_typescript7.default.isIdentifier(el.propertyName) ? el.propertyName.text : localName;
|
|
189353
189508
|
const defaultValueExpr = el.initializer ? ctx.getJS(el.initializer) : undefined;
|
|
189354
189509
|
const baseValue = `${propsName}.${sourceKey}`;
|
|
189355
189510
|
const value2 = defaultValueExpr ? `${baseValue} ?? ${defaultValueExpr}` : baseValue;
|
|
@@ -189369,7 +189524,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
189369
189524
|
}
|
|
189370
189525
|
return;
|
|
189371
189526
|
}
|
|
189372
|
-
if (!
|
|
189527
|
+
if (!import_typescript7.default.isIdentifier(node.name))
|
|
189373
189528
|
return;
|
|
189374
189529
|
if (isSignalDeclaration(node, ctx) || isMemoDeclaration(node, ctx))
|
|
189375
189530
|
return;
|
|
@@ -189387,9 +189542,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
189387
189542
|
let isJsxFunction = false;
|
|
189388
189543
|
if (node.initializer) {
|
|
189389
189544
|
let init = node.initializer;
|
|
189390
|
-
while (
|
|
189545
|
+
while (import_typescript7.default.isParenthesizedExpression(init))
|
|
189391
189546
|
init = init.expression;
|
|
189392
|
-
if (
|
|
189547
|
+
if (import_typescript7.default.isJsxElement(init) || import_typescript7.default.isJsxSelfClosingElement(init) || import_typescript7.default.isJsxFragment(init)) {
|
|
189393
189548
|
isJsx = true;
|
|
189394
189549
|
ctx.jsxConstants.set(name, init);
|
|
189395
189550
|
} else if (initializerShapeContainsJsx(init)) {
|
|
@@ -189397,9 +189552,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
189397
189552
|
} else if (isMapLikeCallWithJsx(init)) {
|
|
189398
189553
|
ctx.inlineableJsxConsts.set(name, init);
|
|
189399
189554
|
}
|
|
189400
|
-
if (
|
|
189555
|
+
if (import_typescript7.default.isArrowFunction(init)) {
|
|
189401
189556
|
const arrowBody = init.body;
|
|
189402
|
-
if (
|
|
189557
|
+
if (import_typescript7.default.isBlock(arrowBody)) {
|
|
189403
189558
|
const jsxReturn = extractSingleJsxReturn(arrowBody);
|
|
189404
189559
|
if (jsxReturn) {
|
|
189405
189560
|
isJsxFunction = true;
|
|
@@ -189419,9 +189574,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
189419
189574
|
}
|
|
189420
189575
|
} else {
|
|
189421
189576
|
let body = arrowBody;
|
|
189422
|
-
while (
|
|
189577
|
+
while (import_typescript7.default.isParenthesizedExpression(body))
|
|
189423
189578
|
body = body.expression;
|
|
189424
|
-
if (
|
|
189579
|
+
if (import_typescript7.default.isJsxElement(body) || import_typescript7.default.isJsxSelfClosingElement(body) || import_typescript7.default.isJsxFragment(body)) {
|
|
189425
189580
|
isJsxFunction = true;
|
|
189426
189581
|
ctx.jsxFunctions.set(name, {
|
|
189427
189582
|
jsxReturn: body,
|
|
@@ -189434,9 +189589,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
189434
189589
|
let valueBranches;
|
|
189435
189590
|
if (node.initializer) {
|
|
189436
189591
|
let inner = node.initializer;
|
|
189437
|
-
while (
|
|
189592
|
+
while (import_typescript7.default.isParenthesizedExpression(inner))
|
|
189438
189593
|
inner = inner.expression;
|
|
189439
|
-
if (
|
|
189594
|
+
if (import_typescript7.default.isConditionalExpression(inner)) {
|
|
189440
189595
|
valueBranches = extractValueBranches(node.initializer, ctx);
|
|
189441
189596
|
}
|
|
189442
189597
|
}
|
|
@@ -189509,7 +189664,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
189509
189664
|
function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
189510
189665
|
const checkComments = (targetNode) => {
|
|
189511
189666
|
const fullStart = targetNode.getFullStart();
|
|
189512
|
-
const leadingComments =
|
|
189667
|
+
const leadingComments = import_typescript7.default.getLeadingCommentRanges(sourceFile.getFullText(), fullStart);
|
|
189513
189668
|
if (!leadingComments)
|
|
189514
189669
|
return false;
|
|
189515
189670
|
for (const range of leadingComments) {
|
|
@@ -189522,10 +189677,10 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
|
189522
189677
|
};
|
|
189523
189678
|
if (checkComments(node))
|
|
189524
189679
|
return true;
|
|
189525
|
-
if (
|
|
189680
|
+
if (import_typescript7.default.isArrowFunction(node)) {
|
|
189526
189681
|
let current = node.parent;
|
|
189527
189682
|
while (current) {
|
|
189528
|
-
if (
|
|
189683
|
+
if (import_typescript7.default.isVariableStatement(current)) {
|
|
189529
189684
|
if (checkComments(current))
|
|
189530
189685
|
return true;
|
|
189531
189686
|
break;
|
|
@@ -189536,7 +189691,7 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
|
189536
189691
|
return false;
|
|
189537
189692
|
}
|
|
189538
189693
|
function extractProps(param, ctx) {
|
|
189539
|
-
if (
|
|
189694
|
+
if (import_typescript7.default.isObjectBindingPattern(param.name)) {
|
|
189540
189695
|
const componentNode = ctx.componentNode;
|
|
189541
189696
|
const ignored = !!(componentNode && hasIgnoreDirective(componentNode, ctx.sourceFile, "props-destructuring"));
|
|
189542
189697
|
ctx.propsDestructuring = {
|
|
@@ -189544,7 +189699,7 @@ function extractProps(param, ctx) {
|
|
|
189544
189699
|
hasIgnoreDirective: ignored
|
|
189545
189700
|
};
|
|
189546
189701
|
for (const element of param.name.elements) {
|
|
189547
|
-
if (
|
|
189702
|
+
if (import_typescript7.default.isBindingElement(element) && import_typescript7.default.isIdentifier(element.name)) {
|
|
189548
189703
|
const localName = element.name.text;
|
|
189549
189704
|
const defaultValue = element.initializer ? ctx.getJS(element.initializer) : undefined;
|
|
189550
189705
|
if (element.dotDotDotToken) {
|
|
@@ -189569,7 +189724,7 @@ function extractProps(param, ctx) {
|
|
|
189569
189724
|
}
|
|
189570
189725
|
}
|
|
189571
189726
|
}
|
|
189572
|
-
if (
|
|
189727
|
+
if (import_typescript7.default.isIdentifier(param.name)) {
|
|
189573
189728
|
ctx.propsObjectName = param.name.text;
|
|
189574
189729
|
if (param.type) {
|
|
189575
189730
|
extractPropsFromType(param.type, ctx);
|
|
@@ -189580,24 +189735,24 @@ function extractProps(param, ctx) {
|
|
|
189580
189735
|
}
|
|
189581
189736
|
}
|
|
189582
189737
|
function collectTypeKeys(typeNode, ctx) {
|
|
189583
|
-
if (
|
|
189738
|
+
if (import_typescript7.default.isTypeLiteralNode(typeNode)) {
|
|
189584
189739
|
return collectKeysFromMembers(typeNode.members, ctx);
|
|
189585
189740
|
}
|
|
189586
|
-
if (
|
|
189741
|
+
if (import_typescript7.default.isTypeReferenceNode(typeNode)) {
|
|
189587
189742
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
189588
189743
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
189589
189744
|
if (!typeDecl)
|
|
189590
189745
|
return null;
|
|
189591
|
-
if (
|
|
189746
|
+
if (import_typescript7.default.isInterfaceDeclaration(typeDecl)) {
|
|
189592
189747
|
if (typeDecl.heritageClauses && typeDecl.heritageClauses.length > 0)
|
|
189593
189748
|
return null;
|
|
189594
189749
|
return collectKeysFromMembers(typeDecl.members, ctx);
|
|
189595
189750
|
}
|
|
189596
|
-
if (
|
|
189597
|
-
if (
|
|
189751
|
+
if (import_typescript7.default.isTypeAliasDeclaration(typeDecl)) {
|
|
189752
|
+
if (import_typescript7.default.isTypeLiteralNode(typeDecl.type)) {
|
|
189598
189753
|
return collectKeysFromMembers(typeDecl.type.members, ctx);
|
|
189599
189754
|
}
|
|
189600
|
-
if (
|
|
189755
|
+
if (import_typescript7.default.isIntersectionTypeNode(typeDecl.type)) {
|
|
189601
189756
|
return null;
|
|
189602
189757
|
}
|
|
189603
189758
|
}
|
|
@@ -189607,26 +189762,26 @@ function collectTypeKeys(typeNode, ctx) {
|
|
|
189607
189762
|
function collectKeysFromMembers(members, ctx) {
|
|
189608
189763
|
const keys = [];
|
|
189609
189764
|
for (const member of members) {
|
|
189610
|
-
if (
|
|
189765
|
+
if (import_typescript7.default.isIndexSignatureDeclaration(member))
|
|
189611
189766
|
return null;
|
|
189612
|
-
if (
|
|
189767
|
+
if (import_typescript7.default.isPropertySignature(member) && member.name) {
|
|
189613
189768
|
keys.push(member.name.getText(ctx.sourceFile));
|
|
189614
189769
|
}
|
|
189615
189770
|
}
|
|
189616
189771
|
return keys;
|
|
189617
189772
|
}
|
|
189618
189773
|
function extractPropsFromType(typeNode, ctx) {
|
|
189619
|
-
if (
|
|
189774
|
+
if (import_typescript7.default.isTypeLiteralNode(typeNode)) {
|
|
189620
189775
|
extractPropsFromTypeMembers(typeNode.members, ctx);
|
|
189621
189776
|
return;
|
|
189622
189777
|
}
|
|
189623
|
-
if (
|
|
189778
|
+
if (import_typescript7.default.isTypeReferenceNode(typeNode)) {
|
|
189624
189779
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
189625
189780
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
189626
189781
|
if (typeDecl) {
|
|
189627
|
-
if (
|
|
189782
|
+
if (import_typescript7.default.isInterfaceDeclaration(typeDecl)) {
|
|
189628
189783
|
extractPropsFromTypeMembers(typeDecl.members, ctx);
|
|
189629
|
-
} else if (
|
|
189784
|
+
} else if (import_typescript7.default.isTypeAliasDeclaration(typeDecl) && import_typescript7.default.isTypeLiteralNode(typeDecl.type)) {
|
|
189630
189785
|
extractPropsFromTypeMembers(typeDecl.type.members, ctx);
|
|
189631
189786
|
}
|
|
189632
189787
|
}
|
|
@@ -189634,7 +189789,7 @@ function extractPropsFromType(typeNode, ctx) {
|
|
|
189634
189789
|
}
|
|
189635
189790
|
function extractPropsFromTypeMembers(members, ctx) {
|
|
189636
189791
|
for (const member of members) {
|
|
189637
|
-
if (
|
|
189792
|
+
if (import_typescript7.default.isPropertySignature(member) && member.name) {
|
|
189638
189793
|
const propName = member.name.getText(ctx.sourceFile);
|
|
189639
189794
|
const isOptional = !!member.questionToken;
|
|
189640
189795
|
const propType = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : { kind: "unknown", raw: "unknown" };
|
|
@@ -189650,17 +189805,17 @@ function extractPropsFromTypeMembers(members, ctx) {
|
|
|
189650
189805
|
function findTypeDeclaration(typeName, sourceFile) {
|
|
189651
189806
|
let result;
|
|
189652
189807
|
function visit2(node) {
|
|
189653
|
-
if (
|
|
189808
|
+
if (import_typescript7.default.isInterfaceDeclaration(node) && node.name.text === typeName) {
|
|
189654
189809
|
result = node;
|
|
189655
189810
|
return;
|
|
189656
189811
|
}
|
|
189657
|
-
if (
|
|
189812
|
+
if (import_typescript7.default.isTypeAliasDeclaration(node) && node.name.text === typeName) {
|
|
189658
189813
|
result = node;
|
|
189659
189814
|
return;
|
|
189660
189815
|
}
|
|
189661
|
-
|
|
189816
|
+
import_typescript7.default.forEachChild(node, visit2);
|
|
189662
189817
|
}
|
|
189663
|
-
|
|
189818
|
+
import_typescript7.default.forEachChild(sourceFile, visit2);
|
|
189664
189819
|
return result;
|
|
189665
189820
|
}
|
|
189666
189821
|
function inferTypeFromValue(value) {
|
|
@@ -189794,16 +189949,16 @@ function isResolvableComponentSource(source) {
|
|
|
189794
189949
|
function collectJsxComponentTags(sourceFile) {
|
|
189795
189950
|
const tags = new Set;
|
|
189796
189951
|
function visit2(node) {
|
|
189797
|
-
if (
|
|
189952
|
+
if (import_typescript7.default.isJsxOpeningElement(node) || import_typescript7.default.isJsxSelfClosingElement(node)) {
|
|
189798
189953
|
const tagName = node.tagName;
|
|
189799
|
-
if (
|
|
189954
|
+
if (import_typescript7.default.isIdentifier(tagName)) {
|
|
189800
189955
|
const first = tagName.text.charAt(0);
|
|
189801
189956
|
if (first >= "A" && first <= "Z") {
|
|
189802
189957
|
tags.add(tagName.text);
|
|
189803
189958
|
}
|
|
189804
189959
|
}
|
|
189805
189960
|
}
|
|
189806
|
-
|
|
189961
|
+
import_typescript7.default.forEachChild(node, visit2);
|
|
189807
189962
|
}
|
|
189808
189963
|
visit2(sourceFile);
|
|
189809
189964
|
return tags;
|
|
@@ -189882,18 +190037,18 @@ function fileHasUseClientDirective(filePath) {
|
|
|
189882
190037
|
} catch {
|
|
189883
190038
|
return true;
|
|
189884
190039
|
}
|
|
189885
|
-
const sf =
|
|
190040
|
+
const sf = import_typescript7.default.createSourceFile(filePath, content, import_typescript7.default.ScriptTarget.Latest, false, import_typescript7.default.ScriptKind.TSX);
|
|
189886
190041
|
let found = false;
|
|
189887
190042
|
function visit2(node) {
|
|
189888
190043
|
if (found)
|
|
189889
190044
|
return;
|
|
189890
|
-
if (
|
|
190045
|
+
if (import_typescript7.default.isExpressionStatement(node) && import_typescript7.default.isStringLiteral(node.expression)) {
|
|
189891
190046
|
if (node.expression.text === "use client") {
|
|
189892
190047
|
found = true;
|
|
189893
190048
|
return;
|
|
189894
190049
|
}
|
|
189895
190050
|
}
|
|
189896
|
-
|
|
190051
|
+
import_typescript7.default.forEachChild(node, visit2);
|
|
189897
190052
|
}
|
|
189898
190053
|
visit2(sf);
|
|
189899
190054
|
return found;
|
|
@@ -189976,16 +190131,16 @@ var REACTIVE_PRIMITIVES = new Set([
|
|
|
189976
190131
|
"onCleanup"
|
|
189977
190132
|
]);
|
|
189978
190133
|
function prescanReactiveFactoriesInSource(source, filePath) {
|
|
189979
|
-
const sourceFile =
|
|
190134
|
+
const sourceFile = import_typescript7.default.createSourceFile(filePath + ".prescan", source, import_typescript7.default.ScriptTarget.Latest, true, import_typescript7.default.ScriptKind.TSX);
|
|
189980
190135
|
const factories = new Map;
|
|
189981
190136
|
function visitTop(node) {
|
|
189982
|
-
if (
|
|
190137
|
+
if (import_typescript7.default.isFunctionDeclaration(node) && node.name && node.body) {
|
|
189983
190138
|
const info = detectReactiveFactory(node, sourceFile, filePath);
|
|
189984
190139
|
if (info)
|
|
189985
190140
|
factories.set(node.name.text, info);
|
|
189986
190141
|
}
|
|
189987
190142
|
}
|
|
189988
|
-
|
|
190143
|
+
import_typescript7.default.forEachChild(sourceFile, visitTop);
|
|
189989
190144
|
return { factories, sourceFile };
|
|
189990
190145
|
}
|
|
189991
190146
|
function detectReactiveFactory(node, sourceFile, filePath) {
|
|
@@ -189994,19 +190149,19 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
189994
190149
|
let tupleReturn = null;
|
|
189995
190150
|
let returnCount = 0;
|
|
189996
190151
|
for (const stmt of node.body.statements) {
|
|
189997
|
-
if (!
|
|
190152
|
+
if (!import_typescript7.default.isReturnStatement(stmt))
|
|
189998
190153
|
continue;
|
|
189999
190154
|
returnCount++;
|
|
190000
190155
|
if (!stmt.expression)
|
|
190001
190156
|
return null;
|
|
190002
190157
|
let expr = stmt.expression;
|
|
190003
|
-
while (
|
|
190158
|
+
while (import_typescript7.default.isParenthesizedExpression(expr))
|
|
190004
190159
|
expr = expr.expression;
|
|
190005
|
-
if (
|
|
190160
|
+
if (import_typescript7.default.isAsExpression(expr))
|
|
190006
190161
|
expr = expr.expression;
|
|
190007
|
-
if (
|
|
190162
|
+
if (import_typescript7.default.isTypeAssertionExpression(expr))
|
|
190008
190163
|
expr = expr.expression;
|
|
190009
|
-
if (!
|
|
190164
|
+
if (!import_typescript7.default.isArrayLiteralExpression(expr))
|
|
190010
190165
|
return null;
|
|
190011
190166
|
tupleReturn = expr;
|
|
190012
190167
|
}
|
|
@@ -190014,7 +190169,7 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
190014
190169
|
return null;
|
|
190015
190170
|
const returnTupleIdentifiers = [];
|
|
190016
190171
|
for (const el of tupleReturn.elements) {
|
|
190017
|
-
if (!
|
|
190172
|
+
if (!import_typescript7.default.isIdentifier(el))
|
|
190018
190173
|
return null;
|
|
190019
190174
|
returnTupleIdentifiers.push(el.text);
|
|
190020
190175
|
}
|
|
@@ -190024,29 +190179,29 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
190024
190179
|
function checkForReactive(n) {
|
|
190025
190180
|
if (hasReactiveCall)
|
|
190026
190181
|
return;
|
|
190027
|
-
if (
|
|
190182
|
+
if (import_typescript7.default.isCallExpression(n) && import_typescript7.default.isIdentifier(n.expression) && REACTIVE_PRIMITIVES.has(n.expression.text)) {
|
|
190028
190183
|
hasReactiveCall = true;
|
|
190029
190184
|
return;
|
|
190030
190185
|
}
|
|
190031
|
-
|
|
190186
|
+
import_typescript7.default.forEachChild(n, checkForReactive);
|
|
190032
190187
|
}
|
|
190033
190188
|
checkForReactive(node.body);
|
|
190034
190189
|
if (!hasReactiveCall)
|
|
190035
190190
|
return null;
|
|
190036
190191
|
const localBindings = [];
|
|
190037
190192
|
for (const stmt of node.body.statements) {
|
|
190038
|
-
if (
|
|
190193
|
+
if (import_typescript7.default.isVariableStatement(stmt)) {
|
|
190039
190194
|
for (const decl of stmt.declarationList.declarations) {
|
|
190040
190195
|
addBindingNames(decl.name, localBindings);
|
|
190041
190196
|
}
|
|
190042
|
-
} else if (
|
|
190197
|
+
} else if (import_typescript7.default.isFunctionDeclaration(stmt) && stmt.name) {
|
|
190043
190198
|
localBindings.push(stmt.name.text);
|
|
190044
190199
|
}
|
|
190045
190200
|
}
|
|
190046
|
-
const bodyStatements = node.body.statements.filter((s) => !
|
|
190201
|
+
const bodyStatements = node.body.statements.filter((s) => !import_typescript7.default.isReturnStatement(s)).map((s) => s.getText(sourceFile)).join(`
|
|
190047
190202
|
`);
|
|
190048
190203
|
const params = node.parameters.map((p) => {
|
|
190049
|
-
if (
|
|
190204
|
+
if (import_typescript7.default.isIdentifier(p.name))
|
|
190050
190205
|
return p.name.text;
|
|
190051
190206
|
return "";
|
|
190052
190207
|
});
|
|
@@ -190061,18 +190216,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
190061
190216
|
};
|
|
190062
190217
|
}
|
|
190063
190218
|
function addBindingNames(name, out) {
|
|
190064
|
-
if (
|
|
190219
|
+
if (import_typescript7.default.isIdentifier(name)) {
|
|
190065
190220
|
out.push(name.text);
|
|
190066
190221
|
return;
|
|
190067
190222
|
}
|
|
190068
|
-
if (
|
|
190223
|
+
if (import_typescript7.default.isObjectBindingPattern(name)) {
|
|
190069
190224
|
for (const el of name.elements)
|
|
190070
190225
|
addBindingNames(el.name, out);
|
|
190071
190226
|
return;
|
|
190072
190227
|
}
|
|
190073
|
-
if (
|
|
190228
|
+
if (import_typescript7.default.isArrayBindingPattern(name)) {
|
|
190074
190229
|
for (const el of name.elements) {
|
|
190075
|
-
if (
|
|
190230
|
+
if (import_typescript7.default.isOmittedExpression(el))
|
|
190076
190231
|
continue;
|
|
190077
190232
|
addBindingNames(el.name, out);
|
|
190078
190233
|
}
|
|
@@ -190083,23 +190238,23 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
190083
190238
|
const edits = [];
|
|
190084
190239
|
let callSiteIndex = 0;
|
|
190085
190240
|
function visitStmt(node, inComponent) {
|
|
190086
|
-
if (
|
|
190241
|
+
if (import_typescript7.default.isVariableStatement(node) && inComponent) {
|
|
190087
190242
|
for (const decl of node.declarationList.declarations) {
|
|
190088
190243
|
maybeRewriteDecl(node, decl);
|
|
190089
190244
|
}
|
|
190090
190245
|
}
|
|
190091
|
-
|
|
190092
|
-
if (
|
|
190246
|
+
import_typescript7.default.forEachChild(node, (child) => {
|
|
190247
|
+
if (import_typescript7.default.isFunctionDeclaration(child) && child.name && factories.has(child.name.text))
|
|
190093
190248
|
return;
|
|
190094
190249
|
visitStmt(child, inComponent || isPascalCaseComponentFn(child));
|
|
190095
190250
|
});
|
|
190096
190251
|
}
|
|
190097
190252
|
function maybeRewriteDecl(stmt, decl) {
|
|
190098
|
-
if (!
|
|
190253
|
+
if (!import_typescript7.default.isArrayBindingPattern(decl.name))
|
|
190099
190254
|
return;
|
|
190100
|
-
if (!decl.initializer || !
|
|
190255
|
+
if (!decl.initializer || !import_typescript7.default.isCallExpression(decl.initializer))
|
|
190101
190256
|
return;
|
|
190102
|
-
if (!
|
|
190257
|
+
if (!import_typescript7.default.isIdentifier(decl.initializer.expression))
|
|
190103
190258
|
return;
|
|
190104
190259
|
const factoryName = decl.initializer.expression.text;
|
|
190105
190260
|
const factory = factories.get(factoryName);
|
|
@@ -190110,7 +190265,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
190110
190265
|
return;
|
|
190111
190266
|
const callerNames = [];
|
|
190112
190267
|
for (const el of elements) {
|
|
190113
|
-
if (
|
|
190268
|
+
if (import_typescript7.default.isOmittedExpression(el) || !import_typescript7.default.isIdentifier(el.name))
|
|
190114
190269
|
return;
|
|
190115
190270
|
callerNames.push(el.name.text);
|
|
190116
190271
|
}
|
|
@@ -190155,10 +190310,10 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
190155
190310
|
return out;
|
|
190156
190311
|
}
|
|
190157
190312
|
function isPascalCaseComponentFn(node) {
|
|
190158
|
-
if (
|
|
190313
|
+
if (import_typescript7.default.isFunctionDeclaration(node) && node.name) {
|
|
190159
190314
|
return /^[A-Z]/.test(node.name.text);
|
|
190160
190315
|
}
|
|
190161
|
-
if (
|
|
190316
|
+
if (import_typescript7.default.isVariableDeclaration(node) && import_typescript7.default.isIdentifier(node.name) && node.initializer && import_typescript7.default.isArrowFunction(node.initializer)) {
|
|
190162
190317
|
return /^[A-Z]/.test(node.name.text);
|
|
190163
190318
|
}
|
|
190164
190319
|
return false;
|
|
@@ -190169,18 +190324,18 @@ function escapeRegex(s) {
|
|
|
190169
190324
|
function validateReactiveFactoryCalls(ctx) {
|
|
190170
190325
|
if (!ctx.componentNode)
|
|
190171
190326
|
return;
|
|
190172
|
-
const body =
|
|
190327
|
+
const body = import_typescript7.default.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : import_typescript7.default.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
|
|
190173
190328
|
if (!body)
|
|
190174
190329
|
return;
|
|
190175
190330
|
for (const stmt of body.statements) {
|
|
190176
|
-
if (!
|
|
190331
|
+
if (!import_typescript7.default.isVariableStatement(stmt))
|
|
190177
190332
|
continue;
|
|
190178
190333
|
for (const decl of stmt.declarationList.declarations) {
|
|
190179
|
-
if (!
|
|
190334
|
+
if (!import_typescript7.default.isArrayBindingPattern(decl.name))
|
|
190180
190335
|
continue;
|
|
190181
|
-
if (!decl.initializer || !
|
|
190336
|
+
if (!decl.initializer || !import_typescript7.default.isCallExpression(decl.initializer))
|
|
190182
190337
|
continue;
|
|
190183
|
-
if (!
|
|
190338
|
+
if (!import_typescript7.default.isIdentifier(decl.initializer.expression))
|
|
190184
190339
|
continue;
|
|
190185
190340
|
const callee = decl.initializer.expression.text;
|
|
190186
190341
|
if (callee === "createSignal" || callee === "createMemo")
|
|
@@ -190197,7 +190352,7 @@ function validateReactiveFactoryCalls(ctx) {
|
|
|
190197
190352
|
}
|
|
190198
190353
|
|
|
190199
190354
|
// ../jsx/src/jsx-to-ir.ts
|
|
190200
|
-
var
|
|
190355
|
+
var import_typescript11 = __toESM(require_typescript(), 1);
|
|
190201
190356
|
|
|
190202
190357
|
// ../jsx/src/types.ts
|
|
190203
190358
|
var SCOPE_FORBIDDEN = {
|
|
@@ -190270,7 +190425,7 @@ var AttrValueOf = {
|
|
|
190270
190425
|
};
|
|
190271
190426
|
|
|
190272
190427
|
// ../jsx/src/expression-parser.ts
|
|
190273
|
-
var
|
|
190428
|
+
var import_typescript8 = __toESM(require_typescript(), 1);
|
|
190274
190429
|
var UNSUPPORTED_METHODS = new Set([
|
|
190275
190430
|
"filter",
|
|
190276
190431
|
"map",
|
|
@@ -190287,37 +190442,37 @@ function parseExpression(expr) {
|
|
|
190287
190442
|
if (!trimmed) {
|
|
190288
190443
|
return { kind: "unsupported", raw: expr, reason: "Empty expression" };
|
|
190289
190444
|
}
|
|
190290
|
-
const sourceFile =
|
|
190445
|
+
const sourceFile = import_typescript8.default.createSourceFile("expression.ts", trimmed, import_typescript8.default.ScriptTarget.Latest, true, import_typescript8.default.ScriptKind.TSX);
|
|
190291
190446
|
if (sourceFile.statements.length === 0) {
|
|
190292
190447
|
return { kind: "unsupported", raw: expr, reason: "No statements found" };
|
|
190293
190448
|
}
|
|
190294
190449
|
const firstStmt = sourceFile.statements[0];
|
|
190295
|
-
if (!
|
|
190450
|
+
if (!import_typescript8.default.isExpressionStatement(firstStmt)) {
|
|
190296
190451
|
return { kind: "unsupported", raw: expr, reason: "Not an expression statement" };
|
|
190297
190452
|
}
|
|
190298
190453
|
return convertNode(firstStmt.expression, expr);
|
|
190299
190454
|
}
|
|
190300
190455
|
function convertNode(node, raw) {
|
|
190301
|
-
if (
|
|
190456
|
+
if (import_typescript8.default.isIdentifier(node)) {
|
|
190302
190457
|
return { kind: "identifier", name: node.text };
|
|
190303
190458
|
}
|
|
190304
|
-
if (
|
|
190459
|
+
if (import_typescript8.default.isStringLiteral(node)) {
|
|
190305
190460
|
return { kind: "literal", value: node.text, literalType: "string" };
|
|
190306
190461
|
}
|
|
190307
|
-
if (
|
|
190462
|
+
if (import_typescript8.default.isNumericLiteral(node)) {
|
|
190308
190463
|
const value = parseFloat(node.text);
|
|
190309
190464
|
return { kind: "literal", value, literalType: "number" };
|
|
190310
190465
|
}
|
|
190311
|
-
if (node.kind ===
|
|
190466
|
+
if (node.kind === import_typescript8.default.SyntaxKind.TrueKeyword) {
|
|
190312
190467
|
return { kind: "literal", value: true, literalType: "boolean" };
|
|
190313
190468
|
}
|
|
190314
|
-
if (node.kind ===
|
|
190469
|
+
if (node.kind === import_typescript8.default.SyntaxKind.FalseKeyword) {
|
|
190315
190470
|
return { kind: "literal", value: false, literalType: "boolean" };
|
|
190316
190471
|
}
|
|
190317
|
-
if (node.kind ===
|
|
190472
|
+
if (node.kind === import_typescript8.default.SyntaxKind.NullKeyword) {
|
|
190318
190473
|
return { kind: "literal", value: null, literalType: "null" };
|
|
190319
190474
|
}
|
|
190320
|
-
if (
|
|
190475
|
+
if (import_typescript8.default.isCallExpression(node)) {
|
|
190321
190476
|
const callee = convertNode(node.expression, raw);
|
|
190322
190477
|
const args = node.arguments.map((arg) => convertNode(arg, raw));
|
|
190323
190478
|
if (callee.kind === "member" && ["filter", "every", "some", "find", "findIndex", "findLast", "findLastIndex"].includes(callee.property)) {
|
|
@@ -190397,57 +190552,57 @@ function convertNode(node, raw) {
|
|
|
190397
190552
|
}
|
|
190398
190553
|
return { kind: "call", callee, args };
|
|
190399
190554
|
}
|
|
190400
|
-
if (
|
|
190555
|
+
if (import_typescript8.default.isArrayLiteralExpression(node)) {
|
|
190401
190556
|
const elements = node.elements.map((el) => convertNode(el, raw));
|
|
190402
190557
|
return { kind: "array-literal", elements };
|
|
190403
190558
|
}
|
|
190404
|
-
if (
|
|
190559
|
+
if (import_typescript8.default.isPropertyAccessExpression(node)) {
|
|
190405
190560
|
const object = convertNode(node.expression, raw);
|
|
190406
190561
|
const property = node.name.text;
|
|
190407
190562
|
return { kind: "member", object, property, computed: false };
|
|
190408
190563
|
}
|
|
190409
|
-
if (
|
|
190564
|
+
if (import_typescript8.default.isElementAccessExpression(node)) {
|
|
190410
190565
|
const object = convertNode(node.expression, raw);
|
|
190411
190566
|
const argNode = node.argumentExpression;
|
|
190412
|
-
if (
|
|
190567
|
+
if (import_typescript8.default.isNumericLiteral(argNode)) {
|
|
190413
190568
|
return { kind: "member", object, property: argNode.text, computed: true };
|
|
190414
190569
|
}
|
|
190415
|
-
if (
|
|
190570
|
+
if (import_typescript8.default.isStringLiteral(argNode)) {
|
|
190416
190571
|
return { kind: "member", object, property: argNode.text, computed: true };
|
|
190417
190572
|
}
|
|
190418
190573
|
return { kind: "unsupported", raw, reason: "Complex computed property access" };
|
|
190419
190574
|
}
|
|
190420
|
-
if (
|
|
190575
|
+
if (import_typescript8.default.isBinaryExpression(node)) {
|
|
190421
190576
|
const left = convertNode(node.left, raw);
|
|
190422
190577
|
const right = convertNode(node.right, raw);
|
|
190423
190578
|
const opToken = node.operatorToken;
|
|
190424
|
-
if (opToken.kind ===
|
|
190579
|
+
if (opToken.kind === import_typescript8.default.SyntaxKind.AmpersandAmpersandToken) {
|
|
190425
190580
|
return { kind: "logical", op: "&&", left, right };
|
|
190426
190581
|
}
|
|
190427
|
-
if (opToken.kind ===
|
|
190582
|
+
if (opToken.kind === import_typescript8.default.SyntaxKind.BarBarToken) {
|
|
190428
190583
|
return { kind: "logical", op: "||", left, right };
|
|
190429
190584
|
}
|
|
190430
|
-
if (opToken.kind ===
|
|
190585
|
+
if (opToken.kind === import_typescript8.default.SyntaxKind.QuestionQuestionToken) {
|
|
190431
190586
|
return { kind: "logical", op: "??", left, right };
|
|
190432
190587
|
}
|
|
190433
190588
|
const op = getOperatorString(opToken.kind);
|
|
190434
190589
|
return { kind: "binary", op, left, right };
|
|
190435
190590
|
}
|
|
190436
|
-
if (
|
|
190591
|
+
if (import_typescript8.default.isPrefixUnaryExpression(node)) {
|
|
190437
190592
|
const argument = convertNode(node.operand, raw);
|
|
190438
190593
|
const op = getUnaryOperatorString(node.operator);
|
|
190439
190594
|
return { kind: "unary", op, argument };
|
|
190440
190595
|
}
|
|
190441
|
-
if (
|
|
190596
|
+
if (import_typescript8.default.isConditionalExpression(node)) {
|
|
190442
190597
|
const test = convertNode(node.condition, raw);
|
|
190443
190598
|
const consequent = convertNode(node.whenTrue, raw);
|
|
190444
190599
|
const alternate = convertNode(node.whenFalse, raw);
|
|
190445
190600
|
return { kind: "conditional", test, consequent, alternate };
|
|
190446
190601
|
}
|
|
190447
|
-
if (
|
|
190602
|
+
if (import_typescript8.default.isParenthesizedExpression(node)) {
|
|
190448
190603
|
return convertNode(node.expression, raw);
|
|
190449
190604
|
}
|
|
190450
|
-
if (
|
|
190605
|
+
if (import_typescript8.default.isTemplateExpression(node)) {
|
|
190451
190606
|
const parts = [];
|
|
190452
190607
|
if (node.head.text) {
|
|
190453
190608
|
parts.push({ type: "string", value: node.head.text });
|
|
@@ -190460,19 +190615,19 @@ function convertNode(node, raw) {
|
|
|
190460
190615
|
}
|
|
190461
190616
|
return { kind: "template-literal", parts };
|
|
190462
190617
|
}
|
|
190463
|
-
if (
|
|
190618
|
+
if (import_typescript8.default.isNoSubstitutionTemplateLiteral(node)) {
|
|
190464
190619
|
return { kind: "literal", value: node.text, literalType: "string" };
|
|
190465
190620
|
}
|
|
190466
|
-
if (
|
|
190621
|
+
if (import_typescript8.default.isArrowFunction(node)) {
|
|
190467
190622
|
if (node.parameters.length !== 1) {
|
|
190468
190623
|
return { kind: "unsupported", raw, reason: "Only single parameter arrow functions are supported" };
|
|
190469
190624
|
}
|
|
190470
190625
|
const param = node.parameters[0];
|
|
190471
|
-
if (
|
|
190626
|
+
if (import_typescript8.default.isBlock(node.body)) {
|
|
190472
190627
|
return { kind: "unsupported", raw, reason: "Block body arrow functions are not supported" };
|
|
190473
190628
|
}
|
|
190474
190629
|
const body = convertNode(node.body, raw);
|
|
190475
|
-
if (
|
|
190630
|
+
if (import_typescript8.default.isObjectBindingPattern(param.name)) {
|
|
190476
190631
|
const fieldMap = new Map;
|
|
190477
190632
|
const excludedTopKeys = new Set;
|
|
190478
190633
|
const collect = collectDestructureBindings(param.name, [], fieldMap, raw, excludedTopKeys);
|
|
@@ -190513,21 +190668,21 @@ function convertNode(node, raw) {
|
|
|
190513
190668
|
const rewritten = substituteDestructuredFields(body, fieldMap, syntheticParam, restName);
|
|
190514
190669
|
return { kind: "arrow-fn", param: syntheticParam, body: rewritten };
|
|
190515
190670
|
}
|
|
190516
|
-
if (!
|
|
190671
|
+
if (!import_typescript8.default.isIdentifier(param.name)) {
|
|
190517
190672
|
return { kind: "unsupported", raw, reason: "Destructuring parameters are not supported" };
|
|
190518
190673
|
}
|
|
190519
190674
|
return { kind: "arrow-fn", param: param.name.text, body };
|
|
190520
190675
|
}
|
|
190521
|
-
if (
|
|
190676
|
+
if (import_typescript8.default.isFunctionExpression(node)) {
|
|
190522
190677
|
if (node.parameters.length !== 1) {
|
|
190523
190678
|
return { kind: "unsupported", raw, reason: "Only single-parameter function expressions are supported" };
|
|
190524
190679
|
}
|
|
190525
190680
|
const param = node.parameters[0];
|
|
190526
|
-
if (!
|
|
190681
|
+
if (!import_typescript8.default.isIdentifier(param.name)) {
|
|
190527
190682
|
return { kind: "unsupported", raw, reason: "Destructured params in function expressions are not supported" };
|
|
190528
190683
|
}
|
|
190529
190684
|
const stmts = node.body.statements;
|
|
190530
|
-
if (stmts.length !== 1 || !
|
|
190685
|
+
if (stmts.length !== 1 || !import_typescript8.default.isReturnStatement(stmts[0]) || !stmts[0].expression) {
|
|
190531
190686
|
return { kind: "unsupported", raw, reason: "Function expressions must be `function (x) { return <expr> }`" };
|
|
190532
190687
|
}
|
|
190533
190688
|
return {
|
|
@@ -190536,35 +190691,35 @@ function convertNode(node, raw) {
|
|
|
190536
190691
|
body: convertNode(stmts[0].expression, raw)
|
|
190537
190692
|
};
|
|
190538
190693
|
}
|
|
190539
|
-
return { kind: "unsupported", raw, reason: `Unsupported syntax: ${
|
|
190694
|
+
return { kind: "unsupported", raw, reason: `Unsupported syntax: ${import_typescript8.default.SyntaxKind[node.kind]}` };
|
|
190540
190695
|
}
|
|
190541
190696
|
function extractSortComparatorFromTS(node, method) {
|
|
190542
|
-
if (!
|
|
190697
|
+
if (!import_typescript8.default.isArrowFunction(node) && !import_typescript8.default.isFunctionExpression(node))
|
|
190543
190698
|
return null;
|
|
190544
190699
|
if (node.parameters.length !== 2)
|
|
190545
190700
|
return null;
|
|
190546
190701
|
const pA = node.parameters[0];
|
|
190547
190702
|
const pB = node.parameters[1];
|
|
190548
|
-
if (!
|
|
190703
|
+
if (!import_typescript8.default.isIdentifier(pA.name) || !import_typescript8.default.isIdentifier(pB.name))
|
|
190549
190704
|
return null;
|
|
190550
190705
|
const paramA = pA.name.text;
|
|
190551
190706
|
const paramB = pB.name.text;
|
|
190552
190707
|
let body;
|
|
190553
|
-
if (
|
|
190554
|
-
if (
|
|
190708
|
+
if (import_typescript8.default.isArrowFunction(node)) {
|
|
190709
|
+
if (import_typescript8.default.isBlock(node.body))
|
|
190555
190710
|
return null;
|
|
190556
190711
|
body = node.body;
|
|
190557
190712
|
} else {
|
|
190558
190713
|
const stmts = node.body.statements;
|
|
190559
|
-
if (stmts.length !== 1 || !
|
|
190714
|
+
if (stmts.length !== 1 || !import_typescript8.default.isReturnStatement(stmts[0]) || !stmts[0].expression)
|
|
190560
190715
|
return null;
|
|
190561
190716
|
body = stmts[0].expression;
|
|
190562
190717
|
}
|
|
190563
190718
|
const raw = body.getText();
|
|
190564
|
-
if (
|
|
190719
|
+
if (import_typescript8.default.isBinaryExpression(body) && body.operatorToken.kind === import_typescript8.default.SyntaxKind.MinusToken) {
|
|
190565
190720
|
return classifyComparatorOperands(body.left, body.right, paramA, paramB, "numeric", method, raw);
|
|
190566
190721
|
}
|
|
190567
|
-
if (
|
|
190722
|
+
if (import_typescript8.default.isCallExpression(body) && import_typescript8.default.isPropertyAccessExpression(body.expression) && body.expression.name.text === "localeCompare" && body.arguments.length === 1) {
|
|
190568
190723
|
return classifyComparatorOperands(body.expression.expression, body.arguments[0], paramA, paramB, "string", method, raw);
|
|
190569
190724
|
}
|
|
190570
190725
|
return null;
|
|
@@ -190593,14 +190748,14 @@ function classifyComparatorOperands(left, right, paramA, paramB, type2, method,
|
|
|
190593
190748
|
};
|
|
190594
190749
|
}
|
|
190595
190750
|
function classifySortOperand(expr, paramA, paramB) {
|
|
190596
|
-
if (
|
|
190751
|
+
if (import_typescript8.default.isIdentifier(expr)) {
|
|
190597
190752
|
if (expr.text === paramA)
|
|
190598
190753
|
return { key: { kind: "self" }, param: "A" };
|
|
190599
190754
|
if (expr.text === paramB)
|
|
190600
190755
|
return { key: { kind: "self" }, param: "B" };
|
|
190601
190756
|
return null;
|
|
190602
190757
|
}
|
|
190603
|
-
if (
|
|
190758
|
+
if (import_typescript8.default.isPropertyAccessExpression(expr) && import_typescript8.default.isIdentifier(expr.expression)) {
|
|
190604
190759
|
if (expr.expression.text === paramA) {
|
|
190605
190760
|
return { key: { kind: "field", field: expr.name.text }, param: "A" };
|
|
190606
190761
|
}
|
|
@@ -190613,24 +190768,24 @@ function classifySortOperand(expr, paramA, paramB) {
|
|
|
190613
190768
|
function collectDestructureBindings(pattern, pathPrefix, fieldMap, raw, excludedTopKeys) {
|
|
190614
190769
|
let restName;
|
|
190615
190770
|
for (const el of pattern.elements) {
|
|
190616
|
-
if (!
|
|
190771
|
+
if (!import_typescript8.default.isBindingElement(el)) {
|
|
190617
190772
|
return { ok: false, reason: "Unsupported binding element in destructured filter param" };
|
|
190618
190773
|
}
|
|
190619
190774
|
if (el.dotDotDotToken) {
|
|
190620
190775
|
if (pathPrefix.length > 0) {
|
|
190621
190776
|
return { ok: false, reason: "Rest patterns at nested destructure levels are not supported" };
|
|
190622
190777
|
}
|
|
190623
|
-
if (!
|
|
190778
|
+
if (!import_typescript8.default.isIdentifier(el.name)) {
|
|
190624
190779
|
return { ok: false, reason: "Rest patterns must bind to a simple identifier" };
|
|
190625
190780
|
}
|
|
190626
190781
|
restName = el.name.text;
|
|
190627
190782
|
continue;
|
|
190628
190783
|
}
|
|
190629
|
-
if (
|
|
190784
|
+
if (import_typescript8.default.isObjectBindingPattern(el.name)) {
|
|
190630
190785
|
if (el.initializer) {
|
|
190631
190786
|
return { ok: false, reason: "Default values on a nested-pattern slot in destructured filter param are not supported" };
|
|
190632
190787
|
}
|
|
190633
|
-
if (!el.propertyName || !
|
|
190788
|
+
if (!el.propertyName || !import_typescript8.default.isIdentifier(el.propertyName)) {
|
|
190634
190789
|
return { ok: false, reason: "Non-identifier (computed/string/numeric) keys in destructured filter param are not supported" };
|
|
190635
190790
|
}
|
|
190636
190791
|
if (excludedTopKeys && pathPrefix.length === 0) {
|
|
@@ -190641,12 +190796,12 @@ function collectDestructureBindings(pattern, pathPrefix, fieldMap, raw, excluded
|
|
|
190641
190796
|
return inner;
|
|
190642
190797
|
continue;
|
|
190643
190798
|
}
|
|
190644
|
-
if (!
|
|
190799
|
+
if (!import_typescript8.default.isIdentifier(el.name)) {
|
|
190645
190800
|
return { ok: false, reason: "Array binding patterns in destructured filter param are not supported" };
|
|
190646
190801
|
}
|
|
190647
190802
|
let fieldName;
|
|
190648
190803
|
if (el.propertyName) {
|
|
190649
|
-
if (!
|
|
190804
|
+
if (!import_typescript8.default.isIdentifier(el.propertyName)) {
|
|
190650
190805
|
return { ok: false, reason: "Non-identifier (computed/string/numeric) keys in destructured filter param are not supported" };
|
|
190651
190806
|
}
|
|
190652
190807
|
fieldName = el.propertyName.text;
|
|
@@ -190928,31 +191083,31 @@ function substituteDestructuredFields(expr, fieldMap, syntheticParam, restName)
|
|
|
190928
191083
|
}
|
|
190929
191084
|
function getOperatorString(kind) {
|
|
190930
191085
|
switch (kind) {
|
|
190931
|
-
case
|
|
191086
|
+
case import_typescript8.default.SyntaxKind.EqualsEqualsToken:
|
|
190932
191087
|
return "==";
|
|
190933
|
-
case
|
|
191088
|
+
case import_typescript8.default.SyntaxKind.EqualsEqualsEqualsToken:
|
|
190934
191089
|
return "===";
|
|
190935
|
-
case
|
|
191090
|
+
case import_typescript8.default.SyntaxKind.ExclamationEqualsToken:
|
|
190936
191091
|
return "!=";
|
|
190937
|
-
case
|
|
191092
|
+
case import_typescript8.default.SyntaxKind.ExclamationEqualsEqualsToken:
|
|
190938
191093
|
return "!==";
|
|
190939
|
-
case
|
|
191094
|
+
case import_typescript8.default.SyntaxKind.GreaterThanToken:
|
|
190940
191095
|
return ">";
|
|
190941
|
-
case
|
|
191096
|
+
case import_typescript8.default.SyntaxKind.LessThanToken:
|
|
190942
191097
|
return "<";
|
|
190943
|
-
case
|
|
191098
|
+
case import_typescript8.default.SyntaxKind.GreaterThanEqualsToken:
|
|
190944
191099
|
return ">=";
|
|
190945
|
-
case
|
|
191100
|
+
case import_typescript8.default.SyntaxKind.LessThanEqualsToken:
|
|
190946
191101
|
return "<=";
|
|
190947
|
-
case
|
|
191102
|
+
case import_typescript8.default.SyntaxKind.PlusToken:
|
|
190948
191103
|
return "+";
|
|
190949
|
-
case
|
|
191104
|
+
case import_typescript8.default.SyntaxKind.MinusToken:
|
|
190950
191105
|
return "-";
|
|
190951
|
-
case
|
|
191106
|
+
case import_typescript8.default.SyntaxKind.AsteriskToken:
|
|
190952
191107
|
return "*";
|
|
190953
|
-
case
|
|
191108
|
+
case import_typescript8.default.SyntaxKind.SlashToken:
|
|
190954
191109
|
return "/";
|
|
190955
|
-
case
|
|
191110
|
+
case import_typescript8.default.SyntaxKind.PercentToken:
|
|
190956
191111
|
return "%";
|
|
190957
191112
|
default:
|
|
190958
191113
|
return "unknown";
|
|
@@ -190960,13 +191115,13 @@ function getOperatorString(kind) {
|
|
|
190960
191115
|
}
|
|
190961
191116
|
function getUnaryOperatorString(op) {
|
|
190962
191117
|
switch (op) {
|
|
190963
|
-
case
|
|
191118
|
+
case import_typescript8.default.SyntaxKind.ExclamationToken:
|
|
190964
191119
|
return "!";
|
|
190965
|
-
case
|
|
191120
|
+
case import_typescript8.default.SyntaxKind.MinusToken:
|
|
190966
191121
|
return "-";
|
|
190967
|
-
case
|
|
191122
|
+
case import_typescript8.default.SyntaxKind.PlusToken:
|
|
190968
191123
|
return "+";
|
|
190969
|
-
case
|
|
191124
|
+
case import_typescript8.default.SyntaxKind.TildeToken:
|
|
190970
191125
|
return "~";
|
|
190971
191126
|
default:
|
|
190972
191127
|
return "unknown";
|
|
@@ -191163,9 +191318,9 @@ function parseBlockBody(block, sourceFile, getJS) {
|
|
|
191163
191318
|
return statements;
|
|
191164
191319
|
}
|
|
191165
191320
|
function parseStatement(stmt, sourceFile, getJS) {
|
|
191166
|
-
if (
|
|
191321
|
+
if (import_typescript8.default.isVariableStatement(stmt)) {
|
|
191167
191322
|
const decl = stmt.declarationList.declarations[0];
|
|
191168
|
-
if (!decl || !
|
|
191323
|
+
if (!decl || !import_typescript8.default.isIdentifier(decl.name) || !decl.initializer) {
|
|
191169
191324
|
return null;
|
|
191170
191325
|
}
|
|
191171
191326
|
const name = decl.name.text;
|
|
@@ -191176,7 +191331,7 @@ function parseStatement(stmt, sourceFile, getJS) {
|
|
|
191176
191331
|
}
|
|
191177
191332
|
return { kind: "var-decl", name, init };
|
|
191178
191333
|
}
|
|
191179
|
-
if (
|
|
191334
|
+
if (import_typescript8.default.isReturnStatement(stmt)) {
|
|
191180
191335
|
if (!stmt.expression) {
|
|
191181
191336
|
return { kind: "return", value: { kind: "literal", value: true, literalType: "boolean" } };
|
|
191182
191337
|
}
|
|
@@ -191187,7 +191342,7 @@ function parseStatement(stmt, sourceFile, getJS) {
|
|
|
191187
191342
|
}
|
|
191188
191343
|
return { kind: "return", value };
|
|
191189
191344
|
}
|
|
191190
|
-
if (
|
|
191345
|
+
if (import_typescript8.default.isIfStatement(stmt)) {
|
|
191191
191346
|
const conditionText = getJS(stmt.expression);
|
|
191192
191347
|
const condition = parseExpression(conditionText);
|
|
191193
191348
|
if (condition.kind === "unsupported") {
|
|
@@ -191199,7 +191354,7 @@ function parseStatement(stmt, sourceFile, getJS) {
|
|
|
191199
191354
|
}
|
|
191200
191355
|
let alternate;
|
|
191201
191356
|
if (stmt.elseStatement) {
|
|
191202
|
-
if (
|
|
191357
|
+
if (import_typescript8.default.isIfStatement(stmt.elseStatement)) {
|
|
191203
191358
|
const elseIf = parseStatement(stmt.elseStatement, sourceFile, getJS);
|
|
191204
191359
|
if (elseIf === null) {
|
|
191205
191360
|
return null;
|
|
@@ -191218,7 +191373,7 @@ function parseStatement(stmt, sourceFile, getJS) {
|
|
|
191218
191373
|
return null;
|
|
191219
191374
|
}
|
|
191220
191375
|
function parseIfBranch(branch, sourceFile, getJS) {
|
|
191221
|
-
if (
|
|
191376
|
+
if (import_typescript8.default.isBlock(branch)) {
|
|
191222
191377
|
return parseBlockBody(branch, sourceFile, getJS);
|
|
191223
191378
|
}
|
|
191224
191379
|
const parsed = parseStatement(branch, sourceFile, getJS);
|
|
@@ -191229,7 +191384,7 @@ function parseIfBranch(branch, sourceFile, getJS) {
|
|
|
191229
191384
|
}
|
|
191230
191385
|
|
|
191231
191386
|
// ../jsx/src/reactivity-checker.ts
|
|
191232
|
-
var
|
|
191387
|
+
var import_typescript9 = __toESM(require_typescript(), 1);
|
|
191233
191388
|
var REACTIVE_BRAND = "__reactive";
|
|
191234
191389
|
function queryType(checker, node) {
|
|
191235
191390
|
incrementCounter("typeCheckerQueries");
|
|
@@ -191247,7 +191402,7 @@ function safeGetText(node) {
|
|
|
191247
191402
|
}
|
|
191248
191403
|
}
|
|
191249
191404
|
function analyze(node, checker) {
|
|
191250
|
-
if (
|
|
191405
|
+
if (import_typescript9.default.isPropertyAccessExpression(node)) {
|
|
191251
191406
|
try {
|
|
191252
191407
|
const type2 = queryType(checker, node);
|
|
191253
191408
|
if (isReactiveType(type2)) {
|
|
@@ -191271,7 +191426,7 @@ function analyze(node, checker) {
|
|
|
191271
191426
|
}
|
|
191272
191427
|
return NOT_REACTIVE;
|
|
191273
191428
|
}
|
|
191274
|
-
if (
|
|
191429
|
+
if (import_typescript9.default.isIdentifier(node)) {
|
|
191275
191430
|
try {
|
|
191276
191431
|
const type2 = queryType(checker, node);
|
|
191277
191432
|
if (isReactiveType(type2)) {
|
|
@@ -191283,7 +191438,7 @@ function analyze(node, checker) {
|
|
|
191283
191438
|
} catch {}
|
|
191284
191439
|
return NOT_REACTIVE;
|
|
191285
191440
|
}
|
|
191286
|
-
if (
|
|
191441
|
+
if (import_typescript9.default.isCallExpression(node)) {
|
|
191287
191442
|
try {
|
|
191288
191443
|
const calleeType = queryType(checker, node.expression);
|
|
191289
191444
|
if (isReactiveType(calleeType)) {
|
|
@@ -191296,7 +191451,7 @@ function analyze(node, checker) {
|
|
|
191296
191451
|
}
|
|
191297
191452
|
let foundChild;
|
|
191298
191453
|
let foundChildText = "";
|
|
191299
|
-
|
|
191454
|
+
import_typescript9.default.forEachChild(node, (child) => {
|
|
191300
191455
|
if (foundChild?.isReactive)
|
|
191301
191456
|
return;
|
|
191302
191457
|
const result = analyze(child, checker);
|
|
@@ -191325,7 +191480,7 @@ function containsReactiveExpression(node, checker) {
|
|
|
191325
191480
|
}
|
|
191326
191481
|
|
|
191327
191482
|
// ../jsx/src/free-refs.ts
|
|
191328
|
-
var
|
|
191483
|
+
var import_typescript10 = __toESM(require_typescript(), 1);
|
|
191329
191484
|
var _bindingMapCache = new WeakMap;
|
|
191330
191485
|
function buildBindingMap(env) {
|
|
191331
191486
|
const cached = _bindingMapCache.get(env);
|
|
@@ -191393,20 +191548,20 @@ function defaultBindingScope(kind) {
|
|
|
191393
191548
|
function collectIdentifiers2(node) {
|
|
191394
191549
|
const out = [];
|
|
191395
191550
|
const visit2 = (n, parent) => {
|
|
191396
|
-
if (
|
|
191397
|
-
if (parent &&
|
|
191551
|
+
if (import_typescript10.default.isIdentifier(n)) {
|
|
191552
|
+
if (parent && import_typescript10.default.isPropertyAccessExpression(parent) && parent.name === n)
|
|
191398
191553
|
return;
|
|
191399
|
-
if (parent &&
|
|
191554
|
+
if (parent && import_typescript10.default.isPropertyAssignment(parent) && parent.name === n)
|
|
191400
191555
|
return;
|
|
191401
|
-
if (parent && (
|
|
191556
|
+
if (parent && (import_typescript10.default.isJsxOpeningElement(parent) || import_typescript10.default.isJsxClosingElement(parent) || import_typescript10.default.isJsxSelfClosingElement(parent)) && parent.tagName === n) {
|
|
191402
191557
|
return;
|
|
191403
191558
|
}
|
|
191404
|
-
if (parent &&
|
|
191559
|
+
if (parent && import_typescript10.default.isJsxAttribute(parent) && parent.name === n)
|
|
191405
191560
|
return;
|
|
191406
191561
|
out.push(n);
|
|
191407
191562
|
return;
|
|
191408
191563
|
}
|
|
191409
|
-
|
|
191564
|
+
import_typescript10.default.forEachChild(n, (child) => visit2(child, n));
|
|
191410
191565
|
};
|
|
191411
191566
|
visit2(node);
|
|
191412
191567
|
return out;
|
|
@@ -191415,7 +191570,7 @@ function collectReactiveBrandRefs(node, checker) {
|
|
|
191415
191570
|
const out = [];
|
|
191416
191571
|
const seen = new Set;
|
|
191417
191572
|
const visit2 = (n) => {
|
|
191418
|
-
if (
|
|
191573
|
+
if (import_typescript10.default.isPropertyAccessExpression(n)) {
|
|
191419
191574
|
try {
|
|
191420
191575
|
const type2 = checker.getTypeAtLocation(n);
|
|
191421
191576
|
if (isReactiveType(type2)) {
|
|
@@ -191433,7 +191588,7 @@ function collectReactiveBrandRefs(node, checker) {
|
|
|
191433
191588
|
incrementCounter("freeRefsTypeLookupFailures");
|
|
191434
191589
|
}
|
|
191435
191590
|
}
|
|
191436
|
-
|
|
191591
|
+
import_typescript10.default.forEachChild(n, visit2);
|
|
191437
191592
|
};
|
|
191438
191593
|
visit2(node);
|
|
191439
191594
|
return out;
|
|
@@ -191443,14 +191598,14 @@ function resolveConstantInitializerRefs(c, env, visited) {
|
|
|
191443
191598
|
return [];
|
|
191444
191599
|
if (c.containsArrow)
|
|
191445
191600
|
return [];
|
|
191446
|
-
const sf =
|
|
191601
|
+
const sf = import_typescript10.default.createSourceFile("__const_init.ts", `const __probe = (${c.value});`, import_typescript10.default.ScriptTarget.Latest, true);
|
|
191447
191602
|
const stmt = sf.statements[0];
|
|
191448
|
-
if (!stmt || !
|
|
191603
|
+
if (!stmt || !import_typescript10.default.isVariableStatement(stmt))
|
|
191449
191604
|
return [];
|
|
191450
191605
|
const decl = stmt.declarationList.declarations[0];
|
|
191451
191606
|
if (!decl || !decl.initializer)
|
|
191452
191607
|
return [];
|
|
191453
|
-
const expr =
|
|
191608
|
+
const expr = import_typescript10.default.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
191454
191609
|
return resolveFreeRefsInternal(expr, env, visited);
|
|
191455
191610
|
}
|
|
191456
191611
|
function resolveFreeRefsInternal(node, env, visited) {
|
|
@@ -191462,7 +191617,7 @@ function resolveFreeRefsInternal(node, env, visited) {
|
|
|
191462
191617
|
const name = ident.text;
|
|
191463
191618
|
if (env.propsObjectName === name) {
|
|
191464
191619
|
const parent = ident.parent;
|
|
191465
|
-
if (parent &&
|
|
191620
|
+
if (parent && import_typescript10.default.isPropertyAccessExpression(parent) && parent.expression === ident && parent.name.text === "children") {
|
|
191466
191621
|
continue;
|
|
191467
191622
|
}
|
|
191468
191623
|
}
|
|
@@ -191548,13 +191703,13 @@ function exprCallsReactiveGetters(expr, ctx) {
|
|
|
191548
191703
|
function visit2(n) {
|
|
191549
191704
|
if (found)
|
|
191550
191705
|
return;
|
|
191551
|
-
if (
|
|
191706
|
+
if (import_typescript11.default.isCallExpression(n) && import_typescript11.default.isIdentifier(n.expression)) {
|
|
191552
191707
|
if (names.has(n.expression.text)) {
|
|
191553
191708
|
found = true;
|
|
191554
191709
|
return;
|
|
191555
191710
|
}
|
|
191556
191711
|
}
|
|
191557
|
-
|
|
191712
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191558
191713
|
}
|
|
191559
191714
|
visit2(expr);
|
|
191560
191715
|
return found;
|
|
@@ -191581,11 +191736,11 @@ function exprReferencesModuleClientSignal(expr, ctx) {
|
|
|
191581
191736
|
function visit2(n) {
|
|
191582
191737
|
if (found)
|
|
191583
191738
|
return;
|
|
191584
|
-
if (
|
|
191739
|
+
if (import_typescript11.default.isCallExpression(n) && import_typescript11.default.isIdentifier(n.expression) && names.has(n.expression.text)) {
|
|
191585
191740
|
found = true;
|
|
191586
191741
|
return;
|
|
191587
191742
|
}
|
|
191588
|
-
|
|
191743
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191589
191744
|
}
|
|
191590
191745
|
visit2(expr);
|
|
191591
191746
|
return found;
|
|
@@ -191595,11 +191750,11 @@ function exprHasFunctionCalls(expr) {
|
|
|
191595
191750
|
function visit2(n) {
|
|
191596
191751
|
if (found)
|
|
191597
191752
|
return;
|
|
191598
|
-
if (
|
|
191753
|
+
if (import_typescript11.default.isCallExpression(n)) {
|
|
191599
191754
|
found = true;
|
|
191600
191755
|
return;
|
|
191601
191756
|
}
|
|
191602
|
-
|
|
191757
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191603
191758
|
}
|
|
191604
191759
|
visit2(expr);
|
|
191605
191760
|
return found;
|
|
@@ -191618,10 +191773,10 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
191618
191773
|
return;
|
|
191619
191774
|
let acc;
|
|
191620
191775
|
function visit2(n, parent) {
|
|
191621
|
-
if (
|
|
191622
|
-
const isObjectKey = parent &&
|
|
191623
|
-
const isShorthand = parent &&
|
|
191624
|
-
const isAccessName = parent &&
|
|
191776
|
+
if (import_typescript11.default.isIdentifier(n) && propDepsMap.has(n.text)) {
|
|
191777
|
+
const isObjectKey = parent && import_typescript11.default.isPropertyAssignment(parent) && parent.name === n;
|
|
191778
|
+
const isShorthand = parent && import_typescript11.default.isShorthandPropertyAssignment(parent) && parent.name === n;
|
|
191779
|
+
const isAccessName = parent && import_typescript11.default.isPropertyAccessExpression(parent) && parent.name === n;
|
|
191625
191780
|
if (!isObjectKey && !isShorthand && !isAccessName) {
|
|
191626
191781
|
const deps = propDepsMap.get(n.text);
|
|
191627
191782
|
if (deps && deps.size > 0) {
|
|
@@ -191632,7 +191787,7 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
191632
191787
|
}
|
|
191633
191788
|
}
|
|
191634
191789
|
}
|
|
191635
|
-
|
|
191790
|
+
import_typescript11.default.forEachChild(n, (child) => visit2(child, n));
|
|
191636
191791
|
}
|
|
191637
191792
|
visit2(node);
|
|
191638
191793
|
return acc;
|
|
@@ -191699,21 +191854,21 @@ function createTransformContext(analyzer) {
|
|
|
191699
191854
|
function buildComponentNamespaces(ctx) {
|
|
191700
191855
|
const result = new Map;
|
|
191701
191856
|
for (const stmt of ctx.sourceFile.statements) {
|
|
191702
|
-
if (!
|
|
191857
|
+
if (!import_typescript11.default.isVariableStatement(stmt))
|
|
191703
191858
|
continue;
|
|
191704
191859
|
for (const decl of stmt.declarationList.declarations) {
|
|
191705
|
-
if (!decl.initializer || !
|
|
191860
|
+
if (!decl.initializer || !import_typescript11.default.isIdentifier(decl.name))
|
|
191706
191861
|
continue;
|
|
191707
191862
|
let init = decl.initializer;
|
|
191708
|
-
while (
|
|
191863
|
+
while (import_typescript11.default.isParenthesizedExpression(init))
|
|
191709
191864
|
init = init.expression;
|
|
191710
|
-
if (!
|
|
191865
|
+
if (!import_typescript11.default.isObjectLiteralExpression(init))
|
|
191711
191866
|
continue;
|
|
191712
191867
|
const members = new Map;
|
|
191713
191868
|
for (const prop of init.properties) {
|
|
191714
|
-
if (
|
|
191869
|
+
if (import_typescript11.default.isShorthandPropertyAssignment(prop)) {
|
|
191715
191870
|
members.set(prop.name.text, prop.name.text);
|
|
191716
|
-
} else if (
|
|
191871
|
+
} else if (import_typescript11.default.isPropertyAssignment(prop) && (import_typescript11.default.isIdentifier(prop.name) || import_typescript11.default.isStringLiteral(prop.name)) && import_typescript11.default.isIdentifier(prop.initializer)) {
|
|
191717
191872
|
members.set(prop.name.text, prop.initializer.text);
|
|
191718
191873
|
}
|
|
191719
191874
|
}
|
|
@@ -191725,11 +191880,11 @@ function buildComponentNamespaces(ctx) {
|
|
|
191725
191880
|
return result;
|
|
191726
191881
|
}
|
|
191727
191882
|
function resolveMemberExpressionTag(tagNode, ctx) {
|
|
191728
|
-
if (!
|
|
191883
|
+
if (!import_typescript11.default.isPropertyAccessExpression(tagNode))
|
|
191729
191884
|
return null;
|
|
191730
|
-
if (!
|
|
191885
|
+
if (!import_typescript11.default.isIdentifier(tagNode.expression))
|
|
191731
191886
|
return null;
|
|
191732
|
-
if (!
|
|
191887
|
+
if (!import_typescript11.default.isIdentifier(tagNode.name))
|
|
191733
191888
|
return null;
|
|
191734
191889
|
if (!ctx._componentNamespaces) {
|
|
191735
191890
|
ctx._componentNamespaces = buildComponentNamespaces(ctx);
|
|
@@ -191777,7 +191932,7 @@ function jsxToIR(analyzer) {
|
|
|
191777
191932
|
return null;
|
|
191778
191933
|
const ctx = createTransformContext(analyzer);
|
|
191779
191934
|
const jsxReturn = analyzer.jsxReturn;
|
|
191780
|
-
if (
|
|
191935
|
+
if (import_typescript11.default.isJsxElement(jsxReturn) || import_typescript11.default.isJsxSelfClosingElement(jsxReturn) || import_typescript11.default.isJsxFragment(jsxReturn)) {
|
|
191781
191936
|
const ir2 = transformNode(jsxReturn, ctx);
|
|
191782
191937
|
if (ir2 && needsScopeWrapper(ir2)) {
|
|
191783
191938
|
return wrapInScopeElement(ir2);
|
|
@@ -191833,22 +191988,22 @@ function wrapInScopeElement(node) {
|
|
|
191833
191988
|
};
|
|
191834
191989
|
}
|
|
191835
191990
|
function transformNode(node, ctx) {
|
|
191836
|
-
if (
|
|
191991
|
+
if (import_typescript11.default.isJsxElement(node)) {
|
|
191837
191992
|
return transformJsxElement(node, ctx);
|
|
191838
191993
|
}
|
|
191839
|
-
if (
|
|
191994
|
+
if (import_typescript11.default.isJsxSelfClosingElement(node)) {
|
|
191840
191995
|
return transformSelfClosingElement(node, ctx);
|
|
191841
191996
|
}
|
|
191842
|
-
if (
|
|
191997
|
+
if (import_typescript11.default.isJsxFragment(node)) {
|
|
191843
191998
|
return transformFragment(node, ctx);
|
|
191844
191999
|
}
|
|
191845
|
-
if (
|
|
192000
|
+
if (import_typescript11.default.isJsxText(node)) {
|
|
191846
192001
|
return transformText(node, ctx);
|
|
191847
192002
|
}
|
|
191848
|
-
if (
|
|
192003
|
+
if (import_typescript11.default.isJsxExpression(node)) {
|
|
191849
192004
|
return transformExpression(node, ctx);
|
|
191850
192005
|
}
|
|
191851
|
-
if (
|
|
192006
|
+
if (import_typescript11.default.isConditionalExpression(node)) {
|
|
191852
192007
|
return transformConditional(node, ctx);
|
|
191853
192008
|
}
|
|
191854
192009
|
return null;
|
|
@@ -192058,7 +192213,7 @@ function transformSelfClosingComponent(node, ctx, name) {
|
|
|
192058
192213
|
}
|
|
192059
192214
|
function isTransparentFragment(node, ctx) {
|
|
192060
192215
|
const children = node.children.filter((child2) => {
|
|
192061
|
-
if (
|
|
192216
|
+
if (import_typescript11.default.isJsxText(child2)) {
|
|
192062
192217
|
return child2.text.trim() !== "";
|
|
192063
192218
|
}
|
|
192064
192219
|
return true;
|
|
@@ -192066,7 +192221,7 @@ function isTransparentFragment(node, ctx) {
|
|
|
192066
192221
|
if (children.length !== 1)
|
|
192067
192222
|
return false;
|
|
192068
192223
|
const child = children[0];
|
|
192069
|
-
if (!
|
|
192224
|
+
if (!import_typescript11.default.isJsxExpression(child))
|
|
192070
192225
|
return false;
|
|
192071
192226
|
if (!child.expression)
|
|
192072
192227
|
return false;
|
|
@@ -192110,7 +192265,7 @@ function transformChildren(children, ctx) {
|
|
|
192110
192265
|
const result = [];
|
|
192111
192266
|
for (let i2 = 0;i2 < children.length; i2++) {
|
|
192112
192267
|
const child = children[i2];
|
|
192113
|
-
if (
|
|
192268
|
+
if (import_typescript11.default.isJsxExpression(child) && !child.expression) {
|
|
192114
192269
|
continue;
|
|
192115
192270
|
}
|
|
192116
192271
|
const transformed = transformNode(child, ctx);
|
|
@@ -192143,7 +192298,7 @@ function transformExpression(node, ctx) {
|
|
|
192143
192298
|
}
|
|
192144
192299
|
function transformExpressionInner(expr, ctx, node, isClientOnly) {
|
|
192145
192300
|
checkBareSignalOrMemoIdentifier(expr, ctx);
|
|
192146
|
-
if (
|
|
192301
|
+
if (import_typescript11.default.isIdentifier(expr)) {
|
|
192147
192302
|
const jsxNode = ctx.analyzer.jsxConstants.get(expr.text);
|
|
192148
192303
|
if (jsxNode) {
|
|
192149
192304
|
return transformNode(jsxNode, ctx);
|
|
@@ -192159,7 +192314,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
|
|
|
192159
192314
|
}
|
|
192160
192315
|
const ir = transformJsxExpression(expr, ctx, isClientOnly);
|
|
192161
192316
|
if (ir !== null) {
|
|
192162
|
-
if (isClientOnly && ir.type === "conditional") {
|
|
192317
|
+
if ((isClientOnly || shouldAutoDeferReactiveBrand(expr, ctx)) && ir.type === "conditional") {
|
|
192163
192318
|
ir.clientOnly = true;
|
|
192164
192319
|
if (!ir.slotId) {
|
|
192165
192320
|
ir.slotId = generateSlotId(ctx);
|
|
@@ -192417,21 +192572,21 @@ function transformLogicalAnd(node, ctx) {
|
|
|
192417
192572
|
};
|
|
192418
192573
|
}
|
|
192419
192574
|
function containsJsxInExpression(node) {
|
|
192420
|
-
if (
|
|
192575
|
+
if (import_typescript11.default.isJsxElement(node) || import_typescript11.default.isJsxSelfClosingElement(node) || import_typescript11.default.isJsxFragment(node)) {
|
|
192421
192576
|
return true;
|
|
192422
192577
|
}
|
|
192423
|
-
return
|
|
192578
|
+
return import_typescript11.default.forEachChild(node, containsJsxInExpression) ?? false;
|
|
192424
192579
|
}
|
|
192425
192580
|
function containsAwaitExpression(node) {
|
|
192426
|
-
if (
|
|
192581
|
+
if (import_typescript11.default.isAwaitExpression(node))
|
|
192427
192582
|
return true;
|
|
192428
|
-
if (
|
|
192583
|
+
if (import_typescript11.default.isFunctionDeclaration(node) || import_typescript11.default.isFunctionExpression(node) || import_typescript11.default.isArrowFunction(node))
|
|
192429
192584
|
return false;
|
|
192430
|
-
return
|
|
192585
|
+
return import_typescript11.default.forEachChild(node, containsAwaitExpression) ?? false;
|
|
192431
192586
|
}
|
|
192432
192587
|
function transformNullishCoalescing(node, ctx) {
|
|
192433
192588
|
const leftText = ctx.getJS(node.left);
|
|
192434
|
-
const isNullish = node.operatorToken.kind ===
|
|
192589
|
+
const isNullish = node.operatorToken.kind === import_typescript11.default.SyntaxKind.QuestionQuestionToken;
|
|
192435
192590
|
const condition = isNullish ? `${leftText} != null` : leftText;
|
|
192436
192591
|
const leftOrigin = {
|
|
192437
192592
|
phase: "tick",
|
|
@@ -192475,38 +192630,38 @@ function transformNullishCoalescing(node, ctx) {
|
|
|
192475
192630
|
origin: leftOrigin
|
|
192476
192631
|
};
|
|
192477
192632
|
}
|
|
192478
|
-
function
|
|
192633
|
+
function assertNever2(expr) {
|
|
192479
192634
|
const kind = expr?.kind;
|
|
192480
|
-
throw new Error(`transformJsxExpression: unhandled ts.SyntaxKind ${kind !== undefined ?
|
|
192635
|
+
throw new Error(`transformJsxExpression: unhandled ts.SyntaxKind ${kind !== undefined ? import_typescript11.default.SyntaxKind[kind] : "unknown"} ` + `(kind=${kind}). Update spec/compiler.md Appendix A and the switch in jsx-to-ir.ts.`);
|
|
192481
192636
|
}
|
|
192482
192637
|
function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
192483
192638
|
const node = expr;
|
|
192484
192639
|
switch (node.kind) {
|
|
192485
|
-
case
|
|
192486
|
-
case
|
|
192487
|
-
case
|
|
192488
|
-
case
|
|
192489
|
-
case
|
|
192490
|
-
case
|
|
192640
|
+
case import_typescript11.default.SyntaxKind.ParenthesizedExpression:
|
|
192641
|
+
case import_typescript11.default.SyntaxKind.AsExpression:
|
|
192642
|
+
case import_typescript11.default.SyntaxKind.SatisfiesExpression:
|
|
192643
|
+
case import_typescript11.default.SyntaxKind.NonNullExpression:
|
|
192644
|
+
case import_typescript11.default.SyntaxKind.TypeAssertionExpression:
|
|
192645
|
+
case import_typescript11.default.SyntaxKind.PartiallyEmittedExpression:
|
|
192491
192646
|
return transformJsxExpression(node.expression, ctx, isClientOnly);
|
|
192492
|
-
case
|
|
192647
|
+
case import_typescript11.default.SyntaxKind.JsxElement:
|
|
192493
192648
|
return transformJsxElement(node, ctx);
|
|
192494
|
-
case
|
|
192649
|
+
case import_typescript11.default.SyntaxKind.JsxFragment:
|
|
192495
192650
|
return transformFragment(node, ctx);
|
|
192496
|
-
case
|
|
192651
|
+
case import_typescript11.default.SyntaxKind.JsxSelfClosingElement:
|
|
192497
192652
|
return transformSelfClosingElement(node, ctx);
|
|
192498
|
-
case
|
|
192653
|
+
case import_typescript11.default.SyntaxKind.ConditionalExpression:
|
|
192499
192654
|
return transformConditional(node, ctx);
|
|
192500
|
-
case
|
|
192501
|
-
if (node.operatorToken.kind ===
|
|
192655
|
+
case import_typescript11.default.SyntaxKind.BinaryExpression: {
|
|
192656
|
+
if (node.operatorToken.kind === import_typescript11.default.SyntaxKind.AmpersandAmpersandToken) {
|
|
192502
192657
|
return transformLogicalAnd(node, ctx);
|
|
192503
192658
|
}
|
|
192504
|
-
if ((node.operatorToken.kind ===
|
|
192659
|
+
if ((node.operatorToken.kind === import_typescript11.default.SyntaxKind.QuestionQuestionToken || node.operatorToken.kind === import_typescript11.default.SyntaxKind.BarBarToken) && containsJsxInExpression(node.right)) {
|
|
192505
192660
|
return transformNullishCoalescing(node, ctx);
|
|
192506
192661
|
}
|
|
192507
192662
|
return null;
|
|
192508
192663
|
}
|
|
192509
|
-
case
|
|
192664
|
+
case import_typescript11.default.SyntaxKind.CallExpression: {
|
|
192510
192665
|
const mapMethod = getMapLikeMethod(node);
|
|
192511
192666
|
if (mapMethod) {
|
|
192512
192667
|
const mapResult = transformMapCall(node, ctx, isClientOnly, mapMethod);
|
|
@@ -192514,7 +192669,7 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
192514
192669
|
return mapResult;
|
|
192515
192670
|
}
|
|
192516
192671
|
const callee = node.expression;
|
|
192517
|
-
if (
|
|
192672
|
+
if (import_typescript11.default.isIdentifier(callee)) {
|
|
192518
192673
|
const jsxFunc = ctx.analyzer.jsxFunctions.get(callee.text);
|
|
192519
192674
|
if (jsxFunc) {
|
|
192520
192675
|
return transformJsxFunctionCall(node, jsxFunc, ctx, isClientOnly);
|
|
@@ -192526,39 +192681,39 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
192526
192681
|
}
|
|
192527
192682
|
return null;
|
|
192528
192683
|
}
|
|
192529
|
-
case
|
|
192530
|
-
case
|
|
192531
|
-
case
|
|
192532
|
-
case
|
|
192533
|
-
case
|
|
192534
|
-
case
|
|
192535
|
-
case
|
|
192536
|
-
case
|
|
192537
|
-
case
|
|
192538
|
-
case
|
|
192539
|
-
case
|
|
192540
|
-
case
|
|
192541
|
-
case
|
|
192542
|
-
case
|
|
192543
|
-
case
|
|
192544
|
-
case
|
|
192545
|
-
case
|
|
192546
|
-
case
|
|
192547
|
-
case
|
|
192548
|
-
case
|
|
192549
|
-
case
|
|
192550
|
-
case
|
|
192551
|
-
case
|
|
192552
|
-
case
|
|
192553
|
-
case
|
|
192554
|
-
case
|
|
192555
|
-
case
|
|
192556
|
-
case
|
|
192557
|
-
case
|
|
192558
|
-
case
|
|
192559
|
-
case
|
|
192684
|
+
case import_typescript11.default.SyntaxKind.Identifier:
|
|
192685
|
+
case import_typescript11.default.SyntaxKind.StringLiteral:
|
|
192686
|
+
case import_typescript11.default.SyntaxKind.NumericLiteral:
|
|
192687
|
+
case import_typescript11.default.SyntaxKind.BigIntLiteral:
|
|
192688
|
+
case import_typescript11.default.SyntaxKind.RegularExpressionLiteral:
|
|
192689
|
+
case import_typescript11.default.SyntaxKind.NoSubstitutionTemplateLiteral:
|
|
192690
|
+
case import_typescript11.default.SyntaxKind.TemplateExpression:
|
|
192691
|
+
case import_typescript11.default.SyntaxKind.TaggedTemplateExpression:
|
|
192692
|
+
case import_typescript11.default.SyntaxKind.TrueKeyword:
|
|
192693
|
+
case import_typescript11.default.SyntaxKind.FalseKeyword:
|
|
192694
|
+
case import_typescript11.default.SyntaxKind.NullKeyword:
|
|
192695
|
+
case import_typescript11.default.SyntaxKind.ThisKeyword:
|
|
192696
|
+
case import_typescript11.default.SyntaxKind.SuperKeyword:
|
|
192697
|
+
case import_typescript11.default.SyntaxKind.ImportKeyword:
|
|
192698
|
+
case import_typescript11.default.SyntaxKind.PropertyAccessExpression:
|
|
192699
|
+
case import_typescript11.default.SyntaxKind.ElementAccessExpression:
|
|
192700
|
+
case import_typescript11.default.SyntaxKind.PrefixUnaryExpression:
|
|
192701
|
+
case import_typescript11.default.SyntaxKind.PostfixUnaryExpression:
|
|
192702
|
+
case import_typescript11.default.SyntaxKind.TypeOfExpression:
|
|
192703
|
+
case import_typescript11.default.SyntaxKind.VoidExpression:
|
|
192704
|
+
case import_typescript11.default.SyntaxKind.DeleteExpression:
|
|
192705
|
+
case import_typescript11.default.SyntaxKind.NewExpression:
|
|
192706
|
+
case import_typescript11.default.SyntaxKind.ObjectLiteralExpression:
|
|
192707
|
+
case import_typescript11.default.SyntaxKind.ArrowFunction:
|
|
192708
|
+
case import_typescript11.default.SyntaxKind.FunctionExpression:
|
|
192709
|
+
case import_typescript11.default.SyntaxKind.ClassExpression:
|
|
192710
|
+
case import_typescript11.default.SyntaxKind.MetaProperty:
|
|
192711
|
+
case import_typescript11.default.SyntaxKind.ExpressionWithTypeArguments:
|
|
192712
|
+
case import_typescript11.default.SyntaxKind.CommaListExpression:
|
|
192713
|
+
case import_typescript11.default.SyntaxKind.SyntheticExpression:
|
|
192714
|
+
case import_typescript11.default.SyntaxKind.ArrayLiteralExpression:
|
|
192560
192715
|
return null;
|
|
192561
|
-
case
|
|
192716
|
+
case import_typescript11.default.SyntaxKind.AwaitExpression:
|
|
192562
192717
|
ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(node, ctx.sourceFile, ctx.filePath)));
|
|
192563
192718
|
return {
|
|
192564
192719
|
type: "expression",
|
|
@@ -192569,19 +192724,19 @@ function transformJsxExpression(expr, ctx, isClientOnly = false) {
|
|
|
192569
192724
|
loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
|
|
192570
192725
|
origin: { phase: "tick", scope: "template", effect: "pure", freeRefs: [] }
|
|
192571
192726
|
};
|
|
192572
|
-
case
|
|
192727
|
+
case import_typescript11.default.SyntaxKind.YieldExpression:
|
|
192573
192728
|
return null;
|
|
192574
|
-
case
|
|
192575
|
-
case
|
|
192576
|
-
case
|
|
192577
|
-
case
|
|
192578
|
-
case
|
|
192579
|
-
case
|
|
192580
|
-
case
|
|
192581
|
-
case
|
|
192729
|
+
case import_typescript11.default.SyntaxKind.SpreadElement:
|
|
192730
|
+
case import_typescript11.default.SyntaxKind.OmittedExpression:
|
|
192731
|
+
case import_typescript11.default.SyntaxKind.JsxExpression:
|
|
192732
|
+
case import_typescript11.default.SyntaxKind.JsxOpeningElement:
|
|
192733
|
+
case import_typescript11.default.SyntaxKind.JsxOpeningFragment:
|
|
192734
|
+
case import_typescript11.default.SyntaxKind.JsxClosingFragment:
|
|
192735
|
+
case import_typescript11.default.SyntaxKind.JsxAttributes:
|
|
192736
|
+
case import_typescript11.default.SyntaxKind.MissingDeclaration:
|
|
192582
192737
|
return null;
|
|
192583
192738
|
default:
|
|
192584
|
-
return
|
|
192739
|
+
return assertNever2(node);
|
|
192585
192740
|
}
|
|
192586
192741
|
}
|
|
192587
192742
|
function transformConditionalBranch(node, ctx) {
|
|
@@ -192595,21 +192750,26 @@ function transformConditionalBranch(node, ctx) {
|
|
|
192595
192750
|
effect: "pure",
|
|
192596
192751
|
freeRefs: resolveFreeRefs(node, makeBindingEnv(ctx))
|
|
192597
192752
|
};
|
|
192753
|
+
const callsReactive = exprCallsReactiveGetters(node, ctx);
|
|
192754
|
+
const hasCalls = exprHasFunctionCalls(node);
|
|
192755
|
+
const reactive = isReactiveExpression(exprText, ctx, node) || isReactiveOrigin(branchOrigin);
|
|
192756
|
+
const needsSlot = reactive || callsReactive;
|
|
192757
|
+
const slotId = needsSlot ? generateSlotId(ctx) : null;
|
|
192598
192758
|
return {
|
|
192599
192759
|
type: "expression",
|
|
192600
192760
|
expr: exprText,
|
|
192601
192761
|
templateExpr: rewriteBarePropRefs2(exprText, node, ctx),
|
|
192602
192762
|
typeInfo: inferExpressionType(node, ctx),
|
|
192603
|
-
reactive
|
|
192604
|
-
slotId
|
|
192605
|
-
callsReactiveGetters:
|
|
192606
|
-
hasFunctionCalls:
|
|
192763
|
+
reactive,
|
|
192764
|
+
slotId,
|
|
192765
|
+
callsReactiveGetters: callsReactive || undefined,
|
|
192766
|
+
hasFunctionCalls: hasCalls || undefined,
|
|
192607
192767
|
loc: getSourceLocation(node, ctx.sourceFile, ctx.filePath),
|
|
192608
192768
|
origin: branchOrigin
|
|
192609
192769
|
};
|
|
192610
192770
|
}
|
|
192611
192771
|
function getMapLikeMethod(node) {
|
|
192612
|
-
if (!
|
|
192772
|
+
if (!import_typescript11.default.isPropertyAccessExpression(node.expression))
|
|
192613
192773
|
return null;
|
|
192614
192774
|
const name = node.expression.name.text;
|
|
192615
192775
|
if (name === "map")
|
|
@@ -192619,9 +192779,9 @@ function getMapLikeMethod(node) {
|
|
|
192619
192779
|
return null;
|
|
192620
192780
|
}
|
|
192621
192781
|
function isFilterCall(node) {
|
|
192622
|
-
if (!
|
|
192782
|
+
if (!import_typescript11.default.isCallExpression(node))
|
|
192623
192783
|
return null;
|
|
192624
|
-
if (!
|
|
192784
|
+
if (!import_typescript11.default.isPropertyAccessExpression(node.expression))
|
|
192625
192785
|
return null;
|
|
192626
192786
|
if (node.expression.name.text !== "filter")
|
|
192627
192787
|
return null;
|
|
@@ -192633,9 +192793,9 @@ function isFilterCall(node) {
|
|
|
192633
192793
|
};
|
|
192634
192794
|
}
|
|
192635
192795
|
function isSortCall(node) {
|
|
192636
|
-
if (!
|
|
192796
|
+
if (!import_typescript11.default.isCallExpression(node))
|
|
192637
192797
|
return null;
|
|
192638
|
-
if (!
|
|
192798
|
+
if (!import_typescript11.default.isPropertyAccessExpression(node.expression))
|
|
192639
192799
|
return null;
|
|
192640
192800
|
const methodName = node.expression.name.text;
|
|
192641
192801
|
if (methodName !== "sort" && methodName !== "toSorted")
|
|
@@ -192648,8 +192808,20 @@ function isSortCall(node) {
|
|
|
192648
192808
|
method: methodName
|
|
192649
192809
|
};
|
|
192650
192810
|
}
|
|
192811
|
+
function isIteratorShapeCall(node) {
|
|
192812
|
+
if (!import_typescript11.default.isCallExpression(node))
|
|
192813
|
+
return null;
|
|
192814
|
+
if (!import_typescript11.default.isPropertyAccessExpression(node.expression))
|
|
192815
|
+
return null;
|
|
192816
|
+
if (node.arguments.length !== 0)
|
|
192817
|
+
return null;
|
|
192818
|
+
const name = node.expression.name.text;
|
|
192819
|
+
if (name !== "entries" && name !== "keys" && name !== "values")
|
|
192820
|
+
return null;
|
|
192821
|
+
return { array: node.expression.expression, shape: name };
|
|
192822
|
+
}
|
|
192651
192823
|
function extractSortComparator(callback, method, ctx) {
|
|
192652
|
-
if (!
|
|
192824
|
+
if (!import_typescript11.default.isArrowFunction(callback) && !import_typescript11.default.isFunctionExpression(callback)) {
|
|
192653
192825
|
return {
|
|
192654
192826
|
result: null,
|
|
192655
192827
|
unsupportedReason: "Sort comparator must be an arrow function or function expression"
|
|
@@ -192670,13 +192842,13 @@ function extractSortComparator(callback, method, ctx) {
|
|
|
192670
192842
|
};
|
|
192671
192843
|
}
|
|
192672
192844
|
function extractFilterPredicate(callback, ctx) {
|
|
192673
|
-
if (!
|
|
192845
|
+
if (!import_typescript11.default.isArrowFunction(callback))
|
|
192674
192846
|
return { result: null };
|
|
192675
192847
|
if (callback.parameters.length < 1)
|
|
192676
192848
|
return { result: null };
|
|
192677
192849
|
const firstParam = callback.parameters[0];
|
|
192678
|
-
if (!
|
|
192679
|
-
if (
|
|
192850
|
+
if (!import_typescript11.default.isIdentifier(firstParam.name)) {
|
|
192851
|
+
if (import_typescript11.default.isBlock(callback.body)) {
|
|
192680
192852
|
return {
|
|
192681
192853
|
result: null,
|
|
192682
192854
|
unsupportedReason: "Block body in a destructured filter param is not supported. Workaround: use an expression-body arrow, or add /* @client */."
|
|
@@ -192696,7 +192868,7 @@ function extractFilterPredicate(callback, ctx) {
|
|
|
192696
192868
|
return { result: null };
|
|
192697
192869
|
}
|
|
192698
192870
|
const param = firstParam.name.getText(ctx.sourceFile);
|
|
192699
|
-
if (
|
|
192871
|
+
if (import_typescript11.default.isBlock(callback.body)) {
|
|
192700
192872
|
const raw2 = ctx.getJS(callback.body);
|
|
192701
192873
|
const statements = parseBlockBody(callback.body, ctx.sourceFile, (n) => ctx.getJS(n));
|
|
192702
192874
|
if (!statements) {
|
|
@@ -192713,7 +192885,7 @@ function extractFilterPredicate(callback, ctx) {
|
|
|
192713
192885
|
return { result: { param, predicate, raw } };
|
|
192714
192886
|
}
|
|
192715
192887
|
function extractLoopParamBindings(pattern) {
|
|
192716
|
-
if (
|
|
192888
|
+
if (import_typescript11.default.isIdentifier(pattern))
|
|
192717
192889
|
return null;
|
|
192718
192890
|
const bindings = [];
|
|
192719
192891
|
let unsupported = false;
|
|
@@ -192722,7 +192894,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
192722
192894
|
return false;
|
|
192723
192895
|
for (let i2 = 0;i2 < key.length; ) {
|
|
192724
192896
|
const cp = key.codePointAt(i2);
|
|
192725
|
-
const ok = i2 === 0 ?
|
|
192897
|
+
const ok = i2 === 0 ? import_typescript11.default.isIdentifierStart(cp, import_typescript11.default.ScriptTarget.Latest) : import_typescript11.default.isIdentifierPart(cp, import_typescript11.default.ScriptTarget.Latest);
|
|
192726
192898
|
if (!ok)
|
|
192727
192899
|
return false;
|
|
192728
192900
|
i2 += cp > 65535 ? 2 : 1;
|
|
@@ -192735,17 +192907,17 @@ function extractLoopParamBindings(pattern) {
|
|
|
192735
192907
|
const walk = (p, prefix) => {
|
|
192736
192908
|
if (unsupported)
|
|
192737
192909
|
return;
|
|
192738
|
-
if (
|
|
192910
|
+
if (import_typescript11.default.isArrayBindingPattern(p)) {
|
|
192739
192911
|
const elements2 = p.elements;
|
|
192740
192912
|
for (let index = 0;index < elements2.length; index++) {
|
|
192741
192913
|
if (unsupported)
|
|
192742
192914
|
return;
|
|
192743
192915
|
const el = elements2[index];
|
|
192744
|
-
if (
|
|
192916
|
+
if (import_typescript11.default.isOmittedExpression(el))
|
|
192745
192917
|
continue;
|
|
192746
192918
|
if (el.dotDotDotToken) {
|
|
192747
192919
|
internalInvariant(index === elements2.length - 1, "extractLoopParamBindings: array rest token in non-final position (parser should reject)");
|
|
192748
|
-
internalInvariant(
|
|
192920
|
+
internalInvariant(import_typescript11.default.isIdentifier(el.name), "extractLoopParamBindings: array rest target is not an identifier (parser should reject)");
|
|
192749
192921
|
bindings.push({
|
|
192750
192922
|
name: el.name.text,
|
|
192751
192923
|
path: prefix,
|
|
@@ -192754,7 +192926,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
192754
192926
|
return;
|
|
192755
192927
|
}
|
|
192756
192928
|
const path = `${prefix}[${index}]`;
|
|
192757
|
-
if (
|
|
192929
|
+
if (import_typescript11.default.isIdentifier(el.name)) {
|
|
192758
192930
|
bindings.push({ name: el.name.text, path });
|
|
192759
192931
|
} else {
|
|
192760
192932
|
walk(el.name, path);
|
|
@@ -192770,7 +192942,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
192770
192942
|
const el = elements[i2];
|
|
192771
192943
|
if (el.dotDotDotToken) {
|
|
192772
192944
|
internalInvariant(i2 === elements.length - 1, "extractLoopParamBindings: object rest token in non-final position (parser should reject)");
|
|
192773
|
-
internalInvariant(
|
|
192945
|
+
internalInvariant(import_typescript11.default.isIdentifier(el.name), "extractLoopParamBindings: object rest target is not an identifier (parser should reject)");
|
|
192774
192946
|
bindings.push({
|
|
192775
192947
|
name: el.name.text,
|
|
192776
192948
|
path: prefix,
|
|
@@ -192781,17 +192953,17 @@ function extractLoopParamBindings(pattern) {
|
|
|
192781
192953
|
let keyText = null;
|
|
192782
192954
|
if (el.propertyName) {
|
|
192783
192955
|
const pn = el.propertyName;
|
|
192784
|
-
if (
|
|
192956
|
+
if (import_typescript11.default.isIdentifier(pn))
|
|
192785
192957
|
keyText = pn.text;
|
|
192786
|
-
else if (
|
|
192958
|
+
else if (import_typescript11.default.isStringLiteral(pn))
|
|
192787
192959
|
keyText = pn.text;
|
|
192788
|
-
else if (
|
|
192960
|
+
else if (import_typescript11.default.isNumericLiteral(pn))
|
|
192789
192961
|
keyText = pn.text;
|
|
192790
192962
|
else {
|
|
192791
192963
|
unsupported = true;
|
|
192792
192964
|
return;
|
|
192793
192965
|
}
|
|
192794
|
-
} else if (
|
|
192966
|
+
} else if (import_typescript11.default.isIdentifier(el.name)) {
|
|
192795
192967
|
keyText = el.name.text;
|
|
192796
192968
|
} else {
|
|
192797
192969
|
unsupported = true;
|
|
@@ -192799,14 +192971,14 @@ function extractLoopParamBindings(pattern) {
|
|
|
192799
192971
|
}
|
|
192800
192972
|
collectedKeys.push({ key: keyText, isIdent: isIdent(keyText) });
|
|
192801
192973
|
const path = appendDotAccess(prefix, keyText);
|
|
192802
|
-
if (
|
|
192974
|
+
if (import_typescript11.default.isIdentifier(el.name)) {
|
|
192803
192975
|
bindings.push({ name: el.name.text, path });
|
|
192804
192976
|
} else {
|
|
192805
192977
|
walk(el.name, path);
|
|
192806
192978
|
}
|
|
192807
192979
|
}
|
|
192808
192980
|
};
|
|
192809
|
-
if (
|
|
192981
|
+
if (import_typescript11.default.isArrayBindingPattern(pattern) || import_typescript11.default.isObjectBindingPattern(pattern)) {
|
|
192810
192982
|
walk(pattern, "");
|
|
192811
192983
|
if (unsupported)
|
|
192812
192984
|
return { unsupported: true };
|
|
@@ -192816,7 +192988,7 @@ function extractLoopParamBindings(pattern) {
|
|
|
192816
192988
|
}
|
|
192817
192989
|
function findKeyJsxAttribute(opening) {
|
|
192818
192990
|
for (const prop of opening.attributes.properties) {
|
|
192819
|
-
if (
|
|
192991
|
+
if (import_typescript11.default.isJsxAttribute(prop) && prop.name.getText() === "key") {
|
|
192820
192992
|
return prop;
|
|
192821
192993
|
}
|
|
192822
192994
|
}
|
|
@@ -192861,7 +193033,7 @@ function keyAttrValueToExpr(v) {
|
|
|
192861
193033
|
function normalizeKeyExpr(expr) {
|
|
192862
193034
|
let out = "";
|
|
192863
193035
|
for (const tok of iterateJsTokens(expr)) {
|
|
192864
|
-
if (tok.kind ===
|
|
193036
|
+
if (tok.kind === import_typescript11.default.SyntaxKind.WhitespaceTrivia || tok.kind === import_typescript11.default.SyntaxKind.NewLineTrivia) {
|
|
192865
193037
|
continue;
|
|
192866
193038
|
}
|
|
192867
193039
|
out += expr.slice(tok.pos, tok.end);
|
|
@@ -192873,13 +193045,13 @@ function conditionalHasExplicitNullishBranch(cond) {
|
|
|
192873
193045
|
}
|
|
192874
193046
|
function branchHasExplicitNullish(branch) {
|
|
192875
193047
|
let b = branch;
|
|
192876
|
-
while (
|
|
193048
|
+
while (import_typescript11.default.isParenthesizedExpression(b))
|
|
192877
193049
|
b = b.expression;
|
|
192878
|
-
if (b.kind ===
|
|
193050
|
+
if (b.kind === import_typescript11.default.SyntaxKind.NullKeyword)
|
|
192879
193051
|
return true;
|
|
192880
|
-
if (
|
|
193052
|
+
if (import_typescript11.default.isIdentifier(b) && b.text === "undefined")
|
|
192881
193053
|
return true;
|
|
192882
|
-
if (
|
|
193054
|
+
if (import_typescript11.default.isConditionalExpression(b))
|
|
192883
193055
|
return conditionalHasExplicitNullishBranch(b);
|
|
192884
193056
|
return false;
|
|
192885
193057
|
}
|
|
@@ -192888,26 +193060,26 @@ function classifyKeyProblem(keyAttr, checker) {
|
|
|
192888
193060
|
return "missing";
|
|
192889
193061
|
if (!keyAttr.initializer)
|
|
192890
193062
|
return "missing";
|
|
192891
|
-
if (
|
|
193063
|
+
if (import_typescript11.default.isJsxExpression(keyAttr.initializer) && !keyAttr.initializer.expression) {
|
|
192892
193064
|
return "missing";
|
|
192893
193065
|
}
|
|
192894
193066
|
let expr;
|
|
192895
|
-
if (
|
|
193067
|
+
if (import_typescript11.default.isStringLiteral(keyAttr.initializer)) {
|
|
192896
193068
|
return null;
|
|
192897
|
-
} else if (
|
|
193069
|
+
} else if (import_typescript11.default.isJsxExpression(keyAttr.initializer)) {
|
|
192898
193070
|
expr = keyAttr.initializer.expression;
|
|
192899
193071
|
}
|
|
192900
193072
|
if (!expr)
|
|
192901
193073
|
return null;
|
|
192902
|
-
if (expr.kind ===
|
|
193074
|
+
if (expr.kind === import_typescript11.default.SyntaxKind.NullKeyword)
|
|
192903
193075
|
return null;
|
|
192904
|
-
if (
|
|
193076
|
+
if (import_typescript11.default.isIdentifier(expr) && expr.text === "undefined")
|
|
192905
193077
|
return null;
|
|
192906
|
-
if (
|
|
193078
|
+
if (import_typescript11.default.isConditionalExpression(expr) && conditionalHasExplicitNullishBranch(expr))
|
|
192907
193079
|
return null;
|
|
192908
193080
|
if (checker) {
|
|
192909
193081
|
const type2 = checker.getTypeAtLocation(expr);
|
|
192910
|
-
const isNullable = type2.isUnion() ? type2.types.some((t) => (t.flags & (
|
|
193082
|
+
const isNullable = type2.isUnion() ? type2.types.some((t) => (t.flags & (import_typescript11.default.TypeFlags.Null | import_typescript11.default.TypeFlags.Undefined | import_typescript11.default.TypeFlags.Void)) !== 0) : (type2.flags & (import_typescript11.default.TypeFlags.Null | import_typescript11.default.TypeFlags.Undefined | import_typescript11.default.TypeFlags.Void)) !== 0;
|
|
192911
193083
|
if (isNullable)
|
|
192912
193084
|
return "nullable-type";
|
|
192913
193085
|
}
|
|
@@ -192933,38 +193105,38 @@ function checkLoopKey(callback, ctx, isNested) {
|
|
|
192933
193105
|
ctx.analyzer.errors.push(createError(errorCode, getSourceLocation(locNode, ctx.sourceFile, ctx.filePath), { suggestion: { message: keyErrorSuggestion(problem) } }));
|
|
192934
193106
|
}
|
|
192935
193107
|
let body = callback.body;
|
|
192936
|
-
if (
|
|
192937
|
-
const ret = body.statements.find((s) =>
|
|
193108
|
+
if (import_typescript11.default.isBlock(body)) {
|
|
193109
|
+
const ret = body.statements.find((s) => import_typescript11.default.isReturnStatement(s) && s.expression != null);
|
|
192938
193110
|
if (!ret?.expression)
|
|
192939
193111
|
return;
|
|
192940
193112
|
body = ret.expression;
|
|
192941
193113
|
}
|
|
192942
|
-
while (
|
|
193114
|
+
while (import_typescript11.default.isParenthesizedExpression(body))
|
|
192943
193115
|
body = body.expression;
|
|
192944
|
-
if (
|
|
193116
|
+
if (import_typescript11.default.isConditionalExpression(body)) {
|
|
192945
193117
|
const whenTrue = body.whenTrue;
|
|
192946
193118
|
const whenFalse = body.whenFalse;
|
|
192947
193119
|
let wt = whenTrue;
|
|
192948
193120
|
let wf = whenFalse;
|
|
192949
|
-
while (
|
|
193121
|
+
while (import_typescript11.default.isParenthesizedExpression(wt))
|
|
192950
193122
|
wt = wt.expression;
|
|
192951
|
-
while (
|
|
193123
|
+
while (import_typescript11.default.isParenthesizedExpression(wf))
|
|
192952
193124
|
wf = wf.expression;
|
|
192953
|
-
if (
|
|
193125
|
+
if (import_typescript11.default.isJsxElement(wt))
|
|
192954
193126
|
checkOpening(wt.openingElement);
|
|
192955
|
-
else if (
|
|
193127
|
+
else if (import_typescript11.default.isJsxSelfClosingElement(wt))
|
|
192956
193128
|
checkOpening(wt);
|
|
192957
|
-
if (
|
|
193129
|
+
if (import_typescript11.default.isJsxElement(wf))
|
|
192958
193130
|
checkOpening(wf.openingElement);
|
|
192959
|
-
else if (
|
|
193131
|
+
else if (import_typescript11.default.isJsxSelfClosingElement(wf))
|
|
192960
193132
|
checkOpening(wf);
|
|
192961
193133
|
return;
|
|
192962
193134
|
}
|
|
192963
|
-
if (
|
|
193135
|
+
if (import_typescript11.default.isJsxElement(body)) {
|
|
192964
193136
|
checkOpening(body.openingElement);
|
|
192965
193137
|
return;
|
|
192966
193138
|
}
|
|
192967
|
-
if (
|
|
193139
|
+
if (import_typescript11.default.isJsxSelfClosingElement(body)) {
|
|
192968
193140
|
checkOpening(body);
|
|
192969
193141
|
return;
|
|
192970
193142
|
}
|
|
@@ -192993,13 +193165,24 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
192993
193165
|
let mapPreamble;
|
|
192994
193166
|
let templateMapPreamble;
|
|
192995
193167
|
let typedMapPreamble;
|
|
193168
|
+
let iterationShape;
|
|
192996
193169
|
const setArray = (node2) => {
|
|
192997
193170
|
array = ctx.getJS(node2);
|
|
192998
193171
|
templateArray = rewriteBarePropRefs2(array, node2, ctx);
|
|
192999
193172
|
arrayExpr = node2;
|
|
193000
193173
|
};
|
|
193001
|
-
|
|
193002
|
-
const
|
|
193174
|
+
let chainSource = mapSource;
|
|
193175
|
+
const iteratorInfo = isIteratorShapeCall(mapSource);
|
|
193176
|
+
if (iteratorInfo) {
|
|
193177
|
+
chainSource = iteratorInfo.array;
|
|
193178
|
+
if (iteratorInfo.shape === "entries") {
|
|
193179
|
+
iterationShape = "entries";
|
|
193180
|
+
} else if (iteratorInfo.shape === "keys") {
|
|
193181
|
+
iterationShape = "keys";
|
|
193182
|
+
}
|
|
193183
|
+
}
|
|
193184
|
+
const filterInfo = isFilterCall(chainSource);
|
|
193185
|
+
const sortInfo = isSortCall(chainSource);
|
|
193003
193186
|
if (sortInfo) {
|
|
193004
193187
|
const innerFilter = isFilterCall(sortInfo.array);
|
|
193005
193188
|
const sortExtraction = extractSortComparator(sortInfo.callback, sortInfo.method, ctx);
|
|
@@ -193076,8 +193259,8 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
193076
193259
|
}
|
|
193077
193260
|
}
|
|
193078
193261
|
} else {
|
|
193079
|
-
array = ctx.getJS(
|
|
193080
|
-
arrayExpr =
|
|
193262
|
+
array = ctx.getJS(chainSource);
|
|
193263
|
+
arrayExpr = chainSource;
|
|
193081
193264
|
}
|
|
193082
193265
|
const callback = node.arguments[0];
|
|
193083
193266
|
let param = "item";
|
|
@@ -193087,21 +193270,36 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
193087
193270
|
let children = [];
|
|
193088
193271
|
let paramBindings;
|
|
193089
193272
|
let flatMapCallback;
|
|
193090
|
-
if (
|
|
193273
|
+
if (import_typescript11.default.isArrowFunction(callback)) {
|
|
193091
193274
|
if (callback.parameters.length > 0) {
|
|
193092
193275
|
const firstParam = callback.parameters[0];
|
|
193093
193276
|
param = firstParam.name.getText(ctx.sourceFile);
|
|
193094
193277
|
if (firstParam.type) {
|
|
193095
193278
|
paramType = firstParam.type.getText(ctx.sourceFile);
|
|
193096
193279
|
}
|
|
193097
|
-
|
|
193098
|
-
|
|
193099
|
-
|
|
193100
|
-
|
|
193101
|
-
|
|
193280
|
+
if (iterationShape === "entries" && import_typescript11.default.isArrayBindingPattern(firstParam.name)) {
|
|
193281
|
+
const elements = firstParam.name.elements.filter((el) => !import_typescript11.default.isOmittedExpression(el));
|
|
193282
|
+
if (elements.length === 2 && import_typescript11.default.isBindingElement(elements[0]) && import_typescript11.default.isIdentifier(elements[0].name) && import_typescript11.default.isBindingElement(elements[1]) && import_typescript11.default.isIdentifier(elements[1].name)) {
|
|
193283
|
+
index = elements[0].name.text;
|
|
193284
|
+
param = elements[1].name.text;
|
|
193285
|
+
} else {
|
|
193286
|
+
const bindingResult = extractLoopParamBindings(firstParam.name);
|
|
193287
|
+
if (bindingResult && !Array.isArray(bindingResult)) {
|
|
193288
|
+
ctx.analyzer.errors.push(createError(ErrorCodes.UNSUPPORTED_DESTRUCTURE_REST, getSourceLocation(firstParam, ctx.sourceFile, ctx.filePath)));
|
|
193289
|
+
} else if (Array.isArray(bindingResult)) {
|
|
193290
|
+
paramBindings = bindingResult;
|
|
193291
|
+
}
|
|
193292
|
+
}
|
|
193293
|
+
} else {
|
|
193294
|
+
const bindingResult = extractLoopParamBindings(firstParam.name);
|
|
193295
|
+
if (bindingResult && !Array.isArray(bindingResult)) {
|
|
193296
|
+
ctx.analyzer.errors.push(createError(ErrorCodes.UNSUPPORTED_DESTRUCTURE_REST, getSourceLocation(firstParam, ctx.sourceFile, ctx.filePath)));
|
|
193297
|
+
} else if (Array.isArray(bindingResult)) {
|
|
193298
|
+
paramBindings = bindingResult;
|
|
193299
|
+
}
|
|
193102
193300
|
}
|
|
193103
193301
|
}
|
|
193104
|
-
if (callback.parameters.length > 1) {
|
|
193302
|
+
if (callback.parameters.length > 1 && iterationShape !== "entries") {
|
|
193105
193303
|
const secondParam = callback.parameters[1];
|
|
193106
193304
|
index = secondParam.name.getText(ctx.sourceFile);
|
|
193107
193305
|
if (secondParam.type) {
|
|
@@ -193117,38 +193315,38 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
193117
193315
|
if (index)
|
|
193118
193316
|
ctx.loopParams.add(index);
|
|
193119
193317
|
const body = callback.body;
|
|
193120
|
-
if (
|
|
193318
|
+
if (import_typescript11.default.isJsxElement(body) || import_typescript11.default.isJsxSelfClosingElement(body) || import_typescript11.default.isJsxFragment(body)) {
|
|
193121
193319
|
const transformed = transformNode(body, ctx);
|
|
193122
193320
|
if (transformed) {
|
|
193123
193321
|
children = [transformed];
|
|
193124
193322
|
}
|
|
193125
|
-
} else if (
|
|
193323
|
+
} else if (import_typescript11.default.isConditionalExpression(body)) {
|
|
193126
193324
|
children = [transformConditional(body, ctx)];
|
|
193127
|
-
} else if (
|
|
193325
|
+
} else if (import_typescript11.default.isParenthesizedExpression(body)) {
|
|
193128
193326
|
let inner = body.expression;
|
|
193129
|
-
while (
|
|
193327
|
+
while (import_typescript11.default.isParenthesizedExpression(inner)) {
|
|
193130
193328
|
inner = inner.expression;
|
|
193131
193329
|
}
|
|
193132
|
-
if (
|
|
193330
|
+
if (import_typescript11.default.isJsxElement(inner) || import_typescript11.default.isJsxSelfClosingElement(inner) || import_typescript11.default.isJsxFragment(inner)) {
|
|
193133
193331
|
const transformed = transformNode(inner, ctx);
|
|
193134
193332
|
if (transformed) {
|
|
193135
193333
|
children = [transformed];
|
|
193136
193334
|
}
|
|
193137
|
-
} else if (
|
|
193335
|
+
} else if (import_typescript11.default.isConditionalExpression(inner)) {
|
|
193138
193336
|
children = [transformConditional(inner, ctx)];
|
|
193139
|
-
} else if (method === "flatMap" &&
|
|
193337
|
+
} else if (method === "flatMap" && import_typescript11.default.isArrayLiteralExpression(inner)) {
|
|
193140
193338
|
children = transformArrayLiteralChildren(inner, ctx);
|
|
193141
193339
|
}
|
|
193142
|
-
} else if (method === "flatMap" &&
|
|
193340
|
+
} else if (method === "flatMap" && import_typescript11.default.isArrayLiteralExpression(body)) {
|
|
193143
193341
|
children = transformArrayLiteralChildren(body, ctx);
|
|
193144
|
-
} else if (
|
|
193145
|
-
const returnStmt = body.statements.find((s) =>
|
|
193342
|
+
} else if (import_typescript11.default.isBlock(body)) {
|
|
193343
|
+
const returnStmt = body.statements.find((s) => import_typescript11.default.isReturnStatement(s) && s.expression != null);
|
|
193146
193344
|
if (returnStmt && returnStmt.expression) {
|
|
193147
193345
|
let returnExpr = returnStmt.expression;
|
|
193148
|
-
while (
|
|
193346
|
+
while (import_typescript11.default.isParenthesizedExpression(returnExpr)) {
|
|
193149
193347
|
returnExpr = returnExpr.expression;
|
|
193150
193348
|
}
|
|
193151
|
-
if (
|
|
193349
|
+
if (import_typescript11.default.isJsxElement(returnExpr) || import_typescript11.default.isJsxSelfClosingElement(returnExpr) || import_typescript11.default.isJsxFragment(returnExpr)) {
|
|
193152
193350
|
const transformed = transformNode(returnExpr, ctx);
|
|
193153
193351
|
if (transformed) {
|
|
193154
193352
|
children = [transformed];
|
|
@@ -193164,11 +193362,11 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
193164
193362
|
break;
|
|
193165
193363
|
const js = ctx.getJS(stmt);
|
|
193166
193364
|
const tjs = ctx.getTemplateJS(stmt);
|
|
193167
|
-
const
|
|
193365
|
+
const ts12 = stmt.getText(ctx.sourceFile);
|
|
193168
193366
|
preambleStmts.push(js.endsWith(";") ? js : js + ";");
|
|
193169
193367
|
templatePreambleStmts.push(tjs.endsWith(";") ? tjs : tjs + ";");
|
|
193170
|
-
typedPreambleStmts.push(
|
|
193171
|
-
if (js !==
|
|
193368
|
+
typedPreambleStmts.push(ts12.endsWith(";") ? ts12 : ts12 + ";");
|
|
193369
|
+
if (js !== ts12)
|
|
193172
193370
|
hasTypeDiff = true;
|
|
193173
193371
|
if (js !== tjs)
|
|
193174
193372
|
hasTemplateDiff = true;
|
|
@@ -193199,7 +193397,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
193199
193397
|
if (children.length === 0 && !flatMapCallback) {
|
|
193200
193398
|
return null;
|
|
193201
193399
|
}
|
|
193202
|
-
if (
|
|
193400
|
+
if (import_typescript11.default.isArrowFunction(node.arguments[0]) && children.length > 0) {
|
|
193203
193401
|
checkLoopKey(node.arguments[0], ctx, isNested);
|
|
193204
193402
|
}
|
|
193205
193403
|
const key = children.length > 0 ? extractLoopKey(children[0]) : null;
|
|
@@ -193246,6 +193444,7 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
193246
193444
|
filterPredicate,
|
|
193247
193445
|
sortComparator,
|
|
193248
193446
|
chainOrder,
|
|
193447
|
+
iterationShape,
|
|
193249
193448
|
clientOnly: isClientOnly || undefined,
|
|
193250
193449
|
mapPreamble,
|
|
193251
193450
|
templateMapPreamble,
|
|
@@ -193261,12 +193460,12 @@ function transformMapCall(node, ctx, isClientOnly = false, method = "map") {
|
|
|
193261
193460
|
function transformArrayLiteralChildren(arrayLiteral, ctx) {
|
|
193262
193461
|
const children = [];
|
|
193263
193462
|
for (const element of arrayLiteral.elements) {
|
|
193264
|
-
if (
|
|
193463
|
+
if (import_typescript11.default.isSpreadElement(element))
|
|
193265
193464
|
continue;
|
|
193266
193465
|
let inner = element;
|
|
193267
|
-
while (
|
|
193466
|
+
while (import_typescript11.default.isParenthesizedExpression(inner))
|
|
193268
193467
|
inner = inner.expression;
|
|
193269
|
-
if (
|
|
193468
|
+
if (import_typescript11.default.isJsxElement(inner) || import_typescript11.default.isJsxSelfClosingElement(inner) || import_typescript11.default.isJsxFragment(inner)) {
|
|
193270
193469
|
const transformed = transformNode(inner, ctx);
|
|
193271
193470
|
if (transformed)
|
|
193272
193471
|
children.push(transformed);
|
|
@@ -193275,7 +193474,7 @@ function transformArrayLiteralChildren(arrayLiteral, ctx) {
|
|
|
193275
193474
|
return children;
|
|
193276
193475
|
}
|
|
193277
193476
|
function containsJsx(node) {
|
|
193278
|
-
if (
|
|
193477
|
+
if (import_typescript11.default.isJsxElement(node) || import_typescript11.default.isJsxSelfClosingElement(node) || import_typescript11.default.isJsxFragment(node))
|
|
193279
193478
|
return true;
|
|
193280
193479
|
let found = false;
|
|
193281
193480
|
node.forEachChild((child) => {
|
|
@@ -193294,7 +193493,7 @@ function buildFlatMapCallback(callback, body, ctx) {
|
|
|
193294
193493
|
const bodyText = sourceText.slice(bodyStart, bodyEnd);
|
|
193295
193494
|
const jsxNodes = [];
|
|
193296
193495
|
function collectJsx(n) {
|
|
193297
|
-
if (
|
|
193496
|
+
if (import_typescript11.default.isJsxElement(n) || import_typescript11.default.isJsxSelfClosingElement(n) || import_typescript11.default.isJsxFragment(n)) {
|
|
193298
193497
|
jsxNodes.push({
|
|
193299
193498
|
node: n,
|
|
193300
193499
|
start: n.getStart(ctx.sourceFile) - bodyStart,
|
|
@@ -193398,13 +193597,13 @@ function expandSpreadAttribute(attr, ctx) {
|
|
|
193398
193597
|
}];
|
|
193399
193598
|
}
|
|
193400
193599
|
function attrFreeIdentifiers(attr) {
|
|
193401
|
-
if (!attr.initializer || !
|
|
193600
|
+
if (!attr.initializer || !import_typescript11.default.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
|
|
193402
193601
|
return;
|
|
193403
193602
|
}
|
|
193404
193603
|
return extractFreeIdentifiersFromNode(attr.initializer.expression);
|
|
193405
193604
|
}
|
|
193406
193605
|
function computeReactivityFlags(attr, ctx) {
|
|
193407
|
-
if (!attr.initializer || !
|
|
193606
|
+
if (!attr.initializer || !import_typescript11.default.isJsxExpression(attr.initializer) || !attr.initializer.expression) {
|
|
193408
193607
|
return {};
|
|
193409
193608
|
}
|
|
193410
193609
|
const expr = attr.initializer.expression;
|
|
@@ -193430,22 +193629,22 @@ function processAttributes(attributes, ctx) {
|
|
|
193430
193629
|
const events = [];
|
|
193431
193630
|
let ref = null;
|
|
193432
193631
|
for (const attr of attributes.properties) {
|
|
193433
|
-
if (
|
|
193632
|
+
if (import_typescript11.default.isJsxSpreadAttribute(attr)) {
|
|
193434
193633
|
attrs.push(...expandSpreadAttribute(attr, ctx));
|
|
193435
193634
|
continue;
|
|
193436
193635
|
}
|
|
193437
|
-
if (!
|
|
193636
|
+
if (!import_typescript11.default.isJsxAttribute(attr))
|
|
193438
193637
|
continue;
|
|
193439
193638
|
const name = attr.name.getText(ctx.sourceFile);
|
|
193440
193639
|
if (name === "ref") {
|
|
193441
|
-
if (attr.initializer &&
|
|
193640
|
+
if (attr.initializer && import_typescript11.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
193442
193641
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
|
|
193443
193642
|
ref = ctx.getJS(attr.initializer.expression);
|
|
193444
193643
|
}
|
|
193445
193644
|
continue;
|
|
193446
193645
|
}
|
|
193447
193646
|
if (/^on[A-Z]/.test(name)) {
|
|
193448
|
-
if (attr.initializer &&
|
|
193647
|
+
if (attr.initializer && import_typescript11.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
193449
193648
|
const eventName = name.slice(2).toLowerCase();
|
|
193450
193649
|
reportJsxBranchLocalInCallback(attr.initializer.expression, ctx);
|
|
193451
193650
|
events.push({
|
|
@@ -193459,14 +193658,14 @@ function processAttributes(attributes, ctx) {
|
|
|
193459
193658
|
}
|
|
193460
193659
|
let value = getAttributeValue(attr, ctx);
|
|
193461
193660
|
let clientOnly;
|
|
193462
|
-
if (attr.initializer &&
|
|
193661
|
+
if (attr.initializer && import_typescript11.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
193463
193662
|
if (value.kind === "expression" && value.templateExpr === undefined) {
|
|
193464
193663
|
const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
|
|
193465
193664
|
if (rewritten !== value.expr) {
|
|
193466
193665
|
value = { ...value, templateExpr: rewritten };
|
|
193467
193666
|
}
|
|
193468
193667
|
}
|
|
193469
|
-
if (hasLeadingClientDirective(attr.initializer.expression, ctx.sourceFile)) {
|
|
193668
|
+
if (hasLeadingClientDirective(attr.initializer.expression, ctx.sourceFile) || shouldAutoDeferReactiveBrand(attr.initializer.expression, ctx)) {
|
|
193470
193669
|
clientOnly = true;
|
|
193471
193670
|
}
|
|
193472
193671
|
}
|
|
@@ -193486,48 +193685,48 @@ function getAttributeValue(attr, ctx) {
|
|
|
193486
193685
|
if (!attr.initializer) {
|
|
193487
193686
|
return AttrValueOf.booleanAttr();
|
|
193488
193687
|
}
|
|
193489
|
-
if (
|
|
193688
|
+
if (import_typescript11.default.isStringLiteral(attr.initializer)) {
|
|
193490
193689
|
return AttrValueOf.literal(attr.initializer.text);
|
|
193491
193690
|
}
|
|
193492
|
-
if (
|
|
193691
|
+
if (import_typescript11.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
193493
193692
|
let expr = attr.initializer.expression;
|
|
193494
|
-
if (
|
|
193693
|
+
if (import_typescript11.default.isIdentifier(expr)) {
|
|
193495
193694
|
const branchInit = ctx._branchScopeVars?.get(expr.text);
|
|
193496
193695
|
if (branchInit && !initializerShapeContainsJsx(branchInit)) {
|
|
193497
193696
|
expr = branchInit;
|
|
193498
193697
|
}
|
|
193499
193698
|
}
|
|
193500
|
-
if (
|
|
193699
|
+
if (import_typescript11.default.isAwaitExpression(expr)) {
|
|
193501
193700
|
ctx.analyzer.errors.push(createError(ErrorCodes.STAGE_AWAIT_IN_TEMPLATE, getSourceLocation(expr, ctx.sourceFile, ctx.filePath)));
|
|
193502
193701
|
return AttrValueOf.expression("undefined");
|
|
193503
193702
|
}
|
|
193504
193703
|
checkBareSignalOrMemoIdentifier(expr, ctx);
|
|
193505
|
-
if (attr.name.getText(ctx.sourceFile) === "style" &&
|
|
193704
|
+
if (attr.name.getText(ctx.sourceFile) === "style" && import_typescript11.default.isObjectLiteralExpression(expr)) {
|
|
193506
193705
|
const cssString = tryStaticStyleObjectToCss(expr);
|
|
193507
193706
|
if (cssString !== null) {
|
|
193508
193707
|
return AttrValueOf.literal(cssString);
|
|
193509
193708
|
}
|
|
193510
193709
|
}
|
|
193511
|
-
if (
|
|
193710
|
+
if (import_typescript11.default.isTemplateExpression(expr)) {
|
|
193512
193711
|
const parts = parseTemplateLiteral(expr, ctx);
|
|
193513
193712
|
if (parts.some((p) => p.type === "ternary" || p.type === "lookup")) {
|
|
193514
193713
|
return AttrValueOf.template(parts);
|
|
193515
193714
|
}
|
|
193516
193715
|
}
|
|
193517
|
-
if (
|
|
193716
|
+
if (import_typescript11.default.isIdentifier(expr)) {
|
|
193518
193717
|
const resolved = tryResolveIdentifierAsTemplateLiteral(expr, ctx);
|
|
193519
193718
|
if (resolved) {
|
|
193520
193719
|
return AttrValueOf.template(resolved);
|
|
193521
193720
|
}
|
|
193522
193721
|
}
|
|
193523
|
-
if (
|
|
193722
|
+
if (import_typescript11.default.isConditionalExpression(expr)) {
|
|
193524
193723
|
const ternary = parseTernary(expr, ctx);
|
|
193525
193724
|
if (ternary) {
|
|
193526
193725
|
return AttrValueOf.template([ternary]);
|
|
193527
193726
|
}
|
|
193528
193727
|
}
|
|
193529
|
-
if (
|
|
193530
|
-
if (
|
|
193728
|
+
if (import_typescript11.default.isBinaryExpression(expr) && expr.operatorToken.kind === import_typescript11.default.SyntaxKind.BarBarToken) {
|
|
193729
|
+
if (import_typescript11.default.isIdentifier(expr.right) && expr.right.text === "undefined") {
|
|
193531
193730
|
const baseExpr = ctx.getJS(expr.left);
|
|
193532
193731
|
return AttrValueOf.expression(baseExpr, { presenceOrUndefined: true });
|
|
193533
193732
|
}
|
|
@@ -193540,11 +193739,11 @@ function getAttributeValue(attr, ctx) {
|
|
|
193540
193739
|
function tryStaticStyleObjectToCss(expr) {
|
|
193541
193740
|
const parts = [];
|
|
193542
193741
|
for (const prop of expr.properties) {
|
|
193543
|
-
if (!
|
|
193742
|
+
if (!import_typescript11.default.isPropertyAssignment(prop))
|
|
193544
193743
|
return null;
|
|
193545
|
-
if (!
|
|
193744
|
+
if (!import_typescript11.default.isIdentifier(prop.name) && !import_typescript11.default.isStringLiteral(prop.name))
|
|
193546
193745
|
return null;
|
|
193547
|
-
if (!
|
|
193746
|
+
if (!import_typescript11.default.isStringLiteral(prop.initializer))
|
|
193548
193747
|
return null;
|
|
193549
193748
|
const key = prop.name.text.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
193550
193749
|
parts.push(`${key}:${prop.initializer.text}`);
|
|
@@ -193557,7 +193756,7 @@ function parseTemplateLiteral(expr, ctx) {
|
|
|
193557
193756
|
parts.push({ type: "string", value: expr.head.text });
|
|
193558
193757
|
}
|
|
193559
193758
|
for (const span of expr.templateSpans) {
|
|
193560
|
-
if (
|
|
193759
|
+
if (import_typescript11.default.isConditionalExpression(span.expression)) {
|
|
193561
193760
|
const ternary = parseTernary(span.expression, ctx);
|
|
193562
193761
|
if (ternary) {
|
|
193563
193762
|
parts.push(ternary);
|
|
@@ -193583,36 +193782,36 @@ function parseTemplateLiteral(expr, ctx) {
|
|
|
193583
193782
|
return parts;
|
|
193584
193783
|
}
|
|
193585
193784
|
function tryResolveTemplateSpanFromConst(expr, ctx) {
|
|
193586
|
-
if (
|
|
193785
|
+
if (import_typescript11.default.isIdentifier(expr)) {
|
|
193587
193786
|
const constInfo = findLocalConst(expr.text, ctx);
|
|
193588
193787
|
if (!constInfo)
|
|
193589
193788
|
return null;
|
|
193590
193789
|
const ast = parseConstInitializer(constInfo);
|
|
193591
193790
|
if (!ast)
|
|
193592
193791
|
return null;
|
|
193593
|
-
if (
|
|
193792
|
+
if (import_typescript11.default.isStringLiteral(ast) || import_typescript11.default.isNoSubstitutionTemplateLiteral(ast)) {
|
|
193594
193793
|
return [{ type: "string", value: ast.text }];
|
|
193595
193794
|
}
|
|
193596
193795
|
return null;
|
|
193597
193796
|
}
|
|
193598
|
-
if (
|
|
193599
|
-
if (!
|
|
193797
|
+
if (import_typescript11.default.isElementAccessExpression(expr)) {
|
|
193798
|
+
if (!import_typescript11.default.isIdentifier(expr.expression))
|
|
193600
193799
|
return null;
|
|
193601
193800
|
const constInfo = findLocalConst(expr.expression.text, ctx);
|
|
193602
193801
|
if (!constInfo)
|
|
193603
193802
|
return null;
|
|
193604
193803
|
const ast = parseConstInitializer(constInfo);
|
|
193605
|
-
if (!ast || !
|
|
193804
|
+
if (!ast || !import_typescript11.default.isObjectLiteralExpression(ast))
|
|
193606
193805
|
return null;
|
|
193607
193806
|
const cases = {};
|
|
193608
193807
|
for (const prop of ast.properties) {
|
|
193609
|
-
if (!
|
|
193808
|
+
if (!import_typescript11.default.isPropertyAssignment(prop))
|
|
193610
193809
|
return null;
|
|
193611
|
-
const keyName = prop.name && (
|
|
193810
|
+
const keyName = prop.name && (import_typescript11.default.isStringLiteral(prop.name) || import_typescript11.default.isIdentifier(prop.name)) ? prop.name.text : null;
|
|
193612
193811
|
if (!keyName)
|
|
193613
193812
|
return null;
|
|
193614
193813
|
const value = prop.initializer;
|
|
193615
|
-
if (
|
|
193814
|
+
if (import_typescript11.default.isStringLiteral(value) || import_typescript11.default.isNoSubstitutionTemplateLiteral(value)) {
|
|
193616
193815
|
cases[keyName] = value.text;
|
|
193617
193816
|
} else {
|
|
193618
193817
|
return null;
|
|
@@ -193639,10 +193838,10 @@ function tryResolveIdentifierAsTemplateLiteral(ident, ctx) {
|
|
|
193639
193838
|
const ast = parseConstInitializer(constInfo);
|
|
193640
193839
|
if (!ast)
|
|
193641
193840
|
return null;
|
|
193642
|
-
if (
|
|
193841
|
+
if (import_typescript11.default.isNoSubstitutionTemplateLiteral(ast) || import_typescript11.default.isStringLiteral(ast)) {
|
|
193643
193842
|
return [{ type: "string", value: ast.text }];
|
|
193644
193843
|
}
|
|
193645
|
-
if (!
|
|
193844
|
+
if (!import_typescript11.default.isTemplateExpression(ast))
|
|
193646
193845
|
return null;
|
|
193647
193846
|
let resolvedAny = false;
|
|
193648
193847
|
const parts = [];
|
|
@@ -193680,14 +193879,14 @@ function parseConstInitializerImpl(c) {
|
|
|
193680
193879
|
if (!c.value)
|
|
193681
193880
|
return null;
|
|
193682
193881
|
const wrapped = `const __bf_resolve__ = (${c.value})`;
|
|
193683
|
-
const sf =
|
|
193882
|
+
const sf = import_typescript11.default.createSourceFile("__bf_resolve.ts", wrapped, import_typescript11.default.ScriptTarget.Latest, true, import_typescript11.default.ScriptKind.TS);
|
|
193684
193883
|
const stmt = sf.statements[0];
|
|
193685
|
-
if (!stmt || !
|
|
193884
|
+
if (!stmt || !import_typescript11.default.isVariableStatement(stmt))
|
|
193686
193885
|
return null;
|
|
193687
193886
|
const decl = stmt.declarationList.declarations[0];
|
|
193688
193887
|
if (!decl?.initializer)
|
|
193689
193888
|
return null;
|
|
193690
|
-
return
|
|
193889
|
+
return import_typescript11.default.isParenthesizedExpression(decl.initializer) ? decl.initializer.expression : decl.initializer;
|
|
193691
193890
|
}
|
|
193692
193891
|
function astText(node) {
|
|
193693
193892
|
return node.getText(node.getSourceFile());
|
|
@@ -193708,10 +193907,10 @@ function parseTernary(expr, ctx) {
|
|
|
193708
193907
|
return null;
|
|
193709
193908
|
}
|
|
193710
193909
|
function getStringValue(node) {
|
|
193711
|
-
if (
|
|
193910
|
+
if (import_typescript11.default.isStringLiteral(node)) {
|
|
193712
193911
|
return node.text;
|
|
193713
193912
|
}
|
|
193714
|
-
if (
|
|
193913
|
+
if (import_typescript11.default.isNoSubstitutionTemplateLiteral(node)) {
|
|
193715
193914
|
return node.text;
|
|
193716
193915
|
}
|
|
193717
193916
|
return null;
|
|
@@ -193719,19 +193918,19 @@ function getStringValue(node) {
|
|
|
193719
193918
|
function processComponentProps(attributes, ctx) {
|
|
193720
193919
|
const props = [];
|
|
193721
193920
|
for (const attr of attributes.properties) {
|
|
193722
|
-
if (
|
|
193921
|
+
if (import_typescript11.default.isJsxSpreadAttribute(attr)) {
|
|
193723
193922
|
props.push(...expandSpreadAttribute(attr, ctx));
|
|
193724
193923
|
continue;
|
|
193725
193924
|
}
|
|
193726
|
-
if (!
|
|
193925
|
+
if (!import_typescript11.default.isJsxAttribute(attr))
|
|
193727
193926
|
continue;
|
|
193728
193927
|
const name = attr.name.getText(ctx.sourceFile);
|
|
193729
|
-
if (attr.initializer &&
|
|
193928
|
+
if (attr.initializer && import_typescript11.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
193730
193929
|
let jsxExpr = attr.initializer.expression;
|
|
193731
|
-
while (
|
|
193930
|
+
while (import_typescript11.default.isParenthesizedExpression(jsxExpr)) {
|
|
193732
193931
|
jsxExpr = jsxExpr.expression;
|
|
193733
193932
|
}
|
|
193734
|
-
if (
|
|
193933
|
+
if (import_typescript11.default.isJsxElement(jsxExpr) || import_typescript11.default.isJsxSelfClosingElement(jsxExpr) || import_typescript11.default.isJsxFragment(jsxExpr)) {
|
|
193735
193934
|
const prevInsideComponentChildren = ctx.insideComponentChildren;
|
|
193736
193935
|
ctx.insideComponentChildren = true;
|
|
193737
193936
|
const irNode = transformNode(jsxExpr, ctx);
|
|
@@ -193755,7 +193954,7 @@ function processComponentProps(attributes, ctx) {
|
|
|
193755
193954
|
value = AttrValueOf.booleanShorthand();
|
|
193756
193955
|
}
|
|
193757
193956
|
let clientOnly;
|
|
193758
|
-
if (attr.initializer &&
|
|
193957
|
+
if (attr.initializer && import_typescript11.default.isJsxExpression(attr.initializer) && attr.initializer.expression) {
|
|
193759
193958
|
if (value.kind === "expression" && value.templateExpr === undefined) {
|
|
193760
193959
|
const rewritten = rewriteBarePropRefs2(value.expr, attr.initializer.expression, ctx);
|
|
193761
193960
|
if (rewritten !== value.expr) {
|
|
@@ -193794,7 +193993,7 @@ function templatePartsToJsString(parts) {
|
|
|
193794
193993
|
return result;
|
|
193795
193994
|
}
|
|
193796
193995
|
function checkBareSignalOrMemoIdentifier(expr, ctx) {
|
|
193797
|
-
if (!
|
|
193996
|
+
if (!import_typescript11.default.isIdentifier(expr))
|
|
193798
193997
|
return;
|
|
193799
193998
|
const name = expr.text;
|
|
193800
193999
|
for (const signal of ctx.analyzer.signals) {
|
|
@@ -193825,12 +194024,12 @@ function checkBareSignalOrMemoIdentifier(expr, ctx) {
|
|
|
193825
194024
|
function isArrayExprDirectPropRef(arrayExpr, ctx) {
|
|
193826
194025
|
const propNames = new Set(ctx.patterns.props.map((p) => p.name));
|
|
193827
194026
|
const propsObjName = ctx.analyzer.propsObjectName;
|
|
193828
|
-
if (
|
|
194027
|
+
if (import_typescript11.default.isIdentifier(arrayExpr)) {
|
|
193829
194028
|
return propNames.has(arrayExpr.text);
|
|
193830
194029
|
}
|
|
193831
|
-
if (
|
|
194030
|
+
if (import_typescript11.default.isPropertyAccessExpression(arrayExpr) && propsObjName) {
|
|
193832
194031
|
const obj = arrayExpr.expression;
|
|
193833
|
-
if (
|
|
194032
|
+
if (import_typescript11.default.isIdentifier(obj) && obj.text === propsObjName) {
|
|
193834
194033
|
return true;
|
|
193835
194034
|
}
|
|
193836
194035
|
}
|
|
@@ -193870,6 +194069,16 @@ function isReactiveExpression(expr, ctx, astNode) {
|
|
|
193870
194069
|
}
|
|
193871
194070
|
return false;
|
|
193872
194071
|
}
|
|
194072
|
+
function shouldAutoDeferReactiveBrand(expr, ctx) {
|
|
194073
|
+
const checker = ctx.analyzer.checker;
|
|
194074
|
+
if (!checker)
|
|
194075
|
+
return false;
|
|
194076
|
+
if (!containsReactiveExpression(expr, checker))
|
|
194077
|
+
return false;
|
|
194078
|
+
if (isSignalOrMemoReference(ctx.getJS(expr), ctx))
|
|
194079
|
+
return false;
|
|
194080
|
+
return true;
|
|
194081
|
+
}
|
|
193873
194082
|
function isSignalOrMemoReference(expr, ctx, visited) {
|
|
193874
194083
|
for (const { pattern } of ctx.patterns.signals) {
|
|
193875
194084
|
if (pattern.test(expr))
|
|
@@ -194012,7 +194221,7 @@ function buildIfStatementChain(analyzer, ctx) {
|
|
|
194012
194221
|
jsxBranchLocalNames.add(n);
|
|
194013
194222
|
}
|
|
194014
194223
|
for (const decl of condReturn.scopeVariables) {
|
|
194015
|
-
if (
|
|
194224
|
+
if (import_typescript11.default.isIdentifier(decl.name) && decl.initializer) {
|
|
194016
194225
|
branchScopeVars.set(decl.name.text, decl.initializer);
|
|
194017
194226
|
if (initializerShapeContainsJsx(decl.initializer)) {
|
|
194018
194227
|
jsxBranchLocalNames.add(decl.name.text);
|
|
@@ -194079,7 +194288,7 @@ function buildIfStatementChain(analyzer, ctx) {
|
|
|
194079
194288
|
}
|
|
194080
194289
|
const scopeVariables = [];
|
|
194081
194290
|
for (const decl of condReturn.scopeVariables) {
|
|
194082
|
-
if (
|
|
194291
|
+
if (import_typescript11.default.isIdentifier(decl.name) && decl.initializer) {
|
|
194083
194292
|
const init = ctx.getJS(decl.initializer);
|
|
194084
194293
|
const typedInit = decl.initializer.getText(ctx.sourceFile);
|
|
194085
194294
|
scopeVariables.push({
|
|
@@ -194105,45 +194314,6 @@ function buildIfStatementChain(analyzer, ctx) {
|
|
|
194105
194314
|
return alternate;
|
|
194106
194315
|
}
|
|
194107
194316
|
|
|
194108
|
-
// ../jsx/src/html-constants.ts
|
|
194109
|
-
var BOOLEAN_ATTRS = new Set([
|
|
194110
|
-
"checked",
|
|
194111
|
-
"disabled",
|
|
194112
|
-
"readonly",
|
|
194113
|
-
"selected",
|
|
194114
|
-
"required",
|
|
194115
|
-
"hidden",
|
|
194116
|
-
"autofocus",
|
|
194117
|
-
"autoplay",
|
|
194118
|
-
"controls",
|
|
194119
|
-
"loop",
|
|
194120
|
-
"muted",
|
|
194121
|
-
"open",
|
|
194122
|
-
"multiple",
|
|
194123
|
-
"novalidate"
|
|
194124
|
-
]);
|
|
194125
|
-
|
|
194126
|
-
// ../jsx/src/ir-to-client-js/csr-substitute.ts
|
|
194127
|
-
var import_typescript11 = __toESM(require_typescript(), 1);
|
|
194128
|
-
|
|
194129
|
-
// ../jsx/src/ir-to-client-js/html-template.ts
|
|
194130
|
-
var VOID_ELEMENTS = new Set([
|
|
194131
|
-
"area",
|
|
194132
|
-
"base",
|
|
194133
|
-
"br",
|
|
194134
|
-
"col",
|
|
194135
|
-
"embed",
|
|
194136
|
-
"hr",
|
|
194137
|
-
"img",
|
|
194138
|
-
"input",
|
|
194139
|
-
"link",
|
|
194140
|
-
"meta",
|
|
194141
|
-
"param",
|
|
194142
|
-
"source",
|
|
194143
|
-
"track",
|
|
194144
|
-
"wbr"
|
|
194145
|
-
]);
|
|
194146
|
-
|
|
194147
194317
|
// ../jsx/src/ir-to-client-js/identifiers.ts
|
|
194148
194318
|
var KEYWORDS_AND_GLOBALS = new Set([
|
|
194149
194319
|
"true",
|
|
@@ -194478,6 +194648,97 @@ var CLIENT_PACKAGE_SOURCES = new Set([
|
|
|
194478
194648
|
"@barefootjs/client",
|
|
194479
194649
|
"@barefootjs/client/runtime"
|
|
194480
194650
|
]);
|
|
194651
|
+
// ../jsx/src/debug.ts
|
|
194652
|
+
function escapeForIdBoundary(name) {
|
|
194653
|
+
return name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
194654
|
+
}
|
|
194655
|
+
function makeIdCallRegex(name) {
|
|
194656
|
+
return new RegExp(`(?:^|[^\\w$])${escapeForIdBoundary(name)}\\s*\\(`);
|
|
194657
|
+
}
|
|
194658
|
+
function buildLocalFunctionSetterMap(meta, setterToSignal) {
|
|
194659
|
+
const setterPatterns = [...setterToSignal.keys()].map((s) => ({ name: s, re: makeIdCallRegex(s) }));
|
|
194660
|
+
const bodies = new Map;
|
|
194661
|
+
for (const fn of meta.localFunctions)
|
|
194662
|
+
bodies.set(fn.name, fn.body);
|
|
194663
|
+
for (const c of meta.localConstants) {
|
|
194664
|
+
if (c.containsArrow && c.value)
|
|
194665
|
+
bodies.set(c.name, c.value);
|
|
194666
|
+
}
|
|
194667
|
+
const fnNamePatterns = [...bodies.keys()].map((n) => ({ name: n, re: makeIdCallRegex(n) }));
|
|
194668
|
+
const directSetters = new Map;
|
|
194669
|
+
const directCalls = new Map;
|
|
194670
|
+
for (const [name, body] of bodies) {
|
|
194671
|
+
const setters = [];
|
|
194672
|
+
for (const { name: setter, re } of setterPatterns) {
|
|
194673
|
+
if (re.test(body))
|
|
194674
|
+
setters.push(setter);
|
|
194675
|
+
}
|
|
194676
|
+
directSetters.set(name, setters);
|
|
194677
|
+
const calls = [];
|
|
194678
|
+
for (const { name: callee, re } of fnNamePatterns) {
|
|
194679
|
+
if (callee !== name && re.test(body))
|
|
194680
|
+
calls.push(callee);
|
|
194681
|
+
}
|
|
194682
|
+
directCalls.set(name, calls);
|
|
194683
|
+
}
|
|
194684
|
+
const resolve2 = (name, stack) => {
|
|
194685
|
+
const out = [];
|
|
194686
|
+
const seen = new Set;
|
|
194687
|
+
for (const setter of directSetters.get(name) ?? []) {
|
|
194688
|
+
if (!seen.has(setter)) {
|
|
194689
|
+
out.push({ setter, chain: [] });
|
|
194690
|
+
seen.add(setter);
|
|
194691
|
+
}
|
|
194692
|
+
}
|
|
194693
|
+
for (const callee of directCalls.get(name) ?? []) {
|
|
194694
|
+
if (stack.has(callee))
|
|
194695
|
+
continue;
|
|
194696
|
+
const sub = resolve2(callee, new Set([...stack, callee]));
|
|
194697
|
+
for (const r of sub) {
|
|
194698
|
+
if (!seen.has(r.setter)) {
|
|
194699
|
+
out.push({ setter: r.setter, chain: [callee, ...r.chain] });
|
|
194700
|
+
seen.add(r.setter);
|
|
194701
|
+
}
|
|
194702
|
+
}
|
|
194703
|
+
}
|
|
194704
|
+
return out;
|
|
194705
|
+
};
|
|
194706
|
+
const result = new Map;
|
|
194707
|
+
for (const name of bodies.keys()) {
|
|
194708
|
+
const resolved = resolve2(name, new Set([name]));
|
|
194709
|
+
if (resolved.length > 0)
|
|
194710
|
+
result.set(name, resolved);
|
|
194711
|
+
}
|
|
194712
|
+
return result;
|
|
194713
|
+
}
|
|
194714
|
+
function resolveSetters(handler, setterToSignal, fnSetters) {
|
|
194715
|
+
const refs = [];
|
|
194716
|
+
const seen = new Set;
|
|
194717
|
+
const trimmed = handler.trim();
|
|
194718
|
+
for (const [setter, signal] of setterToSignal) {
|
|
194719
|
+
if (trimmed === setter || makeIdCallRegex(setter).test(handler)) {
|
|
194720
|
+
if (!seen.has(setter)) {
|
|
194721
|
+
refs.push({ setter, signal });
|
|
194722
|
+
seen.add(setter);
|
|
194723
|
+
}
|
|
194724
|
+
}
|
|
194725
|
+
}
|
|
194726
|
+
for (const [fnName, resolutions] of fnSetters) {
|
|
194727
|
+
if (trimmed === fnName || makeIdCallRegex(fnName).test(handler)) {
|
|
194728
|
+
for (const r of resolutions) {
|
|
194729
|
+
if (!seen.has(r.setter)) {
|
|
194730
|
+
refs.push({
|
|
194731
|
+
setter: r.setter,
|
|
194732
|
+
signal: setterToSignal.get(r.setter) ?? null,
|
|
194733
|
+
via: [fnName, ...r.chain]
|
|
194734
|
+
});
|
|
194735
|
+
seen.add(r.setter);
|
|
194736
|
+
}
|
|
194737
|
+
}
|
|
194738
|
+
}
|
|
194739
|
+
}
|
|
194740
|
+
return refs;
|
|
194741
|
+
}
|
|
194481
194742
|
// src/test-node.ts
|
|
194482
194743
|
class TestNode {
|
|
194483
194744
|
tag;
|
|
@@ -194490,8 +194751,24 @@ class TestNode {
|
|
|
194490
194751
|
aria;
|
|
194491
194752
|
dataState;
|
|
194492
194753
|
events;
|
|
194754
|
+
handlers;
|
|
194493
194755
|
reactive;
|
|
194494
194756
|
componentName;
|
|
194757
|
+
get onClick() {
|
|
194758
|
+
return this.handlers.click;
|
|
194759
|
+
}
|
|
194760
|
+
get onInput() {
|
|
194761
|
+
return this.handlers.input;
|
|
194762
|
+
}
|
|
194763
|
+
get onChange() {
|
|
194764
|
+
return this.handlers.change;
|
|
194765
|
+
}
|
|
194766
|
+
get onSubmit() {
|
|
194767
|
+
return this.handlers.submit;
|
|
194768
|
+
}
|
|
194769
|
+
on(event) {
|
|
194770
|
+
return this.handlers[event] ?? null;
|
|
194771
|
+
}
|
|
194495
194772
|
constructor(data) {
|
|
194496
194773
|
this.tag = data.tag;
|
|
194497
194774
|
this.type = data.type;
|
|
@@ -194503,6 +194780,7 @@ class TestNode {
|
|
|
194503
194780
|
this.aria = data.aria;
|
|
194504
194781
|
this.dataState = data.dataState;
|
|
194505
194782
|
this.events = data.events;
|
|
194783
|
+
this.handlers = data.handlers;
|
|
194506
194784
|
this.reactive = data.reactive;
|
|
194507
194785
|
this.componentName = data.componentName;
|
|
194508
194786
|
}
|
|
@@ -194550,41 +194828,52 @@ class TestNode {
|
|
|
194550
194828
|
}
|
|
194551
194829
|
|
|
194552
194830
|
// src/ir-to-test-node.ts
|
|
194553
|
-
function irNodeToTestNode(node, constantMap) {
|
|
194831
|
+
function irNodeToTestNode(node, constantMap, metadata) {
|
|
194554
194832
|
const cmap = constantMap ?? new Map;
|
|
194555
|
-
|
|
194833
|
+
const setterToSignal = new Map;
|
|
194834
|
+
const fnSetters = new Map;
|
|
194835
|
+
if (metadata) {
|
|
194836
|
+
for (const s of metadata.signals) {
|
|
194837
|
+
if (s.setter)
|
|
194838
|
+
setterToSignal.set(s.setter, s.getter);
|
|
194839
|
+
}
|
|
194840
|
+
for (const [k, v] of buildLocalFunctionSetterMap(metadata, setterToSignal)) {
|
|
194841
|
+
fnSetters.set(k, v);
|
|
194842
|
+
}
|
|
194843
|
+
}
|
|
194844
|
+
return convert(node, { cmap, setterToSignal, fnSetters });
|
|
194556
194845
|
}
|
|
194557
|
-
function convert(node,
|
|
194846
|
+
function convert(node, ctx) {
|
|
194558
194847
|
switch (node.type) {
|
|
194559
194848
|
case "element":
|
|
194560
|
-
return convertElement(node,
|
|
194849
|
+
return convertElement(node, ctx);
|
|
194561
194850
|
case "text":
|
|
194562
194851
|
return convertText(node);
|
|
194563
194852
|
case "expression":
|
|
194564
194853
|
return convertExpression(node);
|
|
194565
194854
|
case "conditional":
|
|
194566
|
-
return convertConditional(node,
|
|
194855
|
+
return convertConditional(node, ctx);
|
|
194567
194856
|
case "loop":
|
|
194568
|
-
return convertLoop(node,
|
|
194857
|
+
return convertLoop(node, ctx);
|
|
194569
194858
|
case "component":
|
|
194570
|
-
return convertComponent(node,
|
|
194859
|
+
return convertComponent(node, ctx);
|
|
194571
194860
|
case "fragment":
|
|
194572
|
-
return convertFragment(node,
|
|
194861
|
+
return convertFragment(node, ctx);
|
|
194573
194862
|
case "slot":
|
|
194574
194863
|
return convertSlot(node);
|
|
194575
194864
|
case "if-statement":
|
|
194576
|
-
return convertIfStatement(node,
|
|
194865
|
+
return convertIfStatement(node, ctx);
|
|
194577
194866
|
case "provider":
|
|
194578
|
-
return convertProvider(node,
|
|
194867
|
+
return convertProvider(node, ctx);
|
|
194579
194868
|
case "async":
|
|
194580
|
-
return convertAsync(node,
|
|
194869
|
+
return convertAsync(node, ctx);
|
|
194581
194870
|
default: {
|
|
194582
194871
|
const _exhaustive = node;
|
|
194583
194872
|
throw new Error(`Unhandled IR node type: ${_exhaustive.type}`);
|
|
194584
194873
|
}
|
|
194585
194874
|
}
|
|
194586
194875
|
}
|
|
194587
|
-
function convertElement(node,
|
|
194876
|
+
function convertElement(node, ctx) {
|
|
194588
194877
|
const props = {};
|
|
194589
194878
|
const aria = {};
|
|
194590
194879
|
let role = null;
|
|
@@ -194595,8 +194884,8 @@ function convertElement(node, cmap) {
|
|
|
194595
194884
|
if (attr.name === "className" || attr.name === "class") {
|
|
194596
194885
|
if (typeof value === "string") {
|
|
194597
194886
|
const isDynamic = attr.value.kind === "expression" || attr.value.kind === "template" || attr.value.kind === "spread";
|
|
194598
|
-
if (isDynamic && cmap.size > 0) {
|
|
194599
|
-
const resolved = resolveClassValue(value, cmap);
|
|
194887
|
+
if (isDynamic && ctx.cmap.size > 0) {
|
|
194888
|
+
const resolved = resolveClassValue(value, ctx.cmap);
|
|
194600
194889
|
if (resolved !== null) {
|
|
194601
194890
|
classes = resolved.split(/\s+/).filter(Boolean);
|
|
194602
194891
|
continue;
|
|
@@ -194627,7 +194916,12 @@ function convertElement(node, cmap) {
|
|
|
194627
194916
|
props[attr.name] = value;
|
|
194628
194917
|
}
|
|
194629
194918
|
const events = node.events.map((e) => e.name);
|
|
194630
|
-
const
|
|
194919
|
+
const handlers = {};
|
|
194920
|
+
for (const event of node.events) {
|
|
194921
|
+
const refs = resolveSetters(event.handler, ctx.setterToSignal, ctx.fnSetters);
|
|
194922
|
+
handlers[event.name] = refsToHandler(refs);
|
|
194923
|
+
}
|
|
194924
|
+
const children = node.children.map((c) => convert(c, ctx));
|
|
194631
194925
|
return new TestNode({
|
|
194632
194926
|
tag: node.tag,
|
|
194633
194927
|
type: "element",
|
|
@@ -194639,6 +194933,7 @@ function convertElement(node, cmap) {
|
|
|
194639
194933
|
aria,
|
|
194640
194934
|
dataState,
|
|
194641
194935
|
events,
|
|
194936
|
+
handlers,
|
|
194642
194937
|
reactive: false,
|
|
194643
194938
|
componentName: null
|
|
194644
194939
|
});
|
|
@@ -194655,6 +194950,7 @@ function convertText(node) {
|
|
|
194655
194950
|
aria: {},
|
|
194656
194951
|
dataState: null,
|
|
194657
194952
|
events: [],
|
|
194953
|
+
handlers: {},
|
|
194658
194954
|
reactive: false,
|
|
194659
194955
|
componentName: null
|
|
194660
194956
|
});
|
|
@@ -194671,14 +194967,15 @@ function convertExpression(node) {
|
|
|
194671
194967
|
aria: {},
|
|
194672
194968
|
dataState: null,
|
|
194673
194969
|
events: [],
|
|
194970
|
+
handlers: {},
|
|
194674
194971
|
reactive: node.reactive,
|
|
194675
194972
|
componentName: null
|
|
194676
194973
|
});
|
|
194677
194974
|
}
|
|
194678
|
-
function convertConditional(node,
|
|
194679
|
-
const children = [convert(node.whenTrue,
|
|
194975
|
+
function convertConditional(node, ctx) {
|
|
194976
|
+
const children = [convert(node.whenTrue, ctx)];
|
|
194680
194977
|
if (node.whenFalse) {
|
|
194681
|
-
children.push(convert(node.whenFalse,
|
|
194978
|
+
children.push(convert(node.whenFalse, ctx));
|
|
194682
194979
|
}
|
|
194683
194980
|
return new TestNode({
|
|
194684
194981
|
tag: null,
|
|
@@ -194691,12 +194988,13 @@ function convertConditional(node, cmap) {
|
|
|
194691
194988
|
aria: {},
|
|
194692
194989
|
dataState: null,
|
|
194693
194990
|
events: [],
|
|
194991
|
+
handlers: {},
|
|
194694
194992
|
reactive: node.reactive,
|
|
194695
194993
|
componentName: null
|
|
194696
194994
|
});
|
|
194697
194995
|
}
|
|
194698
|
-
function convertLoop(node,
|
|
194699
|
-
const children = node.children.map((c) => convert(c,
|
|
194996
|
+
function convertLoop(node, ctx) {
|
|
194997
|
+
const children = node.children.map((c) => convert(c, ctx));
|
|
194700
194998
|
return new TestNode({
|
|
194701
194999
|
tag: null,
|
|
194702
195000
|
type: "loop",
|
|
@@ -194708,12 +195006,15 @@ function convertLoop(node, cmap) {
|
|
|
194708
195006
|
aria: {},
|
|
194709
195007
|
dataState: null,
|
|
194710
195008
|
events: [],
|
|
195009
|
+
handlers: {},
|
|
194711
195010
|
reactive: false,
|
|
194712
195011
|
componentName: null
|
|
194713
195012
|
});
|
|
194714
195013
|
}
|
|
194715
|
-
function convertComponent(node,
|
|
195014
|
+
function convertComponent(node, ctx) {
|
|
194716
195015
|
const props = {};
|
|
195016
|
+
const events = [];
|
|
195017
|
+
const handlers = {};
|
|
194717
195018
|
for (const prop of node.props) {
|
|
194718
195019
|
switch (prop.value.kind) {
|
|
194719
195020
|
case "literal":
|
|
@@ -194734,8 +195035,13 @@ function convertComponent(node, cmap) {
|
|
|
194734
195035
|
props[prop.name] = null;
|
|
194735
195036
|
break;
|
|
194736
195037
|
}
|
|
195038
|
+
if (/^on[A-Z]/.test(prop.name) && prop.value.kind === "expression") {
|
|
195039
|
+
const eventName = prop.name.charAt(2).toLowerCase() + prop.name.slice(3);
|
|
195040
|
+
events.push(eventName);
|
|
195041
|
+
handlers[eventName] = refsToHandler(resolveSetters(prop.value.expr, ctx.setterToSignal, ctx.fnSetters));
|
|
195042
|
+
}
|
|
194737
195043
|
}
|
|
194738
|
-
const children = node.children.map((c) => convert(c,
|
|
195044
|
+
const children = node.children.map((c) => convert(c, ctx));
|
|
194739
195045
|
return new TestNode({
|
|
194740
195046
|
tag: null,
|
|
194741
195047
|
type: "component",
|
|
@@ -194746,13 +195052,14 @@ function convertComponent(node, cmap) {
|
|
|
194746
195052
|
role: null,
|
|
194747
195053
|
aria: {},
|
|
194748
195054
|
dataState: null,
|
|
194749
|
-
events
|
|
195055
|
+
events,
|
|
195056
|
+
handlers,
|
|
194750
195057
|
reactive: false,
|
|
194751
195058
|
componentName: node.name
|
|
194752
195059
|
});
|
|
194753
195060
|
}
|
|
194754
|
-
function convertFragment(node,
|
|
194755
|
-
const children = node.children.map((c) => convert(c,
|
|
195061
|
+
function convertFragment(node, ctx) {
|
|
195062
|
+
const children = node.children.map((c) => convert(c, ctx));
|
|
194756
195063
|
return new TestNode({
|
|
194757
195064
|
tag: null,
|
|
194758
195065
|
type: "fragment",
|
|
@@ -194764,6 +195071,7 @@ function convertFragment(node, cmap) {
|
|
|
194764
195071
|
aria: {},
|
|
194765
195072
|
dataState: null,
|
|
194766
195073
|
events: [],
|
|
195074
|
+
handlers: {},
|
|
194767
195075
|
reactive: false,
|
|
194768
195076
|
componentName: null
|
|
194769
195077
|
});
|
|
@@ -194780,14 +195088,15 @@ function convertSlot(_node) {
|
|
|
194780
195088
|
aria: {},
|
|
194781
195089
|
dataState: null,
|
|
194782
195090
|
events: [],
|
|
195091
|
+
handlers: {},
|
|
194783
195092
|
reactive: false,
|
|
194784
195093
|
componentName: null
|
|
194785
195094
|
});
|
|
194786
195095
|
}
|
|
194787
|
-
function convertIfStatement(node,
|
|
194788
|
-
const children = [convert(node.consequent,
|
|
195096
|
+
function convertIfStatement(node, ctx) {
|
|
195097
|
+
const children = [convert(node.consequent, ctx)];
|
|
194789
195098
|
if (node.alternate) {
|
|
194790
|
-
children.push(convert(node.alternate,
|
|
195099
|
+
children.push(convert(node.alternate, ctx));
|
|
194791
195100
|
}
|
|
194792
195101
|
return new TestNode({
|
|
194793
195102
|
tag: null,
|
|
@@ -194800,12 +195109,13 @@ function convertIfStatement(node, cmap) {
|
|
|
194800
195109
|
aria: {},
|
|
194801
195110
|
dataState: null,
|
|
194802
195111
|
events: [],
|
|
195112
|
+
handlers: {},
|
|
194803
195113
|
reactive: false,
|
|
194804
195114
|
componentName: null
|
|
194805
195115
|
});
|
|
194806
195116
|
}
|
|
194807
|
-
function convertProvider(node,
|
|
194808
|
-
const children = node.children.map((c) => convert(c,
|
|
195117
|
+
function convertProvider(node, ctx) {
|
|
195118
|
+
const children = node.children.map((c) => convert(c, ctx));
|
|
194809
195119
|
if (children.length === 1)
|
|
194810
195120
|
return children[0];
|
|
194811
195121
|
return new TestNode({
|
|
@@ -194819,12 +195129,13 @@ function convertProvider(node, cmap) {
|
|
|
194819
195129
|
aria: {},
|
|
194820
195130
|
dataState: null,
|
|
194821
195131
|
events: [],
|
|
195132
|
+
handlers: {},
|
|
194822
195133
|
reactive: false,
|
|
194823
195134
|
componentName: null
|
|
194824
195135
|
});
|
|
194825
195136
|
}
|
|
194826
|
-
function convertAsync(node,
|
|
194827
|
-
const children = node.children.map((c) => convert(c,
|
|
195137
|
+
function convertAsync(node, ctx) {
|
|
195138
|
+
const children = node.children.map((c) => convert(c, ctx));
|
|
194828
195139
|
return new TestNode({
|
|
194829
195140
|
tag: null,
|
|
194830
195141
|
type: "fragment",
|
|
@@ -194836,10 +195147,24 @@ function convertAsync(node, cmap) {
|
|
|
194836
195147
|
aria: {},
|
|
194837
195148
|
dataState: null,
|
|
194838
195149
|
events: [],
|
|
195150
|
+
handlers: {},
|
|
194839
195151
|
reactive: false,
|
|
194840
195152
|
componentName: null
|
|
194841
195153
|
});
|
|
194842
195154
|
}
|
|
195155
|
+
function refsToHandler(refs) {
|
|
195156
|
+
const setters = [];
|
|
195157
|
+
const via = [];
|
|
195158
|
+
for (const ref of refs) {
|
|
195159
|
+
if (!setters.includes(ref.setter))
|
|
195160
|
+
setters.push(ref.setter);
|
|
195161
|
+
for (const v of ref.via ?? []) {
|
|
195162
|
+
if (!via.includes(v))
|
|
195163
|
+
via.push(v);
|
|
195164
|
+
}
|
|
195165
|
+
}
|
|
195166
|
+
return { setters, via };
|
|
195167
|
+
}
|
|
194843
195168
|
function resolveClassValue(value, cmap) {
|
|
194844
195169
|
if (cmap.has(value)) {
|
|
194845
195170
|
return cmap.get(value);
|
|
@@ -195015,7 +195340,7 @@ function renderToTest(source, filePath, componentName) {
|
|
|
195015
195340
|
}
|
|
195016
195341
|
const metadata = buildMetadata2(ctx);
|
|
195017
195342
|
const constantMap = resolveConstants(metadata.localConstants);
|
|
195018
|
-
const root = irNodeToTestNode(ir, constantMap);
|
|
195343
|
+
const root = irNodeToTestNode(ir, constantMap, metadata);
|
|
195019
195344
|
const signals = metadata.signals.map((s) => s.getter);
|
|
195020
195345
|
const memos = metadata.memos.map((m) => m.name);
|
|
195021
195346
|
const effects = metadata.effects.length;
|
|
@@ -195072,6 +195397,7 @@ function emptyResult(componentName, isClient, errors) {
|
|
|
195072
195397
|
aria: {},
|
|
195073
195398
|
dataState: null,
|
|
195074
195399
|
events: [],
|
|
195400
|
+
handlers: {},
|
|
195075
195401
|
reactive: false,
|
|
195076
195402
|
componentName: null
|
|
195077
195403
|
});
|