poe-code 14.0.83 → 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 +588 -93
- 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-37V6Q4K3.js → chunk-2EZQJQ2C.js} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-PT7PBLVT.js → chunk-CYVI4ZUK.js} +536 -85
- 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.d.ts +6 -1
- package/packages/safe-js/dist/interp/float32.js +38 -10
- 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 +1 -1
- package/packages/safe-js/dist/interp/globals/float32array.js +104 -15
- package/packages/safe-js/dist/interp/globals.d.ts +1 -0
- package/packages/safe-js/dist/interp/globals.js +2 -0
- 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/methods/array-iterator.js +1 -1
- package/packages/safe-js/dist/interp/object-model.js +6 -0
- package/packages/safe-js/dist/interp/values.d.ts +1 -1
- package/packages/safe-js/dist/interp/values.js +47 -5
- 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/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 +8 -1
- package/packages/safe-js/dist/snapshot/float32array.js +23 -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 +13 -1
- package/packages/safe-js/dist/snapshot/serialize.d.ts +5 -2
- package/packages/safe-js/dist/snapshot/serialize.js +20 -11
- package/packages/safe-js/dist/snapshot/validation.js +11 -1
- package/packages/safe-js/dist/chunks/chunk-PT7PBLVT.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-37V6Q4K3.js.map → chunk-2EZQJQ2C.js.map} +0 -0
|
@@ -11,8 +11,10 @@ import { captureGuestHeapNode } from "./guest-heap.js";
|
|
|
11
11
|
import { getGeneratorOrigin } from "../interp/closure-origin.js";
|
|
12
12
|
import { serializeArguments } from "./arguments.js";
|
|
13
13
|
import { requiresArrayEntries, serializeArray } from "./arrays.js";
|
|
14
|
-
import { isFloat32Array } from "../interp/float32.js";
|
|
15
|
-
import { captureFloat32State,
|
|
14
|
+
import { float32Storage, isFloat32Array } from "../interp/float32.js";
|
|
15
|
+
import { captureFloat32State, encodeFloat32Layout } from "./float32array.js";
|
|
16
|
+
import { isSandboxArrayBuffer } from "../interp/array-buffer.js";
|
|
17
|
+
import { captureArrayBufferState, encodeArrayBufferStorage } from "./array-buffer.js";
|
|
16
18
|
import { dateDataProperties, isSandboxDate } from "../interp/date.js";
|
|
17
19
|
import { serializeDate } from "./date-properties.js";
|
|
18
20
|
import { boxedDataProperties, isSandboxBox } from "../interp/boxed.js";
|
|
@@ -104,7 +106,7 @@ function serializeValue(value, path, state) {
|
|
|
104
106
|
}
|
|
105
107
|
return { kind: "ref", id };
|
|
106
108
|
}
|
|
107
|
-
if (typeof value === "object" && value !== null && hasGuestObjectState(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isFloat32Array(value)) {
|
|
109
|
+
if (typeof value === "object" && value !== null && hasGuestObjectState(value) && !isSandboxMap(value) && !isSandboxSet(value) && !isFloat32Array(value) && !isSandboxArrayBuffer(value)) {
|
|
108
110
|
throw new TypeError("Guest function properties and prototype links cannot be serialized.");
|
|
109
111
|
}
|
|
110
112
|
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
@@ -197,7 +199,7 @@ function serializeValue(value, path, state) {
|
|
|
197
199
|
throw new TypeError(`Missing regex heap reference at ${path}.`);
|
|
198
200
|
return { kind: "regex", source: value.source, flags: value.flags, lastIndex: value.lastIndex };
|
|
199
201
|
}
|
|
200
|
-
if (isSandboxBox(value) || isSandboxDate(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxRegExpIterator(value) || isSandboxCollectionIterator(value) || isFloat32Array(value)) {
|
|
202
|
+
if (isSandboxArrayBuffer(value) || isSandboxBox(value) || isSandboxDate(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxRegExpIterator(value) || isSandboxCollectionIterator(value) || isFloat32Array(value)) {
|
|
201
203
|
const reference = serializeHeapReference(value, path, state);
|
|
202
204
|
if (reference === undefined) {
|
|
203
205
|
throw new TypeError(`Cannot serialize collection without a heap reference at ${path}.`);
|
|
@@ -260,12 +262,14 @@ function serializeHeapReference(value, path, state) {
|
|
|
260
262
|
else if (isSandboxDate(value)) {
|
|
261
263
|
state.heap[String(id)] = serializeDate(value, entry => serializeValue(entry, `${path}.<date-property>`, state));
|
|
262
264
|
}
|
|
265
|
+
else if (isSandboxArrayBuffer(value)) {
|
|
266
|
+
state.heap[String(id)] = { ...encodeArrayBufferStorage(value, id, state.float32Buffers, id => ({ kind: "ref", id })),
|
|
267
|
+
state: captureArrayBufferState(value, entry => serializeValue(entry, `${path}.<buffer>`, state)) };
|
|
268
|
+
}
|
|
263
269
|
else if (isFloat32Array(value)) {
|
|
264
|
-
const storage =
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}));
|
|
268
|
-
state.heap[String(id)] = { ...storage, entries: {},
|
|
270
|
+
const storage = float32Storage(value);
|
|
271
|
+
state.heap[String(id)] = { kind: "float32array", ...encodeFloat32Layout(value),
|
|
272
|
+
buffer: serializeHeapReference(storage.buffer, `${path}.buffer`, state), entries: {},
|
|
269
273
|
state: captureFloat32State(value, entry => serializeValue(entry, `${path}.<typed-array>`, state)) };
|
|
270
274
|
}
|
|
271
275
|
else if (isSandboxArguments(value)) {
|
|
@@ -387,6 +391,7 @@ function indexHeapContainers(input) {
|
|
|
387
391
|
isSandboxBox(value) ||
|
|
388
392
|
isSandboxDate(value) ||
|
|
389
393
|
isFloat32Array(value) ||
|
|
394
|
+
isSandboxArrayBuffer(value) ||
|
|
390
395
|
(Array.isArray(value) && requiresArrayEntries(value)) ||
|
|
391
396
|
sandboxErrorTypes.has(value) ||
|
|
392
397
|
isSandboxArguments(value) ||
|
|
@@ -429,11 +434,15 @@ function collectContainerStats(value, stats, ancestors, guestValues, depth = 0)
|
|
|
429
434
|
stat.expanded = true;
|
|
430
435
|
ancestors.add(value);
|
|
431
436
|
const guestEntries = [];
|
|
437
|
+
if (isFloat32Array(value))
|
|
438
|
+
guestEntries.push(float32Storage(value).buffer);
|
|
432
439
|
const guest = isFloat32Array(value)
|
|
433
440
|
? { kind: "float32array", state: captureFloat32State(value, entry => { guestEntries.push(entry); return null; }) }
|
|
434
|
-
:
|
|
441
|
+
: isSandboxArrayBuffer(value)
|
|
442
|
+
? { kind: "arraybuffer", state: captureArrayBufferState(value, entry => { guestEntries.push(entry); return null; }) }
|
|
443
|
+
: captureGuestHeapNode(value, entry => { guestEntries.push(entry); return null; });
|
|
435
444
|
if (guest !== undefined) {
|
|
436
|
-
if (!isFloat32Array(value))
|
|
445
|
+
if (!isFloat32Array(value) && !isSandboxArrayBuffer(value))
|
|
437
446
|
guestValues.add(value);
|
|
438
447
|
for (const entry of guestEntries) {
|
|
439
448
|
collectContainerStats(entry, stats, ancestors, guestValues, depth + 1);
|
|
@@ -6,6 +6,7 @@ import { types } from "node:util";
|
|
|
6
6
|
import { DUMP_FORMAT_VERSION } from "./dump-format.js";
|
|
7
7
|
import { MAX_DATA_DEPTH } from "../graph-depth.js";
|
|
8
8
|
import { validateFloat32Storage } from "./float32array.js";
|
|
9
|
+
import { validateArrayBufferStorage } from "./array-buffer.js";
|
|
9
10
|
import { restoreDateTime } from "../interp/date.js";
|
|
10
11
|
import { validateBoxedProperties } from "./boxed.js";
|
|
11
12
|
import { hasGuestObjectState } from "../interp/object-model.js";
|
|
@@ -117,6 +118,11 @@ function validateDumpHeap(root, state) {
|
|
|
117
118
|
validateDateRecord(entry, path);
|
|
118
119
|
continue;
|
|
119
120
|
}
|
|
121
|
+
if (entry.kind === "arraybuffer") {
|
|
122
|
+
validateArrayBufferStorage(entry);
|
|
123
|
+
validateGuestHeapNode({ kind: "guest-object", state: entry.state }, heap, state.limits.maxEntries);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
120
126
|
if (entry.kind === "float32array") {
|
|
121
127
|
validateFloat32Storage(entry);
|
|
122
128
|
requireRecord(entry.entries, `${path}.entries`);
|
|
@@ -538,7 +544,7 @@ function validateHeapValue(value, path, state, heap) {
|
|
|
538
544
|
fail("invalidValue", path, String(error));
|
|
539
545
|
}
|
|
540
546
|
validateErrorType(record, path);
|
|
541
|
-
if (!["symbol", "arguments", "array", "object", "map", "set", "float32array", "date", "boxed", "collection-iterator", "regexp-iterator", "regex-object"].includes(String(record.kind)))
|
|
547
|
+
if (!["symbol", "arguments", "array", "object", "map", "set", "float32array", "arraybuffer", "date", "boxed", "collection-iterator", "regexp-iterator", "regex-object"].includes(String(record.kind)))
|
|
542
548
|
fail("unknownTag", `${path}.kind`, "unknown heap tag");
|
|
543
549
|
validateValue(record, path, 1, state);
|
|
544
550
|
if (record.kind === "symbol")
|
|
@@ -553,6 +559,10 @@ function validateHeapValue(value, path, state, heap) {
|
|
|
553
559
|
validateBoxedRecord(record, path, heap);
|
|
554
560
|
if (record.kind === "date")
|
|
555
561
|
validateDateRecord(record, path);
|
|
562
|
+
if (record.kind === "arraybuffer") {
|
|
563
|
+
validateArrayBufferStorage(record);
|
|
564
|
+
validateGuestHeapNode({ kind: "guest-object", state: record.state }, heap, state.limits.maxEntries);
|
|
565
|
+
}
|
|
556
566
|
if (record.kind === "float32array") {
|
|
557
567
|
validateFloat32Storage(record);
|
|
558
568
|
requireRecord(record.entries, `${path}.entries`);
|