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.
Files changed (42) hide show
  1. package/dist/index.js +588 -93
  2. package/dist/index.js.map +4 -4
  3. package/dist/metafile.json +1 -1
  4. package/package.json +1 -1
  5. package/packages/safe-js/dist/chunks/{chunk-37V6Q4K3.js → chunk-2EZQJQ2C.js} +2 -2
  6. package/packages/safe-js/dist/chunks/{chunk-PT7PBLVT.js → chunk-CYVI4ZUK.js} +536 -85
  7. package/packages/safe-js/dist/chunks/chunk-CYVI4ZUK.js.map +7 -0
  8. package/packages/safe-js/dist/cli.js +2 -2
  9. package/packages/safe-js/dist/core.js +1 -1
  10. package/packages/safe-js/dist/index.js +2 -2
  11. package/packages/safe-js/dist/interp/array-buffer.d.ts +12 -0
  12. package/packages/safe-js/dist/interp/array-buffer.js +33 -0
  13. package/packages/safe-js/dist/interp/float32.d.ts +6 -1
  14. package/packages/safe-js/dist/interp/float32.js +38 -10
  15. package/packages/safe-js/dist/interp/globals/array-buffer.d.ts +3 -0
  16. package/packages/safe-js/dist/interp/globals/array-buffer.js +112 -0
  17. package/packages/safe-js/dist/interp/globals/float32array.d.ts +1 -1
  18. package/packages/safe-js/dist/interp/globals/float32array.js +104 -15
  19. package/packages/safe-js/dist/interp/globals.d.ts +1 -0
  20. package/packages/safe-js/dist/interp/globals.js +2 -0
  21. package/packages/safe-js/dist/interp/host-bridge.d.ts +1 -0
  22. package/packages/safe-js/dist/interp/host-bridge.js +21 -0
  23. package/packages/safe-js/dist/interp/host-call.js +26 -2
  24. package/packages/safe-js/dist/interp/methods/array-iterator.js +1 -1
  25. package/packages/safe-js/dist/interp/object-model.js +6 -0
  26. package/packages/safe-js/dist/interp/values.d.ts +1 -1
  27. package/packages/safe-js/dist/interp/values.js +47 -5
  28. package/packages/safe-js/dist/lint/rules/known-globals.d.ts +1 -1
  29. package/packages/safe-js/dist/lint/rules/known-globals.js +1 -0
  30. package/packages/safe-js/dist/snapshot/array-buffer.d.ts +13 -0
  31. package/packages/safe-js/dist/snapshot/array-buffer.js +40 -0
  32. package/packages/safe-js/dist/snapshot/dump-format.js +25 -9
  33. package/packages/safe-js/dist/snapshot/float32array.d.ts +8 -1
  34. package/packages/safe-js/dist/snapshot/float32array.js +23 -5
  35. package/packages/safe-js/dist/snapshot/replay-data.d.ts +5 -0
  36. package/packages/safe-js/dist/snapshot/replay-data.js +35 -10
  37. package/packages/safe-js/dist/snapshot/restore.js +13 -1
  38. package/packages/safe-js/dist/snapshot/serialize.d.ts +5 -2
  39. package/packages/safe-js/dist/snapshot/serialize.js +20 -11
  40. package/packages/safe-js/dist/snapshot/validation.js +11 -1
  41. package/packages/safe-js/dist/chunks/chunk-PT7PBLVT.js.map +0 -7
  42. /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, encodeFloat32Storage } from "./float32array.js";
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 = encodeFloat32Storage(value, id, state.float32Buffers, (id) => ({
265
- kind: "ref",
266
- id
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
- : captureGuestHeapNode(value, entry => { guestEntries.push(entry); return null; });
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`);