@poe-platform/safe-js 0.1.582 → 0.1.583

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-ONUOT3QR.js → chunk-27YAKAEE.js} +3 -3
  2. package/dist/safe-js/chunks/{chunk-6H4RX6ZZ.js → chunk-3YD5RZJH.js} +2 -2
  3. package/dist/safe-js/chunks/{chunk-FGSHNQZD.js → chunk-4WKBTY6W.js} +3 -3
  4. package/dist/safe-js/chunks/{chunk-GT6KJSXR.js → chunk-7IEVHJ7R.js} +4 -4
  5. package/dist/safe-js/chunks/{chunk-J56RIONZ.js → chunk-CGIQDK6Z.js} +2 -2
  6. package/dist/safe-js/chunks/{chunk-FVBRBOAB.js → chunk-FRTUNUVH.js} +2 -2
  7. package/dist/safe-js/chunks/{chunk-ADUXPMQM.js → chunk-HENSQ4YT.js} +2 -2
  8. package/dist/safe-js/chunks/{chunk-47LQJKGT.js → chunk-HUD3ISAJ.js} +45 -34
  9. package/dist/safe-js/chunks/chunk-HUD3ISAJ.js.map +7 -0
  10. package/dist/safe-js/chunks/{chunk-GMWNREUZ.js → chunk-P3M3BXHT.js} +3 -3
  11. package/dist/safe-js/chunks/{chunk-WBFZHDKE.js → chunk-QNAVME3B.js} +6 -6
  12. package/dist/safe-js/chunks/{chunk-H4K3LRXJ.js → chunk-XM6DQK7C.js} +2 -2
  13. package/dist/safe-js/chunks/{chunk-2LRIFIS2.js → chunk-YUMLRCTH.js} +2 -2
  14. package/dist/safe-js/chunks/{chunk-BZ2HQIKQ.js → chunk-ZEN6IY6M.js} +4 -4
  15. package/dist/safe-js/chunks/{cli-runtime-GKFPKXDB.js → cli-runtime-R4XQ76EV.js} +13 -13
  16. package/dist/safe-js/chunks/{dump-QOUJIAJ6.js → dump-7N6NYNQE.js} +4 -4
  17. package/dist/safe-js/chunks/{fs-IAKJ3MES.js → fs-DJXSKCFB.js} +4 -4
  18. package/dist/safe-js/chunks/harness-I47WMMSB.js +10 -0
  19. package/dist/safe-js/chunks/mcp-43SITYLO.js +11 -0
  20. package/dist/safe-js/chunks/migration-file-TKW2VXE5.js +12 -0
  21. package/dist/safe-js/chunks/restore-ITFWVMAU.js +13 -0
  22. package/dist/safe-js/chunks/run-P3JBDBSD.js +17 -0
  23. package/dist/safe-js/chunks/runtime-modules-AAL3MW44.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 +43 -32
  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-ONUOT3QR.js.map → chunk-27YAKAEE.js.map} +0 -0
  39. /package/dist/safe-js/chunks/{chunk-6H4RX6ZZ.js.map → chunk-3YD5RZJH.js.map} +0 -0
  40. /package/dist/safe-js/chunks/{chunk-FGSHNQZD.js.map → chunk-4WKBTY6W.js.map} +0 -0
  41. /package/dist/safe-js/chunks/{chunk-GT6KJSXR.js.map → chunk-7IEVHJ7R.js.map} +0 -0
  42. /package/dist/safe-js/chunks/{chunk-J56RIONZ.js.map → chunk-CGIQDK6Z.js.map} +0 -0
  43. /package/dist/safe-js/chunks/{chunk-FVBRBOAB.js.map → chunk-FRTUNUVH.js.map} +0 -0
  44. /package/dist/safe-js/chunks/{chunk-ADUXPMQM.js.map → chunk-HENSQ4YT.js.map} +0 -0
  45. /package/dist/safe-js/chunks/{chunk-GMWNREUZ.js.map → chunk-P3M3BXHT.js.map} +0 -0
  46. /package/dist/safe-js/chunks/{chunk-WBFZHDKE.js.map → chunk-QNAVME3B.js.map} +0 -0
  47. /package/dist/safe-js/chunks/{chunk-H4K3LRXJ.js.map → chunk-XM6DQK7C.js.map} +0 -0
  48. /package/dist/safe-js/chunks/{chunk-2LRIFIS2.js.map → chunk-YUMLRCTH.js.map} +0 -0
  49. /package/dist/safe-js/chunks/{chunk-BZ2HQIKQ.js.map → chunk-ZEN6IY6M.js.map} +0 -0
  50. /package/dist/safe-js/chunks/{cli-runtime-GKFPKXDB.js.map → cli-runtime-R4XQ76EV.js.map} +0 -0
  51. /package/dist/safe-js/chunks/{dump-QOUJIAJ6.js.map → dump-7N6NYNQE.js.map} +0 -0
  52. /package/dist/safe-js/chunks/{fs-IAKJ3MES.js.map → fs-DJXSKCFB.js.map} +0 -0
  53. /package/dist/safe-js/chunks/{harness-6OV7HVLE.js.map → harness-I47WMMSB.js.map} +0 -0
  54. /package/dist/safe-js/chunks/{mcp-6IGCCQLK.js.map → mcp-43SITYLO.js.map} +0 -0
  55. /package/dist/safe-js/chunks/{migration-file-BOE3NXK3.js.map → migration-file-TKW2VXE5.js.map} +0 -0
  56. /package/dist/safe-js/chunks/{restore-B6CSGGER.js.map → restore-ITFWVMAU.js.map} +0 -0
  57. /package/dist/safe-js/chunks/{run-OGRMHDQG.js.map → run-P3JBDBSD.js.map} +0 -0
  58. /package/dist/safe-js/chunks/{runtime-modules-M3KCXZ62.js.map → runtime-modules-AAL3MW44.js.map} +0 -0
@@ -4456,7 +4456,7 @@ var KEYWORDS = /* @__PURE__ */ new Set([
4456
4456
  ]);
4457
4457
  var EXPRESSION_ENDING_KEYWORDS = /* @__PURE__ */ new Set(["true", "false", "null"]);
4458
4458
  var RESERVED_IDENTIFIER_SPELLINGS = /* @__PURE__ */ new Set(["case", "default", "debugger", "enum", "export", "new", "switch", "var"]);
4459
- var CONTROL_FLOW_PAREN_KEYWORDS = /* @__PURE__ */ new Set(["if", "while", "with", "for", "catch"]);
4459
+ var CONTROL_FLOW_PAREN_KEYWORDS = /* @__PURE__ */ new Set(["if", "while", "with", "for", "catch", "switch"]);
4460
4460
  var MAX_UNICODE_CODE_POINT = 1114111;
4461
4461
  var IDENTIFIER_START_PATTERN = /^\p{ID_Start}$/u;
4462
4462
  var IDENTIFIER_PART_PATTERN = /^\p{ID_Continue}$/u;
@@ -4537,7 +4537,7 @@ var Lexer = class {
4537
4537
  column = 1;
4538
4538
  tokens = [];
4539
4539
  groupingStack = [];
4540
- lastClosedControlParenthesis = false;
4540
+ lastClosedStatementBoundary = false;
4541
4541
  legacyStringEscape = false;
4542
4542
  lineHasToken = false;
4543
4543
  tokenize() {
@@ -4710,7 +4710,7 @@ var Lexer = class {
4710
4710
  let depth = 1;
4711
4711
  const tokens = [];
4712
4712
  const groupingStack = [];
4713
- let lastClosedControlParenthesis = false;
4713
+ let lastClosedStatementBoundary = false;
4714
4714
  while (!this.isAtEnd() && depth > 0) {
4715
4715
  this.skipTrivia();
4716
4716
  if (this.isAtEnd()) break;
@@ -4721,13 +4721,13 @@ var Lexer = class {
4721
4721
  if (char === "'" || char === '"') {
4722
4722
  this.skipQuotedString(char);
4723
4723
  tokens.push({ type: "string", value: char });
4724
- lastClosedControlParenthesis = false;
4724
+ lastClosedStatementBoundary = false;
4725
4725
  continue;
4726
4726
  }
4727
4727
  if (char === "`") {
4728
4728
  this.skipNestedTemplate();
4729
4729
  tokens.push({ type: "template", value: "`" });
4730
- lastClosedControlParenthesis = false;
4730
+ lastClosedStatementBoundary = false;
4731
4731
  continue;
4732
4732
  }
4733
4733
  if (char === "/" && this.peekChar(1) === "/") {
@@ -4766,22 +4766,22 @@ var Lexer = class {
4766
4766
  isStart = false;
4767
4767
  }
4768
4768
  tokens.push({ type: KEYWORDS.has(value) ? "keyword" : "identifier", value });
4769
- lastClosedControlParenthesis = false;
4769
+ lastClosedStatementBoundary = false;
4770
4770
  continue;
4771
4771
  }
4772
4772
  if (isDecimalDigit(char) || char === "." && isDecimalDigit(this.peekChar(1))) {
4773
4773
  const start2 = this.position();
4774
4774
  const value = this.scanNumber(start2);
4775
4775
  tokens.push({ type: "numeric", value });
4776
- lastClosedControlParenthesis = false;
4776
+ lastClosedStatementBoundary = false;
4777
4777
  continue;
4778
4778
  }
4779
4779
  if (char === "{") {
4780
4780
  depth += 1;
4781
4781
  this.advance();
4782
- groupingStack.push({ value: "{" });
4782
+ updateGroupingState(groupingStack, tokens[tokens.length - 1], "{", lastClosedStatementBoundary);
4783
4783
  tokens.push({ type: "punctuator", value: "{" });
4784
- lastClosedControlParenthesis = false;
4784
+ lastClosedStatementBoundary = false;
4785
4785
  continue;
4786
4786
  }
4787
4787
  if (char === "}") {
@@ -4790,19 +4790,18 @@ var Lexer = class {
4790
4790
  if (depth === 0) {
4791
4791
  return;
4792
4792
  }
4793
- popGroupingContext(groupingStack, "{");
4793
+ lastClosedStatementBoundary = updateGroupingState(groupingStack, tokens[tokens.length - 1], "}", lastClosedStatementBoundary);
4794
4794
  tokens.push({ type: "punctuator", value: "}" });
4795
- lastClosedControlParenthesis = false;
4796
4795
  continue;
4797
4796
  }
4798
- if (char === "/" && shouldRejectRegexLiteral(tokens[tokens.length - 1], lastClosedControlParenthesis, tokens)) {
4797
+ if (char === "/" && shouldRejectRegexLiteral(tokens[tokens.length - 1], lastClosedStatementBoundary, tokens)) {
4799
4798
  if (!this.options.allowRegexLiterals) {
4800
4799
  this.syntaxError("Regular expression literals are not supported", this.position());
4801
4800
  }
4802
4801
  const start2 = this.position();
4803
4802
  const value = this.scanRegexLiteral(start2);
4804
4803
  tokens.push({ type: "regex", value });
4805
- lastClosedControlParenthesis = false;
4804
+ lastClosedStatementBoundary = false;
4806
4805
  continue;
4807
4806
  }
4808
4807
  const punctuator = matchPunctuator(this.source, this.index);
@@ -4810,10 +4809,13 @@ var Lexer = class {
4810
4809
  const previousToken = tokens[tokens.length - 1];
4811
4810
  this.advanceBy(punctuator.length);
4812
4811
  tokens.push({ type: "punctuator", value: punctuator });
4813
- lastClosedControlParenthesis = updateGroupingState(
4812
+ lastClosedStatementBoundary = updateGroupingState(
4814
4813
  groupingStack,
4815
4814
  previousToken,
4816
- punctuator
4815
+ punctuator,
4816
+ lastClosedStatementBoundary,
4817
+ false,
4818
+ tokens[tokens.length - 3]
4817
4819
  );
4818
4820
  continue;
4819
4821
  }
@@ -5084,7 +5086,7 @@ var Lexer = class {
5084
5086
  }
5085
5087
  }
5086
5088
  readSlashOrPunctuator(start) {
5087
- if (this.currentChar() === "/" && shouldRejectRegexLiteral(this.lastSignificantToken(), this.lastClosedControlParenthesis, this.tokens)) {
5089
+ if (this.currentChar() === "/" && shouldRejectRegexLiteral(this.lastSignificantToken(), this.lastClosedStatementBoundary, this.tokens)) {
5088
5090
  if (!this.options.allowRegexLiterals) {
5089
5091
  this.syntaxError("Regular expression literals are not supported", start);
5090
5092
  }
@@ -5171,14 +5173,17 @@ var Lexer = class {
5171
5173
  };
5172
5174
  this.tokens.push(token);
5173
5175
  if (type === "punctuator") {
5174
- this.lastClosedControlParenthesis = updateGroupingState(
5176
+ this.lastClosedStatementBoundary = updateGroupingState(
5175
5177
  this.groupingStack,
5176
5178
  previousToken,
5177
- value
5179
+ value,
5180
+ this.lastClosedStatementBoundary,
5181
+ this.options.statementList === true,
5182
+ this.tokens[this.tokens.length - 3]
5178
5183
  );
5179
5184
  return;
5180
5185
  }
5181
- this.lastClosedControlParenthesis = false;
5186
+ this.lastClosedStatementBoundary = false;
5182
5187
  }
5183
5188
  currentChar() {
5184
5189
  return this.source[this.index] ?? "";
@@ -5380,7 +5385,7 @@ function matchPunctuator(source, index) {
5380
5385
  (punctuator) => source.startsWith(punctuator, index) && (punctuator !== "?." || !isDecimalDigit(source[index + 2] ?? ""))
5381
5386
  );
5382
5387
  }
5383
- function shouldRejectRegexLiteral(previousToken, lastClosedControlParenthesis, tokens) {
5388
+ function shouldRejectRegexLiteral(previousToken, lastClosedStatementBoundary, tokens) {
5384
5389
  if (previousToken === void 0) {
5385
5390
  return true;
5386
5391
  }
@@ -5391,8 +5396,8 @@ function shouldRejectRegexLiteral(previousToken, lastClosedControlParenthesis, t
5391
5396
  if (previousToken.value === "of") return endsWithForOfSeparator(tokens);
5392
5397
  return !EXPRESSION_ENDING_KEYWORDS.has(previousToken.value);
5393
5398
  }
5394
- if (previousToken.value === ")") {
5395
- return lastClosedControlParenthesis;
5399
+ if (previousToken.value === ")" || previousToken.value === "}") {
5400
+ return lastClosedStatementBoundary;
5396
5401
  }
5397
5402
  return !isExpressionEndingPunctuator(previousToken.value);
5398
5403
  }
@@ -5425,11 +5430,11 @@ function endsWithForOfSeparator(tokens) {
5425
5430
  }
5426
5431
  return false;
5427
5432
  }
5428
- function updateGroupingState(groupingStack, previousToken, punctuator) {
5433
+ function updateGroupingState(groupingStack, previousToken, punctuator, previousStatementBoundary, initialStatementList = false, beforePreviousToken) {
5429
5434
  if (punctuator === "(") {
5430
5435
  groupingStack.push({
5431
5436
  value: "(",
5432
- isControlCondition: previousToken?.type === "keyword" && CONTROL_FLOW_PAREN_KEYWORDS.has(previousToken.value)
5437
+ isControlCondition: (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 !== "?."
5433
5438
  });
5434
5439
  return false;
5435
5440
  }
@@ -5438,7 +5443,13 @@ function updateGroupingState(groupingStack, previousToken, punctuator) {
5438
5443
  return false;
5439
5444
  }
5440
5445
  if (punctuator === "{") {
5441
- groupingStack.push({ value: "{" });
5446
+ const parent = groupingStack[groupingStack.length - 1];
5447
+ 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);
5448
+ groupingStack.push({
5449
+ value: "{",
5450
+ closesStatement,
5451
+ statementList: closesStatement || previousToken?.value === ")" || previousToken?.value === "=>" || previousToken?.value === "static"
5452
+ });
5442
5453
  return false;
5443
5454
  }
5444
5455
  if (punctuator === ")") {
@@ -5449,8 +5460,7 @@ function updateGroupingState(groupingStack, previousToken, punctuator) {
5449
5460
  return false;
5450
5461
  }
5451
5462
  if (punctuator === "}") {
5452
- popGroupingContext(groupingStack, "{");
5453
- return false;
5463
+ return popGroupingContext(groupingStack, "{")?.closesStatement === true;
5454
5464
  }
5455
5465
  return false;
5456
5466
  }
@@ -6621,7 +6631,7 @@ function parseModule(source, filename = "<input>", owner) {
6621
6631
  try {
6622
6632
  const result = assignIds(
6623
6633
  new Parser(
6624
- tokenize(source, { allowRegexLiterals: true, compilation }),
6634
+ tokenize(source, { allowRegexLiterals: true, statementList: true, compilation }),
6625
6635
  source,
6626
6636
  compilation
6627
6637
  ).parseModule()
@@ -6645,7 +6655,7 @@ function parseExecutableModule(source, filename = "<input>", owner) {
6645
6655
  try {
6646
6656
  const result = assignIds(
6647
6657
  new Parser(
6648
- tokenize(source, { allowRegexLiterals: true, compilation }),
6658
+ tokenize(source, { allowRegexLiterals: true, statementList: true, compilation }),
6649
6659
  source,
6650
6660
  compilation,
6651
6661
  "top-level",
@@ -6677,6 +6687,7 @@ function parseEvalScript(source, context = {}, owner) {
6677
6687
  const grammar = { await: false, yield: false, strict: context.strict === true };
6678
6688
  const parser = new Parser(tokenize(source, {
6679
6689
  allowRegexLiterals: true,
6690
+ statementList: true,
6680
6691
  allowLegacyNumbers: true,
6681
6692
  allowLegacyEscapes: true,
6682
6693
  allowHtmlComments: true,
@@ -6720,8 +6731,8 @@ ${body}
6720
6731
  }`;
6721
6732
  const source = `${prefix} anonymous(${parameters}
6722
6733
  ) ${bodySource}`;
6723
- const createParser = (text) => new Parser(
6724
- tokenize(text, { allowRegexLiterals: true, allowLegacyNumbers: true, allowLegacyEscapes: true, allowHtmlComments: true, compilation }),
6734
+ const createParser = (text, statementList = false) => new Parser(
6735
+ tokenize(text, { allowRegexLiterals: true, statementList, allowLegacyNumbers: true, allowLegacyEscapes: true, allowHtmlComments: true, compilation }),
6725
6736
  text,
6726
6737
  compilation,
6727
6738
  kind,
@@ -6733,7 +6744,7 @@ ${body}
6733
6744
  false
6734
6745
  );
6735
6746
  createParser(parameterSource).parseDynamicParameters();
6736
- createParser(bodySource).parseDynamicBody();
6747
+ createParser(bodySource, true).parseDynamicBody();
6737
6748
  const node = assignIds(createParser(source).parseDynamicExpression());
6738
6749
  if (source.includes("#")) validatePrivateNames(node);
6739
6750
  return node;