poe-code 14.0.67 → 14.0.68

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.
Files changed (38) hide show
  1. package/dist/index.js +89 -57
  2. package/dist/index.js.map +2 -2
  3. package/dist/metafile.json +1 -1
  4. package/package.json +1 -1
  5. package/packages/safe-js/dist/chunks/{chunk-7WQTLP7D.js → chunk-6IZRC5HI.js} +2 -2
  6. package/packages/safe-js/dist/chunks/{chunk-F6FZXBQR.js → chunk-WL74XSIE.js} +90 -58
  7. package/packages/safe-js/dist/chunks/chunk-WL74XSIE.js.map +7 -0
  8. package/packages/safe-js/dist/cli.js +2 -2
  9. package/packages/safe-js/dist/core.js +1 -1
  10. package/packages/safe-js/dist/index.js +2 -2
  11. package/packages/safe-js/dist/index.js.map +2 -2
  12. package/packages/safe-js/dist/interp/interpreter.js +51 -21
  13. package/packages/safe-js/dist/lint/rules/AS-async-not-needed.js +2 -2
  14. package/packages/safe-js/dist/lint/rules/AS-destructure-null-default.js +1 -1
  15. package/packages/safe-js/dist/lint/rules/AS-export-import-meta.js +3 -3
  16. package/packages/safe-js/dist/lint/rules/AS-floating-promise.js +4 -3
  17. package/packages/safe-js/dist/lint/rules/AS-frontmatter-field-unused.js +1 -1
  18. package/packages/safe-js/dist/lint/rules/AS-jsdoc-type.js +1 -1
  19. package/packages/safe-js/dist/lint/rules/AS-large-literal.js +1 -1
  20. package/packages/safe-js/dist/lint/rules/AS-missing-async.js +2 -2
  21. package/packages/safe-js/dist/lint/rules/AS-mutating-frozen.js +1 -1
  22. package/packages/safe-js/dist/lint/rules/AS-needless-template.js +1 -1
  23. package/packages/safe-js/dist/lint/rules/AS-shadow-global.js +1 -1
  24. package/packages/safe-js/dist/lint/rules/AS-unbounded-loop.js +1 -1
  25. package/packages/safe-js/dist/lint/rules/AS-unreachable.js +1 -1
  26. package/packages/safe-js/dist/lint/rules/AS-unused-import.js +7 -3
  27. package/packages/safe-js/dist/lint/rules/AS003.js +4 -4
  28. package/packages/safe-js/dist/lint/rules/AS006-007.js +7 -3
  29. package/packages/safe-js/dist/lint/rules/AS009.js +1 -1
  30. package/packages/safe-js/dist/lint/rules/AS010.js +1 -1
  31. package/packages/safe-js/dist/lint/rules/AS011.js +1 -1
  32. package/packages/safe-js/dist/lint/rules/AS015.js +1 -1
  33. package/packages/safe-js/dist/loader/find-exported.d.ts +2 -2
  34. package/packages/safe-js/dist/parse/parse-export.d.ts +4 -4
  35. package/packages/safe-js/dist/parse/parser.d.ts +1 -1
  36. package/packages/safe-js/dist/parse/parser.js +10 -3
  37. package/packages/safe-js/dist/chunks/chunk-F6FZXBQR.js.map +0 -7
  38. /package/packages/safe-js/dist/chunks/{chunk-7WQTLP7D.js.map → chunk-6IZRC5HI.js.map} +0 -0
package/dist/index.js CHANGED
@@ -123802,6 +123802,9 @@ var init_parser3 = __esm({
123802
123802
  }
123803
123803
  parseExportDefaultDeclaration(exportToken) {
123804
123804
  this.index += 1;
123805
+ if (this.currentToken().value === "function" || this.currentToken().value === "async" && this.peekToken(1).value === "function" && !hasLineBreakBetween(this.currentToken(), this.peekToken(1))) {
123806
+ return createExportDefaultDeclaration(exportToken, this.parseFunctionDeclaration(true));
123807
+ }
123805
123808
  if (this.currentToken().value === "class") {
123806
123809
  const named = isIdentifierLikeToken(this.peekToken(1)) && this.peekToken(1).value !== "extends";
123807
123810
  return createExportDefaultDeclaration(exportToken, this.parseClass(named));
@@ -123853,7 +123856,7 @@ var init_parser3 = __esm({
123853
123856
  span: createSpan2(kindToken.start, declarations[declarations.length - 1].span.end)
123854
123857
  };
123855
123858
  }
123856
- parseFunctionDeclaration() {
123859
+ parseFunctionDeclaration(defaultExport = false) {
123857
123860
  const asyncToken = this.consumeKeyword("async");
123858
123861
  const functionToken = this.expectKeyword("function");
123859
123862
  const generatorToken = this.consumePunctuator("*");
@@ -123862,8 +123865,8 @@ var init_parser3 = __esm({
123862
123865
  `async function* is not supported at line ${asyncToken.start.line}, column ${asyncToken.start.column}.`
123863
123866
  );
123864
123867
  }
123865
- const id = this.parseBindingIdentifier();
123866
- this.declareBinding(id, "function");
123868
+ const id = defaultExport && this.currentToken().value === "(" ? void 0 : this.parseBindingIdentifier();
123869
+ if (id !== void 0) this.declareBinding(id, defaultExport ? "lexical" : "function");
123867
123870
  const generator = generatorToken !== void 0;
123868
123871
  const { params, body } = this.parseFunctionParts(generator, ordinaryFunctionContext);
123869
123872
  return this.withFunctionSource({
@@ -134196,7 +134199,7 @@ var init_AS003 = __esm({
134196
134199
  this.visitVariableDeclaration(node.declaration);
134197
134200
  return;
134198
134201
  case "ExportDefaultDeclaration":
134199
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
134202
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
134200
134203
  else this.visitExpression(node.declaration);
134201
134204
  return;
134202
134205
  case "ImportDeclaration":
@@ -134605,7 +134608,7 @@ var init_AS003 = __esm({
134605
134608
  bindings.push(...this.collectDeclarationBindings(declaration));
134606
134609
  }
134607
134610
  for (const statement of body) {
134608
- if (statement.type === "ExportDefaultDeclaration" && statement.declaration.type === "ClassDeclaration") {
134611
+ if (statement.type === "ExportDefaultDeclaration" && (statement.declaration.type === "ClassDeclaration" || statement.declaration.type === "FunctionDeclaration") && statement.declaration.id !== void 0) {
134609
134612
  bindings.push({ kind: "let", name: statement.declaration.id.name });
134610
134613
  continue;
134611
134614
  }
@@ -134613,7 +134616,7 @@ var init_AS003 = __esm({
134613
134616
  bindings.push(...this.collectImportBindings(statement));
134614
134617
  continue;
134615
134618
  }
134616
- if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
134619
+ if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && statement.id !== void 0) {
134617
134620
  bindings.push({ kind: "let", name: statement.id.name });
134618
134621
  continue;
134619
134622
  }
@@ -134630,7 +134633,7 @@ var init_AS003 = __esm({
134630
134633
  collectBlockBindings(body) {
134631
134634
  const bindings = [];
134632
134635
  for (const statement of body) {
134633
- if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
134636
+ if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && statement.id !== void 0) {
134634
134637
  bindings.push({ kind: "let", name: statement.id.name });
134635
134638
  }
134636
134639
  if (statement.type === "VariableDeclaration" && statement.kind !== "var") {
@@ -134943,7 +134946,7 @@ var init_AS006_007 = __esm({
134943
134946
  this.visitVariableDeclaration(node.declaration);
134944
134947
  return;
134945
134948
  case "ExportDefaultDeclaration":
134946
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
134949
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
134947
134950
  else this.visitExpression(node.declaration);
134948
134951
  return;
134949
134952
  case "BlockStatement":
@@ -135391,11 +135394,15 @@ var init_AS006_007 = __esm({
135391
135394
  bindings.push(...this.collectDeclarationBindings(declaration));
135392
135395
  }
135393
135396
  for (const statement of body) {
135397
+ if (statement.type === "ExportDefaultDeclaration" && (statement.declaration.type === "FunctionDeclaration" || statement.declaration.type === "ClassDeclaration") && statement.declaration.id !== void 0) {
135398
+ bindings.push({ ...this.createBinding(statement.declaration.id, "let"), code: void 0 });
135399
+ continue;
135400
+ }
135394
135401
  if (statement.type === "ImportDeclaration") {
135395
135402
  bindings.push(...this.collectImportBindings(statement));
135396
135403
  continue;
135397
135404
  }
135398
- if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
135405
+ if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && statement.id !== void 0) {
135399
135406
  bindings.push(this.createBinding(statement.id, "let"));
135400
135407
  continue;
135401
135408
  }
@@ -135412,7 +135419,7 @@ var init_AS006_007 = __esm({
135412
135419
  collectBlockBindings(body) {
135413
135420
  const bindings = [];
135414
135421
  for (const statement of body) {
135415
- if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
135422
+ if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && statement.id !== void 0) {
135416
135423
  bindings.push(this.createBinding(statement.id, "let"));
135417
135424
  }
135418
135425
  if (statement.type === "VariableDeclaration" && statement.kind !== "var") {
@@ -135649,7 +135656,7 @@ var init_AS009 = __esm({
135649
135656
  this.visitVariableDeclaration(node.declaration);
135650
135657
  return;
135651
135658
  case "ExportDefaultDeclaration":
135652
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
135659
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
135653
135660
  else this.visitExpression(node.declaration);
135654
135661
  return;
135655
135662
  case "ImportDeclaration":
@@ -136164,7 +136171,7 @@ var init_AS010 = __esm({
136164
136171
  this.visitVariableDeclaration(node.declaration);
136165
136172
  return;
136166
136173
  case "ExportDefaultDeclaration":
136167
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
136174
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
136168
136175
  else this.visitExpression(node.declaration);
136169
136176
  return;
136170
136177
  case "ImportDeclaration":
@@ -136824,7 +136831,7 @@ var init_AS011 = __esm({
136824
136831
  this.visitVariableDeclaration(node.declaration);
136825
136832
  return;
136826
136833
  case "ExportDefaultDeclaration":
136827
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
136834
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
136828
136835
  else this.visitExpression(node.declaration);
136829
136836
  return;
136830
136837
  case "ImportDeclaration":
@@ -137276,7 +137283,7 @@ var init_AS015 = __esm({
137276
137283
  this.visitVariableDeclaration(node.declaration);
137277
137284
  return;
137278
137285
  case "ExportDefaultDeclaration":
137279
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
137286
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
137280
137287
  else this.visitExpression(node.declaration);
137281
137288
  return;
137282
137289
  case "ImportDeclaration":
@@ -137578,7 +137585,7 @@ function statementContainsAwait(node) {
137578
137585
  case "ExportNamedDeclaration":
137579
137586
  return variableDeclarationContainsAwait(node.declaration);
137580
137587
  case "ExportDefaultDeclaration":
137581
- return node.declaration.type === "ClassDeclaration" ? statementContainsAwait(node.declaration) : expressionContainsAwait(node.declaration);
137588
+ return node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration" ? statementContainsAwait(node.declaration) : expressionContainsAwait(node.declaration);
137582
137589
  case "ImportDeclaration":
137583
137590
  case "FunctionDeclaration":
137584
137591
  case "BreakStatement":
@@ -137782,7 +137789,7 @@ var init_AS_async_not_needed = __esm({
137782
137789
  this.visitArrowFunction(node.declaration, true);
137783
137790
  return;
137784
137791
  }
137785
- if (node.declaration.type === "FunctionExpression") {
137792
+ if (node.declaration.type === "FunctionExpression" || node.declaration.type === "FunctionDeclaration") {
137786
137793
  this.visitFunctionExpression(node.declaration, true);
137787
137794
  return;
137788
137795
  }
@@ -138209,7 +138216,7 @@ var init_AS_destructure_null_default = __esm({
138209
138216
  this.visitVariableDeclaration(node.declaration);
138210
138217
  return;
138211
138218
  case "ExportDefaultDeclaration":
138212
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
138219
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
138213
138220
  else this.visitExpression(node.declaration);
138214
138221
  return;
138215
138222
  case "ImportDeclaration":
@@ -138567,7 +138574,7 @@ function AS_EXPORT_IMPORT_META(source, options = {}) {
138567
138574
  ).scan(source);
138568
138575
  }
138569
138576
  function isDefaultExportCallable(node) {
138570
- return node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression";
138577
+ return node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression" || node.type === "FunctionDeclaration";
138571
138578
  }
138572
138579
  function hasParameterNames(node, names) {
138573
138580
  if (node.params.length !== names.length) {
@@ -138680,13 +138687,13 @@ var init_AS_export_import_meta = __esm({
138680
138687
  this.pushDiagnostic(
138681
138688
  "AS-EXPORT-DEFAULT-NOT-ARROW",
138682
138689
  "error",
138683
- "Export default initializer must be an arrow or function expression.",
138690
+ "Export default must be an arrow, function expression, or function declaration.",
138684
138691
  node.declaration.span
138685
138692
  );
138686
138693
  } else {
138687
138694
  this.visitDefaultExportSignature(node.declaration);
138688
138695
  }
138689
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
138696
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
138690
138697
  else this.visitExpression(node.declaration);
138691
138698
  return;
138692
138699
  case "BlockStatement":
@@ -139089,7 +139096,7 @@ var init_AS_floating_promise = __esm({
139089
139096
  this.visitVariableDeclaration(node.declaration);
139090
139097
  return;
139091
139098
  case "ExportDefaultDeclaration":
139092
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
139099
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
139093
139100
  else this.visitExpression(node.declaration);
139094
139101
  return;
139095
139102
  case "ImportDeclaration":
@@ -139499,8 +139506,9 @@ var init_AS_floating_promise = __esm({
139499
139506
  ];
139500
139507
  }
139501
139508
  collectBlockBindings(statements) {
139502
- return statements.flatMap((statement) => {
139503
- if (statement.type === "FunctionDeclaration") {
139509
+ return statements.flatMap((entry) => {
139510
+ const statement = entry.type === "ExportDefaultDeclaration" && entry.declaration.type === "FunctionDeclaration" ? entry.declaration : entry;
139511
+ if (statement.type === "FunctionDeclaration" && statement.id !== void 0) {
139504
139512
  return [
139505
139513
  { async: statement.async && !statement.generator, kind: "local", name: statement.id.name }
139506
139514
  ];
@@ -139732,7 +139740,7 @@ var init_AS_frontmatter_field_unused = __esm({
139732
139740
  this.visitVariableDeclaration(node.declaration);
139733
139741
  return;
139734
139742
  case "ExportDefaultDeclaration":
139735
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
139743
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
139736
139744
  else this.visitExpression(node.declaration);
139737
139745
  return;
139738
139746
  case "ImportDeclaration":
@@ -140593,7 +140601,7 @@ var init_AS_jsdoc_type = __esm({
140593
140601
  );
140594
140602
  return;
140595
140603
  case "ExportDefaultDeclaration":
140596
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
140604
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
140597
140605
  else this.visitExpression(node.declaration);
140598
140606
  return;
140599
140607
  case "ImportDeclaration":
@@ -140999,7 +141007,7 @@ var init_AS_large_literal = __esm({
140999
141007
  this.visitVariableDeclaration(node.declaration);
141000
141008
  return;
141001
141009
  case "ExportDefaultDeclaration":
141002
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
141010
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
141003
141011
  else this.visitExpression(node.declaration);
141004
141012
  return;
141005
141013
  case "ImportDeclaration":
@@ -141339,7 +141347,7 @@ function statementContainsAwait2(node) {
141339
141347
  case "ExportNamedDeclaration":
141340
141348
  return variableDeclarationContainsAwait2(node.declaration);
141341
141349
  case "ExportDefaultDeclaration":
141342
- return node.declaration.type === "ClassDeclaration" ? statementContainsAwait2(node.declaration) : expressionContainsAwait2(node.declaration);
141350
+ return node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration" ? statementContainsAwait2(node.declaration) : expressionContainsAwait2(node.declaration);
141343
141351
  case "ImportDeclaration":
141344
141352
  case "FunctionDeclaration":
141345
141353
  case "BreakStatement":
@@ -141537,7 +141545,7 @@ var init_AS_missing_async = __esm({
141537
141545
  this.visitVariableDeclaration(node.declaration);
141538
141546
  return;
141539
141547
  case "ExportDefaultDeclaration":
141540
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
141548
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
141541
141549
  else this.visitExpression(node.declaration);
141542
141550
  return;
141543
141551
  case "ImportDeclaration":
@@ -141961,7 +141969,7 @@ var init_AS_mutating_frozen = __esm({
141961
141969
  this.visitVariableDeclaration(node.declaration);
141962
141970
  return;
141963
141971
  case "ExportDefaultDeclaration":
141964
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
141972
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
141965
141973
  else this.visitExpression(node.declaration);
141966
141974
  return;
141967
141975
  case "ImportDeclaration":
@@ -142475,7 +142483,7 @@ var init_AS_needless_template = __esm({
142475
142483
  this.visitVariableDeclaration(node.declaration);
142476
142484
  return;
142477
142485
  case "ExportDefaultDeclaration":
142478
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
142486
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
142479
142487
  else this.visitExpression(node.declaration);
142480
142488
  return;
142481
142489
  case "ImportDeclaration":
@@ -142859,7 +142867,7 @@ var init_AS_shadow_global = __esm({
142859
142867
  this.visitVariableDeclaration(node.declaration);
142860
142868
  return;
142861
142869
  case "ExportDefaultDeclaration":
142862
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
142870
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
142863
142871
  else this.visitExpression(node.declaration);
142864
142872
  return;
142865
142873
  case "ImportDeclaration":
@@ -143336,7 +143344,7 @@ var init_AS_unbounded_loop = __esm({
143336
143344
  this.visitVariableDeclaration(node.declaration);
143337
143345
  return;
143338
143346
  case "ExportDefaultDeclaration":
143339
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
143347
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
143340
143348
  else this.visitExpression(node.declaration);
143341
143349
  return;
143342
143350
  case "ImportDeclaration":
@@ -143678,7 +143686,7 @@ var init_AS_unreachable = __esm({
143678
143686
  this.visitVariableDeclaration(node.declaration);
143679
143687
  return false;
143680
143688
  case "ExportDefaultDeclaration":
143681
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
143689
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
143682
143690
  else this.visitExpression(node.declaration);
143683
143691
  return false;
143684
143692
  case "ImportDeclaration":
@@ -144048,7 +144056,7 @@ var init_AS_unused_import = __esm({
144048
144056
  this.visitVariableDeclaration(node.declaration);
144049
144057
  return;
144050
144058
  case "ExportDefaultDeclaration":
144051
- if (node.declaration.type === "ClassDeclaration") this.visitStatement(node.declaration);
144059
+ if (node.declaration.type === "ClassDeclaration" || node.declaration.type === "FunctionDeclaration") this.visitStatement(node.declaration);
144052
144060
  else this.visitExpression(node.declaration);
144053
144061
  return;
144054
144062
  case "BlockStatement":
@@ -144416,11 +144424,15 @@ var init_AS_unused_import = __esm({
144416
144424
  collectModuleBindings(body) {
144417
144425
  const bindings = [];
144418
144426
  for (const statement of body) {
144427
+ if (statement.type === "ExportDefaultDeclaration" && (statement.declaration.type === "FunctionDeclaration" || statement.declaration.type === "ClassDeclaration") && statement.declaration.id !== void 0) {
144428
+ bindings.push({ kind: "let", name: statement.declaration.id.name });
144429
+ continue;
144430
+ }
144419
144431
  if (statement.type === "ImportDeclaration") {
144420
144432
  bindings.push(...this.collectImportBindings(statement));
144421
144433
  continue;
144422
144434
  }
144423
- if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
144435
+ if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && statement.id !== void 0) {
144424
144436
  bindings.push({ kind: "let", name: statement.id.name });
144425
144437
  continue;
144426
144438
  }
@@ -144437,7 +144449,7 @@ var init_AS_unused_import = __esm({
144437
144449
  collectBlockBindings(body) {
144438
144450
  const bindings = [];
144439
144451
  for (const statement of body) {
144440
- if (statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") {
144452
+ if ((statement.type === "FunctionDeclaration" || statement.type === "ClassDeclaration") && statement.id !== void 0) {
144441
144453
  bindings.push({ kind: "let", name: statement.id.name });
144442
144454
  }
144443
144455
  if (statement.type === "VariableDeclaration") {
@@ -149585,6 +149597,7 @@ async function evaluateArrowFunction(node, context) {
149585
149597
  return evaluateArrowFunctionExpression(node, context, evaluateNode2);
149586
149598
  }
149587
149599
  async function evaluateFunctionDeclaration(node, context) {
149600
+ if (node.id === void 0) throw new Error("An anonymous declaration requires a default export.");
149588
149601
  if (!context.scope.hasOwnBinding(node.id.name)) {
149589
149602
  context.scope.declare(
149590
149603
  node.id.name,
@@ -149875,6 +149888,10 @@ async function evaluateMetaProperty(_node, context) {
149875
149888
  };
149876
149889
  }
149877
149890
  async function evaluateExportDefaultDeclaration(node, context) {
149891
+ if (node.declaration.type === "FunctionDeclaration") {
149892
+ if (!context.scope.hasOwnBinding("default")) predeclareStatementListBindings([node], context);
149893
+ return { kind: "normal", hasValue: false, value: void 0 };
149894
+ }
149878
149895
  const declaration = await evaluateNode2(node.declaration, { ...context, inferredName: "default" });
149879
149896
  if (declaration.kind !== "normal") {
149880
149897
  return declaration;
@@ -150101,25 +150118,23 @@ function predeclareBlockBindings2(node, context) {
150101
150118
  function predeclareStatementListBindings(statements, context, functionBody = false) {
150102
150119
  const { scope } = context;
150103
150120
  const names = /* @__PURE__ */ new Set();
150104
- for (const statement of statements) {
150105
- if (statement.type === "ExportDefaultDeclaration" && statement.declaration.type === "ClassDeclaration") {
150106
- scope.predeclare(statement.declaration.id.name, "let");
150107
- names.add(statement.declaration.id.name);
150108
- continue;
150109
- }
150121
+ for (const entry of statements) {
150122
+ const exportedFunction = entry.type === "ExportDefaultDeclaration" && entry.declaration.type === "FunctionDeclaration";
150123
+ const statement = entry.type === "ExportDefaultDeclaration" && (entry.declaration.type === "ClassDeclaration" || entry.declaration.type === "FunctionDeclaration") ? entry.declaration : entry;
150110
150124
  if (statement.type === "ClassDeclaration") {
150111
150125
  scope.predeclare(statement.id.name, "let");
150112
150126
  names.add(statement.id.name);
150113
150127
  continue;
150114
150128
  }
150115
150129
  if (statement.type === "FunctionDeclaration") {
150116
- const name = statement.id.name;
150117
- if (names.has(name) && !(functionBody && scope.getOwnBindingKind(name) === "var")) {
150130
+ if (statement.id === void 0 && !exportedFunction) throw new Error("An anonymous declaration requires a default export.");
150131
+ const name = statement.id?.name ?? "default";
150132
+ if (names.has(name) && !(!exportedFunction && functionBody && scope.getOwnBindingKind(name) === "var")) {
150118
150133
  throw new Error(`Cannot redeclare binding '${name}' in the same scope.`);
150119
150134
  }
150120
- const closure = createInterpretedClosure(statement, context, evaluateNode2);
150135
+ const closure = createInterpretedClosure(statement, exportedFunction ? { ...context, inferredName: name } : context, evaluateNode2);
150121
150136
  const ownBindingKind = scope.getOwnBindingKind(name);
150122
- if (ownBindingKind === "var") {
150137
+ if (ownBindingKind === "var" && !exportedFunction) {
150123
150138
  names.add(name);
150124
150139
  scope.assign(name, closure);
150125
150140
  continue;
@@ -150128,7 +150143,8 @@ function predeclareStatementListBindings(statements, context, functionBody = fal
150128
150143
  throw new Error(`Cannot redeclare binding '${name}' in the same scope.`);
150129
150144
  }
150130
150145
  names.add(name);
150131
- scope.declare(name, functionBody ? "var" : "let", closure);
150146
+ scope.declare(name, exportedFunction ? statement.id === void 0 ? "const" : "let" : functionBody ? "var" : "let", closure);
150147
+ if (exportedFunction && statement.id !== void 0) scope.declareAlias("default", name);
150132
150148
  continue;
150133
150149
  }
150134
150150
  if (statement.type !== "VariableDeclaration" || statement.kind === "var") {
@@ -150284,18 +150300,27 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
150284
150300
  context.activeLoopIterations.delete(nodeId);
150285
150301
  return normalEmptyResult();
150286
150302
  }
150303
+ const nextValue = iteration.value;
150287
150304
  context.activeLoopIterations.set(
150288
150305
  nodeId,
150289
150306
  iterator.snapshotIndex === void 0 ? index : {
150290
150307
  get index() {
150291
150308
  return iterator.snapshotIndex();
150292
150309
  },
150293
- values: [value, iteration.value]
150310
+ values: [value, nextValue]
150294
150311
  }
150295
150312
  );
150296
150313
  const scope = context.scope.child();
150297
- const binding = await bindForOfLoopVariable(node.left, iteration.value, scope, context);
150314
+ let binding;
150315
+ try {
150316
+ binding = await bindForOfLoopVariable(node.left, nextValue, scope, context);
150317
+ } catch (error3) {
150318
+ if (isFatalSandboxError(error3) || error3 instanceof HostCallResumabilityError) throw error3;
150319
+ await closeIterator(iterator, true);
150320
+ throw error3;
150321
+ }
150298
150322
  if (!binding.ok) {
150323
+ await closeIterator(iterator, binding.result.kind === "throw");
150299
150324
  return binding.result;
150300
150325
  }
150301
150326
  const iterationContext = createLoopIterationContext(context, scope);
@@ -150312,7 +150337,7 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
150312
150337
  }
150313
150338
  if (result.kind !== "normal") {
150314
150339
  context.activeLoopIterations.delete(nodeId);
150315
- await closeIterator(iterator);
150340
+ await closeIterator(iterator, result.kind === "throw");
150316
150341
  return result;
150317
150342
  }
150318
150343
  index += 1;
@@ -150605,11 +150630,8 @@ function hasLoopLabel(labels, target) {
150605
150630
  return Array.isArray(labels) ? labels.includes(target) : labels === target;
150606
150631
  }
150607
150632
  async function bindForOfLoopVariable(left, value, scope, context) {
150608
- if (left.type === "Identifier") {
150609
- return bindPattern2(left, value, { assign: true }, scope, createPatternContext(context, scope));
150610
- }
150611
150633
  if (left.type !== "VariableDeclaration") {
150612
- throw new TypeError(`Unsupported for...of left-hand side '${left.type}'.`);
150634
+ return bindPattern2(left, value, { assign: true }, scope, createPatternContext(context, scope));
150613
150635
  }
150614
150636
  const [declarator] = left.declarations;
150615
150637
  if (left.declarations.length !== 1 || declarator === void 0) {
@@ -152024,9 +152046,19 @@ function describeObjectSpreadValue(value) {
152024
152046
  }
152025
152047
  return typeof value;
152026
152048
  }
152027
- async function closeIterator(iterator) {
152028
- if (iterator.generator && iterator.return !== void 0) {
152029
- await iterator.return();
152049
+ async function closeIterator(iterator, preserveThrow = false) {
152050
+ try {
152051
+ const close = iterator.return;
152052
+ if (close === void 0) return;
152053
+ const returned = close();
152054
+ const result = iterator.generator || iterator.asynchronous ? await returned : returned;
152055
+ if (typeof result !== "object" && typeof result !== "function" || result === null) {
152056
+ throw new TypeError("Iterator return result must be an object.");
152057
+ }
152058
+ } catch (error3) {
152059
+ if (!preserveThrow || isFatalSandboxError(error3) || error3 instanceof HostCallResumabilityError) {
152060
+ throw error3;
152061
+ }
152030
152062
  }
152031
152063
  }
152032
152064
  function defineSandboxProperty(target, key3, value) {