@barefootjs/test 0.34.0 → 0.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +615 -527
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -187291,7 +187291,7 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
187291
187291
|
var import_typescript25 = __toESM(require_typescript(), 1);
|
|
187292
187292
|
|
|
187293
187293
|
// ../jsx/src/analyzer.ts
|
|
187294
|
-
var
|
|
187294
|
+
var import_typescript11 = __toESM(require_typescript(), 1);
|
|
187295
187295
|
|
|
187296
187296
|
// ../jsx/src/expression-parser.ts
|
|
187297
187297
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
@@ -189438,6 +189438,12 @@ class BindingScope {
|
|
|
189438
189438
|
}
|
|
189439
189439
|
}
|
|
189440
189440
|
|
|
189441
|
+
// ../jsx/src/ir-to-client-js/safe-html.ts
|
|
189442
|
+
function safeHtml(expr) {
|
|
189443
|
+
return expr;
|
|
189444
|
+
}
|
|
189445
|
+
var EMPTY_MARKUP = safeHtml("''");
|
|
189446
|
+
|
|
189441
189447
|
// ../jsx/src/ir-to-client-js/html-template.ts
|
|
189442
189448
|
function splitTemplateInterpolations(inner) {
|
|
189443
189449
|
const parts = [];
|
|
@@ -189626,8 +189632,6 @@ function collectAstPropRefs(node, propNames, out) {
|
|
|
189626
189632
|
walkWithScope(node, (n, parent, shadowed) => {
|
|
189627
189633
|
if (shadowed || !propNames.has(n.text))
|
|
189628
189634
|
return;
|
|
189629
|
-
if (parent && import_typescript7.default.isShorthandPropertyAssignment(parent) && parent.name === n)
|
|
189630
|
-
return;
|
|
189631
189635
|
if (isNonValuePosition(n, parent))
|
|
189632
189636
|
return;
|
|
189633
189637
|
out.add(n.text);
|
|
@@ -189717,7 +189721,7 @@ function incrementCounter(key) {
|
|
|
189717
189721
|
}
|
|
189718
189722
|
|
|
189719
189723
|
// ../jsx/src/analyzer-context.ts
|
|
189720
|
-
var
|
|
189724
|
+
var import_typescript10 = __toESM(require_typescript(), 1);
|
|
189721
189725
|
|
|
189722
189726
|
// ../jsx/src/strip-types.ts
|
|
189723
189727
|
var import_typescript8 = __toESM(require_typescript(), 1);
|
|
@@ -189934,6 +189938,140 @@ function findAngleBracketAfter(lastTypeArg, fullText) {
|
|
|
189934
189938
|
return -1;
|
|
189935
189939
|
}
|
|
189936
189940
|
|
|
189941
|
+
// ../jsx/src/reactivity-checker.ts
|
|
189942
|
+
var import_typescript9 = __toESM(require_typescript(), 1);
|
|
189943
|
+
var REACTIVE_BRAND = "__reactive";
|
|
189944
|
+
function queryType(checker, node) {
|
|
189945
|
+
incrementCounter("typeCheckerQueries");
|
|
189946
|
+
return checker.getTypeAtLocation(node);
|
|
189947
|
+
}
|
|
189948
|
+
function isReactiveType(type2) {
|
|
189949
|
+
return type2.getProperty(REACTIVE_BRAND) !== undefined;
|
|
189950
|
+
}
|
|
189951
|
+
var NOT_REACTIVE = { isReactive: false, reason: { kind: "not-reactive" } };
|
|
189952
|
+
function safeGetText(node) {
|
|
189953
|
+
try {
|
|
189954
|
+
return node.getText();
|
|
189955
|
+
} catch {
|
|
189956
|
+
return "";
|
|
189957
|
+
}
|
|
189958
|
+
}
|
|
189959
|
+
function analyze(node, checker) {
|
|
189960
|
+
if (import_typescript9.default.isPropertyAccessExpression(node)) {
|
|
189961
|
+
try {
|
|
189962
|
+
const type2 = queryType(checker, node);
|
|
189963
|
+
if (isReactiveType(type2)) {
|
|
189964
|
+
return {
|
|
189965
|
+
isReactive: true,
|
|
189966
|
+
reason: { kind: "brand", via: "property-access", nodeText: safeGetText(node) }
|
|
189967
|
+
};
|
|
189968
|
+
}
|
|
189969
|
+
} catch {}
|
|
189970
|
+
const sub = analyze(node.expression, checker);
|
|
189971
|
+
if (sub.isReactive) {
|
|
189972
|
+
return {
|
|
189973
|
+
isReactive: true,
|
|
189974
|
+
reason: {
|
|
189975
|
+
kind: "child",
|
|
189976
|
+
via: "property-access-object",
|
|
189977
|
+
childText: safeGetText(node.expression),
|
|
189978
|
+
childReason: sub.reason
|
|
189979
|
+
}
|
|
189980
|
+
};
|
|
189981
|
+
}
|
|
189982
|
+
return NOT_REACTIVE;
|
|
189983
|
+
}
|
|
189984
|
+
if (import_typescript9.default.isIdentifier(node)) {
|
|
189985
|
+
try {
|
|
189986
|
+
const type2 = queryType(checker, node);
|
|
189987
|
+
if (isReactiveType(type2)) {
|
|
189988
|
+
return {
|
|
189989
|
+
isReactive: true,
|
|
189990
|
+
reason: { kind: "brand", via: "identifier", nodeText: safeGetText(node) }
|
|
189991
|
+
};
|
|
189992
|
+
}
|
|
189993
|
+
} catch {}
|
|
189994
|
+
return NOT_REACTIVE;
|
|
189995
|
+
}
|
|
189996
|
+
if (import_typescript9.default.isCallExpression(node)) {
|
|
189997
|
+
try {
|
|
189998
|
+
const calleeType = queryType(checker, node.expression);
|
|
189999
|
+
if (isReactiveType(calleeType)) {
|
|
190000
|
+
return {
|
|
190001
|
+
isReactive: true,
|
|
190002
|
+
reason: { kind: "brand", via: "callee", nodeText: safeGetText(node) }
|
|
190003
|
+
};
|
|
190004
|
+
}
|
|
190005
|
+
} catch {}
|
|
190006
|
+
}
|
|
190007
|
+
let foundChild;
|
|
190008
|
+
let foundChildText = "";
|
|
190009
|
+
import_typescript9.default.forEachChild(node, (child) => {
|
|
190010
|
+
if (foundChild?.isReactive)
|
|
190011
|
+
return;
|
|
190012
|
+
const result = analyze(child, checker);
|
|
190013
|
+
if (result.isReactive) {
|
|
190014
|
+
foundChild = result;
|
|
190015
|
+
foundChildText = safeGetText(child);
|
|
190016
|
+
}
|
|
190017
|
+
});
|
|
190018
|
+
if (foundChild?.isReactive) {
|
|
190019
|
+
return {
|
|
190020
|
+
isReactive: true,
|
|
190021
|
+
reason: {
|
|
190022
|
+
kind: "child",
|
|
190023
|
+
via: "sub-expression",
|
|
190024
|
+
childText: foundChildText,
|
|
190025
|
+
childReason: foundChild.reason
|
|
190026
|
+
}
|
|
190027
|
+
};
|
|
190028
|
+
}
|
|
190029
|
+
return NOT_REACTIVE;
|
|
190030
|
+
}
|
|
190031
|
+
var brandTypeReactivityAnalyzer = { analyze };
|
|
190032
|
+
function containsReactiveExpression(node, checker) {
|
|
190033
|
+
incrementCounter("reactivityChecks");
|
|
190034
|
+
return brandTypeReactivityAnalyzer.analyze(node, checker).isReactive;
|
|
190035
|
+
}
|
|
190036
|
+
function nodeContainsJsx(node) {
|
|
190037
|
+
if (import_typescript9.default.isJsxElement(node) || import_typescript9.default.isJsxSelfClosingElement(node) || import_typescript9.default.isJsxFragment(node))
|
|
190038
|
+
return true;
|
|
190039
|
+
return import_typescript9.default.forEachChild(node, nodeContainsJsx) ?? false;
|
|
190040
|
+
}
|
|
190041
|
+
function collectReactiveBrandLeaves(node, checker) {
|
|
190042
|
+
const leaves = [];
|
|
190043
|
+
const visit = (n) => {
|
|
190044
|
+
if (import_typescript9.default.isPropertyAccessExpression(n)) {
|
|
190045
|
+
try {
|
|
190046
|
+
if (isReactiveType(queryType(checker, n))) {
|
|
190047
|
+
leaves.push(n);
|
|
190048
|
+
return;
|
|
190049
|
+
}
|
|
190050
|
+
} catch {}
|
|
190051
|
+
visit(n.expression);
|
|
190052
|
+
return;
|
|
190053
|
+
}
|
|
190054
|
+
if (import_typescript9.default.isIdentifier(n)) {
|
|
190055
|
+
try {
|
|
190056
|
+
if (isReactiveType(queryType(checker, n)))
|
|
190057
|
+
leaves.push(n);
|
|
190058
|
+
} catch {}
|
|
190059
|
+
return;
|
|
190060
|
+
}
|
|
190061
|
+
if (import_typescript9.default.isCallExpression(n)) {
|
|
190062
|
+
try {
|
|
190063
|
+
if (isReactiveType(queryType(checker, n.expression))) {
|
|
190064
|
+
leaves.push(nodeContainsJsx(n) ? n.expression : n);
|
|
190065
|
+
return;
|
|
190066
|
+
}
|
|
190067
|
+
} catch {}
|
|
190068
|
+
}
|
|
190069
|
+
import_typescript9.default.forEachChild(n, visit);
|
|
190070
|
+
};
|
|
190071
|
+
visit(node);
|
|
190072
|
+
return leaves;
|
|
190073
|
+
}
|
|
190074
|
+
|
|
189937
190075
|
// ../jsx/src/analyzer-context.ts
|
|
189938
190076
|
function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
|
|
189939
190077
|
return {
|
|
@@ -189985,7 +190123,7 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
|
|
|
189985
190123
|
} catch {
|
|
189986
190124
|
ownSourceFile = undefined;
|
|
189987
190125
|
}
|
|
189988
|
-
if (process.env.BF_ASSERT_NO_JSX_IN_GETJS === "1" && this.errors.
|
|
190126
|
+
if (process.env.BF_ASSERT_NO_JSX_IN_GETJS === "1" && !this.errors.some((e) => e.severity === "error") && nodeContainsJsx(node)) {
|
|
189989
190127
|
throw new Error("getJS() called on a JSX-bearing node — raw JSX must never be spliced " + "into emitted output. Carry mixed content as structured segments " + "(MapCallbackPreamble / FlatMapCallback) instead.");
|
|
189990
190128
|
}
|
|
189991
190129
|
if (ownSourceFile && ownSourceFile !== sourceFile) {
|
|
@@ -189995,11 +190133,6 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
|
|
|
189995
190133
|
}
|
|
189996
190134
|
};
|
|
189997
190135
|
}
|
|
189998
|
-
function nodeContainsJsx(node) {
|
|
189999
|
-
if (import_typescript9.default.isJsxElement(node) || import_typescript9.default.isJsxSelfClosingElement(node) || import_typescript9.default.isJsxFragment(node))
|
|
190000
|
-
return true;
|
|
190001
|
-
return import_typescript9.default.forEachChild(node, nodeContainsJsx) ?? false;
|
|
190002
|
-
}
|
|
190003
190136
|
function getSourceLocation(node, sourceFile, filePath) {
|
|
190004
190137
|
const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
190005
190138
|
const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());
|
|
@@ -190016,20 +190149,20 @@ function getSourceLocation(node, sourceFile, filePath) {
|
|
|
190016
190149
|
};
|
|
190017
190150
|
}
|
|
190018
190151
|
function membersToProperties(members, sourceFile) {
|
|
190019
|
-
return members.filter(
|
|
190152
|
+
return members.filter(import_typescript10.default.isPropertySignature).map((member) => ({
|
|
190020
190153
|
name: propertyNameText(member.name, sourceFile),
|
|
190021
190154
|
type: typeNodeToTypeInfo(member.type, sourceFile) ?? {
|
|
190022
190155
|
kind: "unknown",
|
|
190023
190156
|
raw: "unknown"
|
|
190024
190157
|
},
|
|
190025
190158
|
optional: !!member.questionToken,
|
|
190026
|
-
readonly: !!member.modifiers?.some((m) => m.kind ===
|
|
190159
|
+
readonly: !!member.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.ReadonlyKeyword)
|
|
190027
190160
|
}));
|
|
190028
190161
|
}
|
|
190029
190162
|
function propertyNameText(name, sourceFile) {
|
|
190030
190163
|
if (!name)
|
|
190031
190164
|
return "";
|
|
190032
|
-
if (
|
|
190165
|
+
if (import_typescript10.default.isStringLiteral(name) || import_typescript10.default.isNumericLiteral(name))
|
|
190033
190166
|
return name.text;
|
|
190034
190167
|
return name.getText(sourceFile);
|
|
190035
190168
|
}
|
|
@@ -190040,56 +190173,56 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
|
|
|
190040
190173
|
const raw = rawOf ? rawOf(typeNode) : typeNode.getText(sourceFile);
|
|
190041
190174
|
const recurse = (n) => typeNodeToTypeInfo(n, sourceFile, rawOf) ?? { kind: "unknown", raw: "unknown" };
|
|
190042
190175
|
switch (typeNode.kind) {
|
|
190043
|
-
case
|
|
190176
|
+
case import_typescript10.default.SyntaxKind.StringKeyword:
|
|
190044
190177
|
return { kind: "primitive", raw, primitive: "string" };
|
|
190045
|
-
case
|
|
190178
|
+
case import_typescript10.default.SyntaxKind.NumberKeyword:
|
|
190046
190179
|
return { kind: "primitive", raw, primitive: "number" };
|
|
190047
|
-
case
|
|
190180
|
+
case import_typescript10.default.SyntaxKind.BooleanKeyword:
|
|
190048
190181
|
return { kind: "primitive", raw, primitive: "boolean" };
|
|
190049
|
-
case
|
|
190182
|
+
case import_typescript10.default.SyntaxKind.NullKeyword:
|
|
190050
190183
|
return { kind: "primitive", raw, primitive: "null" };
|
|
190051
|
-
case
|
|
190184
|
+
case import_typescript10.default.SyntaxKind.UndefinedKeyword:
|
|
190052
190185
|
return { kind: "primitive", raw, primitive: "undefined" };
|
|
190053
190186
|
}
|
|
190054
|
-
if (
|
|
190187
|
+
if (import_typescript10.default.isArrayTypeNode(typeNode)) {
|
|
190055
190188
|
return { kind: "array", raw, elementType: recurse(typeNode.elementType) };
|
|
190056
190189
|
}
|
|
190057
|
-
if (
|
|
190190
|
+
if (import_typescript10.default.isLiteralTypeNode(typeNode)) {
|
|
190058
190191
|
const lit = typeNode.literal;
|
|
190059
|
-
if (
|
|
190192
|
+
if (import_typescript10.default.isStringLiteral(lit) || import_typescript10.default.isNoSubstitutionTemplateLiteral(lit)) {
|
|
190060
190193
|
return { kind: "primitive", raw, primitive: "string", literalValue: lit.text };
|
|
190061
190194
|
}
|
|
190062
|
-
if (
|
|
190195
|
+
if (import_typescript10.default.isNumericLiteral(lit)) {
|
|
190063
190196
|
return { kind: "primitive", raw, primitive: "number", literalValue: lit.text };
|
|
190064
190197
|
}
|
|
190065
|
-
if (
|
|
190198
|
+
if (import_typescript10.default.isPrefixUnaryExpression(lit) && lit.operator === import_typescript10.default.SyntaxKind.MinusToken && import_typescript10.default.isNumericLiteral(lit.operand)) {
|
|
190066
190199
|
return { kind: "primitive", raw, primitive: "number", literalValue: `-${lit.operand.text}` };
|
|
190067
190200
|
}
|
|
190068
|
-
if (lit.kind ===
|
|
190201
|
+
if (lit.kind === import_typescript10.default.SyntaxKind.TrueKeyword || lit.kind === import_typescript10.default.SyntaxKind.FalseKeyword) {
|
|
190069
190202
|
return {
|
|
190070
190203
|
kind: "primitive",
|
|
190071
190204
|
raw,
|
|
190072
190205
|
primitive: "boolean",
|
|
190073
|
-
literalValue: lit.kind ===
|
|
190206
|
+
literalValue: lit.kind === import_typescript10.default.SyntaxKind.TrueKeyword ? "true" : "false"
|
|
190074
190207
|
};
|
|
190075
190208
|
}
|
|
190076
|
-
if (lit.kind ===
|
|
190209
|
+
if (lit.kind === import_typescript10.default.SyntaxKind.NullKeyword) {
|
|
190077
190210
|
return { kind: "primitive", raw, primitive: "null" };
|
|
190078
190211
|
}
|
|
190079
190212
|
return { kind: "unknown", raw };
|
|
190080
190213
|
}
|
|
190081
|
-
if (
|
|
190214
|
+
if (import_typescript10.default.isUnionTypeNode(typeNode)) {
|
|
190082
190215
|
return { kind: "union", raw, unionTypes: typeNode.types.map(recurse) };
|
|
190083
190216
|
}
|
|
190084
|
-
if (
|
|
190217
|
+
if (import_typescript10.default.isTypeLiteralNode(typeNode)) {
|
|
190085
190218
|
return {
|
|
190086
190219
|
kind: "object",
|
|
190087
190220
|
raw,
|
|
190088
190221
|
...synthetic ? {} : { properties: membersToProperties(typeNode.members, sourceFile) }
|
|
190089
190222
|
};
|
|
190090
190223
|
}
|
|
190091
|
-
if (
|
|
190092
|
-
const refName =
|
|
190224
|
+
if (import_typescript10.default.isTypeReferenceNode(typeNode)) {
|
|
190225
|
+
const refName = import_typescript10.default.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : "";
|
|
190093
190226
|
if ((refName === "Array" || refName === "ReadonlyArray") && typeNode.typeArguments?.length === 1) {
|
|
190094
190227
|
return { kind: "array", raw, elementType: recurse(typeNode.typeArguments[0]) };
|
|
190095
190228
|
}
|
|
@@ -190098,7 +190231,7 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
|
|
|
190098
190231
|
raw
|
|
190099
190232
|
};
|
|
190100
190233
|
}
|
|
190101
|
-
if (
|
|
190234
|
+
if (import_typescript10.default.isFunctionTypeNode(typeNode)) {
|
|
190102
190235
|
if (synthetic)
|
|
190103
190236
|
return { kind: "function", raw };
|
|
190104
190237
|
return {
|
|
@@ -190118,15 +190251,15 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
|
|
|
190118
190251
|
}
|
|
190119
190252
|
return { kind: "unknown", raw };
|
|
190120
190253
|
}
|
|
190121
|
-
var _typePrinter =
|
|
190122
|
-
var _blankTypeSourceFile =
|
|
190254
|
+
var _typePrinter = import_typescript10.default.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
|
|
190255
|
+
var _blankTypeSourceFile = import_typescript10.default.createSourceFile("__bf_types__.ts", "", import_typescript10.default.ScriptTarget.Latest);
|
|
190123
190256
|
function tsTypeToTypeInfo(type2, checker) {
|
|
190124
|
-
const node = checker.typeToTypeNode(type2, undefined,
|
|
190257
|
+
const node = checker.typeToTypeNode(type2, undefined, import_typescript10.default.NodeBuilderFlags.NoTruncation);
|
|
190125
190258
|
if (!node)
|
|
190126
190259
|
return null;
|
|
190127
190260
|
const rawOf = (n) => {
|
|
190128
190261
|
try {
|
|
190129
|
-
return _typePrinter.printNode(
|
|
190262
|
+
return _typePrinter.printNode(import_typescript10.default.EmitHint.Unspecified, n, _blankTypeSourceFile);
|
|
190130
190263
|
} catch {
|
|
190131
190264
|
return "unknown";
|
|
190132
190265
|
}
|
|
@@ -190137,16 +190270,16 @@ function isPascalCase(name) {
|
|
|
190137
190270
|
return /^[A-Z][a-zA-Z0-9]*$/.test(name);
|
|
190138
190271
|
}
|
|
190139
190272
|
function isComponentFunction(node) {
|
|
190140
|
-
return
|
|
190273
|
+
return import_typescript10.default.isFunctionDeclaration(node) && !!node.name && isPascalCase(node.name.text) && !!node.body;
|
|
190141
190274
|
}
|
|
190142
190275
|
function isArrowComponentFunction(node) {
|
|
190143
|
-
if (!
|
|
190276
|
+
if (!import_typescript10.default.isVariableDeclaration(node))
|
|
190144
190277
|
return false;
|
|
190145
|
-
if (!
|
|
190278
|
+
if (!import_typescript10.default.isIdentifier(node.name))
|
|
190146
190279
|
return false;
|
|
190147
190280
|
if (!isPascalCase(node.name.text))
|
|
190148
190281
|
return false;
|
|
190149
|
-
if (!node.initializer || !
|
|
190282
|
+
if (!node.initializer || !import_typescript10.default.isArrowFunction(node.initializer))
|
|
190150
190283
|
return false;
|
|
190151
190284
|
return true;
|
|
190152
190285
|
}
|
|
@@ -190400,9 +190533,9 @@ function needsTypeBasedDetection(source) {
|
|
|
190400
190533
|
}
|
|
190401
190534
|
function findBrandPackageImportLoc(sourceFile, filePath) {
|
|
190402
190535
|
for (const stmt of sourceFile.statements) {
|
|
190403
|
-
if (!
|
|
190536
|
+
if (!import_typescript11.default.isImportDeclaration(stmt))
|
|
190404
190537
|
continue;
|
|
190405
|
-
if (!
|
|
190538
|
+
if (!import_typescript11.default.isStringLiteral(stmt.moduleSpecifier))
|
|
190406
190539
|
continue;
|
|
190407
190540
|
if (!REACTIVE_BRAND_PACKAGES.includes(stmt.moduleSpecifier.text))
|
|
190408
190541
|
continue;
|
|
@@ -190421,21 +190554,21 @@ function createProgramForFile(source, filePath) {
|
|
|
190421
190554
|
try {
|
|
190422
190555
|
const normalizedPath = path_default.resolve(filePath);
|
|
190423
190556
|
const compilerOptions = {
|
|
190424
|
-
target:
|
|
190425
|
-
module:
|
|
190426
|
-
moduleResolution:
|
|
190427
|
-
jsx:
|
|
190557
|
+
target: import_typescript11.default.ScriptTarget.Latest,
|
|
190558
|
+
module: import_typescript11.default.ModuleKind.ESNext,
|
|
190559
|
+
moduleResolution: import_typescript11.default.ModuleResolutionKind.Bundler,
|
|
190560
|
+
jsx: import_typescript11.default.JsxEmit.ReactJSX,
|
|
190428
190561
|
strict: true,
|
|
190429
190562
|
skipLibCheck: true,
|
|
190430
190563
|
noEmit: true,
|
|
190431
190564
|
baseUrl: path_default.dirname(normalizedPath)
|
|
190432
190565
|
};
|
|
190433
|
-
const defaultHost =
|
|
190566
|
+
const defaultHost = import_typescript11.default.createCompilerHost(compilerOptions);
|
|
190434
190567
|
const virtualHost = {
|
|
190435
190568
|
...defaultHost,
|
|
190436
190569
|
getSourceFile(fileName, languageVersion) {
|
|
190437
190570
|
if (path_default.resolve(fileName) === normalizedPath) {
|
|
190438
|
-
return
|
|
190571
|
+
return import_typescript11.default.createSourceFile(fileName, source, languageVersion, true, import_typescript11.default.ScriptKind.TSX);
|
|
190439
190572
|
}
|
|
190440
190573
|
return defaultHost.getSourceFile(fileName, languageVersion);
|
|
190441
190574
|
},
|
|
@@ -190450,7 +190583,7 @@ function createProgramForFile(source, filePath) {
|
|
|
190450
190583
|
return defaultHost.readFile(fileName);
|
|
190451
190584
|
}
|
|
190452
190585
|
};
|
|
190453
|
-
const program =
|
|
190586
|
+
const program = import_typescript11.default.createProgram([normalizedPath], compilerOptions, virtualHost);
|
|
190454
190587
|
const sourceFile = program.getSourceFile(normalizedPath);
|
|
190455
190588
|
if (!sourceFile)
|
|
190456
190589
|
return null;
|
|
@@ -190483,7 +190616,7 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
|
|
|
190483
190616
|
}
|
|
190484
190617
|
}
|
|
190485
190618
|
if (!sourceFile) {
|
|
190486
|
-
sourceFile =
|
|
190619
|
+
sourceFile = import_typescript11.default.createSourceFile(filePath, source, import_typescript11.default.ScriptTarget.Latest, true, import_typescript11.default.ScriptKind.TSX);
|
|
190487
190620
|
}
|
|
190488
190621
|
if (!checker && needsTypeBasedDetection(source)) {
|
|
190489
190622
|
const result = createProgramForFile(source, filePath);
|
|
@@ -190529,23 +190662,23 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
|
|
|
190529
190662
|
function findDefaultExportedComponent(sourceFile) {
|
|
190530
190663
|
let defaultExportName;
|
|
190531
190664
|
function findDefaultExport(node) {
|
|
190532
|
-
if (
|
|
190533
|
-
if (
|
|
190665
|
+
if (import_typescript11.default.isExportAssignment(node) && !node.isExportEquals) {
|
|
190666
|
+
if (import_typescript11.default.isIdentifier(node.expression)) {
|
|
190534
190667
|
defaultExportName = node.expression.text;
|
|
190535
190668
|
}
|
|
190536
190669
|
}
|
|
190537
|
-
if (
|
|
190670
|
+
if (import_typescript11.default.isFunctionDeclaration(node) && node.name && node.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.DefaultKeyword)) {
|
|
190538
190671
|
defaultExportName = node.name.text;
|
|
190539
190672
|
}
|
|
190540
|
-
|
|
190673
|
+
import_typescript11.default.forEachChild(node, findDefaultExport);
|
|
190541
190674
|
}
|
|
190542
|
-
|
|
190675
|
+
import_typescript11.default.forEachChild(sourceFile, findDefaultExport);
|
|
190543
190676
|
return defaultExportName;
|
|
190544
190677
|
}
|
|
190545
190678
|
function collectNamedExports(sourceFile) {
|
|
190546
190679
|
const exported = new Set;
|
|
190547
190680
|
for (const stmt of sourceFile.statements) {
|
|
190548
|
-
if (
|
|
190681
|
+
if (import_typescript11.default.isExportDeclaration(stmt) && stmt.exportClause && import_typescript11.default.isNamedExports(stmt.exportClause)) {
|
|
190549
190682
|
for (const spec of stmt.exportClause.elements) {
|
|
190550
190683
|
const local = (spec.propertyName ?? spec.name).text;
|
|
190551
190684
|
exported.add(local);
|
|
@@ -190555,22 +190688,22 @@ function collectNamedExports(sourceFile) {
|
|
|
190555
190688
|
return exported;
|
|
190556
190689
|
}
|
|
190557
190690
|
function visit(node, ctx, targetComponentName, namedExports) {
|
|
190558
|
-
if (
|
|
190691
|
+
if (import_typescript11.default.isExpressionStatement(node) && import_typescript11.default.isStringLiteral(node.expression)) {
|
|
190559
190692
|
if (node.expression.text === "use client" || node.expression.text === "'use client'") {
|
|
190560
190693
|
ctx.hasUseClientDirective = true;
|
|
190561
190694
|
}
|
|
190562
190695
|
}
|
|
190563
|
-
if (
|
|
190696
|
+
if (import_typescript11.default.isImportDeclaration(node)) {
|
|
190564
190697
|
collectImport(node, ctx);
|
|
190565
190698
|
}
|
|
190566
|
-
if (
|
|
190699
|
+
if (import_typescript11.default.isInterfaceDeclaration(node)) {
|
|
190567
190700
|
collectInterfaceDefinition(node, ctx);
|
|
190568
190701
|
}
|
|
190569
|
-
if (
|
|
190702
|
+
if (import_typescript11.default.isTypeAliasDeclaration(node)) {
|
|
190570
190703
|
collectTypeAliasDefinition(node, ctx);
|
|
190571
190704
|
}
|
|
190572
|
-
if (!ctx.hasUseClientDirective &&
|
|
190573
|
-
const hasInlineExport = node.modifiers?.some((m) => m.kind ===
|
|
190705
|
+
if (!ctx.hasUseClientDirective && import_typescript11.default.isFunctionDeclaration(node) && node.name && node.body && isMultiReturnJsxFunctionBody(node.body)) {
|
|
190706
|
+
const hasInlineExport = node.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190574
190707
|
const hasNamedExport = namedExports?.has(node.name.text) ?? false;
|
|
190575
190708
|
if (!hasInlineExport && !hasNamedExport) {
|
|
190576
190709
|
collectFunction(node, ctx, true, false);
|
|
@@ -190585,9 +190718,9 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190585
190718
|
if (!ctx.componentName) {
|
|
190586
190719
|
ctx.componentName = node.name.text;
|
|
190587
190720
|
ctx.componentNode = node;
|
|
190588
|
-
ctx.isExported = node.modifiers?.some((m) => m.kind ===
|
|
190721
|
+
ctx.isExported = node.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190589
190722
|
analyzeComponentBody(node, ctx);
|
|
190590
|
-
if (node.modifiers?.some((m) => m.kind ===
|
|
190723
|
+
if (node.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.DefaultKeyword)) {
|
|
190591
190724
|
ctx.hasDefaultExport = true;
|
|
190592
190725
|
}
|
|
190593
190726
|
}
|
|
@@ -190601,10 +190734,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190601
190734
|
ctx.componentName = node.name.text;
|
|
190602
190735
|
ctx.componentNode = node.initializer;
|
|
190603
190736
|
const parentStatement = node.parent;
|
|
190604
|
-
if (
|
|
190737
|
+
if (import_typescript11.default.isVariableDeclarationList(parentStatement)) {
|
|
190605
190738
|
const varStatement = parentStatement.parent;
|
|
190606
|
-
if (
|
|
190607
|
-
ctx.isExported = varStatement.modifiers?.some((m) => m.kind ===
|
|
190739
|
+
if (import_typescript11.default.isVariableStatement(varStatement)) {
|
|
190740
|
+
ctx.isExported = varStatement.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190608
190741
|
}
|
|
190609
190742
|
}
|
|
190610
190743
|
analyzeComponentBody(node.initializer, ctx);
|
|
@@ -190616,10 +190749,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190616
190749
|
if (!ctx.componentNode) {
|
|
190617
190750
|
collectAmbientGlobals(node, ctx);
|
|
190618
190751
|
}
|
|
190619
|
-
const isDeclareStatement =
|
|
190620
|
-
if (
|
|
190621
|
-
const isExported = node.modifiers?.some((m) => m.kind ===
|
|
190622
|
-
const isLet = (node.declarationList.flags &
|
|
190752
|
+
const isDeclareStatement = import_typescript11.default.isVariableStatement(node) && (node.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.DeclareKeyword) ?? false);
|
|
190753
|
+
if (import_typescript11.default.isVariableStatement(node) && !ctx.componentNode && !isDeclareStatement) {
|
|
190754
|
+
const isExported = node.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190755
|
+
const isLet = (node.declarationList.flags & import_typescript11.default.NodeFlags.Let) !== 0;
|
|
190623
190756
|
const isModuleClientDirective = hasLeadingClientDirectiveOnStatement(node, ctx.sourceFile);
|
|
190624
190757
|
for (const decl of node.declarationList.declarations) {
|
|
190625
190758
|
if (declarationIsReactiveFactoryCall(decl, ctx)) {
|
|
@@ -190630,19 +190763,19 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190630
190763
|
}
|
|
190631
190764
|
continue;
|
|
190632
190765
|
}
|
|
190633
|
-
if (
|
|
190766
|
+
if (import_typescript11.default.isIdentifier(decl.name) && (decl.initializer || isLet) && !isArrowComponentFunction(decl)) {
|
|
190634
190767
|
collectConstant(decl, ctx, true, isLet ? "let" : "const", isExported);
|
|
190635
190768
|
}
|
|
190636
190769
|
}
|
|
190637
190770
|
}
|
|
190638
|
-
if (
|
|
190639
|
-
const isExported = node.modifiers?.some((m) => m.kind ===
|
|
190771
|
+
if (import_typescript11.default.isFunctionDeclaration(node) && node.name && !isComponentFunction(node)) {
|
|
190772
|
+
const isExported = node.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190640
190773
|
collectFunction(node, ctx, true, isExported);
|
|
190641
190774
|
return;
|
|
190642
190775
|
}
|
|
190643
|
-
if (
|
|
190776
|
+
if (import_typescript11.default.isExportDeclaration(node) && node.exportClause && import_typescript11.default.isNamedExports(node.exportClause)) {
|
|
190644
190777
|
const isFromReexport = !!node.moduleSpecifier;
|
|
190645
|
-
const sourceSpec = node.moduleSpecifier &&
|
|
190778
|
+
const sourceSpec = node.moduleSpecifier && import_typescript11.default.isStringLiteral(node.moduleSpecifier) ? node.moduleSpecifier.text : null;
|
|
190646
190779
|
const exportSpecifiers = node.exportClause.elements.map((spec) => ({
|
|
190647
190780
|
name: (spec.propertyName ?? spec.name).text,
|
|
190648
190781
|
alias: spec.propertyName ? spec.name.text : null,
|
|
@@ -190670,24 +190803,24 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190670
190803
|
}
|
|
190671
190804
|
}
|
|
190672
190805
|
}
|
|
190673
|
-
if (
|
|
190806
|
+
if (import_typescript11.default.isExportAssignment(node) && !node.isExportEquals) {
|
|
190674
190807
|
const expr = node.expression;
|
|
190675
|
-
if (
|
|
190808
|
+
if (import_typescript11.default.isIdentifier(expr)) {
|
|
190676
190809
|
if (ctx.componentName && expr.text === ctx.componentName) {
|
|
190677
190810
|
ctx.hasDefaultExport = true;
|
|
190678
190811
|
ctx.isExported = true;
|
|
190679
190812
|
}
|
|
190680
190813
|
}
|
|
190681
190814
|
}
|
|
190682
|
-
|
|
190815
|
+
import_typescript11.default.forEachChild(node, (child) => visit(child, ctx, targetComponentName, namedExports));
|
|
190683
190816
|
}
|
|
190684
190817
|
function analyzeComponentBody(node, ctx) {
|
|
190685
190818
|
if (node.parameters.length > 0) {
|
|
190686
190819
|
extractProps(node.parameters[0], ctx);
|
|
190687
190820
|
}
|
|
190688
|
-
const body =
|
|
190821
|
+
const body = import_typescript11.default.isFunctionDeclaration(node) ? node.body : getArrowFunctionBody(node);
|
|
190689
190822
|
if (body) {
|
|
190690
|
-
ctx.componentBodyBlock =
|
|
190823
|
+
ctx.componentBodyBlock = import_typescript11.default.isBlock(body) ? body : null;
|
|
190691
190824
|
if (!ctx.componentBodyBlock) {
|
|
190692
190825
|
ctx.jsxReturn = unwrapJsxTransparent(body);
|
|
190693
190826
|
}
|
|
@@ -190697,14 +190830,14 @@ function analyzeComponentBody(node, ctx) {
|
|
|
190697
190830
|
}
|
|
190698
190831
|
}
|
|
190699
190832
|
function getArrowFunctionBody(node) {
|
|
190700
|
-
if (
|
|
190833
|
+
if (import_typescript11.default.isBlock(node.body)) {
|
|
190701
190834
|
return node.body;
|
|
190702
190835
|
}
|
|
190703
190836
|
return node.body;
|
|
190704
190837
|
}
|
|
190705
190838
|
function visitComponentBody(node, ctx) {
|
|
190706
190839
|
const isTopLevel = ctx.componentBodyBlock !== null && node.parent === ctx.componentBodyBlock;
|
|
190707
|
-
if (
|
|
190840
|
+
if (import_typescript11.default.isVariableStatement(node)) {
|
|
190708
190841
|
for (const decl of node.declarationList.declarations) {
|
|
190709
190842
|
if (isSignalDeclaration(decl, ctx)) {
|
|
190710
190843
|
collectSignal(decl, ctx);
|
|
@@ -190727,16 +190860,16 @@ function visitComponentBody(node, ctx) {
|
|
|
190727
190860
|
collectEffect(decl.initializer, ctx, decl.name.text);
|
|
190728
190861
|
continue;
|
|
190729
190862
|
}
|
|
190730
|
-
if (
|
|
190731
|
-
const isLet = (node.declarationList.flags &
|
|
190863
|
+
if (import_typescript11.default.isIdentifier(decl.name)) {
|
|
190864
|
+
const isLet = (node.declarationList.flags & import_typescript11.default.NodeFlags.Let) !== 0;
|
|
190732
190865
|
collectConstant(decl, ctx, false, isLet ? "let" : "const");
|
|
190733
|
-
} else if (
|
|
190734
|
-
const isLet = (node.declarationList.flags &
|
|
190866
|
+
} else if (import_typescript11.default.isObjectBindingPattern(decl.name) && decl.initializer && import_typescript11.default.isIdentifier(decl.initializer) && ctx.propsObjectName === decl.initializer.text) {
|
|
190867
|
+
const isLet = (node.declarationList.flags & import_typescript11.default.NodeFlags.Let) !== 0;
|
|
190735
190868
|
collectConstant(decl, ctx, false, isLet ? "let" : "const");
|
|
190736
190869
|
}
|
|
190737
190870
|
}
|
|
190738
190871
|
}
|
|
190739
|
-
if (
|
|
190872
|
+
if (import_typescript11.default.isExpressionStatement(node)) {
|
|
190740
190873
|
if (isEffectCall(node.expression, ctx)) {
|
|
190741
190874
|
collectEffect(node.expression, ctx);
|
|
190742
190875
|
return;
|
|
@@ -190750,10 +190883,10 @@ function visitComponentBody(node, ctx) {
|
|
|
190750
190883
|
return;
|
|
190751
190884
|
}
|
|
190752
190885
|
}
|
|
190753
|
-
if (
|
|
190886
|
+
if (import_typescript11.default.isFunctionDeclaration(node) && node.name) {
|
|
190754
190887
|
collectFunction(node, ctx, false);
|
|
190755
190888
|
}
|
|
190756
|
-
if (
|
|
190889
|
+
if (import_typescript11.default.isIfStatement(node)) {
|
|
190757
190890
|
const jsxReturn = findJsxReturnInBlock(node.thenStatement);
|
|
190758
190891
|
if (jsxReturn) {
|
|
190759
190892
|
const scopeVars = collectScopeVariables(node.thenStatement, ctx);
|
|
@@ -190772,8 +190905,8 @@ function visitComponentBody(node, ctx) {
|
|
|
190772
190905
|
return;
|
|
190773
190906
|
}
|
|
190774
190907
|
}
|
|
190775
|
-
if (isTopLevel && (
|
|
190776
|
-
if (
|
|
190908
|
+
if (isTopLevel && (import_typescript11.default.isTryStatement(node) || import_typescript11.default.isSwitchStatement(node) || import_typescript11.default.isForStatement(node) || import_typescript11.default.isForInStatement(node) || import_typescript11.default.isForOfStatement(node) || import_typescript11.default.isWhileStatement(node) || import_typescript11.default.isDoStatement(node) || import_typescript11.default.isThrowStatement(node) || import_typescript11.default.isBlock(node) && node.parent === ctx.componentBodyBlock)) {
|
|
190909
|
+
if (import_typescript11.default.isBlock(node)) {
|
|
190777
190910
|
const returnedLocal = findBlockBodyReturnedJsxLocalName(node);
|
|
190778
190911
|
if (returnedLocal) {
|
|
190779
190912
|
ctx.errors.push(createError(ErrorCodes.RETURN_VALUE_NOT_JSX, getSourceLocation(node, ctx.sourceFile, ctx.filePath), {
|
|
@@ -190784,34 +190917,34 @@ function visitComponentBody(node, ctx) {
|
|
|
190784
190917
|
collectInitStatement(node, ctx);
|
|
190785
190918
|
return;
|
|
190786
190919
|
}
|
|
190787
|
-
if (
|
|
190920
|
+
if (import_typescript11.default.isReturnStatement(node) && node.expression) {
|
|
190788
190921
|
ctx.jsxReturn = unwrapJsxTransparent(node.expression);
|
|
190789
190922
|
}
|
|
190790
|
-
|
|
190791
|
-
if (
|
|
190923
|
+
import_typescript11.default.forEachChild(node, (child) => {
|
|
190924
|
+
if (import_typescript11.default.isArrowFunction(child) || import_typescript11.default.isFunctionExpression(child) || import_typescript11.default.isFunctionDeclaration(child)) {
|
|
190792
190925
|
return;
|
|
190793
190926
|
}
|
|
190794
190927
|
visitComponentBody(child, ctx);
|
|
190795
190928
|
});
|
|
190796
190929
|
}
|
|
190797
190930
|
function findJsxReturnInBlock(node) {
|
|
190798
|
-
if (
|
|
190931
|
+
if (import_typescript11.default.isBlock(node)) {
|
|
190799
190932
|
for (const stmt of node.statements) {
|
|
190800
|
-
if (
|
|
190933
|
+
if (import_typescript11.default.isReturnStatement(stmt) && stmt.expression) {
|
|
190801
190934
|
const jsx = extractJsxFromExpression(stmt.expression);
|
|
190802
190935
|
if (jsx)
|
|
190803
190936
|
return jsx;
|
|
190804
190937
|
}
|
|
190805
190938
|
}
|
|
190806
190939
|
}
|
|
190807
|
-
if (
|
|
190940
|
+
if (import_typescript11.default.isReturnStatement(node) && node.expression) {
|
|
190808
190941
|
return extractJsxFromExpression(node.expression);
|
|
190809
190942
|
}
|
|
190810
190943
|
return null;
|
|
190811
190944
|
}
|
|
190812
190945
|
function unwrapJsxTransparent(expr) {
|
|
190813
190946
|
let current = expr;
|
|
190814
|
-
while (
|
|
190947
|
+
while (import_typescript11.default.isParenthesizedExpression(current) || import_typescript11.default.isAsExpression(current) || import_typescript11.default.isSatisfiesExpression(current) || import_typescript11.default.isNonNullExpression(current) || import_typescript11.default.isTypeAssertionExpression(current) || current.kind === import_typescript11.default.SyntaxKind.PartiallyEmittedExpression) {
|
|
190815
190948
|
current = current.expression;
|
|
190816
190949
|
}
|
|
190817
190950
|
return current;
|
|
@@ -190819,22 +190952,22 @@ function unwrapJsxTransparent(expr) {
|
|
|
190819
190952
|
function findBlockBodyReturnedJsxLocalName(block) {
|
|
190820
190953
|
const stmts = block.statements;
|
|
190821
190954
|
const last = stmts[stmts.length - 1];
|
|
190822
|
-
if (!last || !
|
|
190955
|
+
if (!last || !import_typescript11.default.isReturnStatement(last) || !last.expression)
|
|
190823
190956
|
return null;
|
|
190824
190957
|
const returned = unwrapJsxTransparent(last.expression);
|
|
190825
|
-
if (!
|
|
190958
|
+
if (!import_typescript11.default.isIdentifier(returned))
|
|
190826
190959
|
return null;
|
|
190827
190960
|
const name = returned.text;
|
|
190828
190961
|
for (const stmt of stmts) {
|
|
190829
|
-
if (!
|
|
190962
|
+
if (!import_typescript11.default.isVariableStatement(stmt))
|
|
190830
190963
|
continue;
|
|
190831
190964
|
for (const decl of stmt.declarationList.declarations) {
|
|
190832
|
-
if (!
|
|
190965
|
+
if (!import_typescript11.default.isIdentifier(decl.name) || decl.name.text !== name || !decl.initializer)
|
|
190833
190966
|
continue;
|
|
190834
190967
|
let init = decl.initializer;
|
|
190835
|
-
while (
|
|
190968
|
+
while (import_typescript11.default.isParenthesizedExpression(init))
|
|
190836
190969
|
init = init.expression;
|
|
190837
|
-
if (
|
|
190970
|
+
if (import_typescript11.default.isJsxElement(init) || import_typescript11.default.isJsxSelfClosingElement(init) || import_typescript11.default.isJsxFragment(init) || initializerShapeContainsJsx(init) || isMapLikeCallWithJsx(init)) {
|
|
190838
190971
|
return name;
|
|
190839
190972
|
}
|
|
190840
190973
|
}
|
|
@@ -190843,16 +190976,16 @@ function findBlockBodyReturnedJsxLocalName(block) {
|
|
|
190843
190976
|
}
|
|
190844
190977
|
function extractJsxFromExpression(expr) {
|
|
190845
190978
|
const inner = unwrapJsxTransparent(expr);
|
|
190846
|
-
if (
|
|
190979
|
+
if (import_typescript11.default.isJsxElement(inner) || import_typescript11.default.isJsxFragment(inner) || import_typescript11.default.isJsxSelfClosingElement(inner)) {
|
|
190847
190980
|
return inner;
|
|
190848
190981
|
}
|
|
190849
190982
|
return null;
|
|
190850
190983
|
}
|
|
190851
190984
|
function collectScopeVariables(node, ctx) {
|
|
190852
190985
|
const variables = [];
|
|
190853
|
-
if (
|
|
190986
|
+
if (import_typescript11.default.isBlock(node)) {
|
|
190854
190987
|
for (const stmt of node.statements) {
|
|
190855
|
-
if (
|
|
190988
|
+
if (import_typescript11.default.isVariableStatement(stmt)) {
|
|
190856
190989
|
for (const decl of stmt.declarationList.declarations) {
|
|
190857
190990
|
variables.push(decl);
|
|
190858
190991
|
}
|
|
@@ -190864,13 +190997,13 @@ function collectScopeVariables(node, ctx) {
|
|
|
190864
190997
|
function collectParamBindingNames(params) {
|
|
190865
190998
|
const out = new Set;
|
|
190866
190999
|
const addBindingNames = (name) => {
|
|
190867
|
-
if (
|
|
191000
|
+
if (import_typescript11.default.isIdentifier(name)) {
|
|
190868
191001
|
out.add(name.text);
|
|
190869
|
-
} else if (
|
|
191002
|
+
} else if (import_typescript11.default.isObjectBindingPattern(name)) {
|
|
190870
191003
|
name.elements.forEach((e) => addBindingNames(e.name));
|
|
190871
|
-
} else if (
|
|
191004
|
+
} else if (import_typescript11.default.isArrayBindingPattern(name)) {
|
|
190872
191005
|
name.elements.forEach((e) => {
|
|
190873
|
-
if (!
|
|
191006
|
+
if (!import_typescript11.default.isOmittedExpression(e))
|
|
190874
191007
|
addBindingNames(e.name);
|
|
190875
191008
|
});
|
|
190876
191009
|
}
|
|
@@ -190887,7 +191020,7 @@ function collectEnclosingBranchVars(node, ctx) {
|
|
|
190887
191020
|
if (cr.ifStatement.thenStatement !== current)
|
|
190888
191021
|
continue;
|
|
190889
191022
|
for (const decl of cr.scopeVariables) {
|
|
190890
|
-
if (!
|
|
191023
|
+
if (!import_typescript11.default.isIdentifier(decl.name) || !decl.initializer)
|
|
190891
191024
|
continue;
|
|
190892
191025
|
const varName = decl.name.text;
|
|
190893
191026
|
if (result.has(varName))
|
|
@@ -190902,10 +191035,10 @@ function collectEnclosingBranchVars(node, ctx) {
|
|
|
190902
191035
|
return result;
|
|
190903
191036
|
}
|
|
190904
191037
|
function collectBranchSignals(thenStatement, ctx, branchCondition) {
|
|
190905
|
-
if (!
|
|
191038
|
+
if (!import_typescript11.default.isBlock(thenStatement))
|
|
190906
191039
|
return;
|
|
190907
191040
|
for (const stmt of thenStatement.statements) {
|
|
190908
|
-
if (!
|
|
191041
|
+
if (!import_typescript11.default.isVariableStatement(stmt))
|
|
190909
191042
|
continue;
|
|
190910
191043
|
for (const decl of stmt.declarationList.declarations) {
|
|
190911
191044
|
if (!isSignalDeclaration(decl, ctx))
|
|
@@ -190931,13 +191064,13 @@ var ENV_SIGNAL_FACTORIES = {
|
|
|
190931
191064
|
createSearchParams: "search"
|
|
190932
191065
|
};
|
|
190933
191066
|
function resolvePrimitiveKind(callExpr, ctx) {
|
|
190934
|
-
if (
|
|
191067
|
+
if (import_typescript11.default.isIdentifier(callExpr.expression)) {
|
|
190935
191068
|
const hit = PRIMITIVE_CANONICAL_NAMES[callExpr.expression.text];
|
|
190936
191069
|
if (hit)
|
|
190937
191070
|
return hit;
|
|
190938
191071
|
return resolveCalleeViaChecker(callExpr.expression, ctx);
|
|
190939
191072
|
}
|
|
190940
|
-
if (
|
|
191073
|
+
if (import_typescript11.default.isPropertyAccessExpression(callExpr.expression)) {
|
|
190941
191074
|
const propName = callExpr.expression.name.text;
|
|
190942
191075
|
const hit = PRIMITIVE_CANONICAL_NAMES[propName];
|
|
190943
191076
|
if (!hit)
|
|
@@ -190964,7 +191097,7 @@ function resolveCanonicalClientExportName(ident, ctx) {
|
|
|
190964
191097
|
if (!symbol)
|
|
190965
191098
|
return null;
|
|
190966
191099
|
let target = symbol;
|
|
190967
|
-
if (symbol.flags &
|
|
191100
|
+
if (symbol.flags & import_typescript11.default.SymbolFlags.Alias) {
|
|
190968
191101
|
try {
|
|
190969
191102
|
target = ctx.checker.getAliasedSymbol(symbol);
|
|
190970
191103
|
} catch {
|
|
@@ -190980,14 +191113,14 @@ function resolveCanonicalClientExportName(ident, ctx) {
|
|
|
190980
191113
|
return null;
|
|
190981
191114
|
}
|
|
190982
191115
|
function resolveEnvSignalKey(callExpr, ctx) {
|
|
190983
|
-
if (
|
|
191116
|
+
if (import_typescript11.default.isIdentifier(callExpr.expression)) {
|
|
190984
191117
|
const key = ENV_SIGNAL_FACTORIES[callExpr.expression.text];
|
|
190985
191118
|
if (key)
|
|
190986
191119
|
return key;
|
|
190987
191120
|
const canonical = resolveCanonicalClientExportName(callExpr.expression, ctx);
|
|
190988
191121
|
return canonical ? ENV_SIGNAL_FACTORIES[canonical] ?? null : null;
|
|
190989
191122
|
}
|
|
190990
|
-
if (
|
|
191123
|
+
if (import_typescript11.default.isPropertyAccessExpression(callExpr.expression)) {
|
|
190991
191124
|
const key = ENV_SIGNAL_FACTORIES[callExpr.expression.name.text];
|
|
190992
191125
|
if (key && isBarefootClientNamespace(callExpr.expression.expression, ctx))
|
|
190993
191126
|
return key;
|
|
@@ -190995,7 +191128,7 @@ function resolveEnvSignalKey(callExpr, ctx) {
|
|
|
190995
191128
|
return null;
|
|
190996
191129
|
}
|
|
190997
191130
|
function isBarefootClientNamespace(expr, ctx) {
|
|
190998
|
-
if (!
|
|
191131
|
+
if (!import_typescript11.default.isIdentifier(expr))
|
|
190999
191132
|
return false;
|
|
191000
191133
|
if (!ctx.checker)
|
|
191001
191134
|
return false;
|
|
@@ -191008,22 +191141,22 @@ function isBarefootClientNamespace(expr, ctx) {
|
|
|
191008
191141
|
if (!symbol)
|
|
191009
191142
|
return false;
|
|
191010
191143
|
for (const decl of symbol.declarations ?? []) {
|
|
191011
|
-
if (!
|
|
191144
|
+
if (!import_typescript11.default.isNamespaceImport(decl))
|
|
191012
191145
|
continue;
|
|
191013
191146
|
const importDecl = decl.parent.parent;
|
|
191014
|
-
if (!
|
|
191147
|
+
if (!import_typescript11.default.isImportDeclaration(importDecl))
|
|
191015
191148
|
continue;
|
|
191016
191149
|
const mod = importDecl.moduleSpecifier;
|
|
191017
|
-
if (
|
|
191150
|
+
if (import_typescript11.default.isStringLiteral(mod) && mod.text === "@barefootjs/client") {
|
|
191018
191151
|
return true;
|
|
191019
191152
|
}
|
|
191020
191153
|
}
|
|
191021
191154
|
return false;
|
|
191022
191155
|
}
|
|
191023
191156
|
function isSignalDeclaration(node, ctx) {
|
|
191024
|
-
if (!
|
|
191157
|
+
if (!import_typescript11.default.isArrayBindingPattern(node.name))
|
|
191025
191158
|
return false;
|
|
191026
|
-
if (!node.initializer || !
|
|
191159
|
+
if (!node.initializer || !import_typescript11.default.isCallExpression(node.initializer))
|
|
191027
191160
|
return false;
|
|
191028
191161
|
return resolvePrimitiveKind(node.initializer, ctx) === "signal";
|
|
191029
191162
|
}
|
|
@@ -191031,14 +191164,14 @@ function collectSignal(node, ctx) {
|
|
|
191031
191164
|
const pattern = node.name;
|
|
191032
191165
|
const callExpr = node.initializer;
|
|
191033
191166
|
const elements = pattern.elements;
|
|
191034
|
-
const getterElided = elements.length === 2 &&
|
|
191035
|
-
if (elements.length < 1 || elements.length > 2 || !getterElided && (!
|
|
191167
|
+
const getterElided = elements.length === 2 && import_typescript11.default.isOmittedExpression(elements[0]);
|
|
191168
|
+
if (elements.length < 1 || elements.length > 2 || !getterElided && (!import_typescript11.default.isBindingElement(elements[0]) || !import_typescript11.default.isIdentifier(elements[0].name))) {
|
|
191036
191169
|
return;
|
|
191037
191170
|
}
|
|
191038
|
-
if (elements.length === 2 && (!
|
|
191171
|
+
if (elements.length === 2 && (!import_typescript11.default.isBindingElement(elements[1]) || !import_typescript11.default.isIdentifier(elements[1].name))) {
|
|
191039
191172
|
return;
|
|
191040
191173
|
}
|
|
191041
|
-
const setter = elements.length === 2 &&
|
|
191174
|
+
const setter = elements.length === 2 && import_typescript11.default.isBindingElement(elements[1]) && import_typescript11.default.isIdentifier(elements[1].name) ? elements[1].name.text : null;
|
|
191042
191175
|
if (getterElided && !setter)
|
|
191043
191176
|
return;
|
|
191044
191177
|
const getter = getterElided ? `__bfGet_${setter}` : elements[0].name.text;
|
|
@@ -191075,33 +191208,33 @@ function collectSignal(node, ctx) {
|
|
|
191075
191208
|
});
|
|
191076
191209
|
}
|
|
191077
191210
|
function isSignalTupleDeclaration(node) {
|
|
191078
|
-
if (!
|
|
191211
|
+
if (!import_typescript11.default.isIdentifier(node.name))
|
|
191079
191212
|
return false;
|
|
191080
|
-
if (!node.initializer || !
|
|
191213
|
+
if (!node.initializer || !import_typescript11.default.isCallExpression(node.initializer))
|
|
191081
191214
|
return false;
|
|
191082
191215
|
const callExpr = node.initializer;
|
|
191083
|
-
return
|
|
191216
|
+
return import_typescript11.default.isIdentifier(callExpr.expression) && callExpr.expression.text === "createSignal";
|
|
191084
191217
|
}
|
|
191085
191218
|
function isSignalIndexAccess(node, ctx) {
|
|
191086
|
-
if (!
|
|
191219
|
+
if (!import_typescript11.default.isIdentifier(node.name))
|
|
191087
191220
|
return null;
|
|
191088
|
-
if (!node.initializer || !
|
|
191221
|
+
if (!node.initializer || !import_typescript11.default.isElementAccessExpression(node.initializer))
|
|
191089
191222
|
return null;
|
|
191090
191223
|
const access = node.initializer;
|
|
191091
|
-
if (!
|
|
191224
|
+
if (!import_typescript11.default.isNumericLiteral(access.argumentExpression))
|
|
191092
191225
|
return null;
|
|
191093
191226
|
const indexValue = Number(access.argumentExpression.text);
|
|
191094
191227
|
if (indexValue !== 0 && indexValue !== 1)
|
|
191095
191228
|
return null;
|
|
191096
191229
|
const index = indexValue;
|
|
191097
|
-
if (
|
|
191230
|
+
if (import_typescript11.default.isCallExpression(access.expression)) {
|
|
191098
191231
|
const call = access.expression;
|
|
191099
|
-
if (
|
|
191232
|
+
if (import_typescript11.default.isIdentifier(call.expression) && call.expression.text === "createSignal") {
|
|
191100
191233
|
return { kind: "direct", index, callExpr: call };
|
|
191101
191234
|
}
|
|
191102
191235
|
return null;
|
|
191103
191236
|
}
|
|
191104
|
-
if (
|
|
191237
|
+
if (import_typescript11.default.isIdentifier(access.expression)) {
|
|
191105
191238
|
const tupleName = access.expression.text;
|
|
191106
191239
|
if (ctx.signalTupleRefs.has(tupleName)) {
|
|
191107
191240
|
return { kind: "tupleRef", index, tupleName };
|
|
@@ -191196,30 +191329,30 @@ function flushPendingSignalTuples(ctx) {
|
|
|
191196
191329
|
ctx.signalTupleRefs.clear();
|
|
191197
191330
|
}
|
|
191198
191331
|
function isMemoDeclaration(node, ctx) {
|
|
191199
|
-
if (!
|
|
191332
|
+
if (!import_typescript11.default.isIdentifier(node.name))
|
|
191200
191333
|
return false;
|
|
191201
|
-
if (!node.initializer || !
|
|
191334
|
+
if (!node.initializer || !import_typescript11.default.isCallExpression(node.initializer))
|
|
191202
191335
|
return false;
|
|
191203
191336
|
return resolvePrimitiveKind(node.initializer, ctx) === "memo";
|
|
191204
191337
|
}
|
|
191205
191338
|
function memoBodyIsTemplateLiteral(memoArrow) {
|
|
191206
191339
|
let node = memoArrow;
|
|
191207
|
-
while (node &&
|
|
191340
|
+
while (node && import_typescript11.default.isParenthesizedExpression(node))
|
|
191208
191341
|
node = node.expression;
|
|
191209
|
-
if (!node || !
|
|
191342
|
+
if (!node || !import_typescript11.default.isArrowFunction(node))
|
|
191210
191343
|
return false;
|
|
191211
191344
|
let body = node.body;
|
|
191212
|
-
while (
|
|
191345
|
+
while (import_typescript11.default.isParenthesizedExpression(body))
|
|
191213
191346
|
body = body.expression;
|
|
191214
|
-
if (
|
|
191215
|
-
const ret = body.statements.find(
|
|
191347
|
+
if (import_typescript11.default.isBlock(body)) {
|
|
191348
|
+
const ret = body.statements.find(import_typescript11.default.isReturnStatement);
|
|
191216
191349
|
if (!ret || !ret.expression)
|
|
191217
191350
|
return false;
|
|
191218
191351
|
body = ret.expression;
|
|
191219
|
-
while (
|
|
191352
|
+
while (import_typescript11.default.isParenthesizedExpression(body))
|
|
191220
191353
|
body = body.expression;
|
|
191221
191354
|
}
|
|
191222
|
-
return
|
|
191355
|
+
return import_typescript11.default.isTemplateExpression(body) || import_typescript11.default.isNoSubstitutionTemplateLiteral(body);
|
|
191223
191356
|
}
|
|
191224
191357
|
function collectMemo(node, ctx) {
|
|
191225
191358
|
const name = node.name.text;
|
|
@@ -191236,7 +191369,7 @@ function collectMemo(node, ctx) {
|
|
|
191236
191369
|
type2 = inferTypeFromValue(arrowBody);
|
|
191237
191370
|
}
|
|
191238
191371
|
}
|
|
191239
|
-
if (ctx.checker && (type2.kind === "unknown" || type2.kind === "object") && callExpr.arguments[0] && (
|
|
191372
|
+
if (ctx.checker && (type2.kind === "unknown" || type2.kind === "object") && callExpr.arguments[0] && (import_typescript11.default.isArrowFunction(callExpr.arguments[0]) || import_typescript11.default.isFunctionExpression(callExpr.arguments[0]))) {
|
|
191240
191373
|
const fnType = ctx.checker.getTypeAtLocation(callExpr.arguments[0]);
|
|
191241
191374
|
const sig = fnType.getCallSignatures()[0];
|
|
191242
191375
|
if (sig) {
|
|
@@ -191246,12 +191379,12 @@ function collectMemo(node, ctx) {
|
|
|
191246
191379
|
}
|
|
191247
191380
|
}
|
|
191248
191381
|
const memoArrow = callExpr.arguments[0];
|
|
191249
|
-
const parsedBody = memoArrow &&
|
|
191382
|
+
const parsedBody = memoArrow && import_typescript11.default.isArrowFunction(memoArrow) && !import_typescript11.default.isBlock(memoArrow.body) ? parseExpression(ctx.getJS(memoArrow.body)) : undefined;
|
|
191250
191383
|
const parsed = parsedBody && parsedBody.kind !== "unsupported" && parsedBody.kind !== "object-literal" ? parsedBody : undefined;
|
|
191251
191384
|
let arrowNode = memoArrow;
|
|
191252
|
-
while (arrowNode &&
|
|
191385
|
+
while (arrowNode && import_typescript11.default.isParenthesizedExpression(arrowNode))
|
|
191253
191386
|
arrowNode = arrowNode.expression;
|
|
191254
|
-
const blockBody = arrowNode &&
|
|
191387
|
+
const blockBody = arrowNode && import_typescript11.default.isArrowFunction(arrowNode) && import_typescript11.default.isBlock(arrowNode.body) ? arrowNode.body : undefined;
|
|
191255
191388
|
const parsedBlock = blockBody ? parseBlockBodyTolerant(blockBody, ctx.sourceFile, (node2) => ctx.getJS(node2)) : undefined;
|
|
191256
191389
|
const parsedBlockComplete = parsedBlock && blockBody ? parsedBlock.length === blockBody.statements.length : undefined;
|
|
191257
191390
|
let templateComputation;
|
|
@@ -191278,14 +191411,14 @@ function collectMemo(node, ctx) {
|
|
|
191278
191411
|
});
|
|
191279
191412
|
}
|
|
191280
191413
|
function isEffectCall(node, ctx) {
|
|
191281
|
-
if (!
|
|
191414
|
+
if (!import_typescript11.default.isCallExpression(node))
|
|
191282
191415
|
return false;
|
|
191283
191416
|
return resolvePrimitiveKind(node, ctx) === "effect";
|
|
191284
191417
|
}
|
|
191285
191418
|
function isEffectDisposerCapture(node, ctx) {
|
|
191286
|
-
if (!
|
|
191419
|
+
if (!import_typescript11.default.isIdentifier(node.name))
|
|
191287
191420
|
return false;
|
|
191288
|
-
if (!node.initializer || !
|
|
191421
|
+
if (!node.initializer || !import_typescript11.default.isCallExpression(node.initializer))
|
|
191289
191422
|
return false;
|
|
191290
191423
|
return resolvePrimitiveKind(node.initializer, ctx) === "effect";
|
|
191291
191424
|
}
|
|
@@ -191300,7 +191433,7 @@ function collectEffect(node, ctx, captureName) {
|
|
|
191300
191433
|
});
|
|
191301
191434
|
}
|
|
191302
191435
|
function isOnMountCall(node, ctx) {
|
|
191303
|
-
if (!
|
|
191436
|
+
if (!import_typescript11.default.isCallExpression(node))
|
|
191304
191437
|
return false;
|
|
191305
191438
|
return resolvePrimitiveKind(node, ctx) === "onMount";
|
|
191306
191439
|
}
|
|
@@ -191335,19 +191468,19 @@ function leadsWithAsiHazard(body) {
|
|
|
191335
191468
|
function extractAssignedIdentifiersFromNode(node) {
|
|
191336
191469
|
const ids = new Set;
|
|
191337
191470
|
function addFromTarget(target) {
|
|
191338
|
-
if (
|
|
191471
|
+
if (import_typescript11.default.isIdentifier(target)) {
|
|
191339
191472
|
ids.add(target.text);
|
|
191340
191473
|
return;
|
|
191341
191474
|
}
|
|
191342
|
-
if (
|
|
191475
|
+
if (import_typescript11.default.isParenthesizedExpression(target)) {
|
|
191343
191476
|
addFromTarget(target.expression);
|
|
191344
191477
|
return;
|
|
191345
191478
|
}
|
|
191346
|
-
if (
|
|
191479
|
+
if (import_typescript11.default.isArrayLiteralExpression(target)) {
|
|
191347
191480
|
for (const el of target.elements) {
|
|
191348
|
-
if (
|
|
191481
|
+
if (import_typescript11.default.isOmittedExpression(el))
|
|
191349
191482
|
continue;
|
|
191350
|
-
if (
|
|
191483
|
+
if (import_typescript11.default.isSpreadElement(el)) {
|
|
191351
191484
|
addFromTarget(el.expression);
|
|
191352
191485
|
continue;
|
|
191353
191486
|
}
|
|
@@ -191355,17 +191488,17 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191355
191488
|
}
|
|
191356
191489
|
return;
|
|
191357
191490
|
}
|
|
191358
|
-
if (
|
|
191491
|
+
if (import_typescript11.default.isObjectLiteralExpression(target)) {
|
|
191359
191492
|
for (const prop of target.properties) {
|
|
191360
|
-
if (
|
|
191493
|
+
if (import_typescript11.default.isShorthandPropertyAssignment(prop)) {
|
|
191361
191494
|
ids.add(prop.name.text);
|
|
191362
191495
|
continue;
|
|
191363
191496
|
}
|
|
191364
|
-
if (
|
|
191497
|
+
if (import_typescript11.default.isPropertyAssignment(prop)) {
|
|
191365
191498
|
addFromTarget(prop.initializer);
|
|
191366
191499
|
continue;
|
|
191367
191500
|
}
|
|
191368
|
-
if (
|
|
191501
|
+
if (import_typescript11.default.isSpreadAssignment(prop)) {
|
|
191369
191502
|
addFromTarget(prop.expression);
|
|
191370
191503
|
continue;
|
|
191371
191504
|
}
|
|
@@ -191374,21 +191507,21 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191374
191507
|
}
|
|
191375
191508
|
}
|
|
191376
191509
|
function visit2(n) {
|
|
191377
|
-
if (
|
|
191510
|
+
if (import_typescript11.default.isArrowFunction(n) || import_typescript11.default.isFunctionExpression(n) || import_typescript11.default.isFunctionDeclaration(n) || import_typescript11.default.isMethodDeclaration(n) || import_typescript11.default.isGetAccessorDeclaration(n) || import_typescript11.default.isSetAccessorDeclaration(n) || import_typescript11.default.isConstructorDeclaration(n)) {
|
|
191378
191511
|
return;
|
|
191379
191512
|
}
|
|
191380
|
-
if (
|
|
191513
|
+
if (import_typescript11.default.isBinaryExpression(n)) {
|
|
191381
191514
|
const op = n.operatorToken.kind;
|
|
191382
|
-
if (op ===
|
|
191515
|
+
if (op === import_typescript11.default.SyntaxKind.EqualsToken || op === import_typescript11.default.SyntaxKind.PlusEqualsToken || op === import_typescript11.default.SyntaxKind.MinusEqualsToken || op === import_typescript11.default.SyntaxKind.AsteriskEqualsToken || op === import_typescript11.default.SyntaxKind.SlashEqualsToken || op === import_typescript11.default.SyntaxKind.PercentEqualsToken || op === import_typescript11.default.SyntaxKind.AsteriskAsteriskEqualsToken || op === import_typescript11.default.SyntaxKind.AmpersandEqualsToken || op === import_typescript11.default.SyntaxKind.BarEqualsToken || op === import_typescript11.default.SyntaxKind.CaretEqualsToken || op === import_typescript11.default.SyntaxKind.LessThanLessThanEqualsToken || op === import_typescript11.default.SyntaxKind.GreaterThanGreaterThanEqualsToken || op === import_typescript11.default.SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken || op === import_typescript11.default.SyntaxKind.AmpersandAmpersandEqualsToken || op === import_typescript11.default.SyntaxKind.BarBarEqualsToken || op === import_typescript11.default.SyntaxKind.QuestionQuestionEqualsToken) {
|
|
191383
191516
|
addFromTarget(n.left);
|
|
191384
191517
|
}
|
|
191385
191518
|
}
|
|
191386
|
-
if (
|
|
191387
|
-
if (n.operator ===
|
|
191519
|
+
if (import_typescript11.default.isPrefixUnaryExpression(n) || import_typescript11.default.isPostfixUnaryExpression(n)) {
|
|
191520
|
+
if (n.operator === import_typescript11.default.SyntaxKind.PlusPlusToken || n.operator === import_typescript11.default.SyntaxKind.MinusMinusToken) {
|
|
191388
191521
|
addFromTarget(n.operand);
|
|
191389
191522
|
}
|
|
191390
191523
|
}
|
|
191391
|
-
|
|
191524
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191392
191525
|
}
|
|
191393
191526
|
visit2(node);
|
|
191394
191527
|
const localDecls = collectLocalDeclarations(node);
|
|
@@ -191399,30 +191532,30 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191399
191532
|
function collectLocalDeclarations(root) {
|
|
191400
191533
|
const names = new Set;
|
|
191401
191534
|
function addBindingName(name) {
|
|
191402
|
-
if (
|
|
191535
|
+
if (import_typescript11.default.isIdentifier(name)) {
|
|
191403
191536
|
names.add(name.text);
|
|
191404
191537
|
return;
|
|
191405
191538
|
}
|
|
191406
|
-
if (
|
|
191539
|
+
if (import_typescript11.default.isArrayBindingPattern(name)) {
|
|
191407
191540
|
for (const el of name.elements) {
|
|
191408
|
-
if (
|
|
191541
|
+
if (import_typescript11.default.isBindingElement(el))
|
|
191409
191542
|
addBindingName(el.name);
|
|
191410
191543
|
}
|
|
191411
191544
|
return;
|
|
191412
191545
|
}
|
|
191413
|
-
if (
|
|
191546
|
+
if (import_typescript11.default.isObjectBindingPattern(name)) {
|
|
191414
191547
|
for (const el of name.elements) {
|
|
191415
191548
|
addBindingName(el.name);
|
|
191416
191549
|
}
|
|
191417
191550
|
}
|
|
191418
191551
|
}
|
|
191419
191552
|
function visit2(n) {
|
|
191420
|
-
if (
|
|
191553
|
+
if (import_typescript11.default.isArrowFunction(n) || import_typescript11.default.isFunctionExpression(n) || import_typescript11.default.isFunctionDeclaration(n))
|
|
191421
191554
|
return;
|
|
191422
|
-
if (
|
|
191555
|
+
if (import_typescript11.default.isVariableDeclaration(n)) {
|
|
191423
191556
|
addBindingName(n.name);
|
|
191424
191557
|
}
|
|
191425
|
-
|
|
191558
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191426
191559
|
}
|
|
191427
191560
|
visit2(root);
|
|
191428
191561
|
return names;
|
|
@@ -191449,6 +191582,7 @@ var CLIENT_EXPORTS = new Set([
|
|
|
191449
191582
|
"isSSRPortal",
|
|
191450
191583
|
"findSiblingSlot",
|
|
191451
191584
|
"cleanupPortalPlaceholder",
|
|
191585
|
+
"trackPosition",
|
|
191452
191586
|
"createSearchParams",
|
|
191453
191587
|
"queryHref",
|
|
191454
191588
|
"formatDate",
|
|
@@ -191456,35 +191590,35 @@ var CLIENT_EXPORTS = new Set([
|
|
|
191456
191590
|
"Region"
|
|
191457
191591
|
]);
|
|
191458
191592
|
function collectAmbientGlobals(node, ctx) {
|
|
191459
|
-
if (
|
|
191460
|
-
const isDeclare = node.modifiers?.some((m) => m.kind ===
|
|
191593
|
+
if (import_typescript11.default.isVariableStatement(node)) {
|
|
191594
|
+
const isDeclare = node.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.DeclareKeyword) ?? false;
|
|
191461
191595
|
if (!isDeclare)
|
|
191462
191596
|
return;
|
|
191463
191597
|
for (const decl of node.declarationList.declarations) {
|
|
191464
|
-
if (
|
|
191598
|
+
if (import_typescript11.default.isIdentifier(decl.name))
|
|
191465
191599
|
ctx.ambientGlobals.add(decl.name.text);
|
|
191466
191600
|
}
|
|
191467
191601
|
return;
|
|
191468
191602
|
}
|
|
191469
|
-
if (
|
|
191470
|
-
const isDeclare = node.modifiers?.some((m) => m.kind ===
|
|
191603
|
+
if (import_typescript11.default.isFunctionDeclaration(node) && node.name) {
|
|
191604
|
+
const isDeclare = node.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.DeclareKeyword) ?? false;
|
|
191471
191605
|
if (isDeclare)
|
|
191472
191606
|
ctx.ambientGlobals.add(node.name.text);
|
|
191473
191607
|
return;
|
|
191474
191608
|
}
|
|
191475
|
-
if (
|
|
191476
|
-
const isGlobalAugmentation = (node.flags &
|
|
191609
|
+
if (import_typescript11.default.isModuleDeclaration(node)) {
|
|
191610
|
+
const isGlobalAugmentation = (node.flags & import_typescript11.default.NodeFlags.GlobalAugmentation) !== 0;
|
|
191477
191611
|
if (!isGlobalAugmentation)
|
|
191478
191612
|
return;
|
|
191479
|
-
if (!node.body || !
|
|
191613
|
+
if (!node.body || !import_typescript11.default.isModuleBlock(node.body))
|
|
191480
191614
|
return;
|
|
191481
191615
|
for (const inner of node.body.statements) {
|
|
191482
|
-
if (
|
|
191616
|
+
if (import_typescript11.default.isVariableStatement(inner)) {
|
|
191483
191617
|
for (const decl of inner.declarationList.declarations) {
|
|
191484
|
-
if (
|
|
191618
|
+
if (import_typescript11.default.isIdentifier(decl.name))
|
|
191485
191619
|
ctx.ambientGlobals.add(decl.name.text);
|
|
191486
191620
|
}
|
|
191487
|
-
} else if (
|
|
191621
|
+
} else if (import_typescript11.default.isFunctionDeclaration(inner) && inner.name) {
|
|
191488
191622
|
ctx.ambientGlobals.add(inner.name.text);
|
|
191489
191623
|
}
|
|
191490
191624
|
}
|
|
@@ -191495,7 +191629,7 @@ function collectImport(node, ctx) {
|
|
|
191495
191629
|
const specifiers = [];
|
|
191496
191630
|
const isTypeOnly = !!node.importClause?.isTypeOnly;
|
|
191497
191631
|
const loc = getSourceLocation(node, ctx.sourceFile, ctx.filePath);
|
|
191498
|
-
if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings &&
|
|
191632
|
+
if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings && import_typescript11.default.isNamedImports(node.importClause.namedBindings)) {
|
|
191499
191633
|
const wrongImports = [];
|
|
191500
191634
|
for (const element of node.importClause.namedBindings.elements) {
|
|
191501
191635
|
const name = element.propertyName?.text ?? element.name.text;
|
|
@@ -191523,7 +191657,7 @@ function collectImport(node, ctx) {
|
|
|
191523
191657
|
});
|
|
191524
191658
|
}
|
|
191525
191659
|
if (node.importClause.namedBindings) {
|
|
191526
|
-
if (
|
|
191660
|
+
if (import_typescript11.default.isNamedImports(node.importClause.namedBindings)) {
|
|
191527
191661
|
for (const element of node.importClause.namedBindings.elements) {
|
|
191528
191662
|
specifiers.push({
|
|
191529
191663
|
name: element.propertyName?.text ?? element.name.text,
|
|
@@ -191534,7 +191668,7 @@ function collectImport(node, ctx) {
|
|
|
191534
191668
|
});
|
|
191535
191669
|
}
|
|
191536
191670
|
}
|
|
191537
|
-
if (
|
|
191671
|
+
if (import_typescript11.default.isNamespaceImport(node.importClause.namedBindings)) {
|
|
191538
191672
|
specifiers.push({
|
|
191539
191673
|
name: node.importClause.namedBindings.name.text,
|
|
191540
191674
|
alias: null,
|
|
@@ -191561,7 +191695,7 @@ function collectInterfaceDefinition(node, ctx) {
|
|
|
191561
191695
|
});
|
|
191562
191696
|
}
|
|
191563
191697
|
function collectTypeAliasDefinition(node, ctx) {
|
|
191564
|
-
const properties =
|
|
191698
|
+
const properties = import_typescript11.default.isTypeLiteralNode(node.type) ? membersToProperties(node.type.members, ctx.sourceFile) : undefined;
|
|
191565
191699
|
ctx.typeDefinitions.push({
|
|
191566
191700
|
kind: "type",
|
|
191567
191701
|
name: node.name.text,
|
|
@@ -191574,20 +191708,20 @@ function extractSingleJsxReturn(body) {
|
|
|
191574
191708
|
let jsxReturn = null;
|
|
191575
191709
|
let returnCount = 0;
|
|
191576
191710
|
function visit2(node) {
|
|
191577
|
-
if (
|
|
191711
|
+
if (import_typescript11.default.isFunctionDeclaration(node) || import_typescript11.default.isFunctionExpression(node) || import_typescript11.default.isArrowFunction(node))
|
|
191578
191712
|
return;
|
|
191579
|
-
if (
|
|
191713
|
+
if (import_typescript11.default.isReturnStatement(node)) {
|
|
191580
191714
|
returnCount++;
|
|
191581
191715
|
if (node.expression) {
|
|
191582
191716
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191583
|
-
if (
|
|
191717
|
+
if (import_typescript11.default.isJsxElement(expr) || import_typescript11.default.isJsxSelfClosingElement(expr) || import_typescript11.default.isJsxFragment(expr)) {
|
|
191584
191718
|
jsxReturn = expr;
|
|
191585
191719
|
}
|
|
191586
191720
|
}
|
|
191587
191721
|
}
|
|
191588
|
-
|
|
191722
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
191589
191723
|
}
|
|
191590
|
-
|
|
191724
|
+
import_typescript11.default.forEachChild(body, visit2);
|
|
191591
191725
|
if (returnCount !== 1)
|
|
191592
191726
|
return null;
|
|
191593
191727
|
return jsxReturn;
|
|
@@ -191604,9 +191738,9 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191604
191738
|
const stmts = body.statements;
|
|
191605
191739
|
for (let i2 = 0;i2 < stmts.length; i2++) {
|
|
191606
191740
|
const stmt = stmts[i2];
|
|
191607
|
-
if (
|
|
191741
|
+
if (import_typescript11.default.isIfStatement(stmt)) {
|
|
191608
191742
|
let current = stmt;
|
|
191609
|
-
while (
|
|
191743
|
+
while (import_typescript11.default.isIfStatement(current)) {
|
|
191610
191744
|
const ifStmt = current;
|
|
191611
191745
|
if (!isDirectReturnBlock(ifStmt.thenStatement))
|
|
191612
191746
|
return null;
|
|
@@ -191616,7 +191750,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191616
191750
|
return null;
|
|
191617
191751
|
branches.push({ condition: ifStmt.expression, jsxReturn: jsxReturn ?? null });
|
|
191618
191752
|
if (ifStmt.elseStatement) {
|
|
191619
|
-
if (
|
|
191753
|
+
if (import_typescript11.default.isIfStatement(ifStmt.elseStatement)) {
|
|
191620
191754
|
current = ifStmt.elseStatement;
|
|
191621
191755
|
continue;
|
|
191622
191756
|
}
|
|
@@ -191638,18 +191772,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191638
191772
|
}
|
|
191639
191773
|
continue;
|
|
191640
191774
|
}
|
|
191641
|
-
if (
|
|
191775
|
+
if (import_typescript11.default.isSwitchStatement(stmt)) {
|
|
191642
191776
|
if (branches.length > 0)
|
|
191643
191777
|
return null;
|
|
191644
|
-
if (!
|
|
191778
|
+
if (!import_typescript11.default.isIdentifier(stmt.expression) && !import_typescript11.default.isPropertyAccessExpression(stmt.expression)) {
|
|
191645
191779
|
return null;
|
|
191646
191780
|
}
|
|
191647
|
-
const hasDefault = stmt.caseBlock.clauses.some((c) =>
|
|
191781
|
+
const hasDefault = stmt.caseBlock.clauses.some((c) => import_typescript11.default.isDefaultClause(c));
|
|
191648
191782
|
if (!hasDefault)
|
|
191649
191783
|
return null;
|
|
191650
191784
|
let pendingCases = [];
|
|
191651
191785
|
for (const clause of stmt.caseBlock.clauses) {
|
|
191652
|
-
if (
|
|
191786
|
+
if (import_typescript11.default.isCaseClause(clause) && clause.statements.length === 0) {
|
|
191653
191787
|
pendingCases.push(clause.expression);
|
|
191654
191788
|
continue;
|
|
191655
191789
|
}
|
|
@@ -191659,7 +191793,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191659
191793
|
return null;
|
|
191660
191794
|
if (!caseClauseIsDirectReturn(clause))
|
|
191661
191795
|
return null;
|
|
191662
|
-
if (
|
|
191796
|
+
if (import_typescript11.default.isCaseClause(clause)) {
|
|
191663
191797
|
branches.push({
|
|
191664
191798
|
condition: clause.expression,
|
|
191665
191799
|
jsxReturn: jsxReturn ?? null,
|
|
@@ -191680,18 +191814,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191680
191814
|
return null;
|
|
191681
191815
|
return { branches, fallback, switchDiscriminant: stmt.expression, preamble };
|
|
191682
191816
|
}
|
|
191683
|
-
if (
|
|
191817
|
+
if (import_typescript11.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191684
191818
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191685
|
-
if (
|
|
191819
|
+
if (import_typescript11.default.isJsxElement(expr) || import_typescript11.default.isJsxSelfClosingElement(expr) || import_typescript11.default.isJsxFragment(expr)) {
|
|
191686
191820
|
fallback = expr;
|
|
191687
|
-
} else if (expr.kind ===
|
|
191821
|
+
} else if (expr.kind === import_typescript11.default.SyntaxKind.NullKeyword) {} else {
|
|
191688
191822
|
return null;
|
|
191689
191823
|
}
|
|
191690
191824
|
continue;
|
|
191691
191825
|
}
|
|
191692
|
-
if (
|
|
191826
|
+
if (import_typescript11.default.isVariableStatement(stmt)) {
|
|
191693
191827
|
const declFlags = stmt.declarationList.flags;
|
|
191694
|
-
const isConstOrLet = (declFlags &
|
|
191828
|
+
const isConstOrLet = (declFlags & import_typescript11.default.NodeFlags.Const) !== 0 || (declFlags & import_typescript11.default.NodeFlags.Let) !== 0;
|
|
191695
191829
|
if (allowPreamble && isConstOrLet && branches.length === 0 && fallback === null) {
|
|
191696
191830
|
preamble.push(stmt);
|
|
191697
191831
|
continue;
|
|
@@ -191707,12 +191841,12 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191707
191841
|
return { branches, fallback, preamble };
|
|
191708
191842
|
}
|
|
191709
191843
|
function isDirectReturnBlock(node) {
|
|
191710
|
-
if (
|
|
191844
|
+
if (import_typescript11.default.isReturnStatement(node))
|
|
191711
191845
|
return true;
|
|
191712
|
-
if (
|
|
191846
|
+
if (import_typescript11.default.isBlock(node)) {
|
|
191713
191847
|
let returnCount = 0;
|
|
191714
191848
|
for (const stmt of node.statements) {
|
|
191715
|
-
if (
|
|
191849
|
+
if (import_typescript11.default.isReturnStatement(stmt)) {
|
|
191716
191850
|
returnCount++;
|
|
191717
191851
|
continue;
|
|
191718
191852
|
}
|
|
@@ -191723,25 +191857,25 @@ function isDirectReturnBlock(node) {
|
|
|
191723
191857
|
return false;
|
|
191724
191858
|
}
|
|
191725
191859
|
function findNullReturnInBlock(node) {
|
|
191726
|
-
if (
|
|
191860
|
+
if (import_typescript11.default.isBlock(node)) {
|
|
191727
191861
|
for (const stmt of node.statements) {
|
|
191728
|
-
if (
|
|
191862
|
+
if (import_typescript11.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191729
191863
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191730
|
-
if (expr.kind ===
|
|
191864
|
+
if (expr.kind === import_typescript11.default.SyntaxKind.NullKeyword)
|
|
191731
191865
|
return true;
|
|
191732
191866
|
}
|
|
191733
191867
|
}
|
|
191734
191868
|
}
|
|
191735
|
-
if (
|
|
191869
|
+
if (import_typescript11.default.isReturnStatement(node) && node.expression) {
|
|
191736
191870
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191737
|
-
if (expr.kind ===
|
|
191871
|
+
if (expr.kind === import_typescript11.default.SyntaxKind.NullKeyword)
|
|
191738
191872
|
return true;
|
|
191739
191873
|
}
|
|
191740
191874
|
return false;
|
|
191741
191875
|
}
|
|
191742
191876
|
function findJsxReturnInCaseClause(clause) {
|
|
191743
191877
|
for (const stmt of clause.statements) {
|
|
191744
|
-
if (
|
|
191878
|
+
if (import_typescript11.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191745
191879
|
return extractJsxFromExpression(stmt.expression);
|
|
191746
191880
|
}
|
|
191747
191881
|
}
|
|
@@ -191751,12 +191885,12 @@ function caseClauseIsDirectReturn(clause) {
|
|
|
191751
191885
|
let returnCount = 0;
|
|
191752
191886
|
let seenReturn = false;
|
|
191753
191887
|
for (const stmt of clause.statements) {
|
|
191754
|
-
if (
|
|
191888
|
+
if (import_typescript11.default.isReturnStatement(stmt)) {
|
|
191755
191889
|
returnCount++;
|
|
191756
191890
|
seenReturn = true;
|
|
191757
191891
|
continue;
|
|
191758
191892
|
}
|
|
191759
|
-
if (
|
|
191893
|
+
if (import_typescript11.default.isBreakStatement(stmt)) {
|
|
191760
191894
|
if (!seenReturn)
|
|
191761
191895
|
return false;
|
|
191762
191896
|
continue;
|
|
@@ -191767,9 +191901,9 @@ function caseClauseIsDirectReturn(clause) {
|
|
|
191767
191901
|
}
|
|
191768
191902
|
function findNullReturnInCaseClause(clause) {
|
|
191769
191903
|
for (const stmt of clause.statements) {
|
|
191770
|
-
if (
|
|
191904
|
+
if (import_typescript11.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191771
191905
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191772
|
-
if (expr.kind ===
|
|
191906
|
+
if (expr.kind === import_typescript11.default.SyntaxKind.NullKeyword)
|
|
191773
191907
|
return true;
|
|
191774
191908
|
}
|
|
191775
191909
|
}
|
|
@@ -191780,26 +191914,26 @@ function isMultiReturnJsxFunctionBody(body) {
|
|
|
191780
191914
|
let hasJsxReturn = false;
|
|
191781
191915
|
let allReturnsAreJsxOrNull = true;
|
|
191782
191916
|
function visit2(node) {
|
|
191783
|
-
if (
|
|
191917
|
+
if (import_typescript11.default.isFunctionDeclaration(node) || import_typescript11.default.isFunctionExpression(node) || import_typescript11.default.isArrowFunction(node))
|
|
191784
191918
|
return;
|
|
191785
|
-
if (
|
|
191919
|
+
if (import_typescript11.default.isReturnStatement(node)) {
|
|
191786
191920
|
returnCount++;
|
|
191787
191921
|
if (!node.expression) {
|
|
191788
191922
|
allReturnsAreJsxOrNull = false;
|
|
191789
191923
|
return;
|
|
191790
191924
|
}
|
|
191791
191925
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191792
|
-
const isJsx =
|
|
191793
|
-
const isNull2 = expr.kind ===
|
|
191926
|
+
const isJsx = import_typescript11.default.isJsxElement(expr) || import_typescript11.default.isJsxSelfClosingElement(expr) || import_typescript11.default.isJsxFragment(expr);
|
|
191927
|
+
const isNull2 = expr.kind === import_typescript11.default.SyntaxKind.NullKeyword;
|
|
191794
191928
|
if (isJsx)
|
|
191795
191929
|
hasJsxReturn = true;
|
|
191796
191930
|
if (!isJsx && !isNull2)
|
|
191797
191931
|
allReturnsAreJsxOrNull = false;
|
|
191798
191932
|
return;
|
|
191799
191933
|
}
|
|
191800
|
-
|
|
191934
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
191801
191935
|
}
|
|
191802
|
-
|
|
191936
|
+
import_typescript11.default.forEachChild(body, visit2);
|
|
191803
191937
|
return returnCount > 1 && hasJsxReturn && allReturnsAreJsxOrNull;
|
|
191804
191938
|
}
|
|
191805
191939
|
function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
@@ -191869,7 +192003,7 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
|
191869
192003
|
}
|
|
191870
192004
|
}
|
|
191871
192005
|
}
|
|
191872
|
-
const isAsync = node.modifiers?.some((m) => m.kind ===
|
|
192006
|
+
const isAsync = node.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.AsyncKeyword) ?? false;
|
|
191873
192007
|
const isGenerator = !!node.asteriskToken;
|
|
191874
192008
|
ctx.localFunctions.push({
|
|
191875
192009
|
name,
|
|
@@ -191890,10 +192024,10 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
|
191890
192024
|
});
|
|
191891
192025
|
}
|
|
191892
192026
|
function extractValueBranches(node, ctx) {
|
|
191893
|
-
if (
|
|
192027
|
+
if (import_typescript11.default.isParenthesizedExpression(node)) {
|
|
191894
192028
|
return extractValueBranches(node.expression, ctx);
|
|
191895
192029
|
}
|
|
191896
|
-
if (
|
|
192030
|
+
if (import_typescript11.default.isConditionalExpression(node)) {
|
|
191897
192031
|
return [
|
|
191898
192032
|
...extractValueBranches(node.whenTrue, ctx),
|
|
191899
192033
|
...extractValueBranches(node.whenFalse, ctx)
|
|
@@ -191905,46 +192039,46 @@ function extractFreeIdentifiersFromNode(node) {
|
|
|
191905
192039
|
const ids = new Set;
|
|
191906
192040
|
const boundNames = new Set;
|
|
191907
192041
|
function addBindingNames(name, out) {
|
|
191908
|
-
if (
|
|
192042
|
+
if (import_typescript11.default.isIdentifier(name))
|
|
191909
192043
|
out.push(name.text);
|
|
191910
|
-
else if (
|
|
192044
|
+
else if (import_typescript11.default.isObjectBindingPattern(name))
|
|
191911
192045
|
name.elements.forEach((e) => addBindingNames(e.name, out));
|
|
191912
|
-
else if (
|
|
192046
|
+
else if (import_typescript11.default.isArrayBindingPattern(name))
|
|
191913
192047
|
name.elements.forEach((e) => {
|
|
191914
|
-
if (!
|
|
192048
|
+
if (!import_typescript11.default.isOmittedExpression(e))
|
|
191915
192049
|
addBindingNames(e.name, out);
|
|
191916
192050
|
});
|
|
191917
192051
|
}
|
|
191918
192052
|
function visit2(n) {
|
|
191919
|
-
if (
|
|
192053
|
+
if (import_typescript11.default.isTypeNode(n))
|
|
191920
192054
|
return;
|
|
191921
|
-
if (
|
|
192055
|
+
if (import_typescript11.default.isIdentifier(n)) {
|
|
191922
192056
|
const parent = n.parent;
|
|
191923
|
-
if (parent &&
|
|
192057
|
+
if (parent && import_typescript11.default.isPropertyAccessExpression(parent) && parent.name === n)
|
|
191924
192058
|
return;
|
|
191925
|
-
if (parent &&
|
|
192059
|
+
if (parent && import_typescript11.default.isPropertyAssignment(parent) && parent.name === n)
|
|
191926
192060
|
return;
|
|
191927
|
-
if (parent &&
|
|
192061
|
+
if (parent && import_typescript11.default.isParameter(parent) && parent.name === n)
|
|
191928
192062
|
return;
|
|
191929
|
-
if (parent &&
|
|
192063
|
+
if (parent && import_typescript11.default.isVariableDeclaration(parent) && parent.name === n)
|
|
191930
192064
|
return;
|
|
191931
192065
|
if (boundNames.has(n.text))
|
|
191932
192066
|
return;
|
|
191933
192067
|
ids.add(n.text);
|
|
191934
192068
|
return;
|
|
191935
192069
|
}
|
|
191936
|
-
if (
|
|
192070
|
+
if (import_typescript11.default.isArrowFunction(n)) {
|
|
191937
192071
|
const params = [];
|
|
191938
192072
|
for (const p of n.parameters)
|
|
191939
192073
|
addBindingNames(p.name, params);
|
|
191940
192074
|
for (const name of params)
|
|
191941
192075
|
boundNames.add(name);
|
|
191942
|
-
|
|
192076
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191943
192077
|
for (const name of params)
|
|
191944
192078
|
boundNames.delete(name);
|
|
191945
192079
|
return;
|
|
191946
192080
|
}
|
|
191947
|
-
|
|
192081
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191948
192082
|
}
|
|
191949
192083
|
visit2(node);
|
|
191950
192084
|
return ids;
|
|
@@ -191953,29 +192087,29 @@ function extractFreeTypeIdentifiersFromNode(node) {
|
|
|
191953
192087
|
const ids = new Set;
|
|
191954
192088
|
const boundTypeParams = new Set;
|
|
191955
192089
|
function rootName(name) {
|
|
191956
|
-
return
|
|
192090
|
+
return import_typescript11.default.isQualifiedName(name) ? rootName(name.left) : name;
|
|
191957
192091
|
}
|
|
191958
192092
|
function visit2(n) {
|
|
191959
|
-
if (
|
|
192093
|
+
if (import_typescript11.default.isTypeReferenceNode(n)) {
|
|
191960
192094
|
const name = rootName(n.typeName).text;
|
|
191961
192095
|
if (!boundTypeParams.has(name))
|
|
191962
192096
|
ids.add(name);
|
|
191963
192097
|
}
|
|
191964
|
-
if (
|
|
192098
|
+
if (import_typescript11.default.isTypeQueryNode(n)) {
|
|
191965
192099
|
const name = rootName(n.exprName).text;
|
|
191966
192100
|
if (!boundTypeParams.has(name))
|
|
191967
192101
|
ids.add(name);
|
|
191968
192102
|
}
|
|
191969
|
-
if (
|
|
192103
|
+
if (import_typescript11.default.isFunctionLike(n) && n.typeParameters && n.typeParameters.length > 0) {
|
|
191970
192104
|
const names = n.typeParameters.map((p) => p.name.text);
|
|
191971
192105
|
for (const p of names)
|
|
191972
192106
|
boundTypeParams.add(p);
|
|
191973
|
-
|
|
192107
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191974
192108
|
for (const p of names)
|
|
191975
192109
|
boundTypeParams.delete(p);
|
|
191976
192110
|
return;
|
|
191977
192111
|
}
|
|
191978
|
-
|
|
192112
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191979
192113
|
}
|
|
191980
192114
|
visit2(node);
|
|
191981
192115
|
return ids;
|
|
@@ -191985,22 +192119,22 @@ function initializerShapeContainsJsx(node) {
|
|
|
191985
192119
|
function visit2(n) {
|
|
191986
192120
|
if (found)
|
|
191987
192121
|
return;
|
|
191988
|
-
if (
|
|
192122
|
+
if (import_typescript11.default.isJsxElement(n) || import_typescript11.default.isJsxSelfClosingElement(n) || import_typescript11.default.isJsxFragment(n)) {
|
|
191989
192123
|
found = true;
|
|
191990
192124
|
return;
|
|
191991
192125
|
}
|
|
191992
|
-
if (
|
|
192126
|
+
if (import_typescript11.default.isFunctionDeclaration(n) || import_typescript11.default.isFunctionExpression(n) || import_typescript11.default.isArrowFunction(n)) {
|
|
191993
192127
|
return;
|
|
191994
192128
|
}
|
|
191995
|
-
|
|
192129
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191996
192130
|
}
|
|
191997
192131
|
visit2(node);
|
|
191998
192132
|
return found;
|
|
191999
192133
|
}
|
|
192000
192134
|
function isMapLikeCallWithJsx(node) {
|
|
192001
|
-
if (!
|
|
192135
|
+
if (!import_typescript11.default.isCallExpression(node))
|
|
192002
192136
|
return false;
|
|
192003
|
-
if (!
|
|
192137
|
+
if (!import_typescript11.default.isPropertyAccessExpression(node.expression))
|
|
192004
192138
|
return false;
|
|
192005
192139
|
const method = node.expression.name.text;
|
|
192006
192140
|
if (method !== "map" && method !== "flatMap")
|
|
@@ -192008,12 +192142,12 @@ function isMapLikeCallWithJsx(node) {
|
|
|
192008
192142
|
const callback = node.arguments[0];
|
|
192009
192143
|
if (!callback)
|
|
192010
192144
|
return false;
|
|
192011
|
-
if (!
|
|
192145
|
+
if (!import_typescript11.default.isArrowFunction(callback) && !import_typescript11.default.isFunctionExpression(callback))
|
|
192012
192146
|
return false;
|
|
192013
192147
|
return containsJsxDeep(callback.body);
|
|
192014
192148
|
}
|
|
192015
192149
|
function containsJsxDeep(node) {
|
|
192016
|
-
if (
|
|
192150
|
+
if (import_typescript11.default.isJsxElement(node) || import_typescript11.default.isJsxSelfClosingElement(node) || import_typescript11.default.isJsxFragment(node))
|
|
192017
192151
|
return true;
|
|
192018
192152
|
let found = false;
|
|
192019
192153
|
node.forEachChild((child) => {
|
|
@@ -192027,11 +192161,11 @@ function nodeContainsArrow(node) {
|
|
|
192027
192161
|
function visit2(n) {
|
|
192028
192162
|
if (found)
|
|
192029
192163
|
return;
|
|
192030
|
-
if (
|
|
192164
|
+
if (import_typescript11.default.isArrowFunction(n) || import_typescript11.default.isFunctionExpression(n)) {
|
|
192031
192165
|
found = true;
|
|
192032
192166
|
return;
|
|
192033
192167
|
}
|
|
192034
|
-
|
|
192168
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
192035
192169
|
}
|
|
192036
192170
|
visit2(node);
|
|
192037
192171
|
return found;
|
|
@@ -192079,20 +192213,20 @@ function collectModuleScopeReactive(decl, ctx, isExported) {
|
|
|
192079
192213
|
}));
|
|
192080
192214
|
}
|
|
192081
192215
|
function getSystemConstructKind(node) {
|
|
192082
|
-
if (
|
|
192216
|
+
if (import_typescript11.default.isCallExpression(node) && import_typescript11.default.isIdentifier(node.expression) && node.expression.text === "createContext")
|
|
192083
192217
|
return "createContext";
|
|
192084
|
-
if (
|
|
192218
|
+
if (import_typescript11.default.isNewExpression(node) && import_typescript11.default.isIdentifier(node.expression) && node.expression.text === "WeakMap")
|
|
192085
192219
|
return "weakMap";
|
|
192086
192220
|
return;
|
|
192087
192221
|
}
|
|
192088
192222
|
function collectConstant(node, ctx, _isModule, declarationKind = "const", isExported = false) {
|
|
192089
|
-
if (!_isModule &&
|
|
192223
|
+
if (!_isModule && import_typescript11.default.isObjectBindingPattern(node.name) && node.initializer && import_typescript11.default.isIdentifier(node.initializer) && ctx.propsObjectName === node.initializer.text) {
|
|
192090
192224
|
const propsName = node.initializer.text;
|
|
192091
192225
|
for (const el of node.name.elements) {
|
|
192092
|
-
if (!
|
|
192226
|
+
if (!import_typescript11.default.isBindingElement(el) || !import_typescript11.default.isIdentifier(el.name) || el.dotDotDotToken)
|
|
192093
192227
|
continue;
|
|
192094
192228
|
const localName = el.name.text;
|
|
192095
|
-
const sourceKey = el.propertyName &&
|
|
192229
|
+
const sourceKey = el.propertyName && import_typescript11.default.isIdentifier(el.propertyName) ? el.propertyName.text : localName;
|
|
192096
192230
|
const defaultValueExpr = el.initializer ? ctx.getJS(el.initializer) : undefined;
|
|
192097
192231
|
const baseValue = `${propsName}.${sourceKey}`;
|
|
192098
192232
|
const value2 = defaultValueExpr ? `${baseValue} ?? ${defaultValueExpr}` : baseValue;
|
|
@@ -192114,7 +192248,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192114
192248
|
}
|
|
192115
192249
|
return;
|
|
192116
192250
|
}
|
|
192117
|
-
if (!
|
|
192251
|
+
if (!import_typescript11.default.isIdentifier(node.name))
|
|
192118
192252
|
return;
|
|
192119
192253
|
if (isSignalDeclaration(node, ctx) || isMemoDeclaration(node, ctx))
|
|
192120
192254
|
return;
|
|
@@ -192132,9 +192266,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192132
192266
|
let isJsxFunction = false;
|
|
192133
192267
|
if (node.initializer) {
|
|
192134
192268
|
let init = node.initializer;
|
|
192135
|
-
while (
|
|
192269
|
+
while (import_typescript11.default.isParenthesizedExpression(init))
|
|
192136
192270
|
init = init.expression;
|
|
192137
|
-
if (
|
|
192271
|
+
if (import_typescript11.default.isJsxElement(init) || import_typescript11.default.isJsxSelfClosingElement(init) || import_typescript11.default.isJsxFragment(init)) {
|
|
192138
192272
|
isJsx = true;
|
|
192139
192273
|
ctx.jsxConstants.set(name, init);
|
|
192140
192274
|
} else if (initializerShapeContainsJsx(init)) {
|
|
@@ -192142,9 +192276,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192142
192276
|
} else if (isMapLikeCallWithJsx(init)) {
|
|
192143
192277
|
ctx.inlineableJsxConsts.set(name, init);
|
|
192144
192278
|
}
|
|
192145
|
-
if (
|
|
192279
|
+
if (import_typescript11.default.isArrowFunction(init)) {
|
|
192146
192280
|
const arrowBody = init.body;
|
|
192147
|
-
if (
|
|
192281
|
+
if (import_typescript11.default.isBlock(arrowBody)) {
|
|
192148
192282
|
const jsxReturn = extractSingleJsxReturn(arrowBody);
|
|
192149
192283
|
if (jsxReturn) {
|
|
192150
192284
|
isJsxFunction = true;
|
|
@@ -192164,9 +192298,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192164
192298
|
}
|
|
192165
192299
|
} else {
|
|
192166
192300
|
let body = arrowBody;
|
|
192167
|
-
while (
|
|
192301
|
+
while (import_typescript11.default.isParenthesizedExpression(body))
|
|
192168
192302
|
body = body.expression;
|
|
192169
|
-
if (
|
|
192303
|
+
if (import_typescript11.default.isJsxElement(body) || import_typescript11.default.isJsxSelfClosingElement(body) || import_typescript11.default.isJsxFragment(body)) {
|
|
192170
192304
|
isJsxFunction = true;
|
|
192171
192305
|
ctx.jsxFunctions.set(name, {
|
|
192172
192306
|
jsxReturn: body,
|
|
@@ -192179,9 +192313,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192179
192313
|
let valueBranches;
|
|
192180
192314
|
if (node.initializer) {
|
|
192181
192315
|
let inner = node.initializer;
|
|
192182
|
-
while (
|
|
192316
|
+
while (import_typescript11.default.isParenthesizedExpression(inner))
|
|
192183
192317
|
inner = inner.expression;
|
|
192184
|
-
if (
|
|
192318
|
+
if (import_typescript11.default.isConditionalExpression(inner)) {
|
|
192185
192319
|
valueBranches = extractValueBranches(node.initializer, ctx);
|
|
192186
192320
|
}
|
|
192187
192321
|
}
|
|
@@ -192259,7 +192393,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192259
192393
|
function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
192260
192394
|
const checkComments = (targetNode) => {
|
|
192261
192395
|
const fullStart = targetNode.getFullStart();
|
|
192262
|
-
const leadingComments =
|
|
192396
|
+
const leadingComments = import_typescript11.default.getLeadingCommentRanges(sourceFile.getFullText(), fullStart);
|
|
192263
192397
|
if (!leadingComments)
|
|
192264
192398
|
return false;
|
|
192265
192399
|
for (const range of leadingComments) {
|
|
@@ -192272,10 +192406,10 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
|
192272
192406
|
};
|
|
192273
192407
|
if (checkComments(node))
|
|
192274
192408
|
return true;
|
|
192275
|
-
if (
|
|
192409
|
+
if (import_typescript11.default.isArrowFunction(node)) {
|
|
192276
192410
|
let current = node.parent;
|
|
192277
192411
|
while (current) {
|
|
192278
|
-
if (
|
|
192412
|
+
if (import_typescript11.default.isVariableStatement(current)) {
|
|
192279
192413
|
if (checkComments(current))
|
|
192280
192414
|
return true;
|
|
192281
192415
|
break;
|
|
@@ -192286,7 +192420,7 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
|
192286
192420
|
return false;
|
|
192287
192421
|
}
|
|
192288
192422
|
function extractProps(param, ctx) {
|
|
192289
|
-
if (
|
|
192423
|
+
if (import_typescript11.default.isObjectBindingPattern(param.name)) {
|
|
192290
192424
|
const componentNode = ctx.componentNode;
|
|
192291
192425
|
const ignored = !!(componentNode && hasIgnoreDirective(componentNode, ctx.sourceFile, "props-destructuring"));
|
|
192292
192426
|
ctx.propsDestructuring = {
|
|
@@ -192295,14 +192429,14 @@ function extractProps(param, ctx) {
|
|
|
192295
192429
|
};
|
|
192296
192430
|
const memberTypes = param.type ? collectMemberTypes(param.type, ctx) : null;
|
|
192297
192431
|
for (const element of param.name.elements) {
|
|
192298
|
-
if (
|
|
192432
|
+
if (import_typescript11.default.isBindingElement(element) && import_typescript11.default.isIdentifier(element.name)) {
|
|
192299
192433
|
const localName = element.name.text;
|
|
192300
192434
|
const defaultValue = element.initializer ? ctx.getJS(element.initializer) : undefined;
|
|
192301
192435
|
if (element.dotDotDotToken) {
|
|
192302
192436
|
ctx.restPropsName = localName;
|
|
192303
192437
|
continue;
|
|
192304
192438
|
}
|
|
192305
|
-
const sourcePropName = element.propertyName &&
|
|
192439
|
+
const sourcePropName = element.propertyName && import_typescript11.default.isIdentifier(element.propertyName) ? element.propertyName.text : localName;
|
|
192306
192440
|
const member = memberTypes?.get(sourcePropName);
|
|
192307
192441
|
const resolvedType = member?.type ?? { kind: "unknown", raw: "unknown" };
|
|
192308
192442
|
const defaultContainsArrow = element.initializer ? nodeContainsArrow(element.initializer) : false;
|
|
@@ -192326,7 +192460,7 @@ function extractProps(param, ctx) {
|
|
|
192326
192460
|
}
|
|
192327
192461
|
}
|
|
192328
192462
|
}
|
|
192329
|
-
if (
|
|
192463
|
+
if (import_typescript11.default.isIdentifier(param.name)) {
|
|
192330
192464
|
ctx.propsObjectName = param.name.text;
|
|
192331
192465
|
if (param.type) {
|
|
192332
192466
|
extractPropsFromType(param.type, ctx);
|
|
@@ -192337,24 +192471,24 @@ function extractProps(param, ctx) {
|
|
|
192337
192471
|
}
|
|
192338
192472
|
}
|
|
192339
192473
|
function collectTypeKeys(typeNode, ctx) {
|
|
192340
|
-
if (
|
|
192474
|
+
if (import_typescript11.default.isTypeLiteralNode(typeNode)) {
|
|
192341
192475
|
return collectKeysFromMembers(typeNode.members, ctx);
|
|
192342
192476
|
}
|
|
192343
|
-
if (
|
|
192477
|
+
if (import_typescript11.default.isTypeReferenceNode(typeNode)) {
|
|
192344
192478
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192345
192479
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192346
192480
|
if (!typeDecl)
|
|
192347
192481
|
return null;
|
|
192348
|
-
if (
|
|
192482
|
+
if (import_typescript11.default.isInterfaceDeclaration(typeDecl)) {
|
|
192349
192483
|
if (typeDecl.heritageClauses && typeDecl.heritageClauses.length > 0)
|
|
192350
192484
|
return null;
|
|
192351
192485
|
return collectKeysFromMembers(typeDecl.members, ctx);
|
|
192352
192486
|
}
|
|
192353
|
-
if (
|
|
192354
|
-
if (
|
|
192487
|
+
if (import_typescript11.default.isTypeAliasDeclaration(typeDecl)) {
|
|
192488
|
+
if (import_typescript11.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192355
192489
|
return collectKeysFromMembers(typeDecl.type.members, ctx);
|
|
192356
192490
|
}
|
|
192357
|
-
if (
|
|
192491
|
+
if (import_typescript11.default.isIntersectionTypeNode(typeDecl.type)) {
|
|
192358
192492
|
return null;
|
|
192359
192493
|
}
|
|
192360
192494
|
}
|
|
@@ -192364,9 +192498,9 @@ function collectTypeKeys(typeNode, ctx) {
|
|
|
192364
192498
|
function collectKeysFromMembers(members, ctx) {
|
|
192365
192499
|
const keys = [];
|
|
192366
192500
|
for (const member of members) {
|
|
192367
|
-
if (
|
|
192501
|
+
if (import_typescript11.default.isIndexSignatureDeclaration(member))
|
|
192368
192502
|
return null;
|
|
192369
|
-
if (
|
|
192503
|
+
if (import_typescript11.default.isPropertySignature(member) && member.name) {
|
|
192370
192504
|
keys.push(member.name.getText(ctx.sourceFile));
|
|
192371
192505
|
}
|
|
192372
192506
|
}
|
|
@@ -192390,7 +192524,7 @@ function collectMemberTypes(typeNode, ctx) {
|
|
|
192390
192524
|
const fromMembers = (members) => {
|
|
192391
192525
|
const map = new Map;
|
|
192392
192526
|
for (const member of members) {
|
|
192393
|
-
if (
|
|
192527
|
+
if (import_typescript11.default.isPropertySignature(member) && member.name) {
|
|
192394
192528
|
const info = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : null;
|
|
192395
192529
|
map.set(member.name.getText(ctx.sourceFile), {
|
|
192396
192530
|
type: info && isResolvableMemberType(info) ? info : null,
|
|
@@ -192400,35 +192534,35 @@ function collectMemberTypes(typeNode, ctx) {
|
|
|
192400
192534
|
}
|
|
192401
192535
|
return map;
|
|
192402
192536
|
};
|
|
192403
|
-
if (
|
|
192537
|
+
if (import_typescript11.default.isTypeLiteralNode(typeNode)) {
|
|
192404
192538
|
return fromMembers(typeNode.members);
|
|
192405
192539
|
}
|
|
192406
|
-
if (
|
|
192540
|
+
if (import_typescript11.default.isTypeReferenceNode(typeNode)) {
|
|
192407
192541
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192408
192542
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192409
192543
|
if (!typeDecl)
|
|
192410
192544
|
return null;
|
|
192411
|
-
if (
|
|
192545
|
+
if (import_typescript11.default.isInterfaceDeclaration(typeDecl)) {
|
|
192412
192546
|
return fromMembers(typeDecl.members);
|
|
192413
192547
|
}
|
|
192414
|
-
if (
|
|
192548
|
+
if (import_typescript11.default.isTypeAliasDeclaration(typeDecl) && import_typescript11.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192415
192549
|
return fromMembers(typeDecl.type.members);
|
|
192416
192550
|
}
|
|
192417
192551
|
}
|
|
192418
192552
|
return null;
|
|
192419
192553
|
}
|
|
192420
192554
|
function extractPropsFromType(typeNode, ctx) {
|
|
192421
|
-
if (
|
|
192555
|
+
if (import_typescript11.default.isTypeLiteralNode(typeNode)) {
|
|
192422
192556
|
extractPropsFromTypeMembers(typeNode.members, ctx);
|
|
192423
192557
|
return;
|
|
192424
192558
|
}
|
|
192425
|
-
if (
|
|
192559
|
+
if (import_typescript11.default.isTypeReferenceNode(typeNode)) {
|
|
192426
192560
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192427
192561
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192428
192562
|
if (typeDecl) {
|
|
192429
|
-
if (
|
|
192563
|
+
if (import_typescript11.default.isInterfaceDeclaration(typeDecl)) {
|
|
192430
192564
|
extractPropsFromTypeMembers(typeDecl.members, ctx);
|
|
192431
|
-
} else if (
|
|
192565
|
+
} else if (import_typescript11.default.isTypeAliasDeclaration(typeDecl) && import_typescript11.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192432
192566
|
extractPropsFromTypeMembers(typeDecl.type.members, ctx);
|
|
192433
192567
|
}
|
|
192434
192568
|
}
|
|
@@ -192436,7 +192570,7 @@ function extractPropsFromType(typeNode, ctx) {
|
|
|
192436
192570
|
}
|
|
192437
192571
|
function extractPropsFromTypeMembers(members, ctx) {
|
|
192438
192572
|
for (const member of members) {
|
|
192439
|
-
if (
|
|
192573
|
+
if (import_typescript11.default.isPropertySignature(member) && member.name) {
|
|
192440
192574
|
const propName = member.name.getText(ctx.sourceFile);
|
|
192441
192575
|
const isOptional = !!member.questionToken;
|
|
192442
192576
|
const propType = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : { kind: "unknown", raw: "unknown" };
|
|
@@ -192452,17 +192586,17 @@ function extractPropsFromTypeMembers(members, ctx) {
|
|
|
192452
192586
|
function findTypeDeclaration(typeName, sourceFile) {
|
|
192453
192587
|
let result;
|
|
192454
192588
|
function visit2(node) {
|
|
192455
|
-
if (
|
|
192589
|
+
if (import_typescript11.default.isInterfaceDeclaration(node) && node.name.text === typeName) {
|
|
192456
192590
|
result = node;
|
|
192457
192591
|
return;
|
|
192458
192592
|
}
|
|
192459
|
-
if (
|
|
192593
|
+
if (import_typescript11.default.isTypeAliasDeclaration(node) && node.name.text === typeName) {
|
|
192460
192594
|
result = node;
|
|
192461
192595
|
return;
|
|
192462
192596
|
}
|
|
192463
|
-
|
|
192597
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
192464
192598
|
}
|
|
192465
|
-
|
|
192599
|
+
import_typescript11.default.forEachChild(sourceFile, visit2);
|
|
192466
192600
|
return result;
|
|
192467
192601
|
}
|
|
192468
192602
|
function inferTypeFromValue(value) {
|
|
@@ -192508,12 +192642,12 @@ function inferTypeFromValue(value) {
|
|
|
192508
192642
|
}
|
|
192509
192643
|
function collectCalledIdentifiers(code2) {
|
|
192510
192644
|
const called = new Set;
|
|
192511
|
-
const sf =
|
|
192645
|
+
const sf = import_typescript11.default.createSourceFile("__deps__.tsx", code2, import_typescript11.default.ScriptTarget.Latest, false, import_typescript11.default.ScriptKind.TSX);
|
|
192512
192646
|
const visit2 = (node) => {
|
|
192513
|
-
if (
|
|
192647
|
+
if (import_typescript11.default.isCallExpression(node) && import_typescript11.default.isIdentifier(node.expression)) {
|
|
192514
192648
|
called.add(node.expression.text);
|
|
192515
192649
|
}
|
|
192516
|
-
|
|
192650
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
192517
192651
|
};
|
|
192518
192652
|
visit2(sf);
|
|
192519
192653
|
return called;
|
|
@@ -192611,16 +192745,16 @@ function isResolvableComponentSource(source) {
|
|
|
192611
192745
|
function collectJsxComponentTags(sourceFile) {
|
|
192612
192746
|
const tags = new Set;
|
|
192613
192747
|
function visit2(node) {
|
|
192614
|
-
if (
|
|
192748
|
+
if (import_typescript11.default.isJsxOpeningElement(node) || import_typescript11.default.isJsxSelfClosingElement(node)) {
|
|
192615
192749
|
const tagName = node.tagName;
|
|
192616
|
-
if (
|
|
192750
|
+
if (import_typescript11.default.isIdentifier(tagName)) {
|
|
192617
192751
|
const first = tagName.text.charAt(0);
|
|
192618
192752
|
if (first >= "A" && first <= "Z") {
|
|
192619
192753
|
tags.add(tagName.text);
|
|
192620
192754
|
}
|
|
192621
192755
|
}
|
|
192622
192756
|
}
|
|
192623
|
-
|
|
192757
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
192624
192758
|
}
|
|
192625
192759
|
visit2(sourceFile);
|
|
192626
192760
|
return tags;
|
|
@@ -192699,18 +192833,18 @@ function fileHasUseClientDirective(filePath) {
|
|
|
192699
192833
|
} catch {
|
|
192700
192834
|
return true;
|
|
192701
192835
|
}
|
|
192702
|
-
const sf =
|
|
192836
|
+
const sf = import_typescript11.default.createSourceFile(filePath, content, import_typescript11.default.ScriptTarget.Latest, false, import_typescript11.default.ScriptKind.TSX);
|
|
192703
192837
|
let found = false;
|
|
192704
192838
|
function visit2(node) {
|
|
192705
192839
|
if (found)
|
|
192706
192840
|
return;
|
|
192707
|
-
if (
|
|
192841
|
+
if (import_typescript11.default.isExpressionStatement(node) && import_typescript11.default.isStringLiteral(node.expression)) {
|
|
192708
192842
|
if (node.expression.text === "use client") {
|
|
192709
192843
|
found = true;
|
|
192710
192844
|
return;
|
|
192711
192845
|
}
|
|
192712
192846
|
}
|
|
192713
|
-
|
|
192847
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
192714
192848
|
}
|
|
192715
192849
|
visit2(sf);
|
|
192716
192850
|
return found;
|
|
@@ -192768,7 +192902,8 @@ var BROWSER_ONLY_CLIENT_APIS = new Set([
|
|
|
192768
192902
|
"createPortal",
|
|
192769
192903
|
"isSSRPortal",
|
|
192770
192904
|
"findSiblingSlot",
|
|
192771
|
-
"cleanupPortalPlaceholder"
|
|
192905
|
+
"cleanupPortalPlaceholder",
|
|
192906
|
+
"trackPosition"
|
|
192772
192907
|
]);
|
|
192773
192908
|
function importsBrowserOnlyClientApi(ctx) {
|
|
192774
192909
|
for (const imp of ctx.imports) {
|
|
@@ -192795,13 +192930,13 @@ var REACTIVE_PRIMITIVES = new Set([
|
|
|
192795
192930
|
"onCleanup"
|
|
192796
192931
|
]);
|
|
192797
192932
|
function prescanReactiveFactoriesInSource(source, filePath) {
|
|
192798
|
-
const sourceFile =
|
|
192933
|
+
const sourceFile = import_typescript11.default.createSourceFile(filePath + ".prescan", source, import_typescript11.default.ScriptTarget.Latest, true, import_typescript11.default.ScriptKind.TSX);
|
|
192799
192934
|
const factories = new Map;
|
|
192800
192935
|
const declined = new Map;
|
|
192801
192936
|
const reactiveShaped = new Set;
|
|
192802
192937
|
const cleanFactoryImports = new Set;
|
|
192803
192938
|
function visitTop(node) {
|
|
192804
|
-
if (
|
|
192939
|
+
if (import_typescript11.default.isFunctionDeclaration(node) && node.name && node.body) {
|
|
192805
192940
|
const det = detectReactiveFactory(node, sourceFile, filePath);
|
|
192806
192941
|
if (!det)
|
|
192807
192942
|
return;
|
|
@@ -192818,7 +192953,7 @@ function prescanReactiveFactoriesInSource(source, filePath) {
|
|
|
192818
192953
|
}
|
|
192819
192954
|
}
|
|
192820
192955
|
}
|
|
192821
|
-
|
|
192956
|
+
import_typescript11.default.forEachChild(sourceFile, visitTop);
|
|
192822
192957
|
const result = { factories, declined, reactiveShaped, cleanFactoryImports, sourceFile };
|
|
192823
192958
|
prescanImportedReactiveFactories(sourceFile, filePath, result);
|
|
192824
192959
|
return result;
|
|
@@ -192835,15 +192970,15 @@ function toComponentRelativeSpecifier(resolvedAbs, componentFilePath) {
|
|
|
192835
192970
|
function buildEntryImportIndex(sf, filePath) {
|
|
192836
192971
|
const index = new Map;
|
|
192837
192972
|
for (const stmt of sf.statements) {
|
|
192838
|
-
if (!
|
|
192973
|
+
if (!import_typescript11.default.isImportDeclaration(stmt))
|
|
192839
192974
|
continue;
|
|
192840
|
-
if (!
|
|
192975
|
+
if (!import_typescript11.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192841
192976
|
continue;
|
|
192842
192977
|
const src = stmt.moduleSpecifier.text;
|
|
192843
192978
|
const targetKey = src.startsWith("./") || src.startsWith("../") ? resolveRelativeImportToFile(src, filePath) ?? "unresolved:" + src : src;
|
|
192844
192979
|
const wholeTypeOnly = stmt.importClause?.isTypeOnly === true;
|
|
192845
192980
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
192846
|
-
if (namedBindings &&
|
|
192981
|
+
if (namedBindings && import_typescript11.default.isNamedImports(namedBindings)) {
|
|
192847
192982
|
for (const el of namedBindings.elements) {
|
|
192848
192983
|
index.set(el.name.text, {
|
|
192849
192984
|
targetKey,
|
|
@@ -192858,31 +192993,31 @@ function buildEntryImportIndex(sf, filePath) {
|
|
|
192858
192993
|
function collectEntryBindingNames(sf) {
|
|
192859
192994
|
const names = new Set;
|
|
192860
192995
|
function visit2(node) {
|
|
192861
|
-
if (
|
|
192996
|
+
if (import_typescript11.default.isImportDeclaration(node) && node.importClause) {
|
|
192862
192997
|
if (node.importClause.name)
|
|
192863
192998
|
names.add(node.importClause.name.text);
|
|
192864
192999
|
const namedBindings = node.importClause.namedBindings;
|
|
192865
|
-
if (namedBindings &&
|
|
193000
|
+
if (namedBindings && import_typescript11.default.isNamedImports(namedBindings)) {
|
|
192866
193001
|
for (const el of namedBindings.elements)
|
|
192867
193002
|
names.add(el.name.text);
|
|
192868
193003
|
}
|
|
192869
|
-
if (namedBindings &&
|
|
193004
|
+
if (namedBindings && import_typescript11.default.isNamespaceImport(namedBindings)) {
|
|
192870
193005
|
names.add(namedBindings.name.text);
|
|
192871
193006
|
}
|
|
192872
193007
|
}
|
|
192873
|
-
if (
|
|
193008
|
+
if (import_typescript11.default.isVariableDeclaration(node)) {
|
|
192874
193009
|
const out = [];
|
|
192875
193010
|
addBindingNames(node.name, out);
|
|
192876
193011
|
for (const n of out)
|
|
192877
193012
|
names.add(n);
|
|
192878
193013
|
}
|
|
192879
|
-
if ((
|
|
193014
|
+
if ((import_typescript11.default.isFunctionDeclaration(node) || import_typescript11.default.isClassDeclaration(node) || import_typescript11.default.isEnumDeclaration(node)) && node.name) {
|
|
192880
193015
|
names.add(node.name.text);
|
|
192881
193016
|
}
|
|
192882
|
-
if ((
|
|
193017
|
+
if ((import_typescript11.default.isTypeAliasDeclaration(node) || import_typescript11.default.isInterfaceDeclaration(node)) && node.name) {
|
|
192883
193018
|
names.add(node.name.text);
|
|
192884
193019
|
}
|
|
192885
|
-
if (
|
|
193020
|
+
if (import_typescript11.default.isFunctionLike(node)) {
|
|
192886
193021
|
for (const p of node.parameters) {
|
|
192887
193022
|
const out = [];
|
|
192888
193023
|
addBindingNames(p.name, out);
|
|
@@ -192890,7 +193025,7 @@ function collectEntryBindingNames(sf) {
|
|
|
192890
193025
|
names.add(n);
|
|
192891
193026
|
}
|
|
192892
193027
|
}
|
|
192893
|
-
|
|
193028
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
192894
193029
|
}
|
|
192895
193030
|
visit2(sf);
|
|
192896
193031
|
return names;
|
|
@@ -192899,19 +193034,19 @@ var MAX_REEXPORT_HOPS = 1;
|
|
|
192899
193034
|
function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
192900
193035
|
const candidateCallees = new Set;
|
|
192901
193036
|
function collectCandidates(node) {
|
|
192902
|
-
if (
|
|
193037
|
+
if (import_typescript11.default.isVariableDeclaration(node) && (import_typescript11.default.isArrayBindingPattern(node.name) || import_typescript11.default.isObjectBindingPattern(node.name)) && node.initializer && import_typescript11.default.isCallExpression(node.initializer) && import_typescript11.default.isIdentifier(node.initializer.expression)) {
|
|
192903
193038
|
candidateCallees.add(node.initializer.expression.text);
|
|
192904
193039
|
}
|
|
192905
|
-
|
|
193040
|
+
import_typescript11.default.forEachChild(node, collectCandidates);
|
|
192906
193041
|
}
|
|
192907
193042
|
collectCandidates(entrySourceFile);
|
|
192908
193043
|
if (candidateCallees.size === 0)
|
|
192909
193044
|
return;
|
|
192910
193045
|
const importsToCheck = [];
|
|
192911
193046
|
for (const stmt of entrySourceFile.statements) {
|
|
192912
|
-
if (!
|
|
193047
|
+
if (!import_typescript11.default.isImportDeclaration(stmt))
|
|
192913
193048
|
continue;
|
|
192914
|
-
if (!
|
|
193049
|
+
if (!import_typescript11.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192915
193050
|
continue;
|
|
192916
193051
|
const src = stmt.moduleSpecifier.text;
|
|
192917
193052
|
if (!src.startsWith("./") && !src.startsWith("../"))
|
|
@@ -192919,7 +193054,7 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192919
193054
|
if (stmt.importClause?.isTypeOnly)
|
|
192920
193055
|
continue;
|
|
192921
193056
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
192922
|
-
if (!namedBindings || !
|
|
193057
|
+
if (!namedBindings || !import_typescript11.default.isNamedImports(namedBindings))
|
|
192923
193058
|
continue;
|
|
192924
193059
|
const specs = [];
|
|
192925
193060
|
for (const el of namedBindings.elements) {
|
|
@@ -192957,14 +193092,14 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192957
193092
|
helperCache.set(abs, "clean");
|
|
192958
193093
|
return "clean";
|
|
192959
193094
|
}
|
|
192960
|
-
const sf =
|
|
193095
|
+
const sf = import_typescript11.default.createSourceFile(abs + ".prescan", content, import_typescript11.default.ScriptTarget.Latest, true, import_typescript11.default.ScriptKind.TSX);
|
|
192961
193096
|
const localFns = new Map;
|
|
192962
193097
|
const exportedFns = new Map;
|
|
192963
193098
|
for (const stmt of sf.statements) {
|
|
192964
|
-
if (
|
|
193099
|
+
if (import_typescript11.default.isFunctionDeclaration(stmt) && stmt.name && stmt.body) {
|
|
192965
193100
|
localFns.set(stmt.name.text, stmt);
|
|
192966
|
-
const hasExportModifier = stmt.modifiers?.some((m) => m.kind ===
|
|
192967
|
-
const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind ===
|
|
193101
|
+
const hasExportModifier = stmt.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.ExportKeyword) ?? false;
|
|
193102
|
+
const hasDefaultModifier = stmt.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.DefaultKeyword) ?? false;
|
|
192968
193103
|
if (hasExportModifier && !hasDefaultModifier) {
|
|
192969
193104
|
exportedFns.set(stmt.name.text, stmt);
|
|
192970
193105
|
}
|
|
@@ -192973,10 +193108,10 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192973
193108
|
const reexports = new Map;
|
|
192974
193109
|
let hasStarReexport = false;
|
|
192975
193110
|
for (const stmt of sf.statements) {
|
|
192976
|
-
if (!
|
|
193111
|
+
if (!import_typescript11.default.isExportDeclaration(stmt) || stmt.isTypeOnly)
|
|
192977
193112
|
continue;
|
|
192978
193113
|
if (!stmt.moduleSpecifier) {
|
|
192979
|
-
if (stmt.exportClause &&
|
|
193114
|
+
if (stmt.exportClause && import_typescript11.default.isNamedExports(stmt.exportClause)) {
|
|
192980
193115
|
for (const el of stmt.exportClause.elements) {
|
|
192981
193116
|
if (el.isTypeOnly)
|
|
192982
193117
|
continue;
|
|
@@ -192987,9 +193122,9 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192987
193122
|
}
|
|
192988
193123
|
continue;
|
|
192989
193124
|
}
|
|
192990
|
-
if (!
|
|
193125
|
+
if (!import_typescript11.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192991
193126
|
continue;
|
|
192992
|
-
if (stmt.exportClause &&
|
|
193127
|
+
if (stmt.exportClause && import_typescript11.default.isNamedExports(stmt.exportClause)) {
|
|
192993
193128
|
for (const el of stmt.exportClause.elements) {
|
|
192994
193129
|
if (el.isTypeOnly)
|
|
192995
193130
|
continue;
|
|
@@ -193139,7 +193274,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
193139
193274
|
const importedTypes = new Map;
|
|
193140
193275
|
const imported = new Map;
|
|
193141
193276
|
for (const stmt of sf.statements) {
|
|
193142
|
-
if (
|
|
193277
|
+
if (import_typescript11.default.isVariableStatement(stmt)) {
|
|
193143
193278
|
const out = [];
|
|
193144
193279
|
for (const decl of stmt.declarationList.declarations) {
|
|
193145
193280
|
addBindingNames(decl.name, out);
|
|
@@ -193148,16 +193283,16 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
193148
193283
|
local.add(n);
|
|
193149
193284
|
continue;
|
|
193150
193285
|
}
|
|
193151
|
-
if ((
|
|
193286
|
+
if ((import_typescript11.default.isFunctionDeclaration(stmt) || import_typescript11.default.isClassDeclaration(stmt) || import_typescript11.default.isEnumDeclaration(stmt)) && stmt.name) {
|
|
193152
193287
|
local.add(stmt.name.text);
|
|
193153
193288
|
continue;
|
|
193154
193289
|
}
|
|
193155
|
-
if ((
|
|
193290
|
+
if ((import_typescript11.default.isTypeAliasDeclaration(stmt) || import_typescript11.default.isInterfaceDeclaration(stmt)) && stmt.name) {
|
|
193156
193291
|
localTypes.add(stmt.name.text);
|
|
193157
193292
|
continue;
|
|
193158
193293
|
}
|
|
193159
|
-
if (
|
|
193160
|
-
if (!
|
|
193294
|
+
if (import_typescript11.default.isImportDeclaration(stmt)) {
|
|
193295
|
+
if (!import_typescript11.default.isStringLiteral(stmt.moduleSpecifier))
|
|
193161
193296
|
continue;
|
|
193162
193297
|
const src = stmt.moduleSpecifier.text;
|
|
193163
193298
|
if (src === "@barefootjs/client" || src === "@barefootjs/client/runtime")
|
|
@@ -193166,7 +193301,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
193166
193301
|
if (stmt.importClause?.name)
|
|
193167
193302
|
(wholeTypeOnly ? localTypes : local).add(stmt.importClause.name.text);
|
|
193168
193303
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
193169
|
-
if (namedBindings &&
|
|
193304
|
+
if (namedBindings && import_typescript11.default.isNamedImports(namedBindings)) {
|
|
193170
193305
|
for (const el of namedBindings.elements) {
|
|
193171
193306
|
const entry = { source: src, exportedName: (el.propertyName ?? el.name).text };
|
|
193172
193307
|
if (wholeTypeOnly || el.isTypeOnly)
|
|
@@ -193175,7 +193310,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
193175
193310
|
imported.set(el.name.text, entry);
|
|
193176
193311
|
}
|
|
193177
193312
|
}
|
|
193178
|
-
if (namedBindings &&
|
|
193313
|
+
if (namedBindings && import_typescript11.default.isNamespaceImport(namedBindings)) {
|
|
193179
193314
|
(wholeTypeOnly ? localTypes : local).add(namedBindings.name.text);
|
|
193180
193315
|
}
|
|
193181
193316
|
}
|
|
@@ -193242,11 +193377,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193242
193377
|
function checkForReactive(n) {
|
|
193243
193378
|
if (hasReactiveCall)
|
|
193244
193379
|
return;
|
|
193245
|
-
if (
|
|
193380
|
+
if (import_typescript11.default.isCallExpression(n) && import_typescript11.default.isIdentifier(n.expression) && REACTIVE_PRIMITIVES.has(n.expression.text)) {
|
|
193246
193381
|
hasReactiveCall = true;
|
|
193247
193382
|
return;
|
|
193248
193383
|
}
|
|
193249
|
-
|
|
193384
|
+
import_typescript11.default.forEachChild(n, checkForReactive);
|
|
193250
193385
|
}
|
|
193251
193386
|
checkForReactive(node.body);
|
|
193252
193387
|
if (!hasReactiveCall)
|
|
@@ -193254,29 +193389,29 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193254
193389
|
const loc = getSourceLocation(node, sourceFile, filePath);
|
|
193255
193390
|
let totalReturnCount = 0;
|
|
193256
193391
|
function countReturns(n) {
|
|
193257
|
-
if (
|
|
193392
|
+
if (import_typescript11.default.isFunctionLike(n))
|
|
193258
193393
|
return;
|
|
193259
|
-
if (
|
|
193394
|
+
if (import_typescript11.default.isReturnStatement(n)) {
|
|
193260
193395
|
totalReturnCount++;
|
|
193261
193396
|
return;
|
|
193262
193397
|
}
|
|
193263
|
-
|
|
193398
|
+
import_typescript11.default.forEachChild(n, countReturns);
|
|
193264
193399
|
}
|
|
193265
|
-
|
|
193400
|
+
import_typescript11.default.forEachChild(node.body, countReturns);
|
|
193266
193401
|
let returnExpr = null;
|
|
193267
193402
|
let returnCount = 0;
|
|
193268
193403
|
for (const stmt of node.body.statements) {
|
|
193269
|
-
if (!
|
|
193404
|
+
if (!import_typescript11.default.isReturnStatement(stmt))
|
|
193270
193405
|
continue;
|
|
193271
193406
|
returnCount++;
|
|
193272
193407
|
if (!stmt.expression)
|
|
193273
193408
|
return { kind: "reactive-shaped" };
|
|
193274
193409
|
let expr = stmt.expression;
|
|
193275
|
-
while (
|
|
193410
|
+
while (import_typescript11.default.isParenthesizedExpression(expr))
|
|
193276
193411
|
expr = expr.expression;
|
|
193277
|
-
if (
|
|
193412
|
+
if (import_typescript11.default.isAsExpression(expr))
|
|
193278
193413
|
expr = expr.expression;
|
|
193279
|
-
if (
|
|
193414
|
+
if (import_typescript11.default.isTypeAssertionExpression(expr))
|
|
193280
193415
|
expr = expr.expression;
|
|
193281
193416
|
returnExpr = expr;
|
|
193282
193417
|
}
|
|
@@ -193284,18 +193419,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193284
193419
|
return { kind: "reactive-shaped" };
|
|
193285
193420
|
const returnTupleIdentifiers = [];
|
|
193286
193421
|
let returnKind;
|
|
193287
|
-
if (
|
|
193422
|
+
if (import_typescript11.default.isArrayLiteralExpression(returnExpr)) {
|
|
193288
193423
|
returnKind = "tuple";
|
|
193289
193424
|
for (const el of returnExpr.elements) {
|
|
193290
|
-
if (!
|
|
193425
|
+
if (!import_typescript11.default.isIdentifier(el))
|
|
193291
193426
|
return { kind: "reactive-shaped" };
|
|
193292
193427
|
returnTupleIdentifiers.push(el.text);
|
|
193293
193428
|
}
|
|
193294
193429
|
if (returnTupleIdentifiers.length === 0)
|
|
193295
193430
|
return { kind: "reactive-shaped" };
|
|
193296
|
-
} else if (
|
|
193431
|
+
} else if (import_typescript11.default.isObjectLiteralExpression(returnExpr)) {
|
|
193297
193432
|
returnKind = "object";
|
|
193298
|
-
const hasNonShorthand = returnExpr.properties.some((p) => !
|
|
193433
|
+
const hasNonShorthand = returnExpr.properties.some((p) => !import_typescript11.default.isShorthandPropertyAssignment(p));
|
|
193299
193434
|
if (hasNonShorthand) {
|
|
193300
193435
|
return {
|
|
193301
193436
|
kind: "declined",
|
|
@@ -193316,7 +193451,7 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193316
193451
|
}
|
|
193317
193452
|
const params = [];
|
|
193318
193453
|
for (const p of node.parameters) {
|
|
193319
|
-
if (
|
|
193454
|
+
if (import_typescript11.default.isIdentifier(p.name)) {
|
|
193320
193455
|
params.push(p.name.text);
|
|
193321
193456
|
continue;
|
|
193322
193457
|
}
|
|
@@ -193324,11 +193459,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193324
193459
|
}
|
|
193325
193460
|
const localBindings = [];
|
|
193326
193461
|
for (const stmt of node.body.statements) {
|
|
193327
|
-
if (
|
|
193462
|
+
if (import_typescript11.default.isVariableStatement(stmt)) {
|
|
193328
193463
|
for (const decl of stmt.declarationList.declarations) {
|
|
193329
193464
|
addBindingNames(decl.name, localBindings);
|
|
193330
193465
|
}
|
|
193331
|
-
} else if (
|
|
193466
|
+
} else if (import_typescript11.default.isFunctionDeclaration(stmt) && stmt.name) {
|
|
193332
193467
|
localBindings.push(stmt.name.text);
|
|
193333
193468
|
}
|
|
193334
193469
|
}
|
|
@@ -193348,47 +193483,47 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193348
193483
|
if (!relevantNames.has(id.text))
|
|
193349
193484
|
return;
|
|
193350
193485
|
const p = id.parent;
|
|
193351
|
-
if (
|
|
193486
|
+
if (import_typescript11.default.isPropertyAccessExpression(p) && p.name === id)
|
|
193352
193487
|
return;
|
|
193353
|
-
if (
|
|
193488
|
+
if (import_typescript11.default.isPropertyAssignment(p) && p.name === id)
|
|
193354
193489
|
return;
|
|
193355
|
-
if (
|
|
193490
|
+
if (import_typescript11.default.isBindingElement(p) && p.propertyName === id)
|
|
193356
193491
|
return;
|
|
193357
|
-
if ((
|
|
193492
|
+
if ((import_typescript11.default.isMethodDeclaration(p) || import_typescript11.default.isGetAccessorDeclaration(p) || import_typescript11.default.isSetAccessorDeclaration(p) || import_typescript11.default.isPropertyDeclaration(p) || import_typescript11.default.isEnumMember(p)) && p.name === id)
|
|
193358
193493
|
return;
|
|
193359
|
-
if (
|
|
193494
|
+
if (import_typescript11.default.isJsxAttribute(p) && p.name === id)
|
|
193360
193495
|
return;
|
|
193361
|
-
if (
|
|
193496
|
+
if (import_typescript11.default.isLabeledStatement(p) && p.label === id || (import_typescript11.default.isBreakStatement(p) || import_typescript11.default.isContinueStatement(p)) && p.label === id)
|
|
193362
193497
|
return;
|
|
193363
|
-
if ((
|
|
193498
|
+
if ((import_typescript11.default.isJsxOpeningElement(p) || import_typescript11.default.isJsxSelfClosingElement(p) || import_typescript11.default.isJsxClosingElement(p)) && p.tagName === id && /^[a-z]/.test(id.text))
|
|
193364
193499
|
return;
|
|
193365
|
-
if (
|
|
193500
|
+
if (import_typescript11.default.isShorthandPropertyAssignment(p) && p.name === id) {
|
|
193366
193501
|
push(id, "shorthand");
|
|
193367
193502
|
return;
|
|
193368
193503
|
}
|
|
193369
|
-
if (
|
|
193504
|
+
if (import_typescript11.default.isBindingElement(p) && p.name === id && !p.propertyName && import_typescript11.default.isObjectBindingPattern(p.parent)) {
|
|
193370
193505
|
if (params.includes(id.text))
|
|
193371
193506
|
shadowedParam = id.text;
|
|
193372
193507
|
push(id, "shorthand");
|
|
193373
193508
|
return;
|
|
193374
193509
|
}
|
|
193375
|
-
const isDecl = (
|
|
193510
|
+
const isDecl = (import_typescript11.default.isVariableDeclaration(p) || import_typescript11.default.isParameter(p) || import_typescript11.default.isBindingElement(p) || import_typescript11.default.isFunctionDeclaration(p) || import_typescript11.default.isFunctionExpression(p) || import_typescript11.default.isClassDeclaration(p) || import_typescript11.default.isClassExpression(p)) && p.name === id;
|
|
193376
193511
|
if (isDecl && params.includes(id.text))
|
|
193377
193512
|
shadowedParam = id.text;
|
|
193378
193513
|
push(id, "plain");
|
|
193379
193514
|
}
|
|
193380
193515
|
function visit2(n) {
|
|
193381
|
-
if (
|
|
193516
|
+
if (import_typescript11.default.isTypeNode(n) || import_typescript11.default.isTypeParameterDeclaration(n) || import_typescript11.default.isTypeAliasDeclaration(n) || import_typescript11.default.isInterfaceDeclaration(n))
|
|
193382
193517
|
return;
|
|
193383
|
-
if (
|
|
193518
|
+
if (import_typescript11.default.isIdentifier(n)) {
|
|
193384
193519
|
classify(n);
|
|
193385
193520
|
return;
|
|
193386
193521
|
}
|
|
193387
|
-
|
|
193522
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
193388
193523
|
}
|
|
193389
193524
|
visit2(root);
|
|
193390
193525
|
}
|
|
193391
|
-
const keptStatements = node.body.statements.filter((s) => !
|
|
193526
|
+
const keptStatements = node.body.statements.filter((s) => !import_typescript11.default.isReturnStatement(s));
|
|
193392
193527
|
const pieces = [];
|
|
193393
193528
|
let base = 0;
|
|
193394
193529
|
for (const stmt of keptStatements) {
|
|
@@ -193436,18 +193571,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193436
193571
|
};
|
|
193437
193572
|
}
|
|
193438
193573
|
function addBindingNames(name, out) {
|
|
193439
|
-
if (
|
|
193574
|
+
if (import_typescript11.default.isIdentifier(name)) {
|
|
193440
193575
|
out.push(name.text);
|
|
193441
193576
|
return;
|
|
193442
193577
|
}
|
|
193443
|
-
if (
|
|
193578
|
+
if (import_typescript11.default.isObjectBindingPattern(name)) {
|
|
193444
193579
|
for (const el of name.elements)
|
|
193445
193580
|
addBindingNames(el.name, out);
|
|
193446
193581
|
return;
|
|
193447
193582
|
}
|
|
193448
|
-
if (
|
|
193583
|
+
if (import_typescript11.default.isArrayBindingPattern(name)) {
|
|
193449
193584
|
for (const el of name.elements) {
|
|
193450
|
-
if (
|
|
193585
|
+
if (import_typescript11.default.isOmittedExpression(el))
|
|
193451
193586
|
continue;
|
|
193452
193587
|
addBindingNames(el.name, out);
|
|
193453
193588
|
}
|
|
@@ -193459,33 +193594,33 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193459
193594
|
let callSiteIndex = 0;
|
|
193460
193595
|
const inlinedFactories = new Set;
|
|
193461
193596
|
function visitStmt(node, inComponent) {
|
|
193462
|
-
if (
|
|
193597
|
+
if (import_typescript11.default.isVariableStatement(node) && inComponent) {
|
|
193463
193598
|
for (const decl of node.declarationList.declarations) {
|
|
193464
193599
|
maybeRewriteDecl(node, decl);
|
|
193465
193600
|
}
|
|
193466
193601
|
}
|
|
193467
|
-
|
|
193468
|
-
if (
|
|
193602
|
+
import_typescript11.default.forEachChild(node, (child) => {
|
|
193603
|
+
if (import_typescript11.default.isFunctionDeclaration(child) && child.name && factories.has(child.name.text))
|
|
193469
193604
|
return;
|
|
193470
193605
|
visitStmt(child, inComponent || isPascalCaseComponentFn(child));
|
|
193471
193606
|
});
|
|
193472
193607
|
}
|
|
193473
193608
|
function maybeRewriteDecl(stmt, decl) {
|
|
193474
|
-
if (!decl.initializer || !
|
|
193609
|
+
if (!decl.initializer || !import_typescript11.default.isCallExpression(decl.initializer))
|
|
193475
193610
|
return;
|
|
193476
|
-
if (!
|
|
193611
|
+
if (!import_typescript11.default.isIdentifier(decl.initializer.expression))
|
|
193477
193612
|
return;
|
|
193478
193613
|
const factoryName = decl.initializer.expression.text;
|
|
193479
193614
|
const factory = factories.get(factoryName);
|
|
193480
193615
|
if (!factory)
|
|
193481
193616
|
return;
|
|
193482
|
-
if (
|
|
193617
|
+
if (import_typescript11.default.isArrayBindingPattern(decl.name)) {
|
|
193483
193618
|
if (factory.returnKind !== "tuple")
|
|
193484
193619
|
return;
|
|
193485
193620
|
rewriteTupleDecl(stmt, decl.name, decl.initializer, factory);
|
|
193486
193621
|
return;
|
|
193487
193622
|
}
|
|
193488
|
-
if (
|
|
193623
|
+
if (import_typescript11.default.isObjectBindingPattern(decl.name)) {
|
|
193489
193624
|
if (factory.returnKind !== "object")
|
|
193490
193625
|
return;
|
|
193491
193626
|
rewriteObjectDecl(stmt, decl.name, decl.initializer, factory);
|
|
@@ -193498,7 +193633,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193498
193633
|
return;
|
|
193499
193634
|
const callerNames = [];
|
|
193500
193635
|
for (const el of elements) {
|
|
193501
|
-
if (
|
|
193636
|
+
if (import_typescript11.default.isOmittedExpression(el) || !import_typescript11.default.isIdentifier(el.name))
|
|
193502
193637
|
return;
|
|
193503
193638
|
callerNames.push(el.name.text);
|
|
193504
193639
|
}
|
|
@@ -193520,7 +193655,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193520
193655
|
return;
|
|
193521
193656
|
if (el.initializer)
|
|
193522
193657
|
return;
|
|
193523
|
-
if (!
|
|
193658
|
+
if (!import_typescript11.default.isIdentifier(el.name))
|
|
193524
193659
|
return;
|
|
193525
193660
|
if (!factory.returnTupleIdentifiers.includes(el.name.text))
|
|
193526
193661
|
return;
|
|
@@ -193629,21 +193764,21 @@ function factoryImportInsertionOffset(sf) {
|
|
|
193629
193764
|
let lastImportEnd = -1;
|
|
193630
193765
|
let directiveEnd = -1;
|
|
193631
193766
|
for (const stmt of sf.statements) {
|
|
193632
|
-
if (
|
|
193767
|
+
if (import_typescript11.default.isImportDeclaration(stmt)) {
|
|
193633
193768
|
lastImportEnd = stmt.getEnd();
|
|
193634
193769
|
continue;
|
|
193635
193770
|
}
|
|
193636
|
-
if (directiveEnd === -1 &&
|
|
193771
|
+
if (directiveEnd === -1 && import_typescript11.default.isExpressionStatement(stmt) && import_typescript11.default.isStringLiteral(stmt.expression) && stmt.expression.text === "use client") {
|
|
193637
193772
|
directiveEnd = stmt.getEnd();
|
|
193638
193773
|
}
|
|
193639
193774
|
}
|
|
193640
193775
|
return lastImportEnd >= 0 ? lastImportEnd : directiveEnd >= 0 ? directiveEnd : 0;
|
|
193641
193776
|
}
|
|
193642
193777
|
function isPascalCaseComponentFn(node) {
|
|
193643
|
-
if (
|
|
193778
|
+
if (import_typescript11.default.isFunctionDeclaration(node) && node.name) {
|
|
193644
193779
|
return /^[A-Z]/.test(node.name.text);
|
|
193645
193780
|
}
|
|
193646
|
-
if (
|
|
193781
|
+
if (import_typescript11.default.isVariableDeclaration(node) && import_typescript11.default.isIdentifier(node.name) && node.initializer && import_typescript11.default.isArrowFunction(node.initializer)) {
|
|
193647
193782
|
return /^[A-Z]/.test(node.name.text);
|
|
193648
193783
|
}
|
|
193649
193784
|
return false;
|
|
@@ -193672,20 +193807,20 @@ function declinedFactoryErrorCode(code2) {
|
|
|
193672
193807
|
function validateReactiveFactoryCalls(ctx) {
|
|
193673
193808
|
if (!ctx.componentNode)
|
|
193674
193809
|
return;
|
|
193675
|
-
const body =
|
|
193810
|
+
const body = import_typescript11.default.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : import_typescript11.default.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
|
|
193676
193811
|
if (!body)
|
|
193677
193812
|
return;
|
|
193678
193813
|
for (const stmt of body.statements) {
|
|
193679
|
-
if (!
|
|
193814
|
+
if (!import_typescript11.default.isVariableStatement(stmt))
|
|
193680
193815
|
continue;
|
|
193681
193816
|
for (const decl of stmt.declarationList.declarations) {
|
|
193682
|
-
if (!decl.initializer || !
|
|
193817
|
+
if (!decl.initializer || !import_typescript11.default.isCallExpression(decl.initializer))
|
|
193683
193818
|
continue;
|
|
193684
|
-
if (!
|
|
193819
|
+
if (!import_typescript11.default.isIdentifier(decl.initializer.expression))
|
|
193685
193820
|
continue;
|
|
193686
193821
|
const callee = decl.initializer.expression.text;
|
|
193687
193822
|
const loc = getSourceLocation(stmt, ctx.sourceFile, ctx.filePath);
|
|
193688
|
-
if (
|
|
193823
|
+
if (import_typescript11.default.isArrayBindingPattern(decl.name)) {
|
|
193689
193824
|
if (callee === "createSignal" || callee === "createMemo")
|
|
193690
193825
|
continue;
|
|
193691
193826
|
if (resolveEnvSignalKey(decl.initializer, ctx))
|
|
@@ -193712,7 +193847,7 @@ function validateReactiveFactoryCalls(ctx) {
|
|
|
193712
193847
|
}));
|
|
193713
193848
|
continue;
|
|
193714
193849
|
}
|
|
193715
|
-
if (
|
|
193850
|
+
if (import_typescript11.default.isObjectBindingPattern(decl.name)) {
|
|
193716
193851
|
validateObjectFactoryDestructure(ctx, decl.name, callee, loc);
|
|
193717
193852
|
}
|
|
193718
193853
|
}
|
|
@@ -193721,25 +193856,25 @@ function validateReactiveFactoryCalls(ctx) {
|
|
|
193721
193856
|
function validateNamespaceQualifiedPrimitives(ctx) {
|
|
193722
193857
|
if (!ctx.componentNode)
|
|
193723
193858
|
return;
|
|
193724
|
-
const body =
|
|
193859
|
+
const body = import_typescript11.default.isFunctionDeclaration(ctx.componentNode) ? ctx.componentNode.body : import_typescript11.default.isBlock(ctx.componentNode.body) ? ctx.componentNode.body : null;
|
|
193725
193860
|
if (!body)
|
|
193726
193861
|
return;
|
|
193727
193862
|
for (const stmt of body.statements) {
|
|
193728
193863
|
const calls = [];
|
|
193729
|
-
if (
|
|
193864
|
+
if (import_typescript11.default.isVariableStatement(stmt)) {
|
|
193730
193865
|
for (const decl of stmt.declarationList.declarations) {
|
|
193731
193866
|
let init = decl.initializer;
|
|
193732
|
-
if (init &&
|
|
193867
|
+
if (init && import_typescript11.default.isElementAccessExpression(init))
|
|
193733
193868
|
init = init.expression;
|
|
193734
|
-
if (init &&
|
|
193869
|
+
if (init && import_typescript11.default.isCallExpression(init))
|
|
193735
193870
|
calls.push(init);
|
|
193736
193871
|
}
|
|
193737
|
-
} else if (
|
|
193872
|
+
} else if (import_typescript11.default.isExpressionStatement(stmt) && import_typescript11.default.isCallExpression(stmt.expression)) {
|
|
193738
193873
|
calls.push(stmt.expression);
|
|
193739
193874
|
}
|
|
193740
193875
|
for (const call of calls) {
|
|
193741
193876
|
const callee = call.expression;
|
|
193742
|
-
if (!
|
|
193877
|
+
if (!import_typescript11.default.isPropertyAccessExpression(callee) || !import_typescript11.default.isIdentifier(callee.expression))
|
|
193743
193878
|
continue;
|
|
193744
193879
|
const primitive = callee.name.text;
|
|
193745
193880
|
if (!(primitive in PRIMITIVE_CANONICAL_NAMES))
|
|
@@ -193772,11 +193907,11 @@ function isNamespaceNameShadowedAtComponentTopLevel(name, body, ctx) {
|
|
|
193772
193907
|
if (ctx.propsParams.some((p) => p.name === name))
|
|
193773
193908
|
return true;
|
|
193774
193909
|
for (const stmt of body.statements) {
|
|
193775
|
-
if (
|
|
193910
|
+
if (import_typescript11.default.isFunctionDeclaration(stmt) && stmt.name?.text === name)
|
|
193776
193911
|
return true;
|
|
193777
|
-
if (
|
|
193912
|
+
if (import_typescript11.default.isVariableStatement(stmt)) {
|
|
193778
193913
|
for (const decl of stmt.declarationList.declarations) {
|
|
193779
|
-
if (
|
|
193914
|
+
if (import_typescript11.default.isIdentifier(decl.name) && decl.name.text === name)
|
|
193780
193915
|
return true;
|
|
193781
193916
|
}
|
|
193782
193917
|
}
|
|
@@ -193793,7 +193928,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
193793
193928
|
}));
|
|
193794
193929
|
return;
|
|
193795
193930
|
}
|
|
193796
|
-
const hasUnsupportedElement = pattern.elements.some((el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !
|
|
193931
|
+
const hasUnsupportedElement = pattern.elements.some((el) => !!el.propertyName || !!el.initializer || !!el.dotDotDotToken || !import_typescript11.default.isIdentifier(el.name));
|
|
193797
193932
|
if (hasUnsupportedElement) {
|
|
193798
193933
|
ctx.errors.push(createError(ErrorCodes.REACTIVE_FACTORY_RENAME_UNSUPPORTED, loc, {
|
|
193799
193934
|
severity: "error",
|
|
@@ -193801,7 +193936,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
193801
193936
|
}));
|
|
193802
193937
|
return;
|
|
193803
193938
|
}
|
|
193804
|
-
const unknown = pattern.elements.map((el) =>
|
|
193939
|
+
const unknown = pattern.elements.map((el) => import_typescript11.default.isIdentifier(el.name) ? el.name.text : "").filter((name) => name && !factory.returnTupleIdentifiers.includes(name));
|
|
193805
193940
|
if (unknown.length > 0) {
|
|
193806
193941
|
const label = unknown.length === 1 ? "property" : "properties";
|
|
193807
193942
|
ctx.errors.push(createError(ErrorCodes.UNRECOGNIZED_REACTIVE_FACTORY, loc, {
|
|
@@ -193921,7 +194056,7 @@ var AttrValueOf = {
|
|
|
193921
194056
|
};
|
|
193922
194057
|
|
|
193923
194058
|
// ../jsx/src/module-exports.ts
|
|
193924
|
-
var
|
|
194059
|
+
var import_typescript12 = __toESM(require_typescript(), 1);
|
|
193925
194060
|
function formatParamWithType(p) {
|
|
193926
194061
|
const rest = p.isRest ? "..." : "";
|
|
193927
194062
|
const optional = p.optional ? "?" : "";
|
|
@@ -193956,21 +194091,21 @@ function findAssignedNames(bodyText, candidates) {
|
|
|
193956
194091
|
const assigned = new Set;
|
|
193957
194092
|
if (candidates.size === 0)
|
|
193958
194093
|
return assigned;
|
|
193959
|
-
const sf =
|
|
194094
|
+
const sf = import_typescript12.default.createSourceFile("bf-assignment-scan.tsx", bodyText, import_typescript12.default.ScriptTarget.Latest, false, import_typescript12.default.ScriptKind.TSX);
|
|
193960
194095
|
const record = (target) => {
|
|
193961
|
-
if (
|
|
194096
|
+
if (import_typescript12.default.isIdentifier(target) && candidates.has(target.text)) {
|
|
193962
194097
|
assigned.add(target.text);
|
|
193963
194098
|
}
|
|
193964
194099
|
};
|
|
193965
194100
|
const visit2 = (node) => {
|
|
193966
|
-
if (
|
|
194101
|
+
if (import_typescript12.default.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
|
|
193967
194102
|
record(node.left);
|
|
193968
|
-
} else if ((
|
|
194103
|
+
} else if ((import_typescript12.default.isPrefixUnaryExpression(node) || import_typescript12.default.isPostfixUnaryExpression(node)) && (node.operator === import_typescript12.default.SyntaxKind.PlusPlusToken || node.operator === import_typescript12.default.SyntaxKind.MinusMinusToken)) {
|
|
193969
194104
|
record(node.operand);
|
|
193970
194105
|
}
|
|
193971
|
-
|
|
194106
|
+
import_typescript12.default.forEachChild(node, visit2);
|
|
193972
194107
|
};
|
|
193973
|
-
|
|
194108
|
+
import_typescript12.default.forEachChild(sf, visit2);
|
|
193974
194109
|
return assigned;
|
|
193975
194110
|
}
|
|
193976
194111
|
function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
|
|
@@ -193993,7 +194128,7 @@ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNam
|
|
|
193993
194128
|
return reachable;
|
|
193994
194129
|
}
|
|
193995
194130
|
function isAssignmentOperator(kind) {
|
|
193996
|
-
return kind >=
|
|
194131
|
+
return kind >= import_typescript12.default.SyntaxKind.FirstAssignment && kind <= import_typescript12.default.SyntaxKind.LastAssignment;
|
|
193997
194132
|
}
|
|
193998
194133
|
|
|
193999
194134
|
// ../jsx/src/builtins.ts
|
|
@@ -194002,102 +194137,6 @@ function isClientBuiltinName(name) {
|
|
|
194002
194137
|
return name === "Async" || name === "Region";
|
|
194003
194138
|
}
|
|
194004
194139
|
|
|
194005
|
-
// ../jsx/src/reactivity-checker.ts
|
|
194006
|
-
var import_typescript12 = __toESM(require_typescript(), 1);
|
|
194007
|
-
var REACTIVE_BRAND = "__reactive";
|
|
194008
|
-
function queryType(checker, node) {
|
|
194009
|
-
incrementCounter("typeCheckerQueries");
|
|
194010
|
-
return checker.getTypeAtLocation(node);
|
|
194011
|
-
}
|
|
194012
|
-
function isReactiveType(type2) {
|
|
194013
|
-
return type2.getProperty(REACTIVE_BRAND) !== undefined;
|
|
194014
|
-
}
|
|
194015
|
-
var NOT_REACTIVE = { isReactive: false, reason: { kind: "not-reactive" } };
|
|
194016
|
-
function safeGetText(node) {
|
|
194017
|
-
try {
|
|
194018
|
-
return node.getText();
|
|
194019
|
-
} catch {
|
|
194020
|
-
return "";
|
|
194021
|
-
}
|
|
194022
|
-
}
|
|
194023
|
-
function analyze(node, checker) {
|
|
194024
|
-
if (import_typescript12.default.isPropertyAccessExpression(node)) {
|
|
194025
|
-
try {
|
|
194026
|
-
const type2 = queryType(checker, node);
|
|
194027
|
-
if (isReactiveType(type2)) {
|
|
194028
|
-
return {
|
|
194029
|
-
isReactive: true,
|
|
194030
|
-
reason: { kind: "brand", via: "property-access", nodeText: safeGetText(node) }
|
|
194031
|
-
};
|
|
194032
|
-
}
|
|
194033
|
-
} catch {}
|
|
194034
|
-
const sub = analyze(node.expression, checker);
|
|
194035
|
-
if (sub.isReactive) {
|
|
194036
|
-
return {
|
|
194037
|
-
isReactive: true,
|
|
194038
|
-
reason: {
|
|
194039
|
-
kind: "child",
|
|
194040
|
-
via: "property-access-object",
|
|
194041
|
-
childText: safeGetText(node.expression),
|
|
194042
|
-
childReason: sub.reason
|
|
194043
|
-
}
|
|
194044
|
-
};
|
|
194045
|
-
}
|
|
194046
|
-
return NOT_REACTIVE;
|
|
194047
|
-
}
|
|
194048
|
-
if (import_typescript12.default.isIdentifier(node)) {
|
|
194049
|
-
try {
|
|
194050
|
-
const type2 = queryType(checker, node);
|
|
194051
|
-
if (isReactiveType(type2)) {
|
|
194052
|
-
return {
|
|
194053
|
-
isReactive: true,
|
|
194054
|
-
reason: { kind: "brand", via: "identifier", nodeText: safeGetText(node) }
|
|
194055
|
-
};
|
|
194056
|
-
}
|
|
194057
|
-
} catch {}
|
|
194058
|
-
return NOT_REACTIVE;
|
|
194059
|
-
}
|
|
194060
|
-
if (import_typescript12.default.isCallExpression(node)) {
|
|
194061
|
-
try {
|
|
194062
|
-
const calleeType = queryType(checker, node.expression);
|
|
194063
|
-
if (isReactiveType(calleeType)) {
|
|
194064
|
-
return {
|
|
194065
|
-
isReactive: true,
|
|
194066
|
-
reason: { kind: "brand", via: "callee", nodeText: safeGetText(node) }
|
|
194067
|
-
};
|
|
194068
|
-
}
|
|
194069
|
-
} catch {}
|
|
194070
|
-
}
|
|
194071
|
-
let foundChild;
|
|
194072
|
-
let foundChildText = "";
|
|
194073
|
-
import_typescript12.default.forEachChild(node, (child) => {
|
|
194074
|
-
if (foundChild?.isReactive)
|
|
194075
|
-
return;
|
|
194076
|
-
const result = analyze(child, checker);
|
|
194077
|
-
if (result.isReactive) {
|
|
194078
|
-
foundChild = result;
|
|
194079
|
-
foundChildText = safeGetText(child);
|
|
194080
|
-
}
|
|
194081
|
-
});
|
|
194082
|
-
if (foundChild?.isReactive) {
|
|
194083
|
-
return {
|
|
194084
|
-
isReactive: true,
|
|
194085
|
-
reason: {
|
|
194086
|
-
kind: "child",
|
|
194087
|
-
via: "sub-expression",
|
|
194088
|
-
childText: foundChildText,
|
|
194089
|
-
childReason: foundChild.reason
|
|
194090
|
-
}
|
|
194091
|
-
};
|
|
194092
|
-
}
|
|
194093
|
-
return NOT_REACTIVE;
|
|
194094
|
-
}
|
|
194095
|
-
var brandTypeReactivityAnalyzer = { analyze };
|
|
194096
|
-
function containsReactiveExpression(node, checker) {
|
|
194097
|
-
incrementCounter("reactivityChecks");
|
|
194098
|
-
return brandTypeReactivityAnalyzer.analyze(node, checker).isReactive;
|
|
194099
|
-
}
|
|
194100
|
-
|
|
194101
194140
|
// ../jsx/src/free-refs.ts
|
|
194102
194141
|
var import_typescript13 = __toESM(require_typescript(), 1);
|
|
194103
194142
|
var _bindingMapCache = new WeakMap;
|
|
@@ -194841,9 +194880,8 @@ function collectBranchLocalPropRefsViaSubstitution(node, ctx) {
|
|
|
194841
194880
|
function visit2(n, parent) {
|
|
194842
194881
|
if (import_typescript14.default.isIdentifier(n) && propDepsMap.has(n.text)) {
|
|
194843
194882
|
const isObjectKey = parent && import_typescript14.default.isPropertyAssignment(parent) && parent.name === n;
|
|
194844
|
-
const isShorthand = parent && import_typescript14.default.isShorthandPropertyAssignment(parent) && parent.name === n;
|
|
194845
194883
|
const isAccessName = parent && import_typescript14.default.isPropertyAccessExpression(parent) && parent.name === n;
|
|
194846
|
-
if (!isObjectKey && !
|
|
194884
|
+
if (!isObjectKey && !isAccessName) {
|
|
194847
194885
|
const deps = propDepsMap.get(n.text);
|
|
194848
194886
|
if (deps && deps.size > 0) {
|
|
194849
194887
|
if (!acc)
|
|
@@ -195321,8 +195359,7 @@ function lowerFormControlValueSsr(tagName, attrs, children) {
|
|
|
195321
195359
|
children.push({
|
|
195322
195360
|
type: "expression",
|
|
195323
195361
|
expr,
|
|
195324
|
-
templateExpr
|
|
195325
|
-
escapeInClientTemplate: true,
|
|
195362
|
+
templateExpr,
|
|
195326
195363
|
typeInfo: null,
|
|
195327
195364
|
reactive: false,
|
|
195328
195365
|
slotId: null,
|
|
@@ -195333,26 +195370,76 @@ function lowerFormControlValueSsr(tagName, attrs, children) {
|
|
|
195333
195370
|
}
|
|
195334
195371
|
const selectedForLiteral = (optValue) => AttrValueOf.expression(`(${expr}) === ${JSON.stringify(optValue)}`, templateExpr !== undefined ? { templateExpr: `(${templateExpr}) === ${JSON.stringify(optValue)}` } : undefined);
|
|
195335
195372
|
const selectedForExpr = (optExpr, optTemplateExpr) => AttrValueOf.expression(`(${expr}) === (${optExpr})`, templateExpr !== undefined || optTemplateExpr !== undefined ? { templateExpr: `(${templateExpr ?? expr}) === (${optTemplateExpr ?? optExpr})` } : undefined);
|
|
195373
|
+
const matchConditions = [];
|
|
195374
|
+
let optionSetIsDynamic = false;
|
|
195336
195375
|
const distribute = (nodes) => {
|
|
195337
195376
|
for (const n of nodes) {
|
|
195377
|
+
if (n.type === "text")
|
|
195378
|
+
continue;
|
|
195338
195379
|
if (n.type === "element" && n.tag === "option") {
|
|
195339
|
-
if (n.attrs.some((a) => a.name === "selected"))
|
|
195380
|
+
if (n.attrs.some((a) => a.name === "selected")) {
|
|
195381
|
+
optionSetIsDynamic = true;
|
|
195340
195382
|
continue;
|
|
195383
|
+
}
|
|
195341
195384
|
const optValue = n.attrs.find((a) => a.name === "value");
|
|
195342
|
-
if (!optValue)
|
|
195385
|
+
if (!optValue) {
|
|
195386
|
+
optionSetIsDynamic = true;
|
|
195343
195387
|
continue;
|
|
195388
|
+
}
|
|
195344
195389
|
if (optValue.value.kind === "literal") {
|
|
195345
|
-
|
|
195390
|
+
const selected = selectedForLiteral(optValue.value.value);
|
|
195391
|
+
n.attrs.push({ name: "selected", value: selected, loc: n.loc });
|
|
195392
|
+
matchConditions.push(selected);
|
|
195346
195393
|
} else if (optValue.value.kind === "expression") {
|
|
195347
195394
|
const selected = selectedForExpr(optValue.value.expr, optValue.value.templateExpr);
|
|
195348
195395
|
n.attrs.push({ name: "selected", value: selected, loc: n.loc });
|
|
195396
|
+
matchConditions.push(selected);
|
|
195397
|
+
} else {
|
|
195398
|
+
optionSetIsDynamic = true;
|
|
195349
195399
|
}
|
|
195350
|
-
} else if (n.type === "fragment" || n.type === "
|
|
195400
|
+
} else if (n.type === "fragment" || n.type === "element" && n.tag === "optgroup") {
|
|
195351
195401
|
distribute(n.children);
|
|
195402
|
+
} else if (n.type === "loop") {
|
|
195403
|
+
optionSetIsDynamic = true;
|
|
195404
|
+
distribute(n.children);
|
|
195405
|
+
} else {
|
|
195406
|
+
optionSetIsDynamic = true;
|
|
195352
195407
|
}
|
|
195353
195408
|
}
|
|
195354
195409
|
};
|
|
195355
195410
|
distribute(children);
|
|
195411
|
+
if (optionSetIsDynamic || matchConditions.length === 0)
|
|
195412
|
+
return;
|
|
195413
|
+
if (isMultiSelection(attrs))
|
|
195414
|
+
return;
|
|
195415
|
+
const orExpr = matchConditions.map((c) => `(${c.expr})`).join(" || ");
|
|
195416
|
+
const orTemplateExpr = matchConditions.some((c) => c.templateExpr !== undefined) ? matchConditions.map((c) => `(${c.templateExpr ?? c.expr})`).join(" || ") : undefined;
|
|
195417
|
+
children.unshift({
|
|
195418
|
+
type: "element",
|
|
195419
|
+
tag: "option",
|
|
195420
|
+
attrs: [
|
|
195421
|
+
{ name: "value", value: AttrValueOf.literal(""), loc: valueAttr.loc },
|
|
195422
|
+
{ name: "disabled", value: AttrValueOf.booleanAttr(), loc: valueAttr.loc },
|
|
195423
|
+
{ name: "hidden", value: AttrValueOf.booleanAttr(), loc: valueAttr.loc },
|
|
195424
|
+
{
|
|
195425
|
+
name: "selected",
|
|
195426
|
+
value: AttrValueOf.expression(`!(${orExpr})`, orTemplateExpr !== undefined ? { templateExpr: `!(${orTemplateExpr})` } : undefined),
|
|
195427
|
+
loc: valueAttr.loc
|
|
195428
|
+
}
|
|
195429
|
+
],
|
|
195430
|
+
events: [],
|
|
195431
|
+
ref: null,
|
|
195432
|
+
children: [],
|
|
195433
|
+
slotId: null,
|
|
195434
|
+
needsScope: false,
|
|
195435
|
+
loc: valueAttr.loc
|
|
195436
|
+
});
|
|
195437
|
+
}
|
|
195438
|
+
function isMultiSelection(attrs) {
|
|
195439
|
+
if (attrs.some((a) => a.name === "multiple"))
|
|
195440
|
+
return true;
|
|
195441
|
+
const sizeAttr = attrs.find((a) => a.name === "size");
|
|
195442
|
+
return sizeAttr?.value.kind === "literal" && Number(sizeAttr.value.value) > 1;
|
|
195356
195443
|
}
|
|
195357
195444
|
function transformHtmlElement(node, ctx, tagName) {
|
|
195358
195445
|
const { attrs, events, ref } = processAttributes(node.openingElement.attributes, ctx);
|
|
@@ -195726,7 +195813,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
|
|
|
195726
195813
|
}
|
|
195727
195814
|
const ir = transformJsxExpression(expr, ctx, isClientOnly);
|
|
195728
195815
|
if (ir !== null) {
|
|
195729
|
-
if ((isClientOnly || shouldAutoDeferReactiveBrand(expr, ctx))
|
|
195816
|
+
if (ir.type === "conditional" && (isClientOnly || shouldAutoDeferReactiveBrand(expr, ctx))) {
|
|
195730
195817
|
ir.clientOnly = true;
|
|
195731
195818
|
if (!ir.slotId) {
|
|
195732
195819
|
ir.slotId = generateSlotId(ctx);
|
|
@@ -198673,9 +198760,10 @@ function shouldAutoDeferReactiveBrand(expr, ctx) {
|
|
|
198673
198760
|
const checker = ctx.analyzer.checker;
|
|
198674
198761
|
if (!checker)
|
|
198675
198762
|
return false;
|
|
198676
|
-
|
|
198763
|
+
const leaves = collectReactiveBrandLeaves(expr, checker);
|
|
198764
|
+
if (leaves.length === 0)
|
|
198677
198765
|
return false;
|
|
198678
|
-
if (isSignalOrMemoReference(ctx.getJS(
|
|
198766
|
+
if (leaves.some((leaf) => isSignalOrMemoReference(ctx.getJS(leaf), ctx)))
|
|
198679
198767
|
return false;
|
|
198680
198768
|
return true;
|
|
198681
198769
|
}
|