@poe-platform/safe-js 0.1.582 → 0.1.584

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 (58) hide show
  1. package/dist/safe-js/chunks/{chunk-2LRIFIS2.js → chunk-4DPRV34R.js} +2 -2
  2. package/dist/safe-js/chunks/{chunk-FGSHNQZD.js → chunk-63JRSQOL.js} +3 -3
  3. package/dist/safe-js/chunks/{chunk-WBFZHDKE.js → chunk-7PX7MOB4.js} +6 -6
  4. package/dist/safe-js/chunks/{chunk-GT6KJSXR.js → chunk-AMO5WXVQ.js} +4 -4
  5. package/dist/safe-js/chunks/{chunk-BZ2HQIKQ.js → chunk-AMY5ETO5.js} +4 -4
  6. package/dist/safe-js/chunks/{chunk-GMWNREUZ.js → chunk-EAHOLZQ2.js} +3 -3
  7. package/dist/safe-js/chunks/{chunk-ONUOT3QR.js → chunk-EUQCKN74.js} +3 -3
  8. package/dist/safe-js/chunks/{chunk-J56RIONZ.js → chunk-F6K7WXYP.js} +2 -2
  9. package/dist/safe-js/chunks/{chunk-H4K3LRXJ.js → chunk-J23VJ4EG.js} +2 -2
  10. package/dist/safe-js/chunks/{chunk-47LQJKGT.js → chunk-OMSG6GZF.js} +95 -39
  11. package/dist/safe-js/chunks/chunk-OMSG6GZF.js.map +7 -0
  12. package/dist/safe-js/chunks/{chunk-6H4RX6ZZ.js → chunk-PTB5KJXJ.js} +2 -2
  13. package/dist/safe-js/chunks/{chunk-FVBRBOAB.js → chunk-Q2PTRBJS.js} +2 -2
  14. package/dist/safe-js/chunks/{chunk-ADUXPMQM.js → chunk-XXUVGE2L.js} +2 -2
  15. package/dist/safe-js/chunks/{cli-runtime-GKFPKXDB.js → cli-runtime-PRCR2J63.js} +13 -13
  16. package/dist/safe-js/chunks/{dump-QOUJIAJ6.js → dump-SGDGD32M.js} +4 -4
  17. package/dist/safe-js/chunks/{fs-IAKJ3MES.js → fs-LOAD43QB.js} +4 -4
  18. package/dist/safe-js/chunks/harness-PYDC7ICR.js +10 -0
  19. package/dist/safe-js/chunks/mcp-SL5B3WKQ.js +11 -0
  20. package/dist/safe-js/chunks/migration-file-RIMCERFB.js +12 -0
  21. package/dist/safe-js/chunks/restore-CJSMB4QO.js +13 -0
  22. package/dist/safe-js/chunks/run-ZTGDITEC.js +17 -0
  23. package/dist/safe-js/chunks/runtime-modules-M5XUCL6O.js +10 -0
  24. package/dist/safe-js/cli.js +2 -2
  25. package/dist/safe-js/core.js +7 -7
  26. package/dist/safe-js/index.js +13 -13
  27. package/dist/safe-js/parse/tokenizer.d.ts +1 -0
  28. package/dist/safe-js/workerd.js +93 -37
  29. package/dist/safe-js/workerd.js.map +2 -2
  30. package/package.json +2 -2
  31. package/dist/safe-js/chunks/chunk-47LQJKGT.js.map +0 -7
  32. package/dist/safe-js/chunks/harness-6OV7HVLE.js +0 -10
  33. package/dist/safe-js/chunks/mcp-6IGCCQLK.js +0 -11
  34. package/dist/safe-js/chunks/migration-file-BOE3NXK3.js +0 -12
  35. package/dist/safe-js/chunks/restore-B6CSGGER.js +0 -13
  36. package/dist/safe-js/chunks/run-OGRMHDQG.js +0 -17
  37. package/dist/safe-js/chunks/runtime-modules-M3KCXZ62.js +0 -10
  38. /package/dist/safe-js/chunks/{chunk-2LRIFIS2.js.map → chunk-4DPRV34R.js.map} +0 -0
  39. /package/dist/safe-js/chunks/{chunk-FGSHNQZD.js.map → chunk-63JRSQOL.js.map} +0 -0
  40. /package/dist/safe-js/chunks/{chunk-WBFZHDKE.js.map → chunk-7PX7MOB4.js.map} +0 -0
  41. /package/dist/safe-js/chunks/{chunk-GT6KJSXR.js.map → chunk-AMO5WXVQ.js.map} +0 -0
  42. /package/dist/safe-js/chunks/{chunk-BZ2HQIKQ.js.map → chunk-AMY5ETO5.js.map} +0 -0
  43. /package/dist/safe-js/chunks/{chunk-GMWNREUZ.js.map → chunk-EAHOLZQ2.js.map} +0 -0
  44. /package/dist/safe-js/chunks/{chunk-ONUOT3QR.js.map → chunk-EUQCKN74.js.map} +0 -0
  45. /package/dist/safe-js/chunks/{chunk-J56RIONZ.js.map → chunk-F6K7WXYP.js.map} +0 -0
  46. /package/dist/safe-js/chunks/{chunk-H4K3LRXJ.js.map → chunk-J23VJ4EG.js.map} +0 -0
  47. /package/dist/safe-js/chunks/{chunk-6H4RX6ZZ.js.map → chunk-PTB5KJXJ.js.map} +0 -0
  48. /package/dist/safe-js/chunks/{chunk-FVBRBOAB.js.map → chunk-Q2PTRBJS.js.map} +0 -0
  49. /package/dist/safe-js/chunks/{chunk-ADUXPMQM.js.map → chunk-XXUVGE2L.js.map} +0 -0
  50. /package/dist/safe-js/chunks/{cli-runtime-GKFPKXDB.js.map → cli-runtime-PRCR2J63.js.map} +0 -0
  51. /package/dist/safe-js/chunks/{dump-QOUJIAJ6.js.map → dump-SGDGD32M.js.map} +0 -0
  52. /package/dist/safe-js/chunks/{fs-IAKJ3MES.js.map → fs-LOAD43QB.js.map} +0 -0
  53. /package/dist/safe-js/chunks/{harness-6OV7HVLE.js.map → harness-PYDC7ICR.js.map} +0 -0
  54. /package/dist/safe-js/chunks/{mcp-6IGCCQLK.js.map → mcp-SL5B3WKQ.js.map} +0 -0
  55. /package/dist/safe-js/chunks/{migration-file-BOE3NXK3.js.map → migration-file-RIMCERFB.js.map} +0 -0
  56. /package/dist/safe-js/chunks/{restore-B6CSGGER.js.map → restore-CJSMB4QO.js.map} +0 -0
  57. /package/dist/safe-js/chunks/{run-OGRMHDQG.js.map → run-ZTGDITEC.js.map} +0 -0
  58. /package/dist/safe-js/chunks/{runtime-modules-M3KCXZ62.js.map → runtime-modules-M5XUCL6O.js.map} +0 -0
@@ -39,7 +39,7 @@ import {
39
39
  sandboxErrorTypes,
40
40
  syntaxDiagnostics,
41
41
  templateRealms
42
- } from "./chunk-47LQJKGT.js";
42
+ } from "./chunk-OMSG6GZF.js";
43
43
 
44
44
  // packages/safe-js/src/interp/native-promise-properties.ts
45
45
  import { types } from "node:util";
@@ -47092,4 +47092,4 @@ authorization of the copyright holder.
47092
47092
  SPDX-License-Identifier: Unicode-3.0
47093
47093
 
47094
47094
  */
47095
- //# sourceMappingURL=chunk-2LRIFIS2.js.map
47095
+ //# sourceMappingURL=chunk-4DPRV34R.js.map
@@ -2,14 +2,14 @@ import {
2
2
  HostCallJournal,
3
3
  decodeReplayData,
4
4
  validateSnapshotData
5
- } from "./chunk-2LRIFIS2.js";
5
+ } from "./chunk-4DPRV34R.js";
6
6
  import {
7
7
  CompileScope,
8
8
  SandboxError,
9
9
  functionSources,
10
10
  parse,
11
11
  parseModule
12
- } from "./chunk-47LQJKGT.js";
12
+ } from "./chunk-OMSG6GZF.js";
13
13
 
14
14
  // packages/safe-js/src/parse/hash.ts
15
15
  var FNV_OFFSET_BASIS = 2166136261;
@@ -219,4 +219,4 @@ export {
219
219
  validateMigrationReconciliation,
220
220
  validateSnapshotMigration
221
221
  };
222
- //# sourceMappingURL=chunk-FGSHNQZD.js.map
222
+ //# sourceMappingURL=chunk-63JRSQOL.js.map
@@ -3,11 +3,11 @@ import {
3
3
  } from "./chunk-BRFJ7BKN.js";
4
4
  import {
5
5
  restore
6
- } from "./chunk-BZ2HQIKQ.js";
6
+ } from "./chunk-AMY5ETO5.js";
7
7
  import {
8
8
  attachDumpController,
9
9
  createDumpController
10
- } from "./chunk-GMWNREUZ.js";
10
+ } from "./chunk-EAHOLZQ2.js";
11
11
  import {
12
12
  getOwnErrorCode,
13
13
  hasOwnErrorCode
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  hashParsedAst,
17
17
  hashSource
18
- } from "./chunk-FGSHNQZD.js";
18
+ } from "./chunk-63JRSQOL.js";
19
19
  import {
20
20
  DUMP_FORMAT_VERSION,
21
21
  EXECUTION_SEMANTICS,
@@ -89,7 +89,7 @@ import {
89
89
  withSandboxPromiseRejectionTracker,
90
90
  wrapCallerInjectedBindings,
91
91
  wrapCancelableBindings
92
- } from "./chunk-2LRIFIS2.js";
92
+ } from "./chunk-4DPRV34R.js";
93
93
  import {
94
94
  Budget,
95
95
  CompileScope,
@@ -103,7 +103,7 @@ import {
103
103
  parseExecutableModule,
104
104
  replaceErrorStack,
105
105
  safeAddEvent
106
- } from "./chunk-47LQJKGT.js";
106
+ } from "./chunk-OMSG6GZF.js";
107
107
 
108
108
  // packages/safe-js/src/realm.ts
109
109
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -2037,4 +2037,4 @@ export {
2037
2037
  UnhandledRejectionError,
2038
2038
  run
2039
2039
  };
2040
- //# sourceMappingURL=chunk-WBFZHDKE.js.map
2040
+ //# sourceMappingURL=chunk-7PX7MOB4.js.map
@@ -7,7 +7,7 @@ import {
7
7
  validateMigrationReconciliation,
8
8
  validateMigrationSemantics,
9
9
  validateSnapshotMigration
10
- } from "./chunk-FGSHNQZD.js";
10
+ } from "./chunk-63JRSQOL.js";
11
11
  import {
12
12
  DUMP_FORMAT_VERSION,
13
13
  EXECUTION_SEMANTICS,
@@ -17,10 +17,10 @@ import {
17
17
  serializeSafeJSSnapshot,
18
18
  validateDumpEnvelope,
19
19
  validateSnapshotData
20
- } from "./chunk-2LRIFIS2.js";
20
+ } from "./chunk-4DPRV34R.js";
21
21
  import {
22
22
  parseModule
23
- } from "./chunk-47LQJKGT.js";
23
+ } from "./chunk-OMSG6GZF.js";
24
24
 
25
25
  // packages/safe-js/src/migration-file.ts
26
26
  import { randomUUID } from "node:crypto";
@@ -179,4 +179,4 @@ export {
179
179
  migrateSnapshot,
180
180
  migrateSnapshotFile
181
181
  };
182
- //# sourceMappingURL=chunk-GT6KJSXR.js.map
182
+ //# sourceMappingURL=chunk-AMO5WXVQ.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  hashSource,
3
3
  validateSnapshotMigration
4
- } from "./chunk-FGSHNQZD.js";
4
+ } from "./chunk-63JRSQOL.js";
5
5
  import {
6
6
  SnapshotValidationError,
7
7
  assertSnapshotInactive,
@@ -13,12 +13,12 @@ import {
13
13
  validateDumpEnvelope,
14
14
  validateGuestFunctionAst,
15
15
  validateTemplateObjects
16
- } from "./chunk-2LRIFIS2.js";
16
+ } from "./chunk-4DPRV34R.js";
17
17
  import {
18
18
  ParseError,
19
19
  parseModule,
20
20
  replaceErrorStack
21
- } from "./chunk-47LQJKGT.js";
21
+ } from "./chunk-OMSG6GZF.js";
22
22
 
23
23
  // packages/safe-js/src/restore.ts
24
24
  var SnapshotMismatchError = class extends Error {
@@ -110,4 +110,4 @@ export {
110
110
  SnapshotMismatchError,
111
111
  restore
112
112
  };
113
- //# sourceMappingURL=chunk-BZ2HQIKQ.js.map
113
+ //# sourceMappingURL=chunk-AMY5ETO5.js.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  SnapshotNotReadyError,
3
3
  serializeSafeJSSnapshot
4
- } from "./chunk-2LRIFIS2.js";
4
+ } from "./chunk-4DPRV34R.js";
5
5
  import {
6
6
  SandboxError
7
- } from "./chunk-47LQJKGT.js";
7
+ } from "./chunk-OMSG6GZF.js";
8
8
 
9
9
  // packages/safe-js/src/snapshot/dump.ts
10
10
  var RUN_DUMP_CONTROLLER = /* @__PURE__ */ Symbol("SafeJS.run-dump-controller");
@@ -195,4 +195,4 @@ export {
195
195
  dumpCurrent,
196
196
  serializeRunSnapshot
197
197
  };
198
- //# sourceMappingURL=chunk-GMWNREUZ.js.map
198
+ //# sourceMappingURL=chunk-EAHOLZQ2.js.map
@@ -6,10 +6,10 @@ import {
6
6
  import {
7
7
  declareHostOperation,
8
8
  runResources
9
- } from "./chunk-2LRIFIS2.js";
9
+ } from "./chunk-4DPRV34R.js";
10
10
  import {
11
11
  hostErrorData
12
- } from "./chunk-47LQJKGT.js";
12
+ } from "./chunk-OMSG6GZF.js";
13
13
 
14
14
  // packages/safe-js/src/modules/mcp.ts
15
15
  var DEFAULT_TOOL_BATCH_CONCURRENCY = 4;
@@ -402,4 +402,4 @@ function isPlainObjectRecord(value) {
402
402
  export {
403
403
  makeMcpModule
404
404
  };
405
- //# sourceMappingURL=chunk-ONUOT3QR.js.map
405
+ //# sourceMappingURL=chunk-EUQCKN74.js.map
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-SJZWSPWD.js";
7
7
  import {
8
8
  declareHostOperation
9
- } from "./chunk-2LRIFIS2.js";
9
+ } from "./chunk-4DPRV34R.js";
10
10
 
11
11
  // packages/safe-js/src/modules/fs.ts
12
12
  import { constants as nodeFsConstants } from "node:fs";
@@ -673,4 +673,4 @@ export {
673
673
  FS_OPTION_SURFACE,
674
674
  makeFsModule
675
675
  };
676
- //# sourceMappingURL=chunk-J56RIONZ.js.map
676
+ //# sourceMappingURL=chunk-F6K7WXYP.js.map
@@ -8,7 +8,7 @@ import {
8
8
  numericTypedArrayConstructors,
9
9
  parseModule,
10
10
  tokenize
11
- } from "./chunk-47LQJKGT.js";
11
+ } from "./chunk-OMSG6GZF.js";
12
12
 
13
13
  // packages/safe-js/src/lint/rules/AS001.ts
14
14
  function AS001(source, options = {}) {
@@ -11176,4 +11176,4 @@ function hasOnlyRegexLiteralDiagnostics(diagnostics) {
11176
11176
  export {
11177
11177
  lint
11178
11178
  };
11179
- //# sourceMappingURL=chunk-H4K3LRXJ.js.map
11179
+ //# sourceMappingURL=chunk-J23VJ4EG.js.map
@@ -1149,7 +1149,7 @@ var KEYWORDS = /* @__PURE__ */ new Set([
1149
1149
  ]);
1150
1150
  var EXPRESSION_ENDING_KEYWORDS = /* @__PURE__ */ new Set(["true", "false", "null"]);
1151
1151
  var RESERVED_IDENTIFIER_SPELLINGS = /* @__PURE__ */ new Set(["case", "default", "debugger", "enum", "export", "new", "switch", "var"]);
1152
- var CONTROL_FLOW_PAREN_KEYWORDS = /* @__PURE__ */ new Set(["if", "while", "with", "for", "catch"]);
1152
+ var CONTROL_FLOW_PAREN_KEYWORDS = /* @__PURE__ */ new Set(["if", "while", "with", "for", "catch", "switch"]);
1153
1153
  var MAX_UNICODE_CODE_POINT = 1114111;
1154
1154
  var IDENTIFIER_START_PATTERN = new RegExp("^\\p{ID_Start}$", "u");
1155
1155
  var IDENTIFIER_PART_PATTERN = new RegExp("^\\p{ID_Continue}$", "u");
@@ -1220,7 +1220,7 @@ function tokenize(source, options = {}) {
1220
1220
  }
1221
1221
  function collectComments(source) {
1222
1222
  const comments = [];
1223
- tokenize(source, { allowRegexLiterals: true, comments });
1223
+ tokenize(source, { allowRegexLiterals: true, statementList: true, comments });
1224
1224
  return comments;
1225
1225
  }
1226
1226
  var Lexer = class {
@@ -1234,8 +1234,8 @@ var Lexer = class {
1234
1234
  line = 1;
1235
1235
  column = 1;
1236
1236
  tokens = [];
1237
- groupingStack = [];
1238
- lastClosedControlParenthesis = false;
1237
+ groupingState = { stack: [], classHeads: [], tokenCount: 0 };
1238
+ lastClosedStatementBoundary = false;
1239
1239
  legacyStringEscape = false;
1240
1240
  lineHasToken = false;
1241
1241
  tokenize() {
@@ -1407,8 +1407,8 @@ var Lexer = class {
1407
1407
  skipTemplateExpression(start) {
1408
1408
  let depth = 1;
1409
1409
  const tokens = [];
1410
- const groupingStack = [];
1411
- let lastClosedControlParenthesis = false;
1410
+ const groupingState = { stack: [], classHeads: [], tokenCount: 0 };
1411
+ let lastClosedStatementBoundary = false;
1412
1412
  while (!this.isAtEnd() && depth > 0) {
1413
1413
  this.skipTrivia();
1414
1414
  if (this.isAtEnd()) break;
@@ -1419,13 +1419,13 @@ var Lexer = class {
1419
1419
  if (char === "'" || char === '"') {
1420
1420
  this.skipQuotedString(char);
1421
1421
  tokens.push({ type: "string", value: char });
1422
- lastClosedControlParenthesis = false;
1422
+ lastClosedStatementBoundary = false;
1423
1423
  continue;
1424
1424
  }
1425
1425
  if (char === "`") {
1426
1426
  this.skipNestedTemplate();
1427
1427
  tokens.push({ type: "template", value: "`" });
1428
- lastClosedControlParenthesis = false;
1428
+ lastClosedStatementBoundary = false;
1429
1429
  continue;
1430
1430
  }
1431
1431
  if (char === "/" && this.peekChar(1) === "/") {
@@ -1464,22 +1464,23 @@ var Lexer = class {
1464
1464
  isStart = false;
1465
1465
  }
1466
1466
  tokens.push({ type: KEYWORDS.has(value) ? "keyword" : "identifier", value });
1467
- lastClosedControlParenthesis = false;
1467
+ lastClosedStatementBoundary = false;
1468
1468
  continue;
1469
1469
  }
1470
1470
  if (isDecimalDigit(char) || char === "." && isDecimalDigit(this.peekChar(1))) {
1471
1471
  const start2 = this.position();
1472
1472
  const value = this.scanNumber(start2);
1473
1473
  tokens.push({ type: "numeric", value });
1474
- lastClosedControlParenthesis = false;
1474
+ lastClosedStatementBoundary = false;
1475
1475
  continue;
1476
1476
  }
1477
1477
  if (char === "{") {
1478
1478
  depth += 1;
1479
1479
  this.advance();
1480
- groupingStack.push({ value: "{" });
1480
+ const previousToken = tokens[tokens.length - 1];
1481
1481
  tokens.push({ type: "punctuator", value: "{" });
1482
- lastClosedControlParenthesis = false;
1482
+ updateGroupingState(groupingState, previousToken, "{", lastClosedStatementBoundary, false, tokens);
1483
+ lastClosedStatementBoundary = false;
1483
1484
  continue;
1484
1485
  }
1485
1486
  if (char === "}") {
@@ -1488,19 +1489,19 @@ var Lexer = class {
1488
1489
  if (depth === 0) {
1489
1490
  return;
1490
1491
  }
1491
- popGroupingContext(groupingStack, "{");
1492
+ const previousToken = tokens[tokens.length - 1];
1492
1493
  tokens.push({ type: "punctuator", value: "}" });
1493
- lastClosedControlParenthesis = false;
1494
+ lastClosedStatementBoundary = updateGroupingState(groupingState, previousToken, "}", lastClosedStatementBoundary, false, tokens);
1494
1495
  continue;
1495
1496
  }
1496
- if (char === "/" && shouldRejectRegexLiteral(tokens[tokens.length - 1], lastClosedControlParenthesis, tokens)) {
1497
+ if (char === "/" && shouldRejectRegexLiteral(tokens[tokens.length - 1], lastClosedStatementBoundary, tokens)) {
1497
1498
  if (!this.options.allowRegexLiterals) {
1498
1499
  this.syntaxError("Regular expression literals are not supported", this.position());
1499
1500
  }
1500
1501
  const start2 = this.position();
1501
1502
  const value = this.scanRegexLiteral(start2);
1502
1503
  tokens.push({ type: "regex", value });
1503
- lastClosedControlParenthesis = false;
1504
+ lastClosedStatementBoundary = false;
1504
1505
  continue;
1505
1506
  }
1506
1507
  const punctuator = matchPunctuator(this.source, this.index);
@@ -1508,10 +1509,13 @@ var Lexer = class {
1508
1509
  const previousToken = tokens[tokens.length - 1];
1509
1510
  this.advanceBy(punctuator.length);
1510
1511
  tokens.push({ type: "punctuator", value: punctuator });
1511
- lastClosedControlParenthesis = updateGroupingState(
1512
- groupingStack,
1512
+ lastClosedStatementBoundary = updateGroupingState(
1513
+ groupingState,
1513
1514
  previousToken,
1514
- punctuator
1515
+ punctuator,
1516
+ lastClosedStatementBoundary,
1517
+ false,
1518
+ tokens
1515
1519
  );
1516
1520
  continue;
1517
1521
  }
@@ -1782,7 +1786,7 @@ var Lexer = class {
1782
1786
  }
1783
1787
  }
1784
1788
  readSlashOrPunctuator(start) {
1785
- if (this.currentChar() === "/" && shouldRejectRegexLiteral(this.lastSignificantToken(), this.lastClosedControlParenthesis, this.tokens)) {
1789
+ if (this.currentChar() === "/" && shouldRejectRegexLiteral(this.lastSignificantToken(), this.lastClosedStatementBoundary, this.tokens)) {
1786
1790
  if (!this.options.allowRegexLiterals) {
1787
1791
  this.syntaxError("Regular expression literals are not supported", start);
1788
1792
  }
@@ -1869,14 +1873,17 @@ var Lexer = class {
1869
1873
  };
1870
1874
  this.tokens.push(token);
1871
1875
  if (type === "punctuator") {
1872
- this.lastClosedControlParenthesis = updateGroupingState(
1873
- this.groupingStack,
1876
+ this.lastClosedStatementBoundary = updateGroupingState(
1877
+ this.groupingState,
1874
1878
  previousToken,
1875
- value
1879
+ value,
1880
+ this.lastClosedStatementBoundary,
1881
+ this.options.statementList === true,
1882
+ this.tokens
1876
1883
  );
1877
1884
  return;
1878
1885
  }
1879
- this.lastClosedControlParenthesis = false;
1886
+ this.lastClosedStatementBoundary = false;
1880
1887
  }
1881
1888
  currentChar() {
1882
1889
  return this.source[this.index] ?? "";
@@ -2078,7 +2085,7 @@ function matchPunctuator(source, index) {
2078
2085
  (punctuator) => source.startsWith(punctuator, index) && (punctuator !== "?." || !isDecimalDigit(source[index + 2] ?? ""))
2079
2086
  );
2080
2087
  }
2081
- function shouldRejectRegexLiteral(previousToken, lastClosedControlParenthesis, tokens) {
2088
+ function shouldRejectRegexLiteral(previousToken, lastClosedStatementBoundary, tokens) {
2082
2089
  if (previousToken === void 0) {
2083
2090
  return true;
2084
2091
  }
@@ -2089,8 +2096,8 @@ function shouldRejectRegexLiteral(previousToken, lastClosedControlParenthesis, t
2089
2096
  if (previousToken.value === "of") return endsWithForOfSeparator(tokens);
2090
2097
  return !EXPRESSION_ENDING_KEYWORDS.has(previousToken.value);
2091
2098
  }
2092
- if (previousToken.value === ")") {
2093
- return lastClosedControlParenthesis;
2099
+ if (previousToken.value === ")" || previousToken.value === "}") {
2100
+ return lastClosedStatementBoundary;
2094
2101
  }
2095
2102
  return !isExpressionEndingPunctuator(previousToken.value);
2096
2103
  }
@@ -2123,11 +2130,39 @@ function endsWithForOfSeparator(tokens) {
2123
2130
  }
2124
2131
  return false;
2125
2132
  }
2126
- function updateGroupingState(groupingStack, previousToken, punctuator) {
2133
+ function updateGroupingState(state, previousToken, punctuator, previousStatementBoundary, initialStatementList, tokens) {
2134
+ const groupingStack = state.stack;
2135
+ const functionBody = state.functionBody;
2136
+ state.functionBody = false;
2137
+ for (let index = state.tokenCount; index < tokens.length; index++) {
2138
+ const token = tokens[index];
2139
+ if (token.type !== "keyword" || token.value !== "class") continue;
2140
+ const before = tokens[index - 1];
2141
+ if (before?.value === "." || before?.value === "?.") continue;
2142
+ const next = tokens[index + 1]?.value;
2143
+ const afterName = tokens[index + 2]?.value;
2144
+ if (next !== "{" && next !== "extends" && afterName !== "{" && afterName !== "extends") continue;
2145
+ const parent = groupingStack[groupingStack.length - 1];
2146
+ if (parent?.classBody && (before === void 0 || ["{", "}", ";", "static"].includes(before.value) || ["identifier", "numeric", "string", "template", "regex"].includes(before.type))) continue;
2147
+ state.classHeads.push({
2148
+ depth: groupingStack.length,
2149
+ declaration: isDeclarationPosition(tokens, index, groupingStack, initialStatementList)
2150
+ });
2151
+ }
2152
+ state.tokenCount = tokens.length;
2153
+ const beforePreviousToken = tokens[tokens.length - 3];
2127
2154
  if (punctuator === "(") {
2155
+ let functionIndex = tokens.length - 2;
2156
+ if (tokens[functionIndex]?.value !== "function") {
2157
+ if (tokens[functionIndex]?.value !== "*") functionIndex--;
2158
+ if (tokens[functionIndex]?.value === "*") functionIndex--;
2159
+ }
2160
+ const functionParameters = tokens[functionIndex]?.type === "keyword" && tokens[functionIndex].value === "function";
2161
+ const functionDeclaration = functionParameters && isDeclarationPosition(tokens, functionIndex, groupingStack, initialStatementList);
2128
2162
  groupingStack.push({
2129
2163
  value: "(",
2130
- isControlCondition: previousToken?.type === "keyword" && CONTROL_FLOW_PAREN_KEYWORDS.has(previousToken.value)
2164
+ functionParameters,
2165
+ isControlCondition: functionDeclaration || (previousToken?.type === "keyword" || previousToken?.type === "identifier") && (CONTROL_FLOW_PAREN_KEYWORDS.has(previousToken.value) || previousToken.value === "await" && beforePreviousToken?.type === "keyword" && beforePreviousToken.value === "for") && beforePreviousToken?.value !== "." && beforePreviousToken?.value !== "?."
2131
2166
  });
2132
2167
  return false;
2133
2168
  }
@@ -2136,22 +2171,42 @@ function updateGroupingState(groupingStack, previousToken, punctuator) {
2136
2171
  return false;
2137
2172
  }
2138
2173
  if (punctuator === "{") {
2139
- groupingStack.push({ value: "{" });
2174
+ const classHead = state.classHeads[state.classHeads.length - 1];
2175
+ if (!functionBody && previousToken?.value !== "=>" && classHead?.depth === groupingStack.length) {
2176
+ state.classHeads.pop();
2177
+ groupingStack.push({ value: "{", classBody: true, closesStatement: classHead.declaration });
2178
+ return false;
2179
+ }
2180
+ const parent = groupingStack[groupingStack.length - 1];
2181
+ const closesStatement = previousToken === void 0 ? initialStatementList : previousStatementBoundary || ["{", ";"].includes(previousToken.value) && (parent === void 0 || parent.statementList === true) || previousToken.type === "keyword" && ["else", "do", "try", "finally"].includes(previousToken.value);
2182
+ groupingStack.push({
2183
+ value: "{",
2184
+ closesStatement,
2185
+ statementList: closesStatement || previousToken?.value === ")" || previousToken?.value === "=>" || previousToken?.value === "static"
2186
+ });
2140
2187
  return false;
2141
2188
  }
2142
2189
  if (punctuator === ")") {
2143
- return popGroupingContext(groupingStack, "(")?.isControlCondition === true;
2190
+ const group = popGroupingContext(groupingStack, "(");
2191
+ state.functionBody = group?.functionParameters === true;
2192
+ return group?.isControlCondition === true;
2144
2193
  }
2145
2194
  if (punctuator === "]") {
2146
2195
  popGroupingContext(groupingStack, "[");
2147
2196
  return false;
2148
2197
  }
2149
2198
  if (punctuator === "}") {
2150
- popGroupingContext(groupingStack, "{");
2151
- return false;
2199
+ return popGroupingContext(groupingStack, "{")?.closesStatement === true;
2152
2200
  }
2153
2201
  return false;
2154
2202
  }
2203
+ function isDeclarationPosition(tokens, index, groupingStack, initialStatementList) {
2204
+ const parent = groupingStack[groupingStack.length - 1];
2205
+ if (parent === void 0 ? !initialStatementList : parent.statementList !== true) return false;
2206
+ if (tokens[index - 1]?.value === "async") index--;
2207
+ const previous = tokens[index - 1];
2208
+ return previous === void 0 || ["{", "}", ";", ")", "]", "export", "default"].includes(previous.value) || ["identifier", "numeric", "string", "template", "regex"].includes(previous.type) || previous.type === "keyword" && EXPRESSION_ENDING_KEYWORDS.has(previous.value);
2209
+ }
2155
2210
  function popGroupingContext(groupingStack, expected) {
2156
2211
  const top = groupingStack[groupingStack.length - 1];
2157
2212
  if (top?.value !== expected) {
@@ -3136,7 +3191,7 @@ function parseModule(source, filename = "<input>", owner) {
3136
3191
  try {
3137
3192
  const result = assignIds(
3138
3193
  new Parser(
3139
- tokenize(source, { allowRegexLiterals: true, compilation }),
3194
+ tokenize(source, { allowRegexLiterals: true, statementList: true, compilation }),
3140
3195
  source,
3141
3196
  compilation
3142
3197
  ).parseModule()
@@ -3160,7 +3215,7 @@ function parseExecutableModule(source, filename = "<input>", owner) {
3160
3215
  try {
3161
3216
  const result = assignIds(
3162
3217
  new Parser(
3163
- tokenize(source, { allowRegexLiterals: true, compilation }),
3218
+ tokenize(source, { allowRegexLiterals: true, statementList: true, compilation }),
3164
3219
  source,
3165
3220
  compilation,
3166
3221
  "top-level",
@@ -3192,6 +3247,7 @@ function parseEvalScript(source, context = {}, owner) {
3192
3247
  const grammar = { await: false, yield: false, strict: context.strict === true };
3193
3248
  const parser = new Parser(tokenize(source, {
3194
3249
  allowRegexLiterals: true,
3250
+ statementList: true,
3195
3251
  allowLegacyNumbers: true,
3196
3252
  allowLegacyEscapes: true,
3197
3253
  allowHtmlComments: true,
@@ -3235,8 +3291,8 @@ ${body}
3235
3291
  }`;
3236
3292
  const source = `${prefix} anonymous(${parameters}
3237
3293
  ) ${bodySource}`;
3238
- const createParser = (text) => new Parser(
3239
- tokenize(text, { allowRegexLiterals: true, allowLegacyNumbers: true, allowLegacyEscapes: true, allowHtmlComments: true, compilation }),
3294
+ const createParser = (text, statementList = false) => new Parser(
3295
+ tokenize(text, { allowRegexLiterals: true, statementList, allowLegacyNumbers: true, allowLegacyEscapes: true, allowHtmlComments: true, compilation }),
3240
3296
  text,
3241
3297
  compilation,
3242
3298
  kind,
@@ -3248,7 +3304,7 @@ ${body}
3248
3304
  false
3249
3305
  );
3250
3306
  createParser(parameterSource).parseDynamicParameters();
3251
- createParser(bodySource).parseDynamicBody();
3307
+ createParser(bodySource, true).parseDynamicBody();
3252
3308
  const node = assignIds(createParser(source).parseDynamicExpression());
3253
3309
  if (source.includes("#")) validatePrivateNames(node);
3254
3310
  return node;
@@ -7310,4 +7366,4 @@ export {
7310
7366
  Float16Array2 as Float16Array,
7311
7367
  numericTypedArrayConstructors
7312
7368
  };
7313
- //# sourceMappingURL=chunk-47LQJKGT.js.map
7369
+ //# sourceMappingURL=chunk-OMSG6GZF.js.map