@poe-platform/safe-js 0.1.139 → 0.1.140

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.
@@ -3408,7 +3408,7 @@ var Parser = class {
3408
3408
  });
3409
3409
  });
3410
3410
  }
3411
- parseFunctionParts(generator, lexicalContext) {
3411
+ parseFunctionParts(generator, lexicalContext, accessor) {
3412
3412
  return this.withLexicalContext(lexicalContext, () => {
3413
3413
  const params = this.withScope(() => {
3414
3414
  const parsed = this.parseArrowParameters();
@@ -3416,7 +3416,24 @@ var Parser = class {
3416
3416
  for (const identifier of boundIdentifiers(param)) this.declareBinding(identifier);
3417
3417
  return parsed;
3418
3418
  });
3419
+ if (accessor === "get" && params.length !== 0)
3420
+ throw new Error("A getter cannot have parameters.");
3421
+ if (accessor === "set" && (params.length !== 1 || params[0]?.type === "RestElement"))
3422
+ throw new Error("A setter must have exactly one non-rest parameter.");
3423
+ const bodyTokenIndex = this.index;
3419
3424
  const body = this.withFunctionContext(generator ? "generator" : "normal", () => this.parseBlockStatement(params));
3425
+ if (accessor === "set" && params[0]?.type !== "Identifier") {
3426
+ let directiveTokenIndex = bodyTokenIndex + 1;
3427
+ for (const statement of body.body) {
3428
+ const token = this.tokens[directiveTokenIndex];
3429
+ if (statement.type !== "ExpressionStatement" || statement.expression.type !== "StringLiteral" || token?.type !== "string" || statement.span.start.offset !== token.start.offset || statement.span.end.offset !== token.end.offset) break;
3430
+ if (statement.expression.raw === '"use strict"' || statement.expression.raw === "'use strict'")
3431
+ throw new Error(
3432
+ "A setter with a non-simple parameter cannot contain a use strict directive."
3433
+ );
3434
+ directiveTokenIndex += this.tokens[directiveTokenIndex + 1]?.value === ";" ? 2 : 1;
3435
+ }
3436
+ }
3420
3437
  return { params, body };
3421
3438
  });
3422
3439
  }
@@ -3447,8 +3464,14 @@ var Parser = class {
3447
3464
  }
3448
3465
  const generator = this.consumePunctuator("*") !== void 0;
3449
3466
  if (async && generator) throw new DisallowedSyntaxError("async generator", methodStart.start);
3450
- if ((this.currentToken().value === "get" || this.currentToken().value === "set") && this.isObjectMethodStart())
3451
- throw new DisallowedSyntaxError("class accessor", this.currentToken().start);
3467
+ let accessor;
3468
+ const modifier = this.currentToken();
3469
+ if ((modifier.value === "get" || modifier.value === "set") && this.isObjectMethodStart()) {
3470
+ if (async || generator || modifier.end.offset - modifier.start.offset !== modifier.value.length)
3471
+ throw unexpectedTokenError(modifier);
3472
+ accessor = modifier.value;
3473
+ this.index++;
3474
+ }
3452
3475
  const computed = this.consumePunctuator("[") !== void 0;
3453
3476
  const key = computed ? this.parseExpression({ allowSequence: true }).node : this.currentToken().type === "string" ? createStringLiteral(this.tokens[this.index++]) : this.currentToken().type === "numeric" ? createNumericLiteral(this.tokens[this.index++]) : this.parseIdentifierName();
3454
3477
  if (computed) this.expectPunctuator("]");
@@ -3456,7 +3479,7 @@ var Parser = class {
3456
3479
  if (isStatic && name === "prototype") throw new Error("A static class element cannot be named prototype.");
3457
3480
  if (this.currentToken().value === "(") {
3458
3481
  const constructor = !isStatic && name === "constructor";
3459
- if (constructor && (async || generator)) throw new Error("A class constructor cannot be async or a generator.");
3482
+ if (constructor && (async || generator || accessor !== void 0)) throw new Error("A class constructor must be an ordinary method.");
3460
3483
  const { params, body } = this.parseFunctionParts(generator, {
3461
3484
  newTarget: true,
3462
3485
  superProperty: true,
@@ -3465,7 +3488,7 @@ var Parser = class {
3465
3488
  return: true,
3466
3489
  await: async,
3467
3490
  strictAwait: true
3468
- });
3491
+ }, accessor);
3469
3492
  const value2 = this.withFunctionSource({
3470
3493
  type: "FunctionExpression",
3471
3494
  async,
@@ -3480,7 +3503,7 @@ var Parser = class {
3480
3503
  key,
3481
3504
  computed,
3482
3505
  static: isStatic,
3483
- kind: constructor ? "constructor" : "method",
3506
+ kind: accessor ?? (constructor ? "constructor" : "method"),
3484
3507
  value: value2,
3485
3508
  span: createSpan2(start.start, value2.span.end)
3486
3509
  };
@@ -26516,8 +26539,15 @@ async function evaluateClass(node, context, evaluateNode2, callContext) {
26516
26539
  } else {
26517
26540
  const home = element.static ? constructor : prototype;
26518
26541
  const method = createInterpretedClosure(element.value, classContext, evaluateNode2, home);
26519
- Object.defineProperty(materializeFunctionProperties(method), "name", { value: key });
26520
- Object.defineProperty(element.static ? properties : prototype, key, { value: method, configurable: true, writable: true, enumerable: false });
26542
+ const accessor = element.kind === "get" || element.kind === "set" ? element.kind : void 0;
26543
+ Object.defineProperty(materializeFunctionProperties(method), "name", {
26544
+ value: accessor === void 0 ? key : `${accessor} ${key}`
26545
+ });
26546
+ Object.defineProperty(
26547
+ element.static ? properties : prototype,
26548
+ key,
26549
+ accessor === void 0 ? { value: method, configurable: true, writable: true, enumerable: false } : { [accessor]: accessorAdapter(method, accessor), configurable: true, enumerable: false }
26550
+ );
26521
26551
  }
26522
26552
  }
26523
26553
  if (node.id !== void 0) scope.declare(node.id.name, "const", constructor);
@@ -35469,4 +35499,4 @@ export {
35469
35499
  FileSnapshotBackend,
35470
35500
  run
35471
35501
  };
35472
- //# sourceMappingURL=chunk-EZAX76DY.js.map
35502
+ //# sourceMappingURL=chunk-FYPACPSN.js.map