@poe-platform/safe-js 0.1.151 → 0.1.152

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.
@@ -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;
@@ -31597,9 +31606,19 @@ function describeObjectSpreadValue(value) {
31597
31606
  }
31598
31607
  return typeof value;
31599
31608
  }
31600
- async function closeIterator(iterator) {
31601
- if (iterator.generator && iterator.return !== void 0) {
31602
- await iterator.return();
31609
+ async function closeIterator(iterator, preserveThrow = false) {
31610
+ try {
31611
+ const close = iterator.return;
31612
+ if (close === void 0) return;
31613
+ const returned = close();
31614
+ const result = iterator.generator || iterator.asynchronous ? await returned : returned;
31615
+ if (typeof result !== "object" && typeof result !== "function" || result === null) {
31616
+ throw new TypeError("Iterator return result must be an object.");
31617
+ }
31618
+ } catch (error) {
31619
+ if (!preserveThrow || isFatalSandboxError(error) || error instanceof HostCallResumabilityError) {
31620
+ throw error;
31621
+ }
31603
31622
  }
31604
31623
  }
31605
31624
  function defineSandboxProperty(target, key, value) {
@@ -35581,4 +35600,4 @@ export {
35581
35600
  FileSnapshotBackend,
35582
35601
  run
35583
35602
  };
35584
- //# sourceMappingURL=chunk-LNHPI4GK.js.map
35603
+ //# sourceMappingURL=chunk-6NQIMBX3.js.map