@poe-platform/safe-js 0.1.141 → 0.1.143

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.
@@ -4624,12 +4624,15 @@ var Parser = class {
4624
4624
  `Generator shorthand methods are not supported at line ${generatorToken.start.line}, column ${generatorToken.start.column}.`
4625
4625
  );
4626
4626
  }
4627
+ let accessor;
4628
+ let accessorStart;
4627
4629
  if (this.currentToken().type === "identifier" && (this.currentToken().value === "get" || this.currentToken().value === "set") && this.isObjectMethodStart()) {
4628
4630
  const token2 = this.currentToken();
4629
- const syntax = token2.value === "get" ? "Getter" : "Setter";
4630
- throw new Error(
4631
- `${syntax} shorthand methods are not supported at line ${token2.start.line}, column ${token2.start.column}.`
4632
- );
4631
+ if (token2.end.offset - token2.start.offset !== token2.value.length)
4632
+ throw unexpectedTokenError(token2);
4633
+ accessor = token2.value === "get" ? "get" : "set";
4634
+ accessorStart = token2.start;
4635
+ this.index++;
4633
4636
  }
4634
4637
  const modifierToken = this.currentToken();
4635
4638
  const asyncToken = modifierToken.type === "keyword" && modifierToken.value === "async" && modifierToken.end.offset - modifierToken.start.offset === modifierToken.value.length && this.isObjectMethodStart() && !hasLineBreakBetween(modifierToken, this.peekToken(1)) ? modifierToken : void 0;
@@ -4641,14 +4644,15 @@ var Parser = class {
4641
4644
  const key = this.parseExpression();
4642
4645
  this.expectPunctuator("]");
4643
4646
  if (this.currentToken().type === "punctuator" && this.currentToken().value === "(") {
4644
- const value2 = this.parseObjectMethod(asyncToken, propertyStart.start);
4647
+ const value2 = this.parseObjectMethod(asyncToken, accessorStart ?? propertyStart.start, accessor);
4645
4648
  return {
4646
4649
  type: "Property",
4650
+ ...accessor === void 0 ? {} : { kind: accessor },
4647
4651
  computed: true,
4648
4652
  shorthand: false,
4649
4653
  key: key.node,
4650
4654
  value: value2,
4651
- span: createSpan2(asyncToken?.start ?? propertyStart.start, value2.span.end)
4655
+ span: createSpan2(value2.span.start, value2.span.end)
4652
4656
  };
4653
4657
  }
4654
4658
  this.expectPunctuator(":");
@@ -4667,14 +4671,15 @@ var Parser = class {
4667
4671
  this.index += 1;
4668
4672
  const key = createIdentifierName(token);
4669
4673
  if (this.currentToken().type === "punctuator" && this.currentToken().value === "(") {
4670
- const value2 = this.parseObjectMethod(asyncToken, key.span.start);
4674
+ const value2 = this.parseObjectMethod(asyncToken, accessorStart ?? key.span.start, accessor);
4671
4675
  return {
4672
4676
  type: "Property",
4677
+ ...accessor === void 0 ? {} : { kind: accessor },
4673
4678
  computed: false,
4674
4679
  shorthand: false,
4675
4680
  key,
4676
4681
  value: value2,
4677
- span: createSpan2(asyncToken?.start ?? key.span.start, value2.span.end)
4682
+ span: createSpan2(value2.span.start, value2.span.end)
4678
4683
  };
4679
4684
  }
4680
4685
  if (this.consumePunctuator(":") === void 0) {
@@ -4703,14 +4708,15 @@ var Parser = class {
4703
4708
  this.index += 1;
4704
4709
  const key = createLiteralFromToken(token);
4705
4710
  if (this.currentToken().type === "punctuator" && this.currentToken().value === "(") {
4706
- const value2 = this.parseObjectMethod(asyncToken, key.span.start);
4711
+ const value2 = this.parseObjectMethod(asyncToken, accessorStart ?? key.span.start, accessor);
4707
4712
  return {
4708
4713
  type: "Property",
4714
+ ...accessor === void 0 ? {} : { kind: accessor },
4709
4715
  computed: false,
4710
4716
  shorthand: false,
4711
4717
  key,
4712
4718
  value: value2,
4713
- span: createSpan2(asyncToken?.start ?? key.span.start, value2.span.end)
4719
+ span: createSpan2(value2.span.start, value2.span.end)
4714
4720
  };
4715
4721
  }
4716
4722
  this.expectPunctuator(":");
@@ -4750,11 +4756,12 @@ var Parser = class {
4750
4756
  }
4751
4757
  return (propertyToken.type === "identifier" || propertyToken.type === "keyword" || propertyToken.type === "numeric" || propertyToken.type === "string") && this.peekToken(2).type === "punctuator" && this.peekToken(2).value === "(";
4752
4758
  }
4753
- parseObjectMethod(asyncToken, methodStart) {
4759
+ parseObjectMethod(asyncToken, methodStart, accessor) {
4754
4760
  const { params, body } = this.parseFunctionParts(false, {
4755
4761
  ...ordinaryFunctionContext,
4756
- superProperty: true
4757
- });
4762
+ superProperty: true,
4763
+ ...accessor === void 0 ? {} : { await: false, strictAwait: true }
4764
+ }, accessor);
4758
4765
  return this.withFunctionSource({
4759
4766
  type: "FunctionExpression",
4760
4767
  async: asyncToken !== void 0,
@@ -28974,6 +28981,18 @@ async function evaluateObjectExpression(node, context) {
28974
28981
  if (value.kind !== "normal") {
28975
28982
  return value;
28976
28983
  }
28984
+ if (property.kind !== void 0) {
28985
+ if (!isSandboxClosure(value.value)) throw new TypeError("An accessor must be callable.");
28986
+ Object.defineProperty(materializeFunctionProperties(value.value), "name", {
28987
+ value: `${property.kind} ${String(key.value)}`
28988
+ });
28989
+ defineDataProperty(object, String(key.value), {
28990
+ [property.kind]: accessorAdapter(value.value, property.kind),
28991
+ configurable: true,
28992
+ enumerable: true
28993
+ }, context.budget);
28994
+ continue;
28995
+ }
28977
28996
  if (isObjectPrototypeSetterProperty(property, key.value)) {
28978
28997
  if (value.value === null || typeof value.value === "object") {
28979
28998
  setSandboxPrototype(object, value.value, context.budget);
@@ -28992,7 +29011,7 @@ async function evaluateObjectExpression(node, context) {
28992
29011
  }
28993
29012
  }
28994
29013
  function isObjectPrototypeSetterProperty(property, key) {
28995
- return !property.computed && !property.shorthand && key === "__proto__";
29014
+ return !property.computed && !property.shorthand && key === "__proto__" && !(property.value.type === "FunctionExpression" && property.value.method === true);
28996
29015
  }
28997
29016
  async function evaluateTemplateLiteral(node, context) {
28998
29017
  let value = context.budget.allocateString(node.quasis[0]?.value.cooked ?? "");
@@ -35511,4 +35530,4 @@ export {
35511
35530
  FileSnapshotBackend,
35512
35531
  run
35513
35532
  };
35514
- //# sourceMappingURL=chunk-Q6QTL7UZ.js.map
35533
+ //# sourceMappingURL=chunk-2DVGJCK5.js.map