poe-code 14.0.82 → 14.0.84
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/index.js +1105 -223
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-js/dist/chunks/{chunk-7LGBDF56.js → chunk-2EZQJQ2C.js} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-V6LQP64H.js → chunk-CYVI4ZUK.js} +978 -161
- package/packages/safe-js/dist/chunks/chunk-CYVI4ZUK.js.map +7 -0
- package/packages/safe-js/dist/cli.js +2 -2
- package/packages/safe-js/dist/core.js +1 -1
- package/packages/safe-js/dist/index.js +2 -2
- package/packages/safe-js/dist/interp/array-buffer.d.ts +12 -0
- package/packages/safe-js/dist/interp/array-buffer.js +33 -0
- package/packages/safe-js/dist/interp/float32-prototypes.d.ts +3 -0
- package/packages/safe-js/dist/interp/float32-prototypes.js +1 -0
- package/packages/safe-js/dist/interp/float32.d.ts +7 -1
- package/packages/safe-js/dist/interp/float32.js +50 -14
- package/packages/safe-js/dist/interp/globals/array-buffer.d.ts +3 -0
- package/packages/safe-js/dist/interp/globals/array-buffer.js +112 -0
- package/packages/safe-js/dist/interp/globals/float32array.d.ts +4 -3
- package/packages/safe-js/dist/interp/globals/float32array.js +463 -68
- package/packages/safe-js/dist/interp/globals/object-array.js +3 -3
- package/packages/safe-js/dist/interp/globals.d.ts +2 -0
- package/packages/safe-js/dist/interp/globals.js +6 -2
- package/packages/safe-js/dist/interp/host-bridge.d.ts +1 -0
- package/packages/safe-js/dist/interp/host-bridge.js +21 -0
- package/packages/safe-js/dist/interp/host-call.js +26 -2
- package/packages/safe-js/dist/interp/instanceof.js +1 -1
- package/packages/safe-js/dist/interp/interpreter.js +2 -4
- package/packages/safe-js/dist/interp/iteration.js +15 -6
- package/packages/safe-js/dist/interp/methods/array-iterator.js +1 -1
- package/packages/safe-js/dist/interp/object-model.js +22 -1
- package/packages/safe-js/dist/interp/values.d.ts +1 -1
- package/packages/safe-js/dist/interp/values.js +59 -9
- package/packages/safe-js/dist/lint/rules/known-globals.d.ts +1 -1
- package/packages/safe-js/dist/lint/rules/known-globals.js +1 -0
- package/packages/safe-js/dist/parse/parser.js +8 -3
- package/packages/safe-js/dist/parse/tokenizer.js +45 -3
- package/packages/safe-js/dist/snapshot/array-buffer.d.ts +13 -0
- package/packages/safe-js/dist/snapshot/array-buffer.js +40 -0
- package/packages/safe-js/dist/snapshot/dump-format.js +25 -9
- package/packages/safe-js/dist/snapshot/float32array.d.ts +11 -1
- package/packages/safe-js/dist/snapshot/float32array.js +42 -5
- package/packages/safe-js/dist/snapshot/replay-data.d.ts +5 -0
- package/packages/safe-js/dist/snapshot/replay-data.js +35 -10
- package/packages/safe-js/dist/snapshot/restore.js +30 -3
- package/packages/safe-js/dist/snapshot/serialize.d.ts +7 -3
- package/packages/safe-js/dist/snapshot/serialize.js +24 -14
- package/packages/safe-js/dist/snapshot/validation.js +21 -1
- package/packages/safe-js/dist/chunks/chunk-V6LQP64H.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-7LGBDF56.js.map → chunk-2EZQJQ2C.js.map} +0 -0
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
resolveFsConfig,
|
|
23
23
|
splitFrontmatter,
|
|
24
24
|
withBrokenPipeGuard
|
|
25
|
-
} from "./chunks/chunk-
|
|
25
|
+
} from "./chunks/chunk-2EZQJQ2C.js";
|
|
26
26
|
import {
|
|
27
27
|
Budget,
|
|
28
28
|
SandboxError,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
replaceErrorStack,
|
|
35
35
|
restore,
|
|
36
36
|
run
|
|
37
|
-
} from "./chunks/chunk-
|
|
37
|
+
} from "./chunks/chunk-CYVI4ZUK.js";
|
|
38
38
|
import "./chunks/chunk-M2DLCGEF.js";
|
|
39
39
|
import "./chunks/chunk-Q7USUEL7.js";
|
|
40
40
|
import "./chunks/chunk-4YIDX44G.js";
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
runWithSpawnUsageAccumulator,
|
|
27
27
|
splitFrontmatter,
|
|
28
28
|
supportsSpawnMode
|
|
29
|
-
} from "./chunks/chunk-
|
|
29
|
+
} from "./chunks/chunk-2EZQJQ2C.js";
|
|
30
30
|
import {
|
|
31
31
|
Budget,
|
|
32
32
|
FileSnapshotBackend,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
registerPendingHostCallPolicy,
|
|
51
51
|
restore,
|
|
52
52
|
run
|
|
53
|
-
} from "./chunks/chunk-
|
|
53
|
+
} from "./chunks/chunk-CYVI4ZUK.js";
|
|
54
54
|
import "./chunks/chunk-M2DLCGEF.js";
|
|
55
55
|
import "./chunks/chunk-Q7USUEL7.js";
|
|
56
56
|
import "./chunks/chunk-4YIDX44G.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Budget } from "./budget.js";
|
|
2
|
+
import type { SandboxObject } from "./values.js";
|
|
3
|
+
export declare const arrayBufferPrototypes: WeakMap<Budget, SandboxObject>;
|
|
4
|
+
export declare function isSandboxArrayBuffer(value: unknown): value is ArrayBuffer;
|
|
5
|
+
export declare function arrayBufferLength(value: ArrayBuffer): number;
|
|
6
|
+
export declare function arrayBufferOptions(value: ArrayBuffer): {
|
|
7
|
+
maxByteLength: number;
|
|
8
|
+
} | undefined;
|
|
9
|
+
export declare function copyArrayBufferStorage(value: ArrayBuffer, state: {
|
|
10
|
+
float32Buffers?: WeakMap<ArrayBuffer, ArrayBuffer>;
|
|
11
|
+
}): ArrayBuffer;
|
|
12
|
+
export declare function arrayBufferDataProperties(value: ArrayBuffer): Array<[string | symbol, PropertyDescriptor]>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { types } from "node:util";
|
|
2
|
+
const readLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
|
|
3
|
+
const readResizable = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resizable")?.get;
|
|
4
|
+
const readMaxLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "maxByteLength")?.get;
|
|
5
|
+
export const arrayBufferPrototypes = new WeakMap();
|
|
6
|
+
export function isSandboxArrayBuffer(value) {
|
|
7
|
+
return types.isArrayBuffer(value) && Object.getPrototypeOf(value) === ArrayBuffer.prototype;
|
|
8
|
+
}
|
|
9
|
+
export function arrayBufferLength(value) {
|
|
10
|
+
return Reflect.apply(readLength, value, []);
|
|
11
|
+
}
|
|
12
|
+
export function arrayBufferOptions(value) {
|
|
13
|
+
return readResizable !== undefined && Reflect.apply(readResizable, value, [])
|
|
14
|
+
? { maxByteLength: Reflect.apply(readMaxLength, value, []) } : undefined;
|
|
15
|
+
}
|
|
16
|
+
export function copyArrayBufferStorage(value, state) {
|
|
17
|
+
state.float32Buffers ??= new WeakMap();
|
|
18
|
+
let copy = state.float32Buffers.get(value);
|
|
19
|
+
if (copy === undefined) {
|
|
20
|
+
copy = Reflect.construct(ArrayBuffer, [arrayBufferLength(value), arrayBufferOptions(value)]);
|
|
21
|
+
new Uint8Array(copy).set(new Uint8Array(value));
|
|
22
|
+
state.float32Buffers.set(value, copy);
|
|
23
|
+
}
|
|
24
|
+
return copy;
|
|
25
|
+
}
|
|
26
|
+
export function arrayBufferDataProperties(value) {
|
|
27
|
+
return Reflect.ownKeys(value).map(key => {
|
|
28
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
29
|
+
if (!("value" in descriptor))
|
|
30
|
+
throw new TypeError("ArrayBuffer accessors cannot be copied as data.");
|
|
31
|
+
return [key, descriptor];
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const float32Prototypes = new WeakMap();
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { Budget } from "./budget.js";
|
|
2
|
+
export declare const float32ViewLayouts: WeakMap<Float32Array<ArrayBufferLike>, {
|
|
3
|
+
byteOffset: number;
|
|
4
|
+
length?: number;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function restoreFloat32View(buffer: ArrayBuffer, byteOffset: number, length?: number, budget?: Budget): Float32Array;
|
|
2
7
|
export declare function isFloat32Array(value: unknown): value is Float32Array;
|
|
3
|
-
export declare function float32Storage(value: Float32Array): {
|
|
8
|
+
export declare function float32Storage(value: Float32Array, requireInBounds?: boolean): {
|
|
4
9
|
buffer: ArrayBuffer;
|
|
5
10
|
byteOffset: number;
|
|
6
11
|
length: number;
|
|
7
12
|
byteLength: number;
|
|
8
13
|
};
|
|
14
|
+
export declare function float32Properties(value: Float32Array): Array<[PropertyKey, PropertyDescriptor]>;
|
|
9
15
|
export declare function float32DataProperties(value: Float32Array): Array<[string, PropertyDescriptor]>;
|
|
10
16
|
export declare function isFloat32Index(key: string): boolean;
|
|
11
17
|
export declare function float32Number(value: unknown): number;
|
|
@@ -1,20 +1,48 @@
|
|
|
1
|
+
import { arrayBufferLength, arrayBufferOptions, copyArrayBufferStorage } from "./array-buffer.js";
|
|
1
2
|
const typedArrayPrototype = Object.getPrototypeOf(Float32Array.prototype);
|
|
2
3
|
const readLength = Object.getOwnPropertyDescriptor(typedArrayPrototype, "length").get;
|
|
3
4
|
const readOffset = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteOffset").get;
|
|
4
5
|
const readBuffer = Object.getOwnPropertyDescriptor(typedArrayPrototype, "buffer").get;
|
|
5
6
|
const readTag = Object.getOwnPropertyDescriptor(typedArrayPrototype, Symbol.toStringTag).get;
|
|
7
|
+
const createValuesIterator = Object.getOwnPropertyDescriptor(typedArrayPrototype, "values").value;
|
|
6
8
|
const bufferLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
|
|
7
9
|
const bufferResizable = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resizable")?.get;
|
|
10
|
+
export const float32ViewLayouts = new WeakMap();
|
|
11
|
+
const resizeBuffer = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resize").value;
|
|
12
|
+
export function restoreFloat32View(buffer, byteOffset, length, budget) {
|
|
13
|
+
const originalLength = arrayBufferLength(buffer);
|
|
14
|
+
const required = byteOffset + (length ?? 0) * 4;
|
|
15
|
+
const options = arrayBufferOptions(buffer);
|
|
16
|
+
const grow = required > originalLength;
|
|
17
|
+
if (grow) {
|
|
18
|
+
if (options === undefined || required > options.maxByteLength)
|
|
19
|
+
throw new RangeError("Float32Array layout exceeds backing capacity.");
|
|
20
|
+
budget?.allocateArrayLength(Math.ceil(required / 4));
|
|
21
|
+
budget?.provisionDataUsage(required - originalLength)();
|
|
22
|
+
Reflect.apply(resizeBuffer, buffer, [required]);
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const view = new Float32Array(buffer, byteOffset, length);
|
|
26
|
+
if (options !== undefined)
|
|
27
|
+
float32ViewLayouts.set(view, { byteOffset, ...(length === undefined ? {} : { length }) });
|
|
28
|
+
return view;
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
if (grow)
|
|
32
|
+
Reflect.apply(resizeBuffer, buffer, [originalLength]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
8
35
|
export function isFloat32Array(value) {
|
|
9
36
|
return (ArrayBuffer.isView(value) &&
|
|
10
37
|
Object.getPrototypeOf(value) === Float32Array.prototype &&
|
|
11
38
|
Reflect.apply(readTag, value, []) === "Float32Array");
|
|
12
39
|
}
|
|
13
|
-
export function float32Storage(value) {
|
|
40
|
+
export function float32Storage(value, requireInBounds = false) {
|
|
41
|
+
if (requireInBounds)
|
|
42
|
+
Reflect.apply(createValuesIterator, value, []);
|
|
14
43
|
const buffer = Reflect.apply(readBuffer, value, []);
|
|
15
|
-
if (Object.getPrototypeOf(buffer) !== ArrayBuffer.prototype
|
|
16
|
-
(
|
|
17
|
-
throw new TypeError("Float32Array requires a fixed, non-shared ArrayBuffer.");
|
|
44
|
+
if (Object.getPrototypeOf(buffer) !== ArrayBuffer.prototype) {
|
|
45
|
+
throw new TypeError("Float32Array requires a non-shared ArrayBuffer.");
|
|
18
46
|
}
|
|
19
47
|
return {
|
|
20
48
|
buffer,
|
|
@@ -23,14 +51,22 @@ export function float32Storage(value) {
|
|
|
23
51
|
byteLength: Reflect.apply(bufferLength, buffer, [])
|
|
24
52
|
};
|
|
25
53
|
}
|
|
54
|
+
export function float32Properties(value) {
|
|
55
|
+
const properties = [];
|
|
56
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
57
|
+
if (typeof key === "string" && isFloat32Index(key))
|
|
58
|
+
continue;
|
|
59
|
+
properties.push([key, Object.getOwnPropertyDescriptor(value, key)]);
|
|
60
|
+
}
|
|
61
|
+
return properties;
|
|
62
|
+
}
|
|
26
63
|
export function float32DataProperties(value) {
|
|
27
64
|
if (Object.getOwnPropertySymbols(value).length > 0)
|
|
28
65
|
throw new TypeError("Float32Array symbol properties are not supported.");
|
|
29
66
|
const properties = [];
|
|
30
|
-
for (const key of
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
67
|
+
for (const [key, descriptor] of float32Properties(value)) {
|
|
68
|
+
if (typeof key !== "string")
|
|
69
|
+
throw new TypeError("Float32Array symbol properties are not supported.");
|
|
34
70
|
if (!("value" in descriptor))
|
|
35
71
|
throw new TypeError(`Float32Array accessor property '${key}' is not supported.`);
|
|
36
72
|
properties.push([key, descriptor]);
|
|
@@ -55,12 +91,12 @@ export function checkFloat32Allocation(length, budget) {
|
|
|
55
91
|
}
|
|
56
92
|
export function copyFloat32Storage(value, state) {
|
|
57
93
|
const storage = float32Storage(value);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
94
|
+
const buffer = copyArrayBufferStorage(storage.buffer, state);
|
|
95
|
+
if (bufferResizable !== undefined && Reflect.apply(bufferResizable, storage.buffer, [])) {
|
|
96
|
+
const layout = float32ViewLayouts.get(value);
|
|
97
|
+
if (layout === undefined)
|
|
98
|
+
throw new TypeError("Resizable Float32Array copies require known view layout.");
|
|
99
|
+
return restoreFloat32View(buffer, layout.byteOffset, layout.length);
|
|
64
100
|
}
|
|
65
101
|
return new Float32Array(buffer, storage.byteOffset, storage.length);
|
|
66
102
|
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { arrayBufferLength, arrayBufferOptions, arrayBufferPrototypes, isSandboxArrayBuffer } from "../array-buffer.js";
|
|
2
|
+
import { accessorAdapter, readPropertyDescriptor } from "../accessors.js";
|
|
3
|
+
import { createSandboxClosure } from "../values.js";
|
|
4
|
+
import { getSandboxDataProperty, getSandboxPropertyDescriptor, getSandboxPrototype, materializeFunctionProperties, registerIntrinsicFunction, registerIntrinsicObject, setSandboxPrototype } from "../object-model.js";
|
|
5
|
+
import { invokeBuiltinClosure } from "../builtin-call.js";
|
|
6
|
+
import { registerBuiltinIdentities } from "../intrinsics.js";
|
|
7
|
+
import { sandboxNumber } from "../string-coercion.js";
|
|
8
|
+
import { retainValues } from "../resources.js";
|
|
9
|
+
const resizeBuffer = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resize").value;
|
|
10
|
+
export function createArrayBufferGlobal(budget) {
|
|
11
|
+
const prototype = Object.create(null);
|
|
12
|
+
const constructor = createSandboxClosure({
|
|
13
|
+
guest: true, sandbox: true, name: "ArrayBuffer", length: 1,
|
|
14
|
+
call: () => { throw new TypeError("ArrayBuffer requires new."); },
|
|
15
|
+
construct: async (args, context) => {
|
|
16
|
+
let selected;
|
|
17
|
+
let current;
|
|
18
|
+
const bridge = {
|
|
19
|
+
...context, stack: context?.stack ?? [], thisValue: undefined,
|
|
20
|
+
getProperty: context?.getProperty ?? ((value, key) => {
|
|
21
|
+
const descriptor = getSandboxPropertyDescriptor(value, key, budget);
|
|
22
|
+
return descriptor === undefined ? getSandboxDataProperty(value, key, budget)
|
|
23
|
+
: readPropertyDescriptor(descriptor, value, bridge);
|
|
24
|
+
}),
|
|
25
|
+
invokeClosure: context?.invokeClosure ?? ((callee, values, receiver, construct) => invokeBuiltinClosure(callee, values, budget, context, receiver, construct))
|
|
26
|
+
};
|
|
27
|
+
const release = retainValues(budget, () => [selected, current, ...args]);
|
|
28
|
+
try {
|
|
29
|
+
const number = await sandboxNumber(args[0], budget, bridge);
|
|
30
|
+
const length = Number.isNaN(number) ? 0 : Math.trunc(number);
|
|
31
|
+
if (length < 0 || !Number.isSafeInteger(length))
|
|
32
|
+
throw new RangeError("Invalid ArrayBuffer length.");
|
|
33
|
+
let maxByteLength;
|
|
34
|
+
if (args[1] !== null && typeof args[1] === "object") {
|
|
35
|
+
current = await bridge.getProperty(args[1], "maxByteLength");
|
|
36
|
+
if (current !== undefined) {
|
|
37
|
+
const maximum = await sandboxNumber(current, budget, bridge);
|
|
38
|
+
maxByteLength = Number.isNaN(maximum) ? 0 : Math.trunc(maximum);
|
|
39
|
+
if (!Number.isSafeInteger(maxByteLength) || maxByteLength < length)
|
|
40
|
+
throw new RangeError("Invalid ArrayBuffer maximum length.");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const target = context?.newTarget ?? constructor;
|
|
44
|
+
selected = await bridge.getProperty(target, "prototype");
|
|
45
|
+
budget.allocateArrayLength(maxByteLength ?? length);
|
|
46
|
+
budget.provisionDataUsage(length + 1)();
|
|
47
|
+
const result = Reflect.construct(ArrayBuffer, [length, maxByteLength === undefined ? undefined : { maxByteLength }]);
|
|
48
|
+
setSandboxPrototype(result, selected !== null && typeof selected === "object" ? selected : prototype, budget);
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
release();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(materializeFunctionProperties(constructor), "prototype", { value: prototype, writable: false });
|
|
57
|
+
Object.defineProperty(materializeFunctionProperties(constructor), "isView", {
|
|
58
|
+
writable: true, configurable: true,
|
|
59
|
+
value: createSandboxClosure({ guest: true, sandbox: true, name: "isView", length: 1,
|
|
60
|
+
call: args => ArrayBuffer.isView(args[0]) })
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperties(prototype, {
|
|
63
|
+
constructor: { value: constructor, writable: true, configurable: true },
|
|
64
|
+
[Symbol.toStringTag]: { value: "ArrayBuffer", configurable: true }
|
|
65
|
+
});
|
|
66
|
+
const getters = [];
|
|
67
|
+
Object.defineProperty(prototype, "resize", { writable: true, configurable: true,
|
|
68
|
+
value: createSandboxClosure({ guest: true, sandbox: true, name: "resize", length: 1,
|
|
69
|
+
call: async (args, context) => {
|
|
70
|
+
const receiver = context?.thisValue;
|
|
71
|
+
if (!isSandboxArrayBuffer(receiver) || arrayBufferOptions(receiver) === undefined)
|
|
72
|
+
throw new TypeError("ArrayBuffer resize requires a resizable buffer receiver.");
|
|
73
|
+
const release = retainValues(budget, () => [receiver, ...args]);
|
|
74
|
+
try {
|
|
75
|
+
const number = await sandboxNumber(args[0], budget, context);
|
|
76
|
+
const length = Number.isNaN(number) ? 0 : Math.trunc(number);
|
|
77
|
+
if (!Number.isSafeInteger(length) || length < 0 || length > arrayBufferOptions(receiver).maxByteLength)
|
|
78
|
+
throw new RangeError("Invalid ArrayBuffer resize length.");
|
|
79
|
+
budget.allocateArrayLength(length);
|
|
80
|
+
budget.provisionDataUsage(Math.max(length - arrayBufferLength(receiver), 0))();
|
|
81
|
+
Reflect.apply(resizeBuffer, receiver, [length]);
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
release();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
});
|
|
90
|
+
for (const key of ["byteLength", "maxByteLength", "resizable"]) {
|
|
91
|
+
const getter = createSandboxClosure({ guest: true, sandbox: true, name: `get ${key}`, length: 0,
|
|
92
|
+
call: (_args, context) => {
|
|
93
|
+
if (!isSandboxArrayBuffer(context?.thisValue))
|
|
94
|
+
throw new TypeError(`ArrayBuffer ${key} requires a buffer receiver.`);
|
|
95
|
+
if (key === "byteLength")
|
|
96
|
+
return arrayBufferLength(context.thisValue);
|
|
97
|
+
const options = arrayBufferOptions(context.thisValue);
|
|
98
|
+
return key === "resizable" ? options !== undefined : options?.maxByteLength ?? arrayBufferLength(context.thisValue);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(prototype, key, { get: accessorAdapter(getter, "get"), configurable: true });
|
|
102
|
+
getters.push(getter);
|
|
103
|
+
}
|
|
104
|
+
setSandboxPrototype(prototype, getSandboxPrototype(Object.create(null), budget));
|
|
105
|
+
arrayBufferPrototypes.set(budget, prototype);
|
|
106
|
+
registerBuiltinIdentities(budget, { ArrayBuffer: constructor });
|
|
107
|
+
registerIntrinsicFunction(budget, constructor);
|
|
108
|
+
for (const getter of getters)
|
|
109
|
+
registerIntrinsicFunction(budget, getter);
|
|
110
|
+
registerIntrinsicObject(budget, prototype);
|
|
111
|
+
return constructor;
|
|
112
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Budget } from "../budget.js";
|
|
2
2
|
import { type SandboxClosure, type SandboxValue } from "../values.js";
|
|
3
|
-
export declare function createFloat32ArrayGlobal(budget: Budget): SandboxClosure;
|
|
3
|
+
export declare function createFloat32ArrayGlobal(budget: Budget, nativePrototype?: boolean): SandboxClosure;
|
|
4
|
+
export declare function createFloat32ArrayPrototypes(budget: Budget, constructor: SandboxClosure): void;
|
|
4
5
|
export declare function isFloat32ArrayConstructor(value: unknown): boolean;
|
|
5
|
-
export declare function getFloat32Member(value: Float32Array, property: string | number, budget: Budget): SandboxValue;
|
|
6
|
-
export declare function setFloat32Member(value: Float32Array, property:
|
|
6
|
+
export declare function getFloat32Member(value: Float32Array, property: string | number, budget: Budget, defaultConstructor?: SandboxClosure): SandboxValue;
|
|
7
|
+
export declare function setFloat32Member(value: Float32Array, property: PropertyKey, entry: SandboxValue, budget?: Budget): void;
|