poe-code 14.0.62 → 14.0.63
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 +929 -504
- 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-F7TJSPDZ.js → chunk-KMTTD3BL.js} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-VKGWGZBH.js → chunk-RU2BCN4G.js} +898 -521
- package/packages/safe-js/dist/chunks/chunk-RU2BCN4G.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/graph-depth.js +3 -0
- package/packages/safe-js/dist/index.js +2 -2
- package/packages/safe-js/dist/interp/boxed.d.ts +14 -0
- package/packages/safe-js/dist/interp/boxed.js +50 -0
- package/packages/safe-js/dist/interp/globals/collections.js +4 -4
- package/packages/safe-js/dist/interp/globals/console-json.js +15 -18
- package/packages/safe-js/dist/interp/globals/misc.js +1 -1
- package/packages/safe-js/dist/interp/globals/object-array.js +19 -14
- package/packages/safe-js/dist/interp/globals/object.js +10 -5
- package/packages/safe-js/dist/interp/globals/primitives.d.ts +8 -0
- package/packages/safe-js/dist/interp/globals/primitives.js +69 -0
- package/packages/safe-js/dist/interp/host-bridge.js +22 -0
- package/packages/safe-js/dist/interp/interpreter.js +172 -120
- package/packages/safe-js/dist/interp/iteration.d.ts +5 -3
- package/packages/safe-js/dist/interp/iteration.js +22 -1
- package/packages/safe-js/dist/interp/methods/array.js +6 -3
- package/packages/safe-js/dist/interp/methods/number.d.ts +1 -0
- package/packages/safe-js/dist/interp/methods/number.js +4 -1
- package/packages/safe-js/dist/interp/methods/string.d.ts +2 -0
- package/packages/safe-js/dist/interp/methods/string.js +2 -2
- package/packages/safe-js/dist/interp/object-model.d.ts +5 -0
- package/packages/safe-js/dist/interp/object-model.js +41 -3
- package/packages/safe-js/dist/interp/promise.js +68 -61
- package/packages/safe-js/dist/interp/string-coercion.js +4 -1
- package/packages/safe-js/dist/interp/values.d.ts +1 -0
- package/packages/safe-js/dist/interp/values.js +78 -3
- package/packages/safe-js/dist/migrate.d.ts +2 -2
- package/packages/safe-js/dist/migration-file.d.ts +4 -4
- package/packages/safe-js/dist/snapshot/boxed.d.ts +16 -0
- package/packages/safe-js/dist/snapshot/boxed.js +52 -0
- package/packages/safe-js/dist/snapshot/dump-format.js +18 -5
- package/packages/safe-js/dist/snapshot/replay-data.d.ts +5 -0
- package/packages/safe-js/dist/snapshot/replay-data.js +24 -0
- package/packages/safe-js/dist/snapshot/restore.js +8 -0
- package/packages/safe-js/dist/snapshot/serialize.d.ts +4 -2
- package/packages/safe-js/dist/snapshot/serialize.js +18 -10
- package/packages/safe-js/dist/snapshot/validation.js +22 -1
- package/packages/safe-js/dist/chunks/chunk-VKGWGZBH.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-F7TJSPDZ.js.map → chunk-KMTTD3BL.js.map} +0 -0
|
@@ -8,6 +8,8 @@ import { requiresArrayEntries, serializeArray } from "./arrays.js";
|
|
|
8
8
|
import { float32DataProperties, isFloat32Array } from "../interp/float32.js";
|
|
9
9
|
import { encodeFloat32Storage } from "./float32array.js";
|
|
10
10
|
import { isSandboxDate, serializedDateTime } from "../interp/date.js";
|
|
11
|
+
import { boxedDataProperties, isSandboxBox } from "../interp/boxed.js";
|
|
12
|
+
import { encodeBoxedData } from "./boxed.js";
|
|
11
13
|
import { isSandboxArguments, isSandboxGenerator, isSandboxMap, isSandboxRegex, isSandboxSet } from "../interp/values.js";
|
|
12
14
|
export class UnsnapshotableValueError extends Error {
|
|
13
15
|
path;
|
|
@@ -170,7 +172,7 @@ function serializeValue(value, path, state) {
|
|
|
170
172
|
throw new TypeError(`Missing regex heap reference at ${path}.`);
|
|
171
173
|
return { kind: "regex", source: value.source, flags: value.flags, lastIndex: value.lastIndex };
|
|
172
174
|
}
|
|
173
|
-
if (isSandboxDate(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxCollectionIterator(value) || isFloat32Array(value)) {
|
|
175
|
+
if (isSandboxBox(value) || isSandboxDate(value) || isSandboxMap(value) || isSandboxSet(value) || isSandboxCollectionIterator(value) || isFloat32Array(value)) {
|
|
174
176
|
const reference = serializeHeapReference(value, path, state);
|
|
175
177
|
if (reference === undefined) {
|
|
176
178
|
throw new TypeError(`Cannot serialize collection without a heap reference at ${path}.`);
|
|
@@ -214,6 +216,9 @@ function serializeHeapReference(value, path, state) {
|
|
|
214
216
|
for (const [key, entry] of Object.entries(value))
|
|
215
217
|
entries[key] = serializeValue(entry, `${path}.${key}`, state);
|
|
216
218
|
}
|
|
219
|
+
else if (isSandboxBox(value)) {
|
|
220
|
+
state.heap[String(id)] = encodeBoxedData(value, (entry, key) => serializeValue(entry, `${path}.${key}`, state));
|
|
221
|
+
}
|
|
217
222
|
else if (isSandboxDate(value)) {
|
|
218
223
|
state.heap[String(id)] = { kind: "date", time: serializedDateTime(value) };
|
|
219
224
|
}
|
|
@@ -326,6 +331,7 @@ function indexHeapContainers(input) {
|
|
|
326
331
|
stat.cyclic ||
|
|
327
332
|
(isSandboxRegex(value) && (!Number.isSafeInteger(value.lastIndex) ||
|
|
328
333
|
(typeof value.lastIndex === "number" && value.lastIndex < 0) || Object.is(value.lastIndex, -0))) ||
|
|
334
|
+
isSandboxBox(value) ||
|
|
329
335
|
isSandboxDate(value) ||
|
|
330
336
|
isFloat32Array(value) ||
|
|
331
337
|
(Array.isArray(value) && requiresArrayEntries(value)) ||
|
|
@@ -376,15 +382,17 @@ function collectContainerStats(value, stats, ancestors) {
|
|
|
376
382
|
}
|
|
377
383
|
stat.expanded = true;
|
|
378
384
|
ancestors.add(value);
|
|
379
|
-
const entries =
|
|
380
|
-
?
|
|
381
|
-
:
|
|
382
|
-
?
|
|
383
|
-
:
|
|
384
|
-
?
|
|
385
|
-
:
|
|
386
|
-
? [...value.
|
|
387
|
-
:
|
|
385
|
+
const entries = isSandboxBox(value)
|
|
386
|
+
? boxedDataProperties(value).map(([, descriptor]) => descriptor.value)
|
|
387
|
+
: isSandboxCollectionIterator(value)
|
|
388
|
+
? [collectionIteratorState(value).collection, ...Object.values(value)]
|
|
389
|
+
: isSandboxArguments(value)
|
|
390
|
+
? Object.values(Object.getOwnPropertyDescriptors(value)).flatMap((descriptor) => "value" in descriptor ? [descriptor.value] : [])
|
|
391
|
+
: isSandboxMap(value)
|
|
392
|
+
? [...value.entries].flatMap(([key, entry]) => [key, entry])
|
|
393
|
+
: isSandboxSet(value)
|
|
394
|
+
? [...value.values]
|
|
395
|
+
: Object.values(value);
|
|
388
396
|
for (const entry of entries) {
|
|
389
397
|
collectContainerStats(entry, stats, ancestors);
|
|
390
398
|
}
|
|
@@ -4,6 +4,7 @@ import { DUMP_FORMAT_VERSION } from "./dump-format.js";
|
|
|
4
4
|
import { MAX_DATA_DEPTH } from "../graph-depth.js";
|
|
5
5
|
import { validateFloat32Storage } from "./float32array.js";
|
|
6
6
|
import { restoreDateTime } from "../interp/date.js";
|
|
7
|
+
import { validateBoxedProperties } from "./boxed.js";
|
|
7
8
|
import { hasGuestObjectState } from "../interp/object-model.js";
|
|
8
9
|
const DEFAULT_MAX_DEPTH = MAX_DATA_DEPTH;
|
|
9
10
|
const DEFAULT_MAX_ENTRIES = 100_000;
|
|
@@ -81,6 +82,10 @@ function validateDumpHeap(root, state) {
|
|
|
81
82
|
addUnique(heapIds, id, path);
|
|
82
83
|
const entry = requireRecord(value, path);
|
|
83
84
|
validateErrorType(entry, path);
|
|
85
|
+
if (entry.kind === "boxed") {
|
|
86
|
+
validateBoxedRecord(entry, path);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
84
89
|
if (entry.kind === "date") {
|
|
85
90
|
validateDateRecord(entry, path);
|
|
86
91
|
continue;
|
|
@@ -414,7 +419,7 @@ function validateGeneratorShape(record, path, state) {
|
|
|
414
419
|
function validateHeapValue(value, path, state) {
|
|
415
420
|
const record = requireRecord(value, path);
|
|
416
421
|
validateErrorType(record, path);
|
|
417
|
-
if (!["arguments", "array", "object", "map", "set", "float32array", "date", "collection-iterator", "regex-object"].includes(String(record.kind)))
|
|
422
|
+
if (!["arguments", "array", "object", "map", "set", "float32array", "date", "boxed", "collection-iterator", "regex-object"].includes(String(record.kind)))
|
|
418
423
|
fail("unknownTag", `${path}.kind`, "unknown heap tag");
|
|
419
424
|
validateValue(record, path, 1, state);
|
|
420
425
|
if (record.kind === "arguments")
|
|
@@ -423,6 +428,8 @@ function validateHeapValue(value, path, state) {
|
|
|
423
428
|
validateArrayHeap(record, path, state);
|
|
424
429
|
if (record.kind === "object")
|
|
425
430
|
requireRecord(record.entries, `${path}.entries`);
|
|
431
|
+
if (record.kind === "boxed")
|
|
432
|
+
validateBoxedRecord(record, path);
|
|
426
433
|
if (record.kind === "date")
|
|
427
434
|
validateDateRecord(record, path);
|
|
428
435
|
if (record.kind === "float32array") {
|
|
@@ -451,6 +458,20 @@ function validateHeapValue(value, path, state) {
|
|
|
451
458
|
requireRecord(record.entries, `${path}.entries`);
|
|
452
459
|
}
|
|
453
460
|
}
|
|
461
|
+
function validateBoxedRecord(record, path) {
|
|
462
|
+
try {
|
|
463
|
+
validateBoxedProperties(record);
|
|
464
|
+
}
|
|
465
|
+
catch {
|
|
466
|
+
fail("invalidValue", path, "invalid boxed primitive properties");
|
|
467
|
+
}
|
|
468
|
+
const value = record.value;
|
|
469
|
+
if (typeof value === "number" || typeof value === "string" || typeof value === "boolean")
|
|
470
|
+
return;
|
|
471
|
+
const number = requireRecord(value, `${path}.value`);
|
|
472
|
+
if (number.kind !== "number" || !["NaN", "Infinity", "-Infinity", "-0"].includes(String(number.value)))
|
|
473
|
+
fail("invalidValue", `${path}.value`, "invalid boxed primitive payload");
|
|
474
|
+
}
|
|
454
475
|
function validateDateRecord(record, path) {
|
|
455
476
|
if (Object.keys(record).length !== 2)
|
|
456
477
|
fail("invalidValue", path, "invalid Date fields");
|