@poe-platform/safe-js 0.1.239 → 0.1.241
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-KRIQESNQ.js → chunk-DND27FSF.js} +2 -2
- package/dist/safe-js/chunks/{chunk-GM6QCOXT.js → chunk-L2JX3HPQ.js} +95 -47
- package/dist/safe-js/chunks/chunk-L2JX3HPQ.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 +7 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-GM6QCOXT.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-KRIQESNQ.js.map → chunk-DND27FSF.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-L2JX3HPQ.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-DND27FSF.js.map
|
|
@@ -16113,48 +16113,67 @@ function predeclareStatementListBindings(statements, context, functionBody = fal
|
|
|
16113
16113
|
}
|
|
16114
16114
|
}
|
|
16115
16115
|
async function evaluateSwitchStatement(node, context) {
|
|
16116
|
-
const
|
|
16116
|
+
const saved = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
16117
|
+
if (saved !== void 0 && saved.kind !== "switch") throw new TypeError("Invalid switch continuation.");
|
|
16118
|
+
const discriminant = saved === void 0 ? await evaluateNode(node.discriminant, context) : { kind: "normal", value: saved.value };
|
|
16117
16119
|
if (discriminant.kind !== "normal") {
|
|
16118
16120
|
return discriminant;
|
|
16119
16121
|
}
|
|
16120
|
-
const
|
|
16121
|
-
|
|
16122
|
+
const progress = saved === void 0 ? { kind: "switch", phase: "test", index: 0, statementIndex: 0, value: discriminant.value, scope: context.scope.child() } : { ...saved };
|
|
16123
|
+
const switchContext = {
|
|
16124
|
+
...context,
|
|
16125
|
+
scope: progress.scope,
|
|
16126
|
+
...context.generatorYield === void 0 || node.nodeId === void 0 ? {} : {
|
|
16127
|
+
generatorExpressionStates: new Map([...context.generatorExpressionStates ?? [], [node.nodeId, progress]])
|
|
16128
|
+
}
|
|
16129
|
+
};
|
|
16130
|
+
if (saved === void 0) predeclareStatementListBindings(
|
|
16122
16131
|
node.cases.flatMap((switchCase) => switchCase.consequent),
|
|
16123
16132
|
switchContext
|
|
16124
16133
|
);
|
|
16125
|
-
|
|
16126
|
-
|
|
16127
|
-
|
|
16128
|
-
|
|
16129
|
-
|
|
16130
|
-
|
|
16131
|
-
|
|
16132
|
-
|
|
16133
|
-
|
|
16134
|
-
|
|
16135
|
-
|
|
16134
|
+
const release = retainValues(context.budget, () => [progress.value]);
|
|
16135
|
+
try {
|
|
16136
|
+
const defaultIndex = node.cases.findIndex((entry) => entry.test === void 0);
|
|
16137
|
+
let startIndex = saved?.phase === "body" ? saved.index : void 0;
|
|
16138
|
+
for (let index = progress.index; startIndex === void 0 && index < node.cases.length; index += 1) {
|
|
16139
|
+
const switchCase = node.cases[index];
|
|
16140
|
+
if (switchCase.test === void 0) {
|
|
16141
|
+
continue;
|
|
16142
|
+
}
|
|
16143
|
+
progress.index = index;
|
|
16144
|
+
const test = await evaluateNode(switchCase.test, switchContext);
|
|
16145
|
+
if (test.kind !== "normal") {
|
|
16146
|
+
return test;
|
|
16147
|
+
}
|
|
16148
|
+
if (discriminant.value === test.value) {
|
|
16149
|
+
startIndex = index;
|
|
16150
|
+
break;
|
|
16151
|
+
}
|
|
16136
16152
|
}
|
|
16137
|
-
|
|
16138
|
-
|
|
16139
|
-
|
|
16153
|
+
startIndex ??= defaultIndex < 0 ? void 0 : defaultIndex;
|
|
16154
|
+
if (startIndex === void 0) {
|
|
16155
|
+
return normalEmptyResult();
|
|
16140
16156
|
}
|
|
16141
|
-
|
|
16142
|
-
|
|
16143
|
-
|
|
16144
|
-
|
|
16145
|
-
|
|
16146
|
-
|
|
16147
|
-
|
|
16148
|
-
|
|
16149
|
-
|
|
16150
|
-
|
|
16151
|
-
|
|
16152
|
-
|
|
16153
|
-
|
|
16157
|
+
for (let caseIndex = startIndex; caseIndex < node.cases.length; caseIndex += 1) {
|
|
16158
|
+
progress.phase = "body";
|
|
16159
|
+
progress.index = caseIndex;
|
|
16160
|
+
const statements = node.cases[caseIndex].consequent;
|
|
16161
|
+
for (let statementIndex = saved?.phase === "body" && caseIndex === saved.index ? saved.statementIndex : 0; statementIndex < statements.length; statementIndex++) {
|
|
16162
|
+
progress.statementIndex = statementIndex;
|
|
16163
|
+
const statement = statements[statementIndex];
|
|
16164
|
+
const result = await evaluateNode(statement, switchContext);
|
|
16165
|
+
if (result.kind === "break" && result.label === void 0) {
|
|
16166
|
+
return normalEmptyResult();
|
|
16167
|
+
}
|
|
16168
|
+
if (result.kind !== "normal") {
|
|
16169
|
+
return result;
|
|
16170
|
+
}
|
|
16154
16171
|
}
|
|
16155
16172
|
}
|
|
16173
|
+
return normalEmptyResult();
|
|
16174
|
+
} finally {
|
|
16175
|
+
release();
|
|
16156
16176
|
}
|
|
16157
|
-
return normalEmptyResult();
|
|
16158
16177
|
}
|
|
16159
16178
|
async function evaluateIfStatement(node, context) {
|
|
16160
16179
|
const test = await evaluateNode(node.test, context);
|
|
@@ -16545,20 +16564,24 @@ async function evaluateWhileStatement(node, context) {
|
|
|
16545
16564
|
}
|
|
16546
16565
|
}
|
|
16547
16566
|
async function evaluateDoWhileStatement(node, context) {
|
|
16567
|
+
let resumeTest = context.generatorResume !== void 0 && context.generatorResume.completed !== true && containsResumeTarget(node.test, /* @__PURE__ */ new Set([context.generatorResume.yieldNodeId]));
|
|
16548
16568
|
while (true) {
|
|
16549
|
-
|
|
16550
|
-
|
|
16551
|
-
|
|
16552
|
-
|
|
16553
|
-
|
|
16554
|
-
|
|
16555
|
-
|
|
16556
|
-
|
|
16557
|
-
|
|
16558
|
-
|
|
16559
|
-
|
|
16560
|
-
|
|
16569
|
+
if (!resumeTest) {
|
|
16570
|
+
const iterationContext = createLoopIterationContext(context, context.scope);
|
|
16571
|
+
emitLoopIterationBreakpoint(node, iterationContext);
|
|
16572
|
+
const result = await evaluateNode(node.body, iterationContext);
|
|
16573
|
+
if (isMatchingBreak(result, loopLabels(node))) {
|
|
16574
|
+
return {
|
|
16575
|
+
kind: "normal",
|
|
16576
|
+
hasValue: false,
|
|
16577
|
+
value: void 0
|
|
16578
|
+
};
|
|
16579
|
+
}
|
|
16580
|
+
if (result.kind !== "normal" && !isMatchingContinue(result, loopLabels(node))) {
|
|
16581
|
+
return result;
|
|
16582
|
+
}
|
|
16561
16583
|
}
|
|
16584
|
+
resumeTest = false;
|
|
16562
16585
|
const test = await evaluateNode(node.test, context);
|
|
16563
16586
|
if (test.kind !== "normal") {
|
|
16564
16587
|
return test;
|
|
@@ -21055,7 +21078,7 @@ function captureGuestHeapNode(value, encode) {
|
|
|
21055
21078
|
...value.state !== "suspended" || origin2.expressionStates === void 0 ? {} : {
|
|
21056
21079
|
expressionStates: Object.fromEntries([...origin2.expressionStates].map(([id, expression]) => [
|
|
21057
21080
|
String(id),
|
|
21058
|
-
expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "declaration" ? { ...expression } : expression.kind === "yield-delegate" ? {
|
|
21081
|
+
expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "declaration" ? { ...expression } : expression.kind === "switch" ? { ...expression, value: encode(expression.value), scope: encode(expression.scope) } : expression.kind === "yield-delegate" ? {
|
|
21059
21082
|
...expression,
|
|
21060
21083
|
value: encode(expression.value),
|
|
21061
21084
|
current: encode(expression.current),
|
|
@@ -22802,6 +22825,13 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
22802
22825
|
if (Object.hasOwn(expression, "phase") && !["left", "body"].includes(String(expression.phase))) throw new TypeError("Invalid for-in phase.");
|
|
22803
22826
|
if (array(expression.keys).some((key) => typeof key !== "string") || integer(expression.index) >= array(expression.keys).length) throw new TypeError("Invalid for-in continuation.");
|
|
22804
22827
|
reference(expression.scope, ["scope-frame"]);
|
|
22828
|
+
} else if (expression.kind === "switch") {
|
|
22829
|
+
fields(expression, ["kind", "phase", "index", "statementIndex", "value", "scope"]);
|
|
22830
|
+
if (!["test", "body"].includes(String(expression.phase))) throw new TypeError("Invalid switch phase.");
|
|
22831
|
+
integer(expression.index);
|
|
22832
|
+
integer(expression.statementIndex);
|
|
22833
|
+
if (expression.phase === "test" && expression.statementIndex !== 0) throw new TypeError("Invalid switch test position.");
|
|
22834
|
+
reference(expression.scope, ["scope-frame"]);
|
|
22805
22835
|
} else if (expression.kind === "for") {
|
|
22806
22836
|
fields(expression, ["kind", "phase", "loopScope", "activeScope"]);
|
|
22807
22837
|
if (!["init", "test", "body", "update"].includes(String(expression.phase))) throw new TypeError("Invalid for-loop phase.");
|
|
@@ -22940,6 +22970,24 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22940
22970
|
yieldExpressions = node.delegate === true && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "yield-delegate", async: record3.async === true }]]) : frame.expressions;
|
|
22941
22971
|
}
|
|
22942
22972
|
for (const [key, value] of Object.entries(node)) {
|
|
22973
|
+
if (node.type === "SwitchStatement" && key === "cases" && typeof node.nodeId === "number" && Array.isArray(value)) {
|
|
22974
|
+
const id = node.nodeId;
|
|
22975
|
+
value.forEach((entry, index) => {
|
|
22976
|
+
pending.push({
|
|
22977
|
+
value: entry.test,
|
|
22978
|
+
blocks,
|
|
22979
|
+
finalizers: frame.finalizers,
|
|
22980
|
+
expressions: new Map([...frame.expressions, [id, { kind: "switch", phase: "test", index, statementIndex: 0 }]])
|
|
22981
|
+
});
|
|
22982
|
+
entry.consequent.forEach((statement, statementIndex) => pending.push({
|
|
22983
|
+
value: statement,
|
|
22984
|
+
blocks,
|
|
22985
|
+
finalizers: frame.finalizers,
|
|
22986
|
+
expressions: new Map([...frame.expressions, [id, { kind: "switch", phase: "body", index, statementIndex }]])
|
|
22987
|
+
}));
|
|
22988
|
+
});
|
|
22989
|
+
continue;
|
|
22990
|
+
}
|
|
22943
22991
|
if (node.type === "VariableDeclaration" && key === "declarations" && typeof node.nodeId === "number" && Array.isArray(value)) {
|
|
22944
22992
|
value.forEach((declarator, index) => pending.push({
|
|
22945
22993
|
value: declarator,
|
|
@@ -23042,7 +23090,7 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
23042
23090
|
for (const [id, expression] of expressions) {
|
|
23043
23091
|
const expected = yieldExpressions?.get(Number(id));
|
|
23044
23092
|
const compatibleKind = expected?.kind === expression.kind || expected?.kind === "for-of" && (expression.kind === "for-of-iterator" || !expected.async && expression.kind === "for-of-array") || expected?.kind === "call" && expected.member === true && expression.kind === "array-call";
|
|
23045
|
-
if (expected === void 0 || !compatibleKind || expected.kind !== "binary" && expected.kind !== "yield-delegate" && expected.kind !== "pattern-source" && expected.kind !== "identifier-assignment" && expected.kind !== "member" && expected.kind !== "member-assignment" && expected.kind !== "for" && expected.kind !== "for-in" && expected.kind !== "for-of" && expected.index !== expression.index || expected.kind === "yield-delegate" && expected.async !== expression.async || (expected.kind === "for" || expected.kind === "for-of") && expected.phase !== expression.phase || expected.kind === "for-in" && expected.phase !== (expression.phase ?? "body") || expected.kind === "object-pattern" && expected.key !== (expression.phase === "key") || expected.kind === "for-of" && expression.kind === "for-of-iterator" && expected.async !== expression.async || 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"))
|
|
23093
|
+
if (expected === void 0 || !compatibleKind || expected.kind !== "binary" && expected.kind !== "yield-delegate" && expected.kind !== "pattern-source" && expected.kind !== "identifier-assignment" && expected.kind !== "member" && expected.kind !== "member-assignment" && expected.kind !== "for" && expected.kind !== "for-in" && expected.kind !== "for-of" && expected.index !== expression.index || expected.kind === "yield-delegate" && expected.async !== expression.async || expected.kind === "switch" && (expected.phase !== expression.phase || expected.statementIndex !== expression.statementIndex) || (expected.kind === "for" || expected.kind === "for-of") && expected.phase !== expression.phase || expected.kind === "for-in" && expected.phase !== (expression.phase ?? "body") || expected.kind === "object-pattern" && expected.key !== (expression.phase === "key") || expected.kind === "for-of" && expression.kind === "for-of-iterator" && expected.async !== expression.async || 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"))
|
|
23046
23094
|
throw new TypeError("Invalid generator AST identity: unrelated expression continuation");
|
|
23047
23095
|
}
|
|
23048
23096
|
}
|
|
@@ -23255,7 +23303,7 @@ function validateDumpReferences(value, path, depth, state, heapIds, heap, role =
|
|
|
23255
23303
|
}
|
|
23256
23304
|
for (const [key, entry] of Object.entries(record3)) {
|
|
23257
23305
|
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";
|
|
23258
|
-
const scopeField = role === "scope-map" || role === "expression" && (record3.kind === "for" && ["loopScope", "activeScope"].includes(key) || ["for-in", "for-of-array", "for-of-iterator"].includes(String(record3.kind)) && 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));
|
|
23306
|
+
const scopeField = role === "scope-map" || role === "expression" && (record3.kind === "for" && ["loopScope", "activeScope"].includes(key) || ["switch", "for-in", "for-of-array", "for-of-iterator"].includes(String(record3.kind)) && 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));
|
|
23259
23307
|
validateDumpReferences(entry, `${path}${formatKey(key)}`, depth + 1, state, heapIds, heap, childRole, scopeField);
|
|
23260
23308
|
}
|
|
23261
23309
|
}
|
|
@@ -39288,4 +39336,4 @@ export {
|
|
|
39288
39336
|
FileSnapshotBackend,
|
|
39289
39337
|
run
|
|
39290
39338
|
};
|
|
39291
|
-
//# sourceMappingURL=chunk-
|
|
39339
|
+
//# sourceMappingURL=chunk-L2JX3HPQ.js.map
|