@poe-platform/safe-js 0.1.343 → 0.1.345

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.
@@ -14883,7 +14883,7 @@ function createFloat32ArrayPrototypes(budget, constructor) {
14883
14883
  getters.push(getter);
14884
14884
  Object.defineProperty(shared, key, { get: accessorAdapter(getter, "get"), configurable: true });
14885
14885
  }
14886
- for (const key of ["set", "slice", "subarray", "fill", "copyWithin", "reverse", "at", "includes", "indexOf", "lastIndexOf", "forEach", "every", "some", "find", "findIndex", "findLast", "findLastIndex", "reduce", "map", "filter", "toLocaleString"])
14886
+ for (const key of ["set", "slice", "subarray", "fill", "copyWithin", "reverse", "at", "includes", "indexOf", "lastIndexOf", "forEach", "every", "some", "find", "findIndex", "findLast", "findLastIndex", "sort", "reduce", "reduceRight", "map", "filter", "toLocaleString"])
14887
14887
  Object.defineProperty(shared, key, { value: getFloat32Member(new Float32Array(0), key, budget, constructor), writable: true, configurable: true });
14888
14888
  const arrayPrototype = resolveIntrinsicIdentity(budget, '["Array","prototype"]');
14889
14889
  Object.defineProperty(shared, "toString", { value: getSandboxDataProperty(arrayPrototype, "toString", budget), writable: true, configurable: true });
@@ -14965,18 +14965,20 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
14965
14965
  if (key === "byteLength") return storage.length * 4;
14966
14966
  if (key === "byteOffset") return storage.byteOffset;
14967
14967
  if (key === "BYTES_PER_ELEMENT") return 4;
14968
- if (!["set", "slice", "subarray", "fill", "copyWithin", "reverse", "at", "includes", "indexOf", "lastIndexOf", "forEach", "every", "some", "find", "findIndex", "findLast", "findLastIndex", "reduce", "map", "filter", "toLocaleString"].includes(key)) return void 0;
14968
+ if (!["set", "slice", "subarray", "fill", "copyWithin", "reverse", "at", "includes", "indexOf", "lastIndexOf", "forEach", "every", "some", "find", "findIndex", "findLast", "findLastIndex", "sort", "reduce", "reduceRight", "map", "filter", "toLocaleString"].includes(key)) return void 0;
14969
14969
  const numberPrototype = key === "toLocaleString" ? getBoxedPrototype(0, budget) : void 0;
14970
14970
  return createSandboxClosure({
14971
14971
  guest: true,
14972
14972
  sandbox: true,
14973
14973
  name: key,
14974
- length: key === "reverse" || key === "toLocaleString" ? 0 : key === "reduce" || key === "map" || key === "filter" || key === "set" || key === "fill" || key === "at" || key === "includes" || key === "indexOf" || key === "lastIndexOf" || key === "forEach" || key === "every" || key === "some" || key === "find" || key === "findIndex" || key === "findLast" || key === "findLastIndex" ? 1 : 2,
14974
+ length: key === "reverse" || key === "toLocaleString" ? 0 : key === "sort" || key === "reduce" || key === "reduceRight" || key === "map" || key === "filter" || key === "set" || key === "fill" || key === "at" || key === "includes" || key === "indexOf" || key === "lastIndexOf" || key === "forEach" || key === "every" || key === "some" || key === "find" || key === "findIndex" || key === "findLast" || key === "findLastIndex" ? 1 : 2,
14975
14975
  call: (args, context) => {
14976
+ if (key === "sort" && args[0] !== void 0 && !isSandboxClosure(args[0]))
14977
+ throw new TypeError("TypedArray sort comparator must be callable.");
14976
14978
  const receiver = context?.thisValue;
14977
14979
  if (!isFloat32Array(receiver))
14978
14980
  throw new TypeError(`Float32Array#${key} requires a Float32Array receiver.`);
14979
- const storage2 = float32Storage(receiver, key === "reduce" || key === "map" || key === "filter" || key === "slice" || key === "fill" || key === "copyWithin" || key === "reverse" || key === "at" || key === "includes" || key === "indexOf" || key === "lastIndexOf" || key === "forEach" || key === "every" || key === "some" || key === "find" || key === "findIndex" || key === "findLast" || key === "findLastIndex" || key === "toLocaleString");
14981
+ const storage2 = float32Storage(receiver, key === "sort" || key === "reduce" || key === "reduceRight" || key === "map" || key === "filter" || key === "slice" || key === "fill" || key === "copyWithin" || key === "reverse" || key === "at" || key === "includes" || key === "indexOf" || key === "lastIndexOf" || key === "forEach" || key === "every" || key === "some" || key === "find" || key === "findIndex" || key === "findLast" || key === "findLastIndex" || key === "toLocaleString");
14980
14982
  if (key === "reverse") {
14981
14983
  const release = retainValues(budget, () => [receiver, ...args]);
14982
14984
  try {
@@ -15005,6 +15007,66 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
15005
15007
  }),
15006
15008
  invokeClosure: context?.invokeClosure ?? ((callee, values, thisValue, construct) => invokeBuiltinClosure(callee, values, budget, context, thisValue, construct))
15007
15009
  };
15010
+ if (key === "sort") {
15011
+ const comparator = args[0];
15012
+ if (storage2.length < 2) return receiver;
15013
+ return (async () => {
15014
+ let items;
15015
+ let scratch;
15016
+ let comparisonResult;
15017
+ const release = retainValues(budget, () => [receiver, items, scratch, comparisonResult, ...args]);
15018
+ const checkData = createDataCheckpoint(budget, bridge);
15019
+ try {
15020
+ checkFloat32Allocation(storage2.length, budget);
15021
+ items = new Float32Array(storage2.length);
15022
+ checkData(items, 0, true);
15023
+ checkFloat32Allocation(storage2.length, budget);
15024
+ scratch = new Float32Array(storage2.length);
15025
+ checkData(scratch, 0, true);
15026
+ for (let index = 0; index < storage2.length; index++) {
15027
+ budget.visitNode();
15028
+ items[index] = receiver[index];
15029
+ }
15030
+ for (let width = 1; width < storage2.length; width *= 2) {
15031
+ for (let start = 0; start < storage2.length; start += width * 2) {
15032
+ const middle = Math.min(start + width, storage2.length);
15033
+ const end = Math.min(start + width * 2, storage2.length);
15034
+ let left = start;
15035
+ let right = middle;
15036
+ for (let output = start; output < end; output++) {
15037
+ budget.visitNode();
15038
+ let takeLeft = right === end;
15039
+ if (left < middle && right < end) {
15040
+ const a = items[left];
15041
+ const b = items[right];
15042
+ let order;
15043
+ if (comparator !== void 0) {
15044
+ comparisonResult = await invokeBuiltinClosure(comparator, [a, b], budget, bridge, void 0);
15045
+ order = await sandboxNumber(comparisonResult, budget, bridge);
15046
+ if (Number.isNaN(order)) order = 0;
15047
+ } else if (Number.isNaN(a)) order = Number.isNaN(b) ? 0 : 1;
15048
+ else if (Number.isNaN(b)) order = -1;
15049
+ else if (a === 0 && b === 0) order = Object.is(a, -0) ? Object.is(b, -0) ? 0 : -1 : Object.is(b, -0) ? 1 : 0;
15050
+ else order = a < b ? -1 : a > b ? 1 : 0;
15051
+ takeLeft = order <= 0;
15052
+ }
15053
+ scratch[output] = takeLeft ? items[left++] : items[right++];
15054
+ }
15055
+ }
15056
+ const previous = items;
15057
+ items = scratch;
15058
+ scratch = previous;
15059
+ }
15060
+ for (let index = 0; index < storage2.length; index++) {
15061
+ budget.visitNode();
15062
+ receiver[index] = items[index];
15063
+ }
15064
+ return receiver;
15065
+ } finally {
15066
+ release();
15067
+ }
15068
+ })();
15069
+ }
15008
15070
  if (key === "toLocaleString") {
15009
15071
  return (async () => {
15010
15072
  let text = "";
@@ -15029,16 +15091,18 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
15029
15091
  }
15030
15092
  })();
15031
15093
  }
15032
- if (key === "reduce") {
15094
+ if (key === "reduce" || key === "reduceRight") {
15033
15095
  const callback2 = args[0];
15034
- if (!isSandboxClosure(callback2)) throw new TypeError("Float32Array#reduce callback must be callable.");
15096
+ if (!isSandboxClosure(callback2)) throw new TypeError(`Float32Array#${key} callback must be callable.`);
15035
15097
  const hasInitialValue = args.length > 1;
15036
15098
  if (!hasInitialValue && storage2.length === 0) throw new TypeError("Reduce of empty typed array with no initial value.");
15037
- let accumulator = hasInitialValue ? args[1] : receiver[0];
15099
+ const backwards = key === "reduceRight";
15100
+ const first = backwards ? storage2.length - 1 : 0;
15101
+ let accumulator = hasInitialValue ? args[1] : receiver[first];
15038
15102
  return (async () => {
15039
15103
  const release = retainValues(budget, () => [receiver, accumulator, ...args]);
15040
15104
  try {
15041
- for (let index = hasInitialValue ? 0 : 1; index < storage2.length; index++) {
15105
+ for (let index = hasInitialValue ? first : first + (backwards ? -1 : 1); backwards ? index >= 0 : index < storage2.length; index += backwards ? -1 : 1) {
15042
15106
  budget.visitNode();
15043
15107
  accumulator = await invokeBuiltinClosure(callback2, [accumulator, receiver[index], index, receiver], budget, bridge, void 0);
15044
15108
  }
@@ -42552,4 +42616,4 @@ export {
42552
42616
  FileSnapshotBackend,
42553
42617
  run
42554
42618
  };
42555
- //# sourceMappingURL=chunk-B4T2KNMY.js.map
42619
+ //# sourceMappingURL=chunk-GW25G3LN.js.map