poe-code 12.0.2 → 12.0.4
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/README.md +24 -0
- package/dist/index.js +430 -6
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/package.json +8 -2
- package/packages/package-lint/dist/bundle-policy.d.ts +45 -0
- package/packages/package-lint/dist/bundle-policy.js +169 -0
- package/packages/package-lint/dist/model.d.ts +4 -10
- package/packages/package-lint/dist/model.js +4 -2
- package/packages/package-lint/dist/packlist.js +5 -1
- package/packages/package-lint/dist/rules/bundle-self-contained.js +11 -25
- package/packages/safe-fs/dist/contracts/abort.d.ts +5 -0
- package/packages/safe-fs/dist/contracts/cleanup.d.ts +1 -0
- package/packages/safe-fs/dist/contracts/errors.d.ts +49 -0
- package/packages/safe-fs/dist/contracts/filesystem.d.ts +96 -0
- package/packages/safe-fs/dist/contracts/index.d.ts +4 -0
- package/packages/safe-fs/dist/contracts/io.d.ts +8 -0
- package/packages/safe-fs/dist/contracts/path.d.ts +13 -0
- package/packages/safe-fs/dist/fs/memory/index.d.ts +58 -0
- package/packages/safe-fs/dist/fs/mount/comparison.d.ts +18 -0
- package/packages/safe-fs/dist/fs/mount/identity.d.ts +2 -0
- package/packages/safe-fs/dist/fs/mount/index.d.ts +44 -0
- package/packages/safe-fs/dist/fs/overlay/index.d.ts +72 -0
- package/packages/safe-fs/dist/fs/readonly/index.d.ts +30 -0
- package/packages/safe-fs/dist/fs/real/allocation.d.ts +1 -0
- package/packages/safe-fs/dist/fs/real/index.d.ts +76 -0
- package/packages/safe-fs/dist/fs/s3/authority.d.ts +13 -0
- package/packages/safe-fs/dist/fs/s3/filesystem.d.ts +93 -0
- package/packages/safe-fs/dist/fs/s3/http/index.d.ts +2 -0
- package/packages/safe-fs/dist/fs/s3/http/request.d.ts +16 -0
- package/packages/safe-fs/dist/fs/s3/http/signature.d.ts +20 -0
- package/packages/safe-fs/dist/fs/s3/http/transport.d.ts +3 -0
- package/packages/safe-fs/dist/fs/s3/http/types.d.ts +30 -0
- package/packages/safe-fs/dist/fs/s3/http/xml.d.ts +11 -0
- package/packages/safe-fs/dist/fs/s3/index.d.ts +6 -0
- package/packages/safe-fs/dist/fs/s3/mock.d.ts +48 -0
- package/packages/safe-fs/dist/fs/s3/transport.d.ts +103 -0
- package/packages/safe-fs/dist/fs/webdav/index.d.ts +2 -0
- package/packages/safe-fs/dist/fs/webdav/resource-id.d.ts +18 -0
- package/packages/safe-fs/dist/fs/webdav/webdav.d.ts +98 -0
- package/packages/safe-fs/dist/fs/webdav/xml.d.ts +15 -0
- package/packages/safe-fs/dist/index.d.ts +11 -0
- package/packages/safe-fs/dist/node/filesystem.d.ts +11 -0
- package/packages/safe-fs/dist/node/index.d.ts +2 -0
- package/packages/safe-fs/dist/node/stats.d.ts +4 -0
- package/packages/safe-fs/dist/node/values.d.ts +6 -0
- package/packages/safejs/dist/chunks/{chunk-T55OILHA.js → chunk-LF5LY5O3.js} +2 -2
- package/packages/safejs/dist/chunks/{chunk-Z3ZMLYCK.js → chunk-XBRQ72W6.js} +387 -5
- package/packages/safejs/dist/chunks/chunk-XBRQ72W6.js.map +7 -0
- package/packages/safejs/dist/cli.js +2 -2
- package/packages/safejs/dist/core.js +1 -1
- package/packages/safejs/dist/index.js +2 -2
- package/packages/safejs/dist/interp/float32.d.ts +16 -0
- package/packages/safejs/dist/interp/float32.js +65 -0
- package/packages/safejs/dist/interp/globals/float32array.d.ts +6 -0
- package/packages/safejs/dist/interp/globals/float32array.js +130 -0
- package/packages/safejs/dist/interp/globals/object-array.js +6 -0
- package/packages/safejs/dist/interp/host-bridge.js +18 -0
- package/packages/safejs/dist/interp/host-call.js +15 -0
- package/packages/safejs/dist/interp/interpreter.js +17 -1
- package/packages/safejs/dist/interp/iteration.js +4 -0
- package/packages/safejs/dist/interp/values.d.ts +1 -1
- package/packages/safejs/dist/interp/values.js +56 -0
- package/packages/safejs/dist/lint/rules/known-globals.d.ts +1 -1
- package/packages/safejs/dist/lint/rules/known-globals.js +1 -0
- package/packages/safejs/dist/run.js +2 -0
- package/packages/safejs/dist/safe-fs.js +6476 -0
- package/packages/safejs/dist/safe-fs.js.map +7 -0
- package/packages/safejs/dist/snapshot/dump-format.js +20 -2
- package/packages/safejs/dist/snapshot/float32array.d.ts +12 -0
- package/packages/safejs/dist/snapshot/float32array.js +46 -0
- package/packages/safejs/dist/snapshot/replay-data.d.ts +5 -1
- package/packages/safejs/dist/snapshot/replay-data.js +29 -0
- package/packages/safejs/dist/snapshot/restore.js +14 -0
- package/packages/safejs/dist/snapshot/serialize.d.ts +5 -2
- package/packages/safejs/dist/snapshot/serialize.js +17 -2
- package/packages/safejs/dist/snapshot/validation.js +11 -1
- package/packages/safejs/dist/chunks/chunk-Z3ZMLYCK.js.map +0 -7
- /package/packages/safejs/dist/chunks/{chunk-T55OILHA.js.map → chunk-LF5LY5O3.js.map} +0 -0
|
@@ -5982,6 +5982,7 @@ var KNOWN_RUNTIME_GLOBALS = [
|
|
|
5982
5982
|
"isNaN",
|
|
5983
5983
|
"JSON",
|
|
5984
5984
|
"Map",
|
|
5985
|
+
"Float32Array",
|
|
5985
5986
|
"Math",
|
|
5986
5987
|
"NaN",
|
|
5987
5988
|
"Number",
|
|
@@ -16959,6 +16960,104 @@ function serializeArray(value, serializeValue) {
|
|
|
16959
16960
|
return { kind: "array", length: value.length, entries };
|
|
16960
16961
|
}
|
|
16961
16962
|
|
|
16963
|
+
// packages/safejs/src/interp/float32.ts
|
|
16964
|
+
var typedArrayPrototype = Object.getPrototypeOf(Float32Array.prototype);
|
|
16965
|
+
var readLength = Object.getOwnPropertyDescriptor(typedArrayPrototype, "length").get;
|
|
16966
|
+
var readOffset = Object.getOwnPropertyDescriptor(typedArrayPrototype, "byteOffset").get;
|
|
16967
|
+
var readBuffer = Object.getOwnPropertyDescriptor(typedArrayPrototype, "buffer").get;
|
|
16968
|
+
var readTag = Object.getOwnPropertyDescriptor(typedArrayPrototype, Symbol.toStringTag).get;
|
|
16969
|
+
var bufferLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
|
|
16970
|
+
var bufferResizable = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resizable")?.get;
|
|
16971
|
+
function isFloat32Array(value) {
|
|
16972
|
+
return ArrayBuffer.isView(value) && Object.getPrototypeOf(value) === Float32Array.prototype && Reflect.apply(readTag, value, []) === "Float32Array";
|
|
16973
|
+
}
|
|
16974
|
+
function float32Storage(value) {
|
|
16975
|
+
const buffer = Reflect.apply(readBuffer, value, []);
|
|
16976
|
+
if (Object.getPrototypeOf(buffer) !== ArrayBuffer.prototype || bufferResizable !== void 0 && Reflect.apply(bufferResizable, buffer, [])) {
|
|
16977
|
+
throw new TypeError("Float32Array requires a fixed, non-shared ArrayBuffer.");
|
|
16978
|
+
}
|
|
16979
|
+
return {
|
|
16980
|
+
buffer,
|
|
16981
|
+
byteOffset: Reflect.apply(readOffset, value, []),
|
|
16982
|
+
length: Reflect.apply(readLength, value, []),
|
|
16983
|
+
byteLength: Reflect.apply(bufferLength, buffer, [])
|
|
16984
|
+
};
|
|
16985
|
+
}
|
|
16986
|
+
function float32DataProperties(value) {
|
|
16987
|
+
if (Object.getOwnPropertySymbols(value).length > 0)
|
|
16988
|
+
throw new TypeError("Float32Array symbol properties are not supported.");
|
|
16989
|
+
const properties = [];
|
|
16990
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
|
|
16991
|
+
if (isFloat32Index(key)) continue;
|
|
16992
|
+
if (!("value" in descriptor))
|
|
16993
|
+
throw new TypeError(`Float32Array accessor property '${key}' is not supported.`);
|
|
16994
|
+
properties.push([key, descriptor]);
|
|
16995
|
+
}
|
|
16996
|
+
return properties;
|
|
16997
|
+
}
|
|
16998
|
+
function isFloat32Index(key) {
|
|
16999
|
+
return key === "-0" || String(Number(key)) === key;
|
|
17000
|
+
}
|
|
17001
|
+
function float32Number(value) {
|
|
17002
|
+
if (value !== null && typeof value === "object" || typeof value === "function" || typeof value === "symbol" || typeof value === "bigint") {
|
|
17003
|
+
throw new TypeError(
|
|
17004
|
+
"Float32Array numeric arguments must be primitive numeric-coercible values."
|
|
17005
|
+
);
|
|
17006
|
+
}
|
|
17007
|
+
return Number(value);
|
|
17008
|
+
}
|
|
17009
|
+
function checkFloat32Allocation(length, budget) {
|
|
17010
|
+
budget.allocateArrayLength(length);
|
|
17011
|
+
budget.provisionDataUsage(length * Float32Array.BYTES_PER_ELEMENT + 1)();
|
|
17012
|
+
}
|
|
17013
|
+
function copyFloat32Storage(value, state) {
|
|
17014
|
+
const storage = float32Storage(value);
|
|
17015
|
+
state.float32Buffers ??= /* @__PURE__ */ new WeakMap();
|
|
17016
|
+
let buffer = state.float32Buffers.get(storage.buffer);
|
|
17017
|
+
if (buffer === void 0) {
|
|
17018
|
+
buffer = new ArrayBuffer(storage.byteLength);
|
|
17019
|
+
new Uint8Array(buffer).set(new Uint8Array(storage.buffer));
|
|
17020
|
+
state.float32Buffers.set(storage.buffer, buffer);
|
|
17021
|
+
}
|
|
17022
|
+
return new Float32Array(buffer, storage.byteOffset, storage.length);
|
|
17023
|
+
}
|
|
17024
|
+
|
|
17025
|
+
// packages/safejs/src/snapshot/float32array.ts
|
|
17026
|
+
function encodeFloat32Storage(value, id, buffers, reference) {
|
|
17027
|
+
const storage = float32Storage(value);
|
|
17028
|
+
const existing = buffers.get(storage.buffer);
|
|
17029
|
+
if (existing === void 0) buffers.set(storage.buffer, id);
|
|
17030
|
+
return {
|
|
17031
|
+
kind: "float32array",
|
|
17032
|
+
byteOffset: storage.byteOffset,
|
|
17033
|
+
length: storage.length,
|
|
17034
|
+
...existing === void 0 ? { bytes: Array.from(new Uint8Array(storage.buffer)) } : { buffer: reference(existing) }
|
|
17035
|
+
};
|
|
17036
|
+
}
|
|
17037
|
+
function validateFloat32Storage(value) {
|
|
17038
|
+
if (!Number.isSafeInteger(value.length) || Number(value.length) < 0 || !Number.isSafeInteger(value.byteOffset) || Number(value.byteOffset) < 0 || Number(value.byteOffset) % 4 !== 0)
|
|
17039
|
+
throw new TypeError("Invalid Float32Array view dimensions.");
|
|
17040
|
+
if (Object.hasOwn(value, "bytes") === Object.hasOwn(value, "buffer"))
|
|
17041
|
+
throw new TypeError("Float32Array requires one backing storage description.");
|
|
17042
|
+
if (Object.hasOwn(value, "bytes")) {
|
|
17043
|
+
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)) / 4))
|
|
17044
|
+
throw new TypeError("Invalid Float32Array backing bytes.");
|
|
17045
|
+
}
|
|
17046
|
+
}
|
|
17047
|
+
function decodeFloat32Storage(value, resolve) {
|
|
17048
|
+
validateFloat32Storage(value);
|
|
17049
|
+
let buffer;
|
|
17050
|
+
if (Array.isArray(value.bytes)) {
|
|
17051
|
+
buffer = new ArrayBuffer(value.bytes.length);
|
|
17052
|
+
new Uint8Array(buffer).set(value.bytes);
|
|
17053
|
+
} else {
|
|
17054
|
+
const referenced = resolve(value.buffer);
|
|
17055
|
+
if (!isFloat32Array(referenced)) throw new TypeError("Invalid Float32Array backing reference.");
|
|
17056
|
+
buffer = float32Storage(referenced).buffer;
|
|
17057
|
+
}
|
|
17058
|
+
return new Float32Array(buffer, Number(value.byteOffset), Number(value.length));
|
|
17059
|
+
}
|
|
17060
|
+
|
|
16962
17061
|
// packages/safejs/src/snapshot/dump-format.ts
|
|
16963
17062
|
var DUMP_FORMAT_VERSION = 1;
|
|
16964
17063
|
var EXECUTION_SEMANTICS = "jobs-v7";
|
|
@@ -16978,6 +17077,7 @@ function serializeSafeJSSnapshot(snapshot) {
|
|
|
16978
17077
|
}
|
|
16979
17078
|
function createDumpFile(snapshot) {
|
|
16980
17079
|
const state = {
|
|
17080
|
+
float32Buffers: /* @__PURE__ */ new WeakMap(),
|
|
16981
17081
|
heap: {},
|
|
16982
17082
|
heapIds: indexHeapContainers(snapshot),
|
|
16983
17083
|
serializedHeapIds: /* @__PURE__ */ new Set()
|
|
@@ -17016,6 +17116,7 @@ function serializeDumpValue(value, path, state) {
|
|
|
17016
17116
|
if (typeof value !== "object") {
|
|
17017
17117
|
return SKIP_VALUE;
|
|
17018
17118
|
}
|
|
17119
|
+
if (isFloat32Array(value)) return serializeHeapReference(value, path, state);
|
|
17019
17120
|
if (Array.isArray(value)) {
|
|
17020
17121
|
const reference2 = serializeHeapReference(value, path, state);
|
|
17021
17122
|
if (reference2 !== void 0) {
|
|
@@ -17039,7 +17140,18 @@ function serializeHeapReference(value, path, state) {
|
|
|
17039
17140
|
}
|
|
17040
17141
|
if (!state.serializedHeapIds.has(id)) {
|
|
17041
17142
|
state.serializedHeapIds.add(id);
|
|
17042
|
-
if (
|
|
17143
|
+
if (isFloat32Array(value)) {
|
|
17144
|
+
const storage = encodeFloat32Storage(value, id, state.float32Buffers, (id2) => ({
|
|
17145
|
+
kind: "ref",
|
|
17146
|
+
id: id2
|
|
17147
|
+
}));
|
|
17148
|
+
const entries = /* @__PURE__ */ Object.create(null);
|
|
17149
|
+
state.heap[String(id)] = { ...storage, entries };
|
|
17150
|
+
for (const [key, descriptor] of float32DataProperties(value)) {
|
|
17151
|
+
const serialized = serializeDumpValue(descriptor.value, `${path}.${key}`, state);
|
|
17152
|
+
entries[key] = serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
|
|
17153
|
+
}
|
|
17154
|
+
} else if (isSandboxArguments(value)) {
|
|
17043
17155
|
state.heap[String(id)] = serializeArguments(value, (entry, key) => {
|
|
17044
17156
|
const serialized = serializeDumpValue(entry, `${path}.${key}`, state);
|
|
17045
17157
|
return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
|
|
@@ -17085,7 +17197,7 @@ function indexHeapContainers(snapshot) {
|
|
|
17085
17197
|
const heapIds = /* @__PURE__ */ new WeakMap();
|
|
17086
17198
|
let nextId = 1;
|
|
17087
17199
|
for (const [value, stat2] of stats.entries()) {
|
|
17088
|
-
if (stat2.count > 1 || stat2.cyclic || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
17200
|
+
if (stat2.count > 1 || stat2.cyclic || isFloat32Array(value) || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
|
|
17089
17201
|
heapIds.set(value, nextId);
|
|
17090
17202
|
nextId += 1;
|
|
17091
17203
|
}
|
|
@@ -17096,7 +17208,7 @@ function collectContainerStats(value, stats, ancestors) {
|
|
|
17096
17208
|
if (value === null || typeof value !== "object") {
|
|
17097
17209
|
return;
|
|
17098
17210
|
}
|
|
17099
|
-
if (!Array.isArray(value) && !isPlainObject(value)) {
|
|
17211
|
+
if (!Array.isArray(value) && !isPlainObject(value) && !isFloat32Array(value)) {
|
|
17100
17212
|
return;
|
|
17101
17213
|
}
|
|
17102
17214
|
let stat2 = stats.get(value);
|
|
@@ -17232,6 +17344,11 @@ function validateDumpHeap(root, state) {
|
|
|
17232
17344
|
addUnique(heapIds, id, path);
|
|
17233
17345
|
const entry = requireRecord(value, path);
|
|
17234
17346
|
validateErrorType(entry, path);
|
|
17347
|
+
if (entry.kind === "float32array") {
|
|
17348
|
+
validateFloat32Storage(entry);
|
|
17349
|
+
requireRecord(entry.entries, `${path}.entries`);
|
|
17350
|
+
continue;
|
|
17351
|
+
}
|
|
17235
17352
|
if (entry.kind === "arguments") {
|
|
17236
17353
|
validateArgumentsProperties(entry, path);
|
|
17237
17354
|
continue;
|
|
@@ -18575,6 +18692,9 @@ function assertSnapshotInactive(snapshot) {
|
|
|
18575
18692
|
|
|
18576
18693
|
// packages/safejs/src/interp/iteration.ts
|
|
18577
18694
|
function getSandboxIterator(value) {
|
|
18695
|
+
if (isFloat32Array(value)) {
|
|
18696
|
+
return syncIterator(Float32Array.prototype.values.call(value));
|
|
18697
|
+
}
|
|
18578
18698
|
if (isSandboxGenerator(value)) {
|
|
18579
18699
|
return generatorIterator(value);
|
|
18580
18700
|
}
|
|
@@ -19860,6 +19980,18 @@ function measureSandboxData(values, options = {}) {
|
|
|
19860
19980
|
if (seen.has(value)) return;
|
|
19861
19981
|
seen.add(value);
|
|
19862
19982
|
usage += 1;
|
|
19983
|
+
if (isFloat32Array(value)) {
|
|
19984
|
+
const storage = float32Storage(value);
|
|
19985
|
+
if (!seen.has(storage.buffer)) {
|
|
19986
|
+
seen.add(storage.buffer);
|
|
19987
|
+
usage += storage.byteLength;
|
|
19988
|
+
}
|
|
19989
|
+
for (const [key, descriptor] of float32DataProperties(value)) {
|
|
19990
|
+
usage += key.length + 1;
|
|
19991
|
+
visit(descriptor.value);
|
|
19992
|
+
}
|
|
19993
|
+
return;
|
|
19994
|
+
}
|
|
19863
19995
|
if (Array.isArray(value)) {
|
|
19864
19996
|
usage += value.length;
|
|
19865
19997
|
for (let index = 0; index < value.length; index += 1) {
|
|
@@ -19968,6 +20100,26 @@ function copyToSandbox(value, state, path = "<root>", cloneSandboxCollections =
|
|
|
19968
20100
|
}
|
|
19969
20101
|
return sandboxPromise;
|
|
19970
20102
|
}
|
|
20103
|
+
if (isFloat32Array(value)) {
|
|
20104
|
+
const existing = state.seen.get(value);
|
|
20105
|
+
if (existing !== void 0) return existing;
|
|
20106
|
+
const copy = copyFloat32Storage(value, state);
|
|
20107
|
+
state.seen.set(value, copy);
|
|
20108
|
+
for (const [key, descriptor] of float32DataProperties(value)) {
|
|
20109
|
+
Object.defineProperty(copy, key, {
|
|
20110
|
+
...descriptor,
|
|
20111
|
+
value: copyToSandbox(
|
|
20112
|
+
descriptor.value,
|
|
20113
|
+
state,
|
|
20114
|
+
joinPath(path, key),
|
|
20115
|
+
cloneSandboxCollections,
|
|
20116
|
+
depth + 1
|
|
20117
|
+
)
|
|
20118
|
+
});
|
|
20119
|
+
}
|
|
20120
|
+
if (!Object.isExtensible(value)) Object.preventExtensions(copy);
|
|
20121
|
+
return copy;
|
|
20122
|
+
}
|
|
19971
20123
|
if (value instanceof Map) {
|
|
19972
20124
|
const existing = state.seen.get(value);
|
|
19973
20125
|
if (existing !== void 0) {
|
|
@@ -20062,6 +20214,20 @@ function copyFromSandbox(value, state, path = "<root>", options, depth = 0) {
|
|
|
20062
20214
|
if (isSandboxPrimitive(value)) {
|
|
20063
20215
|
return value;
|
|
20064
20216
|
}
|
|
20217
|
+
if (isFloat32Array(value)) {
|
|
20218
|
+
const existing = state.seen.get(value);
|
|
20219
|
+
if (existing !== void 0) return existing;
|
|
20220
|
+
const copy = copyFloat32Storage(value, state);
|
|
20221
|
+
state.seen.set(value, copy);
|
|
20222
|
+
for (const [key, descriptor] of float32DataProperties(value)) {
|
|
20223
|
+
Object.defineProperty(copy, key, {
|
|
20224
|
+
...descriptor,
|
|
20225
|
+
value: copyFromSandbox(descriptor.value, state, joinPath(path, key), options, depth + 1)
|
|
20226
|
+
});
|
|
20227
|
+
}
|
|
20228
|
+
if (!Object.isExtensible(value)) Object.preventExtensions(copy);
|
|
20229
|
+
return copy;
|
|
20230
|
+
}
|
|
20065
20231
|
if (isSandboxClosure(value)) {
|
|
20066
20232
|
if (options.wrapClosure === void 0) {
|
|
20067
20233
|
throw new TypeError(
|
|
@@ -20177,6 +20343,16 @@ function allocateSandboxValue2(value, budget, seen) {
|
|
|
20177
20343
|
budget.allocateString(value);
|
|
20178
20344
|
return;
|
|
20179
20345
|
}
|
|
20346
|
+
if (isFloat32Array(value)) {
|
|
20347
|
+
if (seen.has(value)) return;
|
|
20348
|
+
seen.add(value);
|
|
20349
|
+
budget.allocateArrayLength(Math.ceil(float32Storage(value).byteLength / 4));
|
|
20350
|
+
for (const [key, descriptor] of float32DataProperties(value)) {
|
|
20351
|
+
budget.allocateString(key);
|
|
20352
|
+
allocateSandboxValue2(descriptor.value, budget, seen);
|
|
20353
|
+
}
|
|
20354
|
+
return;
|
|
20355
|
+
}
|
|
20180
20356
|
if (Array.isArray(value)) {
|
|
20181
20357
|
if (seen.has(value)) {
|
|
20182
20358
|
return;
|
|
@@ -20312,6 +20488,7 @@ var MissingReplayCapabilityError = class extends TypeError {
|
|
|
20312
20488
|
function encodeReplayData(value, options = {}) {
|
|
20313
20489
|
const nodes = [];
|
|
20314
20490
|
const seen = /* @__PURE__ */ new WeakMap();
|
|
20491
|
+
const float32Buffers = /* @__PURE__ */ new WeakMap();
|
|
20315
20492
|
const encode = (entry, depth, path) => {
|
|
20316
20493
|
if (depth > MAX_DATA_DEPTH) throw new TypeError("Replay data exceeds the nesting limit.");
|
|
20317
20494
|
if (entry === null || typeof entry === "boolean" || typeof entry === "string") return entry;
|
|
@@ -20352,6 +20529,21 @@ function encodeReplayData(value, options = {}) {
|
|
|
20352
20529
|
id: capabilityId,
|
|
20353
20530
|
properties: child(entry.properties, "properties")
|
|
20354
20531
|
};
|
|
20532
|
+
} else if (isFloat32Array(entry)) {
|
|
20533
|
+
const storage = encodeFloat32Storage(entry, id, float32Buffers, (id2) => ({
|
|
20534
|
+
tag: "ref",
|
|
20535
|
+
id: id2
|
|
20536
|
+
}));
|
|
20537
|
+
const properties = /* @__PURE__ */ Object.create(null);
|
|
20538
|
+
for (const [key, descriptor] of float32DataProperties(entry)) {
|
|
20539
|
+
properties[key] = {
|
|
20540
|
+
value: child(descriptor.value, key),
|
|
20541
|
+
configurable: descriptor.configurable === true,
|
|
20542
|
+
enumerable: descriptor.enumerable === true,
|
|
20543
|
+
writable: descriptor.writable === true
|
|
20544
|
+
};
|
|
20545
|
+
}
|
|
20546
|
+
nodes[id] = { ...storage, properties, extensible: Object.isExtensible(entry) };
|
|
20355
20547
|
} else if (isSandboxMap(entry)) {
|
|
20356
20548
|
nodes[id] = {
|
|
20357
20549
|
kind: "map",
|
|
@@ -20484,6 +20676,15 @@ function decodeReplayData(input, options = {}) {
|
|
|
20484
20676
|
options.onCapabilityRestored?.(capability, copy);
|
|
20485
20677
|
return copy;
|
|
20486
20678
|
}
|
|
20679
|
+
if (kind === "float32array") {
|
|
20680
|
+
if (typeof node.extensible !== "boolean")
|
|
20681
|
+
throw new TypeError("Invalid Float32Array extensibility.");
|
|
20682
|
+
const result2 = decodeFloat32Storage(node, child);
|
|
20683
|
+
restored.set(id, result2);
|
|
20684
|
+
defineProperties(result2, record(own(node, "properties")), child);
|
|
20685
|
+
if (!node.extensible) Object.preventExtensions(result2);
|
|
20686
|
+
return result2;
|
|
20687
|
+
}
|
|
20487
20688
|
if (kind === "map") {
|
|
20488
20689
|
const result2 = createSandboxMap();
|
|
20489
20690
|
restored.set(id, result2);
|
|
@@ -21117,6 +21318,22 @@ function normalize(value, seen) {
|
|
|
21117
21318
|
if (seen.has(value)) throw new TypeError("Host call arguments cannot contain cycles.");
|
|
21118
21319
|
seen.add(value);
|
|
21119
21320
|
try {
|
|
21321
|
+
if (isFloat32Array(value)) {
|
|
21322
|
+
const storage = float32Storage(value);
|
|
21323
|
+
const properties = /* @__PURE__ */ Object.create(null);
|
|
21324
|
+
for (const [key, descriptor] of float32DataProperties(value).sort(
|
|
21325
|
+
([left], [right]) => left < right ? -1 : left > right ? 1 : 0
|
|
21326
|
+
)) {
|
|
21327
|
+
defineOwnDataProperty(properties, key, normalize(descriptor.value, seen));
|
|
21328
|
+
}
|
|
21329
|
+
return Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
21330
|
+
$type: "float32array",
|
|
21331
|
+
bytes: normalize(Array.from(new Uint8Array(storage.buffer)), seen),
|
|
21332
|
+
byteOffset: storage.byteOffset,
|
|
21333
|
+
length: storage.length,
|
|
21334
|
+
properties
|
|
21335
|
+
});
|
|
21336
|
+
}
|
|
21120
21337
|
if (Array.isArray(value)) {
|
|
21121
21338
|
const normalized2 = new Array(value.length);
|
|
21122
21339
|
Object.setPrototypeOf(normalized2, null);
|
|
@@ -22637,6 +22854,27 @@ function copyHostValueToSandbox(value, stackFrames, options, state, path) {
|
|
|
22637
22854
|
state
|
|
22638
22855
|
);
|
|
22639
22856
|
}
|
|
22857
|
+
if (isFloat32Array(value)) {
|
|
22858
|
+
const existing = state.seen.get(value);
|
|
22859
|
+
if (existing !== void 0) return existing;
|
|
22860
|
+
checkFloat32Allocation(Math.ceil(float32Storage(value).byteLength / 4), budget);
|
|
22861
|
+
const copy = copyFloat32Storage(value, state);
|
|
22862
|
+
state.seen.set(value, copy);
|
|
22863
|
+
for (const [key, descriptor] of float32DataProperties(value)) {
|
|
22864
|
+
Object.defineProperty(copy, key, {
|
|
22865
|
+
...descriptor,
|
|
22866
|
+
value: copyHostValueToSandbox(
|
|
22867
|
+
descriptor.value,
|
|
22868
|
+
stackFrames,
|
|
22869
|
+
{ ...options, capabilityPath: [...options.capabilityPath ?? [], key] },
|
|
22870
|
+
state,
|
|
22871
|
+
joinPath2(path, key)
|
|
22872
|
+
)
|
|
22873
|
+
});
|
|
22874
|
+
}
|
|
22875
|
+
if (!Object.isExtensible(value)) Object.preventExtensions(copy);
|
|
22876
|
+
return copy;
|
|
22877
|
+
}
|
|
22640
22878
|
if (!options.errorData && isPromiseLike3(value)) {
|
|
22641
22879
|
if (options.proofFunctions !== void 0)
|
|
22642
22880
|
throw new TypeError(`Unsupported proof value at ${path}: promise`);
|
|
@@ -23658,6 +23896,131 @@ function createBudgetedSet(values, budget) {
|
|
|
23658
23896
|
return createSandboxSet(values);
|
|
23659
23897
|
}
|
|
23660
23898
|
|
|
23899
|
+
// packages/safejs/src/interp/globals/float32array.ts
|
|
23900
|
+
var constructors = /* @__PURE__ */ new WeakSet();
|
|
23901
|
+
function createFloat32ArrayGlobal(budget) {
|
|
23902
|
+
const constructor = createSandboxClosure({
|
|
23903
|
+
sandbox: true,
|
|
23904
|
+
name: "Float32Array",
|
|
23905
|
+
length: 3,
|
|
23906
|
+
properties: { BYTES_PER_ELEMENT: 4 },
|
|
23907
|
+
call: () => {
|
|
23908
|
+
throw new TypeError("Constructor Float32Array requires 'new'.");
|
|
23909
|
+
},
|
|
23910
|
+
construct: ([source]) => {
|
|
23911
|
+
if (Array.isArray(source) || isFloat32Array(source)) {
|
|
23912
|
+
const length2 = isFloat32Array(source) ? float32Storage(source).length : source.length;
|
|
23913
|
+
checkFloat32Allocation(length2, budget);
|
|
23914
|
+
if (isFloat32Array(source)) return new Float32Array(source);
|
|
23915
|
+
const result = new Float32Array(length2);
|
|
23916
|
+
for (let index = 0; index < length2; index += 1) {
|
|
23917
|
+
budget.visitNode();
|
|
23918
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, index);
|
|
23919
|
+
if (descriptor !== void 0 && !("value" in descriptor))
|
|
23920
|
+
throw new TypeError("Float32Array input accessors are not supported.");
|
|
23921
|
+
result[index] = float32Number(descriptor?.value);
|
|
23922
|
+
}
|
|
23923
|
+
return result;
|
|
23924
|
+
}
|
|
23925
|
+
const number = float32Number(source);
|
|
23926
|
+
const length = Number.isNaN(number) ? 0 : Math.trunc(number);
|
|
23927
|
+
if (length < 0 || !Number.isSafeInteger(length))
|
|
23928
|
+
throw new RangeError("Invalid typed array length.");
|
|
23929
|
+
checkFloat32Allocation(length, budget);
|
|
23930
|
+
return new Float32Array(length);
|
|
23931
|
+
}
|
|
23932
|
+
});
|
|
23933
|
+
constructors.add(constructor);
|
|
23934
|
+
return constructor;
|
|
23935
|
+
}
|
|
23936
|
+
function isFloat32ArrayConstructor(value) {
|
|
23937
|
+
return typeof value === "object" && value !== null && constructors.has(value);
|
|
23938
|
+
}
|
|
23939
|
+
function getFloat32Member(value, property, budget) {
|
|
23940
|
+
const key = String(property);
|
|
23941
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
23942
|
+
if (descriptor !== void 0) {
|
|
23943
|
+
if (!("value" in descriptor)) throw new TypeError("Float32Array accessors are not supported.");
|
|
23944
|
+
return descriptor.value;
|
|
23945
|
+
}
|
|
23946
|
+
const storage = float32Storage(value);
|
|
23947
|
+
if (key === "length") return storage.length;
|
|
23948
|
+
if (key === "byteLength") return storage.length * 4;
|
|
23949
|
+
if (key === "byteOffset") return storage.byteOffset;
|
|
23950
|
+
if (key === "BYTES_PER_ELEMENT") return 4;
|
|
23951
|
+
if (!["set", "slice", "subarray"].includes(key)) return void 0;
|
|
23952
|
+
return createSandboxClosure({
|
|
23953
|
+
sandbox: true,
|
|
23954
|
+
name: key,
|
|
23955
|
+
length: key === "set" ? 1 : 2,
|
|
23956
|
+
call: (args, context) => {
|
|
23957
|
+
const receiver = context?.thisValue;
|
|
23958
|
+
if (!isFloat32Array(receiver))
|
|
23959
|
+
throw new TypeError(`Float32Array#${key} requires a Float32Array receiver.`);
|
|
23960
|
+
const storage2 = float32Storage(receiver);
|
|
23961
|
+
if (key === "set") {
|
|
23962
|
+
const [source, offsetValue = 0] = args;
|
|
23963
|
+
if (!Array.isArray(source) && !isFloat32Array(source))
|
|
23964
|
+
throw new TypeError("Float32Array#set requires an array or Float32Array.");
|
|
23965
|
+
const number = float32Number(offsetValue);
|
|
23966
|
+
const offset = Number.isNaN(number) ? 0 : Math.trunc(number);
|
|
23967
|
+
const length2 = isFloat32Array(source) ? float32Storage(source).length : source.length;
|
|
23968
|
+
if (offset < 0 || !Number.isSafeInteger(offset) || offset + length2 > storage2.length)
|
|
23969
|
+
throw new RangeError("Float32Array#set source is out of bounds.");
|
|
23970
|
+
if (isFloat32Array(source)) {
|
|
23971
|
+
Float32Array.prototype.set.call(receiver, source, offset);
|
|
23972
|
+
return void 0;
|
|
23973
|
+
}
|
|
23974
|
+
checkFloat32Allocation(length2, budget);
|
|
23975
|
+
const copied = new Float32Array(length2);
|
|
23976
|
+
for (let index = 0; index < length2; index += 1) {
|
|
23977
|
+
budget.visitNode();
|
|
23978
|
+
const entry = Object.getOwnPropertyDescriptor(source, index);
|
|
23979
|
+
if (entry !== void 0 && !("value" in entry))
|
|
23980
|
+
throw new TypeError("Float32Array input accessors are not supported.");
|
|
23981
|
+
copied[index] = float32Number(entry?.value);
|
|
23982
|
+
}
|
|
23983
|
+
Float32Array.prototype.set.call(receiver, copied, offset);
|
|
23984
|
+
return void 0;
|
|
23985
|
+
}
|
|
23986
|
+
const start = relativeIndex(args[0], storage2.length, 0);
|
|
23987
|
+
const end = relativeIndex(args[1], storage2.length, storage2.length);
|
|
23988
|
+
const length = Math.max(end - start, 0);
|
|
23989
|
+
if (key === "subarray")
|
|
23990
|
+
return new Float32Array(storage2.buffer, storage2.byteOffset + start * 4, length);
|
|
23991
|
+
checkFloat32Allocation(length, budget);
|
|
23992
|
+
const result = new Float32Array(length);
|
|
23993
|
+
new Uint8Array(result.buffer).set(
|
|
23994
|
+
new Uint8Array(storage2.buffer, storage2.byteOffset + start * 4, length * 4)
|
|
23995
|
+
);
|
|
23996
|
+
return result;
|
|
23997
|
+
}
|
|
23998
|
+
});
|
|
23999
|
+
}
|
|
24000
|
+
function setFloat32Member(value, property, entry) {
|
|
24001
|
+
const key = String(property);
|
|
24002
|
+
if (isFloat32Index(key)) {
|
|
24003
|
+
Reflect.set(value, key, float32Number(entry));
|
|
24004
|
+
return;
|
|
24005
|
+
}
|
|
24006
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
24007
|
+
if (descriptor === void 0 && ["length", "byteLength", "byteOffset", "buffer", "BYTES_PER_ELEMENT"].includes(key))
|
|
24008
|
+
throw new TypeError(`Cannot assign to read only property '${key}'.`);
|
|
24009
|
+
if (descriptor !== void 0 && (!("value" in descriptor) || !descriptor.writable))
|
|
24010
|
+
throw new TypeError(`Cannot assign to read only property '${key}'.`);
|
|
24011
|
+
Object.defineProperty(
|
|
24012
|
+
value,
|
|
24013
|
+
key,
|
|
24014
|
+
descriptor === void 0 ? { value: entry, configurable: true, enumerable: true, writable: true } : { value: entry }
|
|
24015
|
+
);
|
|
24016
|
+
}
|
|
24017
|
+
function relativeIndex(value, length, fallback) {
|
|
24018
|
+
if (value === void 0) return fallback;
|
|
24019
|
+
const numeric = float32Number(value);
|
|
24020
|
+
const integer = Number.isNaN(numeric) ? 0 : Math.trunc(numeric);
|
|
24021
|
+
return integer < 0 ? Math.max(length + integer, 0) : Math.min(integer, length);
|
|
24022
|
+
}
|
|
24023
|
+
|
|
23661
24024
|
// packages/safejs/src/interp/globals/error.ts
|
|
23662
24025
|
var errorConstructorNames = /* @__PURE__ */ new WeakMap();
|
|
23663
24026
|
var errorNames = [
|
|
@@ -23993,6 +24356,10 @@ function assignSandboxValues(target, sources) {
|
|
|
23993
24356
|
continue;
|
|
23994
24357
|
}
|
|
23995
24358
|
for (const [key, value] of getOwnEnumerableEntries(source)) {
|
|
24359
|
+
if (isFloat32Array(target)) {
|
|
24360
|
+
setFloat32Member(target, key, value);
|
|
24361
|
+
continue;
|
|
24362
|
+
}
|
|
23996
24363
|
Object.defineProperty(target, key, {
|
|
23997
24364
|
configurable: true,
|
|
23998
24365
|
enumerable: true,
|
|
@@ -26941,7 +27308,7 @@ function forInObject(value) {
|
|
|
26941
27308
|
if (value === null || value === void 0 || isSandboxClosure(value) || isSandboxPromise(value)) {
|
|
26942
27309
|
return void 0;
|
|
26943
27310
|
}
|
|
26944
|
-
if (typeof value === "string" || Array.isArray(value) || isPlainForInObject(value)) {
|
|
27311
|
+
if (typeof value === "string" || Array.isArray(value) || isFloat32Array(value) || isPlainForInObject(value)) {
|
|
26945
27312
|
return Object(value);
|
|
26946
27313
|
}
|
|
26947
27314
|
return void 0;
|
|
@@ -27443,6 +27810,7 @@ function getPropertyValue(target, property, context) {
|
|
|
27443
27810
|
if (typeof target === "string") return getStringMember(target, property, context.budget);
|
|
27444
27811
|
if (typeof target === "number") return getNumberMember(target, property, context.budget);
|
|
27445
27812
|
if (typeof target === "boolean") return void 0;
|
|
27813
|
+
if (isFloat32Array(target)) return getFloat32Member(target, property, context.budget);
|
|
27446
27814
|
if (isSandboxMap(target)) return getMapMember(target, property, createMapMethodOptions(context));
|
|
27447
27815
|
if (isSandboxSet(target)) return getSetMember(target, property, createSetMethodOptions(context));
|
|
27448
27816
|
if (isSandboxGenerator(target)) return getGeneratorMember(target, property, context.budget);
|
|
@@ -27671,6 +28039,14 @@ async function evaluateMemberCallExpression(node, context) {
|
|
|
27671
28039
|
context
|
|
27672
28040
|
);
|
|
27673
28041
|
}
|
|
28042
|
+
if (isFloat32Array(member.object)) {
|
|
28043
|
+
return evaluateResolvedCallExpression(
|
|
28044
|
+
node,
|
|
28045
|
+
getFloat32Member(member.object, member.property, context.budget),
|
|
28046
|
+
context,
|
|
28047
|
+
member.object
|
|
28048
|
+
);
|
|
28049
|
+
}
|
|
27674
28050
|
if (isSandboxSet(member.object)) {
|
|
27675
28051
|
return evaluatePrimitiveMemberCall(
|
|
27676
28052
|
node,
|
|
@@ -27913,6 +28289,7 @@ function applyBinaryOperator(node, left, right, context) {
|
|
|
27913
28289
|
if (isSandboxMapConstructor(right) && isSandboxMap(left)) {
|
|
27914
28290
|
return true;
|
|
27915
28291
|
}
|
|
28292
|
+
if (isFloat32ArrayConstructor(right)) return isFloat32Array(left);
|
|
27916
28293
|
if (isSandboxSetConstructor(right) && isSandboxSet(left)) {
|
|
27917
28294
|
return true;
|
|
27918
28295
|
}
|
|
@@ -28131,6 +28508,10 @@ function getArrayMemberValue(target, property, context) {
|
|
|
28131
28508
|
return getArrayMember(target, property, createArrayMethodOptions(context));
|
|
28132
28509
|
}
|
|
28133
28510
|
function setSandboxProperty(target, property, value) {
|
|
28511
|
+
if (isFloat32Array(target)) {
|
|
28512
|
+
setFloat32Member(target, property, value);
|
|
28513
|
+
return;
|
|
28514
|
+
}
|
|
28134
28515
|
if (isSandboxRegex(target)) {
|
|
28135
28516
|
setRegexMember(target, property, value);
|
|
28136
28517
|
return;
|
|
@@ -28797,6 +29178,7 @@ function run(source, options = {}) {
|
|
|
28797
29178
|
sink: options.sink
|
|
28798
29179
|
}),
|
|
28799
29180
|
...createCollectionGlobals({ budget }),
|
|
29181
|
+
Float32Array: createFloat32ArrayGlobal(budget),
|
|
28800
29182
|
...createErrorGlobals({
|
|
28801
29183
|
budget
|
|
28802
29184
|
}),
|
|
@@ -29294,4 +29676,4 @@ export {
|
|
|
29294
29676
|
FileSnapshotBackend,
|
|
29295
29677
|
run
|
|
29296
29678
|
};
|
|
29297
|
-
//# sourceMappingURL=chunk-
|
|
29679
|
+
//# sourceMappingURL=chunk-XBRQ72W6.js.map
|