@poe-platform/safe-js 0.1.226 → 0.1.227

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.
@@ -8581,7 +8581,7 @@ function captureGuestHeapNode(value, encode) {
8581
8581
  ...value.state !== "suspended" || origin2.expressionStates === void 0 ? {} : {
8582
8582
  expressionStates: Object.fromEntries([...origin2.expressionStates].map(([id, expression]) => [
8583
8583
  String(id),
8584
- expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "identifier-assignment" ? { kind: "identifier-assignment", current: encode(expression.current) } : expression.kind === "member-assignment" ? {
8584
+ expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "for" ? { kind: "for", phase: expression.phase, loopScope: encode(expression.loopScope), activeScope: encode(expression.activeScope) } : expression.kind === "identifier-assignment" ? { kind: "identifier-assignment", current: encode(expression.current) } : expression.kind === "member-assignment" ? {
8585
8585
  kind: "member-assignment",
8586
8586
  object: encode(expression.object),
8587
8587
  property: encode(expression.property),
@@ -17646,14 +17646,27 @@ function normalEmptyResult() {
17646
17646
  return { kind: "normal", hasValue: false, value: void 0 };
17647
17647
  }
17648
17648
  async function evaluateForStatement(node, context) {
17649
- const loopScope = context.scope.child();
17649
+ const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
17650
+ if (restored !== void 0 && restored.kind !== "for") throw new TypeError("Invalid for-loop continuation.");
17651
+ let resumePhase = restored?.phase;
17652
+ const loopScope = restored?.loopScope ?? context.scope.child();
17650
17653
  const loopBindingNames = getForStatementBindingNames(node);
17651
17654
  const loopContext = {
17652
17655
  ...context,
17653
17656
  scope: loopScope
17654
17657
  };
17655
- if (node.init !== void 0) {
17656
- const init = await evaluateNode(node.init, loopContext);
17658
+ const phaseContext = (phase, scope) => ({
17659
+ ...loopContext,
17660
+ scope,
17661
+ ...context.generatorYield === void 0 || node.nodeId === void 0 ? {} : {
17662
+ generatorExpressionStates: new Map([
17663
+ ...context.generatorExpressionStates ?? [],
17664
+ [node.nodeId, { kind: "for", phase, loopScope, activeScope: scope }]
17665
+ ])
17666
+ }
17667
+ });
17668
+ if (node.init !== void 0 && (resumePhase === void 0 || resumePhase === "init")) {
17669
+ const init = await evaluateNode(node.init, phaseContext("init", loopScope));
17657
17670
  if (init.kind !== "normal") {
17658
17671
  return init;
17659
17672
  }
@@ -17661,8 +17674,8 @@ async function evaluateForStatement(node, context) {
17661
17674
  while (true) {
17662
17675
  context.budget.visitNode();
17663
17676
  context.stats.nodeVisits += 1;
17664
- if (node.test !== void 0) {
17665
- const test = await evaluateNode(node.test, loopContext);
17677
+ if (node.test !== void 0 && resumePhase !== "body" && resumePhase !== "update") {
17678
+ const test = await evaluateNode(node.test, phaseContext("test", loopScope));
17666
17679
  if (test.kind !== "normal") {
17667
17680
  return test;
17668
17681
  }
@@ -17674,28 +17687,24 @@ async function evaluateForStatement(node, context) {
17674
17687
  };
17675
17688
  }
17676
17689
  }
17677
- const iterationScope = loopBindingNames.length === 0 ? loopScope : loopScope.iterationChild(loopBindingNames);
17678
- const iterationContext = {
17679
- ...loopContext,
17680
- ...createLoopIterationContext(loopContext, iterationScope)
17681
- };
17682
- emitLoopIterationBreakpoint(node, iterationContext);
17683
- const result = await evaluateNode(node.body, iterationContext);
17684
- if (isMatchingBreak(result, loopLabels(node))) {
17685
- return {
17686
- kind: "normal",
17687
- hasValue: false,
17688
- value: void 0
17689
- };
17690
- }
17691
- if (result.kind !== "normal" && !isMatchingContinue(result, loopLabels(node))) {
17692
- return result;
17690
+ const iterationScope = resumePhase === "body" || resumePhase === "update" ? restored.activeScope : loopBindingNames.length === 0 ? loopScope : loopScope.iterationChild(loopBindingNames);
17691
+ if (resumePhase !== "update") {
17692
+ const iterationContext = createLoopIterationContext(phaseContext("body", iterationScope), iterationScope);
17693
+ emitLoopIterationBreakpoint(node, iterationContext);
17694
+ const result = await evaluateNode(node.body, iterationContext);
17695
+ if (isMatchingBreak(result, loopLabels(node))) {
17696
+ return {
17697
+ kind: "normal",
17698
+ hasValue: false,
17699
+ value: void 0
17700
+ };
17701
+ }
17702
+ if (result.kind !== "normal" && !isMatchingContinue(result, loopLabels(node))) {
17703
+ return result;
17704
+ }
17693
17705
  }
17694
- const updateScope = loopBindingNames.length === 0 ? iterationScope : iterationScope.iterationChild(loopBindingNames);
17695
- const updateContext = {
17696
- ...loopContext,
17697
- scope: updateScope
17698
- };
17706
+ const updateScope = resumePhase === "update" ? restored.activeScope : loopBindingNames.length === 0 ? iterationScope : iterationScope.iterationChild(loopBindingNames);
17707
+ const updateContext = phaseContext("update", updateScope);
17699
17708
  if (node.update !== void 0) {
17700
17709
  const update = await evaluateNode(node.update, updateContext);
17701
17710
  if (update.kind !== "normal") {
@@ -17703,6 +17712,7 @@ async function evaluateForStatement(node, context) {
17703
17712
  }
17704
17713
  }
17705
17714
  loopScope.copyInitializedBindingsFrom(updateScope, loopBindingNames);
17715
+ resumePhase = void 0;
17706
17716
  }
17707
17717
  }
17708
17718
  async function evaluateWhileStatement(node, context) {
@@ -22485,6 +22495,11 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
22485
22495
  const expression = record2(raw2);
22486
22496
  if (expression.kind === "binary") {
22487
22497
  fields(expression, ["kind", "left"]);
22498
+ } else if (expression.kind === "for") {
22499
+ fields(expression, ["kind", "phase", "loopScope", "activeScope"]);
22500
+ if (!["init", "test", "body", "update"].includes(String(expression.phase))) throw new TypeError("Invalid for-loop phase.");
22501
+ reference(expression.loopScope, ["scope-frame"]);
22502
+ reference(expression.activeScope, ["scope-frame"]);
22488
22503
  } else if (expression.kind === "identifier-assignment") {
22489
22504
  fields(expression, ["kind", "current"]);
22490
22505
  } else if (expression.kind === "member-assignment") {
@@ -22667,7 +22682,7 @@ function validateGuestFunctionAst(record3, origin) {
22667
22682
  pending.push({
22668
22683
  value,
22669
22684
  blocks,
22670
- expressions: node.type === "BinaryExpression" && key === "right" && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "binary" }]]) : node.type === "AssignmentExpression" && key === "right" && typeof node.nodeId === "number" && node.left.type === "Identifier" ? new Map([...frame.expressions, [node.nodeId, { kind: "identifier-assignment" }]]) : node.type === "AssignmentExpression" && key === "right" && typeof node.nodeId === "number" && node.left.type === "MemberExpression" ? new Map([...frame.expressions, [node.nodeId, {
22685
+ expressions: node.type === "ForStatement" && ["init", "test", "body", "update"].includes(key) && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "for", phase: key }]]) : node.type === "BinaryExpression" && key === "right" && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "binary" }]]) : node.type === "AssignmentExpression" && key === "right" && typeof node.nodeId === "number" && node.left.type === "Identifier" ? new Map([...frame.expressions, [node.nodeId, { kind: "identifier-assignment" }]]) : node.type === "AssignmentExpression" && key === "right" && typeof node.nodeId === "number" && node.left.type === "MemberExpression" ? new Map([...frame.expressions, [node.nodeId, {
22671
22686
  kind: "member-assignment",
22672
22687
  key: node.operator !== "=",
22673
22688
  superReceiver: node.left.object.type === "Super"
@@ -22697,7 +22712,7 @@ function validateGuestFunctionAst(record3, origin) {
22697
22712
  for (const [id, expression] of expressions) {
22698
22713
  const expected = yieldExpressions?.get(Number(id));
22699
22714
  const compatibleKind = expected?.kind === expression.kind || expected?.kind === "call" && expected.member === true && expression.kind === "array-call";
22700
- if (expected === void 0 || !compatibleKind || expected.kind !== "binary" && expected.kind !== "identifier-assignment" && expected.kind !== "member" && expected.kind !== "member-assignment" && expected.index !== expression.index || expected.kind === "member-assignment" && (expected.key !== Object.hasOwn(expression, "key") || expected.superReceiver !== Object.hasOwn(expression, "superReceiver")) || expected.kind === "member" && expected.superReceiver !== Object.hasOwn(expression, "superReceiver") || expected.kind === "object" && expected.key !== Object.hasOwn(expression, "key"))
22715
+ if (expected === void 0 || !compatibleKind || expected.kind !== "binary" && expected.kind !== "identifier-assignment" && expected.kind !== "member" && expected.kind !== "member-assignment" && expected.kind !== "for" && expected.index !== expression.index || expected.kind === "for" && expected.phase !== expression.phase || expected.kind === "member-assignment" && (expected.key !== Object.hasOwn(expression, "key") || expected.superReceiver !== Object.hasOwn(expression, "superReceiver")) || expected.kind === "member" && expected.superReceiver !== Object.hasOwn(expression, "superReceiver") || expected.kind === "object" && expected.key !== Object.hasOwn(expression, "key"))
22701
22716
  throw new TypeError("Invalid generator AST identity: unrelated expression continuation");
22702
22717
  }
22703
22718
  }
@@ -22909,8 +22924,8 @@ function validateDumpReferences(value, path, depth, state, heapIds, heap, role =
22909
22924
  fail("invalidValue", path, "Internal scopes cannot be guest data");
22910
22925
  }
22911
22926
  for (const [key, entry] of Object.entries(record3)) {
22912
- const childRole = role === "root" && key === "heap" ? "heap" : role === "heap" ? "heap-node" : role === "heap-node" && record3.kind === "guest-generator" && key === "blockScopes" ? "scope-map" : "data";
22913
- const scopeField = role === "scope-map" || role === "heap-node" && (record3.kind === "scope-frame" && key === "parent" || record3.kind === "guest-function" && key === "scope" || record3.kind === "guest-generator" && ["scope", "closureScope", "suspendedScope"].includes(key));
22927
+ const childRole = role === "root" && key === "heap" ? "heap" : role === "heap" ? "heap-node" : role === "heap-node" && record3.kind === "guest-generator" && key === "blockScopes" ? "scope-map" : role === "heap-node" && record3.kind === "guest-generator" && key === "expressionStates" ? "expressions" : role === "expressions" ? "expression" : "data";
22928
+ const scopeField = role === "scope-map" || role === "expression" && record3.kind === "for" && ["loopScope", "activeScope"].includes(key) || role === "heap-node" && (record3.kind === "scope-frame" && key === "parent" || record3.kind === "guest-function" && key === "scope" || record3.kind === "guest-generator" && ["scope", "closureScope", "suspendedScope"].includes(key));
22914
22929
  validateDumpReferences(entry, `${path}${formatKey(key)}`, depth + 1, state, heapIds, heap, childRole, scopeField);
22915
22930
  }
22916
22931
  }
@@ -38943,4 +38958,4 @@ export {
38943
38958
  FileSnapshotBackend,
38944
38959
  run
38945
38960
  };
38946
- //# sourceMappingURL=chunk-EY6YV2R2.js.map
38961
+ //# sourceMappingURL=chunk-DRN33ZMF.js.map