@poe-platform/safe-js 0.1.355 → 0.1.357
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.
- package/dist/safe-js/chunks/{chunk-3OJO2L46.js → chunk-FKOORMNH.js} +253 -219
- package/dist/safe-js/chunks/chunk-FKOORMNH.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-X64WTTKU.js → chunk-GSUPVJU4.js} +2 -2
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +1 -1
- package/dist/safe-js/index.js +2 -2
- package/dist/safe-js/interp/typed-array.d.ts +30 -0
- package/dist/safe-js/interp/values.d.ts +2 -1
- package/dist/safe-js/snapshot/replay-data.d.ts +2 -2
- package/dist/safe-js/snapshot/typed-array.d.ts +29 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-3OJO2L46.js.map +0 -7
- package/dist/safe-js/snapshot/float32array.d.ts +0 -22
- /package/dist/safe-js/chunks/{chunk-X64WTTKU.js.map → chunk-GSUPVJU4.js.map} +0 -0
|
@@ -6887,7 +6887,8 @@ function arrayBufferDataProperties(value) {
|
|
|
6887
6887
|
});
|
|
6888
6888
|
}
|
|
6889
6889
|
|
|
6890
|
-
// packages/safe-js/src/interp/
|
|
6890
|
+
// packages/safe-js/src/interp/typed-array.ts
|
|
6891
|
+
var numericTypedArrayConstructors = { Float32Array, Uint8Array };
|
|
6891
6892
|
var typedArrayPrototype = Object.getPrototypeOf(Float32Array.prototype);
|
|
6892
6893
|
var readLength2 = Object.getOwnPropertyDescriptor(typedArrayPrototype, "length").get;
|
|
6893
6894
|
var readOffset = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteOffset").get;
|
|
@@ -6896,57 +6897,62 @@ var readTag = Object.getOwnPropertyDescriptor(typedArrayPrototype, Symbol.toStri
|
|
|
6896
6897
|
var createValuesIterator = Object.getOwnPropertyDescriptor(typedArrayPrototype, "values").value;
|
|
6897
6898
|
var bufferLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
|
|
6898
6899
|
var bufferResizable = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resizable")?.get;
|
|
6899
|
-
var
|
|
6900
|
+
var typedArrayViewLayouts = /* @__PURE__ */ new WeakMap();
|
|
6900
6901
|
var resizeBuffer = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resize")?.value;
|
|
6901
|
-
function
|
|
6902
|
+
function restoreTypedArrayView(buffer, byteOffset, length, budget, Native = Float32Array) {
|
|
6902
6903
|
const originalLength = arrayBufferLength(buffer);
|
|
6903
|
-
const required = byteOffset + (length ?? 0) *
|
|
6904
|
+
const required = byteOffset + (length ?? 0) * Native.BYTES_PER_ELEMENT;
|
|
6904
6905
|
const options = arrayBufferOptions(buffer);
|
|
6905
6906
|
const grow = required > originalLength;
|
|
6906
6907
|
if (grow) {
|
|
6907
6908
|
if (resizeBuffer === void 0 || options === void 0 || required > options.maxByteLength)
|
|
6908
6909
|
throw new RangeError("Float32Array layout exceeds backing capacity.");
|
|
6909
|
-
budget?.allocateArrayLength(Math.ceil(required /
|
|
6910
|
+
budget?.allocateArrayLength(Math.ceil(required / Native.BYTES_PER_ELEMENT));
|
|
6910
6911
|
budget?.provisionDataUsage(required - originalLength)();
|
|
6911
6912
|
Reflect.apply(resizeBuffer, buffer, [required]);
|
|
6912
6913
|
}
|
|
6913
6914
|
try {
|
|
6914
|
-
const view = new
|
|
6915
|
-
if (options !== void 0)
|
|
6915
|
+
const view = new Native(buffer, byteOffset, length);
|
|
6916
|
+
if (options !== void 0) typedArrayViewLayouts.set(view, { byteOffset, ...length === void 0 ? {} : { length } });
|
|
6916
6917
|
return view;
|
|
6917
6918
|
} finally {
|
|
6918
6919
|
if (grow) Reflect.apply(resizeBuffer, buffer, [originalLength]);
|
|
6919
6920
|
}
|
|
6920
6921
|
}
|
|
6921
|
-
function
|
|
6922
|
-
|
|
6922
|
+
function isNumericTypedArray(value) {
|
|
6923
|
+
if (!ArrayBuffer.isView(value)) return false;
|
|
6924
|
+
const tag = Reflect.apply(readTag, value, []);
|
|
6925
|
+
return Object.hasOwn(numericTypedArrayConstructors, tag) && Object.getPrototypeOf(value) === numericTypedArrayConstructors[tag].prototype;
|
|
6923
6926
|
}
|
|
6924
|
-
function
|
|
6927
|
+
function typedArrayStorage(value, requireInBounds = false) {
|
|
6925
6928
|
if (requireInBounds) Reflect.apply(createValuesIterator, value, []);
|
|
6926
6929
|
const buffer = Reflect.apply(readBuffer, value, []);
|
|
6927
6930
|
if (Object.getPrototypeOf(buffer) !== ArrayBuffer.prototype) {
|
|
6928
6931
|
throw new TypeError("Float32Array requires a non-shared ArrayBuffer.");
|
|
6929
6932
|
}
|
|
6933
|
+
const Native = numericTypedArrayConstructors[Reflect.apply(readTag, value, [])];
|
|
6930
6934
|
return {
|
|
6935
|
+
Native,
|
|
6936
|
+
elementSize: Native.BYTES_PER_ELEMENT,
|
|
6931
6937
|
buffer,
|
|
6932
6938
|
byteOffset: Reflect.apply(readOffset, value, []),
|
|
6933
6939
|
length: Reflect.apply(readLength2, value, []),
|
|
6934
6940
|
byteLength: Reflect.apply(bufferLength, buffer, [])
|
|
6935
6941
|
};
|
|
6936
6942
|
}
|
|
6937
|
-
function
|
|
6943
|
+
function typedArrayProperties(value) {
|
|
6938
6944
|
const properties = [];
|
|
6939
6945
|
for (const key of Reflect.ownKeys(value)) {
|
|
6940
|
-
if (typeof key === "string" &&
|
|
6946
|
+
if (typeof key === "string" && isTypedArrayIndex(key)) continue;
|
|
6941
6947
|
properties.push([key, Object.getOwnPropertyDescriptor(value, key)]);
|
|
6942
6948
|
}
|
|
6943
6949
|
return properties;
|
|
6944
6950
|
}
|
|
6945
|
-
function
|
|
6951
|
+
function typedArrayDataProperties(value) {
|
|
6946
6952
|
if (Object.getOwnPropertySymbols(value).length > 0)
|
|
6947
6953
|
throw new TypeError("Float32Array symbol properties are not supported.");
|
|
6948
6954
|
const properties = [];
|
|
6949
|
-
for (const [key, descriptor] of
|
|
6955
|
+
for (const [key, descriptor] of typedArrayProperties(value)) {
|
|
6950
6956
|
if (typeof key !== "string") throw new TypeError("Float32Array symbol properties are not supported.");
|
|
6951
6957
|
if (!("value" in descriptor))
|
|
6952
6958
|
throw new TypeError(`Float32Array accessor property '${key}' is not supported.`);
|
|
@@ -6954,10 +6960,10 @@ function float32DataProperties(value) {
|
|
|
6954
6960
|
}
|
|
6955
6961
|
return properties;
|
|
6956
6962
|
}
|
|
6957
|
-
function
|
|
6963
|
+
function isTypedArrayIndex(key) {
|
|
6958
6964
|
return key === "-0" || String(Number(key)) === key;
|
|
6959
6965
|
}
|
|
6960
|
-
function
|
|
6966
|
+
function typedArrayNumber(value) {
|
|
6961
6967
|
if (value !== null && typeof value === "object" || typeof value === "function" || typeof value === "symbol" || typeof value === "bigint") {
|
|
6962
6968
|
throw new TypeError(
|
|
6963
6969
|
"Float32Array numeric arguments must be primitive numeric-coercible values."
|
|
@@ -6965,19 +6971,19 @@ function float32Number(value) {
|
|
|
6965
6971
|
}
|
|
6966
6972
|
return Number(value);
|
|
6967
6973
|
}
|
|
6968
|
-
function
|
|
6974
|
+
function checkTypedArrayAllocation(length, budget, elementSize = Float32Array.BYTES_PER_ELEMENT) {
|
|
6969
6975
|
budget.allocateArrayLength(length);
|
|
6970
|
-
budget.provisionDataUsage(length *
|
|
6976
|
+
budget.provisionDataUsage(length * elementSize + 1)();
|
|
6971
6977
|
}
|
|
6972
|
-
function
|
|
6973
|
-
const storage =
|
|
6978
|
+
function copyTypedArrayStorage(value, state) {
|
|
6979
|
+
const storage = typedArrayStorage(value);
|
|
6974
6980
|
const buffer = copyArrayBufferStorage(storage.buffer, state);
|
|
6975
6981
|
if (bufferResizable !== void 0 && Reflect.apply(bufferResizable, storage.buffer, [])) {
|
|
6976
|
-
const layout =
|
|
6982
|
+
const layout = typedArrayViewLayouts.get(value);
|
|
6977
6983
|
if (layout === void 0) throw new TypeError("Resizable Float32Array copies require known view layout.");
|
|
6978
|
-
return
|
|
6984
|
+
return restoreTypedArrayView(buffer, layout.byteOffset, layout.length, void 0, storage.Native);
|
|
6979
6985
|
}
|
|
6980
|
-
return new
|
|
6986
|
+
return new storage.Native(buffer, storage.byteOffset, storage.length);
|
|
6981
6987
|
}
|
|
6982
6988
|
|
|
6983
6989
|
// packages/safe-js/src/interp/date.ts
|
|
@@ -7970,8 +7976,8 @@ function namedKeys(state) {
|
|
|
7970
7976
|
// packages/safe-js/src/interp/error-prototypes.ts
|
|
7971
7977
|
var errorPrototypes = /* @__PURE__ */ new WeakMap();
|
|
7972
7978
|
|
|
7973
|
-
// packages/safe-js/src/interp/
|
|
7974
|
-
var
|
|
7979
|
+
// packages/safe-js/src/interp/typed-array-prototypes.ts
|
|
7980
|
+
var typedArrayPrototypes = /* @__PURE__ */ new WeakMap();
|
|
7975
7981
|
|
|
7976
7982
|
// packages/safe-js/src/interp/object-model.ts
|
|
7977
7983
|
var guestClosures = /* @__PURE__ */ new WeakSet();
|
|
@@ -8198,7 +8204,7 @@ function releaseObjectPrototype(budget) {
|
|
|
8198
8204
|
functionPrototypes.delete(budget);
|
|
8199
8205
|
generatorPrototypes.delete(budget);
|
|
8200
8206
|
errorPrototypes.delete(budget);
|
|
8201
|
-
|
|
8207
|
+
typedArrayPrototypes.delete(budget);
|
|
8202
8208
|
arrayBufferPrototypes.delete(budget);
|
|
8203
8209
|
initialRegexDescriptors.delete(budget);
|
|
8204
8210
|
intrinsicPrototypes.delete(budget);
|
|
@@ -8206,7 +8212,7 @@ function releaseObjectPrototype(budget) {
|
|
|
8206
8212
|
function getSandboxPrototype(value, budget) {
|
|
8207
8213
|
if (prototypes.has(value)) return prototypes.get(value) ?? null;
|
|
8208
8214
|
if (isSandboxArrayBuffer(value)) return budget === void 0 ? null : arrayBufferPrototypes.get(budget) ?? null;
|
|
8209
|
-
if (
|
|
8215
|
+
if (isNumericTypedArray(value)) return budget === void 0 ? null : typedArrayPrototypes.get(budget)?.get(typedArrayStorage(value).Native) ?? null;
|
|
8210
8216
|
const errorType = sandboxErrorTypes.get(value);
|
|
8211
8217
|
if (budget !== void 0 && errorType !== void 0) {
|
|
8212
8218
|
const prototype = errorPrototypes.get(budget)?.get(errorType);
|
|
@@ -8239,7 +8245,7 @@ function getSandboxPropertyDescriptor(value, key, budget) {
|
|
|
8239
8245
|
let current = value;
|
|
8240
8246
|
let depth = 0;
|
|
8241
8247
|
while (typeof current === "object" && current !== null && (Array.isArray(current) || isSandboxGenerator(current) || isSandboxDate(current) || isSandboxPromise(current) || isSandboxRegex(current) || isSandboxMap(current) || isSandboxSet(current) || isPrototypeRecord(current))) {
|
|
8242
|
-
if (
|
|
8248
|
+
if (isNumericTypedArray(current) && typeof key !== "symbol" && isTypedArrayIndex(String(key)))
|
|
8243
8249
|
return Object.getOwnPropertyDescriptor(current, key);
|
|
8244
8250
|
const properties = isSandboxGenerator(current) ? getGeneratorProperties(current) : isSandboxPromise(current) ? getPromiseProperties(current) : isGuestClosure(current) ? key === "prototype" && current.construct !== void 0 && current.boundTarget === void 0 ? materializeFunctionProperties(current) : getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : isSandboxMap(current) || isSandboxSet(current) ? getCollectionProperties(current) : current;
|
|
8245
8251
|
if (properties === void 0 && isGuestClosure(current) && (key === "name" || key === "length"))
|
|
@@ -8263,7 +8269,7 @@ function getSandboxDataProperty(value, key, budget) {
|
|
|
8263
8269
|
let current = value;
|
|
8264
8270
|
let depth = 0;
|
|
8265
8271
|
while (typeof current === "object" && current !== null) {
|
|
8266
|
-
if (
|
|
8272
|
+
if (isNumericTypedArray(current) && typeof key !== "symbol" && isTypedArrayIndex(String(key)))
|
|
8267
8273
|
return Object.getOwnPropertyDescriptor(current, key)?.value;
|
|
8268
8274
|
if (isGuestHostObject(current)) return typeof key === "symbol" ? void 0 : getHostObjectMember(current, String(key));
|
|
8269
8275
|
if (isSandboxRegex(current)) return Object.getOwnPropertyDescriptor(getRegexProperties(current), key)?.value;
|
|
@@ -8317,7 +8323,7 @@ function setSandboxPrototype(value, prototype, budget) {
|
|
|
8317
8323
|
}
|
|
8318
8324
|
function isPrototypeRecord(value) {
|
|
8319
8325
|
if (isSandboxArrayBuffer(value)) return true;
|
|
8320
|
-
if (
|
|
8326
|
+
if (isNumericTypedArray(value)) return true;
|
|
8321
8327
|
if (isGuestClosure(value)) return true;
|
|
8322
8328
|
if (isGuestHostObject(value)) return false;
|
|
8323
8329
|
if (isSandboxClosure(value) || isSandboxGenerator(value) || isSandboxMap(value) || isSandboxPromise(value) || isSandboxRegex(value) || isSandboxSet(value))
|
|
@@ -8337,7 +8343,7 @@ function hasGuestObjectState(value) {
|
|
|
8337
8343
|
if (isLiveCapability(value)) return true;
|
|
8338
8344
|
if (functionProperties.has(value) || prototypes.has(value) && !hasNullObjectPrototype(value)) return true;
|
|
8339
8345
|
if (isSandboxBox(value) || isSandboxDate(value)) return false;
|
|
8340
|
-
return descriptorObjects.has(value) && (
|
|
8346
|
+
return descriptorObjects.has(value) && (isNumericTypedArray(value) ? typedArrayProperties(value).map(([, descriptor]) => descriptor) : Object.values(Object.getOwnPropertyDescriptors(value))).some(
|
|
8341
8347
|
(descriptor) => !descriptor.enumerable || !descriptor.configurable || !descriptor.writable
|
|
8342
8348
|
);
|
|
8343
8349
|
}
|
|
@@ -9801,8 +9807,8 @@ function getSandboxIterator(value, budget, context) {
|
|
|
9801
9807
|
};
|
|
9802
9808
|
}
|
|
9803
9809
|
if (isGuestHostObject(value)) return getHostObjectIterator(value);
|
|
9804
|
-
if (
|
|
9805
|
-
if (hasExplicitSandboxPrototype(value) || budget !== void 0 &&
|
|
9810
|
+
if (isNumericTypedArray(value)) {
|
|
9811
|
+
if (hasExplicitSandboxPrototype(value) || budget !== void 0 && typedArrayPrototypes.has(budget)) {
|
|
9806
9812
|
if (getSandboxPropertyDescriptor(value, Symbol.iterator, budget) === void 0) return void 0;
|
|
9807
9813
|
return guestProtocolAdapter(value, budget ?? new Budget(), context, false);
|
|
9808
9814
|
}
|
|
@@ -10727,10 +10733,10 @@ async function nextArrayIterator(value, budget, context) {
|
|
|
10727
10733
|
if (source === void 0) return { value: void 0, done: true };
|
|
10728
10734
|
const index = state.index;
|
|
10729
10735
|
const release = retainValues(budget, () => [value, source]);
|
|
10730
|
-
const read = (key) => context?.getProperty !== void 0 ? context.getProperty(source, key) : readPropertyDescriptor((
|
|
10736
|
+
const read = (key) => context?.getProperty !== void 0 ? context.getProperty(source, key) : readPropertyDescriptor((isNumericTypedArray(source) ? Object.getOwnPropertyDescriptor(source, key) : void 0) ?? getSandboxPropertyDescriptor(source, key, budget) ?? { value: void 0 }, source, context);
|
|
10731
10737
|
try {
|
|
10732
10738
|
budget.visitNode();
|
|
10733
|
-
const number =
|
|
10739
|
+
const number = isNumericTypedArray(source) ? typedArrayStorage(source, true).length : await sandboxNumber(await read("length"), budget, context);
|
|
10734
10740
|
const length = Number.isNaN(number) || number <= 0 ? 0 : Math.min(Math.trunc(number), Number.MAX_SAFE_INTEGER);
|
|
10735
10741
|
if (index >= length) {
|
|
10736
10742
|
state.source = void 0;
|
|
@@ -10814,7 +10820,7 @@ async function canonicalizeGuestLocales(input, budget, context) {
|
|
|
10814
10820
|
for (let index = 0; index < length; index++) {
|
|
10815
10821
|
budget.visitNode();
|
|
10816
10822
|
const key = String(index);
|
|
10817
|
-
if (getSandboxPropertyDescriptor(list2, key, budget) === void 0 && !(
|
|
10823
|
+
if (getSandboxPropertyDescriptor(list2, key, budget) === void 0 && !(isNumericTypedArray(list2) && Object.hasOwn(list2, key))) continue;
|
|
10818
10824
|
const value = await readIntlProperty(list2, key, budget, context);
|
|
10819
10825
|
if (typeof value !== "string" && (typeof value !== "object" || value === null))
|
|
10820
10826
|
return Reflect.apply(canonicalLocales, Intl, [[value]]);
|
|
@@ -13775,7 +13781,7 @@ async function definePropertiesFromObject(target, descriptors2, budget, context)
|
|
|
13775
13781
|
}
|
|
13776
13782
|
function defineDataProperty(target, key, descriptor, budget, context) {
|
|
13777
13783
|
budget.visitNode();
|
|
13778
|
-
if (
|
|
13784
|
+
if (isNumericTypedArray(target) && typeof key !== "symbol" && isTypedArrayIndex(String(key)) && "value" in descriptor) {
|
|
13779
13785
|
const { value, ...attributes } = descriptor;
|
|
13780
13786
|
Object.defineProperty(target, key, attributes);
|
|
13781
13787
|
return (async () => {
|
|
@@ -14621,31 +14627,31 @@ async function callSetMethod(target, methodName, args, options, stack = []) {
|
|
|
14621
14627
|
}
|
|
14622
14628
|
}
|
|
14623
14629
|
|
|
14624
|
-
// packages/safe-js/src/interp/globals/
|
|
14625
|
-
var constructors = /* @__PURE__ */ new
|
|
14626
|
-
function
|
|
14630
|
+
// packages/safe-js/src/interp/globals/numeric-typed-array.ts
|
|
14631
|
+
var constructors = /* @__PURE__ */ new WeakMap();
|
|
14632
|
+
function createNumericTypedArrayGlobal(budget, nativePrototype = false, Native = Float32Array) {
|
|
14627
14633
|
const constructor = createSandboxClosure({
|
|
14628
14634
|
guest: nativePrototype,
|
|
14629
14635
|
sandbox: true,
|
|
14630
|
-
name:
|
|
14636
|
+
name: Native.name,
|
|
14631
14637
|
length: 3,
|
|
14632
|
-
properties: { BYTES_PER_ELEMENT:
|
|
14638
|
+
properties: { BYTES_PER_ELEMENT: Native.BYTES_PER_ELEMENT },
|
|
14633
14639
|
call: () => {
|
|
14634
14640
|
throw new TypeError("Constructor Float32Array requires 'new'.");
|
|
14635
14641
|
},
|
|
14636
14642
|
construct: (args, context) => {
|
|
14637
|
-
if (!nativePrototype) return
|
|
14643
|
+
if (!nativePrototype) return allocateTypedArray(args[0], budget, Native);
|
|
14638
14644
|
return (async () => {
|
|
14639
14645
|
const newTarget = context?.newTarget ?? constructor;
|
|
14640
14646
|
const candidate = context?.getProperty === void 0 ? getSandboxDataProperty(newTarget, "prototype", budget) : await context.getProperty(newTarget, "prototype");
|
|
14641
|
-
const prototype = candidate !== null && typeof candidate === "object" ? candidate :
|
|
14647
|
+
const prototype = candidate !== null && typeof candidate === "object" ? candidate : typedArrayPrototypes.get(budget).get(Native);
|
|
14642
14648
|
const release = retainValues(budget, () => [prototype, ...args]);
|
|
14643
14649
|
try {
|
|
14644
14650
|
if (isSandboxArrayBuffer(args[0])) {
|
|
14645
14651
|
const buffer = args[0];
|
|
14646
14652
|
const number = await sandboxNumber(args[1], budget, context);
|
|
14647
14653
|
const offset = Number.isNaN(number) ? 0 : Math.trunc(number);
|
|
14648
|
-
if (!Number.isSafeInteger(offset) || offset < 0 || offset %
|
|
14654
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || offset % Native.BYTES_PER_ELEMENT !== 0)
|
|
14649
14655
|
throw new RangeError("Invalid Float32Array buffer offset.");
|
|
14650
14656
|
let length;
|
|
14651
14657
|
if (args[2] !== void 0) {
|
|
@@ -14657,21 +14663,21 @@ function createFloat32ArrayGlobal(budget, nativePrototype = false) {
|
|
|
14657
14663
|
if (arrayBufferDetached(buffer)) throw new TypeError("Cannot construct Float32Array from a detached ArrayBuffer.");
|
|
14658
14664
|
const bytes = arrayBufferLength(buffer);
|
|
14659
14665
|
if (length === void 0) {
|
|
14660
|
-
if (arrayBufferOptions(buffer) === void 0 && bytes %
|
|
14666
|
+
if (arrayBufferOptions(buffer) === void 0 && bytes % Native.BYTES_PER_ELEMENT !== 0 || offset > bytes)
|
|
14661
14667
|
throw new RangeError("Invalid Float32Array buffer length.");
|
|
14662
|
-
length = Math.floor((bytes - offset) /
|
|
14668
|
+
length = Math.floor((bytes - offset) / Native.BYTES_PER_ELEMENT);
|
|
14663
14669
|
} else {
|
|
14664
|
-
if (offset + length *
|
|
14670
|
+
if (offset + length * Native.BYTES_PER_ELEMENT > bytes)
|
|
14665
14671
|
throw new RangeError("Invalid Float32Array view length.");
|
|
14666
14672
|
}
|
|
14667
14673
|
budget.allocateArrayLength(length);
|
|
14668
|
-
const result2 = new
|
|
14674
|
+
const result2 = new Native(buffer, offset, args[2] === void 0 ? void 0 : length);
|
|
14669
14675
|
if (arrayBufferOptions(buffer) !== void 0)
|
|
14670
|
-
|
|
14676
|
+
typedArrayViewLayouts.set(result2, { byteOffset: offset, ...args[2] === void 0 ? {} : { length } });
|
|
14671
14677
|
setSandboxPrototype(result2, prototype, budget);
|
|
14672
14678
|
return result2;
|
|
14673
14679
|
}
|
|
14674
|
-
const result = args[0] !== null && typeof args[0] === "object" && !
|
|
14680
|
+
const result = args[0] !== null && typeof args[0] === "object" && !isNumericTypedArray(args[0]) ? await allocateTypedArrayInput(args[0], budget, Native, context) : allocateTypedArray(args[0], budget, Native);
|
|
14675
14681
|
setSandboxPrototype(result, prototype, budget);
|
|
14676
14682
|
return result;
|
|
14677
14683
|
} finally {
|
|
@@ -14680,10 +14686,10 @@ function createFloat32ArrayGlobal(budget, nativePrototype = false) {
|
|
|
14680
14686
|
})();
|
|
14681
14687
|
}
|
|
14682
14688
|
});
|
|
14683
|
-
constructors.
|
|
14689
|
+
constructors.set(constructor, Native);
|
|
14684
14690
|
return constructor;
|
|
14685
14691
|
}
|
|
14686
|
-
async function
|
|
14692
|
+
async function allocateTypedArrayInput(source, budget, Native, context) {
|
|
14687
14693
|
const callerContext = context;
|
|
14688
14694
|
const bridge = {
|
|
14689
14695
|
...callerContext,
|
|
@@ -14721,8 +14727,8 @@ async function allocateFloat32Input(source, budget, context) {
|
|
|
14721
14727
|
const number = await sandboxNumber(current, budget, bridge);
|
|
14722
14728
|
length = Number.isNaN(number) || number <= 0 ? 0 : Math.min(Math.trunc(number), Number.MAX_SAFE_INTEGER);
|
|
14723
14729
|
}
|
|
14724
|
-
|
|
14725
|
-
result = new
|
|
14730
|
+
checkTypedArrayAllocation(length, budget, Native.BYTES_PER_ELEMENT);
|
|
14731
|
+
result = new Native(length);
|
|
14726
14732
|
checkData(result, 0, true);
|
|
14727
14733
|
for (let index = 0; index < length; index++) {
|
|
14728
14734
|
budget.visitNode();
|
|
@@ -14734,30 +14740,29 @@ async function allocateFloat32Input(source, budget, context) {
|
|
|
14734
14740
|
release();
|
|
14735
14741
|
}
|
|
14736
14742
|
}
|
|
14737
|
-
function
|
|
14738
|
-
if (Array.isArray(source) ||
|
|
14739
|
-
const length2 =
|
|
14740
|
-
|
|
14741
|
-
if (
|
|
14742
|
-
const result = new
|
|
14743
|
+
function allocateTypedArray(source, budget, Native) {
|
|
14744
|
+
if (Array.isArray(source) || isNumericTypedArray(source)) {
|
|
14745
|
+
const length2 = isNumericTypedArray(source) ? typedArrayStorage(source).length : source.length;
|
|
14746
|
+
checkTypedArrayAllocation(length2, budget, Native.BYTES_PER_ELEMENT);
|
|
14747
|
+
if (isNumericTypedArray(source)) return new Native(source);
|
|
14748
|
+
const result = new Native(length2);
|
|
14743
14749
|
for (let index = 0; index < length2; index += 1) {
|
|
14744
14750
|
budget.visitNode();
|
|
14745
14751
|
const descriptor = Object.getOwnPropertyDescriptor(source, index);
|
|
14746
14752
|
if (descriptor !== void 0 && !("value" in descriptor))
|
|
14747
14753
|
throw new TypeError("Float32Array input accessors are not supported.");
|
|
14748
|
-
result[index] =
|
|
14754
|
+
result[index] = typedArrayNumber(descriptor?.value);
|
|
14749
14755
|
}
|
|
14750
14756
|
return result;
|
|
14751
14757
|
}
|
|
14752
|
-
const number =
|
|
14758
|
+
const number = typedArrayNumber(source);
|
|
14753
14759
|
const length = Number.isNaN(number) ? 0 : Math.trunc(number);
|
|
14754
14760
|
if (length < 0 || !Number.isSafeInteger(length))
|
|
14755
14761
|
throw new RangeError("Invalid typed array length.");
|
|
14756
|
-
|
|
14757
|
-
return new
|
|
14762
|
+
checkTypedArrayAllocation(length, budget, Native.BYTES_PER_ELEMENT);
|
|
14763
|
+
return new Native(length);
|
|
14758
14764
|
}
|
|
14759
|
-
function
|
|
14760
|
-
const prototype = /* @__PURE__ */ Object.create(null);
|
|
14765
|
+
function createNumericTypedArrayPrototypes(budget, bindings) {
|
|
14761
14766
|
const shared = /* @__PURE__ */ Object.create(null);
|
|
14762
14767
|
const abstractCall = () => {
|
|
14763
14768
|
throw new TypeError("Abstract TypedArray constructor cannot be called.");
|
|
@@ -14826,7 +14831,7 @@ function createFloat32ArrayPrototypes(budget, constructor) {
|
|
|
14826
14831
|
length = Number.isNaN(number) || number <= 0 ? 0 : Math.min(Math.trunc(number), Number.MAX_SAFE_INTEGER);
|
|
14827
14832
|
}
|
|
14828
14833
|
result = await invokeBuiltinClosure(target, [length], budget, context, void 0, true);
|
|
14829
|
-
if (!
|
|
14834
|
+
if (!isNumericTypedArray(result) || typedArrayStorage(result).length < length)
|
|
14830
14835
|
throw new TypeError("TypedArray.from constructor must return sufficient typed storage.");
|
|
14831
14836
|
checkData(result, 0, true);
|
|
14832
14837
|
for (let index = 0; index < length; index++) {
|
|
@@ -14859,7 +14864,7 @@ function createFloat32ArrayPrototypes(budget, constructor) {
|
|
|
14859
14864
|
const release = retainValues(budget, () => [target, result, ...args]);
|
|
14860
14865
|
try {
|
|
14861
14866
|
result = await invokeBuiltinClosure(target, [args.length], budget, context, void 0, true);
|
|
14862
|
-
if (!
|
|
14867
|
+
if (!isNumericTypedArray(result) || typedArrayStorage(result).length < args.length)
|
|
14863
14868
|
throw new TypeError("TypedArray.of constructor must return sufficient typed storage.");
|
|
14864
14869
|
for (let index = 0; index < args.length; index++) {
|
|
14865
14870
|
budget.visitNode();
|
|
@@ -14872,17 +14877,25 @@ function createFloat32ArrayPrototypes(budget, constructor) {
|
|
|
14872
14877
|
}
|
|
14873
14878
|
})
|
|
14874
14879
|
});
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
|
|
14880
|
-
|
|
14881
|
-
|
|
14882
|
-
|
|
14880
|
+
const prototypes2 = /* @__PURE__ */ new Map();
|
|
14881
|
+
for (const [name, Native] of Object.entries(numericTypedArrayConstructors)) {
|
|
14882
|
+
const constructor = bindings[name];
|
|
14883
|
+
const prototype = /* @__PURE__ */ Object.create(null);
|
|
14884
|
+
Object.defineProperties(materializeFunctionProperties(constructor), {
|
|
14885
|
+
prototype: { value: prototype, writable: false },
|
|
14886
|
+
BYTES_PER_ELEMENT: { value: Native.BYTES_PER_ELEMENT, writable: false, enumerable: false, configurable: false }
|
|
14887
|
+
});
|
|
14888
|
+
Object.defineProperties(prototype, {
|
|
14889
|
+
constructor: { value: constructor, writable: true, configurable: true },
|
|
14890
|
+
BYTES_PER_ELEMENT: { value: Native.BYTES_PER_ELEMENT }
|
|
14891
|
+
});
|
|
14892
|
+
setSandboxPrototype(constructor, typedArray);
|
|
14893
|
+
setSandboxPrototype(prototype, shared);
|
|
14894
|
+
prototypes2.set(Native, prototype);
|
|
14895
|
+
registerIntrinsicFunction(budget, constructor);
|
|
14896
|
+
registerIntrinsicObject(budget, prototype);
|
|
14897
|
+
}
|
|
14883
14898
|
Object.defineProperty(shared, "constructor", { value: typedArray, writable: true, configurable: true });
|
|
14884
|
-
setSandboxPrototype(constructor, typedArray);
|
|
14885
|
-
setSandboxPrototype(prototype, shared);
|
|
14886
14899
|
setSandboxPrototype(shared, getSandboxPrototype(/* @__PURE__ */ Object.create(null), budget));
|
|
14887
14900
|
const getters = [];
|
|
14888
14901
|
const species = createSandboxClosure({
|
|
@@ -14904,16 +14917,16 @@ function createFloat32ArrayPrototypes(budget, constructor) {
|
|
|
14904
14917
|
name: `get ${key}`,
|
|
14905
14918
|
length: 0,
|
|
14906
14919
|
call: (_args, context) => {
|
|
14907
|
-
if (!
|
|
14908
|
-
const storage =
|
|
14909
|
-
return key === "byteLength" ? storage.length *
|
|
14920
|
+
if (!isNumericTypedArray(context?.thisValue)) throw new TypeError(`TypedArray ${key} requires a typed array receiver.`);
|
|
14921
|
+
const storage = typedArrayStorage(context.thisValue);
|
|
14922
|
+
return key === "byteLength" ? storage.length * storage.elementSize : storage[key];
|
|
14910
14923
|
}
|
|
14911
14924
|
});
|
|
14912
14925
|
getters.push(getter);
|
|
14913
14926
|
Object.defineProperty(shared, key, { get: accessorAdapter(getter, "get"), configurable: true });
|
|
14914
14927
|
}
|
|
14915
14928
|
for (const key of ["set", "slice", "subarray", "fill", "copyWithin", "reverse", "toReversed", "at", "includes", "indexOf", "lastIndexOf", "forEach", "every", "some", "find", "findIndex", "findLast", "findLastIndex", "sort", "toSorted", "with", "reduce", "reduceRight", "map", "filter", "toLocaleString"])
|
|
14916
|
-
Object.defineProperty(shared, key, { value:
|
|
14929
|
+
Object.defineProperty(shared, key, { value: getTypedArrayMember(new Float32Array(0), key, budget, bindings), writable: true, configurable: true });
|
|
14917
14930
|
const arrayPrototype = resolveIntrinsicIdentity(budget, '["Array","prototype"]');
|
|
14918
14931
|
Object.defineProperty(shared, "toString", { value: getSandboxDataProperty(arrayPrototype, "toString", budget), writable: true, configurable: true });
|
|
14919
14932
|
Object.defineProperty(shared, "join", {
|
|
@@ -14925,9 +14938,9 @@ function createFloat32ArrayPrototypes(budget, constructor) {
|
|
|
14925
14938
|
name: "join",
|
|
14926
14939
|
length: 1,
|
|
14927
14940
|
call: async (args, context) => {
|
|
14928
|
-
if (!
|
|
14941
|
+
if (!isNumericTypedArray(context?.thisValue)) throw new TypeError("TypedArray join requires a typed array receiver.");
|
|
14929
14942
|
const receiver = context.thisValue;
|
|
14930
|
-
const length =
|
|
14943
|
+
const length = typedArrayStorage(receiver, true).length;
|
|
14931
14944
|
let separator = ",";
|
|
14932
14945
|
let text = "";
|
|
14933
14946
|
const release = retainValues(budget, () => [receiver, separator, text, ...args]);
|
|
@@ -14950,7 +14963,7 @@ function createFloat32ArrayPrototypes(budget, constructor) {
|
|
|
14950
14963
|
sandbox: true,
|
|
14951
14964
|
name: "get [Symbol.toStringTag]",
|
|
14952
14965
|
length: 0,
|
|
14953
|
-
call: (_args, context) =>
|
|
14966
|
+
call: (_args, context) => isNumericTypedArray(context?.thisValue) ? typedArrayStorage(context.thisValue).Native.name : void 0
|
|
14954
14967
|
});
|
|
14955
14968
|
getters.push(tagGetter);
|
|
14956
14969
|
Object.defineProperty(shared, Symbol.toStringTag, { get: accessorAdapter(tagGetter, "get"), configurable: true });
|
|
@@ -14962,38 +14975,36 @@ function createFloat32ArrayPrototypes(budget, constructor) {
|
|
|
14962
14975
|
name: key,
|
|
14963
14976
|
length: 0,
|
|
14964
14977
|
call: (args, context) => {
|
|
14965
|
-
if (!
|
|
14966
|
-
|
|
14978
|
+
if (!isNumericTypedArray(context?.thisValue)) throw new TypeError(`TypedArray ${key} requires a typed array receiver.`);
|
|
14979
|
+
typedArrayStorage(context.thisValue, true);
|
|
14967
14980
|
return invokeBuiltinClosure(method, args, budget, context, context.thisValue);
|
|
14968
14981
|
}
|
|
14969
14982
|
});
|
|
14970
14983
|
Object.defineProperty(shared, key, { value: closure, writable: true, configurable: true });
|
|
14971
14984
|
if (key === "values") Object.defineProperty(shared, Symbol.iterator, { value: closure, writable: true, configurable: true });
|
|
14972
14985
|
}
|
|
14973
|
-
|
|
14974
|
-
registerBuiltinIdentities(budget, {
|
|
14975
|
-
registerIntrinsicFunction(budget, constructor);
|
|
14986
|
+
typedArrayPrototypes.set(budget, prototypes2);
|
|
14987
|
+
registerBuiltinIdentities(budget, { ...bindings, "%TypedArray%": typedArray });
|
|
14976
14988
|
registerIntrinsicFunction(budget, typedArray);
|
|
14977
|
-
registerIntrinsicObject(budget, prototype);
|
|
14978
14989
|
registerIntrinsicObject(budget, shared);
|
|
14979
14990
|
for (const getter of getters) registerIntrinsicFunction(budget, getter);
|
|
14980
14991
|
}
|
|
14981
|
-
function
|
|
14982
|
-
return typeof value === "object" && value !== null
|
|
14992
|
+
function numericTypedArrayConstructor(value) {
|
|
14993
|
+
return typeof value === "object" && value !== null ? constructors.get(value) : void 0;
|
|
14983
14994
|
}
|
|
14984
|
-
function
|
|
14995
|
+
function getTypedArrayMember(value, property, budget, bindings) {
|
|
14985
14996
|
const key = String(property);
|
|
14986
14997
|
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
14987
14998
|
if (descriptor !== void 0) {
|
|
14988
14999
|
if (!("value" in descriptor)) throw new TypeError("Float32Array accessors are not supported.");
|
|
14989
15000
|
return descriptor.value;
|
|
14990
15001
|
}
|
|
14991
|
-
if (
|
|
14992
|
-
const storage =
|
|
15002
|
+
if (typedArrayPrototypes.has(budget)) return void 0;
|
|
15003
|
+
const storage = typedArrayStorage(value);
|
|
14993
15004
|
if (key === "length") return storage.length;
|
|
14994
|
-
if (key === "byteLength") return storage.length *
|
|
15005
|
+
if (key === "byteLength") return storage.length * storage.elementSize;
|
|
14995
15006
|
if (key === "byteOffset") return storage.byteOffset;
|
|
14996
|
-
if (key === "BYTES_PER_ELEMENT") return
|
|
15007
|
+
if (key === "BYTES_PER_ELEMENT") return storage.elementSize;
|
|
14997
15008
|
if (!["set", "slice", "subarray", "fill", "copyWithin", "reverse", "toReversed", "at", "includes", "indexOf", "lastIndexOf", "forEach", "every", "some", "find", "findIndex", "findLast", "findLastIndex", "sort", "toSorted", "with", "reduce", "reduceRight", "map", "filter", "toLocaleString"].includes(key)) return void 0;
|
|
14998
15009
|
const numberPrototype = key === "toLocaleString" ? getBoxedPrototype(0, budget) : void 0;
|
|
14999
15010
|
return createSandboxClosure({
|
|
@@ -15005,15 +15016,16 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
|
|
|
15005
15016
|
if ((key === "sort" || key === "toSorted") && args[0] !== void 0 && !isSandboxClosure(args[0]))
|
|
15006
15017
|
throw new TypeError("TypedArray sort comparator must be callable.");
|
|
15007
15018
|
const receiver = context?.thisValue;
|
|
15008
|
-
if (!
|
|
15019
|
+
if (!isNumericTypedArray(receiver))
|
|
15009
15020
|
throw new TypeError(`Float32Array#${key} requires a Float32Array receiver.`);
|
|
15010
|
-
const storage2 =
|
|
15021
|
+
const storage2 = typedArrayStorage(receiver, key === "sort" || key === "toSorted" || key === "with" || key === "reduce" || key === "reduceRight" || key === "map" || key === "filter" || key === "slice" || key === "fill" || key === "copyWithin" || key === "reverse" || key === "toReversed" || key === "at" || key === "includes" || key === "indexOf" || key === "lastIndexOf" || key === "forEach" || key === "every" || key === "some" || key === "find" || key === "findIndex" || key === "findLast" || key === "findLastIndex" || key === "toLocaleString");
|
|
15022
|
+
const defaultConstructor = bindings?.[storage2.Native.name];
|
|
15011
15023
|
if (key === "toReversed") {
|
|
15012
15024
|
let result;
|
|
15013
15025
|
const release = retainValues(budget, () => [receiver, result, ...args]);
|
|
15014
15026
|
try {
|
|
15015
|
-
|
|
15016
|
-
result = new
|
|
15027
|
+
checkTypedArrayAllocation(storage2.length, budget, storage2.elementSize);
|
|
15028
|
+
result = new storage2.Native(storage2.length);
|
|
15017
15029
|
createDataCheckpoint(budget, context)(result, 0, true);
|
|
15018
15030
|
for (let index = 0; index < storage2.length; index++) {
|
|
15019
15031
|
budget.visitNode();
|
|
@@ -15027,14 +15039,14 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
|
|
|
15027
15039
|
if (key === "reverse") {
|
|
15028
15040
|
const release = retainValues(budget, () => [receiver, ...args]);
|
|
15029
15041
|
try {
|
|
15030
|
-
const bytes = new Uint8Array(storage2.buffer, storage2.byteOffset, storage2.length *
|
|
15042
|
+
const bytes = new Uint8Array(storage2.buffer, storage2.byteOffset, storage2.length * storage2.elementSize);
|
|
15031
15043
|
for (let lower = 0; lower < Math.floor(storage2.length / 2); lower++) {
|
|
15032
15044
|
const upper = storage2.length - lower - 1;
|
|
15033
|
-
for (let offset = 0; offset <
|
|
15045
|
+
for (let offset = 0; offset < storage2.elementSize; offset++) {
|
|
15034
15046
|
budget.visitNode();
|
|
15035
|
-
const saved = bytes[lower *
|
|
15036
|
-
bytes[lower *
|
|
15037
|
-
bytes[upper *
|
|
15047
|
+
const saved = bytes[lower * storage2.elementSize + offset];
|
|
15048
|
+
bytes[lower * storage2.elementSize + offset] = bytes[upper * storage2.elementSize + offset];
|
|
15049
|
+
bytes[upper * storage2.elementSize + offset] = saved;
|
|
15038
15050
|
}
|
|
15039
15051
|
}
|
|
15040
15052
|
return receiver;
|
|
@@ -15062,16 +15074,16 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
|
|
|
15062
15074
|
const release = retainValues(budget, () => [receiver, items, scratch, comparisonResult, ...args]);
|
|
15063
15075
|
const checkData = createDataCheckpoint(budget, bridge);
|
|
15064
15076
|
try {
|
|
15065
|
-
|
|
15066
|
-
items = new
|
|
15077
|
+
checkTypedArrayAllocation(storage2.length, budget, storage2.elementSize);
|
|
15078
|
+
items = new storage2.Native(storage2.length);
|
|
15067
15079
|
checkData(items, 0, true);
|
|
15068
15080
|
for (let index = 0; index < storage2.length; index++) {
|
|
15069
15081
|
budget.visitNode();
|
|
15070
15082
|
items[index] = receiver[index];
|
|
15071
15083
|
}
|
|
15072
15084
|
if (storage2.length < 2) return items;
|
|
15073
|
-
|
|
15074
|
-
scratch = new
|
|
15085
|
+
checkTypedArrayAllocation(storage2.length, budget, storage2.elementSize);
|
|
15086
|
+
scratch = new storage2.Native(storage2.length);
|
|
15075
15087
|
checkData(scratch, 0, true);
|
|
15076
15088
|
for (let width = 1; width < storage2.length; width *= 2) {
|
|
15077
15089
|
for (let start = 0; start < storage2.length; start += width * 2) {
|
|
@@ -15216,10 +15228,10 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
|
|
|
15216
15228
|
const relative = Number.isNaN(number) ? 0 : Math.trunc(number);
|
|
15217
15229
|
const index = relative < 0 ? storage2.length + relative : relative;
|
|
15218
15230
|
const replacement = await sandboxNumber(args[1], budget, bridge);
|
|
15219
|
-
if (index < 0 || index >=
|
|
15231
|
+
if (index < 0 || index >= typedArrayStorage(receiver).length)
|
|
15220
15232
|
throw new RangeError("Float32Array#with index is out of bounds.");
|
|
15221
|
-
|
|
15222
|
-
result = new
|
|
15233
|
+
checkTypedArrayAllocation(storage2.length, budget, storage2.elementSize);
|
|
15234
|
+
result = new storage2.Native(storage2.length);
|
|
15223
15235
|
createDataCheckpoint(budget, bridge)(result, 0, true);
|
|
15224
15236
|
for (let offset = 0; offset < storage2.length; offset++) {
|
|
15225
15237
|
budget.visitNode();
|
|
@@ -15253,14 +15265,14 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
|
|
|
15253
15265
|
const end = args[2] === void 0 ? storage2.length : relativeIndex(await sandboxNumber(args[2], budget, bridge), storage2.length);
|
|
15254
15266
|
let count = Math.min(end - start, storage2.length - target);
|
|
15255
15267
|
if (count > 0) {
|
|
15256
|
-
const current =
|
|
15268
|
+
const current = typedArrayStorage(receiver, true);
|
|
15257
15269
|
count = Math.min(count, current.length - start, current.length - target);
|
|
15258
15270
|
if (count > 0) {
|
|
15259
|
-
const bytes = new Uint8Array(current.buffer, current.byteOffset, current.length *
|
|
15271
|
+
const bytes = new Uint8Array(current.buffer, current.byteOffset, current.length * storage2.elementSize);
|
|
15260
15272
|
const direction = start < target && target < start + count ? -1 : 1;
|
|
15261
|
-
let from = start *
|
|
15262
|
-
let to = target *
|
|
15263
|
-
for (let remaining = count *
|
|
15273
|
+
let from = start * storage2.elementSize + (direction < 0 ? count * storage2.elementSize - 1 : 0);
|
|
15274
|
+
let to = target * storage2.elementSize + (direction < 0 ? count * storage2.elementSize - 1 : 0);
|
|
15275
|
+
for (let remaining = count * storage2.elementSize; remaining > 0; remaining--) {
|
|
15264
15276
|
budget.visitNode();
|
|
15265
15277
|
bytes[to] = bytes[from];
|
|
15266
15278
|
from += direction;
|
|
@@ -15281,7 +15293,7 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
|
|
|
15281
15293
|
const value2 = await sandboxNumber(args[0], budget, bridge);
|
|
15282
15294
|
const start = relativeIndex(await sandboxNumber(args[1], budget, bridge), storage2.length);
|
|
15283
15295
|
const end = args[2] === void 0 ? storage2.length : relativeIndex(await sandboxNumber(args[2], budget, bridge), storage2.length);
|
|
15284
|
-
const current =
|
|
15296
|
+
const current = typedArrayStorage(receiver, true);
|
|
15285
15297
|
for (let index = start; index < Math.min(end, current.length); index++) {
|
|
15286
15298
|
budget.visitNode();
|
|
15287
15299
|
receiver[index] = value2;
|
|
@@ -15302,10 +15314,10 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
|
|
|
15302
15314
|
const number = await sandboxNumber(offsetValue, budget, bridge);
|
|
15303
15315
|
const offset = Number.isNaN(number) ? 0 : Math.trunc(number);
|
|
15304
15316
|
if (offset < 0) throw new RangeError("Float32Array#set offset is out of bounds.");
|
|
15305
|
-
const targetStorage =
|
|
15317
|
+
const targetStorage = typedArrayStorage(receiver, true);
|
|
15306
15318
|
if (source === null || source === void 0) throw new TypeError("Float32Array#set requires a non-null source.");
|
|
15307
15319
|
let length;
|
|
15308
|
-
if (
|
|
15320
|
+
if (isNumericTypedArray(source)) length = typedArrayStorage(source, true).length;
|
|
15309
15321
|
else {
|
|
15310
15322
|
sourceObject = typeof source === "object" ? source : createSandboxBox(source);
|
|
15311
15323
|
current = await bridge.getProperty(sourceObject, "length");
|
|
@@ -15313,7 +15325,7 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
|
|
|
15313
15325
|
length = Number.isNaN(size) || size <= 0 ? 0 : Math.min(Math.trunc(size), Number.MAX_SAFE_INTEGER);
|
|
15314
15326
|
}
|
|
15315
15327
|
if (offset + length > targetStorage.length) throw new RangeError("Float32Array#set source is out of bounds.");
|
|
15316
|
-
if (
|
|
15328
|
+
if (isNumericTypedArray(source)) Float32Array.prototype.set.call(receiver, source, offset);
|
|
15317
15329
|
else for (let index = 0; index < length; index++) {
|
|
15318
15330
|
budget.visitNode();
|
|
15319
15331
|
current = await bridge.getProperty(sourceObject, String(index));
|
|
@@ -15351,8 +15363,8 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
|
|
|
15351
15363
|
}
|
|
15352
15364
|
length = kept.length;
|
|
15353
15365
|
}
|
|
15354
|
-
const layout =
|
|
15355
|
-
const offset = (layout?.byteOffset ?? storage2.byteOffset) + start *
|
|
15366
|
+
const layout = typedArrayViewLayouts.get(receiver);
|
|
15367
|
+
const offset = (layout?.byteOffset ?? storage2.byteOffset) + start * storage2.elementSize;
|
|
15356
15368
|
const tracking = layout !== void 0 && layout.length === void 0 && args[1] === void 0;
|
|
15357
15369
|
if (defaultConstructor !== void 0) {
|
|
15358
15370
|
candidate = await bridge.getProperty(receiver, "constructor");
|
|
@@ -15367,24 +15379,24 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
|
|
|
15367
15379
|
if (candidate !== void 0 && candidate !== null && candidate !== defaultConstructor) {
|
|
15368
15380
|
const values = key !== "subarray" ? [length] : [storage2.buffer, offset, tracking ? void 0 : length];
|
|
15369
15381
|
result = await invokeBuiltinClosure(candidate, values, budget, bridge, void 0, true);
|
|
15370
|
-
if (!
|
|
15371
|
-
const target =
|
|
15382
|
+
if (!isNumericTypedArray(result)) throw new TypeError("TypedArray species must return typed storage.");
|
|
15383
|
+
const target = typedArrayStorage(result, key !== "subarray");
|
|
15372
15384
|
if (key !== "subarray" && target.length < length)
|
|
15373
15385
|
throw new TypeError("TypedArray species returned insufficient storage.");
|
|
15374
15386
|
}
|
|
15375
15387
|
if (key === "subarray") {
|
|
15376
15388
|
if (result === void 0) {
|
|
15377
|
-
result = new
|
|
15389
|
+
result = new storage2.Native(storage2.buffer, offset, tracking ? void 0 : length);
|
|
15378
15390
|
if (arrayBufferOptions(storage2.buffer) !== void 0)
|
|
15379
|
-
|
|
15391
|
+
typedArrayViewLayouts.set(result, { byteOffset: offset, ...tracking ? {} : { length } });
|
|
15380
15392
|
}
|
|
15381
15393
|
return result;
|
|
15382
15394
|
}
|
|
15383
15395
|
if (result === void 0) {
|
|
15384
|
-
|
|
15385
|
-
result = new
|
|
15396
|
+
checkTypedArrayAllocation(length, budget, storage2.elementSize);
|
|
15397
|
+
result = new storage2.Native(length);
|
|
15386
15398
|
}
|
|
15387
|
-
if (!
|
|
15399
|
+
if (!isNumericTypedArray(result)) throw new TypeError("TypedArray species must return typed storage.");
|
|
15388
15400
|
if (key === "filter") {
|
|
15389
15401
|
for (let index = 0; index < length; index++) {
|
|
15390
15402
|
budget.visitNode();
|
|
@@ -15401,12 +15413,17 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
|
|
|
15401
15413
|
return result;
|
|
15402
15414
|
}
|
|
15403
15415
|
if (length > 0) {
|
|
15404
|
-
const current =
|
|
15405
|
-
const target =
|
|
15416
|
+
const current = typedArrayStorage(receiver, true);
|
|
15417
|
+
const target = typedArrayStorage(result, true);
|
|
15406
15418
|
const count = Math.min(length, Math.max(current.length - start, 0));
|
|
15407
|
-
if (count > 0) {
|
|
15408
|
-
|
|
15409
|
-
|
|
15419
|
+
if (count > 0 && current.Native !== target.Native) {
|
|
15420
|
+
for (let index = 0; index < count; index++) {
|
|
15421
|
+
budget.visitNode();
|
|
15422
|
+
result[index] = receiver[start + index];
|
|
15423
|
+
}
|
|
15424
|
+
} else if (count > 0) {
|
|
15425
|
+
const sourceBytes = new Uint8Array(current.buffer, current.byteOffset + start * storage2.elementSize, count * storage2.elementSize);
|
|
15426
|
+
const targetBytes = new Uint8Array(target.buffer, target.byteOffset, count * storage2.elementSize);
|
|
15410
15427
|
if (current.buffer === target.buffer && targetBytes.byteOffset > sourceBytes.byteOffset && targetBytes.byteOffset < sourceBytes.byteOffset + sourceBytes.length) {
|
|
15411
15428
|
for (let index = 0; index < sourceBytes.length; index++) {
|
|
15412
15429
|
budget.visitNode();
|
|
@@ -15423,9 +15440,9 @@ function getFloat32Member(value, property, budget, defaultConstructor) {
|
|
|
15423
15440
|
}
|
|
15424
15441
|
});
|
|
15425
15442
|
}
|
|
15426
|
-
function
|
|
15443
|
+
function setTypedArrayMember(value, property, entry, budget, context) {
|
|
15427
15444
|
const key = typeof property === "symbol" ? property : String(property);
|
|
15428
|
-
if (typeof key !== "symbol" &&
|
|
15445
|
+
if (typeof key !== "symbol" && isTypedArrayIndex(key)) {
|
|
15429
15446
|
return (async () => {
|
|
15430
15447
|
const release = retainValues(budget, () => [value, entry]);
|
|
15431
15448
|
try {
|
|
@@ -15438,7 +15455,7 @@ function setFloat32Member(value, property, entry, budget, context) {
|
|
|
15438
15455
|
}
|
|
15439
15456
|
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
15440
15457
|
const inherited = descriptor ?? getSandboxPropertyDescriptor(value, key, budget);
|
|
15441
|
-
if (descriptor === void 0 && typeof key === "string" && !
|
|
15458
|
+
if (descriptor === void 0 && typeof key === "string" && !typedArrayPrototypes.has(budget) && ["length", "byteLength", "byteOffset", "buffer", "BYTES_PER_ELEMENT"].includes(key))
|
|
15442
15459
|
throw new TypeError(`Cannot assign to read only property '${String(key)}'.`);
|
|
15443
15460
|
if (inherited !== void 0 && (!("value" in inherited) || !inherited.writable))
|
|
15444
15461
|
throw new TypeError(`Cannot assign to read only property '${String(key)}'.`);
|
|
@@ -15611,7 +15628,8 @@ async function ordinaryHasInstance(value, constructor, budget, context) {
|
|
|
15611
15628
|
budget.visitNode();
|
|
15612
15629
|
return evaluateInstanceof(value, constructor.boundTarget, budget, context);
|
|
15613
15630
|
}
|
|
15614
|
-
if (
|
|
15631
|
+
if (numericTypedArrayConstructor(constructor) !== void 0 && !isGuestClosure(constructor))
|
|
15632
|
+
return isNumericTypedArray(value) && typedArrayStorage(value).Native === numericTypedArrayConstructor(constructor);
|
|
15615
15633
|
if ((!isGuestClosure(constructor) || value !== null && typeof value === "object" && !hasExplicitSandboxPrototype(value)) && isSandboxErrorConstructorInstance2(value, constructor)) return true;
|
|
15616
15634
|
if (!isGuestClosure(constructor) || typeof value !== "object" || value === null) return false;
|
|
15617
15635
|
const prototype = await readInstanceProperty(constructor, "prototype", budget, context);
|
|
@@ -17365,7 +17383,7 @@ function forInObject(value) {
|
|
|
17365
17383
|
if (value === null || value === void 0 || isSandboxClosure(value)) {
|
|
17366
17384
|
return void 0;
|
|
17367
17385
|
}
|
|
17368
|
-
if (typeof value === "string" || Array.isArray(value) ||
|
|
17386
|
+
if (typeof value === "string" || Array.isArray(value) || isNumericTypedArray(value) || isPlainForInObject(value)) {
|
|
17369
17387
|
return Object(value);
|
|
17370
17388
|
}
|
|
17371
17389
|
return void 0;
|
|
@@ -17944,7 +17962,7 @@ function getPropertyValue(target, property, context, receiver = target) {
|
|
|
17944
17962
|
if (typeof target === "string") return getStringMember(target, property, context.budget);
|
|
17945
17963
|
if (typeof target === "number") return getNumberMember(property, context.budget);
|
|
17946
17964
|
if (typeof target === "boolean") return void 0;
|
|
17947
|
-
if (
|
|
17965
|
+
if (isNumericTypedArray(target)) return getTypedArrayMember(target, property, context.budget);
|
|
17948
17966
|
if (isSandboxDate(target)) return void 0;
|
|
17949
17967
|
if (isSandboxMap(target)) return getSandboxPrototype(target, context.budget) === null ? getMapMember(target, property, createMapMethodOptions(context)) : void 0;
|
|
17950
17968
|
if (isSandboxSet(target)) return getSandboxPrototype(target, context.budget) === null ? getSetMember(target, property, createSetMethodOptions(context)) : void 0;
|
|
@@ -18248,7 +18266,7 @@ async function evaluateMemberCallExpression(node, context) {
|
|
|
18248
18266
|
if (isSandboxDate(member.object)) {
|
|
18249
18267
|
return evaluateResolvedCallExpression(node, await getPropertyValue(member.object, member.property, context), context, member.object);
|
|
18250
18268
|
}
|
|
18251
|
-
if (
|
|
18269
|
+
if (isNumericTypedArray(member.object)) {
|
|
18252
18270
|
return evaluateResolvedCallExpression(
|
|
18253
18271
|
node,
|
|
18254
18272
|
await getPropertyValue(member.object, member.property, context),
|
|
@@ -18539,7 +18557,7 @@ function hasSandboxProperty(value, key, context) {
|
|
|
18539
18557
|
while (typeof current === "object" && current !== null) {
|
|
18540
18558
|
if (isGuestHostObject(current)) return typeof key === "symbol" ? false : hasHostObjectMember(current, String(key));
|
|
18541
18559
|
if (hasOwnSandboxProperty(current, key, false)) return true;
|
|
18542
|
-
if (!isSandboxDate(current) && !isSandboxRegex(current) && !isSandboxMap(current) && !isSandboxSet(current) && !((isGuestClosure(current) || isSandboxGenerator(current) || Array.isArray(current)) && hasExplicitSandboxPrototype(current)) && (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) ||
|
|
18560
|
+
if (!isSandboxDate(current) && !isSandboxRegex(current) && !isSandboxMap(current) && !isSandboxSet(current) && !((isGuestClosure(current) || isSandboxGenerator(current) || Array.isArray(current)) && hasExplicitSandboxPrototype(current)) && (Array.isArray(current) || !isPlainSandboxObject(current) || isSandboxDate(current) || isNumericTypedArray(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current) || isSandboxRegExpIterator(current))) {
|
|
18543
18561
|
return getPropertyValue(current, key, context) !== void 0;
|
|
18544
18562
|
}
|
|
18545
18563
|
current = getSandboxPrototype(current, context.budget);
|
|
@@ -18751,7 +18769,7 @@ function getMemberValue(target, property, context) {
|
|
|
18751
18769
|
while (typeof current === "object" && current !== null) {
|
|
18752
18770
|
if (isSandboxClosure(current)) return getClosureMemberValue(current, property, context);
|
|
18753
18771
|
if (Array.isArray(current)) return getArrayMemberValue(current, property, context);
|
|
18754
|
-
if (!isPlainSandboxObject(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current) || isSandboxRegExpIterator(current) ||
|
|
18772
|
+
if (!isPlainSandboxObject(current) || isSandboxGenerator(current) || isSandboxCollectionIterator(current) || isSandboxRegExpIterator(current) || isNumericTypedArray(current)) {
|
|
18755
18773
|
return getPropertyValue(current, property, context);
|
|
18756
18774
|
}
|
|
18757
18775
|
if (Object.hasOwn(current, String(property))) return current[String(property)];
|
|
@@ -18787,8 +18805,8 @@ function setSandboxProperty(target, property, value, budget, checkInherited = tr
|
|
|
18787
18805
|
if (isSandboxPromise(target)) target = getPromiseProperties(target);
|
|
18788
18806
|
if (isSandboxGenerator(target)) target = getGeneratorProperties(target);
|
|
18789
18807
|
if (isSandboxMap(target) || isSandboxSet(target)) target = getCollectionProperties(target);
|
|
18790
|
-
if (
|
|
18791
|
-
return
|
|
18808
|
+
if (isNumericTypedArray(target)) {
|
|
18809
|
+
return setTypedArrayMember(target, property, value, budget, context);
|
|
18792
18810
|
}
|
|
18793
18811
|
if (isSandboxRegex(target)) {
|
|
18794
18812
|
setRegexMember(target, property, value, budget);
|
|
@@ -19421,7 +19439,7 @@ async function objectToPrimitive(value, budget, context, joining, hint, ordinary
|
|
|
19421
19439
|
}
|
|
19422
19440
|
}
|
|
19423
19441
|
function conversionHook(value, name, budget, context) {
|
|
19424
|
-
const implicitBuiltin = !hasExplicitSandboxPrototype(value) && (Array.isArray(value) && getSandboxPrototype(value, budget) === null ||
|
|
19442
|
+
const implicitBuiltin = !hasExplicitSandboxPrototype(value) && (Array.isArray(value) && getSandboxPrototype(value, budget) === null || isNumericTypedArray(value) || sandboxErrorTypes.has(value) || isSandboxClosure(value) && getSandboxPrototype(value, budget) === null || isSandboxMap(value) || isSandboxSet(value) || isSandboxCollectionIterator(value) || isSandboxRegExpIterator(value) || isSandboxPromise(value) || isSandboxRegex(value) && getSandboxPrototype(value, budget) === null || isSandboxGenerator(value) || isGuestHostObject(value));
|
|
19425
19443
|
let current = value;
|
|
19426
19444
|
let depth = 0;
|
|
19427
19445
|
while (current !== null) {
|
|
@@ -19454,14 +19472,14 @@ async function defaultToString(value, budget, context, joining) {
|
|
|
19454
19472
|
if (isSandboxGenerator(value)) return "[object Generator]";
|
|
19455
19473
|
if (isSandboxRegex(value)) return regexToString(value, budget, context);
|
|
19456
19474
|
if (isSandboxDate(value)) return budget.allocateString(dateString(value));
|
|
19457
|
-
if (Array.isArray(value) ||
|
|
19475
|
+
if (Array.isArray(value) || isNumericTypedArray(value)) {
|
|
19458
19476
|
if (Object.hasOwn(value, "join")) {
|
|
19459
19477
|
const join = await readCoercionProperty(value, "join", context);
|
|
19460
19478
|
if (!isSandboxClosure(join))
|
|
19461
|
-
return
|
|
19479
|
+
return isNumericTypedArray(value) ? `[object ${typedArrayStorage(value).Native.name}]` : "[object Array]";
|
|
19462
19480
|
return invokeBuiltinClosure(join, [], budget, context, value);
|
|
19463
19481
|
}
|
|
19464
|
-
const length =
|
|
19482
|
+
const length = isNumericTypedArray(value) ? typedArrayStorage(value).length : value.length;
|
|
19465
19483
|
return joinSandboxArray(value, length, ",", budget, context, joining);
|
|
19466
19484
|
}
|
|
19467
19485
|
if (sandboxErrorTypes.has(value)) {
|
|
@@ -19668,7 +19686,7 @@ function typeTag(value, builtinOnly = false) {
|
|
|
19668
19686
|
if (isSandboxCollectionIterator(value)) return collectionIteratorState(value).collectionKind === "map" ? "Map Iterator" : "Set Iterator";
|
|
19669
19687
|
if (isSandboxPromise(value)) return "Promise";
|
|
19670
19688
|
if (isSandboxGenerator(value)) return "Generator";
|
|
19671
|
-
if (
|
|
19689
|
+
if (isNumericTypedArray(value)) return typedArrayStorage(value).Native.name;
|
|
19672
19690
|
return "Object";
|
|
19673
19691
|
}
|
|
19674
19692
|
|
|
@@ -21534,33 +21552,36 @@ function serializeArray(value, serializeValue) {
|
|
|
21534
21552
|
return { kind: "array", length: value.length, entries };
|
|
21535
21553
|
}
|
|
21536
21554
|
|
|
21537
|
-
// packages/safe-js/src/snapshot/
|
|
21538
|
-
function
|
|
21539
|
-
const storage =
|
|
21540
|
-
|
|
21541
|
-
if (
|
|
21542
|
-
|
|
21555
|
+
// packages/safe-js/src/snapshot/typed-array.ts
|
|
21556
|
+
function encodeTypedArrayLayout(value) {
|
|
21557
|
+
const storage = typedArrayStorage(value);
|
|
21558
|
+
const identity = storage.Native === Float32Array ? { kind: "float32array" } : { kind: "typedarray", arrayType: storage.Native.name };
|
|
21559
|
+
if (arrayBufferDetached(storage.buffer)) return { ...identity, byteOffset: 0, length: 0 };
|
|
21560
|
+
if (arrayBufferOptions(storage.buffer) === void 0) return { ...identity, byteOffset: storage.byteOffset, length: storage.length };
|
|
21561
|
+
const layout = typedArrayViewLayouts.get(value);
|
|
21543
21562
|
if (layout === void 0) throw new TypeError("Resizable Float32Array snapshots require known view layout.");
|
|
21544
21563
|
return {
|
|
21564
|
+
...identity,
|
|
21545
21565
|
byteOffset: layout.byteOffset,
|
|
21546
21566
|
length: layout.length ?? 0,
|
|
21547
21567
|
...layout.length === void 0 ? { lengthTracking: true } : {}
|
|
21548
21568
|
};
|
|
21549
21569
|
}
|
|
21550
|
-
function
|
|
21570
|
+
function validateTypedArrayStorage(value) {
|
|
21571
|
+
const Native = snapshotTypedArrayConstructor(value);
|
|
21551
21572
|
if (Object.hasOwn(value, "lengthTracking") && (value.lengthTracking !== true || value.length !== 0 || Object.hasOwn(value, "bytes")))
|
|
21552
21573
|
throw new TypeError("Invalid Float32Array length-tracking layout.");
|
|
21553
|
-
if (!Number.isSafeInteger(value.length) || Number(value.length) < 0 || !Number.isSafeInteger(value.byteOffset) || Number(value.byteOffset) < 0 || Number(value.byteOffset) %
|
|
21574
|
+
if (!Number.isSafeInteger(value.length) || Number(value.length) < 0 || !Number.isSafeInteger(value.byteOffset) || Number(value.byteOffset) < 0 || Number(value.byteOffset) % Native.BYTES_PER_ELEMENT !== 0)
|
|
21554
21575
|
throw new TypeError("Invalid Float32Array view dimensions.");
|
|
21555
21576
|
if (Object.hasOwn(value, "bytes") === Object.hasOwn(value, "buffer"))
|
|
21556
21577
|
throw new TypeError("Float32Array requires one backing storage description.");
|
|
21557
21578
|
if (Object.hasOwn(value, "bytes")) {
|
|
21558
|
-
if (!Array.isArray(value.bytes) || value.bytes.some((byte) => !Number.isInteger(byte) || byte < 0 || byte > 255) || Number(value.length) > Math.floor((value.bytes.length - Number(value.byteOffset)) /
|
|
21579
|
+
if (!Array.isArray(value.bytes) || value.bytes.some((byte) => !Number.isInteger(byte) || byte < 0 || byte > 255) || Number(value.length) > Math.floor((value.bytes.length - Number(value.byteOffset)) / Native.BYTES_PER_ELEMENT))
|
|
21559
21580
|
throw new TypeError("Invalid Float32Array backing bytes.");
|
|
21560
21581
|
}
|
|
21561
21582
|
}
|
|
21562
|
-
function
|
|
21563
|
-
|
|
21583
|
+
function decodeTypedArrayStorage(value, resolve, budget) {
|
|
21584
|
+
validateTypedArrayStorage(value);
|
|
21564
21585
|
let buffer;
|
|
21565
21586
|
if (Array.isArray(value.bytes)) {
|
|
21566
21587
|
buffer = new ArrayBuffer(value.bytes.length);
|
|
@@ -21568,12 +21589,21 @@ function decodeFloat32Storage(value, resolve, budget) {
|
|
|
21568
21589
|
} else {
|
|
21569
21590
|
const referenced = resolve(value.buffer);
|
|
21570
21591
|
if (isSandboxArrayBuffer(referenced)) buffer = referenced;
|
|
21571
|
-
else if (
|
|
21592
|
+
else if (isNumericTypedArray(referenced)) buffer = typedArrayStorage(referenced).buffer;
|
|
21572
21593
|
else throw new TypeError("Invalid Float32Array backing reference.");
|
|
21573
21594
|
}
|
|
21574
21595
|
if (value.lengthTracking === true && arrayBufferOptions(buffer) === void 0)
|
|
21575
21596
|
throw new TypeError("Length-tracking layout requires resizable backing storage.");
|
|
21576
|
-
return
|
|
21597
|
+
return restoreTypedArrayView(buffer, Number(value.byteOffset), value.lengthTracking === true ? void 0 : Number(value.length), budget, snapshotTypedArrayConstructor(value));
|
|
21598
|
+
}
|
|
21599
|
+
function snapshotTypedArrayConstructor(value) {
|
|
21600
|
+
if (value.kind !== "typedarray") {
|
|
21601
|
+
if (Object.hasOwn(value, "arrayType")) throw new TypeError("Legacy Float32Array storage cannot specify another array type.");
|
|
21602
|
+
return Float32Array;
|
|
21603
|
+
}
|
|
21604
|
+
if (typeof value.arrayType !== "string" || !Object.hasOwn(numericTypedArrayConstructors, value.arrayType))
|
|
21605
|
+
throw new TypeError("Invalid typed array storage type.");
|
|
21606
|
+
return numericTypedArrayConstructors[value.arrayType];
|
|
21577
21607
|
}
|
|
21578
21608
|
|
|
21579
21609
|
// packages/safe-js/src/snapshot/array-buffer.ts
|
|
@@ -21628,7 +21658,7 @@ function decodeArrayBufferStorage(value, resolve, budget, deferredDetachment) {
|
|
|
21628
21658
|
}
|
|
21629
21659
|
const referenced = resolve(value.buffer);
|
|
21630
21660
|
if (isSandboxArrayBuffer(referenced)) return referenced;
|
|
21631
|
-
if (
|
|
21661
|
+
if (isNumericTypedArray(referenced)) return typedArrayStorage(referenced).buffer;
|
|
21632
21662
|
throw new TypeError("Invalid ArrayBuffer backing reference.");
|
|
21633
21663
|
}
|
|
21634
21664
|
|
|
@@ -21760,7 +21790,7 @@ function serializeDumpValue(value, path, state) {
|
|
|
21760
21790
|
if (hasGuestObjectState(value) && !(state.trustedRunReplay && (isSandboxDate(value) || isSandboxPromise(value) || isPromiseResolvingFunction(value)))) {
|
|
21761
21791
|
throw new TypeError("Guest function properties and prototype links cannot be serialized.");
|
|
21762
21792
|
}
|
|
21763
|
-
if (isSandboxArrayBuffer(value) || isSandboxRegExpIterator(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxBox(value) || isSandboxDate(value) ||
|
|
21793
|
+
if (isSandboxArrayBuffer(value) || isSandboxRegExpIterator(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxBox(value) || isSandboxDate(value) || isNumericTypedArray(value)) return serializeHeapReference(value, path, state);
|
|
21764
21794
|
if (Array.isArray(value)) {
|
|
21765
21795
|
const reference2 = serializeHeapReference(value, path, state);
|
|
21766
21796
|
if (reference2 !== void 0) {
|
|
@@ -21840,16 +21870,15 @@ function serializeHeapReference(value, path, state) {
|
|
|
21840
21870
|
return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
|
|
21841
21871
|
})
|
|
21842
21872
|
};
|
|
21843
|
-
} else if (
|
|
21844
|
-
const backing =
|
|
21873
|
+
} else if (isNumericTypedArray(value)) {
|
|
21874
|
+
const backing = typedArrayStorage(value);
|
|
21845
21875
|
const storage = {
|
|
21846
|
-
|
|
21847
|
-
...encodeFloat32Layout(value),
|
|
21876
|
+
...encodeTypedArrayLayout(value),
|
|
21848
21877
|
buffer: serializeHeapReference(backing.buffer, `${path}.buffer`, state)
|
|
21849
21878
|
};
|
|
21850
21879
|
const entries = /* @__PURE__ */ Object.create(null);
|
|
21851
21880
|
state.heap[String(id)] = { ...storage, entries };
|
|
21852
|
-
for (const [key, descriptor] of
|
|
21881
|
+
for (const [key, descriptor] of typedArrayDataProperties(value)) {
|
|
21853
21882
|
const serialized = serializeDumpValue(descriptor.value, `${path}.${key}`, state);
|
|
21854
21883
|
entries[key] = serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
|
|
21855
21884
|
}
|
|
@@ -21912,7 +21941,7 @@ function indexHeapContainers(snapshot) {
|
|
|
21912
21941
|
const heapIds = /* @__PURE__ */ new Map();
|
|
21913
21942
|
let nextId = 1;
|
|
21914
21943
|
for (const [value, stat2] of stats.entries()) {
|
|
21915
|
-
if (stat2.count > 1 || stat2.forceHeap === true || guestValues.has(value) || stat2.cyclic || hasNullObjectPrototype(value) || ownSerializableSymbolKeys(value).length > 0 || isSandboxBox(value) || isSandboxRegExpIterator(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxDate(value) ||
|
|
21944
|
+
if (stat2.count > 1 || stat2.forceHeap === true || guestValues.has(value) || stat2.cyclic || hasNullObjectPrototype(value) || ownSerializableSymbolKeys(value).length > 0 || isSandboxBox(value) || isSandboxRegExpIterator(value) || isSandboxRegex(value) && hasCustomRegexProperties(value) || isSandboxDate(value) || isNumericTypedArray(value) || isSandboxArrayBuffer(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
21916
21945
|
heapIds.set(value, nextId);
|
|
21917
21946
|
nextId += 1;
|
|
21918
21947
|
}
|
|
@@ -21944,7 +21973,7 @@ function collectContainerStats(value, stats, ancestors, guestValues, depth = 0)
|
|
|
21944
21973
|
stat2.expanded = true;
|
|
21945
21974
|
ancestors.add(value);
|
|
21946
21975
|
const guestEntries = [];
|
|
21947
|
-
if (
|
|
21976
|
+
if (isNumericTypedArray(value)) guestEntries.push(typedArrayStorage(value).buffer);
|
|
21948
21977
|
const guest = isSandboxArrayBuffer(value) ? { kind: "arraybuffer", state: captureArrayBufferState(value, (entry) => {
|
|
21949
21978
|
guestEntries.push(entry);
|
|
21950
21979
|
return null;
|
|
@@ -21962,7 +21991,7 @@ function collectContainerStats(value, stats, ancestors, guestValues, depth = 0)
|
|
|
21962
21991
|
return;
|
|
21963
21992
|
}
|
|
21964
21993
|
for (const entry of guestEntries) collectContainerStats(entry, stats, ancestors, guestValues, depth + 1);
|
|
21965
|
-
if (!Array.isArray(value) && !isPlainObject(value) && !
|
|
21994
|
+
if (!Array.isArray(value) && !isPlainObject(value) && !isNumericTypedArray(value) && !isSandboxDate(value)) {
|
|
21966
21995
|
ancestors.delete(value);
|
|
21967
21996
|
return;
|
|
21968
21997
|
}
|
|
@@ -22296,11 +22325,11 @@ function encodeReplayData(value, options = {}) {
|
|
|
22296
22325
|
let symbolIndex = 0;
|
|
22297
22326
|
const symbolEntries = serializeSymbolProperties(entry, (value2) => encode(value2, depth + 1, [...path, { symbol: Math.floor(symbolIndex++ / 2) }]));
|
|
22298
22327
|
nodes[id] = { ...storage, properties, extensible: Object.isExtensible(entry), symbolEntries };
|
|
22299
|
-
} else if (
|
|
22300
|
-
const backing =
|
|
22301
|
-
const storage = {
|
|
22328
|
+
} else if (isNumericTypedArray(entry)) {
|
|
22329
|
+
const backing = typedArrayStorage(entry);
|
|
22330
|
+
const storage = { ...encodeTypedArrayLayout(entry), buffer: child(backing.buffer, "<buffer>") };
|
|
22302
22331
|
const properties = /* @__PURE__ */ Object.create(null);
|
|
22303
|
-
for (const [key, descriptor] of
|
|
22332
|
+
for (const [key, descriptor] of typedArrayDataProperties(entry)) {
|
|
22304
22333
|
properties[key] = {
|
|
22305
22334
|
value: child(descriptor.value, key),
|
|
22306
22335
|
configurable: descriptor.configurable === true,
|
|
@@ -22537,10 +22566,10 @@ function decodeReplayData(input, options = {}, parent) {
|
|
|
22537
22566
|
});
|
|
22538
22567
|
return result3;
|
|
22539
22568
|
}
|
|
22540
|
-
if (kind === "float32array") {
|
|
22569
|
+
if (kind === "float32array" || kind === "typedarray") {
|
|
22541
22570
|
if (typeof node.extensible !== "boolean")
|
|
22542
22571
|
throw new TypeError("Invalid Float32Array extensibility.");
|
|
22543
|
-
const result3 =
|
|
22572
|
+
const result3 = decodeTypedArrayStorage(node, child, compilation.owner?.budget);
|
|
22544
22573
|
restored.set(id, result3);
|
|
22545
22574
|
defineProperties(result3, record2(own(node, "properties")), child);
|
|
22546
22575
|
if (!node.extensible) Object.preventExtensions(result3);
|
|
@@ -23451,22 +23480,23 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
|
|
|
23451
23480
|
if (!Object.isExtensible(value)) Object.preventExtensions(copy);
|
|
23452
23481
|
return copy;
|
|
23453
23482
|
}
|
|
23454
|
-
if (
|
|
23483
|
+
if (isNumericTypedArray(value)) {
|
|
23455
23484
|
const existing = state.seen.get(value);
|
|
23456
23485
|
if (existing !== void 0) return existing;
|
|
23457
|
-
const capacity = arrayBufferOptions(
|
|
23486
|
+
const capacity = arrayBufferOptions(typedArrayStorage(value).buffer)?.maxByteLength;
|
|
23458
23487
|
if (capacity !== void 0) budget.allocateArrayLength(capacity);
|
|
23459
|
-
|
|
23460
|
-
|
|
23488
|
+
const storage = typedArrayStorage(value);
|
|
23489
|
+
checkTypedArrayAllocation(Math.ceil(storage.byteLength / storage.elementSize), budget, storage.elementSize);
|
|
23490
|
+
const copy = copyTypedArrayStorage(value, state);
|
|
23461
23491
|
state.seen.set(value, copy);
|
|
23462
23492
|
copyHostValueToSandbox(
|
|
23463
|
-
|
|
23493
|
+
typedArrayStorage(value).buffer,
|
|
23464
23494
|
stackFrames,
|
|
23465
23495
|
{ ...options, capabilityPath: [...options.capabilityPath ?? [], "buffer"] },
|
|
23466
23496
|
state,
|
|
23467
23497
|
`${path}.buffer`
|
|
23468
23498
|
);
|
|
23469
|
-
for (const [key, descriptor] of
|
|
23499
|
+
for (const [key, descriptor] of typedArrayDataProperties(value)) {
|
|
23470
23500
|
Object.defineProperty(copy, key, {
|
|
23471
23501
|
...descriptor,
|
|
23472
23502
|
value: copyHostValueToSandbox(
|
|
@@ -25741,7 +25771,7 @@ function createBuiltinBindings(options) {
|
|
|
25741
25771
|
const bindings = {
|
|
25742
25772
|
...createConsoleJsonGlobals(options),
|
|
25743
25773
|
...createCollectionGlobals(options),
|
|
25744
|
-
|
|
25774
|
+
...Object.fromEntries(Object.entries(numericTypedArrayConstructors).map(([name, Native]) => [name, createNumericTypedArrayGlobal(options.budget, options.typedArrayPrototypes !== false, Native)])),
|
|
25745
25775
|
Date: createDateGlobal(options),
|
|
25746
25776
|
Symbol: createSymbolGlobal(options.budget),
|
|
25747
25777
|
BigInt: createBigIntGlobal(options.budget),
|
|
@@ -25755,7 +25785,7 @@ function createBuiltinBindings(options) {
|
|
|
25755
25785
|
...createRegexGlobals(options)
|
|
25756
25786
|
};
|
|
25757
25787
|
createFunctionPrototype(options.budget, options.functionHasInstance);
|
|
25758
|
-
if (options.
|
|
25788
|
+
if (options.typedArrayPrototypes !== false) createNumericTypedArrayPrototypes(options.budget, bindings);
|
|
25759
25789
|
if (options.errorPrototypes !== false) createErrorPrototypes(options.budget, bindings);
|
|
25760
25790
|
createGeneratorPrototypes(options.budget);
|
|
25761
25791
|
registerBuiltinIdentities(options.budget, bindings);
|
|
@@ -26490,8 +26520,8 @@ function validateDumpHeap(root, state) {
|
|
|
26490
26520
|
validateGuestHeapNode({ kind: "guest-object", state: entry.state }, heap, state.limits.maxEntries);
|
|
26491
26521
|
continue;
|
|
26492
26522
|
}
|
|
26493
|
-
if (entry.kind === "float32array") {
|
|
26494
|
-
|
|
26523
|
+
if (entry.kind === "float32array" || entry.kind === "typedarray") {
|
|
26524
|
+
validateTypedArrayStorage(entry);
|
|
26495
26525
|
requireRecord(entry.entries, `${path}.entries`);
|
|
26496
26526
|
if (Object.hasOwn(entry, "state")) {
|
|
26497
26527
|
if (Object.keys(entry.entries).length !== 0) fail("invalidValue", path, "ambiguous Float32Array property state");
|
|
@@ -26713,7 +26743,7 @@ function validateHeapValue(value, path, state, heap) {
|
|
|
26713
26743
|
fail("invalidValue", path, String(error));
|
|
26714
26744
|
}
|
|
26715
26745
|
validateErrorType(record4, path);
|
|
26716
|
-
if (!["symbol", "arguments", "array", "object", "map", "set", "float32array", "arraybuffer", "date", "boxed", "collection-iterator", "regexp-iterator", "regex-object"].includes(String(record4.kind)))
|
|
26746
|
+
if (!["symbol", "arguments", "array", "object", "map", "set", "float32array", "typedarray", "arraybuffer", "date", "boxed", "collection-iterator", "regexp-iterator", "regex-object"].includes(String(record4.kind)))
|
|
26717
26747
|
fail("unknownTag", `${path}.kind`, "unknown heap tag");
|
|
26718
26748
|
validateValue(record4, path, 1, state);
|
|
26719
26749
|
if (record4.kind === "symbol") validateSymbolRecord(record4, path, state);
|
|
@@ -26726,8 +26756,8 @@ function validateHeapValue(value, path, state, heap) {
|
|
|
26726
26756
|
validateArrayBufferStorage(record4);
|
|
26727
26757
|
validateGuestHeapNode({ kind: "guest-object", state: record4.state }, heap, state.limits.maxEntries);
|
|
26728
26758
|
}
|
|
26729
|
-
if (record4.kind === "float32array") {
|
|
26730
|
-
|
|
26759
|
+
if (record4.kind === "float32array" || record4.kind === "typedarray") {
|
|
26760
|
+
validateTypedArrayStorage(record4);
|
|
26731
26761
|
requireRecord(record4.entries, `${path}.entries`);
|
|
26732
26762
|
if (Object.hasOwn(record4, "state")) {
|
|
26733
26763
|
if (Object.keys(record4.entries).length !== 0) fail("invalidValue", path, "ambiguous Float32Array property state");
|
|
@@ -27722,10 +27752,10 @@ function measureSandboxData(values, options = {}) {
|
|
|
27722
27752
|
const prototype = getSandboxPrototype(value);
|
|
27723
27753
|
if (prototype !== null) visit(prototype, depth + 1);
|
|
27724
27754
|
if (isSandboxArrayBuffer(value)) usage += arrayBufferLength(value);
|
|
27725
|
-
if (
|
|
27726
|
-
const storage =
|
|
27755
|
+
if (isNumericTypedArray(value)) {
|
|
27756
|
+
const storage = typedArrayStorage(value);
|
|
27727
27757
|
visit(storage.buffer, depth + 1);
|
|
27728
|
-
for (const [key, descriptor] of
|
|
27758
|
+
for (const [key, descriptor] of typedArrayProperties(value)) {
|
|
27729
27759
|
usage += 1;
|
|
27730
27760
|
if (typeof key === "string") usage += key.length;
|
|
27731
27761
|
else visit(key, depth + 1);
|
|
@@ -27879,7 +27909,7 @@ function reconcileCompiledValues(budget, values, compilation, parent, escaping =
|
|
|
27879
27909
|
const included = /* @__PURE__ */ new Set();
|
|
27880
27910
|
const usage = measureSandboxData([...values, ...budget.retainedValues()], { compileTickets: included });
|
|
27881
27911
|
const kept = /* @__PURE__ */ new Set();
|
|
27882
|
-
if (parent !== void 0) measureSandboxData(escaping, { compileTickets: kept });
|
|
27912
|
+
if (parent !== void 0 && included.size > 0) measureSandboxData(escaping, { compileTickets: kept });
|
|
27883
27913
|
const transferred = /* @__PURE__ */ new Set();
|
|
27884
27914
|
for (const ticket of included) {
|
|
27885
27915
|
if (!kept.has(ticket)) {
|
|
@@ -27995,7 +28025,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
27995
28025
|
}
|
|
27996
28026
|
return copy;
|
|
27997
28027
|
}
|
|
27998
|
-
if (typeof value === "object" && value !== null && hasGuestObjectState(value) && !(state.structuredClone && isSandboxDate(value))) {
|
|
28028
|
+
if (typeof value === "object" && value !== null && hasGuestObjectState(value) && !(state.structuredClone && (isSandboxDate(value) || isSandboxArrayBuffer(value) || isNumericTypedArray(value)))) {
|
|
27999
28029
|
throw new TypeError("Guest prototype links and custom descriptors cannot be copied as data.");
|
|
28000
28030
|
}
|
|
28001
28031
|
const primitive = nativeBoxedValue(value);
|
|
@@ -28064,6 +28094,7 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
28064
28094
|
if (existing !== void 0) return existing;
|
|
28065
28095
|
const copy = copyArrayBufferStorage(value, state);
|
|
28066
28096
|
state.seen.set(value, copy);
|
|
28097
|
+
if (state.structuredClone) return copy;
|
|
28067
28098
|
for (const [key, descriptor] of arrayBufferDataProperties(value)) {
|
|
28068
28099
|
Object.defineProperty(copy, key, {
|
|
28069
28100
|
...descriptor,
|
|
@@ -28086,13 +28117,14 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
28086
28117
|
if (!state.structuredClone && !Object.isExtensible(value)) Object.preventExtensions(copy);
|
|
28087
28118
|
return copy;
|
|
28088
28119
|
}
|
|
28089
|
-
if (
|
|
28120
|
+
if (isNumericTypedArray(value)) {
|
|
28090
28121
|
const existing = state.seen.get(value);
|
|
28091
28122
|
if (existing !== void 0) return existing;
|
|
28092
|
-
const copy =
|
|
28123
|
+
const copy = copyTypedArrayStorage(value, state);
|
|
28093
28124
|
state.seen.set(value, copy);
|
|
28094
|
-
|
|
28095
|
-
|
|
28125
|
+
if (state.structuredClone) return copy;
|
|
28126
|
+
copyToSandbox(typedArrayStorage(value).buffer, state, `${path}.buffer`, cloneSandboxCollections, depth + 1);
|
|
28127
|
+
for (const [key, descriptor] of typedArrayDataProperties(value)) {
|
|
28096
28128
|
Object.defineProperty(copy, key, {
|
|
28097
28129
|
...descriptor,
|
|
28098
28130
|
value: copyToSandbox(
|
|
@@ -28308,13 +28340,13 @@ function copyFromSandbox(value, state, path = "<root>", options, depth = 0) {
|
|
|
28308
28340
|
guard.close();
|
|
28309
28341
|
}
|
|
28310
28342
|
}
|
|
28311
|
-
if (
|
|
28343
|
+
if (isNumericTypedArray(value)) {
|
|
28312
28344
|
const existing = state.seen.get(value);
|
|
28313
28345
|
if (existing !== void 0) return existing;
|
|
28314
|
-
const copy =
|
|
28346
|
+
const copy = copyTypedArrayStorage(value, state);
|
|
28315
28347
|
state.seen.set(value, copy);
|
|
28316
|
-
copyFromSandbox(
|
|
28317
|
-
for (const [key, descriptor] of
|
|
28348
|
+
copyFromSandbox(typedArrayStorage(value).buffer, state, `${path}.buffer`, options, depth + 1);
|
|
28349
|
+
for (const [key, descriptor] of typedArrayDataProperties(value)) {
|
|
28318
28350
|
Object.defineProperty(copy, key, {
|
|
28319
28351
|
...descriptor,
|
|
28320
28352
|
value: copyFromSandbox(descriptor.value, state, joinPath2(path, key), options, depth + 1)
|
|
@@ -28519,13 +28551,14 @@ function allocateSandboxValue2(value, budget, seen) {
|
|
|
28519
28551
|
}
|
|
28520
28552
|
return;
|
|
28521
28553
|
}
|
|
28522
|
-
if (
|
|
28554
|
+
if (isNumericTypedArray(value)) {
|
|
28523
28555
|
if (seen.has(value)) return;
|
|
28524
28556
|
seen.add(value);
|
|
28525
|
-
|
|
28526
|
-
|
|
28557
|
+
const storage = typedArrayStorage(value);
|
|
28558
|
+
budget.allocateArrayLength(Math.ceil(storage.byteLength / storage.elementSize));
|
|
28559
|
+
const capacity = arrayBufferOptions(typedArrayStorage(value).buffer)?.maxByteLength;
|
|
28527
28560
|
if (capacity !== void 0) budget.allocateArrayLength(capacity);
|
|
28528
|
-
for (const [key, descriptor] of
|
|
28561
|
+
for (const [key, descriptor] of typedArrayDataProperties(value)) {
|
|
28529
28562
|
budget.allocateString(key);
|
|
28530
28563
|
allocateSandboxValue2(descriptor.value, budget, seen);
|
|
28531
28564
|
}
|
|
@@ -29272,20 +29305,20 @@ function normalize(value, seen) {
|
|
|
29272
29305
|
properties
|
|
29273
29306
|
});
|
|
29274
29307
|
}
|
|
29275
|
-
if (
|
|
29276
|
-
const storage =
|
|
29308
|
+
if (isNumericTypedArray(value)) {
|
|
29309
|
+
const storage = typedArrayStorage(value);
|
|
29277
29310
|
const resizable = arrayBufferOptions(storage.buffer) !== void 0;
|
|
29278
|
-
const layout = resizable ?
|
|
29311
|
+
const layout = resizable ? typedArrayViewLayouts.get(value) : void 0;
|
|
29279
29312
|
if (resizable && layout === void 0)
|
|
29280
29313
|
throw new TypeError("Resizable Float32Array host-call identity requires known view layout.");
|
|
29281
29314
|
const properties = /* @__PURE__ */ Object.create(null);
|
|
29282
|
-
for (const [key, descriptor] of
|
|
29315
|
+
for (const [key, descriptor] of typedArrayDataProperties(value).sort(
|
|
29283
29316
|
([left], [right]) => left < right ? -1 : left > right ? 1 : 0
|
|
29284
29317
|
)) {
|
|
29285
29318
|
defineOwnDataProperty(properties, key, normalize(descriptor.value, seen));
|
|
29286
29319
|
}
|
|
29287
29320
|
return Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
29288
|
-
$type: "float32array",
|
|
29321
|
+
$type: storage.Native === Float32Array ? "float32array" : storage.Native.name,
|
|
29289
29322
|
bytes: normalize(Array.from(new Uint8Array(storage.buffer)), seen),
|
|
29290
29323
|
byteOffset: storage.byteOffset,
|
|
29291
29324
|
length: storage.length,
|
|
@@ -30262,6 +30295,7 @@ var KNOWN_RUNTIME_GLOBALS = [
|
|
|
30262
30295
|
"JSON",
|
|
30263
30296
|
"Map",
|
|
30264
30297
|
"Float32Array",
|
|
30298
|
+
"Uint8Array",
|
|
30265
30299
|
"Math",
|
|
30266
30300
|
"NaN",
|
|
30267
30301
|
"Number",
|
|
@@ -42760,4 +42794,4 @@ export {
|
|
|
42760
42794
|
FileSnapshotBackend,
|
|
42761
42795
|
run
|
|
42762
42796
|
};
|
|
42763
|
-
//# sourceMappingURL=chunk-
|
|
42797
|
+
//# sourceMappingURL=chunk-FKOORMNH.js.map
|