poe-code 11.0.4 → 11.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-code",
3
- "version": "11.0.4",
3
+ "version": "11.0.5",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,7 +27,7 @@ import {
27
27
  validateMigrationSemantics,
28
28
  validateSnapshotData,
29
29
  validateSnapshotMigration
30
- } from "./chunk-CA342J7E.js";
30
+ } from "./chunk-WC2N7PM5.js";
31
31
 
32
32
  // packages/safejs/src/migrate.ts
33
33
  import { createHash } from "node:crypto";
@@ -8048,4 +8048,4 @@ export {
8048
8048
  parseMcpConfig,
8049
8049
  makeMcpModule
8050
8050
  };
8051
- //# sourceMappingURL=chunk-NBVIHENC.js.map
8051
+ //# sourceMappingURL=chunk-EWC7GLGM.js.map
@@ -18514,12 +18514,10 @@ function getSandboxIterator(value) {
18514
18514
  return syncIterator(value[Symbol.iterator]());
18515
18515
  }
18516
18516
  if (isSandboxMap(value)) {
18517
- return syncIterator(
18518
- Array.from(value.entries, ([key, entry]) => [key, entry])[Symbol.iterator]()
18519
- );
18517
+ return collectionIterator(value.entries);
18520
18518
  }
18521
18519
  if (isSandboxSet(value)) {
18522
- return syncIterator(value.values[Symbol.iterator]());
18520
+ return collectionIterator(value.values);
18523
18521
  }
18524
18522
  if (typeof value !== "object" && typeof value !== "function" || value === null) {
18525
18523
  return void 0;
@@ -18530,6 +18528,29 @@ function getSandboxIterator(value) {
18530
18528
  }
18531
18529
  return syncIterator(Reflect.apply(iteratorMethod, value, []));
18532
18530
  }
18531
+ function collectionIterator(collection) {
18532
+ let iterator = collection[Symbol.iterator]();
18533
+ let exhausted = false;
18534
+ return {
18535
+ ...syncIterator({
18536
+ next: () => {
18537
+ if (exhausted) return { done: true, value: void 0 };
18538
+ const result = iterator.next();
18539
+ exhausted = result.done === true;
18540
+ return result;
18541
+ }
18542
+ }),
18543
+ snapshotIndex: () => {
18544
+ if (exhausted) return collection.size;
18545
+ let remaining = 0;
18546
+ while (!iterator.next().done) remaining += 1;
18547
+ const index = collection.size - remaining;
18548
+ iterator = collection[Symbol.iterator]();
18549
+ for (let skipped = 0; skipped < index; skipped += 1) iterator.next();
18550
+ return index;
18551
+ }
18552
+ };
18553
+ }
18533
18554
  function generatorIterator(generator) {
18534
18555
  const invoke = async (method, value) => {
18535
18556
  const leaveRunning = enterRunningState(generator);
@@ -26221,19 +26242,35 @@ async function evaluateVariableDeclaration(node, context) {
26221
26242
  value: void 0
26222
26243
  };
26223
26244
  }
26224
- function isRestorableBindingValue(value) {
26225
- if (Array.isArray(value)) {
26226
- return value.every(isRestorableBindingValue);
26227
- }
26245
+ function isRestorableBindingValue(value, seen = /* @__PURE__ */ new WeakSet()) {
26228
26246
  if (typeof value !== "object" || value === null) {
26229
26247
  return true;
26230
26248
  }
26249
+ if (seen.has(value)) return true;
26250
+ seen.add(value);
26251
+ if (isSandboxMap(value)) {
26252
+ for (const [key, entry] of value.entries) {
26253
+ if (!isRestorableBindingValue(key, seen) || !isRestorableBindingValue(entry, seen)) {
26254
+ return false;
26255
+ }
26256
+ }
26257
+ return true;
26258
+ }
26259
+ if (isSandboxSet(value)) {
26260
+ for (const entry of value.values) {
26261
+ if (!isRestorableBindingValue(entry, seen)) return false;
26262
+ }
26263
+ return true;
26264
+ }
26265
+ if (Array.isArray(value)) {
26266
+ return value.every((entry) => isRestorableBindingValue(entry, seen));
26267
+ }
26231
26268
  if (Object.hasOwn(value, "kind")) {
26232
26269
  return !["fn", "generator", "map", "promise", "regex", "set"].includes(
26233
26270
  String(value.kind)
26234
26271
  );
26235
26272
  }
26236
- return Object.values(value).every(isRestorableBindingValue);
26273
+ return Object.values(value).every((entry) => isRestorableBindingValue(entry, seen));
26237
26274
  }
26238
26275
  function predeclareDeclarationBindings(node, scope) {
26239
26276
  for (const name of getDeclarationBindingNames2(node)) {
@@ -26447,13 +26484,24 @@ async function evaluateIfStatement(node, context) {
26447
26484
  return evaluateNode(branch, context);
26448
26485
  }
26449
26486
  async function evaluateForOfStatement(node, context) {
26487
+ const restoredIteration = context.restoredLoopIterations.get(node.nodeId ?? -1);
26488
+ let restoredEntry;
26489
+ if (typeof restoredIteration === "object" && typeof restoredIteration.values[0] === "string") {
26490
+ const restored = context.scope.consumeRestoredBinding(restoredIteration.values[0]);
26491
+ if (restored.found && Array.isArray(restored.value)) {
26492
+ restoredEntry = { done: false, value: restored.value[1] };
26493
+ if (isSandboxMap(restored.value[0]) || isSandboxSet(restored.value[0])) {
26494
+ return evaluateForOfIterator(node, restored.value[0], context, restoredEntry);
26495
+ }
26496
+ }
26497
+ }
26450
26498
  const iterable = await evaluateNode(node.right, context);
26451
26499
  if (iterable.kind !== "normal") {
26452
26500
  return iterable;
26453
26501
  }
26454
26502
  const values = snapshotableIterationValues(iterable.value);
26455
26503
  if (values === void 0) {
26456
- return evaluateForOfIterator(node, iterable.value, context);
26504
+ return evaluateForOfIterator(node, iterable.value, context, restoredEntry);
26457
26505
  }
26458
26506
  const restoredIndex = consumeRestoredLoopIterationIndex(node, context);
26459
26507
  for (let index = restoredIndex; index < values.length; index += 1) {
@@ -26489,7 +26537,7 @@ async function evaluateForOfStatement(node, context) {
26489
26537
  value: void 0
26490
26538
  };
26491
26539
  }
26492
- async function evaluateForOfIterator(node, value, context) {
26540
+ async function evaluateForOfIterator(node, value, context, restoredEntry) {
26493
26541
  const iterator = getSandboxIterator(value);
26494
26542
  if (iterator === void 0) {
26495
26543
  throw new TypeError(`${String(value)} is not a supported iterable`);
@@ -26506,7 +26554,8 @@ async function evaluateForOfIterator(node, value, context) {
26506
26554
  }
26507
26555
  }
26508
26556
  while (true) {
26509
- const iteration = await iterator.next();
26557
+ const iteration = restoredEntry ?? await iterator.next();
26558
+ restoredEntry = void 0;
26510
26559
  if (typeof iteration !== "object" || iteration === null) {
26511
26560
  throw new TypeError("Iterator result must be an object.");
26512
26561
  }
@@ -26514,7 +26563,15 @@ async function evaluateForOfIterator(node, value, context) {
26514
26563
  context.activeLoopIterations.delete(nodeId);
26515
26564
  return normalEmptyResult();
26516
26565
  }
26517
- context.activeLoopIterations.set(nodeId, index);
26566
+ context.activeLoopIterations.set(
26567
+ nodeId,
26568
+ iterator.snapshotIndex === void 0 ? index : {
26569
+ get index() {
26570
+ return iterator.snapshotIndex();
26571
+ },
26572
+ values: [value, iteration.value]
26573
+ }
26574
+ );
26518
26575
  const scope = context.scope.child();
26519
26576
  const binding = await bindForOfLoopVariable(node.left, iteration.value, scope, context);
26520
26577
  if (!binding.ok) {
@@ -26753,10 +26810,21 @@ function createLoopIterationContext(context, scope) {
26753
26810
  return {
26754
26811
  ...context,
26755
26812
  scope,
26756
- snapshot: (currentScope) => ({
26757
- ...currentScope.snapshot(),
26758
- ...context.activeLoopIterations.size === 0 ? {} : { loopIterations: Object.fromEntries(context.activeLoopIterations) }
26759
- })
26813
+ snapshot: (currentScope) => {
26814
+ const snapshot = currentScope.snapshot();
26815
+ if (context.activeLoopIterations.size === 0) return snapshot;
26816
+ snapshot.loopIterations = {};
26817
+ for (const [nodeId, iteration] of context.activeLoopIterations) {
26818
+ if (typeof iteration !== "number" && (isSandboxMap(iteration.values[0]) || isSandboxSet(iteration.values[0]))) {
26819
+ const bindingName = `#for-of:${nodeId}`;
26820
+ snapshot.bindings[bindingName] = iteration.values;
26821
+ snapshot.loopIterations[nodeId] = { index: iteration.index, values: [bindingName] };
26822
+ } else {
26823
+ snapshot.loopIterations[nodeId] = iteration;
26824
+ }
26825
+ }
26826
+ return snapshot;
26827
+ }
26760
26828
  };
26761
26829
  }
26762
26830
  function consumeRestoredLoopIteration(node, context) {
@@ -26776,12 +26844,6 @@ function snapshotableIterationValues(value) {
26776
26844
  if (Array.isArray(value)) {
26777
26845
  return value;
26778
26846
  }
26779
- if (isSandboxMap(value)) {
26780
- return Array.from(value.entries, ([key, entry]) => [key, entry]);
26781
- }
26782
- if (isSandboxSet(value)) {
26783
- return Array.from(value.values);
26784
- }
26785
26847
  return void 0;
26786
26848
  }
26787
26849
  function isMatchingBreak(result, labels) {
@@ -28914,4 +28976,4 @@ export {
28914
28976
  FileSnapshotBackend,
28915
28977
  run
28916
28978
  };
28917
- //# sourceMappingURL=chunk-CA342J7E.js.map
28979
+ //# sourceMappingURL=chunk-WC2N7PM5.js.map