@poe-platform/safe-js 0.1.283 → 0.1.285

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-Y55BYBLS.js";
30
+ } from "./chunk-O3NO3NGW.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-UOJGDWKG.js.map
8252
+ //# sourceMappingURL=chunk-4HGDBYOL.js.map
@@ -21887,10 +21887,13 @@ function createDateGlobal(options) {
21887
21887
  construct: async (args, context) => {
21888
21888
  let time;
21889
21889
  if (args.length === 0) time = Number(await now.call([], context));
21890
- else if (args.length > 1) time = dateFromParts(args, false);
21890
+ else if (args.length > 1) time = await coerceDateParts(args, false, options.budget, context);
21891
21891
  else if (isSandboxDate(args[0])) time = dateTime(args[0]);
21892
- else if (typeof args[0] === "string") time = parseDate(args[0], options.budget);
21893
- else time = dateNumber(args[0]);
21892
+ else {
21893
+ const input = args[0];
21894
+ const primitive = input !== null && typeof input === "object" ? await objectToPrimitive(input, options.budget, context, /* @__PURE__ */ new Set(), "default") : input;
21895
+ time = typeof primitive === "string" ? parseDate(primitive, options.budget) : await sandboxNumber(primitive, options.budget, context);
21896
+ }
21894
21897
  const newTarget = context?.newTarget;
21895
21898
  const selectedPrototype = newTarget === void 0 || newTarget === constructor ? prototype : context?.getProperty !== void 0 ? await context.getProperty(newTarget, "prototype") : await readPropertyDescriptor(getSandboxPropertyDescriptor(newTarget, "prototype", options.budget) ?? { value: void 0 }, newTarget, context);
21896
21899
  options.budget.chargeDataUsage(9);
@@ -21907,13 +21910,13 @@ function createDateGlobal(options) {
21907
21910
  sandbox: true,
21908
21911
  name: "parse",
21909
21912
  length: 1,
21910
- call: ([value]) => parseDate(value, options.budget)
21913
+ call: async ([value], context) => parseDate(await sandboxString(value, options.budget, context), options.budget)
21911
21914
  }),
21912
21915
  UTC: createSandboxClosure({
21913
21916
  sandbox: true,
21914
21917
  name: "UTC",
21915
21918
  length: 7,
21916
- call: (args) => dateFromParts(args, true)
21919
+ call: (args, context) => coerceDateParts(args, true, options.budget, context)
21917
21920
  })
21918
21921
  };
21919
21922
  const methods = /* @__PURE__ */ new Map();
@@ -21931,6 +21934,7 @@ function createDateGlobal(options) {
21931
21934
  if (!isSandboxDate(receiver))
21932
21935
  throw new TypeError(`Date#${name} requires a Date receiver.`);
21933
21936
  options.budget.visitNode();
21937
+ if (name.startsWith("set")) return coerceDateSetter(name, receiver, args, options.budget, context);
21934
21938
  const value = method.invoke(receiver, args);
21935
21939
  return typeof value === "string" ? options.budget.allocateString(value) : value;
21936
21940
  }
@@ -21957,6 +21961,20 @@ function createDateGlobal(options) {
21957
21961
  installDatePrototype(options.budget, prototype, constructor);
21958
21962
  return constructor;
21959
21963
  }
21964
+ async function coerceDateParts(args, utc, budget, context) {
21965
+ const parts = [];
21966
+ for (const value of args.slice(0, 7)) parts.push(await sandboxNumber(value, budget, context));
21967
+ return dateFromParts(parts, utc);
21968
+ }
21969
+ async function coerceDateSetter(name, receiver, args, budget, context) {
21970
+ const method = dateMethods.get(name);
21971
+ const initialTime = dateTime(receiver);
21972
+ const converted = [];
21973
+ for (const value of args.slice(0, method.length)) converted.push(await sandboxNumber(value, budget, context));
21974
+ if (Number.isNaN(initialTime) && name !== "setTime" && !name.endsWith("FullYear")) return NaN;
21975
+ const result = method.invoke(createSandboxDate(initialTime), converted);
21976
+ return dateMethods.get("setTime").invoke(receiver, [result]);
21977
+ }
21960
21978
  async function dateToJSON(receiver, budget, context) {
21961
21979
  if (receiver === null || receiver === void 0) throw new TypeError("Date JSON conversion requires a receiver.");
21962
21980
  if (typeof receiver === "number" || typeof receiver === "string" || typeof receiver === "boolean") {
@@ -25664,7 +25682,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
25664
25682
  }
25665
25683
  return copy;
25666
25684
  }
25667
- if (typeof value === "object" && value !== null && hasGuestObjectState(value)) {
25685
+ if (typeof value === "object" && value !== null && hasGuestObjectState(value) && !(state.structuredClone && isSandboxDate(value))) {
25668
25686
  throw new TypeError("Guest prototype links and custom descriptors cannot be copied as data.");
25669
25687
  }
25670
25688
  const primitive = nativeBoxedValue(value);
@@ -25733,6 +25751,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
25733
25751
  if (existing !== void 0) return existing;
25734
25752
  const copy = copyNativeDate(value);
25735
25753
  state.seen.set(value, copy);
25754
+ if (state.structuredClone) return copy;
25736
25755
  if (!state.structuredClone && hasNullObjectPrototype(value)) setSandboxPrototype(copy, null);
25737
25756
  for (const [key, descriptor] of dateDataProperties(value)) {
25738
25757
  Object.defineProperty(copy, key, { ...descriptor, value: copyToSandbox(descriptor.value, state, joinPath2(path, key), cloneSandboxCollections, depth + 1) });
@@ -40311,4 +40330,4 @@ export {
40311
40330
  FileSnapshotBackend,
40312
40331
  run
40313
40332
  };
40314
- //# sourceMappingURL=chunk-Y55BYBLS.js.map
40333
+ //# sourceMappingURL=chunk-O3NO3NGW.js.map