@poe-platform/safe-js 0.1.151 → 0.1.153

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.
@@ -27,7 +27,7 @@ import {
27
27
  validateMigrationSemantics,
28
28
  validateSnapshotData,
29
29
  validateSnapshotMigration
30
- } from "./chunk-LNHPI4GK.js";
30
+ } from "./chunk-WL74XSIE.js";
31
31
 
32
32
  // packages/safe-js/src/migrate.ts
33
33
  import { createHash } from "node:crypto";
@@ -8249,4 +8249,4 @@ export {
8249
8249
  parseMcpConfig,
8250
8250
  makeMcpModule
8251
8251
  };
8252
- //# sourceMappingURL=chunk-3BLGB6FX.js.map
8252
+ //# sourceMappingURL=chunk-45U4DCFW.js.map
@@ -29857,18 +29857,27 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
29857
29857
  context.activeLoopIterations.delete(nodeId);
29858
29858
  return normalEmptyResult();
29859
29859
  }
29860
+ const nextValue = iteration.value;
29860
29861
  context.activeLoopIterations.set(
29861
29862
  nodeId,
29862
29863
  iterator.snapshotIndex === void 0 ? index : {
29863
29864
  get index() {
29864
29865
  return iterator.snapshotIndex();
29865
29866
  },
29866
- values: [value, iteration.value]
29867
+ values: [value, nextValue]
29867
29868
  }
29868
29869
  );
29869
29870
  const scope = context.scope.child();
29870
- const binding = await bindForOfLoopVariable(node.left, iteration.value, scope, context);
29871
+ let binding;
29872
+ try {
29873
+ binding = await bindForOfLoopVariable(node.left, nextValue, scope, context);
29874
+ } catch (error) {
29875
+ if (isFatalSandboxError(error) || error instanceof HostCallResumabilityError) throw error;
29876
+ await closeIterator(iterator, true);
29877
+ throw error;
29878
+ }
29871
29879
  if (!binding.ok) {
29880
+ await closeIterator(iterator, binding.result.kind === "throw");
29872
29881
  return binding.result;
29873
29882
  }
29874
29883
  const iterationContext = createLoopIterationContext(context, scope);
@@ -29885,7 +29894,7 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
29885
29894
  }
29886
29895
  if (result.kind !== "normal") {
29887
29896
  context.activeLoopIterations.delete(nodeId);
29888
- await closeIterator(iterator);
29897
+ await closeIterator(iterator, result.kind === "throw");
29889
29898
  return result;
29890
29899
  }
29891
29900
  index += 1;
@@ -30178,11 +30187,8 @@ function hasLoopLabel(labels, target) {
30178
30187
  return Array.isArray(labels) ? labels.includes(target) : labels === target;
30179
30188
  }
30180
30189
  async function bindForOfLoopVariable(left, value, scope, context) {
30181
- if (left.type === "Identifier") {
30182
- return bindPattern2(left, value, { assign: true }, scope, createPatternContext(context, scope));
30183
- }
30184
30190
  if (left.type !== "VariableDeclaration") {
30185
- throw new TypeError(`Unsupported for...of left-hand side '${left.type}'.`);
30191
+ return bindPattern2(left, value, { assign: true }, scope, createPatternContext(context, scope));
30186
30192
  }
30187
30193
  const [declarator] = left.declarations;
30188
30194
  if (left.declarations.length !== 1 || declarator === void 0) {
@@ -31597,9 +31603,19 @@ function describeObjectSpreadValue(value) {
31597
31603
  }
31598
31604
  return typeof value;
31599
31605
  }
31600
- async function closeIterator(iterator) {
31601
- if (iterator.generator && iterator.return !== void 0) {
31602
- await iterator.return();
31606
+ async function closeIterator(iterator, preserveThrow = false) {
31607
+ try {
31608
+ const close = iterator.return;
31609
+ if (close === void 0) return;
31610
+ const returned = close();
31611
+ const result = iterator.generator || iterator.asynchronous ? await returned : returned;
31612
+ if (typeof result !== "object" && typeof result !== "function" || result === null) {
31613
+ throw new TypeError("Iterator return result must be an object.");
31614
+ }
31615
+ } catch (error) {
31616
+ if (!preserveThrow || isFatalSandboxError(error) || error instanceof HostCallResumabilityError) {
31617
+ throw error;
31618
+ }
31603
31619
  }
31604
31620
  }
31605
31621
  function defineSandboxProperty(target, key, value) {
@@ -35581,4 +35597,4 @@ export {
35581
35597
  FileSnapshotBackend,
35582
35598
  run
35583
35599
  };
35584
- //# sourceMappingURL=chunk-LNHPI4GK.js.map
35600
+ //# sourceMappingURL=chunk-WL74XSIE.js.map