@poe-platform/safe-js 0.1.139 → 0.1.141

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-EZAX76DY.js";
30
+ } from "./chunk-Q6QTL7UZ.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-I5E3GOL7.js.map
8252
+ //# sourceMappingURL=chunk-HEQEBF3T.js.map
@@ -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
  };
@@ -4728,7 +4751,10 @@ var Parser = class {
4728
4751
  return (propertyToken.type === "identifier" || propertyToken.type === "keyword" || propertyToken.type === "numeric" || propertyToken.type === "string") && this.peekToken(2).type === "punctuator" && this.peekToken(2).value === "(";
4729
4752
  }
4730
4753
  parseObjectMethod(asyncToken, methodStart) {
4731
- const { params, body } = this.parseFunctionParts(false, ordinaryFunctionContext);
4754
+ const { params, body } = this.parseFunctionParts(false, {
4755
+ ...ordinaryFunctionContext,
4756
+ superProperty: true
4757
+ });
4732
4758
  return this.withFunctionSource({
4733
4759
  type: "FunctionExpression",
4734
4760
  async: asyncToken !== void 0,
@@ -26516,8 +26542,15 @@ async function evaluateClass(node, context, evaluateNode2, callContext) {
26516
26542
  } else {
26517
26543
  const home = element.static ? constructor : prototype;
26518
26544
  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 });
26545
+ const accessor = element.kind === "get" || element.kind === "set" ? element.kind : void 0;
26546
+ Object.defineProperty(materializeFunctionProperties(method), "name", {
26547
+ value: accessor === void 0 ? key : `${accessor} ${key}`
26548
+ });
26549
+ Object.defineProperty(
26550
+ element.static ? properties : prototype,
26551
+ key,
26552
+ accessor === void 0 ? { value: method, configurable: true, writable: true, enumerable: false } : { [accessor]: accessorAdapter(method, accessor), configurable: true, enumerable: false }
26553
+ );
26521
26554
  }
26522
26555
  }
26523
26556
  if (node.id !== void 0) scope.declare(node.id.name, "const", constructor);
@@ -28930,7 +28963,11 @@ async function evaluateObjectExpression(node, context) {
28930
28963
  const releaseKey = retainValues(context.budget, () => [key.value]);
28931
28964
  let value;
28932
28965
  try {
28933
- value = await evaluateNode(property.value, { ...context, inferredName: String(key.value) });
28966
+ value = await evaluateNode(property.value, {
28967
+ ...context,
28968
+ inferredName: String(key.value),
28969
+ ...property.value.type === "FunctionExpression" && property.value.method === true ? { functionEnvironment: { homeObject: object } } : {}
28970
+ });
28934
28971
  } finally {
28935
28972
  releaseKey();
28936
28973
  }
@@ -31540,7 +31577,12 @@ async function evaluateFunctionExpression(node, context, evaluateNode2) {
31540
31577
  return {
31541
31578
  kind: "normal",
31542
31579
  hasValue: true,
31543
- value: createInterpretedClosure(node, context, evaluateNode2)
31580
+ value: createInterpretedClosure(
31581
+ node,
31582
+ context,
31583
+ evaluateNode2,
31584
+ node.method === true ? context.functionEnvironment?.homeObject : void 0
31585
+ )
31544
31586
  };
31545
31587
  }
31546
31588
  const wrapperScope = context.scope.child();
@@ -35469,4 +35511,4 @@ export {
35469
35511
  FileSnapshotBackend,
35470
35512
  run
35471
35513
  };
35472
- //# sourceMappingURL=chunk-EZAX76DY.js.map
35514
+ //# sourceMappingURL=chunk-Q6QTL7UZ.js.map