@poe-platform/safe-js 0.1.240 → 0.1.242
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-JD5SV5DJ.js → chunk-FMIETDHG.js} +2 -2
- package/dist/safe-js/chunks/{chunk-IIEGYHM4.js → chunk-HL454CBB.js} +84 -35
- package/dist/safe-js/chunks/chunk-HL454CBB.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-IIEGYHM4.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-JD5SV5DJ.js.map → chunk-FMIETDHG.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-HL454CBB.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-FMIETDHG.js.map
|
|
@@ -16113,50 +16113,74 @@ 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) {
|
|
16179
|
+
if (context.generatorResume !== void 0 && context.generatorResume.completed !== true) {
|
|
16180
|
+
const target = /* @__PURE__ */ new Set([context.generatorResume.yieldNodeId]);
|
|
16181
|
+
if (containsResumeTarget(node.consequent, target)) return evaluateNode(node.consequent, context);
|
|
16182
|
+
if (node.alternate !== void 0 && containsResumeTarget(node.alternate, target)) return evaluateNode(node.alternate, context);
|
|
16183
|
+
}
|
|
16160
16184
|
const test = await evaluateNode(node.test, context);
|
|
16161
16185
|
if (test.kind !== "normal") {
|
|
16162
16186
|
return test;
|
|
@@ -21059,7 +21083,7 @@ function captureGuestHeapNode(value, encode) {
|
|
|
21059
21083
|
...value.state !== "suspended" || origin2.expressionStates === void 0 ? {} : {
|
|
21060
21084
|
expressionStates: Object.fromEntries([...origin2.expressionStates].map(([id, expression]) => [
|
|
21061
21085
|
String(id),
|
|
21062
|
-
expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "declaration" ? { ...expression } : expression.kind === "yield-delegate" ? {
|
|
21086
|
+
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" ? {
|
|
21063
21087
|
...expression,
|
|
21064
21088
|
value: encode(expression.value),
|
|
21065
21089
|
current: encode(expression.current),
|
|
@@ -22806,6 +22830,13 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
22806
22830
|
if (Object.hasOwn(expression, "phase") && !["left", "body"].includes(String(expression.phase))) throw new TypeError("Invalid for-in phase.");
|
|
22807
22831
|
if (array(expression.keys).some((key) => typeof key !== "string") || integer(expression.index) >= array(expression.keys).length) throw new TypeError("Invalid for-in continuation.");
|
|
22808
22832
|
reference(expression.scope, ["scope-frame"]);
|
|
22833
|
+
} else if (expression.kind === "switch") {
|
|
22834
|
+
fields(expression, ["kind", "phase", "index", "statementIndex", "value", "scope"]);
|
|
22835
|
+
if (!["test", "body"].includes(String(expression.phase))) throw new TypeError("Invalid switch phase.");
|
|
22836
|
+
integer(expression.index);
|
|
22837
|
+
integer(expression.statementIndex);
|
|
22838
|
+
if (expression.phase === "test" && expression.statementIndex !== 0) throw new TypeError("Invalid switch test position.");
|
|
22839
|
+
reference(expression.scope, ["scope-frame"]);
|
|
22809
22840
|
} else if (expression.kind === "for") {
|
|
22810
22841
|
fields(expression, ["kind", "phase", "loopScope", "activeScope"]);
|
|
22811
22842
|
if (!["init", "test", "body", "update"].includes(String(expression.phase))) throw new TypeError("Invalid for-loop phase.");
|
|
@@ -22944,6 +22975,24 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22944
22975
|
yieldExpressions = node.delegate === true && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "yield-delegate", async: record3.async === true }]]) : frame.expressions;
|
|
22945
22976
|
}
|
|
22946
22977
|
for (const [key, value] of Object.entries(node)) {
|
|
22978
|
+
if (node.type === "SwitchStatement" && key === "cases" && typeof node.nodeId === "number" && Array.isArray(value)) {
|
|
22979
|
+
const id = node.nodeId;
|
|
22980
|
+
value.forEach((entry, index) => {
|
|
22981
|
+
pending.push({
|
|
22982
|
+
value: entry.test,
|
|
22983
|
+
blocks,
|
|
22984
|
+
finalizers: frame.finalizers,
|
|
22985
|
+
expressions: new Map([...frame.expressions, [id, { kind: "switch", phase: "test", index, statementIndex: 0 }]])
|
|
22986
|
+
});
|
|
22987
|
+
entry.consequent.forEach((statement, statementIndex) => pending.push({
|
|
22988
|
+
value: statement,
|
|
22989
|
+
blocks,
|
|
22990
|
+
finalizers: frame.finalizers,
|
|
22991
|
+
expressions: new Map([...frame.expressions, [id, { kind: "switch", phase: "body", index, statementIndex }]])
|
|
22992
|
+
}));
|
|
22993
|
+
});
|
|
22994
|
+
continue;
|
|
22995
|
+
}
|
|
22947
22996
|
if (node.type === "VariableDeclaration" && key === "declarations" && typeof node.nodeId === "number" && Array.isArray(value)) {
|
|
22948
22997
|
value.forEach((declarator, index) => pending.push({
|
|
22949
22998
|
value: declarator,
|
|
@@ -23046,7 +23095,7 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
23046
23095
|
for (const [id, expression] of expressions) {
|
|
23047
23096
|
const expected = yieldExpressions?.get(Number(id));
|
|
23048
23097
|
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";
|
|
23049
|
-
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"))
|
|
23098
|
+
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"))
|
|
23050
23099
|
throw new TypeError("Invalid generator AST identity: unrelated expression continuation");
|
|
23051
23100
|
}
|
|
23052
23101
|
}
|
|
@@ -23259,7 +23308,7 @@ function validateDumpReferences(value, path, depth, state, heapIds, heap, role =
|
|
|
23259
23308
|
}
|
|
23260
23309
|
for (const [key, entry] of Object.entries(record3)) {
|
|
23261
23310
|
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";
|
|
23262
|
-
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));
|
|
23311
|
+
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));
|
|
23263
23312
|
validateDumpReferences(entry, `${path}${formatKey(key)}`, depth + 1, state, heapIds, heap, childRole, scopeField);
|
|
23264
23313
|
}
|
|
23265
23314
|
}
|
|
@@ -39292,4 +39341,4 @@ export {
|
|
|
39292
39341
|
FileSnapshotBackend,
|
|
39293
39342
|
run
|
|
39294
39343
|
};
|
|
39295
|
-
//# sourceMappingURL=chunk-
|
|
39344
|
+
//# sourceMappingURL=chunk-HL454CBB.js.map
|