@poe-platform/safe-js 0.1.226 → 0.1.228
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/safe-js/chunks/{chunk-XOV3P7HH.js → chunk-NJ2FVOTB.js} +2 -2
- package/dist/safe-js/chunks/{chunk-EY6YV2R2.js → chunk-PHJUQHVC.js} +74 -42
- package/dist/safe-js/chunks/chunk-PHJUQHVC.js.map +7 -0
- package/dist/safe-js/cli.js +2 -2
- package/dist/safe-js/core.js +1 -1
- package/dist/safe-js/index.js +2 -2
- package/dist/safe-js/interp/generator-expression-state.d.ts +13 -1
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-EY6YV2R2.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-XOV3P7HH.js.map → chunk-NJ2FVOTB.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-PHJUQHVC.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-
|
|
8252
|
+
//# sourceMappingURL=chunk-NJ2FVOTB.js.map
|
|
@@ -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-in" ? { ...expression, keys: [...expression.keys], object: encode(expression.object), scope: encode(expression.scope) } : 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),
|
|
@@ -17541,7 +17541,9 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
17541
17541
|
}
|
|
17542
17542
|
}
|
|
17543
17543
|
async function evaluateForInStatement(node, context) {
|
|
17544
|
-
const
|
|
17544
|
+
const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
17545
|
+
if (restored !== void 0 && restored.kind !== "for-in") throw new TypeError("Invalid for-in continuation.");
|
|
17546
|
+
const right = restored === void 0 ? await evaluateNode(node.right, context) : { kind: "normal", value: restored.object };
|
|
17545
17547
|
if (right.kind !== "normal") {
|
|
17546
17548
|
return right;
|
|
17547
17549
|
}
|
|
@@ -17550,21 +17552,32 @@ async function evaluateForInStatement(node, context) {
|
|
|
17550
17552
|
return normalEmptyResult();
|
|
17551
17553
|
}
|
|
17552
17554
|
const restoredIteration = consumeRestoredLoopIteration(node, context);
|
|
17553
|
-
const keys = restoredIteration === void 0 || typeof restoredIteration === "number" ? forInKeys(object, context.budget) : restoredIteration.values.map(String);
|
|
17554
|
-
const restoredIndex = typeof restoredIteration === "number" ? restoredIteration : restoredIteration?.index ?? 0;
|
|
17555
|
+
const keys = restored?.keys ?? (restoredIteration === void 0 || typeof restoredIteration === "number" ? forInKeys(object, context.budget) : restoredIteration.values.map(String));
|
|
17556
|
+
const restoredIndex = restored?.index ?? (typeof restoredIteration === "number" ? restoredIteration : restoredIteration?.index ?? 0);
|
|
17555
17557
|
for (let index = restoredIndex; index < keys.length; index += 1) {
|
|
17556
17558
|
context.activeLoopIterations.set(node.nodeId ?? -1, { index, values: keys });
|
|
17557
17559
|
const key = keys[index];
|
|
17558
|
-
|
|
17560
|
+
const resuming = restored !== void 0 && index === restored.index;
|
|
17561
|
+
if (!resuming && !hasForInProperty(object, key, context.budget)) {
|
|
17559
17562
|
continue;
|
|
17560
17563
|
}
|
|
17561
|
-
const scope = context.scope.child();
|
|
17562
|
-
|
|
17563
|
-
|
|
17564
|
-
|
|
17565
|
-
|
|
17564
|
+
const scope = resuming ? restored.scope : context.scope.child();
|
|
17565
|
+
if (!resuming) {
|
|
17566
|
+
const binding = await bindForInLoopVariable(node.left, key, scope, context);
|
|
17567
|
+
if (!binding.ok) {
|
|
17568
|
+
context.activeLoopIterations.delete(node.nodeId ?? -1);
|
|
17569
|
+
return binding.result;
|
|
17570
|
+
}
|
|
17566
17571
|
}
|
|
17567
|
-
const iterationContext = createLoopIterationContext(
|
|
17572
|
+
const iterationContext = createLoopIterationContext({
|
|
17573
|
+
...context,
|
|
17574
|
+
...context.generatorYield === void 0 || node.nodeId === void 0 ? {} : {
|
|
17575
|
+
generatorExpressionStates: new Map([
|
|
17576
|
+
...context.generatorExpressionStates ?? [],
|
|
17577
|
+
[node.nodeId, { kind: "for-in", object: right.value, keys, index, scope }]
|
|
17578
|
+
])
|
|
17579
|
+
}
|
|
17580
|
+
}, scope);
|
|
17568
17581
|
emitLoopIterationBreakpoint(node, iterationContext);
|
|
17569
17582
|
const result = await evaluateNode(node.body, iterationContext);
|
|
17570
17583
|
if (isMatchingBreak(result, loopLabels(node))) {
|
|
@@ -17646,14 +17659,27 @@ function normalEmptyResult() {
|
|
|
17646
17659
|
return { kind: "normal", hasValue: false, value: void 0 };
|
|
17647
17660
|
}
|
|
17648
17661
|
async function evaluateForStatement(node, context) {
|
|
17649
|
-
const
|
|
17662
|
+
const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
17663
|
+
if (restored !== void 0 && restored.kind !== "for") throw new TypeError("Invalid for-loop continuation.");
|
|
17664
|
+
let resumePhase = restored?.phase;
|
|
17665
|
+
const loopScope = restored?.loopScope ?? context.scope.child();
|
|
17650
17666
|
const loopBindingNames = getForStatementBindingNames(node);
|
|
17651
17667
|
const loopContext = {
|
|
17652
17668
|
...context,
|
|
17653
17669
|
scope: loopScope
|
|
17654
17670
|
};
|
|
17655
|
-
|
|
17656
|
-
|
|
17671
|
+
const phaseContext = (phase, scope) => ({
|
|
17672
|
+
...loopContext,
|
|
17673
|
+
scope,
|
|
17674
|
+
...context.generatorYield === void 0 || node.nodeId === void 0 ? {} : {
|
|
17675
|
+
generatorExpressionStates: new Map([
|
|
17676
|
+
...context.generatorExpressionStates ?? [],
|
|
17677
|
+
[node.nodeId, { kind: "for", phase, loopScope, activeScope: scope }]
|
|
17678
|
+
])
|
|
17679
|
+
}
|
|
17680
|
+
});
|
|
17681
|
+
if (node.init !== void 0 && (resumePhase === void 0 || resumePhase === "init")) {
|
|
17682
|
+
const init = await evaluateNode(node.init, phaseContext("init", loopScope));
|
|
17657
17683
|
if (init.kind !== "normal") {
|
|
17658
17684
|
return init;
|
|
17659
17685
|
}
|
|
@@ -17661,8 +17687,8 @@ async function evaluateForStatement(node, context) {
|
|
|
17661
17687
|
while (true) {
|
|
17662
17688
|
context.budget.visitNode();
|
|
17663
17689
|
context.stats.nodeVisits += 1;
|
|
17664
|
-
if (node.test !== void 0) {
|
|
17665
|
-
const test = await evaluateNode(node.test,
|
|
17690
|
+
if (node.test !== void 0 && resumePhase !== "body" && resumePhase !== "update") {
|
|
17691
|
+
const test = await evaluateNode(node.test, phaseContext("test", loopScope));
|
|
17666
17692
|
if (test.kind !== "normal") {
|
|
17667
17693
|
return test;
|
|
17668
17694
|
}
|
|
@@ -17674,28 +17700,24 @@ async function evaluateForStatement(node, context) {
|
|
|
17674
17700
|
};
|
|
17675
17701
|
}
|
|
17676
17702
|
}
|
|
17677
|
-
const iterationScope = loopBindingNames.length === 0 ? loopScope : loopScope.iterationChild(loopBindingNames);
|
|
17678
|
-
|
|
17679
|
-
|
|
17680
|
-
|
|
17681
|
-
|
|
17682
|
-
|
|
17683
|
-
|
|
17684
|
-
|
|
17685
|
-
|
|
17686
|
-
|
|
17687
|
-
|
|
17688
|
-
|
|
17689
|
-
|
|
17690
|
-
|
|
17691
|
-
|
|
17692
|
-
return result;
|
|
17703
|
+
const iterationScope = resumePhase === "body" || resumePhase === "update" ? restored.activeScope : loopBindingNames.length === 0 ? loopScope : loopScope.iterationChild(loopBindingNames);
|
|
17704
|
+
if (resumePhase !== "update") {
|
|
17705
|
+
const iterationContext = createLoopIterationContext(phaseContext("body", iterationScope), iterationScope);
|
|
17706
|
+
emitLoopIterationBreakpoint(node, iterationContext);
|
|
17707
|
+
const result = await evaluateNode(node.body, iterationContext);
|
|
17708
|
+
if (isMatchingBreak(result, loopLabels(node))) {
|
|
17709
|
+
return {
|
|
17710
|
+
kind: "normal",
|
|
17711
|
+
hasValue: false,
|
|
17712
|
+
value: void 0
|
|
17713
|
+
};
|
|
17714
|
+
}
|
|
17715
|
+
if (result.kind !== "normal" && !isMatchingContinue(result, loopLabels(node))) {
|
|
17716
|
+
return result;
|
|
17717
|
+
}
|
|
17693
17718
|
}
|
|
17694
|
-
const updateScope = loopBindingNames.length === 0 ? iterationScope : iterationScope.iterationChild(loopBindingNames);
|
|
17695
|
-
const updateContext =
|
|
17696
|
-
...loopContext,
|
|
17697
|
-
scope: updateScope
|
|
17698
|
-
};
|
|
17719
|
+
const updateScope = resumePhase === "update" ? restored.activeScope : loopBindingNames.length === 0 ? iterationScope : iterationScope.iterationChild(loopBindingNames);
|
|
17720
|
+
const updateContext = phaseContext("update", updateScope);
|
|
17699
17721
|
if (node.update !== void 0) {
|
|
17700
17722
|
const update = await evaluateNode(node.update, updateContext);
|
|
17701
17723
|
if (update.kind !== "normal") {
|
|
@@ -17703,6 +17725,7 @@ async function evaluateForStatement(node, context) {
|
|
|
17703
17725
|
}
|
|
17704
17726
|
}
|
|
17705
17727
|
loopScope.copyInitializedBindingsFrom(updateScope, loopBindingNames);
|
|
17728
|
+
resumePhase = void 0;
|
|
17706
17729
|
}
|
|
17707
17730
|
}
|
|
17708
17731
|
async function evaluateWhileStatement(node, context) {
|
|
@@ -22485,6 +22508,15 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
22485
22508
|
const expression = record2(raw2);
|
|
22486
22509
|
if (expression.kind === "binary") {
|
|
22487
22510
|
fields(expression, ["kind", "left"]);
|
|
22511
|
+
} else if (expression.kind === "for-in") {
|
|
22512
|
+
fields(expression, ["kind", "object", "keys", "index", "scope"]);
|
|
22513
|
+
if (array(expression.keys).some((key) => typeof key !== "string") || integer(expression.index) >= array(expression.keys).length) throw new TypeError("Invalid for-in continuation.");
|
|
22514
|
+
reference(expression.scope, ["scope-frame"]);
|
|
22515
|
+
} else if (expression.kind === "for") {
|
|
22516
|
+
fields(expression, ["kind", "phase", "loopScope", "activeScope"]);
|
|
22517
|
+
if (!["init", "test", "body", "update"].includes(String(expression.phase))) throw new TypeError("Invalid for-loop phase.");
|
|
22518
|
+
reference(expression.loopScope, ["scope-frame"]);
|
|
22519
|
+
reference(expression.activeScope, ["scope-frame"]);
|
|
22488
22520
|
} else if (expression.kind === "identifier-assignment") {
|
|
22489
22521
|
fields(expression, ["kind", "current"]);
|
|
22490
22522
|
} else if (expression.kind === "member-assignment") {
|
|
@@ -22667,7 +22699,7 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22667
22699
|
pending.push({
|
|
22668
22700
|
value,
|
|
22669
22701
|
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, {
|
|
22702
|
+
expressions: node.type === "ForInStatement" && key === "body" && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "for-in" }]]) : 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
22703
|
kind: "member-assignment",
|
|
22672
22704
|
key: node.operator !== "=",
|
|
22673
22705
|
superReceiver: node.left.object.type === "Super"
|
|
@@ -22697,7 +22729,7 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22697
22729
|
for (const [id, expression] of expressions) {
|
|
22698
22730
|
const expected = yieldExpressions?.get(Number(id));
|
|
22699
22731
|
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"))
|
|
22732
|
+
if (expected === void 0 || !compatibleKind || expected.kind !== "binary" && expected.kind !== "identifier-assignment" && expected.kind !== "member" && expected.kind !== "member-assignment" && expected.kind !== "for" && expected.kind !== "for-in" && 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
22733
|
throw new TypeError("Invalid generator AST identity: unrelated expression continuation");
|
|
22702
22734
|
}
|
|
22703
22735
|
}
|
|
@@ -22909,8 +22941,8 @@ function validateDumpReferences(value, path, depth, state, heapIds, heap, role =
|
|
|
22909
22941
|
fail("invalidValue", path, "Internal scopes cannot be guest data");
|
|
22910
22942
|
}
|
|
22911
22943
|
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));
|
|
22944
|
+
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";
|
|
22945
|
+
const scopeField = role === "scope-map" || role === "expression" && (record3.kind === "for" && ["loopScope", "activeScope"].includes(key) || record3.kind === "for-in" && key === "scope") || 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
22946
|
validateDumpReferences(entry, `${path}${formatKey(key)}`, depth + 1, state, heapIds, heap, childRole, scopeField);
|
|
22915
22947
|
}
|
|
22916
22948
|
}
|
|
@@ -38943,4 +38975,4 @@ export {
|
|
|
38943
38975
|
FileSnapshotBackend,
|
|
38944
38976
|
run
|
|
38945
38977
|
};
|
|
38946
|
-
//# sourceMappingURL=chunk-
|
|
38978
|
+
//# sourceMappingURL=chunk-PHJUQHVC.js.map
|