poe-code 11.0.18 → 11.0.19

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 CHANGED
@@ -136317,7 +136317,6 @@ function graphEntries(value) {
136317
136317
  if (isSandboxArguments(value)) {
136318
136318
  return getSandboxArgumentEntries(value).map(([key3, entry]) => [`.${key3}`, entry]);
136319
136319
  }
136320
- if (Array.isArray(value)) return value.map((entry, index) => [`[${index}]`, entry]);
136321
136320
  if (value instanceof Map) {
136322
136321
  return [...value.entries()].flatMap(([key3, entry], index) => [
136323
136322
  [`.<map>[${index}].key`, key3],
@@ -136331,7 +136330,7 @@ function graphEntries(value) {
136331
136330
  for (const key3 of Object.keys(value)) {
136332
136331
  const descriptor = Object.getOwnPropertyDescriptor(value, key3);
136333
136332
  if (descriptor !== void 0 && "value" in descriptor)
136334
- entries.push([`.${key3}`, descriptor.value]);
136333
+ entries.push([Array.isArray(value) ? `[${key3}]` : `.${key3}`, descriptor.value]);
136335
136334
  }
136336
136335
  return entries;
136337
136336
  }
@@ -136399,6 +136398,40 @@ var init_arguments2 = __esm({
136399
136398
  }
136400
136399
  });
136401
136400
 
136401
+ // packages/safejs/src/snapshot/arrays.ts
136402
+ function requiresArrayEntries(value) {
136403
+ const keys = Object.keys(value);
136404
+ return keys.length !== value.length || keys.some((key3, index) => key3 !== String(index));
136405
+ }
136406
+ function serializeArray(value, serializeValue) {
136407
+ if (!requiresArrayEntries(value)) {
136408
+ return {
136409
+ kind: "array",
136410
+ items: Array.from({ length: value.length }, (_, index) => {
136411
+ const key3 = String(index);
136412
+ const descriptor = Object.getOwnPropertyDescriptor(value, key3);
136413
+ return serializeValue(
136414
+ descriptor !== void 0 && "value" in descriptor ? descriptor.value : void 0,
136415
+ key3
136416
+ );
136417
+ })
136418
+ };
136419
+ }
136420
+ const entries = /* @__PURE__ */ Object.create(null);
136421
+ for (const key3 of Object.keys(value)) {
136422
+ const descriptor = Object.getOwnPropertyDescriptor(value, key3);
136423
+ if (descriptor !== void 0 && "value" in descriptor) {
136424
+ entries[key3] = serializeValue(descriptor.value, key3);
136425
+ }
136426
+ }
136427
+ return { kind: "array", length: value.length, entries };
136428
+ }
136429
+ var init_arrays = __esm({
136430
+ "packages/safejs/src/snapshot/arrays.ts"() {
136431
+ "use strict";
136432
+ }
136433
+ });
136434
+
136402
136435
  // packages/safejs/src/snapshot/dump-format.ts
136403
136436
  function serializeSafeJSSnapshot(snapshot2) {
136404
136437
  const replayError = Object.getOwnPropertyDescriptor(snapshot2, "replayError");
@@ -136482,10 +136515,10 @@ function serializeHeapReference(value, path191, state) {
136482
136515
  return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
136483
136516
  });
136484
136517
  } else if (Array.isArray(value)) {
136485
- state.heap[String(id)] = {
136486
- kind: "array",
136487
- items: serializeArrayItems(value, path191, state)
136488
- };
136518
+ state.heap[String(id)] = serializeArray(value, (entry, key3) => {
136519
+ const serialized = serializeDumpValue(entry, `${path191}[${key3}]`, state);
136520
+ return serialized === SKIP_VALUE ? { kind: "undefined" } : serialized;
136521
+ });
136489
136522
  } else {
136490
136523
  const errorType = sandboxErrorTypes.get(value);
136491
136524
  state.heap[String(id)] = {
@@ -136522,7 +136555,7 @@ function indexHeapContainers(snapshot2) {
136522
136555
  const heapIds = /* @__PURE__ */ new WeakMap();
136523
136556
  let nextId = 1;
136524
136557
  for (const [value, stat36] of stats2.entries()) {
136525
- if (stat36.count > 1 || stat36.cyclic || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
136558
+ if (stat36.count > 1 || stat36.cyclic || Array.isArray(value) && requiresArrayEntries(value) || isSandboxArguments(value) || sandboxErrorTypes.has(value)) {
136526
136559
  heapIds.set(value, nextId);
136527
136560
  nextId += 1;
136528
136561
  }
@@ -136555,7 +136588,7 @@ function collectContainerStats(value, stats2, ancestors) {
136555
136588
  }
136556
136589
  stat36.expanded = true;
136557
136590
  ancestors.add(value);
136558
- const entries = isSandboxArguments(value) ? getSandboxArgumentEntries(value).map(([, entry]) => entry) : Array.isArray(value) ? getArrayDataItems(value) : getEnumerableDataValues(value);
136591
+ const entries = isSandboxArguments(value) ? getSandboxArgumentEntries(value).map(([, entry]) => entry) : getEnumerableDataValues(value);
136559
136592
  for (const entry of entries) {
136560
136593
  collectContainerStats(entry, stats2, ancestors);
136561
136594
  }
@@ -136600,6 +136633,7 @@ var init_dump_format = __esm({
136600
136633
  init_shape();
136601
136634
  init_arguments();
136602
136635
  init_arguments2();
136636
+ init_arrays();
136603
136637
  DUMP_FORMAT_VERSION = 1;
136604
136638
  EXECUTION_SEMANTICS = "jobs-v6";
136605
136639
  SKIP_VALUE = /* @__PURE__ */ Symbol("SafeJS.skip-dump-value");
@@ -136658,7 +136692,7 @@ function validateDumpHeap(root, state) {
136658
136692
  continue;
136659
136693
  }
136660
136694
  if (entry.kind === "array") {
136661
- requireArray(entry.items, `${path191}.items`, state);
136695
+ validateArrayHeap(entry, path191, state);
136662
136696
  continue;
136663
136697
  }
136664
136698
  if (entry.kind === "object") {
@@ -136805,6 +136839,30 @@ function validateGeneratorShape(record2, path191, state) {
136805
136839
  }
136806
136840
  });
136807
136841
  }
136842
+ function validateArrayHeap(record2, path191, state) {
136843
+ if (Object.hasOwn(record2, "items")) {
136844
+ requireArray(record2.items, `${path191}.items`, state);
136845
+ if (Object.hasOwn(record2, "length") || Object.hasOwn(record2, "entries"))
136846
+ fail2("invalidValue", path191, "array must use either items or length and entries");
136847
+ return;
136848
+ }
136849
+ const length = requireSafeInteger(record2.length, `${path191}.length`, 0);
136850
+ if (length > 4294967295) fail2("invalidValue", `${path191}.length`, "exceeds maximum array length");
136851
+ if (length > state.limits.maxEntries)
136852
+ fail2(
136853
+ "budgetExceeded",
136854
+ `${path191}.length`,
136855
+ `exceeds collection entry limit ${state.limits.maxEntries}`
136856
+ );
136857
+ const entries = requireRecord3(record2.entries, `${path191}.entries`);
136858
+ for (const key3 of Object.keys(entries)) {
136859
+ if (key3 === "length")
136860
+ fail2("invalidValue", `${path191}.entries.length`, "array length is stored separately");
136861
+ const index = Number(key3);
136862
+ if (String(index) === key3 && Number.isInteger(index) && index >= 0 && index < 4294967295 && index >= length)
136863
+ fail2("invalidValue", `${path191}.entries${formatKey(key3)}`, "array index exceeds its length");
136864
+ }
136865
+ }
136808
136866
  function validateErrorType(record2, path191) {
136809
136867
  if (!Object.hasOwn(record2, "errorType")) return;
136810
136868
  if (record2.kind !== "object" || !sandboxErrorNames.includes(record2.errorType)) {
@@ -147985,6 +148043,7 @@ var init_serialize = __esm({
147985
148043
  init_shape();
147986
148044
  init_graph_depth();
147987
148045
  init_arguments2();
148046
+ init_arrays();
147988
148047
  init_values();
147989
148048
  UnsnapshotableValueError = class extends Error {
147990
148049
  path;
@@ -155649,7 +155708,7 @@ var init_package2 = __esm({
155649
155708
  "package.json"() {
155650
155709
  package_default2 = {
155651
155710
  name: "poe-code",
155652
- version: "11.0.18",
155711
+ version: "11.0.19",
155653
155712
  description: "CLI tool to configure Poe API for developer workflows.",
155654
155713
  license: "MIT",
155655
155714
  type: "module",