@poe-platform/safe-js 0.1.284 → 0.1.286

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-TF7REBUG.js";
30
+ } from "./chunk-HEI7BJVB.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-KSXYQRJE.js.map
8252
+ //# sourceMappingURL=chunk-2KGYHU5J.js.map
@@ -7954,10 +7954,7 @@ function releaseObjectPrototype(budget) {
7954
7954
  }
7955
7955
  function getSandboxPrototype(value, budget) {
7956
7956
  if (prototypes.has(value)) return prototypes.get(value) ?? null;
7957
- if (budget !== void 0 && isSandboxDate(value)) {
7958
- const prototype = datePrototypes.get(budget);
7959
- return prototype === value ? intrinsicPrototypes.get(budget) ?? null : prototype ?? null;
7960
- }
7957
+ if (budget !== void 0 && isSandboxDate(value)) return datePrototypes.get(budget) ?? null;
7961
7958
  if (budget !== void 0 && isSandboxPromise(value)) return promisePrototypes.get(budget) ?? null;
7962
7959
  if (budget !== void 0 && (isSandboxMap(value) || isSandboxSet(value)))
7963
7960
  return collectionPrototypes.get(budget)?.get(isSandboxMap(value) ? "Map" : "Set") ?? null;
@@ -21875,7 +21872,7 @@ function createDateGlobal(options) {
21875
21872
  }
21876
21873
  );
21877
21874
  const now = wrapCallerInjectedBindings({ now: readNow }, { ...options, moduleId: "<Date>" }).now;
21878
- const prototype = createSandboxDate(NaN);
21875
+ const prototype = /* @__PURE__ */ Object.create(null);
21879
21876
  const constructor = createSandboxClosure({
21880
21877
  guest: true,
21881
21878
  sandbox: true,
@@ -21934,6 +21931,7 @@ function createDateGlobal(options) {
21934
21931
  if (!isSandboxDate(receiver))
21935
21932
  throw new TypeError(`Date#${name} requires a Date receiver.`);
21936
21933
  options.budget.visitNode();
21934
+ if (name.startsWith("set")) return coerceDateSetter(name, receiver, args, options.budget, context);
21937
21935
  const value = method.invoke(receiver, args);
21938
21936
  return typeof value === "string" ? options.budget.allocateString(value) : value;
21939
21937
  }
@@ -21965,6 +21963,15 @@ async function coerceDateParts(args, utc, budget, context) {
21965
21963
  for (const value of args.slice(0, 7)) parts.push(await sandboxNumber(value, budget, context));
21966
21964
  return dateFromParts(parts, utc);
21967
21965
  }
21966
+ async function coerceDateSetter(name, receiver, args, budget, context) {
21967
+ const method = dateMethods.get(name);
21968
+ const initialTime = dateTime(receiver);
21969
+ const converted = [];
21970
+ for (const value of args.slice(0, method.length)) converted.push(await sandboxNumber(value, budget, context));
21971
+ if (Number.isNaN(initialTime) && name !== "setTime" && !name.endsWith("FullYear")) return NaN;
21972
+ const result = method.invoke(createSandboxDate(initialTime), converted);
21973
+ return dateMethods.get("setTime").invoke(receiver, [result]);
21974
+ }
21968
21975
  async function dateToJSON(receiver, budget, context) {
21969
21976
  if (receiver === null || receiver === void 0) throw new TypeError("Date JSON conversion requires a receiver.");
21970
21977
  if (typeof receiver === "number" || typeof receiver === "string" || typeof receiver === "boolean") {
@@ -25672,7 +25679,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
25672
25679
  }
25673
25680
  return copy;
25674
25681
  }
25675
- if (typeof value === "object" && value !== null && hasGuestObjectState(value)) {
25682
+ if (typeof value === "object" && value !== null && hasGuestObjectState(value) && !(state.structuredClone && isSandboxDate(value))) {
25676
25683
  throw new TypeError("Guest prototype links and custom descriptors cannot be copied as data.");
25677
25684
  }
25678
25685
  const primitive = nativeBoxedValue(value);
@@ -25741,6 +25748,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
25741
25748
  if (existing !== void 0) return existing;
25742
25749
  const copy = copyNativeDate(value);
25743
25750
  state.seen.set(value, copy);
25751
+ if (state.structuredClone) return copy;
25744
25752
  if (!state.structuredClone && hasNullObjectPrototype(value)) setSandboxPrototype(copy, null);
25745
25753
  for (const [key, descriptor] of dateDataProperties(value)) {
25746
25754
  Object.defineProperty(copy, key, { ...descriptor, value: copyToSandbox(descriptor.value, state, joinPath2(path, key), cloneSandboxCollections, depth + 1) });
@@ -40319,4 +40327,4 @@ export {
40319
40327
  FileSnapshotBackend,
40320
40328
  run
40321
40329
  };
40322
- //# sourceMappingURL=chunk-TF7REBUG.js.map
40330
+ //# sourceMappingURL=chunk-HEI7BJVB.js.map