@poe-platform/safe-js 0.1.311 → 0.1.313

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.
@@ -14557,7 +14557,7 @@ function createFloat32ArrayGlobal(budget, nativePrototype = false) {
14557
14557
  const prototype = candidate !== null && typeof candidate === "object" ? candidate : float32Prototypes.get(budget);
14558
14558
  const release = retainValues(budget, () => [prototype, ...args]);
14559
14559
  try {
14560
- const result = allocateFloat32Array(args[0], budget);
14560
+ const result = args[0] !== null && typeof args[0] === "object" && !isFloat32Array(args[0]) ? await allocateFloat32Input(args[0], budget, context) : allocateFloat32Array(args[0], budget);
14561
14561
  setSandboxPrototype(result, prototype, budget);
14562
14562
  return result;
14563
14563
  } finally {
@@ -14569,6 +14569,57 @@ function createFloat32ArrayGlobal(budget, nativePrototype = false) {
14569
14569
  constructors.add(constructor);
14570
14570
  return constructor;
14571
14571
  }
14572
+ async function allocateFloat32Input(source, budget, context) {
14573
+ const callerContext = context;
14574
+ const bridge = {
14575
+ ...callerContext,
14576
+ stack: callerContext?.stack ?? [],
14577
+ thisValue: void 0,
14578
+ getProperty: callerContext?.getProperty ?? ((value, key) => {
14579
+ const descriptor = getSandboxPropertyDescriptor(value, key, budget);
14580
+ return descriptor === void 0 ? getSandboxDataProperty(value, key, budget) : readPropertyDescriptor(descriptor, value, bridge);
14581
+ }),
14582
+ invokeClosure: callerContext?.invokeClosure ?? ((callee, values2, receiver, construct) => invokeBuiltinClosure(callee, values2, budget, callerContext, receiver, construct))
14583
+ };
14584
+ const values = [];
14585
+ let iterator;
14586
+ let current;
14587
+ let result;
14588
+ const release = retainValues(budget, () => [source, values, iterator?.retainedValue, current, result]);
14589
+ const checkData = createDataCheckpoint(budget, bridge);
14590
+ try {
14591
+ iterator = await acquireSandboxIterator(source, budget, bridge);
14592
+ let length;
14593
+ if (iterator !== void 0) {
14594
+ while (true) {
14595
+ budget.visitNode();
14596
+ const next = await iterator.next();
14597
+ if (typeof next !== "object" || next === null) throw new TypeError("Iterator result must be an object.");
14598
+ if ((await readIteratorResult(iterator, next, "done")).value) break;
14599
+ current = (await readIteratorResult(iterator, next, "value")).value;
14600
+ budget.allocateArrayLength(values.length + 1);
14601
+ values.push(current);
14602
+ checkData(values, 1 + (budget.limits.dataSize === void 0 ? 0 : measureSandboxData([current])));
14603
+ }
14604
+ length = values.length;
14605
+ } else {
14606
+ current = await bridge.getProperty(source, "length");
14607
+ const number = await sandboxNumber(current, budget, bridge);
14608
+ length = Number.isNaN(number) || number <= 0 ? 0 : Math.min(Math.trunc(number), Number.MAX_SAFE_INTEGER);
14609
+ }
14610
+ checkFloat32Allocation(length, budget);
14611
+ result = new Float32Array(length);
14612
+ checkData(result, 0, true);
14613
+ for (let index = 0; index < length; index++) {
14614
+ budget.visitNode();
14615
+ current = iterator === void 0 ? await bridge.getProperty(source, String(index)) : values[index];
14616
+ result[index] = await sandboxNumber(current, budget, bridge);
14617
+ }
14618
+ return result;
14619
+ } finally {
14620
+ release();
14621
+ }
14622
+ }
14572
14623
  function allocateFloat32Array(source, budget) {
14573
14624
  if (Array.isArray(source) || isFloat32Array(source)) {
14574
14625
  const length2 = isFloat32Array(source) ? float32Storage(source).length : source.length;
@@ -14827,29 +14878,46 @@ function getFloat32Member(value, property, budget) {
14827
14878
  throw new TypeError(`Float32Array#${key} requires a Float32Array receiver.`);
14828
14879
  const storage2 = float32Storage(receiver);
14829
14880
  if (key === "set") {
14830
- const [source, offsetValue = 0] = args;
14831
- if (!Array.isArray(source) && !isFloat32Array(source))
14832
- throw new TypeError("Float32Array#set requires an array or Float32Array.");
14833
- const number = float32Number(offsetValue);
14834
- const offset = Number.isNaN(number) ? 0 : Math.trunc(number);
14835
- const length2 = isFloat32Array(source) ? float32Storage(source).length : source.length;
14836
- if (offset < 0 || !Number.isSafeInteger(offset) || offset + length2 > storage2.length)
14837
- throw new RangeError("Float32Array#set source is out of bounds.");
14838
- if (isFloat32Array(source)) {
14839
- Float32Array.prototype.set.call(receiver, source, offset);
14840
- return void 0;
14841
- }
14842
- checkFloat32Allocation(length2, budget);
14843
- const copied = new Float32Array(length2);
14844
- for (let index = 0; index < length2; index += 1) {
14845
- budget.visitNode();
14846
- const entry = Object.getOwnPropertyDescriptor(source, index);
14847
- if (entry !== void 0 && !("value" in entry))
14848
- throw new TypeError("Float32Array input accessors are not supported.");
14849
- copied[index] = float32Number(entry?.value);
14850
- }
14851
- Float32Array.prototype.set.call(receiver, copied, offset);
14852
- return void 0;
14881
+ return (async () => {
14882
+ const [source, offsetValue = 0] = args;
14883
+ const bridge = {
14884
+ ...context,
14885
+ stack: context?.stack ?? [],
14886
+ thisValue: receiver,
14887
+ getProperty: context?.getProperty ?? ((value2, property2) => {
14888
+ const descriptor2 = getSandboxPropertyDescriptor(value2, property2, budget);
14889
+ return descriptor2 === void 0 ? getSandboxDataProperty(value2, property2, budget) : readPropertyDescriptor(descriptor2, value2, bridge);
14890
+ }),
14891
+ invokeClosure: context?.invokeClosure ?? ((callee, values, thisValue, construct) => invokeBuiltinClosure(callee, values, budget, context, thisValue, construct))
14892
+ };
14893
+ let current;
14894
+ let sourceObject;
14895
+ const release = retainValues(budget, () => [receiver, sourceObject, current, ...args]);
14896
+ try {
14897
+ const number = await sandboxNumber(offsetValue, budget, bridge);
14898
+ const offset = Number.isNaN(number) ? 0 : Math.trunc(number);
14899
+ if (offset < 0) throw new RangeError("Float32Array#set offset is out of bounds.");
14900
+ if (source === null || source === void 0) throw new TypeError("Float32Array#set requires a non-null source.");
14901
+ let length2;
14902
+ if (isFloat32Array(source)) length2 = float32Storage(source).length;
14903
+ else {
14904
+ sourceObject = typeof source === "object" ? source : createSandboxBox(source);
14905
+ current = await bridge.getProperty(sourceObject, "length");
14906
+ const size = await sandboxNumber(current, budget, bridge);
14907
+ length2 = Number.isNaN(size) || size <= 0 ? 0 : Math.min(Math.trunc(size), Number.MAX_SAFE_INTEGER);
14908
+ }
14909
+ if (offset + length2 > storage2.length) throw new RangeError("Float32Array#set source is out of bounds.");
14910
+ if (isFloat32Array(source)) Float32Array.prototype.set.call(receiver, source, offset);
14911
+ else for (let index = 0; index < length2; index++) {
14912
+ budget.visitNode();
14913
+ current = await bridge.getProperty(sourceObject, String(index));
14914
+ receiver[offset + index] = await sandboxNumber(current, budget, bridge);
14915
+ }
14916
+ return void 0;
14917
+ } finally {
14918
+ release();
14919
+ }
14920
+ })();
14853
14921
  }
14854
14922
  const start = relativeIndex(args[0], storage2.length, 0);
14855
14923
  const end = relativeIndex(args[1], storage2.length, storage2.length);
@@ -41741,4 +41809,4 @@ export {
41741
41809
  FileSnapshotBackend,
41742
41810
  run
41743
41811
  };
41744
- //# sourceMappingURL=chunk-GWV7ELQW.js.map
41812
+ //# sourceMappingURL=chunk-HUG5DIKM.js.map