@poe-platform/safe-js 0.1.369 → 0.1.371

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-54LUHONC.js";
30
+ } from "./chunk-SDKXAZOP.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-PO624I2M.js.map
8252
+ //# sourceMappingURL=chunk-J5WI6EGF.js.map
@@ -7409,6 +7409,9 @@ async function withRunResources(signal, execute) {
7409
7409
  return result;
7410
7410
  }
7411
7411
 
7412
+ // packages/safe-js/src/interp/error-prototypes.ts
7413
+ var errorPrototypes = /* @__PURE__ */ new WeakMap();
7414
+
7412
7415
  // packages/safe-js/src/interp/collection-brands.ts
7413
7416
  var sandboxMapBrand = /* @__PURE__ */ Symbol("SandboxMap");
7414
7417
  var sandboxSetBrand = /* @__PURE__ */ Symbol("SandboxSet");
@@ -8047,9 +8050,6 @@ function namedKeys(state) {
8047
8050
  });
8048
8051
  }
8049
8052
 
8050
- // packages/safe-js/src/interp/error-prototypes.ts
8051
- var errorPrototypes = /* @__PURE__ */ new WeakMap();
8052
-
8053
8053
  // packages/safe-js/src/interp/typed-array-prototypes.ts
8054
8054
  var typedArrayPrototypes = /* @__PURE__ */ new WeakMap();
8055
8055
 
@@ -25680,9 +25680,14 @@ function cloneStructuredValue(value, transfers, budget, context) {
25680
25680
  let step = first;
25681
25681
  try {
25682
25682
  while (!step.done) {
25683
- const { descriptor, receiver } = step.value;
25684
- createDataCheckpoint(budget, context)(receiver, 0, true);
25685
- step = iterator.next(await readPropertyDescriptor(descriptor, receiver, context));
25683
+ const request = step.value;
25684
+ if ("stringValue" in request) {
25685
+ createDataCheckpoint(budget, context)(request.stringValue, 0, true);
25686
+ step = iterator.next(await sandboxString(request.stringValue, budget, context));
25687
+ } else {
25688
+ createDataCheckpoint(budget, context)(request.receiver, 0, true);
25689
+ step = iterator.next(await readPropertyDescriptor(request.descriptor, request.receiver, context));
25690
+ }
25686
25691
  }
25687
25692
  return step.value;
25688
25693
  } finally {
@@ -28365,6 +28370,7 @@ function allocateProducedSandboxValue(value, budget) {
28365
28370
  allocateSandboxValue2(value, budget, /* @__PURE__ */ new WeakSet());
28366
28371
  return value;
28367
28372
  }
28373
+ var structuredCloneErrorNames = ["Error", "EvalError", "RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError"];
28368
28374
  function* cloneStructuredGraph(value, state, budget, depth = 0) {
28369
28375
  assertSandboxDataDepth(depth);
28370
28376
  budget.visitNode();
@@ -28388,12 +28394,32 @@ function* cloneStructuredGraph(value, state, budget, depth = 0) {
28388
28394
  const copy = map ? createSandboxMap() : set ? createSandboxSet() : array2 ? new Array(value.length) : createPlainObject(Object.getPrototypeOf(value) === null);
28389
28395
  state.seen.set(value, copy);
28390
28396
  const errorType = sandboxErrorTypes.get(value);
28391
- if (errorType !== void 0) sandboxErrorTypes.set(copy, errorType);
28392
28397
  let pending;
28393
28398
  let current;
28394
28399
  const release = retainValues(budget, () => [value, copy, pending, current]);
28395
28400
  try {
28396
- if (map && isSandboxMap(copy)) {
28401
+ if (errorType !== void 0) {
28402
+ const nameDescriptor = getSandboxPropertyDescriptor(value, "name", budget);
28403
+ current = nameDescriptor === void 0 ? void 0 : "value" in nameDescriptor ? nameDescriptor.value : yield { descriptor: nameDescriptor, receiver: value };
28404
+ const name = structuredCloneErrorNames.find((name2) => name2 === current) ?? "Error";
28405
+ const prototype = errorPrototypes.get(budget)?.get(name);
28406
+ if (prototype !== void 0) setSandboxPrototype(copy, prototype, budget);
28407
+ sandboxErrorTypes.set(copy, name);
28408
+ const message = Object.getOwnPropertyDescriptor(value, "message");
28409
+ if (message !== void 0 && "value" in message) {
28410
+ current = message.value;
28411
+ current = yield { stringValue: current };
28412
+ Object.defineProperty(copy, "message", { value: current, writable: true, configurable: true });
28413
+ }
28414
+ const stack = Object.getOwnPropertyDescriptor(value, "stack");
28415
+ if (stack !== void 0 && "value" in stack && typeof stack.value === "string")
28416
+ Object.defineProperty(copy, "stack", { value: budget.allocateString(stack.value), writable: true, configurable: true });
28417
+ const cause = Object.getOwnPropertyDescriptor(value, "cause");
28418
+ if (cause !== void 0 && "value" in cause) {
28419
+ current = cause.value;
28420
+ Object.defineProperty(copy, "cause", { value: yield* cloneStructuredGraph(current, state, budget, depth + 1), writable: true, configurable: true });
28421
+ }
28422
+ } else if (map && isSandboxMap(copy)) {
28397
28423
  budget.allocateArrayLength(value.entries.size);
28398
28424
  budget.provisionDataUsage(value.entries.size * 3 + 1)();
28399
28425
  const entries = [...value.entries];
@@ -28689,6 +28715,8 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
28689
28715
  if (isSandboxPrimitive(value)) {
28690
28716
  return value;
28691
28717
  }
28718
+ if (state.structuredClone && nodeTypes.isSymbolObject(value))
28719
+ throw new DOMException("Cannot clone a boxed symbol.", "DataCloneError");
28692
28720
  if (isLiveCapability(value)) throw new TypeError("Live capabilities require their owning realm bridge.");
28693
28721
  if (isRawJson(value)) {
28694
28722
  const existing = state.seen.get(value);
@@ -43594,4 +43622,4 @@ export {
43594
43622
  FileSnapshotBackend,
43595
43623
  run
43596
43624
  };
43597
- //# sourceMappingURL=chunk-54LUHONC.js.map
43625
+ //# sourceMappingURL=chunk-SDKXAZOP.js.map