poe-code 14.0.6 → 14.0.7

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 (48) hide show
  1. package/dist/index.js +454 -39
  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-2M6MNQBY.js → chunk-BWVASPJX.js} +420 -33
  6. package/packages/safe-js/dist/chunks/chunk-BWVASPJX.js.map +7 -0
  7. package/packages/safe-js/dist/chunks/{chunk-QSSQJNKE.js → chunk-ETKM3KPA.js} +2 -2
  8. package/packages/safe-js/dist/cli.js +2 -2
  9. package/packages/safe-js/dist/core.d.ts +1 -1
  10. package/packages/safe-js/dist/core.js +1 -1
  11. package/packages/safe-js/dist/extensions.d.ts +2 -0
  12. package/packages/safe-js/dist/index.d.ts +1 -1
  13. package/packages/safe-js/dist/index.js +2 -2
  14. package/packages/safe-js/dist/index.js.map +1 -1
  15. package/packages/safe-js/dist/interp/date.d.ts +19 -0
  16. package/packages/safe-js/dist/interp/date.js +129 -0
  17. package/packages/safe-js/dist/interp/globals/console-json.js +5 -1
  18. package/packages/safe-js/dist/interp/globals/date.d.ts +10 -0
  19. package/packages/safe-js/dist/interp/globals/date.js +95 -0
  20. package/packages/safe-js/dist/interp/globals/object-array.d.ts +2 -1
  21. package/packages/safe-js/dist/interp/globals/object-array.js +10 -1
  22. package/packages/safe-js/dist/interp/globals.d.ts +3 -0
  23. package/packages/safe-js/dist/interp/globals.js +2 -0
  24. package/packages/safe-js/dist/interp/host-bridge.d.ts +4 -0
  25. package/packages/safe-js/dist/interp/host-bridge.js +21 -2
  26. package/packages/safe-js/dist/interp/host-call.js +4 -0
  27. package/packages/safe-js/dist/interp/host-capabilities.d.ts +7 -0
  28. package/packages/safe-js/dist/interp/host-capabilities.js +29 -1
  29. package/packages/safe-js/dist/interp/interpreter.js +19 -2
  30. package/packages/safe-js/dist/interp/string-coercion.js +3 -0
  31. package/packages/safe-js/dist/interp/values.d.ts +1 -1
  32. package/packages/safe-js/dist/interp/values.js +21 -0
  33. package/packages/safe-js/dist/lint/rules/known-globals.d.ts +1 -1
  34. package/packages/safe-js/dist/lint/rules/known-globals.js +1 -0
  35. package/packages/safe-js/dist/parse/parser.js +4 -2
  36. package/packages/safe-js/dist/realm.d.ts +4 -1
  37. package/packages/safe-js/dist/realm.js +74 -8
  38. package/packages/safe-js/dist/run.d.ts +2 -0
  39. package/packages/safe-js/dist/run.js +1 -1
  40. package/packages/safe-js/dist/snapshot/dump-format.js +8 -3
  41. package/packages/safe-js/dist/snapshot/replay-data.d.ts +4 -1
  42. package/packages/safe-js/dist/snapshot/replay-data.js +11 -0
  43. package/packages/safe-js/dist/snapshot/restore.js +6 -0
  44. package/packages/safe-js/dist/snapshot/serialize.d.ts +5 -2
  45. package/packages/safe-js/dist/snapshot/serialize.js +8 -2
  46. package/packages/safe-js/dist/snapshot/validation.js +18 -1
  47. package/packages/safe-js/dist/chunks/chunk-2M6MNQBY.js.map +0 -7
  48. /package/packages/safe-js/dist/chunks/{chunk-QSSQJNKE.js.map → chunk-ETKM3KPA.js.map} +0 -0
@@ -1,6 +1,7 @@
1
1
  import { Budget, SandboxError } from "../interp/budget.js";
2
2
  import { CompileScope } from "../interp/regex/compile-guard.js";
3
3
  import { decodeFloat32Storage } from "./float32array.js";
4
+ import { restoreDateTime } from "../interp/date.js";
4
5
  import { sandboxErrorTypes } from "../error/shape.js";
5
6
  import { SnapshotMismatchError } from "../restore.js";
6
7
  import { Scope, setSandboxProperty } from "../interp/interpreter.js";
@@ -339,6 +340,11 @@ function restoreHeapValue(id, state) {
339
340
  if (serialized === undefined) {
340
341
  throw new Error(`Snapshot references unknown heap value ${id}.`);
341
342
  }
343
+ if (serialized.kind === "date") {
344
+ const value = restoreDateTime(serialized.time);
345
+ state.heapValueById.set(id, value);
346
+ return value;
347
+ }
342
348
  if (serialized.kind === "float32array") {
343
349
  const value = decodeFloat32Storage(serialized, (reference) => deserializeValue(reference, state));
344
350
  state.heapValueById.set(id, value);
@@ -40,7 +40,10 @@ export type SerializedReferenceValue = {
40
40
  kind: "ref";
41
41
  id: number;
42
42
  };
43
- export type SerializedHeapValue = (Float32Data<SerializedReferenceValue> & {
43
+ export type SerializedHeapValue = {
44
+ kind: "date";
45
+ time: number | null;
46
+ } | (Float32Data<SerializedReferenceValue> & {
44
47
  entries: Record<string, SerializedSnapshotValue>;
45
48
  }) | SerializedArguments<SerializedSnapshotValue> | SerializedArray<SerializedSnapshotValue> | {
46
49
  kind: "object";
@@ -72,7 +75,7 @@ export type RuntimePromiseValue = {
72
75
  id: SnapshotId;
73
76
  promise?: Promise<unknown>;
74
77
  };
75
- export type RuntimeSnapshotValue = Float32Array | boolean | null | number | string | undefined | RuntimeClosureValue | SandboxGenerator | RuntimePromiseValue | SandboxMap | SandboxRegex | SandboxSet | RuntimeSnapshotValue[] | {
78
+ export type RuntimeSnapshotValue = Date | Float32Array | boolean | null | number | string | undefined | RuntimeClosureValue | SandboxGenerator | RuntimePromiseValue | SandboxMap | SandboxRegex | SandboxSet | RuntimeSnapshotValue[] | {
76
79
  [key: string]: RuntimeSnapshotValue;
77
80
  };
78
81
  export type RuntimeScopeFrame = {
@@ -6,6 +6,7 @@ import { serializeArguments } from "./arguments.js";
6
6
  import { requiresArrayEntries, serializeArray } from "./arrays.js";
7
7
  import { float32DataProperties, isFloat32Array } from "../interp/float32.js";
8
8
  import { encodeFloat32Storage } from "./float32array.js";
9
+ import { isSandboxDate, serializedDateTime } from "../interp/date.js";
9
10
  import { isSandboxArguments, isSandboxGenerator, isSandboxMap, isSandboxRegex, isSandboxSet } from "../interp/values.js";
10
11
  export class UnsnapshotableValueError extends Error {
11
12
  path;
@@ -161,7 +162,7 @@ function serializeValue(value, path, state) {
161
162
  if (isSandboxRegex(value)) {
162
163
  return { kind: "regex", source: value.source, flags: value.flags, lastIndex: value.lastIndex };
163
164
  }
164
- if (isSandboxMap(value) || isSandboxSet(value) || isFloat32Array(value)) {
165
+ if (isSandboxDate(value) || isSandboxMap(value) || isSandboxSet(value) || isFloat32Array(value)) {
165
166
  const reference = serializeHeapReference(value, path, state);
166
167
  if (reference === undefined) {
167
168
  throw new TypeError(`Cannot serialize collection without a heap reference at ${path}.`);
@@ -190,7 +191,10 @@ function serializeHeapReference(value, path, state) {
190
191
  }
191
192
  if (!state.serializedHeapIds.has(id)) {
192
193
  state.serializedHeapIds.add(id);
193
- if (isFloat32Array(value)) {
194
+ if (isSandboxDate(value)) {
195
+ state.heap[String(id)] = { kind: "date", time: serializedDateTime(value) };
196
+ }
197
+ else if (isFloat32Array(value)) {
194
198
  const storage = encodeFloat32Storage(value, id, state.float32Buffers, (id) => ({
195
199
  kind: "ref",
196
200
  id
@@ -297,6 +301,7 @@ function indexHeapContainers(input) {
297
301
  for (const [value, stat] of stats.entries()) {
298
302
  if (stat.count > 1 ||
299
303
  stat.cyclic ||
304
+ isSandboxDate(value) ||
300
305
  isFloat32Array(value) ||
301
306
  (Array.isArray(value) && requiresArrayEntries(value)) ||
302
307
  sandboxErrorTypes.has(value) ||
@@ -319,6 +324,7 @@ function collectContainerStats(value, stats, ancestors) {
319
324
  }
320
325
  if (!Array.isArray(value) &&
321
326
  !isPlainObject(value) &&
327
+ !isSandboxDate(value) &&
322
328
  !isFloat32Array(value) &&
323
329
  !isSandboxMap(value) &&
324
330
  !isSandboxSet(value)) {
@@ -3,6 +3,7 @@ import { types } from "node:util";
3
3
  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
+ import { restoreDateTime } from "../interp/date.js";
6
7
  import { hasGuestObjectState } from "../interp/object-model.js";
7
8
  const DEFAULT_MAX_DEPTH = MAX_DATA_DEPTH;
8
9
  const DEFAULT_MAX_ENTRIES = 100_000;
@@ -80,6 +81,10 @@ function validateDumpHeap(root, state) {
80
81
  addUnique(heapIds, id, path);
81
82
  const entry = requireRecord(value, path);
82
83
  validateErrorType(entry, path);
84
+ if (entry.kind === "date") {
85
+ validateDateRecord(entry, path);
86
+ continue;
87
+ }
83
88
  if (entry.kind === "float32array") {
84
89
  validateFloat32Storage(entry);
85
90
  requireRecord(entry.entries, `${path}.entries`);
@@ -402,7 +407,7 @@ function validateGeneratorShape(record, path, state) {
402
407
  function validateHeapValue(value, path, state) {
403
408
  const record = requireRecord(value, path);
404
409
  validateErrorType(record, path);
405
- if (!["arguments", "array", "object", "map", "set", "float32array"].includes(String(record.kind)))
410
+ if (!["arguments", "array", "object", "map", "set", "float32array", "date"].includes(String(record.kind)))
406
411
  fail("unknownTag", `${path}.kind`, "unknown heap tag");
407
412
  validateValue(record, path, 1, state);
408
413
  if (record.kind === "arguments")
@@ -411,6 +416,8 @@ function validateHeapValue(value, path, state) {
411
416
  validateArrayHeap(record, path, state);
412
417
  if (record.kind === "object")
413
418
  requireRecord(record.entries, `${path}.entries`);
419
+ if (record.kind === "date")
420
+ validateDateRecord(record, path);
414
421
  if (record.kind === "float32array") {
415
422
  validateFloat32Storage(record);
416
423
  requireRecord(record.entries, `${path}.entries`);
@@ -425,6 +432,16 @@ function validateHeapValue(value, path, state) {
425
432
  if (record.kind === "set")
426
433
  requireArray(record.values, `${path}.values`, state);
427
434
  }
435
+ function validateDateRecord(record, path) {
436
+ if (Object.keys(record).length !== 2)
437
+ fail("invalidValue", path, "invalid Date fields");
438
+ try {
439
+ restoreDateTime(record.time);
440
+ }
441
+ catch {
442
+ fail("invalidValue", `${path}.time`, "invalid Date epoch");
443
+ }
444
+ }
428
445
  function validateArrayHeap(record, path, state) {
429
446
  if (Object.hasOwn(record, "items")) {
430
447
  requireArray(record.items, `${path}.items`, state);