@poe-platform/safe-js 0.1.149 → 0.1.151
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/safe-js/chunks/{chunk-AJOCDNNB.js → chunk-3BLGB6FX.js} +2 -2
- package/dist/safe-js/chunks/{chunk-F6FZXBQR.js → chunk-LNHPI4GK.js} +64 -48
- package/dist/safe-js/chunks/chunk-LNHPI4GK.js.map +7 -0
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +1 -1
- package/dist/safe-js/index.js +2 -2
- package/dist/safe-js/index.js.map +2 -2
- package/dist/safe-js/loader/find-exported.d.ts +2 -2
- package/dist/safe-js/parse/parse-export.d.ts +4 -4
- package/dist/safe-js/parse/parser.d.ts +1 -1
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-F6FZXBQR.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-AJOCDNNB.js.map → chunk-3BLGB6FX.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-LNHPI4GK.js";
|
|
31
31
|
|
|
32
32
|
// packages/safe-js/src/migrate.ts
|
|
33
33
|
import { createHash } from "node:crypto";
|
|
@@ -8249,4 +8249,4 @@ export {
|
|
|
8249
8249
|
parseMcpConfig,
|
|
8250
8250
|
makeMcpModule
|
|
8251
8251
|
};
|
|
8252
|
-
//# sourceMappingURL=chunk-
|
|
8252
|
+
//# sourceMappingURL=chunk-3BLGB6FX.js.map
|
|
@@ -3297,6 +3297,9 @@ var Parser = class {
|
|
|
3297
3297
|
}
|
|
3298
3298
|
parseExportDefaultDeclaration(exportToken) {
|
|
3299
3299
|
this.index += 1;
|
|
3300
|
+
if (this.currentToken().value === "function" || this.currentToken().value === "async" && this.peekToken(1).value === "function" && !hasLineBreakBetween(this.currentToken(), this.peekToken(1))) {
|
|
3301
|
+
return createExportDefaultDeclaration(exportToken, this.parseFunctionDeclaration(true));
|
|
3302
|
+
}
|
|
3300
3303
|
if (this.currentToken().value === "class") {
|
|
3301
3304
|
const named = isIdentifierLikeToken(this.peekToken(1)) && this.peekToken(1).value !== "extends";
|
|
3302
3305
|
return createExportDefaultDeclaration(exportToken, this.parseClass(named));
|
|
@@ -3348,7 +3351,7 @@ var Parser = class {
|
|
|
3348
3351
|
span: createSpan2(kindToken.start, declarations[declarations.length - 1].span.end)
|
|
3349
3352
|
};
|
|
3350
3353
|
}
|
|
3351
|
-
parseFunctionDeclaration() {
|
|
3354
|
+
parseFunctionDeclaration(defaultExport = false) {
|
|
3352
3355
|
const asyncToken = this.consumeKeyword("async");
|
|
3353
3356
|
const functionToken = this.expectKeyword("function");
|
|
3354
3357
|
const generatorToken = this.consumePunctuator("*");
|
|
@@ -3357,8 +3360,8 @@ var Parser = class {
|
|
|
3357
3360
|
`async function* is not supported at line ${asyncToken.start.line}, column ${asyncToken.start.column}.`
|
|
3358
3361
|
);
|
|
3359
3362
|
}
|
|
3360
|
-
const id = this.parseBindingIdentifier();
|
|
3361
|
-
this.declareBinding(id, "function");
|
|
3363
|
+
const id = defaultExport && this.currentToken().value === "(" ? void 0 : this.parseBindingIdentifier();
|
|
3364
|
+
if (id !== void 0) this.declareBinding(id, defaultExport ? "lexical" : "function");
|
|
3362
3365
|
const generator = generatorToken !== void 0;
|
|
3363
3366
|
const { params, body } = this.parseFunctionParts(generator, ordinaryFunctionContext);
|
|
3364
3367
|
return this.withFunctionSource({
|
|
@@ -14111,7 +14114,7 @@ var AS003Scanner = class {
|
|
|
14111
14114
|
this.visitVariableDeclaration(node.declaration);
|
|
14112
14115
|
return;
|
|
14113
14116
|
case "ExportDefaultDeclaration":
|
|
14114
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
14117
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
14115
14118
|
else this.visitExpression(node.declaration);
|
|
14116
14119
|
return;
|
|
14117
14120
|
case "ImportDeclaration":
|
|
@@ -14520,7 +14523,7 @@ var AS003Scanner = class {
|
|
|
14520
14523
|
bindings.push(...this.collectDeclarationBindings(declaration));
|
|
14521
14524
|
}
|
|
14522
14525
|
for (const statement of body) {
|
|
14523
|
-
if (statement.type === "ExportDefaultDeclaration" && statement.declaration.type === "ClassDeclaration") {
|
|
14526
|
+
if (statement.type === "ExportDefaultDeclaration" && (statement.declaration.type === "ClassDeclaration" || statement.declaration.type === "FunctionDeclaration") && statement.declaration.id !== void 0) {
|
|
14524
14527
|
bindings.push({ kind: "let", name: statement.declaration.id.name });
|
|
14525
14528
|
continue;
|
|
14526
14529
|
}
|
|
@@ -14528,7 +14531,7 @@ var AS003Scanner = class {
|
|
|
14528
14531
|
bindings.push(...this.collectImportBindings(statement));
|
|
14529
14532
|
continue;
|
|
14530
14533
|
}
|
|
14531
|
-
if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
|
|
14534
|
+
if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && statement.id !== void 0) {
|
|
14532
14535
|
bindings.push({ kind: "let", name: statement.id.name });
|
|
14533
14536
|
continue;
|
|
14534
14537
|
}
|
|
@@ -14545,7 +14548,7 @@ var AS003Scanner = class {
|
|
|
14545
14548
|
collectBlockBindings(body) {
|
|
14546
14549
|
const bindings = [];
|
|
14547
14550
|
for (const statement of body) {
|
|
14548
|
-
if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
|
|
14551
|
+
if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && statement.id !== void 0) {
|
|
14549
14552
|
bindings.push({ kind: "let", name: statement.id.name });
|
|
14550
14553
|
}
|
|
14551
14554
|
if (statement.type === "VariableDeclaration" && statement.kind !== "var") {
|
|
@@ -14862,7 +14865,7 @@ var AS006007Scanner = class {
|
|
|
14862
14865
|
this.visitVariableDeclaration(node.declaration);
|
|
14863
14866
|
return;
|
|
14864
14867
|
case "ExportDefaultDeclaration":
|
|
14865
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
14868
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
14866
14869
|
else this.visitExpression(node.declaration);
|
|
14867
14870
|
return;
|
|
14868
14871
|
case "BlockStatement":
|
|
@@ -15310,11 +15313,15 @@ var AS006007Scanner = class {
|
|
|
15310
15313
|
bindings.push(...this.collectDeclarationBindings(declaration));
|
|
15311
15314
|
}
|
|
15312
15315
|
for (const statement of body) {
|
|
15316
|
+
if (statement.type === "ExportDefaultDeclaration" && (statement.declaration.type === "FunctionDeclaration" || statement.declaration.type === "ClassDeclaration") && statement.declaration.id !== void 0) {
|
|
15317
|
+
bindings.push({ ...this.createBinding(statement.declaration.id, "let"), code: void 0 });
|
|
15318
|
+
continue;
|
|
15319
|
+
}
|
|
15313
15320
|
if (statement.type === "ImportDeclaration") {
|
|
15314
15321
|
bindings.push(...this.collectImportBindings(statement));
|
|
15315
15322
|
continue;
|
|
15316
15323
|
}
|
|
15317
|
-
if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
|
|
15324
|
+
if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && statement.id !== void 0) {
|
|
15318
15325
|
bindings.push(this.createBinding(statement.id, "let"));
|
|
15319
15326
|
continue;
|
|
15320
15327
|
}
|
|
@@ -15331,7 +15338,7 @@ var AS006007Scanner = class {
|
|
|
15331
15338
|
collectBlockBindings(body) {
|
|
15332
15339
|
const bindings = [];
|
|
15333
15340
|
for (const statement of body) {
|
|
15334
|
-
if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
|
|
15341
|
+
if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && statement.id !== void 0) {
|
|
15335
15342
|
bindings.push(this.createBinding(statement.id, "let"));
|
|
15336
15343
|
}
|
|
15337
15344
|
if (statement.type === "VariableDeclaration" && statement.kind !== "var") {
|
|
@@ -15560,7 +15567,7 @@ var AS009Scanner = class {
|
|
|
15560
15567
|
this.visitVariableDeclaration(node.declaration);
|
|
15561
15568
|
return;
|
|
15562
15569
|
case "ExportDefaultDeclaration":
|
|
15563
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
15570
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
15564
15571
|
else this.visitExpression(node.declaration);
|
|
15565
15572
|
return;
|
|
15566
15573
|
case "ImportDeclaration":
|
|
@@ -16067,7 +16074,7 @@ var AS010Scanner = class {
|
|
|
16067
16074
|
this.visitVariableDeclaration(node.declaration);
|
|
16068
16075
|
return;
|
|
16069
16076
|
case "ExportDefaultDeclaration":
|
|
16070
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
16077
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
16071
16078
|
else this.visitExpression(node.declaration);
|
|
16072
16079
|
return;
|
|
16073
16080
|
case "ImportDeclaration":
|
|
@@ -16719,7 +16726,7 @@ var AS011Scanner = class {
|
|
|
16719
16726
|
this.visitVariableDeclaration(node.declaration);
|
|
16720
16727
|
return;
|
|
16721
16728
|
case "ExportDefaultDeclaration":
|
|
16722
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
16729
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
16723
16730
|
else this.visitExpression(node.declaration);
|
|
16724
16731
|
return;
|
|
16725
16732
|
case "ImportDeclaration":
|
|
@@ -17143,7 +17150,7 @@ var AS015Scanner = class {
|
|
|
17143
17150
|
this.visitVariableDeclaration(node.declaration);
|
|
17144
17151
|
return;
|
|
17145
17152
|
case "ExportDefaultDeclaration":
|
|
17146
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
17153
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
17147
17154
|
else this.visitExpression(node.declaration);
|
|
17148
17155
|
return;
|
|
17149
17156
|
case "ImportDeclaration":
|
|
@@ -17474,7 +17481,7 @@ var ASAsyncNotNeededScanner = class {
|
|
|
17474
17481
|
this.visitArrowFunction(node.declaration, true);
|
|
17475
17482
|
return;
|
|
17476
17483
|
}
|
|
17477
|
-
if (node.declaration.type === "FunctionExpression") {
|
|
17484
|
+
if (node.declaration.type === "FunctionExpression" || node.declaration.type === "FunctionDeclaration") {
|
|
17478
17485
|
this.visitFunctionExpression(node.declaration, true);
|
|
17479
17486
|
return;
|
|
17480
17487
|
}
|
|
@@ -17834,7 +17841,7 @@ function statementContainsAwait(node) {
|
|
|
17834
17841
|
case "ExportNamedDeclaration":
|
|
17835
17842
|
return variableDeclarationContainsAwait(node.declaration);
|
|
17836
17843
|
case "ExportDefaultDeclaration":
|
|
17837
|
-
return node.declaration.type === "ClassDeclaration" ? statementContainsAwait(node.declaration) : expressionContainsAwait(node.declaration);
|
|
17844
|
+
return node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration" ? statementContainsAwait(node.declaration) : expressionContainsAwait(node.declaration);
|
|
17838
17845
|
case "ImportDeclaration":
|
|
17839
17846
|
case "FunctionDeclaration":
|
|
17840
17847
|
case "BreakStatement":
|
|
@@ -18034,7 +18041,7 @@ var ASDestructureNullDefaultScanner = class {
|
|
|
18034
18041
|
this.visitVariableDeclaration(node.declaration);
|
|
18035
18042
|
return;
|
|
18036
18043
|
case "ExportDefaultDeclaration":
|
|
18037
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
18044
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
18038
18045
|
else this.visitExpression(node.declaration);
|
|
18039
18046
|
return;
|
|
18040
18047
|
case "ImportDeclaration":
|
|
@@ -18497,13 +18504,13 @@ var Scanner = class {
|
|
|
18497
18504
|
this.pushDiagnostic(
|
|
18498
18505
|
"AS-EXPORT-DEFAULT-NOT-ARROW",
|
|
18499
18506
|
"error",
|
|
18500
|
-
"Export default
|
|
18507
|
+
"Export default must be an arrow, function expression, or function declaration.",
|
|
18501
18508
|
node.declaration.span
|
|
18502
18509
|
);
|
|
18503
18510
|
} else {
|
|
18504
18511
|
this.visitDefaultExportSignature(node.declaration);
|
|
18505
18512
|
}
|
|
18506
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
18513
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
18507
18514
|
else this.visitExpression(node.declaration);
|
|
18508
18515
|
return;
|
|
18509
18516
|
case "BlockStatement":
|
|
@@ -18823,7 +18830,7 @@ var Scanner = class {
|
|
|
18823
18830
|
}
|
|
18824
18831
|
};
|
|
18825
18832
|
function isDefaultExportCallable(node) {
|
|
18826
|
-
return node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression";
|
|
18833
|
+
return node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression" || node.type === "FunctionDeclaration";
|
|
18827
18834
|
}
|
|
18828
18835
|
function hasParameterNames(node, names) {
|
|
18829
18836
|
if (node.params.length !== names.length) {
|
|
@@ -18936,7 +18943,7 @@ var ASFloatingPromiseScanner = class {
|
|
|
18936
18943
|
this.visitVariableDeclaration(node.declaration);
|
|
18937
18944
|
return;
|
|
18938
18945
|
case "ExportDefaultDeclaration":
|
|
18939
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
18946
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
18940
18947
|
else this.visitExpression(node.declaration);
|
|
18941
18948
|
return;
|
|
18942
18949
|
case "ImportDeclaration":
|
|
@@ -19346,8 +19353,9 @@ var ASFloatingPromiseScanner = class {
|
|
|
19346
19353
|
];
|
|
19347
19354
|
}
|
|
19348
19355
|
collectBlockBindings(statements) {
|
|
19349
|
-
return statements.flatMap((
|
|
19350
|
-
|
|
19356
|
+
return statements.flatMap((entry) => {
|
|
19357
|
+
const statement = entry.type === "ExportDefaultDeclaration" && entry.declaration.type === "FunctionDeclaration" ? entry.declaration : entry;
|
|
19358
|
+
if (statement.type === "FunctionDeclaration" && statement.id !== void 0) {
|
|
19351
19359
|
return [
|
|
19352
19360
|
{ async: statement.async && !statement.generator, kind: "local", name: statement.id.name }
|
|
19353
19361
|
];
|
|
@@ -19553,7 +19561,7 @@ var ASFrontmatterFieldUnusedScanner = class {
|
|
|
19553
19561
|
this.visitVariableDeclaration(node.declaration);
|
|
19554
19562
|
return;
|
|
19555
19563
|
case "ExportDefaultDeclaration":
|
|
19556
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
19564
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
19557
19565
|
else this.visitExpression(node.declaration);
|
|
19558
19566
|
return;
|
|
19559
19567
|
case "ImportDeclaration":
|
|
@@ -20076,7 +20084,7 @@ var ASJsdocTypeScanner = class {
|
|
|
20076
20084
|
);
|
|
20077
20085
|
return;
|
|
20078
20086
|
case "ExportDefaultDeclaration":
|
|
20079
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
20087
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
20080
20088
|
else this.visitExpression(node.declaration);
|
|
20081
20089
|
return;
|
|
20082
20090
|
case "ImportDeclaration":
|
|
@@ -20807,7 +20815,7 @@ var ASLargeLiteralScanner = class {
|
|
|
20807
20815
|
this.visitVariableDeclaration(node.declaration);
|
|
20808
20816
|
return;
|
|
20809
20817
|
case "ExportDefaultDeclaration":
|
|
20810
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
20818
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
20811
20819
|
else this.visitExpression(node.declaration);
|
|
20812
20820
|
return;
|
|
20813
20821
|
case "ImportDeclaration":
|
|
@@ -21173,7 +21181,7 @@ var ASMissingAsyncScanner = class {
|
|
|
21173
21181
|
this.visitVariableDeclaration(node.declaration);
|
|
21174
21182
|
return;
|
|
21175
21183
|
case "ExportDefaultDeclaration":
|
|
21176
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
21184
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
21177
21185
|
else this.visitExpression(node.declaration);
|
|
21178
21186
|
return;
|
|
21179
21187
|
case "ImportDeclaration":
|
|
@@ -21516,7 +21524,7 @@ function statementContainsAwait2(node) {
|
|
|
21516
21524
|
case "ExportNamedDeclaration":
|
|
21517
21525
|
return variableDeclarationContainsAwait2(node.declaration);
|
|
21518
21526
|
case "ExportDefaultDeclaration":
|
|
21519
|
-
return node.declaration.type === "ClassDeclaration" ? statementContainsAwait2(node.declaration) : expressionContainsAwait2(node.declaration);
|
|
21527
|
+
return node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration" ? statementContainsAwait2(node.declaration) : expressionContainsAwait2(node.declaration);
|
|
21520
21528
|
case "ImportDeclaration":
|
|
21521
21529
|
case "FunctionDeclaration":
|
|
21522
21530
|
case "BreakStatement":
|
|
@@ -21726,7 +21734,7 @@ var ASMutatingFrozenScanner = class {
|
|
|
21726
21734
|
this.visitVariableDeclaration(node.declaration);
|
|
21727
21735
|
return;
|
|
21728
21736
|
case "ExportDefaultDeclaration":
|
|
21729
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
21737
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
21730
21738
|
else this.visitExpression(node.declaration);
|
|
21731
21739
|
return;
|
|
21732
21740
|
case "ImportDeclaration":
|
|
@@ -22250,7 +22258,7 @@ var ASNeedlessTemplateScanner = class {
|
|
|
22250
22258
|
this.visitVariableDeclaration(node.declaration);
|
|
22251
22259
|
return;
|
|
22252
22260
|
case "ExportDefaultDeclaration":
|
|
22253
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
22261
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
22254
22262
|
else this.visitExpression(node.declaration);
|
|
22255
22263
|
return;
|
|
22256
22264
|
case "ImportDeclaration":
|
|
@@ -22640,7 +22648,7 @@ var ASShadowGlobalScanner = class {
|
|
|
22640
22648
|
this.visitVariableDeclaration(node.declaration);
|
|
22641
22649
|
return;
|
|
22642
22650
|
case "ExportDefaultDeclaration":
|
|
22643
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
22651
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
22644
22652
|
else this.visitExpression(node.declaration);
|
|
22645
22653
|
return;
|
|
22646
22654
|
case "ImportDeclaration":
|
|
@@ -23055,7 +23063,7 @@ var ASUnboundedLoopScanner = class {
|
|
|
23055
23063
|
this.visitVariableDeclaration(node.declaration);
|
|
23056
23064
|
return;
|
|
23057
23065
|
case "ExportDefaultDeclaration":
|
|
23058
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
23066
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
23059
23067
|
else this.visitExpression(node.declaration);
|
|
23060
23068
|
return;
|
|
23061
23069
|
case "ImportDeclaration":
|
|
@@ -23440,7 +23448,7 @@ var ASUnreachableScanner = class {
|
|
|
23440
23448
|
this.visitVariableDeclaration(node.declaration);
|
|
23441
23449
|
return false;
|
|
23442
23450
|
case "ExportDefaultDeclaration":
|
|
23443
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
23451
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
23444
23452
|
else this.visitExpression(node.declaration);
|
|
23445
23453
|
return false;
|
|
23446
23454
|
case "ImportDeclaration":
|
|
@@ -23728,7 +23736,7 @@ var ASUnusedImportScanner = class {
|
|
|
23728
23736
|
this.visitVariableDeclaration(node.declaration);
|
|
23729
23737
|
return;
|
|
23730
23738
|
case "ExportDefaultDeclaration":
|
|
23731
|
-
if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
|
|
23739
|
+
if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
|
|
23732
23740
|
else this.visitExpression(node.declaration);
|
|
23733
23741
|
return;
|
|
23734
23742
|
case "BlockStatement":
|
|
@@ -24096,11 +24104,15 @@ var ASUnusedImportScanner = class {
|
|
|
24096
24104
|
collectModuleBindings(body) {
|
|
24097
24105
|
const bindings = [];
|
|
24098
24106
|
for (const statement of body) {
|
|
24107
|
+
if (statement.type === "ExportDefaultDeclaration" && (statement.declaration.type === "FunctionDeclaration" || statement.declaration.type === "ClassDeclaration") && statement.declaration.id !== void 0) {
|
|
24108
|
+
bindings.push({ kind: "let", name: statement.declaration.id.name });
|
|
24109
|
+
continue;
|
|
24110
|
+
}
|
|
24099
24111
|
if (statement.type === "ImportDeclaration") {
|
|
24100
24112
|
bindings.push(...this.collectImportBindings(statement));
|
|
24101
24113
|
continue;
|
|
24102
24114
|
}
|
|
24103
|
-
if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
|
|
24115
|
+
if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && statement.id !== void 0) {
|
|
24104
24116
|
bindings.push({ kind: "let", name: statement.id.name });
|
|
24105
24117
|
continue;
|
|
24106
24118
|
}
|
|
@@ -24117,7 +24129,7 @@ var ASUnusedImportScanner = class {
|
|
|
24117
24129
|
collectBlockBindings(body) {
|
|
24118
24130
|
const bindings = [];
|
|
24119
24131
|
for (const statement of body) {
|
|
24120
|
-
if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
|
|
24132
|
+
if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && statement.id !== void 0) {
|
|
24121
24133
|
bindings.push({ kind: "let", name: statement.id.name });
|
|
24122
24134
|
}
|
|
24123
24135
|
if (statement.type === "VariableDeclaration") {
|
|
@@ -29142,6 +29154,7 @@ async function evaluateArrowFunction(node, context) {
|
|
|
29142
29154
|
return evaluateArrowFunctionExpression(node, context, evaluateNode);
|
|
29143
29155
|
}
|
|
29144
29156
|
async function evaluateFunctionDeclaration(node, context) {
|
|
29157
|
+
if (node.id === void 0) throw new Error("An anonymous declaration requires a default export.");
|
|
29145
29158
|
if (!context.scope.hasOwnBinding(node.id.name)) {
|
|
29146
29159
|
context.scope.declare(
|
|
29147
29160
|
node.id.name,
|
|
@@ -29432,6 +29445,10 @@ async function evaluateMetaProperty(_node, context) {
|
|
|
29432
29445
|
};
|
|
29433
29446
|
}
|
|
29434
29447
|
async function evaluateExportDefaultDeclaration(node, context) {
|
|
29448
|
+
if (node.declaration.type === "FunctionDeclaration") {
|
|
29449
|
+
if (!context.scope.hasOwnBinding("default")) predeclareStatementListBindings([node], context);
|
|
29450
|
+
return { kind: "normal", hasValue: false, value: void 0 };
|
|
29451
|
+
}
|
|
29435
29452
|
const declaration = await evaluateNode(node.declaration, { ...context, inferredName: "default" });
|
|
29436
29453
|
if (declaration.kind !== "normal") {
|
|
29437
29454
|
return declaration;
|
|
@@ -29658,25 +29675,23 @@ function predeclareBlockBindings2(node, context) {
|
|
|
29658
29675
|
function predeclareStatementListBindings(statements, context, functionBody = false) {
|
|
29659
29676
|
const { scope } = context;
|
|
29660
29677
|
const names = /* @__PURE__ */ new Set();
|
|
29661
|
-
for (const
|
|
29662
|
-
|
|
29663
|
-
|
|
29664
|
-
names.add(statement.declaration.id.name);
|
|
29665
|
-
continue;
|
|
29666
|
-
}
|
|
29678
|
+
for (const entry of statements) {
|
|
29679
|
+
const exportedFunction = entry.type === "ExportDefaultDeclaration" && entry.declaration.type === "FunctionDeclaration";
|
|
29680
|
+
const statement = entry.type === "ExportDefaultDeclaration" && (entry.declaration.type === "ClassDeclaration" || entry.declaration.type === "FunctionDeclaration") ? entry.declaration : entry;
|
|
29667
29681
|
if (statement.type === "ClassDeclaration") {
|
|
29668
29682
|
scope.predeclare(statement.id.name, "let");
|
|
29669
29683
|
names.add(statement.id.name);
|
|
29670
29684
|
continue;
|
|
29671
29685
|
}
|
|
29672
29686
|
if (statement.type === "FunctionDeclaration") {
|
|
29673
|
-
|
|
29674
|
-
|
|
29687
|
+
if (statement.id === void 0 && !exportedFunction) throw new Error("An anonymous declaration requires a default export.");
|
|
29688
|
+
const name = statement.id?.name ?? "default";
|
|
29689
|
+
if (names.has(name) && !(!exportedFunction && functionBody && scope.getOwnBindingKind(name) === "var")) {
|
|
29675
29690
|
throw new Error(`Cannot redeclare binding '${name}' in the same scope.`);
|
|
29676
29691
|
}
|
|
29677
|
-
const closure = createInterpretedClosure(statement, context, evaluateNode);
|
|
29692
|
+
const closure = createInterpretedClosure(statement, exportedFunction ? { ...context, inferredName: name } : context, evaluateNode);
|
|
29678
29693
|
const ownBindingKind = scope.getOwnBindingKind(name);
|
|
29679
|
-
if (ownBindingKind === "var") {
|
|
29694
|
+
if (ownBindingKind === "var" && !exportedFunction) {
|
|
29680
29695
|
names.add(name);
|
|
29681
29696
|
scope.assign(name, closure);
|
|
29682
29697
|
continue;
|
|
@@ -29685,7 +29700,8 @@ function predeclareStatementListBindings(statements, context, functionBody = fal
|
|
|
29685
29700
|
throw new Error(`Cannot redeclare binding '${name}' in the same scope.`);
|
|
29686
29701
|
}
|
|
29687
29702
|
names.add(name);
|
|
29688
|
-
scope.declare(name, functionBody ? "var" : "let", closure);
|
|
29703
|
+
scope.declare(name, exportedFunction ? statement.id === void 0 ? "const" : "let" : functionBody ? "var" : "let", closure);
|
|
29704
|
+
if (exportedFunction && statement.id !== void 0) scope.declareAlias("default", name);
|
|
29689
29705
|
continue;
|
|
29690
29706
|
}
|
|
29691
29707
|
if (statement.type !== "VariableDeclaration" || statement.kind === "var") {
|
|
@@ -35565,4 +35581,4 @@ export {
|
|
|
35565
35581
|
FileSnapshotBackend,
|
|
35566
35582
|
run
|
|
35567
35583
|
};
|
|
35568
|
-
//# sourceMappingURL=chunk-
|
|
35584
|
+
//# sourceMappingURL=chunk-LNHPI4GK.js.map
|