@poe-platform/safe-js 0.1.304 → 0.1.305

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.
@@ -14195,25 +14195,37 @@ function callFunctionMethod(target, methodName, args, options, stack, context) {
14195
14195
  if (applyArgs === null || applyArgs === void 0) {
14196
14196
  return options.callClosure(target, [], stack, thisValue);
14197
14197
  }
14198
- if (!Array.isArray(applyArgs)) {
14199
- throw new TypeError("Function#apply requires an array or nullish arguments value.");
14198
+ if (typeof applyArgs !== "object") {
14199
+ throw new TypeError("Function#apply requires an object or nullish arguments value.");
14200
14200
  }
14201
- if (context?.getProperty === void 0)
14201
+ if (context?.getProperty === void 0 && Array.isArray(applyArgs))
14202
14202
  return options.callClosure(target, applyArgs, stack, thisValue);
14203
14203
  return (async () => {
14204
+ const budget = options.budget ?? new Budget();
14205
+ const invocationContext = {
14206
+ ...context,
14207
+ stack,
14208
+ thisValue: context?.thisValue,
14209
+ invokeClosure: context?.invokeClosure ?? ((callee, values2, receiver) => Promise.resolve(options.callClosure(callee, values2, stack, receiver)))
14210
+ };
14211
+ const read = (value, key) => {
14212
+ if (context?.getProperty !== void 0) return context.getProperty(value, key);
14213
+ const descriptor = getSandboxPropertyDescriptor(value, key, budget);
14214
+ return descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, value, invocationContext);
14215
+ };
14204
14216
  const values = [];
14205
- const length = applyArgs.length;
14206
- options.budget?.allocateArrayLength(length);
14207
- const retained = {};
14208
- options.budget?.setRetainedValues(retained, () => values);
14217
+ const release = retainValues(budget, () => [applyArgs, ...values]);
14209
14218
  try {
14219
+ const number = await sandboxNumber(await read(applyArgs, "length"), budget, invocationContext);
14220
+ const length = Number.isNaN(number) || number <= 0 ? 0 : Math.min(Math.trunc(number), Number.MAX_SAFE_INTEGER);
14221
+ budget.allocateArrayLength(length);
14210
14222
  for (let index = 0; index < length; index++) {
14211
- options.budget?.visitNode();
14212
- values.push(await context.getProperty(applyArgs, index));
14223
+ budget.visitNode();
14224
+ values.push(await read(applyArgs, String(index)));
14213
14225
  }
14214
14226
  return await options.callClosure(target, values, stack, thisValue);
14215
14227
  } finally {
14216
- options.budget?.setRetainedValues(retained, void 0);
14228
+ release();
14217
14229
  }
14218
14230
  })();
14219
14231
  }
@@ -41239,4 +41251,4 @@ export {
41239
41251
  FileSnapshotBackend,
41240
41252
  run
41241
41253
  };
41242
- //# sourceMappingURL=chunk-I3JCUPXR.js.map
41254
+ //# sourceMappingURL=chunk-JIC2DHRN.js.map