@poe-platform/safe-js 0.1.126 → 0.1.127

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-D4YY44EF.js";
30
+ } from "./chunk-MKJBQPBH.js";
31
31
 
32
32
  // packages/safe-js/src/migrate.ts
33
33
  import { createHash } from "node:crypto";
@@ -8245,4 +8245,4 @@ export {
8245
8245
  parseMcpConfig,
8246
8246
  makeMcpModule
8247
8247
  };
8248
- //# sourceMappingURL=chunk-AHZ74NTE.js.map
8248
+ //# sourceMappingURL=chunk-23ZKK6SC.js.map
@@ -2525,23 +2525,21 @@ function parseTokens(tokens, compilation) {
2525
2525
  function parseModuleTokens(tokens, compilation) {
2526
2526
  return new Parser(tokens, compilation).parseModule();
2527
2527
  }
2528
- function parseExpressionTokens(tokens, compilation) {
2529
- return new Parser(tokens, compilation).parseExpressionOnly();
2530
- }
2531
2528
  var Parser = class {
2532
- constructor(tokens, compilation) {
2529
+ constructor(tokens, compilation, functionContext = "normal") {
2533
2530
  this.tokens = tokens;
2534
2531
  this.compilation = compilation;
2532
+ this.functionContext = functionContext;
2535
2533
  this.functionScopes.add(this.scopes[0]);
2536
2534
  }
2537
2535
  tokens;
2538
2536
  compilation;
2537
+ functionContext;
2539
2538
  index = 0;
2540
2539
  breakableDepth = 0;
2541
2540
  conditionalExpressionDepth = 0;
2542
2541
  ifStatementDepth = 0;
2543
2542
  loopDepth = 0;
2544
- generatorBody = false;
2545
2543
  scopes = [/* @__PURE__ */ new Map()];
2546
2544
  functionScopes = /* @__PURE__ */ new WeakSet();
2547
2545
  varNames = /* @__PURE__ */ new WeakMap();
@@ -2727,9 +2725,9 @@ var Parser = class {
2727
2725
  }
2728
2726
  parseArrowFunctionBody(params) {
2729
2727
  if (this.currentToken().type === "punctuator" && this.currentToken().value === "{") {
2730
- return this.withFunctionContext(false, () => this.parseBlockStatement(params));
2728
+ return this.withFunctionContext("normal", () => this.parseBlockStatement(params));
2731
2729
  }
2732
- return this.withFunctionContext(false, () => this.parseExpression().node);
2730
+ return this.withFunctionContext("normal", () => this.parseExpression().node);
2733
2731
  }
2734
2732
  parseBlockStatement(params, catchParam) {
2735
2733
  const start = this.expectPunctuator("{");
@@ -3333,7 +3331,7 @@ var Parser = class {
3333
3331
  return parsedParams;
3334
3332
  });
3335
3333
  const generator = generatorToken !== void 0;
3336
- const body = this.withFunctionContext(generator, () => this.parseBlockStatement(params));
3334
+ const body = this.withFunctionContext(generator ? "generator" : "normal", () => this.parseBlockStatement(params));
3337
3335
  return {
3338
3336
  type: "FunctionDeclaration",
3339
3337
  async: asyncToken !== void 0,
@@ -3368,32 +3366,34 @@ var Parser = class {
3368
3366
  };
3369
3367
  }
3370
3368
  parseArrowParameters() {
3371
- this.expectPunctuator("(");
3372
- const params = [];
3373
- if (this.consumePunctuator(")") !== void 0) {
3374
- return params;
3375
- }
3376
- while (true) {
3377
- const param = this.parseBindingElement();
3378
- params.push(param);
3379
- const comma = this.consumePunctuator(",");
3380
- if (comma === void 0) {
3381
- break;
3369
+ return this.withFunctionContext("parameters", () => {
3370
+ this.expectPunctuator("(");
3371
+ const params = [];
3372
+ if (this.consumePunctuator(")") !== void 0) {
3373
+ return params;
3382
3374
  }
3383
- if (param.type === "RestElement") {
3375
+ while (true) {
3376
+ const param = this.parseBindingElement();
3377
+ params.push(param);
3378
+ const comma = this.consumePunctuator(",");
3379
+ if (comma === void 0) {
3380
+ break;
3381
+ }
3382
+ if (param.type === "RestElement") {
3383
+ if (this.currentToken().type === "punctuator" && this.currentToken().value === ")") {
3384
+ throw unexpectedTokenError(comma);
3385
+ }
3386
+ throw new Error(
3387
+ `Rest element must be the last parameter at line ${comma.start.line}, column ${comma.start.column}.`
3388
+ );
3389
+ }
3384
3390
  if (this.currentToken().type === "punctuator" && this.currentToken().value === ")") {
3385
- throw unexpectedTokenError(comma);
3391
+ break;
3386
3392
  }
3387
- throw new Error(
3388
- `Rest element must be the last parameter at line ${comma.start.line}, column ${comma.start.column}.`
3389
- );
3390
- }
3391
- if (this.currentToken().type === "punctuator" && this.currentToken().value === ")") {
3392
- break;
3393
3393
  }
3394
- }
3395
- this.expectPunctuator(")");
3396
- return params;
3394
+ this.expectPunctuator(")");
3395
+ return params;
3396
+ });
3397
3397
  }
3398
3398
  parseBindingElement() {
3399
3399
  if (this.consumePunctuator("...") !== void 0) {
@@ -3947,7 +3947,7 @@ var Parser = class {
3947
3947
  };
3948
3948
  }
3949
3949
  if (token.type === "keyword" && token.value === "yield") {
3950
- if (!this.generatorBody) {
3950
+ if (this.functionContext !== "generator") {
3951
3951
  throw new Error(
3952
3952
  `yield is only valid inside a generator body at line ${token.start.line}, column ${token.start.column}.`
3953
3953
  );
@@ -3974,11 +3974,16 @@ var Parser = class {
3974
3974
  };
3975
3975
  }
3976
3976
  if (token.type === "keyword" && token.value === "await") {
3977
- if (this.generatorBody) {
3977
+ if (this.functionContext === "generator") {
3978
3978
  throw new Error(
3979
3979
  `generators cannot await; use a regular async function at line ${token.start.line}, column ${token.start.column}.`
3980
3980
  );
3981
3981
  }
3982
+ if (this.functionContext === "parameters") {
3983
+ throw new Error(
3984
+ `await is not valid in function parameters at line ${token.start.line}, column ${token.start.column}.`
3985
+ );
3986
+ }
3982
3987
  this.index += 1;
3983
3988
  const argument = this.parseUnaryExpression();
3984
3989
  return {
@@ -4103,7 +4108,7 @@ var Parser = class {
4103
4108
  if (this.currentToken().type === "template") {
4104
4109
  const quasi = createTemplateLiteral(
4105
4110
  this.currentToken(),
4106
- { allowMalformedEscapes: true },
4111
+ { allowMalformedEscapes: true, functionContext: this.functionContext },
4107
4112
  this.compilation
4108
4113
  );
4109
4114
  this.index += 1;
@@ -4190,7 +4195,11 @@ var Parser = class {
4190
4195
  if (token.type === "template") {
4191
4196
  this.index += 1;
4192
4197
  return {
4193
- node: createTemplateLiteral(token, { allowMalformedEscapes: false }, this.compilation),
4198
+ node: createTemplateLiteral(
4199
+ token,
4200
+ { allowMalformedEscapes: false, functionContext: this.functionContext },
4201
+ this.compilation
4202
+ ),
4194
4203
  parenthesized: false
4195
4204
  };
4196
4205
  }
@@ -4306,7 +4315,7 @@ var Parser = class {
4306
4315
  return parsedParams;
4307
4316
  });
4308
4317
  const generator = generatorToken !== void 0;
4309
- const body = this.withFunctionContext(generator, () => this.parseBlockStatement(params));
4318
+ const body = this.withFunctionContext(generator ? "generator" : "normal", () => this.parseBlockStatement(params));
4310
4319
  return {
4311
4320
  type: "FunctionExpression",
4312
4321
  async: asyncToken !== void 0,
@@ -4550,7 +4559,7 @@ var Parser = class {
4550
4559
  }
4551
4560
  return parsedParams;
4552
4561
  });
4553
- const body = this.withFunctionContext(false, () => this.parseBlockStatement(params));
4562
+ const body = this.withFunctionContext("normal", () => this.parseBlockStatement(params));
4554
4563
  return {
4555
4564
  type: "FunctionExpression",
4556
4565
  async: asyncToken !== void 0,
@@ -4955,19 +4964,19 @@ var Parser = class {
4955
4964
  hasReturnArgument(returnToken, nextToken) {
4956
4965
  return !(hasLineBreakBetween(returnToken, nextToken) || nextToken.type === "punctuator" && (nextToken.value === ";" || nextToken.value === "}") || nextToken.type === "eof");
4957
4966
  }
4958
- withFunctionContext(generatorBody, callback) {
4967
+ withFunctionContext(functionContext, callback) {
4959
4968
  const previousBreakableDepth = this.breakableDepth;
4960
4969
  const previousLoopDepth = this.loopDepth;
4961
- const previousGeneratorBody = this.generatorBody;
4970
+ const previousFunctionContext = this.functionContext;
4962
4971
  this.breakableDepth = 0;
4963
4972
  this.loopDepth = 0;
4964
- this.generatorBody = generatorBody;
4973
+ this.functionContext = functionContext;
4965
4974
  try {
4966
4975
  return callback();
4967
4976
  } finally {
4968
4977
  this.breakableDepth = previousBreakableDepth;
4969
4978
  this.loopDepth = previousLoopDepth;
4970
- this.generatorBody = previousGeneratorBody;
4979
+ this.functionContext = previousFunctionContext;
4971
4980
  }
4972
4981
  }
4973
4982
  withLoopContext(callback) {
@@ -5402,7 +5411,7 @@ function createLiteralFromToken(token) {
5402
5411
  }
5403
5412
  return createKeywordLiteral(token);
5404
5413
  }
5405
- function createTemplateLiteral(token, options = { allowMalformedEscapes: false }, compilation) {
5414
+ function createTemplateLiteral(token, options, compilation) {
5406
5415
  const raw = token.value;
5407
5416
  const expressions = [];
5408
5417
  const quasis = [];
@@ -5422,6 +5431,7 @@ function createTemplateLiteral(token, options = { allowMalformedEscapes: false }
5422
5431
  parseEmbeddedExpression(
5423
5432
  raw.slice(expressionStart, expressionEnd),
5424
5433
  positionWithinRaw(token.start, raw, expressionStart),
5434
+ options.functionContext,
5425
5435
  compilation
5426
5436
  )
5427
5437
  );
@@ -5784,13 +5794,13 @@ function decodeHexEscape(value, start) {
5784
5794
  end: index + 2
5785
5795
  };
5786
5796
  }
5787
- function parseEmbeddedExpression(source, base, compilation) {
5797
+ function parseEmbeddedExpression(source, base, functionContext, compilation) {
5788
5798
  const tokens = tokenize(source, { allowRegexLiterals: true, compilation }).map((token) => ({
5789
5799
  ...token,
5790
5800
  start: rebasePosition(token.start, base),
5791
5801
  end: rebasePosition(token.end, base)
5792
5802
  }));
5793
- return parseExpressionTokens(tokens, compilation);
5803
+ return new Parser(tokens, compilation, functionContext).parseExpressionOnly();
5794
5804
  }
5795
5805
  function findRegexLiteral(node) {
5796
5806
  if (node === null || node === void 0) {
@@ -33463,4 +33473,4 @@ export {
33463
33473
  FileSnapshotBackend,
33464
33474
  run
33465
33475
  };
33466
- //# sourceMappingURL=chunk-D4YY44EF.js.map
33476
+ //# sourceMappingURL=chunk-MKJBQPBH.js.map