@barefootjs/test 0.35.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 +550 -516
- 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);
|
|
@@ -189721,7 +189721,7 @@ function incrementCounter(key) {
|
|
|
189721
189721
|
}
|
|
189722
189722
|
|
|
189723
189723
|
// ../jsx/src/analyzer-context.ts
|
|
189724
|
-
var
|
|
189724
|
+
var import_typescript10 = __toESM(require_typescript(), 1);
|
|
189725
189725
|
|
|
189726
189726
|
// ../jsx/src/strip-types.ts
|
|
189727
189727
|
var import_typescript8 = __toESM(require_typescript(), 1);
|
|
@@ -189938,6 +189938,140 @@ function findAngleBracketAfter(lastTypeArg, fullText) {
|
|
|
189938
189938
|
return -1;
|
|
189939
189939
|
}
|
|
189940
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
|
+
|
|
189941
190075
|
// ../jsx/src/analyzer-context.ts
|
|
189942
190076
|
function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
|
|
189943
190077
|
return {
|
|
@@ -189989,7 +190123,7 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
|
|
|
189989
190123
|
} catch {
|
|
189990
190124
|
ownSourceFile = undefined;
|
|
189991
190125
|
}
|
|
189992
|
-
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)) {
|
|
189993
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.");
|
|
189994
190128
|
}
|
|
189995
190129
|
if (ownSourceFile && ownSourceFile !== sourceFile) {
|
|
@@ -189999,11 +190133,6 @@ function createAnalyzerContext(sourceFile, filePath, acceptsCallbackBody) {
|
|
|
189999
190133
|
}
|
|
190000
190134
|
};
|
|
190001
190135
|
}
|
|
190002
|
-
function nodeContainsJsx(node) {
|
|
190003
|
-
if (import_typescript9.default.isJsxElement(node) || import_typescript9.default.isJsxSelfClosingElement(node) || import_typescript9.default.isJsxFragment(node))
|
|
190004
|
-
return true;
|
|
190005
|
-
return import_typescript9.default.forEachChild(node, nodeContainsJsx) ?? false;
|
|
190006
|
-
}
|
|
190007
190136
|
function getSourceLocation(node, sourceFile, filePath) {
|
|
190008
190137
|
const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
190009
190138
|
const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());
|
|
@@ -190020,20 +190149,20 @@ function getSourceLocation(node, sourceFile, filePath) {
|
|
|
190020
190149
|
};
|
|
190021
190150
|
}
|
|
190022
190151
|
function membersToProperties(members, sourceFile) {
|
|
190023
|
-
return members.filter(
|
|
190152
|
+
return members.filter(import_typescript10.default.isPropertySignature).map((member) => ({
|
|
190024
190153
|
name: propertyNameText(member.name, sourceFile),
|
|
190025
190154
|
type: typeNodeToTypeInfo(member.type, sourceFile) ?? {
|
|
190026
190155
|
kind: "unknown",
|
|
190027
190156
|
raw: "unknown"
|
|
190028
190157
|
},
|
|
190029
190158
|
optional: !!member.questionToken,
|
|
190030
|
-
readonly: !!member.modifiers?.some((m) => m.kind ===
|
|
190159
|
+
readonly: !!member.modifiers?.some((m) => m.kind === import_typescript10.default.SyntaxKind.ReadonlyKeyword)
|
|
190031
190160
|
}));
|
|
190032
190161
|
}
|
|
190033
190162
|
function propertyNameText(name, sourceFile) {
|
|
190034
190163
|
if (!name)
|
|
190035
190164
|
return "";
|
|
190036
|
-
if (
|
|
190165
|
+
if (import_typescript10.default.isStringLiteral(name) || import_typescript10.default.isNumericLiteral(name))
|
|
190037
190166
|
return name.text;
|
|
190038
190167
|
return name.getText(sourceFile);
|
|
190039
190168
|
}
|
|
@@ -190044,56 +190173,56 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
|
|
|
190044
190173
|
const raw = rawOf ? rawOf(typeNode) : typeNode.getText(sourceFile);
|
|
190045
190174
|
const recurse = (n) => typeNodeToTypeInfo(n, sourceFile, rawOf) ?? { kind: "unknown", raw: "unknown" };
|
|
190046
190175
|
switch (typeNode.kind) {
|
|
190047
|
-
case
|
|
190176
|
+
case import_typescript10.default.SyntaxKind.StringKeyword:
|
|
190048
190177
|
return { kind: "primitive", raw, primitive: "string" };
|
|
190049
|
-
case
|
|
190178
|
+
case import_typescript10.default.SyntaxKind.NumberKeyword:
|
|
190050
190179
|
return { kind: "primitive", raw, primitive: "number" };
|
|
190051
|
-
case
|
|
190180
|
+
case import_typescript10.default.SyntaxKind.BooleanKeyword:
|
|
190052
190181
|
return { kind: "primitive", raw, primitive: "boolean" };
|
|
190053
|
-
case
|
|
190182
|
+
case import_typescript10.default.SyntaxKind.NullKeyword:
|
|
190054
190183
|
return { kind: "primitive", raw, primitive: "null" };
|
|
190055
|
-
case
|
|
190184
|
+
case import_typescript10.default.SyntaxKind.UndefinedKeyword:
|
|
190056
190185
|
return { kind: "primitive", raw, primitive: "undefined" };
|
|
190057
190186
|
}
|
|
190058
|
-
if (
|
|
190187
|
+
if (import_typescript10.default.isArrayTypeNode(typeNode)) {
|
|
190059
190188
|
return { kind: "array", raw, elementType: recurse(typeNode.elementType) };
|
|
190060
190189
|
}
|
|
190061
|
-
if (
|
|
190190
|
+
if (import_typescript10.default.isLiteralTypeNode(typeNode)) {
|
|
190062
190191
|
const lit = typeNode.literal;
|
|
190063
|
-
if (
|
|
190192
|
+
if (import_typescript10.default.isStringLiteral(lit) || import_typescript10.default.isNoSubstitutionTemplateLiteral(lit)) {
|
|
190064
190193
|
return { kind: "primitive", raw, primitive: "string", literalValue: lit.text };
|
|
190065
190194
|
}
|
|
190066
|
-
if (
|
|
190195
|
+
if (import_typescript10.default.isNumericLiteral(lit)) {
|
|
190067
190196
|
return { kind: "primitive", raw, primitive: "number", literalValue: lit.text };
|
|
190068
190197
|
}
|
|
190069
|
-
if (
|
|
190198
|
+
if (import_typescript10.default.isPrefixUnaryExpression(lit) && lit.operator === import_typescript10.default.SyntaxKind.MinusToken && import_typescript10.default.isNumericLiteral(lit.operand)) {
|
|
190070
190199
|
return { kind: "primitive", raw, primitive: "number", literalValue: `-${lit.operand.text}` };
|
|
190071
190200
|
}
|
|
190072
|
-
if (lit.kind ===
|
|
190201
|
+
if (lit.kind === import_typescript10.default.SyntaxKind.TrueKeyword || lit.kind === import_typescript10.default.SyntaxKind.FalseKeyword) {
|
|
190073
190202
|
return {
|
|
190074
190203
|
kind: "primitive",
|
|
190075
190204
|
raw,
|
|
190076
190205
|
primitive: "boolean",
|
|
190077
|
-
literalValue: lit.kind ===
|
|
190206
|
+
literalValue: lit.kind === import_typescript10.default.SyntaxKind.TrueKeyword ? "true" : "false"
|
|
190078
190207
|
};
|
|
190079
190208
|
}
|
|
190080
|
-
if (lit.kind ===
|
|
190209
|
+
if (lit.kind === import_typescript10.default.SyntaxKind.NullKeyword) {
|
|
190081
190210
|
return { kind: "primitive", raw, primitive: "null" };
|
|
190082
190211
|
}
|
|
190083
190212
|
return { kind: "unknown", raw };
|
|
190084
190213
|
}
|
|
190085
|
-
if (
|
|
190214
|
+
if (import_typescript10.default.isUnionTypeNode(typeNode)) {
|
|
190086
190215
|
return { kind: "union", raw, unionTypes: typeNode.types.map(recurse) };
|
|
190087
190216
|
}
|
|
190088
|
-
if (
|
|
190217
|
+
if (import_typescript10.default.isTypeLiteralNode(typeNode)) {
|
|
190089
190218
|
return {
|
|
190090
190219
|
kind: "object",
|
|
190091
190220
|
raw,
|
|
190092
190221
|
...synthetic ? {} : { properties: membersToProperties(typeNode.members, sourceFile) }
|
|
190093
190222
|
};
|
|
190094
190223
|
}
|
|
190095
|
-
if (
|
|
190096
|
-
const refName =
|
|
190224
|
+
if (import_typescript10.default.isTypeReferenceNode(typeNode)) {
|
|
190225
|
+
const refName = import_typescript10.default.isIdentifier(typeNode.typeName) ? typeNode.typeName.text : "";
|
|
190097
190226
|
if ((refName === "Array" || refName === "ReadonlyArray") && typeNode.typeArguments?.length === 1) {
|
|
190098
190227
|
return { kind: "array", raw, elementType: recurse(typeNode.typeArguments[0]) };
|
|
190099
190228
|
}
|
|
@@ -190102,7 +190231,7 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
|
|
|
190102
190231
|
raw
|
|
190103
190232
|
};
|
|
190104
190233
|
}
|
|
190105
|
-
if (
|
|
190234
|
+
if (import_typescript10.default.isFunctionTypeNode(typeNode)) {
|
|
190106
190235
|
if (synthetic)
|
|
190107
190236
|
return { kind: "function", raw };
|
|
190108
190237
|
return {
|
|
@@ -190122,15 +190251,15 @@ function typeNodeToTypeInfo(typeNode, sourceFile, rawOf) {
|
|
|
190122
190251
|
}
|
|
190123
190252
|
return { kind: "unknown", raw };
|
|
190124
190253
|
}
|
|
190125
|
-
var _typePrinter =
|
|
190126
|
-
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);
|
|
190127
190256
|
function tsTypeToTypeInfo(type2, checker) {
|
|
190128
|
-
const node = checker.typeToTypeNode(type2, undefined,
|
|
190257
|
+
const node = checker.typeToTypeNode(type2, undefined, import_typescript10.default.NodeBuilderFlags.NoTruncation);
|
|
190129
190258
|
if (!node)
|
|
190130
190259
|
return null;
|
|
190131
190260
|
const rawOf = (n) => {
|
|
190132
190261
|
try {
|
|
190133
|
-
return _typePrinter.printNode(
|
|
190262
|
+
return _typePrinter.printNode(import_typescript10.default.EmitHint.Unspecified, n, _blankTypeSourceFile);
|
|
190134
190263
|
} catch {
|
|
190135
190264
|
return "unknown";
|
|
190136
190265
|
}
|
|
@@ -190141,16 +190270,16 @@ function isPascalCase(name) {
|
|
|
190141
190270
|
return /^[A-Z][a-zA-Z0-9]*$/.test(name);
|
|
190142
190271
|
}
|
|
190143
190272
|
function isComponentFunction(node) {
|
|
190144
|
-
return
|
|
190273
|
+
return import_typescript10.default.isFunctionDeclaration(node) && !!node.name && isPascalCase(node.name.text) && !!node.body;
|
|
190145
190274
|
}
|
|
190146
190275
|
function isArrowComponentFunction(node) {
|
|
190147
|
-
if (!
|
|
190276
|
+
if (!import_typescript10.default.isVariableDeclaration(node))
|
|
190148
190277
|
return false;
|
|
190149
|
-
if (!
|
|
190278
|
+
if (!import_typescript10.default.isIdentifier(node.name))
|
|
190150
190279
|
return false;
|
|
190151
190280
|
if (!isPascalCase(node.name.text))
|
|
190152
190281
|
return false;
|
|
190153
|
-
if (!node.initializer || !
|
|
190282
|
+
if (!node.initializer || !import_typescript10.default.isArrowFunction(node.initializer))
|
|
190154
190283
|
return false;
|
|
190155
190284
|
return true;
|
|
190156
190285
|
}
|
|
@@ -190404,9 +190533,9 @@ function needsTypeBasedDetection(source) {
|
|
|
190404
190533
|
}
|
|
190405
190534
|
function findBrandPackageImportLoc(sourceFile, filePath) {
|
|
190406
190535
|
for (const stmt of sourceFile.statements) {
|
|
190407
|
-
if (!
|
|
190536
|
+
if (!import_typescript11.default.isImportDeclaration(stmt))
|
|
190408
190537
|
continue;
|
|
190409
|
-
if (!
|
|
190538
|
+
if (!import_typescript11.default.isStringLiteral(stmt.moduleSpecifier))
|
|
190410
190539
|
continue;
|
|
190411
190540
|
if (!REACTIVE_BRAND_PACKAGES.includes(stmt.moduleSpecifier.text))
|
|
190412
190541
|
continue;
|
|
@@ -190425,21 +190554,21 @@ function createProgramForFile(source, filePath) {
|
|
|
190425
190554
|
try {
|
|
190426
190555
|
const normalizedPath = path_default.resolve(filePath);
|
|
190427
190556
|
const compilerOptions = {
|
|
190428
|
-
target:
|
|
190429
|
-
module:
|
|
190430
|
-
moduleResolution:
|
|
190431
|
-
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,
|
|
190432
190561
|
strict: true,
|
|
190433
190562
|
skipLibCheck: true,
|
|
190434
190563
|
noEmit: true,
|
|
190435
190564
|
baseUrl: path_default.dirname(normalizedPath)
|
|
190436
190565
|
};
|
|
190437
|
-
const defaultHost =
|
|
190566
|
+
const defaultHost = import_typescript11.default.createCompilerHost(compilerOptions);
|
|
190438
190567
|
const virtualHost = {
|
|
190439
190568
|
...defaultHost,
|
|
190440
190569
|
getSourceFile(fileName, languageVersion) {
|
|
190441
190570
|
if (path_default.resolve(fileName) === normalizedPath) {
|
|
190442
|
-
return
|
|
190571
|
+
return import_typescript11.default.createSourceFile(fileName, source, languageVersion, true, import_typescript11.default.ScriptKind.TSX);
|
|
190443
190572
|
}
|
|
190444
190573
|
return defaultHost.getSourceFile(fileName, languageVersion);
|
|
190445
190574
|
},
|
|
@@ -190454,7 +190583,7 @@ function createProgramForFile(source, filePath) {
|
|
|
190454
190583
|
return defaultHost.readFile(fileName);
|
|
190455
190584
|
}
|
|
190456
190585
|
};
|
|
190457
|
-
const program =
|
|
190586
|
+
const program = import_typescript11.default.createProgram([normalizedPath], compilerOptions, virtualHost);
|
|
190458
190587
|
const sourceFile = program.getSourceFile(normalizedPath);
|
|
190459
190588
|
if (!sourceFile)
|
|
190460
190589
|
return null;
|
|
@@ -190487,7 +190616,7 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
|
|
|
190487
190616
|
}
|
|
190488
190617
|
}
|
|
190489
190618
|
if (!sourceFile) {
|
|
190490
|
-
sourceFile =
|
|
190619
|
+
sourceFile = import_typescript11.default.createSourceFile(filePath, source, import_typescript11.default.ScriptTarget.Latest, true, import_typescript11.default.ScriptKind.TSX);
|
|
190491
190620
|
}
|
|
190492
190621
|
if (!checker && needsTypeBasedDetection(source)) {
|
|
190493
190622
|
const result = createProgramForFile(source, filePath);
|
|
@@ -190533,23 +190662,23 @@ function analyzeComponent(source, filePath, targetComponentName, program, accept
|
|
|
190533
190662
|
function findDefaultExportedComponent(sourceFile) {
|
|
190534
190663
|
let defaultExportName;
|
|
190535
190664
|
function findDefaultExport(node) {
|
|
190536
|
-
if (
|
|
190537
|
-
if (
|
|
190665
|
+
if (import_typescript11.default.isExportAssignment(node) && !node.isExportEquals) {
|
|
190666
|
+
if (import_typescript11.default.isIdentifier(node.expression)) {
|
|
190538
190667
|
defaultExportName = node.expression.text;
|
|
190539
190668
|
}
|
|
190540
190669
|
}
|
|
190541
|
-
if (
|
|
190670
|
+
if (import_typescript11.default.isFunctionDeclaration(node) && node.name && node.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.DefaultKeyword)) {
|
|
190542
190671
|
defaultExportName = node.name.text;
|
|
190543
190672
|
}
|
|
190544
|
-
|
|
190673
|
+
import_typescript11.default.forEachChild(node, findDefaultExport);
|
|
190545
190674
|
}
|
|
190546
|
-
|
|
190675
|
+
import_typescript11.default.forEachChild(sourceFile, findDefaultExport);
|
|
190547
190676
|
return defaultExportName;
|
|
190548
190677
|
}
|
|
190549
190678
|
function collectNamedExports(sourceFile) {
|
|
190550
190679
|
const exported = new Set;
|
|
190551
190680
|
for (const stmt of sourceFile.statements) {
|
|
190552
|
-
if (
|
|
190681
|
+
if (import_typescript11.default.isExportDeclaration(stmt) && stmt.exportClause && import_typescript11.default.isNamedExports(stmt.exportClause)) {
|
|
190553
190682
|
for (const spec of stmt.exportClause.elements) {
|
|
190554
190683
|
const local = (spec.propertyName ?? spec.name).text;
|
|
190555
190684
|
exported.add(local);
|
|
@@ -190559,22 +190688,22 @@ function collectNamedExports(sourceFile) {
|
|
|
190559
190688
|
return exported;
|
|
190560
190689
|
}
|
|
190561
190690
|
function visit(node, ctx, targetComponentName, namedExports) {
|
|
190562
|
-
if (
|
|
190691
|
+
if (import_typescript11.default.isExpressionStatement(node) && import_typescript11.default.isStringLiteral(node.expression)) {
|
|
190563
190692
|
if (node.expression.text === "use client" || node.expression.text === "'use client'") {
|
|
190564
190693
|
ctx.hasUseClientDirective = true;
|
|
190565
190694
|
}
|
|
190566
190695
|
}
|
|
190567
|
-
if (
|
|
190696
|
+
if (import_typescript11.default.isImportDeclaration(node)) {
|
|
190568
190697
|
collectImport(node, ctx);
|
|
190569
190698
|
}
|
|
190570
|
-
if (
|
|
190699
|
+
if (import_typescript11.default.isInterfaceDeclaration(node)) {
|
|
190571
190700
|
collectInterfaceDefinition(node, ctx);
|
|
190572
190701
|
}
|
|
190573
|
-
if (
|
|
190702
|
+
if (import_typescript11.default.isTypeAliasDeclaration(node)) {
|
|
190574
190703
|
collectTypeAliasDefinition(node, ctx);
|
|
190575
190704
|
}
|
|
190576
|
-
if (!ctx.hasUseClientDirective &&
|
|
190577
|
-
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;
|
|
190578
190707
|
const hasNamedExport = namedExports?.has(node.name.text) ?? false;
|
|
190579
190708
|
if (!hasInlineExport && !hasNamedExport) {
|
|
190580
190709
|
collectFunction(node, ctx, true, false);
|
|
@@ -190589,9 +190718,9 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190589
190718
|
if (!ctx.componentName) {
|
|
190590
190719
|
ctx.componentName = node.name.text;
|
|
190591
190720
|
ctx.componentNode = node;
|
|
190592
|
-
ctx.isExported = node.modifiers?.some((m) => m.kind ===
|
|
190721
|
+
ctx.isExported = node.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.ExportKeyword) ?? false;
|
|
190593
190722
|
analyzeComponentBody(node, ctx);
|
|
190594
|
-
if (node.modifiers?.some((m) => m.kind ===
|
|
190723
|
+
if (node.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.DefaultKeyword)) {
|
|
190595
190724
|
ctx.hasDefaultExport = true;
|
|
190596
190725
|
}
|
|
190597
190726
|
}
|
|
@@ -190605,10 +190734,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190605
190734
|
ctx.componentName = node.name.text;
|
|
190606
190735
|
ctx.componentNode = node.initializer;
|
|
190607
190736
|
const parentStatement = node.parent;
|
|
190608
|
-
if (
|
|
190737
|
+
if (import_typescript11.default.isVariableDeclarationList(parentStatement)) {
|
|
190609
190738
|
const varStatement = parentStatement.parent;
|
|
190610
|
-
if (
|
|
190611
|
-
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;
|
|
190612
190741
|
}
|
|
190613
190742
|
}
|
|
190614
190743
|
analyzeComponentBody(node.initializer, ctx);
|
|
@@ -190620,10 +190749,10 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190620
190749
|
if (!ctx.componentNode) {
|
|
190621
190750
|
collectAmbientGlobals(node, ctx);
|
|
190622
190751
|
}
|
|
190623
|
-
const isDeclareStatement =
|
|
190624
|
-
if (
|
|
190625
|
-
const isExported = node.modifiers?.some((m) => m.kind ===
|
|
190626
|
-
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;
|
|
190627
190756
|
const isModuleClientDirective = hasLeadingClientDirectiveOnStatement(node, ctx.sourceFile);
|
|
190628
190757
|
for (const decl of node.declarationList.declarations) {
|
|
190629
190758
|
if (declarationIsReactiveFactoryCall(decl, ctx)) {
|
|
@@ -190634,19 +190763,19 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190634
190763
|
}
|
|
190635
190764
|
continue;
|
|
190636
190765
|
}
|
|
190637
|
-
if (
|
|
190766
|
+
if (import_typescript11.default.isIdentifier(decl.name) && (decl.initializer || isLet) && !isArrowComponentFunction(decl)) {
|
|
190638
190767
|
collectConstant(decl, ctx, true, isLet ? "let" : "const", isExported);
|
|
190639
190768
|
}
|
|
190640
190769
|
}
|
|
190641
190770
|
}
|
|
190642
|
-
if (
|
|
190643
|
-
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;
|
|
190644
190773
|
collectFunction(node, ctx, true, isExported);
|
|
190645
190774
|
return;
|
|
190646
190775
|
}
|
|
190647
|
-
if (
|
|
190776
|
+
if (import_typescript11.default.isExportDeclaration(node) && node.exportClause && import_typescript11.default.isNamedExports(node.exportClause)) {
|
|
190648
190777
|
const isFromReexport = !!node.moduleSpecifier;
|
|
190649
|
-
const sourceSpec = node.moduleSpecifier &&
|
|
190778
|
+
const sourceSpec = node.moduleSpecifier && import_typescript11.default.isStringLiteral(node.moduleSpecifier) ? node.moduleSpecifier.text : null;
|
|
190650
190779
|
const exportSpecifiers = node.exportClause.elements.map((spec) => ({
|
|
190651
190780
|
name: (spec.propertyName ?? spec.name).text,
|
|
190652
190781
|
alias: spec.propertyName ? spec.name.text : null,
|
|
@@ -190674,24 +190803,24 @@ function visit(node, ctx, targetComponentName, namedExports) {
|
|
|
190674
190803
|
}
|
|
190675
190804
|
}
|
|
190676
190805
|
}
|
|
190677
|
-
if (
|
|
190806
|
+
if (import_typescript11.default.isExportAssignment(node) && !node.isExportEquals) {
|
|
190678
190807
|
const expr = node.expression;
|
|
190679
|
-
if (
|
|
190808
|
+
if (import_typescript11.default.isIdentifier(expr)) {
|
|
190680
190809
|
if (ctx.componentName && expr.text === ctx.componentName) {
|
|
190681
190810
|
ctx.hasDefaultExport = true;
|
|
190682
190811
|
ctx.isExported = true;
|
|
190683
190812
|
}
|
|
190684
190813
|
}
|
|
190685
190814
|
}
|
|
190686
|
-
|
|
190815
|
+
import_typescript11.default.forEachChild(node, (child) => visit(child, ctx, targetComponentName, namedExports));
|
|
190687
190816
|
}
|
|
190688
190817
|
function analyzeComponentBody(node, ctx) {
|
|
190689
190818
|
if (node.parameters.length > 0) {
|
|
190690
190819
|
extractProps(node.parameters[0], ctx);
|
|
190691
190820
|
}
|
|
190692
|
-
const body =
|
|
190821
|
+
const body = import_typescript11.default.isFunctionDeclaration(node) ? node.body : getArrowFunctionBody(node);
|
|
190693
190822
|
if (body) {
|
|
190694
|
-
ctx.componentBodyBlock =
|
|
190823
|
+
ctx.componentBodyBlock = import_typescript11.default.isBlock(body) ? body : null;
|
|
190695
190824
|
if (!ctx.componentBodyBlock) {
|
|
190696
190825
|
ctx.jsxReturn = unwrapJsxTransparent(body);
|
|
190697
190826
|
}
|
|
@@ -190701,14 +190830,14 @@ function analyzeComponentBody(node, ctx) {
|
|
|
190701
190830
|
}
|
|
190702
190831
|
}
|
|
190703
190832
|
function getArrowFunctionBody(node) {
|
|
190704
|
-
if (
|
|
190833
|
+
if (import_typescript11.default.isBlock(node.body)) {
|
|
190705
190834
|
return node.body;
|
|
190706
190835
|
}
|
|
190707
190836
|
return node.body;
|
|
190708
190837
|
}
|
|
190709
190838
|
function visitComponentBody(node, ctx) {
|
|
190710
190839
|
const isTopLevel = ctx.componentBodyBlock !== null && node.parent === ctx.componentBodyBlock;
|
|
190711
|
-
if (
|
|
190840
|
+
if (import_typescript11.default.isVariableStatement(node)) {
|
|
190712
190841
|
for (const decl of node.declarationList.declarations) {
|
|
190713
190842
|
if (isSignalDeclaration(decl, ctx)) {
|
|
190714
190843
|
collectSignal(decl, ctx);
|
|
@@ -190731,16 +190860,16 @@ function visitComponentBody(node, ctx) {
|
|
|
190731
190860
|
collectEffect(decl.initializer, ctx, decl.name.text);
|
|
190732
190861
|
continue;
|
|
190733
190862
|
}
|
|
190734
|
-
if (
|
|
190735
|
-
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;
|
|
190736
190865
|
collectConstant(decl, ctx, false, isLet ? "let" : "const");
|
|
190737
|
-
} else if (
|
|
190738
|
-
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;
|
|
190739
190868
|
collectConstant(decl, ctx, false, isLet ? "let" : "const");
|
|
190740
190869
|
}
|
|
190741
190870
|
}
|
|
190742
190871
|
}
|
|
190743
|
-
if (
|
|
190872
|
+
if (import_typescript11.default.isExpressionStatement(node)) {
|
|
190744
190873
|
if (isEffectCall(node.expression, ctx)) {
|
|
190745
190874
|
collectEffect(node.expression, ctx);
|
|
190746
190875
|
return;
|
|
@@ -190754,10 +190883,10 @@ function visitComponentBody(node, ctx) {
|
|
|
190754
190883
|
return;
|
|
190755
190884
|
}
|
|
190756
190885
|
}
|
|
190757
|
-
if (
|
|
190886
|
+
if (import_typescript11.default.isFunctionDeclaration(node) && node.name) {
|
|
190758
190887
|
collectFunction(node, ctx, false);
|
|
190759
190888
|
}
|
|
190760
|
-
if (
|
|
190889
|
+
if (import_typescript11.default.isIfStatement(node)) {
|
|
190761
190890
|
const jsxReturn = findJsxReturnInBlock(node.thenStatement);
|
|
190762
190891
|
if (jsxReturn) {
|
|
190763
190892
|
const scopeVars = collectScopeVariables(node.thenStatement, ctx);
|
|
@@ -190776,8 +190905,8 @@ function visitComponentBody(node, ctx) {
|
|
|
190776
190905
|
return;
|
|
190777
190906
|
}
|
|
190778
190907
|
}
|
|
190779
|
-
if (isTopLevel && (
|
|
190780
|
-
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)) {
|
|
190781
190910
|
const returnedLocal = findBlockBodyReturnedJsxLocalName(node);
|
|
190782
190911
|
if (returnedLocal) {
|
|
190783
190912
|
ctx.errors.push(createError(ErrorCodes.RETURN_VALUE_NOT_JSX, getSourceLocation(node, ctx.sourceFile, ctx.filePath), {
|
|
@@ -190788,34 +190917,34 @@ function visitComponentBody(node, ctx) {
|
|
|
190788
190917
|
collectInitStatement(node, ctx);
|
|
190789
190918
|
return;
|
|
190790
190919
|
}
|
|
190791
|
-
if (
|
|
190920
|
+
if (import_typescript11.default.isReturnStatement(node) && node.expression) {
|
|
190792
190921
|
ctx.jsxReturn = unwrapJsxTransparent(node.expression);
|
|
190793
190922
|
}
|
|
190794
|
-
|
|
190795
|
-
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)) {
|
|
190796
190925
|
return;
|
|
190797
190926
|
}
|
|
190798
190927
|
visitComponentBody(child, ctx);
|
|
190799
190928
|
});
|
|
190800
190929
|
}
|
|
190801
190930
|
function findJsxReturnInBlock(node) {
|
|
190802
|
-
if (
|
|
190931
|
+
if (import_typescript11.default.isBlock(node)) {
|
|
190803
190932
|
for (const stmt of node.statements) {
|
|
190804
|
-
if (
|
|
190933
|
+
if (import_typescript11.default.isReturnStatement(stmt) && stmt.expression) {
|
|
190805
190934
|
const jsx = extractJsxFromExpression(stmt.expression);
|
|
190806
190935
|
if (jsx)
|
|
190807
190936
|
return jsx;
|
|
190808
190937
|
}
|
|
190809
190938
|
}
|
|
190810
190939
|
}
|
|
190811
|
-
if (
|
|
190940
|
+
if (import_typescript11.default.isReturnStatement(node) && node.expression) {
|
|
190812
190941
|
return extractJsxFromExpression(node.expression);
|
|
190813
190942
|
}
|
|
190814
190943
|
return null;
|
|
190815
190944
|
}
|
|
190816
190945
|
function unwrapJsxTransparent(expr) {
|
|
190817
190946
|
let current = expr;
|
|
190818
|
-
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) {
|
|
190819
190948
|
current = current.expression;
|
|
190820
190949
|
}
|
|
190821
190950
|
return current;
|
|
@@ -190823,22 +190952,22 @@ function unwrapJsxTransparent(expr) {
|
|
|
190823
190952
|
function findBlockBodyReturnedJsxLocalName(block) {
|
|
190824
190953
|
const stmts = block.statements;
|
|
190825
190954
|
const last = stmts[stmts.length - 1];
|
|
190826
|
-
if (!last || !
|
|
190955
|
+
if (!last || !import_typescript11.default.isReturnStatement(last) || !last.expression)
|
|
190827
190956
|
return null;
|
|
190828
190957
|
const returned = unwrapJsxTransparent(last.expression);
|
|
190829
|
-
if (!
|
|
190958
|
+
if (!import_typescript11.default.isIdentifier(returned))
|
|
190830
190959
|
return null;
|
|
190831
190960
|
const name = returned.text;
|
|
190832
190961
|
for (const stmt of stmts) {
|
|
190833
|
-
if (!
|
|
190962
|
+
if (!import_typescript11.default.isVariableStatement(stmt))
|
|
190834
190963
|
continue;
|
|
190835
190964
|
for (const decl of stmt.declarationList.declarations) {
|
|
190836
|
-
if (!
|
|
190965
|
+
if (!import_typescript11.default.isIdentifier(decl.name) || decl.name.text !== name || !decl.initializer)
|
|
190837
190966
|
continue;
|
|
190838
190967
|
let init = decl.initializer;
|
|
190839
|
-
while (
|
|
190968
|
+
while (import_typescript11.default.isParenthesizedExpression(init))
|
|
190840
190969
|
init = init.expression;
|
|
190841
|
-
if (
|
|
190970
|
+
if (import_typescript11.default.isJsxElement(init) || import_typescript11.default.isJsxSelfClosingElement(init) || import_typescript11.default.isJsxFragment(init) || initializerShapeContainsJsx(init) || isMapLikeCallWithJsx(init)) {
|
|
190842
190971
|
return name;
|
|
190843
190972
|
}
|
|
190844
190973
|
}
|
|
@@ -190847,16 +190976,16 @@ function findBlockBodyReturnedJsxLocalName(block) {
|
|
|
190847
190976
|
}
|
|
190848
190977
|
function extractJsxFromExpression(expr) {
|
|
190849
190978
|
const inner = unwrapJsxTransparent(expr);
|
|
190850
|
-
if (
|
|
190979
|
+
if (import_typescript11.default.isJsxElement(inner) || import_typescript11.default.isJsxFragment(inner) || import_typescript11.default.isJsxSelfClosingElement(inner)) {
|
|
190851
190980
|
return inner;
|
|
190852
190981
|
}
|
|
190853
190982
|
return null;
|
|
190854
190983
|
}
|
|
190855
190984
|
function collectScopeVariables(node, ctx) {
|
|
190856
190985
|
const variables = [];
|
|
190857
|
-
if (
|
|
190986
|
+
if (import_typescript11.default.isBlock(node)) {
|
|
190858
190987
|
for (const stmt of node.statements) {
|
|
190859
|
-
if (
|
|
190988
|
+
if (import_typescript11.default.isVariableStatement(stmt)) {
|
|
190860
190989
|
for (const decl of stmt.declarationList.declarations) {
|
|
190861
190990
|
variables.push(decl);
|
|
190862
190991
|
}
|
|
@@ -190868,13 +190997,13 @@ function collectScopeVariables(node, ctx) {
|
|
|
190868
190997
|
function collectParamBindingNames(params) {
|
|
190869
190998
|
const out = new Set;
|
|
190870
190999
|
const addBindingNames = (name) => {
|
|
190871
|
-
if (
|
|
191000
|
+
if (import_typescript11.default.isIdentifier(name)) {
|
|
190872
191001
|
out.add(name.text);
|
|
190873
|
-
} else if (
|
|
191002
|
+
} else if (import_typescript11.default.isObjectBindingPattern(name)) {
|
|
190874
191003
|
name.elements.forEach((e) => addBindingNames(e.name));
|
|
190875
|
-
} else if (
|
|
191004
|
+
} else if (import_typescript11.default.isArrayBindingPattern(name)) {
|
|
190876
191005
|
name.elements.forEach((e) => {
|
|
190877
|
-
if (!
|
|
191006
|
+
if (!import_typescript11.default.isOmittedExpression(e))
|
|
190878
191007
|
addBindingNames(e.name);
|
|
190879
191008
|
});
|
|
190880
191009
|
}
|
|
@@ -190891,7 +191020,7 @@ function collectEnclosingBranchVars(node, ctx) {
|
|
|
190891
191020
|
if (cr.ifStatement.thenStatement !== current)
|
|
190892
191021
|
continue;
|
|
190893
191022
|
for (const decl of cr.scopeVariables) {
|
|
190894
|
-
if (!
|
|
191023
|
+
if (!import_typescript11.default.isIdentifier(decl.name) || !decl.initializer)
|
|
190895
191024
|
continue;
|
|
190896
191025
|
const varName = decl.name.text;
|
|
190897
191026
|
if (result.has(varName))
|
|
@@ -190906,10 +191035,10 @@ function collectEnclosingBranchVars(node, ctx) {
|
|
|
190906
191035
|
return result;
|
|
190907
191036
|
}
|
|
190908
191037
|
function collectBranchSignals(thenStatement, ctx, branchCondition) {
|
|
190909
|
-
if (!
|
|
191038
|
+
if (!import_typescript11.default.isBlock(thenStatement))
|
|
190910
191039
|
return;
|
|
190911
191040
|
for (const stmt of thenStatement.statements) {
|
|
190912
|
-
if (!
|
|
191041
|
+
if (!import_typescript11.default.isVariableStatement(stmt))
|
|
190913
191042
|
continue;
|
|
190914
191043
|
for (const decl of stmt.declarationList.declarations) {
|
|
190915
191044
|
if (!isSignalDeclaration(decl, ctx))
|
|
@@ -190935,13 +191064,13 @@ var ENV_SIGNAL_FACTORIES = {
|
|
|
190935
191064
|
createSearchParams: "search"
|
|
190936
191065
|
};
|
|
190937
191066
|
function resolvePrimitiveKind(callExpr, ctx) {
|
|
190938
|
-
if (
|
|
191067
|
+
if (import_typescript11.default.isIdentifier(callExpr.expression)) {
|
|
190939
191068
|
const hit = PRIMITIVE_CANONICAL_NAMES[callExpr.expression.text];
|
|
190940
191069
|
if (hit)
|
|
190941
191070
|
return hit;
|
|
190942
191071
|
return resolveCalleeViaChecker(callExpr.expression, ctx);
|
|
190943
191072
|
}
|
|
190944
|
-
if (
|
|
191073
|
+
if (import_typescript11.default.isPropertyAccessExpression(callExpr.expression)) {
|
|
190945
191074
|
const propName = callExpr.expression.name.text;
|
|
190946
191075
|
const hit = PRIMITIVE_CANONICAL_NAMES[propName];
|
|
190947
191076
|
if (!hit)
|
|
@@ -190968,7 +191097,7 @@ function resolveCanonicalClientExportName(ident, ctx) {
|
|
|
190968
191097
|
if (!symbol)
|
|
190969
191098
|
return null;
|
|
190970
191099
|
let target = symbol;
|
|
190971
|
-
if (symbol.flags &
|
|
191100
|
+
if (symbol.flags & import_typescript11.default.SymbolFlags.Alias) {
|
|
190972
191101
|
try {
|
|
190973
191102
|
target = ctx.checker.getAliasedSymbol(symbol);
|
|
190974
191103
|
} catch {
|
|
@@ -190984,14 +191113,14 @@ function resolveCanonicalClientExportName(ident, ctx) {
|
|
|
190984
191113
|
return null;
|
|
190985
191114
|
}
|
|
190986
191115
|
function resolveEnvSignalKey(callExpr, ctx) {
|
|
190987
|
-
if (
|
|
191116
|
+
if (import_typescript11.default.isIdentifier(callExpr.expression)) {
|
|
190988
191117
|
const key = ENV_SIGNAL_FACTORIES[callExpr.expression.text];
|
|
190989
191118
|
if (key)
|
|
190990
191119
|
return key;
|
|
190991
191120
|
const canonical = resolveCanonicalClientExportName(callExpr.expression, ctx);
|
|
190992
191121
|
return canonical ? ENV_SIGNAL_FACTORIES[canonical] ?? null : null;
|
|
190993
191122
|
}
|
|
190994
|
-
if (
|
|
191123
|
+
if (import_typescript11.default.isPropertyAccessExpression(callExpr.expression)) {
|
|
190995
191124
|
const key = ENV_SIGNAL_FACTORIES[callExpr.expression.name.text];
|
|
190996
191125
|
if (key && isBarefootClientNamespace(callExpr.expression.expression, ctx))
|
|
190997
191126
|
return key;
|
|
@@ -190999,7 +191128,7 @@ function resolveEnvSignalKey(callExpr, ctx) {
|
|
|
190999
191128
|
return null;
|
|
191000
191129
|
}
|
|
191001
191130
|
function isBarefootClientNamespace(expr, ctx) {
|
|
191002
|
-
if (!
|
|
191131
|
+
if (!import_typescript11.default.isIdentifier(expr))
|
|
191003
191132
|
return false;
|
|
191004
191133
|
if (!ctx.checker)
|
|
191005
191134
|
return false;
|
|
@@ -191012,22 +191141,22 @@ function isBarefootClientNamespace(expr, ctx) {
|
|
|
191012
191141
|
if (!symbol)
|
|
191013
191142
|
return false;
|
|
191014
191143
|
for (const decl of symbol.declarations ?? []) {
|
|
191015
|
-
if (!
|
|
191144
|
+
if (!import_typescript11.default.isNamespaceImport(decl))
|
|
191016
191145
|
continue;
|
|
191017
191146
|
const importDecl = decl.parent.parent;
|
|
191018
|
-
if (!
|
|
191147
|
+
if (!import_typescript11.default.isImportDeclaration(importDecl))
|
|
191019
191148
|
continue;
|
|
191020
191149
|
const mod = importDecl.moduleSpecifier;
|
|
191021
|
-
if (
|
|
191150
|
+
if (import_typescript11.default.isStringLiteral(mod) && mod.text === "@barefootjs/client") {
|
|
191022
191151
|
return true;
|
|
191023
191152
|
}
|
|
191024
191153
|
}
|
|
191025
191154
|
return false;
|
|
191026
191155
|
}
|
|
191027
191156
|
function isSignalDeclaration(node, ctx) {
|
|
191028
|
-
if (!
|
|
191157
|
+
if (!import_typescript11.default.isArrayBindingPattern(node.name))
|
|
191029
191158
|
return false;
|
|
191030
|
-
if (!node.initializer || !
|
|
191159
|
+
if (!node.initializer || !import_typescript11.default.isCallExpression(node.initializer))
|
|
191031
191160
|
return false;
|
|
191032
191161
|
return resolvePrimitiveKind(node.initializer, ctx) === "signal";
|
|
191033
191162
|
}
|
|
@@ -191035,14 +191164,14 @@ function collectSignal(node, ctx) {
|
|
|
191035
191164
|
const pattern = node.name;
|
|
191036
191165
|
const callExpr = node.initializer;
|
|
191037
191166
|
const elements = pattern.elements;
|
|
191038
|
-
const getterElided = elements.length === 2 &&
|
|
191039
|
-
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))) {
|
|
191040
191169
|
return;
|
|
191041
191170
|
}
|
|
191042
|
-
if (elements.length === 2 && (!
|
|
191171
|
+
if (elements.length === 2 && (!import_typescript11.default.isBindingElement(elements[1]) || !import_typescript11.default.isIdentifier(elements[1].name))) {
|
|
191043
191172
|
return;
|
|
191044
191173
|
}
|
|
191045
|
-
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;
|
|
191046
191175
|
if (getterElided && !setter)
|
|
191047
191176
|
return;
|
|
191048
191177
|
const getter = getterElided ? `__bfGet_${setter}` : elements[0].name.text;
|
|
@@ -191079,33 +191208,33 @@ function collectSignal(node, ctx) {
|
|
|
191079
191208
|
});
|
|
191080
191209
|
}
|
|
191081
191210
|
function isSignalTupleDeclaration(node) {
|
|
191082
|
-
if (!
|
|
191211
|
+
if (!import_typescript11.default.isIdentifier(node.name))
|
|
191083
191212
|
return false;
|
|
191084
|
-
if (!node.initializer || !
|
|
191213
|
+
if (!node.initializer || !import_typescript11.default.isCallExpression(node.initializer))
|
|
191085
191214
|
return false;
|
|
191086
191215
|
const callExpr = node.initializer;
|
|
191087
|
-
return
|
|
191216
|
+
return import_typescript11.default.isIdentifier(callExpr.expression) && callExpr.expression.text === "createSignal";
|
|
191088
191217
|
}
|
|
191089
191218
|
function isSignalIndexAccess(node, ctx) {
|
|
191090
|
-
if (!
|
|
191219
|
+
if (!import_typescript11.default.isIdentifier(node.name))
|
|
191091
191220
|
return null;
|
|
191092
|
-
if (!node.initializer || !
|
|
191221
|
+
if (!node.initializer || !import_typescript11.default.isElementAccessExpression(node.initializer))
|
|
191093
191222
|
return null;
|
|
191094
191223
|
const access = node.initializer;
|
|
191095
|
-
if (!
|
|
191224
|
+
if (!import_typescript11.default.isNumericLiteral(access.argumentExpression))
|
|
191096
191225
|
return null;
|
|
191097
191226
|
const indexValue = Number(access.argumentExpression.text);
|
|
191098
191227
|
if (indexValue !== 0 && indexValue !== 1)
|
|
191099
191228
|
return null;
|
|
191100
191229
|
const index = indexValue;
|
|
191101
|
-
if (
|
|
191230
|
+
if (import_typescript11.default.isCallExpression(access.expression)) {
|
|
191102
191231
|
const call = access.expression;
|
|
191103
|
-
if (
|
|
191232
|
+
if (import_typescript11.default.isIdentifier(call.expression) && call.expression.text === "createSignal") {
|
|
191104
191233
|
return { kind: "direct", index, callExpr: call };
|
|
191105
191234
|
}
|
|
191106
191235
|
return null;
|
|
191107
191236
|
}
|
|
191108
|
-
if (
|
|
191237
|
+
if (import_typescript11.default.isIdentifier(access.expression)) {
|
|
191109
191238
|
const tupleName = access.expression.text;
|
|
191110
191239
|
if (ctx.signalTupleRefs.has(tupleName)) {
|
|
191111
191240
|
return { kind: "tupleRef", index, tupleName };
|
|
@@ -191200,30 +191329,30 @@ function flushPendingSignalTuples(ctx) {
|
|
|
191200
191329
|
ctx.signalTupleRefs.clear();
|
|
191201
191330
|
}
|
|
191202
191331
|
function isMemoDeclaration(node, ctx) {
|
|
191203
|
-
if (!
|
|
191332
|
+
if (!import_typescript11.default.isIdentifier(node.name))
|
|
191204
191333
|
return false;
|
|
191205
|
-
if (!node.initializer || !
|
|
191334
|
+
if (!node.initializer || !import_typescript11.default.isCallExpression(node.initializer))
|
|
191206
191335
|
return false;
|
|
191207
191336
|
return resolvePrimitiveKind(node.initializer, ctx) === "memo";
|
|
191208
191337
|
}
|
|
191209
191338
|
function memoBodyIsTemplateLiteral(memoArrow) {
|
|
191210
191339
|
let node = memoArrow;
|
|
191211
|
-
while (node &&
|
|
191340
|
+
while (node && import_typescript11.default.isParenthesizedExpression(node))
|
|
191212
191341
|
node = node.expression;
|
|
191213
|
-
if (!node || !
|
|
191342
|
+
if (!node || !import_typescript11.default.isArrowFunction(node))
|
|
191214
191343
|
return false;
|
|
191215
191344
|
let body = node.body;
|
|
191216
|
-
while (
|
|
191345
|
+
while (import_typescript11.default.isParenthesizedExpression(body))
|
|
191217
191346
|
body = body.expression;
|
|
191218
|
-
if (
|
|
191219
|
-
const ret = body.statements.find(
|
|
191347
|
+
if (import_typescript11.default.isBlock(body)) {
|
|
191348
|
+
const ret = body.statements.find(import_typescript11.default.isReturnStatement);
|
|
191220
191349
|
if (!ret || !ret.expression)
|
|
191221
191350
|
return false;
|
|
191222
191351
|
body = ret.expression;
|
|
191223
|
-
while (
|
|
191352
|
+
while (import_typescript11.default.isParenthesizedExpression(body))
|
|
191224
191353
|
body = body.expression;
|
|
191225
191354
|
}
|
|
191226
|
-
return
|
|
191355
|
+
return import_typescript11.default.isTemplateExpression(body) || import_typescript11.default.isNoSubstitutionTemplateLiteral(body);
|
|
191227
191356
|
}
|
|
191228
191357
|
function collectMemo(node, ctx) {
|
|
191229
191358
|
const name = node.name.text;
|
|
@@ -191240,7 +191369,7 @@ function collectMemo(node, ctx) {
|
|
|
191240
191369
|
type2 = inferTypeFromValue(arrowBody);
|
|
191241
191370
|
}
|
|
191242
191371
|
}
|
|
191243
|
-
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]))) {
|
|
191244
191373
|
const fnType = ctx.checker.getTypeAtLocation(callExpr.arguments[0]);
|
|
191245
191374
|
const sig = fnType.getCallSignatures()[0];
|
|
191246
191375
|
if (sig) {
|
|
@@ -191250,12 +191379,12 @@ function collectMemo(node, ctx) {
|
|
|
191250
191379
|
}
|
|
191251
191380
|
}
|
|
191252
191381
|
const memoArrow = callExpr.arguments[0];
|
|
191253
|
-
const parsedBody = memoArrow &&
|
|
191382
|
+
const parsedBody = memoArrow && import_typescript11.default.isArrowFunction(memoArrow) && !import_typescript11.default.isBlock(memoArrow.body) ? parseExpression(ctx.getJS(memoArrow.body)) : undefined;
|
|
191254
191383
|
const parsed = parsedBody && parsedBody.kind !== "unsupported" && parsedBody.kind !== "object-literal" ? parsedBody : undefined;
|
|
191255
191384
|
let arrowNode = memoArrow;
|
|
191256
|
-
while (arrowNode &&
|
|
191385
|
+
while (arrowNode && import_typescript11.default.isParenthesizedExpression(arrowNode))
|
|
191257
191386
|
arrowNode = arrowNode.expression;
|
|
191258
|
-
const blockBody = arrowNode &&
|
|
191387
|
+
const blockBody = arrowNode && import_typescript11.default.isArrowFunction(arrowNode) && import_typescript11.default.isBlock(arrowNode.body) ? arrowNode.body : undefined;
|
|
191259
191388
|
const parsedBlock = blockBody ? parseBlockBodyTolerant(blockBody, ctx.sourceFile, (node2) => ctx.getJS(node2)) : undefined;
|
|
191260
191389
|
const parsedBlockComplete = parsedBlock && blockBody ? parsedBlock.length === blockBody.statements.length : undefined;
|
|
191261
191390
|
let templateComputation;
|
|
@@ -191282,14 +191411,14 @@ function collectMemo(node, ctx) {
|
|
|
191282
191411
|
});
|
|
191283
191412
|
}
|
|
191284
191413
|
function isEffectCall(node, ctx) {
|
|
191285
|
-
if (!
|
|
191414
|
+
if (!import_typescript11.default.isCallExpression(node))
|
|
191286
191415
|
return false;
|
|
191287
191416
|
return resolvePrimitiveKind(node, ctx) === "effect";
|
|
191288
191417
|
}
|
|
191289
191418
|
function isEffectDisposerCapture(node, ctx) {
|
|
191290
|
-
if (!
|
|
191419
|
+
if (!import_typescript11.default.isIdentifier(node.name))
|
|
191291
191420
|
return false;
|
|
191292
|
-
if (!node.initializer || !
|
|
191421
|
+
if (!node.initializer || !import_typescript11.default.isCallExpression(node.initializer))
|
|
191293
191422
|
return false;
|
|
191294
191423
|
return resolvePrimitiveKind(node.initializer, ctx) === "effect";
|
|
191295
191424
|
}
|
|
@@ -191304,7 +191433,7 @@ function collectEffect(node, ctx, captureName) {
|
|
|
191304
191433
|
});
|
|
191305
191434
|
}
|
|
191306
191435
|
function isOnMountCall(node, ctx) {
|
|
191307
|
-
if (!
|
|
191436
|
+
if (!import_typescript11.default.isCallExpression(node))
|
|
191308
191437
|
return false;
|
|
191309
191438
|
return resolvePrimitiveKind(node, ctx) === "onMount";
|
|
191310
191439
|
}
|
|
@@ -191339,19 +191468,19 @@ function leadsWithAsiHazard(body) {
|
|
|
191339
191468
|
function extractAssignedIdentifiersFromNode(node) {
|
|
191340
191469
|
const ids = new Set;
|
|
191341
191470
|
function addFromTarget(target) {
|
|
191342
|
-
if (
|
|
191471
|
+
if (import_typescript11.default.isIdentifier(target)) {
|
|
191343
191472
|
ids.add(target.text);
|
|
191344
191473
|
return;
|
|
191345
191474
|
}
|
|
191346
|
-
if (
|
|
191475
|
+
if (import_typescript11.default.isParenthesizedExpression(target)) {
|
|
191347
191476
|
addFromTarget(target.expression);
|
|
191348
191477
|
return;
|
|
191349
191478
|
}
|
|
191350
|
-
if (
|
|
191479
|
+
if (import_typescript11.default.isArrayLiteralExpression(target)) {
|
|
191351
191480
|
for (const el of target.elements) {
|
|
191352
|
-
if (
|
|
191481
|
+
if (import_typescript11.default.isOmittedExpression(el))
|
|
191353
191482
|
continue;
|
|
191354
|
-
if (
|
|
191483
|
+
if (import_typescript11.default.isSpreadElement(el)) {
|
|
191355
191484
|
addFromTarget(el.expression);
|
|
191356
191485
|
continue;
|
|
191357
191486
|
}
|
|
@@ -191359,17 +191488,17 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191359
191488
|
}
|
|
191360
191489
|
return;
|
|
191361
191490
|
}
|
|
191362
|
-
if (
|
|
191491
|
+
if (import_typescript11.default.isObjectLiteralExpression(target)) {
|
|
191363
191492
|
for (const prop of target.properties) {
|
|
191364
|
-
if (
|
|
191493
|
+
if (import_typescript11.default.isShorthandPropertyAssignment(prop)) {
|
|
191365
191494
|
ids.add(prop.name.text);
|
|
191366
191495
|
continue;
|
|
191367
191496
|
}
|
|
191368
|
-
if (
|
|
191497
|
+
if (import_typescript11.default.isPropertyAssignment(prop)) {
|
|
191369
191498
|
addFromTarget(prop.initializer);
|
|
191370
191499
|
continue;
|
|
191371
191500
|
}
|
|
191372
|
-
if (
|
|
191501
|
+
if (import_typescript11.default.isSpreadAssignment(prop)) {
|
|
191373
191502
|
addFromTarget(prop.expression);
|
|
191374
191503
|
continue;
|
|
191375
191504
|
}
|
|
@@ -191378,21 +191507,21 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191378
191507
|
}
|
|
191379
191508
|
}
|
|
191380
191509
|
function visit2(n) {
|
|
191381
|
-
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)) {
|
|
191382
191511
|
return;
|
|
191383
191512
|
}
|
|
191384
|
-
if (
|
|
191513
|
+
if (import_typescript11.default.isBinaryExpression(n)) {
|
|
191385
191514
|
const op = n.operatorToken.kind;
|
|
191386
|
-
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) {
|
|
191387
191516
|
addFromTarget(n.left);
|
|
191388
191517
|
}
|
|
191389
191518
|
}
|
|
191390
|
-
if (
|
|
191391
|
-
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) {
|
|
191392
191521
|
addFromTarget(n.operand);
|
|
191393
191522
|
}
|
|
191394
191523
|
}
|
|
191395
|
-
|
|
191524
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191396
191525
|
}
|
|
191397
191526
|
visit2(node);
|
|
191398
191527
|
const localDecls = collectLocalDeclarations(node);
|
|
@@ -191403,30 +191532,30 @@ function extractAssignedIdentifiersFromNode(node) {
|
|
|
191403
191532
|
function collectLocalDeclarations(root) {
|
|
191404
191533
|
const names = new Set;
|
|
191405
191534
|
function addBindingName(name) {
|
|
191406
|
-
if (
|
|
191535
|
+
if (import_typescript11.default.isIdentifier(name)) {
|
|
191407
191536
|
names.add(name.text);
|
|
191408
191537
|
return;
|
|
191409
191538
|
}
|
|
191410
|
-
if (
|
|
191539
|
+
if (import_typescript11.default.isArrayBindingPattern(name)) {
|
|
191411
191540
|
for (const el of name.elements) {
|
|
191412
|
-
if (
|
|
191541
|
+
if (import_typescript11.default.isBindingElement(el))
|
|
191413
191542
|
addBindingName(el.name);
|
|
191414
191543
|
}
|
|
191415
191544
|
return;
|
|
191416
191545
|
}
|
|
191417
|
-
if (
|
|
191546
|
+
if (import_typescript11.default.isObjectBindingPattern(name)) {
|
|
191418
191547
|
for (const el of name.elements) {
|
|
191419
191548
|
addBindingName(el.name);
|
|
191420
191549
|
}
|
|
191421
191550
|
}
|
|
191422
191551
|
}
|
|
191423
191552
|
function visit2(n) {
|
|
191424
|
-
if (
|
|
191553
|
+
if (import_typescript11.default.isArrowFunction(n) || import_typescript11.default.isFunctionExpression(n) || import_typescript11.default.isFunctionDeclaration(n))
|
|
191425
191554
|
return;
|
|
191426
|
-
if (
|
|
191555
|
+
if (import_typescript11.default.isVariableDeclaration(n)) {
|
|
191427
191556
|
addBindingName(n.name);
|
|
191428
191557
|
}
|
|
191429
|
-
|
|
191558
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191430
191559
|
}
|
|
191431
191560
|
visit2(root);
|
|
191432
191561
|
return names;
|
|
@@ -191461,35 +191590,35 @@ var CLIENT_EXPORTS = new Set([
|
|
|
191461
191590
|
"Region"
|
|
191462
191591
|
]);
|
|
191463
191592
|
function collectAmbientGlobals(node, ctx) {
|
|
191464
|
-
if (
|
|
191465
|
-
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;
|
|
191466
191595
|
if (!isDeclare)
|
|
191467
191596
|
return;
|
|
191468
191597
|
for (const decl of node.declarationList.declarations) {
|
|
191469
|
-
if (
|
|
191598
|
+
if (import_typescript11.default.isIdentifier(decl.name))
|
|
191470
191599
|
ctx.ambientGlobals.add(decl.name.text);
|
|
191471
191600
|
}
|
|
191472
191601
|
return;
|
|
191473
191602
|
}
|
|
191474
|
-
if (
|
|
191475
|
-
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;
|
|
191476
191605
|
if (isDeclare)
|
|
191477
191606
|
ctx.ambientGlobals.add(node.name.text);
|
|
191478
191607
|
return;
|
|
191479
191608
|
}
|
|
191480
|
-
if (
|
|
191481
|
-
const isGlobalAugmentation = (node.flags &
|
|
191609
|
+
if (import_typescript11.default.isModuleDeclaration(node)) {
|
|
191610
|
+
const isGlobalAugmentation = (node.flags & import_typescript11.default.NodeFlags.GlobalAugmentation) !== 0;
|
|
191482
191611
|
if (!isGlobalAugmentation)
|
|
191483
191612
|
return;
|
|
191484
|
-
if (!node.body || !
|
|
191613
|
+
if (!node.body || !import_typescript11.default.isModuleBlock(node.body))
|
|
191485
191614
|
return;
|
|
191486
191615
|
for (const inner of node.body.statements) {
|
|
191487
|
-
if (
|
|
191616
|
+
if (import_typescript11.default.isVariableStatement(inner)) {
|
|
191488
191617
|
for (const decl of inner.declarationList.declarations) {
|
|
191489
|
-
if (
|
|
191618
|
+
if (import_typescript11.default.isIdentifier(decl.name))
|
|
191490
191619
|
ctx.ambientGlobals.add(decl.name.text);
|
|
191491
191620
|
}
|
|
191492
|
-
} else if (
|
|
191621
|
+
} else if (import_typescript11.default.isFunctionDeclaration(inner) && inner.name) {
|
|
191493
191622
|
ctx.ambientGlobals.add(inner.name.text);
|
|
191494
191623
|
}
|
|
191495
191624
|
}
|
|
@@ -191500,7 +191629,7 @@ function collectImport(node, ctx) {
|
|
|
191500
191629
|
const specifiers = [];
|
|
191501
191630
|
const isTypeOnly = !!node.importClause?.isTypeOnly;
|
|
191502
191631
|
const loc = getSourceLocation(node, ctx.sourceFile, ctx.filePath);
|
|
191503
|
-
if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings &&
|
|
191632
|
+
if (source === "@barefootjs/client" && !isTypeOnly && node.importClause?.namedBindings && import_typescript11.default.isNamedImports(node.importClause.namedBindings)) {
|
|
191504
191633
|
const wrongImports = [];
|
|
191505
191634
|
for (const element of node.importClause.namedBindings.elements) {
|
|
191506
191635
|
const name = element.propertyName?.text ?? element.name.text;
|
|
@@ -191528,7 +191657,7 @@ function collectImport(node, ctx) {
|
|
|
191528
191657
|
});
|
|
191529
191658
|
}
|
|
191530
191659
|
if (node.importClause.namedBindings) {
|
|
191531
|
-
if (
|
|
191660
|
+
if (import_typescript11.default.isNamedImports(node.importClause.namedBindings)) {
|
|
191532
191661
|
for (const element of node.importClause.namedBindings.elements) {
|
|
191533
191662
|
specifiers.push({
|
|
191534
191663
|
name: element.propertyName?.text ?? element.name.text,
|
|
@@ -191539,7 +191668,7 @@ function collectImport(node, ctx) {
|
|
|
191539
191668
|
});
|
|
191540
191669
|
}
|
|
191541
191670
|
}
|
|
191542
|
-
if (
|
|
191671
|
+
if (import_typescript11.default.isNamespaceImport(node.importClause.namedBindings)) {
|
|
191543
191672
|
specifiers.push({
|
|
191544
191673
|
name: node.importClause.namedBindings.name.text,
|
|
191545
191674
|
alias: null,
|
|
@@ -191566,7 +191695,7 @@ function collectInterfaceDefinition(node, ctx) {
|
|
|
191566
191695
|
});
|
|
191567
191696
|
}
|
|
191568
191697
|
function collectTypeAliasDefinition(node, ctx) {
|
|
191569
|
-
const properties =
|
|
191698
|
+
const properties = import_typescript11.default.isTypeLiteralNode(node.type) ? membersToProperties(node.type.members, ctx.sourceFile) : undefined;
|
|
191570
191699
|
ctx.typeDefinitions.push({
|
|
191571
191700
|
kind: "type",
|
|
191572
191701
|
name: node.name.text,
|
|
@@ -191579,20 +191708,20 @@ function extractSingleJsxReturn(body) {
|
|
|
191579
191708
|
let jsxReturn = null;
|
|
191580
191709
|
let returnCount = 0;
|
|
191581
191710
|
function visit2(node) {
|
|
191582
|
-
if (
|
|
191711
|
+
if (import_typescript11.default.isFunctionDeclaration(node) || import_typescript11.default.isFunctionExpression(node) || import_typescript11.default.isArrowFunction(node))
|
|
191583
191712
|
return;
|
|
191584
|
-
if (
|
|
191713
|
+
if (import_typescript11.default.isReturnStatement(node)) {
|
|
191585
191714
|
returnCount++;
|
|
191586
191715
|
if (node.expression) {
|
|
191587
191716
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191588
|
-
if (
|
|
191717
|
+
if (import_typescript11.default.isJsxElement(expr) || import_typescript11.default.isJsxSelfClosingElement(expr) || import_typescript11.default.isJsxFragment(expr)) {
|
|
191589
191718
|
jsxReturn = expr;
|
|
191590
191719
|
}
|
|
191591
191720
|
}
|
|
191592
191721
|
}
|
|
191593
|
-
|
|
191722
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
191594
191723
|
}
|
|
191595
|
-
|
|
191724
|
+
import_typescript11.default.forEachChild(body, visit2);
|
|
191596
191725
|
if (returnCount !== 1)
|
|
191597
191726
|
return null;
|
|
191598
191727
|
return jsxReturn;
|
|
@@ -191609,9 +191738,9 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191609
191738
|
const stmts = body.statements;
|
|
191610
191739
|
for (let i2 = 0;i2 < stmts.length; i2++) {
|
|
191611
191740
|
const stmt = stmts[i2];
|
|
191612
|
-
if (
|
|
191741
|
+
if (import_typescript11.default.isIfStatement(stmt)) {
|
|
191613
191742
|
let current = stmt;
|
|
191614
|
-
while (
|
|
191743
|
+
while (import_typescript11.default.isIfStatement(current)) {
|
|
191615
191744
|
const ifStmt = current;
|
|
191616
191745
|
if (!isDirectReturnBlock(ifStmt.thenStatement))
|
|
191617
191746
|
return null;
|
|
@@ -191621,7 +191750,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191621
191750
|
return null;
|
|
191622
191751
|
branches.push({ condition: ifStmt.expression, jsxReturn: jsxReturn ?? null });
|
|
191623
191752
|
if (ifStmt.elseStatement) {
|
|
191624
|
-
if (
|
|
191753
|
+
if (import_typescript11.default.isIfStatement(ifStmt.elseStatement)) {
|
|
191625
191754
|
current = ifStmt.elseStatement;
|
|
191626
191755
|
continue;
|
|
191627
191756
|
}
|
|
@@ -191643,18 +191772,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191643
191772
|
}
|
|
191644
191773
|
continue;
|
|
191645
191774
|
}
|
|
191646
|
-
if (
|
|
191775
|
+
if (import_typescript11.default.isSwitchStatement(stmt)) {
|
|
191647
191776
|
if (branches.length > 0)
|
|
191648
191777
|
return null;
|
|
191649
|
-
if (!
|
|
191778
|
+
if (!import_typescript11.default.isIdentifier(stmt.expression) && !import_typescript11.default.isPropertyAccessExpression(stmt.expression)) {
|
|
191650
191779
|
return null;
|
|
191651
191780
|
}
|
|
191652
|
-
const hasDefault = stmt.caseBlock.clauses.some((c) =>
|
|
191781
|
+
const hasDefault = stmt.caseBlock.clauses.some((c) => import_typescript11.default.isDefaultClause(c));
|
|
191653
191782
|
if (!hasDefault)
|
|
191654
191783
|
return null;
|
|
191655
191784
|
let pendingCases = [];
|
|
191656
191785
|
for (const clause of stmt.caseBlock.clauses) {
|
|
191657
|
-
if (
|
|
191786
|
+
if (import_typescript11.default.isCaseClause(clause) && clause.statements.length === 0) {
|
|
191658
191787
|
pendingCases.push(clause.expression);
|
|
191659
191788
|
continue;
|
|
191660
191789
|
}
|
|
@@ -191664,7 +191793,7 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191664
191793
|
return null;
|
|
191665
191794
|
if (!caseClauseIsDirectReturn(clause))
|
|
191666
191795
|
return null;
|
|
191667
|
-
if (
|
|
191796
|
+
if (import_typescript11.default.isCaseClause(clause)) {
|
|
191668
191797
|
branches.push({
|
|
191669
191798
|
condition: clause.expression,
|
|
191670
191799
|
jsxReturn: jsxReturn ?? null,
|
|
@@ -191685,18 +191814,18 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191685
191814
|
return null;
|
|
191686
191815
|
return { branches, fallback, switchDiscriminant: stmt.expression, preamble };
|
|
191687
191816
|
}
|
|
191688
|
-
if (
|
|
191817
|
+
if (import_typescript11.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191689
191818
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191690
|
-
if (
|
|
191819
|
+
if (import_typescript11.default.isJsxElement(expr) || import_typescript11.default.isJsxSelfClosingElement(expr) || import_typescript11.default.isJsxFragment(expr)) {
|
|
191691
191820
|
fallback = expr;
|
|
191692
|
-
} else if (expr.kind ===
|
|
191821
|
+
} else if (expr.kind === import_typescript11.default.SyntaxKind.NullKeyword) {} else {
|
|
191693
191822
|
return null;
|
|
191694
191823
|
}
|
|
191695
191824
|
continue;
|
|
191696
191825
|
}
|
|
191697
|
-
if (
|
|
191826
|
+
if (import_typescript11.default.isVariableStatement(stmt)) {
|
|
191698
191827
|
const declFlags = stmt.declarationList.flags;
|
|
191699
|
-
const isConstOrLet = (declFlags &
|
|
191828
|
+
const isConstOrLet = (declFlags & import_typescript11.default.NodeFlags.Const) !== 0 || (declFlags & import_typescript11.default.NodeFlags.Let) !== 0;
|
|
191700
191829
|
if (allowPreamble && isConstOrLet && branches.length === 0 && fallback === null) {
|
|
191701
191830
|
preamble.push(stmt);
|
|
191702
191831
|
continue;
|
|
@@ -191712,12 +191841,12 @@ function extractMultiReturnJsxBranches(body, allowPreamble = false) {
|
|
|
191712
191841
|
return { branches, fallback, preamble };
|
|
191713
191842
|
}
|
|
191714
191843
|
function isDirectReturnBlock(node) {
|
|
191715
|
-
if (
|
|
191844
|
+
if (import_typescript11.default.isReturnStatement(node))
|
|
191716
191845
|
return true;
|
|
191717
|
-
if (
|
|
191846
|
+
if (import_typescript11.default.isBlock(node)) {
|
|
191718
191847
|
let returnCount = 0;
|
|
191719
191848
|
for (const stmt of node.statements) {
|
|
191720
|
-
if (
|
|
191849
|
+
if (import_typescript11.default.isReturnStatement(stmt)) {
|
|
191721
191850
|
returnCount++;
|
|
191722
191851
|
continue;
|
|
191723
191852
|
}
|
|
@@ -191728,25 +191857,25 @@ function isDirectReturnBlock(node) {
|
|
|
191728
191857
|
return false;
|
|
191729
191858
|
}
|
|
191730
191859
|
function findNullReturnInBlock(node) {
|
|
191731
|
-
if (
|
|
191860
|
+
if (import_typescript11.default.isBlock(node)) {
|
|
191732
191861
|
for (const stmt of node.statements) {
|
|
191733
|
-
if (
|
|
191862
|
+
if (import_typescript11.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191734
191863
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191735
|
-
if (expr.kind ===
|
|
191864
|
+
if (expr.kind === import_typescript11.default.SyntaxKind.NullKeyword)
|
|
191736
191865
|
return true;
|
|
191737
191866
|
}
|
|
191738
191867
|
}
|
|
191739
191868
|
}
|
|
191740
|
-
if (
|
|
191869
|
+
if (import_typescript11.default.isReturnStatement(node) && node.expression) {
|
|
191741
191870
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191742
|
-
if (expr.kind ===
|
|
191871
|
+
if (expr.kind === import_typescript11.default.SyntaxKind.NullKeyword)
|
|
191743
191872
|
return true;
|
|
191744
191873
|
}
|
|
191745
191874
|
return false;
|
|
191746
191875
|
}
|
|
191747
191876
|
function findJsxReturnInCaseClause(clause) {
|
|
191748
191877
|
for (const stmt of clause.statements) {
|
|
191749
|
-
if (
|
|
191878
|
+
if (import_typescript11.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191750
191879
|
return extractJsxFromExpression(stmt.expression);
|
|
191751
191880
|
}
|
|
191752
191881
|
}
|
|
@@ -191756,12 +191885,12 @@ function caseClauseIsDirectReturn(clause) {
|
|
|
191756
191885
|
let returnCount = 0;
|
|
191757
191886
|
let seenReturn = false;
|
|
191758
191887
|
for (const stmt of clause.statements) {
|
|
191759
|
-
if (
|
|
191888
|
+
if (import_typescript11.default.isReturnStatement(stmt)) {
|
|
191760
191889
|
returnCount++;
|
|
191761
191890
|
seenReturn = true;
|
|
191762
191891
|
continue;
|
|
191763
191892
|
}
|
|
191764
|
-
if (
|
|
191893
|
+
if (import_typescript11.default.isBreakStatement(stmt)) {
|
|
191765
191894
|
if (!seenReturn)
|
|
191766
191895
|
return false;
|
|
191767
191896
|
continue;
|
|
@@ -191772,9 +191901,9 @@ function caseClauseIsDirectReturn(clause) {
|
|
|
191772
191901
|
}
|
|
191773
191902
|
function findNullReturnInCaseClause(clause) {
|
|
191774
191903
|
for (const stmt of clause.statements) {
|
|
191775
|
-
if (
|
|
191904
|
+
if (import_typescript11.default.isReturnStatement(stmt) && stmt.expression) {
|
|
191776
191905
|
const expr = unwrapJsxTransparent(stmt.expression);
|
|
191777
|
-
if (expr.kind ===
|
|
191906
|
+
if (expr.kind === import_typescript11.default.SyntaxKind.NullKeyword)
|
|
191778
191907
|
return true;
|
|
191779
191908
|
}
|
|
191780
191909
|
}
|
|
@@ -191785,26 +191914,26 @@ function isMultiReturnJsxFunctionBody(body) {
|
|
|
191785
191914
|
let hasJsxReturn = false;
|
|
191786
191915
|
let allReturnsAreJsxOrNull = true;
|
|
191787
191916
|
function visit2(node) {
|
|
191788
|
-
if (
|
|
191917
|
+
if (import_typescript11.default.isFunctionDeclaration(node) || import_typescript11.default.isFunctionExpression(node) || import_typescript11.default.isArrowFunction(node))
|
|
191789
191918
|
return;
|
|
191790
|
-
if (
|
|
191919
|
+
if (import_typescript11.default.isReturnStatement(node)) {
|
|
191791
191920
|
returnCount++;
|
|
191792
191921
|
if (!node.expression) {
|
|
191793
191922
|
allReturnsAreJsxOrNull = false;
|
|
191794
191923
|
return;
|
|
191795
191924
|
}
|
|
191796
191925
|
const expr = unwrapJsxTransparent(node.expression);
|
|
191797
|
-
const isJsx =
|
|
191798
|
-
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;
|
|
191799
191928
|
if (isJsx)
|
|
191800
191929
|
hasJsxReturn = true;
|
|
191801
191930
|
if (!isJsx && !isNull2)
|
|
191802
191931
|
allReturnsAreJsxOrNull = false;
|
|
191803
191932
|
return;
|
|
191804
191933
|
}
|
|
191805
|
-
|
|
191934
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
191806
191935
|
}
|
|
191807
|
-
|
|
191936
|
+
import_typescript11.default.forEachChild(body, visit2);
|
|
191808
191937
|
return returnCount > 1 && hasJsxReturn && allReturnsAreJsxOrNull;
|
|
191809
191938
|
}
|
|
191810
191939
|
function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
@@ -191874,7 +192003,7 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
|
191874
192003
|
}
|
|
191875
192004
|
}
|
|
191876
192005
|
}
|
|
191877
|
-
const isAsync = node.modifiers?.some((m) => m.kind ===
|
|
192006
|
+
const isAsync = node.modifiers?.some((m) => m.kind === import_typescript11.default.SyntaxKind.AsyncKeyword) ?? false;
|
|
191878
192007
|
const isGenerator = !!node.asteriskToken;
|
|
191879
192008
|
ctx.localFunctions.push({
|
|
191880
192009
|
name,
|
|
@@ -191895,10 +192024,10 @@ function collectFunction(node, ctx, _isModule, isExported = false) {
|
|
|
191895
192024
|
});
|
|
191896
192025
|
}
|
|
191897
192026
|
function extractValueBranches(node, ctx) {
|
|
191898
|
-
if (
|
|
192027
|
+
if (import_typescript11.default.isParenthesizedExpression(node)) {
|
|
191899
192028
|
return extractValueBranches(node.expression, ctx);
|
|
191900
192029
|
}
|
|
191901
|
-
if (
|
|
192030
|
+
if (import_typescript11.default.isConditionalExpression(node)) {
|
|
191902
192031
|
return [
|
|
191903
192032
|
...extractValueBranches(node.whenTrue, ctx),
|
|
191904
192033
|
...extractValueBranches(node.whenFalse, ctx)
|
|
@@ -191910,46 +192039,46 @@ function extractFreeIdentifiersFromNode(node) {
|
|
|
191910
192039
|
const ids = new Set;
|
|
191911
192040
|
const boundNames = new Set;
|
|
191912
192041
|
function addBindingNames(name, out) {
|
|
191913
|
-
if (
|
|
192042
|
+
if (import_typescript11.default.isIdentifier(name))
|
|
191914
192043
|
out.push(name.text);
|
|
191915
|
-
else if (
|
|
192044
|
+
else if (import_typescript11.default.isObjectBindingPattern(name))
|
|
191916
192045
|
name.elements.forEach((e) => addBindingNames(e.name, out));
|
|
191917
|
-
else if (
|
|
192046
|
+
else if (import_typescript11.default.isArrayBindingPattern(name))
|
|
191918
192047
|
name.elements.forEach((e) => {
|
|
191919
|
-
if (!
|
|
192048
|
+
if (!import_typescript11.default.isOmittedExpression(e))
|
|
191920
192049
|
addBindingNames(e.name, out);
|
|
191921
192050
|
});
|
|
191922
192051
|
}
|
|
191923
192052
|
function visit2(n) {
|
|
191924
|
-
if (
|
|
192053
|
+
if (import_typescript11.default.isTypeNode(n))
|
|
191925
192054
|
return;
|
|
191926
|
-
if (
|
|
192055
|
+
if (import_typescript11.default.isIdentifier(n)) {
|
|
191927
192056
|
const parent = n.parent;
|
|
191928
|
-
if (parent &&
|
|
192057
|
+
if (parent && import_typescript11.default.isPropertyAccessExpression(parent) && parent.name === n)
|
|
191929
192058
|
return;
|
|
191930
|
-
if (parent &&
|
|
192059
|
+
if (parent && import_typescript11.default.isPropertyAssignment(parent) && parent.name === n)
|
|
191931
192060
|
return;
|
|
191932
|
-
if (parent &&
|
|
192061
|
+
if (parent && import_typescript11.default.isParameter(parent) && parent.name === n)
|
|
191933
192062
|
return;
|
|
191934
|
-
if (parent &&
|
|
192063
|
+
if (parent && import_typescript11.default.isVariableDeclaration(parent) && parent.name === n)
|
|
191935
192064
|
return;
|
|
191936
192065
|
if (boundNames.has(n.text))
|
|
191937
192066
|
return;
|
|
191938
192067
|
ids.add(n.text);
|
|
191939
192068
|
return;
|
|
191940
192069
|
}
|
|
191941
|
-
if (
|
|
192070
|
+
if (import_typescript11.default.isArrowFunction(n)) {
|
|
191942
192071
|
const params = [];
|
|
191943
192072
|
for (const p of n.parameters)
|
|
191944
192073
|
addBindingNames(p.name, params);
|
|
191945
192074
|
for (const name of params)
|
|
191946
192075
|
boundNames.add(name);
|
|
191947
|
-
|
|
192076
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191948
192077
|
for (const name of params)
|
|
191949
192078
|
boundNames.delete(name);
|
|
191950
192079
|
return;
|
|
191951
192080
|
}
|
|
191952
|
-
|
|
192081
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191953
192082
|
}
|
|
191954
192083
|
visit2(node);
|
|
191955
192084
|
return ids;
|
|
@@ -191958,29 +192087,29 @@ function extractFreeTypeIdentifiersFromNode(node) {
|
|
|
191958
192087
|
const ids = new Set;
|
|
191959
192088
|
const boundTypeParams = new Set;
|
|
191960
192089
|
function rootName(name) {
|
|
191961
|
-
return
|
|
192090
|
+
return import_typescript11.default.isQualifiedName(name) ? rootName(name.left) : name;
|
|
191962
192091
|
}
|
|
191963
192092
|
function visit2(n) {
|
|
191964
|
-
if (
|
|
192093
|
+
if (import_typescript11.default.isTypeReferenceNode(n)) {
|
|
191965
192094
|
const name = rootName(n.typeName).text;
|
|
191966
192095
|
if (!boundTypeParams.has(name))
|
|
191967
192096
|
ids.add(name);
|
|
191968
192097
|
}
|
|
191969
|
-
if (
|
|
192098
|
+
if (import_typescript11.default.isTypeQueryNode(n)) {
|
|
191970
192099
|
const name = rootName(n.exprName).text;
|
|
191971
192100
|
if (!boundTypeParams.has(name))
|
|
191972
192101
|
ids.add(name);
|
|
191973
192102
|
}
|
|
191974
|
-
if (
|
|
192103
|
+
if (import_typescript11.default.isFunctionLike(n) && n.typeParameters && n.typeParameters.length > 0) {
|
|
191975
192104
|
const names = n.typeParameters.map((p) => p.name.text);
|
|
191976
192105
|
for (const p of names)
|
|
191977
192106
|
boundTypeParams.add(p);
|
|
191978
|
-
|
|
192107
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191979
192108
|
for (const p of names)
|
|
191980
192109
|
boundTypeParams.delete(p);
|
|
191981
192110
|
return;
|
|
191982
192111
|
}
|
|
191983
|
-
|
|
192112
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
191984
192113
|
}
|
|
191985
192114
|
visit2(node);
|
|
191986
192115
|
return ids;
|
|
@@ -191990,22 +192119,22 @@ function initializerShapeContainsJsx(node) {
|
|
|
191990
192119
|
function visit2(n) {
|
|
191991
192120
|
if (found)
|
|
191992
192121
|
return;
|
|
191993
|
-
if (
|
|
192122
|
+
if (import_typescript11.default.isJsxElement(n) || import_typescript11.default.isJsxSelfClosingElement(n) || import_typescript11.default.isJsxFragment(n)) {
|
|
191994
192123
|
found = true;
|
|
191995
192124
|
return;
|
|
191996
192125
|
}
|
|
191997
|
-
if (
|
|
192126
|
+
if (import_typescript11.default.isFunctionDeclaration(n) || import_typescript11.default.isFunctionExpression(n) || import_typescript11.default.isArrowFunction(n)) {
|
|
191998
192127
|
return;
|
|
191999
192128
|
}
|
|
192000
|
-
|
|
192129
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
192001
192130
|
}
|
|
192002
192131
|
visit2(node);
|
|
192003
192132
|
return found;
|
|
192004
192133
|
}
|
|
192005
192134
|
function isMapLikeCallWithJsx(node) {
|
|
192006
|
-
if (!
|
|
192135
|
+
if (!import_typescript11.default.isCallExpression(node))
|
|
192007
192136
|
return false;
|
|
192008
|
-
if (!
|
|
192137
|
+
if (!import_typescript11.default.isPropertyAccessExpression(node.expression))
|
|
192009
192138
|
return false;
|
|
192010
192139
|
const method = node.expression.name.text;
|
|
192011
192140
|
if (method !== "map" && method !== "flatMap")
|
|
@@ -192013,12 +192142,12 @@ function isMapLikeCallWithJsx(node) {
|
|
|
192013
192142
|
const callback = node.arguments[0];
|
|
192014
192143
|
if (!callback)
|
|
192015
192144
|
return false;
|
|
192016
|
-
if (!
|
|
192145
|
+
if (!import_typescript11.default.isArrowFunction(callback) && !import_typescript11.default.isFunctionExpression(callback))
|
|
192017
192146
|
return false;
|
|
192018
192147
|
return containsJsxDeep(callback.body);
|
|
192019
192148
|
}
|
|
192020
192149
|
function containsJsxDeep(node) {
|
|
192021
|
-
if (
|
|
192150
|
+
if (import_typescript11.default.isJsxElement(node) || import_typescript11.default.isJsxSelfClosingElement(node) || import_typescript11.default.isJsxFragment(node))
|
|
192022
192151
|
return true;
|
|
192023
192152
|
let found = false;
|
|
192024
192153
|
node.forEachChild((child) => {
|
|
@@ -192032,11 +192161,11 @@ function nodeContainsArrow(node) {
|
|
|
192032
192161
|
function visit2(n) {
|
|
192033
192162
|
if (found)
|
|
192034
192163
|
return;
|
|
192035
|
-
if (
|
|
192164
|
+
if (import_typescript11.default.isArrowFunction(n) || import_typescript11.default.isFunctionExpression(n)) {
|
|
192036
192165
|
found = true;
|
|
192037
192166
|
return;
|
|
192038
192167
|
}
|
|
192039
|
-
|
|
192168
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
192040
192169
|
}
|
|
192041
192170
|
visit2(node);
|
|
192042
192171
|
return found;
|
|
@@ -192084,20 +192213,20 @@ function collectModuleScopeReactive(decl, ctx, isExported) {
|
|
|
192084
192213
|
}));
|
|
192085
192214
|
}
|
|
192086
192215
|
function getSystemConstructKind(node) {
|
|
192087
|
-
if (
|
|
192216
|
+
if (import_typescript11.default.isCallExpression(node) && import_typescript11.default.isIdentifier(node.expression) && node.expression.text === "createContext")
|
|
192088
192217
|
return "createContext";
|
|
192089
|
-
if (
|
|
192218
|
+
if (import_typescript11.default.isNewExpression(node) && import_typescript11.default.isIdentifier(node.expression) && node.expression.text === "WeakMap")
|
|
192090
192219
|
return "weakMap";
|
|
192091
192220
|
return;
|
|
192092
192221
|
}
|
|
192093
192222
|
function collectConstant(node, ctx, _isModule, declarationKind = "const", isExported = false) {
|
|
192094
|
-
if (!_isModule &&
|
|
192223
|
+
if (!_isModule && import_typescript11.default.isObjectBindingPattern(node.name) && node.initializer && import_typescript11.default.isIdentifier(node.initializer) && ctx.propsObjectName === node.initializer.text) {
|
|
192095
192224
|
const propsName = node.initializer.text;
|
|
192096
192225
|
for (const el of node.name.elements) {
|
|
192097
|
-
if (!
|
|
192226
|
+
if (!import_typescript11.default.isBindingElement(el) || !import_typescript11.default.isIdentifier(el.name) || el.dotDotDotToken)
|
|
192098
192227
|
continue;
|
|
192099
192228
|
const localName = el.name.text;
|
|
192100
|
-
const sourceKey = el.propertyName &&
|
|
192229
|
+
const sourceKey = el.propertyName && import_typescript11.default.isIdentifier(el.propertyName) ? el.propertyName.text : localName;
|
|
192101
192230
|
const defaultValueExpr = el.initializer ? ctx.getJS(el.initializer) : undefined;
|
|
192102
192231
|
const baseValue = `${propsName}.${sourceKey}`;
|
|
192103
192232
|
const value2 = defaultValueExpr ? `${baseValue} ?? ${defaultValueExpr}` : baseValue;
|
|
@@ -192119,7 +192248,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192119
192248
|
}
|
|
192120
192249
|
return;
|
|
192121
192250
|
}
|
|
192122
|
-
if (!
|
|
192251
|
+
if (!import_typescript11.default.isIdentifier(node.name))
|
|
192123
192252
|
return;
|
|
192124
192253
|
if (isSignalDeclaration(node, ctx) || isMemoDeclaration(node, ctx))
|
|
192125
192254
|
return;
|
|
@@ -192137,9 +192266,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192137
192266
|
let isJsxFunction = false;
|
|
192138
192267
|
if (node.initializer) {
|
|
192139
192268
|
let init = node.initializer;
|
|
192140
|
-
while (
|
|
192269
|
+
while (import_typescript11.default.isParenthesizedExpression(init))
|
|
192141
192270
|
init = init.expression;
|
|
192142
|
-
if (
|
|
192271
|
+
if (import_typescript11.default.isJsxElement(init) || import_typescript11.default.isJsxSelfClosingElement(init) || import_typescript11.default.isJsxFragment(init)) {
|
|
192143
192272
|
isJsx = true;
|
|
192144
192273
|
ctx.jsxConstants.set(name, init);
|
|
192145
192274
|
} else if (initializerShapeContainsJsx(init)) {
|
|
@@ -192147,9 +192276,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192147
192276
|
} else if (isMapLikeCallWithJsx(init)) {
|
|
192148
192277
|
ctx.inlineableJsxConsts.set(name, init);
|
|
192149
192278
|
}
|
|
192150
|
-
if (
|
|
192279
|
+
if (import_typescript11.default.isArrowFunction(init)) {
|
|
192151
192280
|
const arrowBody = init.body;
|
|
192152
|
-
if (
|
|
192281
|
+
if (import_typescript11.default.isBlock(arrowBody)) {
|
|
192153
192282
|
const jsxReturn = extractSingleJsxReturn(arrowBody);
|
|
192154
192283
|
if (jsxReturn) {
|
|
192155
192284
|
isJsxFunction = true;
|
|
@@ -192169,9 +192298,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192169
192298
|
}
|
|
192170
192299
|
} else {
|
|
192171
192300
|
let body = arrowBody;
|
|
192172
|
-
while (
|
|
192301
|
+
while (import_typescript11.default.isParenthesizedExpression(body))
|
|
192173
192302
|
body = body.expression;
|
|
192174
|
-
if (
|
|
192303
|
+
if (import_typescript11.default.isJsxElement(body) || import_typescript11.default.isJsxSelfClosingElement(body) || import_typescript11.default.isJsxFragment(body)) {
|
|
192175
192304
|
isJsxFunction = true;
|
|
192176
192305
|
ctx.jsxFunctions.set(name, {
|
|
192177
192306
|
jsxReturn: body,
|
|
@@ -192184,9 +192313,9 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192184
192313
|
let valueBranches;
|
|
192185
192314
|
if (node.initializer) {
|
|
192186
192315
|
let inner = node.initializer;
|
|
192187
|
-
while (
|
|
192316
|
+
while (import_typescript11.default.isParenthesizedExpression(inner))
|
|
192188
192317
|
inner = inner.expression;
|
|
192189
|
-
if (
|
|
192318
|
+
if (import_typescript11.default.isConditionalExpression(inner)) {
|
|
192190
192319
|
valueBranches = extractValueBranches(node.initializer, ctx);
|
|
192191
192320
|
}
|
|
192192
192321
|
}
|
|
@@ -192264,7 +192393,7 @@ function collectConstant(node, ctx, _isModule, declarationKind = "const", isExpo
|
|
|
192264
192393
|
function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
192265
192394
|
const checkComments = (targetNode) => {
|
|
192266
192395
|
const fullStart = targetNode.getFullStart();
|
|
192267
|
-
const leadingComments =
|
|
192396
|
+
const leadingComments = import_typescript11.default.getLeadingCommentRanges(sourceFile.getFullText(), fullStart);
|
|
192268
192397
|
if (!leadingComments)
|
|
192269
192398
|
return false;
|
|
192270
192399
|
for (const range of leadingComments) {
|
|
@@ -192277,10 +192406,10 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
|
192277
192406
|
};
|
|
192278
192407
|
if (checkComments(node))
|
|
192279
192408
|
return true;
|
|
192280
|
-
if (
|
|
192409
|
+
if (import_typescript11.default.isArrowFunction(node)) {
|
|
192281
192410
|
let current = node.parent;
|
|
192282
192411
|
while (current) {
|
|
192283
|
-
if (
|
|
192412
|
+
if (import_typescript11.default.isVariableStatement(current)) {
|
|
192284
192413
|
if (checkComments(current))
|
|
192285
192414
|
return true;
|
|
192286
192415
|
break;
|
|
@@ -192291,7 +192420,7 @@ function hasIgnoreDirective(node, sourceFile, ruleId) {
|
|
|
192291
192420
|
return false;
|
|
192292
192421
|
}
|
|
192293
192422
|
function extractProps(param, ctx) {
|
|
192294
|
-
if (
|
|
192423
|
+
if (import_typescript11.default.isObjectBindingPattern(param.name)) {
|
|
192295
192424
|
const componentNode = ctx.componentNode;
|
|
192296
192425
|
const ignored = !!(componentNode && hasIgnoreDirective(componentNode, ctx.sourceFile, "props-destructuring"));
|
|
192297
192426
|
ctx.propsDestructuring = {
|
|
@@ -192300,14 +192429,14 @@ function extractProps(param, ctx) {
|
|
|
192300
192429
|
};
|
|
192301
192430
|
const memberTypes = param.type ? collectMemberTypes(param.type, ctx) : null;
|
|
192302
192431
|
for (const element of param.name.elements) {
|
|
192303
|
-
if (
|
|
192432
|
+
if (import_typescript11.default.isBindingElement(element) && import_typescript11.default.isIdentifier(element.name)) {
|
|
192304
192433
|
const localName = element.name.text;
|
|
192305
192434
|
const defaultValue = element.initializer ? ctx.getJS(element.initializer) : undefined;
|
|
192306
192435
|
if (element.dotDotDotToken) {
|
|
192307
192436
|
ctx.restPropsName = localName;
|
|
192308
192437
|
continue;
|
|
192309
192438
|
}
|
|
192310
|
-
const sourcePropName = element.propertyName &&
|
|
192439
|
+
const sourcePropName = element.propertyName && import_typescript11.default.isIdentifier(element.propertyName) ? element.propertyName.text : localName;
|
|
192311
192440
|
const member = memberTypes?.get(sourcePropName);
|
|
192312
192441
|
const resolvedType = member?.type ?? { kind: "unknown", raw: "unknown" };
|
|
192313
192442
|
const defaultContainsArrow = element.initializer ? nodeContainsArrow(element.initializer) : false;
|
|
@@ -192331,7 +192460,7 @@ function extractProps(param, ctx) {
|
|
|
192331
192460
|
}
|
|
192332
192461
|
}
|
|
192333
192462
|
}
|
|
192334
|
-
if (
|
|
192463
|
+
if (import_typescript11.default.isIdentifier(param.name)) {
|
|
192335
192464
|
ctx.propsObjectName = param.name.text;
|
|
192336
192465
|
if (param.type) {
|
|
192337
192466
|
extractPropsFromType(param.type, ctx);
|
|
@@ -192342,24 +192471,24 @@ function extractProps(param, ctx) {
|
|
|
192342
192471
|
}
|
|
192343
192472
|
}
|
|
192344
192473
|
function collectTypeKeys(typeNode, ctx) {
|
|
192345
|
-
if (
|
|
192474
|
+
if (import_typescript11.default.isTypeLiteralNode(typeNode)) {
|
|
192346
192475
|
return collectKeysFromMembers(typeNode.members, ctx);
|
|
192347
192476
|
}
|
|
192348
|
-
if (
|
|
192477
|
+
if (import_typescript11.default.isTypeReferenceNode(typeNode)) {
|
|
192349
192478
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192350
192479
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192351
192480
|
if (!typeDecl)
|
|
192352
192481
|
return null;
|
|
192353
|
-
if (
|
|
192482
|
+
if (import_typescript11.default.isInterfaceDeclaration(typeDecl)) {
|
|
192354
192483
|
if (typeDecl.heritageClauses && typeDecl.heritageClauses.length > 0)
|
|
192355
192484
|
return null;
|
|
192356
192485
|
return collectKeysFromMembers(typeDecl.members, ctx);
|
|
192357
192486
|
}
|
|
192358
|
-
if (
|
|
192359
|
-
if (
|
|
192487
|
+
if (import_typescript11.default.isTypeAliasDeclaration(typeDecl)) {
|
|
192488
|
+
if (import_typescript11.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192360
192489
|
return collectKeysFromMembers(typeDecl.type.members, ctx);
|
|
192361
192490
|
}
|
|
192362
|
-
if (
|
|
192491
|
+
if (import_typescript11.default.isIntersectionTypeNode(typeDecl.type)) {
|
|
192363
192492
|
return null;
|
|
192364
192493
|
}
|
|
192365
192494
|
}
|
|
@@ -192369,9 +192498,9 @@ function collectTypeKeys(typeNode, ctx) {
|
|
|
192369
192498
|
function collectKeysFromMembers(members, ctx) {
|
|
192370
192499
|
const keys = [];
|
|
192371
192500
|
for (const member of members) {
|
|
192372
|
-
if (
|
|
192501
|
+
if (import_typescript11.default.isIndexSignatureDeclaration(member))
|
|
192373
192502
|
return null;
|
|
192374
|
-
if (
|
|
192503
|
+
if (import_typescript11.default.isPropertySignature(member) && member.name) {
|
|
192375
192504
|
keys.push(member.name.getText(ctx.sourceFile));
|
|
192376
192505
|
}
|
|
192377
192506
|
}
|
|
@@ -192395,7 +192524,7 @@ function collectMemberTypes(typeNode, ctx) {
|
|
|
192395
192524
|
const fromMembers = (members) => {
|
|
192396
192525
|
const map = new Map;
|
|
192397
192526
|
for (const member of members) {
|
|
192398
|
-
if (
|
|
192527
|
+
if (import_typescript11.default.isPropertySignature(member) && member.name) {
|
|
192399
192528
|
const info = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : null;
|
|
192400
192529
|
map.set(member.name.getText(ctx.sourceFile), {
|
|
192401
192530
|
type: info && isResolvableMemberType(info) ? info : null,
|
|
@@ -192405,35 +192534,35 @@ function collectMemberTypes(typeNode, ctx) {
|
|
|
192405
192534
|
}
|
|
192406
192535
|
return map;
|
|
192407
192536
|
};
|
|
192408
|
-
if (
|
|
192537
|
+
if (import_typescript11.default.isTypeLiteralNode(typeNode)) {
|
|
192409
192538
|
return fromMembers(typeNode.members);
|
|
192410
192539
|
}
|
|
192411
|
-
if (
|
|
192540
|
+
if (import_typescript11.default.isTypeReferenceNode(typeNode)) {
|
|
192412
192541
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192413
192542
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192414
192543
|
if (!typeDecl)
|
|
192415
192544
|
return null;
|
|
192416
|
-
if (
|
|
192545
|
+
if (import_typescript11.default.isInterfaceDeclaration(typeDecl)) {
|
|
192417
192546
|
return fromMembers(typeDecl.members);
|
|
192418
192547
|
}
|
|
192419
|
-
if (
|
|
192548
|
+
if (import_typescript11.default.isTypeAliasDeclaration(typeDecl) && import_typescript11.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192420
192549
|
return fromMembers(typeDecl.type.members);
|
|
192421
192550
|
}
|
|
192422
192551
|
}
|
|
192423
192552
|
return null;
|
|
192424
192553
|
}
|
|
192425
192554
|
function extractPropsFromType(typeNode, ctx) {
|
|
192426
|
-
if (
|
|
192555
|
+
if (import_typescript11.default.isTypeLiteralNode(typeNode)) {
|
|
192427
192556
|
extractPropsFromTypeMembers(typeNode.members, ctx);
|
|
192428
192557
|
return;
|
|
192429
192558
|
}
|
|
192430
|
-
if (
|
|
192559
|
+
if (import_typescript11.default.isTypeReferenceNode(typeNode)) {
|
|
192431
192560
|
const typeName = typeNode.typeName.getText(ctx.sourceFile);
|
|
192432
192561
|
const typeDecl = findTypeDeclaration(typeName, ctx.sourceFile);
|
|
192433
192562
|
if (typeDecl) {
|
|
192434
|
-
if (
|
|
192563
|
+
if (import_typescript11.default.isInterfaceDeclaration(typeDecl)) {
|
|
192435
192564
|
extractPropsFromTypeMembers(typeDecl.members, ctx);
|
|
192436
|
-
} else if (
|
|
192565
|
+
} else if (import_typescript11.default.isTypeAliasDeclaration(typeDecl) && import_typescript11.default.isTypeLiteralNode(typeDecl.type)) {
|
|
192437
192566
|
extractPropsFromTypeMembers(typeDecl.type.members, ctx);
|
|
192438
192567
|
}
|
|
192439
192568
|
}
|
|
@@ -192441,7 +192570,7 @@ function extractPropsFromType(typeNode, ctx) {
|
|
|
192441
192570
|
}
|
|
192442
192571
|
function extractPropsFromTypeMembers(members, ctx) {
|
|
192443
192572
|
for (const member of members) {
|
|
192444
|
-
if (
|
|
192573
|
+
if (import_typescript11.default.isPropertySignature(member) && member.name) {
|
|
192445
192574
|
const propName = member.name.getText(ctx.sourceFile);
|
|
192446
192575
|
const isOptional = !!member.questionToken;
|
|
192447
192576
|
const propType = member.type ? typeNodeToTypeInfo(member.type, ctx.sourceFile) : { kind: "unknown", raw: "unknown" };
|
|
@@ -192457,17 +192586,17 @@ function extractPropsFromTypeMembers(members, ctx) {
|
|
|
192457
192586
|
function findTypeDeclaration(typeName, sourceFile) {
|
|
192458
192587
|
let result;
|
|
192459
192588
|
function visit2(node) {
|
|
192460
|
-
if (
|
|
192589
|
+
if (import_typescript11.default.isInterfaceDeclaration(node) && node.name.text === typeName) {
|
|
192461
192590
|
result = node;
|
|
192462
192591
|
return;
|
|
192463
192592
|
}
|
|
192464
|
-
if (
|
|
192593
|
+
if (import_typescript11.default.isTypeAliasDeclaration(node) && node.name.text === typeName) {
|
|
192465
192594
|
result = node;
|
|
192466
192595
|
return;
|
|
192467
192596
|
}
|
|
192468
|
-
|
|
192597
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
192469
192598
|
}
|
|
192470
|
-
|
|
192599
|
+
import_typescript11.default.forEachChild(sourceFile, visit2);
|
|
192471
192600
|
return result;
|
|
192472
192601
|
}
|
|
192473
192602
|
function inferTypeFromValue(value) {
|
|
@@ -192513,12 +192642,12 @@ function inferTypeFromValue(value) {
|
|
|
192513
192642
|
}
|
|
192514
192643
|
function collectCalledIdentifiers(code2) {
|
|
192515
192644
|
const called = new Set;
|
|
192516
|
-
const sf =
|
|
192645
|
+
const sf = import_typescript11.default.createSourceFile("__deps__.tsx", code2, import_typescript11.default.ScriptTarget.Latest, false, import_typescript11.default.ScriptKind.TSX);
|
|
192517
192646
|
const visit2 = (node) => {
|
|
192518
|
-
if (
|
|
192647
|
+
if (import_typescript11.default.isCallExpression(node) && import_typescript11.default.isIdentifier(node.expression)) {
|
|
192519
192648
|
called.add(node.expression.text);
|
|
192520
192649
|
}
|
|
192521
|
-
|
|
192650
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
192522
192651
|
};
|
|
192523
192652
|
visit2(sf);
|
|
192524
192653
|
return called;
|
|
@@ -192616,16 +192745,16 @@ function isResolvableComponentSource(source) {
|
|
|
192616
192745
|
function collectJsxComponentTags(sourceFile) {
|
|
192617
192746
|
const tags = new Set;
|
|
192618
192747
|
function visit2(node) {
|
|
192619
|
-
if (
|
|
192748
|
+
if (import_typescript11.default.isJsxOpeningElement(node) || import_typescript11.default.isJsxSelfClosingElement(node)) {
|
|
192620
192749
|
const tagName = node.tagName;
|
|
192621
|
-
if (
|
|
192750
|
+
if (import_typescript11.default.isIdentifier(tagName)) {
|
|
192622
192751
|
const first = tagName.text.charAt(0);
|
|
192623
192752
|
if (first >= "A" && first <= "Z") {
|
|
192624
192753
|
tags.add(tagName.text);
|
|
192625
192754
|
}
|
|
192626
192755
|
}
|
|
192627
192756
|
}
|
|
192628
|
-
|
|
192757
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
192629
192758
|
}
|
|
192630
192759
|
visit2(sourceFile);
|
|
192631
192760
|
return tags;
|
|
@@ -192704,18 +192833,18 @@ function fileHasUseClientDirective(filePath) {
|
|
|
192704
192833
|
} catch {
|
|
192705
192834
|
return true;
|
|
192706
192835
|
}
|
|
192707
|
-
const sf =
|
|
192836
|
+
const sf = import_typescript11.default.createSourceFile(filePath, content, import_typescript11.default.ScriptTarget.Latest, false, import_typescript11.default.ScriptKind.TSX);
|
|
192708
192837
|
let found = false;
|
|
192709
192838
|
function visit2(node) {
|
|
192710
192839
|
if (found)
|
|
192711
192840
|
return;
|
|
192712
|
-
if (
|
|
192841
|
+
if (import_typescript11.default.isExpressionStatement(node) && import_typescript11.default.isStringLiteral(node.expression)) {
|
|
192713
192842
|
if (node.expression.text === "use client") {
|
|
192714
192843
|
found = true;
|
|
192715
192844
|
return;
|
|
192716
192845
|
}
|
|
192717
192846
|
}
|
|
192718
|
-
|
|
192847
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
192719
192848
|
}
|
|
192720
192849
|
visit2(sf);
|
|
192721
192850
|
return found;
|
|
@@ -192801,13 +192930,13 @@ var REACTIVE_PRIMITIVES = new Set([
|
|
|
192801
192930
|
"onCleanup"
|
|
192802
192931
|
]);
|
|
192803
192932
|
function prescanReactiveFactoriesInSource(source, filePath) {
|
|
192804
|
-
const sourceFile =
|
|
192933
|
+
const sourceFile = import_typescript11.default.createSourceFile(filePath + ".prescan", source, import_typescript11.default.ScriptTarget.Latest, true, import_typescript11.default.ScriptKind.TSX);
|
|
192805
192934
|
const factories = new Map;
|
|
192806
192935
|
const declined = new Map;
|
|
192807
192936
|
const reactiveShaped = new Set;
|
|
192808
192937
|
const cleanFactoryImports = new Set;
|
|
192809
192938
|
function visitTop(node) {
|
|
192810
|
-
if (
|
|
192939
|
+
if (import_typescript11.default.isFunctionDeclaration(node) && node.name && node.body) {
|
|
192811
192940
|
const det = detectReactiveFactory(node, sourceFile, filePath);
|
|
192812
192941
|
if (!det)
|
|
192813
192942
|
return;
|
|
@@ -192824,7 +192953,7 @@ function prescanReactiveFactoriesInSource(source, filePath) {
|
|
|
192824
192953
|
}
|
|
192825
192954
|
}
|
|
192826
192955
|
}
|
|
192827
|
-
|
|
192956
|
+
import_typescript11.default.forEachChild(sourceFile, visitTop);
|
|
192828
192957
|
const result = { factories, declined, reactiveShaped, cleanFactoryImports, sourceFile };
|
|
192829
192958
|
prescanImportedReactiveFactories(sourceFile, filePath, result);
|
|
192830
192959
|
return result;
|
|
@@ -192841,15 +192970,15 @@ function toComponentRelativeSpecifier(resolvedAbs, componentFilePath) {
|
|
|
192841
192970
|
function buildEntryImportIndex(sf, filePath) {
|
|
192842
192971
|
const index = new Map;
|
|
192843
192972
|
for (const stmt of sf.statements) {
|
|
192844
|
-
if (!
|
|
192973
|
+
if (!import_typescript11.default.isImportDeclaration(stmt))
|
|
192845
192974
|
continue;
|
|
192846
|
-
if (!
|
|
192975
|
+
if (!import_typescript11.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192847
192976
|
continue;
|
|
192848
192977
|
const src = stmt.moduleSpecifier.text;
|
|
192849
192978
|
const targetKey = src.startsWith("./") || src.startsWith("../") ? resolveRelativeImportToFile(src, filePath) ?? "unresolved:" + src : src;
|
|
192850
192979
|
const wholeTypeOnly = stmt.importClause?.isTypeOnly === true;
|
|
192851
192980
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
192852
|
-
if (namedBindings &&
|
|
192981
|
+
if (namedBindings && import_typescript11.default.isNamedImports(namedBindings)) {
|
|
192853
192982
|
for (const el of namedBindings.elements) {
|
|
192854
192983
|
index.set(el.name.text, {
|
|
192855
192984
|
targetKey,
|
|
@@ -192864,31 +192993,31 @@ function buildEntryImportIndex(sf, filePath) {
|
|
|
192864
192993
|
function collectEntryBindingNames(sf) {
|
|
192865
192994
|
const names = new Set;
|
|
192866
192995
|
function visit2(node) {
|
|
192867
|
-
if (
|
|
192996
|
+
if (import_typescript11.default.isImportDeclaration(node) && node.importClause) {
|
|
192868
192997
|
if (node.importClause.name)
|
|
192869
192998
|
names.add(node.importClause.name.text);
|
|
192870
192999
|
const namedBindings = node.importClause.namedBindings;
|
|
192871
|
-
if (namedBindings &&
|
|
193000
|
+
if (namedBindings && import_typescript11.default.isNamedImports(namedBindings)) {
|
|
192872
193001
|
for (const el of namedBindings.elements)
|
|
192873
193002
|
names.add(el.name.text);
|
|
192874
193003
|
}
|
|
192875
|
-
if (namedBindings &&
|
|
193004
|
+
if (namedBindings && import_typescript11.default.isNamespaceImport(namedBindings)) {
|
|
192876
193005
|
names.add(namedBindings.name.text);
|
|
192877
193006
|
}
|
|
192878
193007
|
}
|
|
192879
|
-
if (
|
|
193008
|
+
if (import_typescript11.default.isVariableDeclaration(node)) {
|
|
192880
193009
|
const out = [];
|
|
192881
193010
|
addBindingNames(node.name, out);
|
|
192882
193011
|
for (const n of out)
|
|
192883
193012
|
names.add(n);
|
|
192884
193013
|
}
|
|
192885
|
-
if ((
|
|
193014
|
+
if ((import_typescript11.default.isFunctionDeclaration(node) || import_typescript11.default.isClassDeclaration(node) || import_typescript11.default.isEnumDeclaration(node)) && node.name) {
|
|
192886
193015
|
names.add(node.name.text);
|
|
192887
193016
|
}
|
|
192888
|
-
if ((
|
|
193017
|
+
if ((import_typescript11.default.isTypeAliasDeclaration(node) || import_typescript11.default.isInterfaceDeclaration(node)) && node.name) {
|
|
192889
193018
|
names.add(node.name.text);
|
|
192890
193019
|
}
|
|
192891
|
-
if (
|
|
193020
|
+
if (import_typescript11.default.isFunctionLike(node)) {
|
|
192892
193021
|
for (const p of node.parameters) {
|
|
192893
193022
|
const out = [];
|
|
192894
193023
|
addBindingNames(p.name, out);
|
|
@@ -192896,7 +193025,7 @@ function collectEntryBindingNames(sf) {
|
|
|
192896
193025
|
names.add(n);
|
|
192897
193026
|
}
|
|
192898
193027
|
}
|
|
192899
|
-
|
|
193028
|
+
import_typescript11.default.forEachChild(node, visit2);
|
|
192900
193029
|
}
|
|
192901
193030
|
visit2(sf);
|
|
192902
193031
|
return names;
|
|
@@ -192905,19 +193034,19 @@ var MAX_REEXPORT_HOPS = 1;
|
|
|
192905
193034
|
function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
192906
193035
|
const candidateCallees = new Set;
|
|
192907
193036
|
function collectCandidates(node) {
|
|
192908
|
-
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)) {
|
|
192909
193038
|
candidateCallees.add(node.initializer.expression.text);
|
|
192910
193039
|
}
|
|
192911
|
-
|
|
193040
|
+
import_typescript11.default.forEachChild(node, collectCandidates);
|
|
192912
193041
|
}
|
|
192913
193042
|
collectCandidates(entrySourceFile);
|
|
192914
193043
|
if (candidateCallees.size === 0)
|
|
192915
193044
|
return;
|
|
192916
193045
|
const importsToCheck = [];
|
|
192917
193046
|
for (const stmt of entrySourceFile.statements) {
|
|
192918
|
-
if (!
|
|
193047
|
+
if (!import_typescript11.default.isImportDeclaration(stmt))
|
|
192919
193048
|
continue;
|
|
192920
|
-
if (!
|
|
193049
|
+
if (!import_typescript11.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192921
193050
|
continue;
|
|
192922
193051
|
const src = stmt.moduleSpecifier.text;
|
|
192923
193052
|
if (!src.startsWith("./") && !src.startsWith("../"))
|
|
@@ -192925,7 +193054,7 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192925
193054
|
if (stmt.importClause?.isTypeOnly)
|
|
192926
193055
|
continue;
|
|
192927
193056
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
192928
|
-
if (!namedBindings || !
|
|
193057
|
+
if (!namedBindings || !import_typescript11.default.isNamedImports(namedBindings))
|
|
192929
193058
|
continue;
|
|
192930
193059
|
const specs = [];
|
|
192931
193060
|
for (const el of namedBindings.elements) {
|
|
@@ -192963,14 +193092,14 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192963
193092
|
helperCache.set(abs, "clean");
|
|
192964
193093
|
return "clean";
|
|
192965
193094
|
}
|
|
192966
|
-
const sf =
|
|
193095
|
+
const sf = import_typescript11.default.createSourceFile(abs + ".prescan", content, import_typescript11.default.ScriptTarget.Latest, true, import_typescript11.default.ScriptKind.TSX);
|
|
192967
193096
|
const localFns = new Map;
|
|
192968
193097
|
const exportedFns = new Map;
|
|
192969
193098
|
for (const stmt of sf.statements) {
|
|
192970
|
-
if (
|
|
193099
|
+
if (import_typescript11.default.isFunctionDeclaration(stmt) && stmt.name && stmt.body) {
|
|
192971
193100
|
localFns.set(stmt.name.text, stmt);
|
|
192972
|
-
const hasExportModifier = stmt.modifiers?.some((m) => m.kind ===
|
|
192973
|
-
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;
|
|
192974
193103
|
if (hasExportModifier && !hasDefaultModifier) {
|
|
192975
193104
|
exportedFns.set(stmt.name.text, stmt);
|
|
192976
193105
|
}
|
|
@@ -192979,10 +193108,10 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192979
193108
|
const reexports = new Map;
|
|
192980
193109
|
let hasStarReexport = false;
|
|
192981
193110
|
for (const stmt of sf.statements) {
|
|
192982
|
-
if (!
|
|
193111
|
+
if (!import_typescript11.default.isExportDeclaration(stmt) || stmt.isTypeOnly)
|
|
192983
193112
|
continue;
|
|
192984
193113
|
if (!stmt.moduleSpecifier) {
|
|
192985
|
-
if (stmt.exportClause &&
|
|
193114
|
+
if (stmt.exportClause && import_typescript11.default.isNamedExports(stmt.exportClause)) {
|
|
192986
193115
|
for (const el of stmt.exportClause.elements) {
|
|
192987
193116
|
if (el.isTypeOnly)
|
|
192988
193117
|
continue;
|
|
@@ -192993,9 +193122,9 @@ function prescanImportedReactiveFactories(entrySourceFile, filePath, result) {
|
|
|
192993
193122
|
}
|
|
192994
193123
|
continue;
|
|
192995
193124
|
}
|
|
192996
|
-
if (!
|
|
193125
|
+
if (!import_typescript11.default.isStringLiteral(stmt.moduleSpecifier))
|
|
192997
193126
|
continue;
|
|
192998
|
-
if (stmt.exportClause &&
|
|
193127
|
+
if (stmt.exportClause && import_typescript11.default.isNamedExports(stmt.exportClause)) {
|
|
192999
193128
|
for (const el of stmt.exportClause.elements) {
|
|
193000
193129
|
if (el.isTypeOnly)
|
|
193001
193130
|
continue;
|
|
@@ -193145,7 +193274,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
193145
193274
|
const importedTypes = new Map;
|
|
193146
193275
|
const imported = new Map;
|
|
193147
193276
|
for (const stmt of sf.statements) {
|
|
193148
|
-
if (
|
|
193277
|
+
if (import_typescript11.default.isVariableStatement(stmt)) {
|
|
193149
193278
|
const out = [];
|
|
193150
193279
|
for (const decl of stmt.declarationList.declarations) {
|
|
193151
193280
|
addBindingNames(decl.name, out);
|
|
@@ -193154,16 +193283,16 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
193154
193283
|
local.add(n);
|
|
193155
193284
|
continue;
|
|
193156
193285
|
}
|
|
193157
|
-
if ((
|
|
193286
|
+
if ((import_typescript11.default.isFunctionDeclaration(stmt) || import_typescript11.default.isClassDeclaration(stmt) || import_typescript11.default.isEnumDeclaration(stmt)) && stmt.name) {
|
|
193158
193287
|
local.add(stmt.name.text);
|
|
193159
193288
|
continue;
|
|
193160
193289
|
}
|
|
193161
|
-
if ((
|
|
193290
|
+
if ((import_typescript11.default.isTypeAliasDeclaration(stmt) || import_typescript11.default.isInterfaceDeclaration(stmt)) && stmt.name) {
|
|
193162
193291
|
localTypes.add(stmt.name.text);
|
|
193163
193292
|
continue;
|
|
193164
193293
|
}
|
|
193165
|
-
if (
|
|
193166
|
-
if (!
|
|
193294
|
+
if (import_typescript11.default.isImportDeclaration(stmt)) {
|
|
193295
|
+
if (!import_typescript11.default.isStringLiteral(stmt.moduleSpecifier))
|
|
193167
193296
|
continue;
|
|
193168
193297
|
const src = stmt.moduleSpecifier.text;
|
|
193169
193298
|
if (src === "@barefootjs/client" || src === "@barefootjs/client/runtime")
|
|
@@ -193172,7 +193301,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
193172
193301
|
if (stmt.importClause?.name)
|
|
193173
193302
|
(wholeTypeOnly ? localTypes : local).add(stmt.importClause.name.text);
|
|
193174
193303
|
const namedBindings = stmt.importClause?.namedBindings;
|
|
193175
|
-
if (namedBindings &&
|
|
193304
|
+
if (namedBindings && import_typescript11.default.isNamedImports(namedBindings)) {
|
|
193176
193305
|
for (const el of namedBindings.elements) {
|
|
193177
193306
|
const entry = { source: src, exportedName: (el.propertyName ?? el.name).text };
|
|
193178
193307
|
if (wholeTypeOnly || el.isTypeOnly)
|
|
@@ -193181,7 +193310,7 @@ function collectHelperModuleValueBindings(sf) {
|
|
|
193181
193310
|
imported.set(el.name.text, entry);
|
|
193182
193311
|
}
|
|
193183
193312
|
}
|
|
193184
|
-
if (namedBindings &&
|
|
193313
|
+
if (namedBindings && import_typescript11.default.isNamespaceImport(namedBindings)) {
|
|
193185
193314
|
(wholeTypeOnly ? localTypes : local).add(namedBindings.name.text);
|
|
193186
193315
|
}
|
|
193187
193316
|
}
|
|
@@ -193248,11 +193377,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193248
193377
|
function checkForReactive(n) {
|
|
193249
193378
|
if (hasReactiveCall)
|
|
193250
193379
|
return;
|
|
193251
|
-
if (
|
|
193380
|
+
if (import_typescript11.default.isCallExpression(n) && import_typescript11.default.isIdentifier(n.expression) && REACTIVE_PRIMITIVES.has(n.expression.text)) {
|
|
193252
193381
|
hasReactiveCall = true;
|
|
193253
193382
|
return;
|
|
193254
193383
|
}
|
|
193255
|
-
|
|
193384
|
+
import_typescript11.default.forEachChild(n, checkForReactive);
|
|
193256
193385
|
}
|
|
193257
193386
|
checkForReactive(node.body);
|
|
193258
193387
|
if (!hasReactiveCall)
|
|
@@ -193260,29 +193389,29 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193260
193389
|
const loc = getSourceLocation(node, sourceFile, filePath);
|
|
193261
193390
|
let totalReturnCount = 0;
|
|
193262
193391
|
function countReturns(n) {
|
|
193263
|
-
if (
|
|
193392
|
+
if (import_typescript11.default.isFunctionLike(n))
|
|
193264
193393
|
return;
|
|
193265
|
-
if (
|
|
193394
|
+
if (import_typescript11.default.isReturnStatement(n)) {
|
|
193266
193395
|
totalReturnCount++;
|
|
193267
193396
|
return;
|
|
193268
193397
|
}
|
|
193269
|
-
|
|
193398
|
+
import_typescript11.default.forEachChild(n, countReturns);
|
|
193270
193399
|
}
|
|
193271
|
-
|
|
193400
|
+
import_typescript11.default.forEachChild(node.body, countReturns);
|
|
193272
193401
|
let returnExpr = null;
|
|
193273
193402
|
let returnCount = 0;
|
|
193274
193403
|
for (const stmt of node.body.statements) {
|
|
193275
|
-
if (!
|
|
193404
|
+
if (!import_typescript11.default.isReturnStatement(stmt))
|
|
193276
193405
|
continue;
|
|
193277
193406
|
returnCount++;
|
|
193278
193407
|
if (!stmt.expression)
|
|
193279
193408
|
return { kind: "reactive-shaped" };
|
|
193280
193409
|
let expr = stmt.expression;
|
|
193281
|
-
while (
|
|
193410
|
+
while (import_typescript11.default.isParenthesizedExpression(expr))
|
|
193282
193411
|
expr = expr.expression;
|
|
193283
|
-
if (
|
|
193412
|
+
if (import_typescript11.default.isAsExpression(expr))
|
|
193284
193413
|
expr = expr.expression;
|
|
193285
|
-
if (
|
|
193414
|
+
if (import_typescript11.default.isTypeAssertionExpression(expr))
|
|
193286
193415
|
expr = expr.expression;
|
|
193287
193416
|
returnExpr = expr;
|
|
193288
193417
|
}
|
|
@@ -193290,18 +193419,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193290
193419
|
return { kind: "reactive-shaped" };
|
|
193291
193420
|
const returnTupleIdentifiers = [];
|
|
193292
193421
|
let returnKind;
|
|
193293
|
-
if (
|
|
193422
|
+
if (import_typescript11.default.isArrayLiteralExpression(returnExpr)) {
|
|
193294
193423
|
returnKind = "tuple";
|
|
193295
193424
|
for (const el of returnExpr.elements) {
|
|
193296
|
-
if (!
|
|
193425
|
+
if (!import_typescript11.default.isIdentifier(el))
|
|
193297
193426
|
return { kind: "reactive-shaped" };
|
|
193298
193427
|
returnTupleIdentifiers.push(el.text);
|
|
193299
193428
|
}
|
|
193300
193429
|
if (returnTupleIdentifiers.length === 0)
|
|
193301
193430
|
return { kind: "reactive-shaped" };
|
|
193302
|
-
} else if (
|
|
193431
|
+
} else if (import_typescript11.default.isObjectLiteralExpression(returnExpr)) {
|
|
193303
193432
|
returnKind = "object";
|
|
193304
|
-
const hasNonShorthand = returnExpr.properties.some((p) => !
|
|
193433
|
+
const hasNonShorthand = returnExpr.properties.some((p) => !import_typescript11.default.isShorthandPropertyAssignment(p));
|
|
193305
193434
|
if (hasNonShorthand) {
|
|
193306
193435
|
return {
|
|
193307
193436
|
kind: "declined",
|
|
@@ -193322,7 +193451,7 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193322
193451
|
}
|
|
193323
193452
|
const params = [];
|
|
193324
193453
|
for (const p of node.parameters) {
|
|
193325
|
-
if (
|
|
193454
|
+
if (import_typescript11.default.isIdentifier(p.name)) {
|
|
193326
193455
|
params.push(p.name.text);
|
|
193327
193456
|
continue;
|
|
193328
193457
|
}
|
|
@@ -193330,11 +193459,11 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193330
193459
|
}
|
|
193331
193460
|
const localBindings = [];
|
|
193332
193461
|
for (const stmt of node.body.statements) {
|
|
193333
|
-
if (
|
|
193462
|
+
if (import_typescript11.default.isVariableStatement(stmt)) {
|
|
193334
193463
|
for (const decl of stmt.declarationList.declarations) {
|
|
193335
193464
|
addBindingNames(decl.name, localBindings);
|
|
193336
193465
|
}
|
|
193337
|
-
} else if (
|
|
193466
|
+
} else if (import_typescript11.default.isFunctionDeclaration(stmt) && stmt.name) {
|
|
193338
193467
|
localBindings.push(stmt.name.text);
|
|
193339
193468
|
}
|
|
193340
193469
|
}
|
|
@@ -193354,47 +193483,47 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193354
193483
|
if (!relevantNames.has(id.text))
|
|
193355
193484
|
return;
|
|
193356
193485
|
const p = id.parent;
|
|
193357
|
-
if (
|
|
193486
|
+
if (import_typescript11.default.isPropertyAccessExpression(p) && p.name === id)
|
|
193358
193487
|
return;
|
|
193359
|
-
if (
|
|
193488
|
+
if (import_typescript11.default.isPropertyAssignment(p) && p.name === id)
|
|
193360
193489
|
return;
|
|
193361
|
-
if (
|
|
193490
|
+
if (import_typescript11.default.isBindingElement(p) && p.propertyName === id)
|
|
193362
193491
|
return;
|
|
193363
|
-
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)
|
|
193364
193493
|
return;
|
|
193365
|
-
if (
|
|
193494
|
+
if (import_typescript11.default.isJsxAttribute(p) && p.name === id)
|
|
193366
193495
|
return;
|
|
193367
|
-
if (
|
|
193496
|
+
if (import_typescript11.default.isLabeledStatement(p) && p.label === id || (import_typescript11.default.isBreakStatement(p) || import_typescript11.default.isContinueStatement(p)) && p.label === id)
|
|
193368
193497
|
return;
|
|
193369
|
-
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))
|
|
193370
193499
|
return;
|
|
193371
|
-
if (
|
|
193500
|
+
if (import_typescript11.default.isShorthandPropertyAssignment(p) && p.name === id) {
|
|
193372
193501
|
push(id, "shorthand");
|
|
193373
193502
|
return;
|
|
193374
193503
|
}
|
|
193375
|
-
if (
|
|
193504
|
+
if (import_typescript11.default.isBindingElement(p) && p.name === id && !p.propertyName && import_typescript11.default.isObjectBindingPattern(p.parent)) {
|
|
193376
193505
|
if (params.includes(id.text))
|
|
193377
193506
|
shadowedParam = id.text;
|
|
193378
193507
|
push(id, "shorthand");
|
|
193379
193508
|
return;
|
|
193380
193509
|
}
|
|
193381
|
-
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;
|
|
193382
193511
|
if (isDecl && params.includes(id.text))
|
|
193383
193512
|
shadowedParam = id.text;
|
|
193384
193513
|
push(id, "plain");
|
|
193385
193514
|
}
|
|
193386
193515
|
function visit2(n) {
|
|
193387
|
-
if (
|
|
193516
|
+
if (import_typescript11.default.isTypeNode(n) || import_typescript11.default.isTypeParameterDeclaration(n) || import_typescript11.default.isTypeAliasDeclaration(n) || import_typescript11.default.isInterfaceDeclaration(n))
|
|
193388
193517
|
return;
|
|
193389
|
-
if (
|
|
193518
|
+
if (import_typescript11.default.isIdentifier(n)) {
|
|
193390
193519
|
classify(n);
|
|
193391
193520
|
return;
|
|
193392
193521
|
}
|
|
193393
|
-
|
|
193522
|
+
import_typescript11.default.forEachChild(n, visit2);
|
|
193394
193523
|
}
|
|
193395
193524
|
visit2(root);
|
|
193396
193525
|
}
|
|
193397
|
-
const keptStatements = node.body.statements.filter((s) => !
|
|
193526
|
+
const keptStatements = node.body.statements.filter((s) => !import_typescript11.default.isReturnStatement(s));
|
|
193398
193527
|
const pieces = [];
|
|
193399
193528
|
let base = 0;
|
|
193400
193529
|
for (const stmt of keptStatements) {
|
|
@@ -193442,18 +193571,18 @@ function detectReactiveFactory(node, sourceFile, filePath) {
|
|
|
193442
193571
|
};
|
|
193443
193572
|
}
|
|
193444
193573
|
function addBindingNames(name, out) {
|
|
193445
|
-
if (
|
|
193574
|
+
if (import_typescript11.default.isIdentifier(name)) {
|
|
193446
193575
|
out.push(name.text);
|
|
193447
193576
|
return;
|
|
193448
193577
|
}
|
|
193449
|
-
if (
|
|
193578
|
+
if (import_typescript11.default.isObjectBindingPattern(name)) {
|
|
193450
193579
|
for (const el of name.elements)
|
|
193451
193580
|
addBindingNames(el.name, out);
|
|
193452
193581
|
return;
|
|
193453
193582
|
}
|
|
193454
|
-
if (
|
|
193583
|
+
if (import_typescript11.default.isArrayBindingPattern(name)) {
|
|
193455
193584
|
for (const el of name.elements) {
|
|
193456
|
-
if (
|
|
193585
|
+
if (import_typescript11.default.isOmittedExpression(el))
|
|
193457
193586
|
continue;
|
|
193458
193587
|
addBindingNames(el.name, out);
|
|
193459
193588
|
}
|
|
@@ -193465,33 +193594,33 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193465
193594
|
let callSiteIndex = 0;
|
|
193466
193595
|
const inlinedFactories = new Set;
|
|
193467
193596
|
function visitStmt(node, inComponent) {
|
|
193468
|
-
if (
|
|
193597
|
+
if (import_typescript11.default.isVariableStatement(node) && inComponent) {
|
|
193469
193598
|
for (const decl of node.declarationList.declarations) {
|
|
193470
193599
|
maybeRewriteDecl(node, decl);
|
|
193471
193600
|
}
|
|
193472
193601
|
}
|
|
193473
|
-
|
|
193474
|
-
if (
|
|
193602
|
+
import_typescript11.default.forEachChild(node, (child) => {
|
|
193603
|
+
if (import_typescript11.default.isFunctionDeclaration(child) && child.name && factories.has(child.name.text))
|
|
193475
193604
|
return;
|
|
193476
193605
|
visitStmt(child, inComponent || isPascalCaseComponentFn(child));
|
|
193477
193606
|
});
|
|
193478
193607
|
}
|
|
193479
193608
|
function maybeRewriteDecl(stmt, decl) {
|
|
193480
|
-
if (!decl.initializer || !
|
|
193609
|
+
if (!decl.initializer || !import_typescript11.default.isCallExpression(decl.initializer))
|
|
193481
193610
|
return;
|
|
193482
|
-
if (!
|
|
193611
|
+
if (!import_typescript11.default.isIdentifier(decl.initializer.expression))
|
|
193483
193612
|
return;
|
|
193484
193613
|
const factoryName = decl.initializer.expression.text;
|
|
193485
193614
|
const factory = factories.get(factoryName);
|
|
193486
193615
|
if (!factory)
|
|
193487
193616
|
return;
|
|
193488
|
-
if (
|
|
193617
|
+
if (import_typescript11.default.isArrayBindingPattern(decl.name)) {
|
|
193489
193618
|
if (factory.returnKind !== "tuple")
|
|
193490
193619
|
return;
|
|
193491
193620
|
rewriteTupleDecl(stmt, decl.name, decl.initializer, factory);
|
|
193492
193621
|
return;
|
|
193493
193622
|
}
|
|
193494
|
-
if (
|
|
193623
|
+
if (import_typescript11.default.isObjectBindingPattern(decl.name)) {
|
|
193495
193624
|
if (factory.returnKind !== "object")
|
|
193496
193625
|
return;
|
|
193497
193626
|
rewriteObjectDecl(stmt, decl.name, decl.initializer, factory);
|
|
@@ -193504,7 +193633,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193504
193633
|
return;
|
|
193505
193634
|
const callerNames = [];
|
|
193506
193635
|
for (const el of elements) {
|
|
193507
|
-
if (
|
|
193636
|
+
if (import_typescript11.default.isOmittedExpression(el) || !import_typescript11.default.isIdentifier(el.name))
|
|
193508
193637
|
return;
|
|
193509
193638
|
callerNames.push(el.name.text);
|
|
193510
193639
|
}
|
|
@@ -193526,7 +193655,7 @@ function rewriteFactoryCallsInSource(source, prescan) {
|
|
|
193526
193655
|
return;
|
|
193527
193656
|
if (el.initializer)
|
|
193528
193657
|
return;
|
|
193529
|
-
if (!
|
|
193658
|
+
if (!import_typescript11.default.isIdentifier(el.name))
|
|
193530
193659
|
return;
|
|
193531
193660
|
if (!factory.returnTupleIdentifiers.includes(el.name.text))
|
|
193532
193661
|
return;
|
|
@@ -193635,21 +193764,21 @@ function factoryImportInsertionOffset(sf) {
|
|
|
193635
193764
|
let lastImportEnd = -1;
|
|
193636
193765
|
let directiveEnd = -1;
|
|
193637
193766
|
for (const stmt of sf.statements) {
|
|
193638
|
-
if (
|
|
193767
|
+
if (import_typescript11.default.isImportDeclaration(stmt)) {
|
|
193639
193768
|
lastImportEnd = stmt.getEnd();
|
|
193640
193769
|
continue;
|
|
193641
193770
|
}
|
|
193642
|
-
if (directiveEnd === -1 &&
|
|
193771
|
+
if (directiveEnd === -1 && import_typescript11.default.isExpressionStatement(stmt) && import_typescript11.default.isStringLiteral(stmt.expression) && stmt.expression.text === "use client") {
|
|
193643
193772
|
directiveEnd = stmt.getEnd();
|
|
193644
193773
|
}
|
|
193645
193774
|
}
|
|
193646
193775
|
return lastImportEnd >= 0 ? lastImportEnd : directiveEnd >= 0 ? directiveEnd : 0;
|
|
193647
193776
|
}
|
|
193648
193777
|
function isPascalCaseComponentFn(node) {
|
|
193649
|
-
if (
|
|
193778
|
+
if (import_typescript11.default.isFunctionDeclaration(node) && node.name) {
|
|
193650
193779
|
return /^[A-Z]/.test(node.name.text);
|
|
193651
193780
|
}
|
|
193652
|
-
if (
|
|
193781
|
+
if (import_typescript11.default.isVariableDeclaration(node) && import_typescript11.default.isIdentifier(node.name) && node.initializer && import_typescript11.default.isArrowFunction(node.initializer)) {
|
|
193653
193782
|
return /^[A-Z]/.test(node.name.text);
|
|
193654
193783
|
}
|
|
193655
193784
|
return false;
|
|
@@ -193678,20 +193807,20 @@ function declinedFactoryErrorCode(code2) {
|
|
|
193678
193807
|
function validateReactiveFactoryCalls(ctx) {
|
|
193679
193808
|
if (!ctx.componentNode)
|
|
193680
193809
|
return;
|
|
193681
|
-
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;
|
|
193682
193811
|
if (!body)
|
|
193683
193812
|
return;
|
|
193684
193813
|
for (const stmt of body.statements) {
|
|
193685
|
-
if (!
|
|
193814
|
+
if (!import_typescript11.default.isVariableStatement(stmt))
|
|
193686
193815
|
continue;
|
|
193687
193816
|
for (const decl of stmt.declarationList.declarations) {
|
|
193688
|
-
if (!decl.initializer || !
|
|
193817
|
+
if (!decl.initializer || !import_typescript11.default.isCallExpression(decl.initializer))
|
|
193689
193818
|
continue;
|
|
193690
|
-
if (!
|
|
193819
|
+
if (!import_typescript11.default.isIdentifier(decl.initializer.expression))
|
|
193691
193820
|
continue;
|
|
193692
193821
|
const callee = decl.initializer.expression.text;
|
|
193693
193822
|
const loc = getSourceLocation(stmt, ctx.sourceFile, ctx.filePath);
|
|
193694
|
-
if (
|
|
193823
|
+
if (import_typescript11.default.isArrayBindingPattern(decl.name)) {
|
|
193695
193824
|
if (callee === "createSignal" || callee === "createMemo")
|
|
193696
193825
|
continue;
|
|
193697
193826
|
if (resolveEnvSignalKey(decl.initializer, ctx))
|
|
@@ -193718,7 +193847,7 @@ function validateReactiveFactoryCalls(ctx) {
|
|
|
193718
193847
|
}));
|
|
193719
193848
|
continue;
|
|
193720
193849
|
}
|
|
193721
|
-
if (
|
|
193850
|
+
if (import_typescript11.default.isObjectBindingPattern(decl.name)) {
|
|
193722
193851
|
validateObjectFactoryDestructure(ctx, decl.name, callee, loc);
|
|
193723
193852
|
}
|
|
193724
193853
|
}
|
|
@@ -193727,25 +193856,25 @@ function validateReactiveFactoryCalls(ctx) {
|
|
|
193727
193856
|
function validateNamespaceQualifiedPrimitives(ctx) {
|
|
193728
193857
|
if (!ctx.componentNode)
|
|
193729
193858
|
return;
|
|
193730
|
-
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;
|
|
193731
193860
|
if (!body)
|
|
193732
193861
|
return;
|
|
193733
193862
|
for (const stmt of body.statements) {
|
|
193734
193863
|
const calls = [];
|
|
193735
|
-
if (
|
|
193864
|
+
if (import_typescript11.default.isVariableStatement(stmt)) {
|
|
193736
193865
|
for (const decl of stmt.declarationList.declarations) {
|
|
193737
193866
|
let init = decl.initializer;
|
|
193738
|
-
if (init &&
|
|
193867
|
+
if (init && import_typescript11.default.isElementAccessExpression(init))
|
|
193739
193868
|
init = init.expression;
|
|
193740
|
-
if (init &&
|
|
193869
|
+
if (init && import_typescript11.default.isCallExpression(init))
|
|
193741
193870
|
calls.push(init);
|
|
193742
193871
|
}
|
|
193743
|
-
} else if (
|
|
193872
|
+
} else if (import_typescript11.default.isExpressionStatement(stmt) && import_typescript11.default.isCallExpression(stmt.expression)) {
|
|
193744
193873
|
calls.push(stmt.expression);
|
|
193745
193874
|
}
|
|
193746
193875
|
for (const call of calls) {
|
|
193747
193876
|
const callee = call.expression;
|
|
193748
|
-
if (!
|
|
193877
|
+
if (!import_typescript11.default.isPropertyAccessExpression(callee) || !import_typescript11.default.isIdentifier(callee.expression))
|
|
193749
193878
|
continue;
|
|
193750
193879
|
const primitive = callee.name.text;
|
|
193751
193880
|
if (!(primitive in PRIMITIVE_CANONICAL_NAMES))
|
|
@@ -193778,11 +193907,11 @@ function isNamespaceNameShadowedAtComponentTopLevel(name, body, ctx) {
|
|
|
193778
193907
|
if (ctx.propsParams.some((p) => p.name === name))
|
|
193779
193908
|
return true;
|
|
193780
193909
|
for (const stmt of body.statements) {
|
|
193781
|
-
if (
|
|
193910
|
+
if (import_typescript11.default.isFunctionDeclaration(stmt) && stmt.name?.text === name)
|
|
193782
193911
|
return true;
|
|
193783
|
-
if (
|
|
193912
|
+
if (import_typescript11.default.isVariableStatement(stmt)) {
|
|
193784
193913
|
for (const decl of stmt.declarationList.declarations) {
|
|
193785
|
-
if (
|
|
193914
|
+
if (import_typescript11.default.isIdentifier(decl.name) && decl.name.text === name)
|
|
193786
193915
|
return true;
|
|
193787
193916
|
}
|
|
193788
193917
|
}
|
|
@@ -193799,7 +193928,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
193799
193928
|
}));
|
|
193800
193929
|
return;
|
|
193801
193930
|
}
|
|
193802
|
-
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));
|
|
193803
193932
|
if (hasUnsupportedElement) {
|
|
193804
193933
|
ctx.errors.push(createError(ErrorCodes.REACTIVE_FACTORY_RENAME_UNSUPPORTED, loc, {
|
|
193805
193934
|
severity: "error",
|
|
@@ -193807,7 +193936,7 @@ function validateObjectFactoryDestructure(ctx, pattern, callee, loc) {
|
|
|
193807
193936
|
}));
|
|
193808
193937
|
return;
|
|
193809
193938
|
}
|
|
193810
|
-
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));
|
|
193811
193940
|
if (unknown.length > 0) {
|
|
193812
193941
|
const label = unknown.length === 1 ? "property" : "properties";
|
|
193813
193942
|
ctx.errors.push(createError(ErrorCodes.UNRECOGNIZED_REACTIVE_FACTORY, loc, {
|
|
@@ -193927,7 +194056,7 @@ var AttrValueOf = {
|
|
|
193927
194056
|
};
|
|
193928
194057
|
|
|
193929
194058
|
// ../jsx/src/module-exports.ts
|
|
193930
|
-
var
|
|
194059
|
+
var import_typescript12 = __toESM(require_typescript(), 1);
|
|
193931
194060
|
function formatParamWithType(p) {
|
|
193932
194061
|
const rest = p.isRest ? "..." : "";
|
|
193933
194062
|
const optional = p.optional ? "?" : "";
|
|
@@ -193962,21 +194091,21 @@ function findAssignedNames(bodyText, candidates) {
|
|
|
193962
194091
|
const assigned = new Set;
|
|
193963
194092
|
if (candidates.size === 0)
|
|
193964
194093
|
return assigned;
|
|
193965
|
-
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);
|
|
193966
194095
|
const record = (target) => {
|
|
193967
|
-
if (
|
|
194096
|
+
if (import_typescript12.default.isIdentifier(target) && candidates.has(target.text)) {
|
|
193968
194097
|
assigned.add(target.text);
|
|
193969
194098
|
}
|
|
193970
194099
|
};
|
|
193971
194100
|
const visit2 = (node) => {
|
|
193972
|
-
if (
|
|
194101
|
+
if (import_typescript12.default.isBinaryExpression(node) && isAssignmentOperator(node.operatorToken.kind)) {
|
|
193973
194102
|
record(node.left);
|
|
193974
|
-
} 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)) {
|
|
193975
194104
|
record(node.operand);
|
|
193976
194105
|
}
|
|
193977
|
-
|
|
194106
|
+
import_typescript12.default.forEachChild(node, visit2);
|
|
193978
194107
|
};
|
|
193979
|
-
|
|
194108
|
+
import_typescript12.default.forEachChild(sf, visit2);
|
|
193980
194109
|
return assigned;
|
|
193981
194110
|
}
|
|
193982
194111
|
function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNames) {
|
|
@@ -193999,7 +194128,7 @@ function closeOverWritersOfMutableBindings(primaryRefs, declarations, mutableNam
|
|
|
193999
194128
|
return reachable;
|
|
194000
194129
|
}
|
|
194001
194130
|
function isAssignmentOperator(kind) {
|
|
194002
|
-
return kind >=
|
|
194131
|
+
return kind >= import_typescript12.default.SyntaxKind.FirstAssignment && kind <= import_typescript12.default.SyntaxKind.LastAssignment;
|
|
194003
194132
|
}
|
|
194004
194133
|
|
|
194005
194134
|
// ../jsx/src/builtins.ts
|
|
@@ -194008,102 +194137,6 @@ function isClientBuiltinName(name) {
|
|
|
194008
194137
|
return name === "Async" || name === "Region";
|
|
194009
194138
|
}
|
|
194010
194139
|
|
|
194011
|
-
// ../jsx/src/reactivity-checker.ts
|
|
194012
|
-
var import_typescript12 = __toESM(require_typescript(), 1);
|
|
194013
|
-
var REACTIVE_BRAND = "__reactive";
|
|
194014
|
-
function queryType(checker, node) {
|
|
194015
|
-
incrementCounter("typeCheckerQueries");
|
|
194016
|
-
return checker.getTypeAtLocation(node);
|
|
194017
|
-
}
|
|
194018
|
-
function isReactiveType(type2) {
|
|
194019
|
-
return type2.getProperty(REACTIVE_BRAND) !== undefined;
|
|
194020
|
-
}
|
|
194021
|
-
var NOT_REACTIVE = { isReactive: false, reason: { kind: "not-reactive" } };
|
|
194022
|
-
function safeGetText(node) {
|
|
194023
|
-
try {
|
|
194024
|
-
return node.getText();
|
|
194025
|
-
} catch {
|
|
194026
|
-
return "";
|
|
194027
|
-
}
|
|
194028
|
-
}
|
|
194029
|
-
function analyze(node, checker) {
|
|
194030
|
-
if (import_typescript12.default.isPropertyAccessExpression(node)) {
|
|
194031
|
-
try {
|
|
194032
|
-
const type2 = queryType(checker, node);
|
|
194033
|
-
if (isReactiveType(type2)) {
|
|
194034
|
-
return {
|
|
194035
|
-
isReactive: true,
|
|
194036
|
-
reason: { kind: "brand", via: "property-access", nodeText: safeGetText(node) }
|
|
194037
|
-
};
|
|
194038
|
-
}
|
|
194039
|
-
} catch {}
|
|
194040
|
-
const sub = analyze(node.expression, checker);
|
|
194041
|
-
if (sub.isReactive) {
|
|
194042
|
-
return {
|
|
194043
|
-
isReactive: true,
|
|
194044
|
-
reason: {
|
|
194045
|
-
kind: "child",
|
|
194046
|
-
via: "property-access-object",
|
|
194047
|
-
childText: safeGetText(node.expression),
|
|
194048
|
-
childReason: sub.reason
|
|
194049
|
-
}
|
|
194050
|
-
};
|
|
194051
|
-
}
|
|
194052
|
-
return NOT_REACTIVE;
|
|
194053
|
-
}
|
|
194054
|
-
if (import_typescript12.default.isIdentifier(node)) {
|
|
194055
|
-
try {
|
|
194056
|
-
const type2 = queryType(checker, node);
|
|
194057
|
-
if (isReactiveType(type2)) {
|
|
194058
|
-
return {
|
|
194059
|
-
isReactive: true,
|
|
194060
|
-
reason: { kind: "brand", via: "identifier", nodeText: safeGetText(node) }
|
|
194061
|
-
};
|
|
194062
|
-
}
|
|
194063
|
-
} catch {}
|
|
194064
|
-
return NOT_REACTIVE;
|
|
194065
|
-
}
|
|
194066
|
-
if (import_typescript12.default.isCallExpression(node)) {
|
|
194067
|
-
try {
|
|
194068
|
-
const calleeType = queryType(checker, node.expression);
|
|
194069
|
-
if (isReactiveType(calleeType)) {
|
|
194070
|
-
return {
|
|
194071
|
-
isReactive: true,
|
|
194072
|
-
reason: { kind: "brand", via: "callee", nodeText: safeGetText(node) }
|
|
194073
|
-
};
|
|
194074
|
-
}
|
|
194075
|
-
} catch {}
|
|
194076
|
-
}
|
|
194077
|
-
let foundChild;
|
|
194078
|
-
let foundChildText = "";
|
|
194079
|
-
import_typescript12.default.forEachChild(node, (child) => {
|
|
194080
|
-
if (foundChild?.isReactive)
|
|
194081
|
-
return;
|
|
194082
|
-
const result = analyze(child, checker);
|
|
194083
|
-
if (result.isReactive) {
|
|
194084
|
-
foundChild = result;
|
|
194085
|
-
foundChildText = safeGetText(child);
|
|
194086
|
-
}
|
|
194087
|
-
});
|
|
194088
|
-
if (foundChild?.isReactive) {
|
|
194089
|
-
return {
|
|
194090
|
-
isReactive: true,
|
|
194091
|
-
reason: {
|
|
194092
|
-
kind: "child",
|
|
194093
|
-
via: "sub-expression",
|
|
194094
|
-
childText: foundChildText,
|
|
194095
|
-
childReason: foundChild.reason
|
|
194096
|
-
}
|
|
194097
|
-
};
|
|
194098
|
-
}
|
|
194099
|
-
return NOT_REACTIVE;
|
|
194100
|
-
}
|
|
194101
|
-
var brandTypeReactivityAnalyzer = { analyze };
|
|
194102
|
-
function containsReactiveExpression(node, checker) {
|
|
194103
|
-
incrementCounter("reactivityChecks");
|
|
194104
|
-
return brandTypeReactivityAnalyzer.analyze(node, checker).isReactive;
|
|
194105
|
-
}
|
|
194106
|
-
|
|
194107
194140
|
// ../jsx/src/free-refs.ts
|
|
194108
194141
|
var import_typescript13 = __toESM(require_typescript(), 1);
|
|
194109
194142
|
var _bindingMapCache = new WeakMap;
|
|
@@ -195780,7 +195813,7 @@ function transformExpressionInner(expr, ctx, node, isClientOnly) {
|
|
|
195780
195813
|
}
|
|
195781
195814
|
const ir = transformJsxExpression(expr, ctx, isClientOnly);
|
|
195782
195815
|
if (ir !== null) {
|
|
195783
|
-
if ((isClientOnly || shouldAutoDeferReactiveBrand(expr, ctx))
|
|
195816
|
+
if (ir.type === "conditional" && (isClientOnly || shouldAutoDeferReactiveBrand(expr, ctx))) {
|
|
195784
195817
|
ir.clientOnly = true;
|
|
195785
195818
|
if (!ir.slotId) {
|
|
195786
195819
|
ir.slotId = generateSlotId(ctx);
|
|
@@ -198727,9 +198760,10 @@ function shouldAutoDeferReactiveBrand(expr, ctx) {
|
|
|
198727
198760
|
const checker = ctx.analyzer.checker;
|
|
198728
198761
|
if (!checker)
|
|
198729
198762
|
return false;
|
|
198730
|
-
|
|
198763
|
+
const leaves = collectReactiveBrandLeaves(expr, checker);
|
|
198764
|
+
if (leaves.length === 0)
|
|
198731
198765
|
return false;
|
|
198732
|
-
if (isSignalOrMemoReference(ctx.getJS(
|
|
198766
|
+
if (leaves.some((leaf) => isSignalOrMemoReference(ctx.getJS(leaf), ctx)))
|
|
198733
198767
|
return false;
|
|
198734
198768
|
return true;
|
|
198735
198769
|
}
|