@poe-platform/safe-js 0.1.489 → 0.1.491

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.
@@ -27,7 +27,7 @@ import {
27
27
  validateMigrationSemantics,
28
28
  validateSnapshotData,
29
29
  validateSnapshotMigration
30
- } from "./chunk-3IBFK7UI.js";
30
+ } from "./chunk-NQKOR5UJ.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-Y2KLKO2Y.js.map
8252
+ //# sourceMappingURL=chunk-CJDD5FTA.js.map
@@ -1009,6 +1009,7 @@ var Lexer = class {
1009
1009
  tokens = [];
1010
1010
  groupingStack = [];
1011
1011
  lastClosedControlParenthesis = false;
1012
+ legacyStringEscape = false;
1012
1013
  tokenize() {
1013
1014
  while (!this.isAtEnd()) {
1014
1015
  this.skipTrivia();
@@ -1113,12 +1114,14 @@ var Lexer = class {
1113
1114
  this.pushToken(privateName ? "private-identifier" : KEYWORDS.has(value) ? "keyword" : "identifier", start, value);
1114
1115
  }
1115
1116
  readString(start, quote) {
1117
+ this.legacyStringEscape = false;
1116
1118
  this.advance();
1117
1119
  while (!this.isAtEnd()) {
1118
1120
  const char = this.currentChar();
1119
1121
  if (char === quote) {
1120
1122
  this.advance();
1121
1123
  this.pushToken("string", start, this.source.slice(start.offset, this.index));
1124
+ if (this.legacyStringEscape) this.tokens[this.tokens.length - 1].legacyEscape = true;
1122
1125
  return;
1123
1126
  }
1124
1127
  if (char === "\\") {
@@ -1390,6 +1393,23 @@ var Lexer = class {
1390
1393
  return this.source.slice(start.offset, this.index);
1391
1394
  }
1392
1395
  if (isDecimalDigit(prefix)) {
1396
+ if (this.options.allowLegacyNumbers) {
1397
+ let octal = true;
1398
+ while (isDecimalDigit(this.currentChar())) {
1399
+ if (!isOctalDigit(this.currentChar())) octal = false;
1400
+ this.advance();
1401
+ }
1402
+ if (!octal) {
1403
+ if (this.currentChar() === ".") {
1404
+ this.advance();
1405
+ this.consumeOptionalDecimalDigits();
1406
+ }
1407
+ this.consumeExponent();
1408
+ }
1409
+ this.rejectBigIntSuffix();
1410
+ this.rejectInvalidNumericLiteralContinuation();
1411
+ return this.source.slice(start.offset, this.index);
1412
+ }
1393
1413
  this.advance();
1394
1414
  this.syntaxError("Legacy octal numeric literals are not supported in strict mode", start);
1395
1415
  }
@@ -1671,12 +1691,21 @@ var Lexer = class {
1671
1691
  if (escaped === "0") {
1672
1692
  this.advance();
1673
1693
  if (isDecimalDigit(this.currentChar())) {
1674
- this.syntaxError("Legacy octal escape sequences are not supported", escapeStart);
1694
+ if (!this.options.allowLegacyEscapes)
1695
+ this.syntaxError("Legacy octal escape sequences are not supported", escapeStart);
1696
+ this.legacyStringEscape = true;
1675
1697
  }
1676
1698
  return;
1677
1699
  }
1678
1700
  if (isOctalDigit(escaped)) {
1679
- this.syntaxError("Legacy octal escape sequences are not supported", escapeStart);
1701
+ if (!this.options.allowLegacyEscapes)
1702
+ this.syntaxError("Legacy octal escape sequences are not supported", escapeStart);
1703
+ this.legacyStringEscape = true;
1704
+ }
1705
+ if (escaped === "8" || escaped === "9") {
1706
+ if (!this.options.allowLegacyEscapes)
1707
+ this.syntaxError("Legacy decimal escape sequences are not supported", escapeStart);
1708
+ this.legacyStringEscape = true;
1680
1709
  }
1681
1710
  this.advance();
1682
1711
  }
@@ -3339,6 +3368,7 @@ var Parser = class {
3339
3368
  parseBlockStatementBody(start, functionBody = false) {
3340
3369
  const body = [];
3341
3370
  let directivePrologue = functionBody;
3371
+ let legacyDirective = false;
3342
3372
  while (this.consumePunctuator("}") === void 0) {
3343
3373
  if (this.currentToken().type === "eof") {
3344
3374
  throw new Error(
@@ -3350,8 +3380,11 @@ var Parser = class {
3350
3380
  body.push(statement);
3351
3381
  if (directivePrologue && this.lexicalContext.grammar !== void 0) {
3352
3382
  directivePrologue = statement.type === "ExpressionStatement" && statement.expression.type === "StringLiteral" && firstToken.type === "string" && statement.span.start.offset === firstToken.start.offset && statement.span.end.offset === firstToken.end.offset;
3353
- if (directivePrologue && statement.type === "ExpressionStatement" && statement.expression.type === "StringLiteral" && (statement.expression.raw === '"use strict"' || statement.expression.raw === "'use strict'"))
3383
+ if (directivePrologue && statement.type === "ExpressionStatement" && statement.expression.type === "StringLiteral" && (statement.expression.raw === '"use strict"' || statement.expression.raw === "'use strict'")) {
3384
+ if (legacyDirective) throw new Error("Legacy escape sequences are not supported in strict directives.");
3354
3385
  this.lexicalContext.grammar.strict = true;
3386
+ }
3387
+ if (directivePrologue && firstToken.legacyEscape) legacyDirective = true;
3355
3388
  }
3356
3389
  let semicolons = 0;
3357
3390
  while (statement.type !== "EmptyStatement" && this.consumePunctuator(";") !== void 0) {
@@ -5987,7 +6020,12 @@ var Parser = class {
5987
6020
  }
5988
6021
  }
5989
6022
  currentToken() {
5990
- return this.tokens[this.index] ?? this.tokens[this.tokens.length - 1];
6023
+ const token = this.tokens[this.index] ?? this.tokens[this.tokens.length - 1];
6024
+ if (this.lexicalContext.grammar?.strict !== false && token.legacyEscape)
6025
+ throw new Error("Legacy escape sequences are not supported in strict mode.");
6026
+ if (this.lexicalContext.grammar?.strict !== false && token.type === "numeric" && token.value[0] === "0" && isDecimalDigit3(token.value[1] ?? ""))
6027
+ throw new Error("Legacy numeric literals are not supported in strict mode.");
6028
+ return token;
5991
6029
  }
5992
6030
  peekToken(offset) {
5993
6031
  return this.tokens[this.index + offset] ?? this.tokens[this.tokens.length - 1];
@@ -6227,7 +6265,7 @@ function createNumericLiteral(token) {
6227
6265
  return {
6228
6266
  type: "NumericLiteral",
6229
6267
  raw: token.value,
6230
- value: Number(token.value.replaceAll("_", "")),
6268
+ value: token.value.length > 1 && token.value[0] === "0" && [...token.value].every(isOctalDigit2) ? Number.parseInt(token.value, 8) : Number(token.value.replaceAll("_", "")),
6231
6269
  span: createTokenSpan(token)
6232
6270
  };
6233
6271
  }
@@ -6235,7 +6273,7 @@ function createStringLiteral(token) {
6235
6273
  return {
6236
6274
  type: "StringLiteral",
6237
6275
  raw: token.value,
6238
- value: decodeEscapedText(token.value.slice(1, -1)),
6276
+ value: decodeEscapedText(token.value.slice(1, -1), token.legacyEscape),
6239
6277
  span: createTokenSpan(token)
6240
6278
  };
6241
6279
  }
@@ -6599,7 +6637,7 @@ function skipEscapedCharacter(raw, start) {
6599
6637
  }
6600
6638
  return Math.min(start + 2, raw.length);
6601
6639
  }
6602
- function decodeEscapedText(value) {
6640
+ function decodeEscapedText(value, allowLegacy = false) {
6603
6641
  let decoded = "";
6604
6642
  let index = 0;
6605
6643
  while (index < value.length) {
@@ -6642,6 +6680,14 @@ function decodeEscapedText(value) {
6642
6680
  continue;
6643
6681
  }
6644
6682
  }
6683
+ if (allowLegacy && isOctalDigit2(next)) {
6684
+ const start = index + 1;
6685
+ const limit = next <= "3" ? 3 : 2;
6686
+ index = start + 1;
6687
+ while (index < start + limit && isOctalDigit2(value[index] ?? "")) index++;
6688
+ decoded += String.fromCharCode(Number.parseInt(value.slice(start, index), 8));
6689
+ continue;
6690
+ }
6645
6691
  decoded += decodeEscapeCharacter(next);
6646
6692
  index += 2;
6647
6693
  }
@@ -6702,7 +6748,12 @@ function decodeHexEscape(value, start) {
6702
6748
  };
6703
6749
  }
6704
6750
  function parseEmbeddedExpression(source, base, functionContext, lexicalContext, fullSource, compilation) {
6705
- const tokens = tokenize(source, { allowRegexLiterals: true, compilation }).map((token) => ({
6751
+ const tokens = tokenize(source, {
6752
+ allowRegexLiterals: true,
6753
+ allowLegacyNumbers: lexicalContext.grammar?.strict === false,
6754
+ allowLegacyEscapes: lexicalContext.grammar?.strict === false,
6755
+ compilation
6756
+ }).map((token) => ({
6706
6757
  ...token,
6707
6758
  start: rebasePosition(token.start, base),
6708
6759
  end: rebasePosition(token.end, base)
@@ -57278,4 +57329,4 @@ authorization of the copyright holder.
57278
57329
  SPDX-License-Identifier: Unicode-3.0
57279
57330
 
57280
57331
  */
57281
- //# sourceMappingURL=chunk-3IBFK7UI.js.map
57332
+ //# sourceMappingURL=chunk-NQKOR5UJ.js.map