@poe-platform/safe-js 0.1.294 → 0.1.295

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.
@@ -13059,7 +13059,18 @@ function createArrayGlobal(budget) {
13059
13059
  guest: true,
13060
13060
  sandbox: true,
13061
13061
  call: (args) => createArrayFromConstructorArgs(args, budget),
13062
- construct: (args) => createArrayFromConstructorArgs(args, budget),
13062
+ construct: async (args, context) => {
13063
+ const target = context?.newTarget;
13064
+ const parent = target === void 0 || target === constructor ? prototype : context?.getProperty === void 0 ? await readPropertyDescriptor(
13065
+ getSandboxPropertyDescriptor(target, "prototype", budget) ?? { value: void 0 },
13066
+ target,
13067
+ context
13068
+ ) : await context.getProperty(target, "prototype");
13069
+ const value = createArrayFromConstructorArgs(args, budget);
13070
+ if (parent !== prototype && typeof parent === "object" && parent !== null)
13071
+ setSandboxPrototype(value, parent, budget);
13072
+ return value;
13073
+ },
13063
13074
  name: "Array",
13064
13075
  length: 1
13065
13076
  });
@@ -13103,7 +13114,33 @@ function createArrayGlobal(budget) {
13103
13114
  const statics = {
13104
13115
  isArray: createSandboxClosure({ sandbox: true, name: "isArray", call: ([value]) => Array.isArray(value) }),
13105
13116
  from: createSandboxClosure({ sandbox: true, name: "from", call: (args, context) => arrayFromSandboxValues(args, budget, context) }),
13106
- of: createSandboxClosure({ sandbox: true, name: "of", call: (args) => budgetSandboxValue(Reflect.apply(Array.of, Array, [...args]), budget) })
13117
+ of: createSandboxClosure({
13118
+ guest: true,
13119
+ sandbox: true,
13120
+ name: "of",
13121
+ length: 0,
13122
+ call: async (args, context) => {
13123
+ const target = context?.thisValue;
13124
+ let result;
13125
+ const release = retainValues(budget, () => [...args, target, result]);
13126
+ try {
13127
+ result = isSandboxClosure(target) && target.construct !== void 0 ? await invokeBuiltinClosure(target, [args.length], budget, context, void 0, true) : createArrayFromConstructorArgs([args.length], budget);
13128
+ const checkData = createDataCheckpoint(budget, context);
13129
+ checkData(result, 0, true);
13130
+ for (let index = 0; index < args.length; index += 1) {
13131
+ budget.visitNode();
13132
+ if (Array.isArray(result)) budget.allocateArrayLength(index + 1);
13133
+ defineOwnDataProperty(objectProperties(result, true), String(index), args[index]);
13134
+ checkData(result, 0, true);
13135
+ }
13136
+ await setSandboxProperty(result, "length", args.length, budget, true, context);
13137
+ checkData(result, 0, true);
13138
+ return allocateProducedSandboxValue(result, budget);
13139
+ } finally {
13140
+ release();
13141
+ }
13142
+ }
13143
+ })
13107
13144
  };
13108
13145
  for (const [name, value] of Object.entries(statics))
13109
13146
  Object.defineProperty(properties, name, { value, writable: true, configurable: true });
@@ -13410,7 +13447,7 @@ async function arrayFromSandboxValues(args, budget, context) {
13410
13447
  }
13411
13448
  index += 1;
13412
13449
  }
13413
- setSandboxProperty(result, "length", index, budget);
13450
+ await setSandboxProperty(result, "length", index, budget, true, context);
13414
13451
  checkData(result, 0, true);
13415
13452
  return allocateProducedSandboxValue(result, budget);
13416
13453
  } finally {
@@ -13419,11 +13456,11 @@ async function arrayFromSandboxValues(args, budget, context) {
13419
13456
  }
13420
13457
  function createArrayFromConstructorArgs(args, budget) {
13421
13458
  if (args.length !== 1) {
13422
- return budgetSandboxValue(Reflect.apply(Array, Array, [...args]), budget);
13459
+ return allocateProducedSandboxValue([...args], budget);
13423
13460
  }
13424
13461
  const [lengthOrValue] = args;
13425
13462
  if (typeof lengthOrValue !== "number") {
13426
- return budgetSandboxValue([lengthOrValue], budget);
13463
+ return allocateProducedSandboxValue([lengthOrValue], budget);
13427
13464
  }
13428
13465
  if (!Number.isInteger(lengthOrValue) || lengthOrValue < 0 || lengthOrValue > 4294967295) {
13429
13466
  throw new RangeError("Invalid array length.");
@@ -40728,4 +40765,4 @@ export {
40728
40765
  FileSnapshotBackend,
40729
40766
  run
40730
40767
  };
40731
- //# sourceMappingURL=chunk-DB2DTDG3.js.map
40768
+ //# sourceMappingURL=chunk-CL6E5SM7.js.map