@poe-platform/safe-js 0.1.216 → 0.1.217
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-WS5ICU3W.js → chunk-42FLUHBI.js} +2 -2
- package/dist/safe-js/chunks/{chunk-J5BFJAKX.js → chunk-F2O4RZOG.js} +79 -13
- package/dist/safe-js/chunks/chunk-F2O4RZOG.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 +12 -0
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-J5BFJAKX.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-WS5ICU3W.js.map → chunk-42FLUHBI.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-F2O4RZOG.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-42FLUHBI.js.map
|
|
@@ -8538,7 +8538,7 @@ function captureGuestHeapNode(value, encode) {
|
|
|
8538
8538
|
...value.state !== "suspended" || origin2.expressionStates === void 0 ? {} : {
|
|
8539
8539
|
expressionStates: Object.fromEntries([...origin2.expressionStates].map(([id, expression]) => [
|
|
8540
8540
|
String(id),
|
|
8541
|
-
expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : { kind: "array", values: encode(expression.values), index: expression.index }
|
|
8541
|
+
expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "array" ? { kind: "array", values: encode(expression.values), index: expression.index } : expression.kind === "array-call" ? { kind: "array-call", target: encode(expression.target), method: expression.method, args: encode(expression.args), index: expression.index } : { kind: expression.kind, callee: encode(expression.callee), thisValue: encode(expression.thisValue), args: encode(expression.args), index: expression.index }
|
|
8542
8542
|
]))
|
|
8543
8543
|
},
|
|
8544
8544
|
sent: channel.sent.map((completion) => ({ type: completion.type, value: encode(completion.value) })),
|
|
@@ -9848,7 +9848,7 @@ function typeTag(value, builtinOnly = false) {
|
|
|
9848
9848
|
|
|
9849
9849
|
// packages/safe-js/src/interp/resume-target.ts
|
|
9850
9850
|
function containsResumeTarget(node, targetNodeIds) {
|
|
9851
|
-
if (node.nodeId !== void 0 && targetNodeIds.has(node.nodeId)) {
|
|
9851
|
+
if (targetNodeIds === void 0 ? node.type === "YieldExpression" : node.nodeId !== void 0 && targetNodeIds.has(node.nodeId)) {
|
|
9852
9852
|
return true;
|
|
9853
9853
|
}
|
|
9854
9854
|
if (node.type === "ArrowFunctionExpression" || node.type === "FunctionDeclaration" || node.type === "FunctionExpression") {
|
|
@@ -18075,6 +18075,12 @@ function createPatternContext(context, scope = context.scope, evaluate = evaluat
|
|
|
18075
18075
|
};
|
|
18076
18076
|
}
|
|
18077
18077
|
async function evaluateCallExpression(node, context) {
|
|
18078
|
+
const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
18079
|
+
if (restored?.kind === "call") return evaluateResolvedCallExpression(node, restored.callee, context, restored.thisValue);
|
|
18080
|
+
if (restored?.kind === "array-call") {
|
|
18081
|
+
if (!Array.isArray(restored.target) || !isArrayMethodName(restored.method)) throw new TypeError("Invalid array call continuation.");
|
|
18082
|
+
return evaluateArrayMethodCall(node, restored.target, restored.method, context);
|
|
18083
|
+
}
|
|
18078
18084
|
if (node.callee.type === "Super") {
|
|
18079
18085
|
const construction = context.functionEnvironment?.construction;
|
|
18080
18086
|
if (construction === void 0)
|
|
@@ -18095,12 +18101,15 @@ async function evaluateCallExpression(node, context) {
|
|
|
18095
18101
|
return evaluateResolvedCallExpression(node, callee.value, context);
|
|
18096
18102
|
}
|
|
18097
18103
|
async function evaluateNewExpression(node, context) {
|
|
18098
|
-
const
|
|
18104
|
+
const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
18105
|
+
const callee = restored?.kind === "new" ? { kind: "normal", value: restored.callee } : await evaluateNode(node.callee, context);
|
|
18099
18106
|
if (callee.kind !== "normal") {
|
|
18100
18107
|
return callee;
|
|
18101
18108
|
}
|
|
18102
18109
|
const name = getConstructorName(node.callee);
|
|
18103
|
-
const
|
|
18110
|
+
const call = createCallContinuation(node, callee.value, context);
|
|
18111
|
+
context = call.context;
|
|
18112
|
+
const args = await evaluateCallArguments(node.arguments, context, call.state);
|
|
18104
18113
|
if (!args.ok) {
|
|
18105
18114
|
return args.result;
|
|
18106
18115
|
}
|
|
@@ -18233,6 +18242,12 @@ async function evaluateMemberCallExpression(node, context) {
|
|
|
18233
18242
|
...reference,
|
|
18234
18243
|
property: await toPropertyKey(reference.property, context.budget, createCoercionContext(context))
|
|
18235
18244
|
};
|
|
18245
|
+
if (context.generatorYield !== void 0 && node.arguments.some((argument) => containsResumeTarget(argument.type === "SpreadElement" ? argument.argument : argument))) {
|
|
18246
|
+
if (Array.isArray(member.object) && !hasExplicitSandboxPrototype(member.object) && typeof member.property !== "symbol" && isArrayMethodName(member.property) && !Object.hasOwn(member.object, member.property))
|
|
18247
|
+
return evaluateArrayMethodCall(node, member.object, member.property, context);
|
|
18248
|
+
const receiver = member.superReceiver?.value ?? member.object;
|
|
18249
|
+
return evaluateResolvedCallExpression(node, await getPropertyValue(member.object, member.property, context, receiver), context, receiver);
|
|
18250
|
+
}
|
|
18236
18251
|
if (member.superReceiver !== void 0)
|
|
18237
18252
|
return evaluateResolvedCallExpression(node, await getPropertyValue(member.object, member.property, context, member.superReceiver.value), context, member.superReceiver.value);
|
|
18238
18253
|
if (typeof member.property === "symbol")
|
|
@@ -18397,7 +18412,21 @@ async function evaluateStringMethodCall(node, target, methodName, context) {
|
|
|
18397
18412
|
}
|
|
18398
18413
|
}
|
|
18399
18414
|
async function evaluateArrayMethodCall(node, target, methodName, context) {
|
|
18400
|
-
const
|
|
18415
|
+
const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
18416
|
+
if (restored !== void 0 && (restored.kind !== "array-call" || !Array.isArray(restored.args)))
|
|
18417
|
+
throw new TypeError("Invalid array call continuation.");
|
|
18418
|
+
const state = {
|
|
18419
|
+
kind: "array-call",
|
|
18420
|
+
target,
|
|
18421
|
+
method: methodName,
|
|
18422
|
+
args: restored?.kind === "array-call" ? restored.args : [],
|
|
18423
|
+
index: restored?.kind === "array-call" ? restored.index : 0
|
|
18424
|
+
};
|
|
18425
|
+
if (context.generatorYield !== void 0 && node.nodeId !== void 0) context = {
|
|
18426
|
+
...context,
|
|
18427
|
+
generatorExpressionStates: new Map([...context.generatorExpressionStates ?? [], [node.nodeId, state]])
|
|
18428
|
+
};
|
|
18429
|
+
const args = await evaluateCallArguments(node.arguments, context, state);
|
|
18401
18430
|
if (!args.ok) {
|
|
18402
18431
|
return args.result;
|
|
18403
18432
|
}
|
|
@@ -18943,7 +18972,9 @@ async function evaluateResolvedCallExpression(node, callee, context, thisValue =
|
|
|
18943
18972
|
value: void 0
|
|
18944
18973
|
};
|
|
18945
18974
|
}
|
|
18946
|
-
const
|
|
18975
|
+
const call = createCallContinuation(node, callee, context, thisValue);
|
|
18976
|
+
context = call.context;
|
|
18977
|
+
const args = await evaluateCallArguments(node.arguments, context, call.state);
|
|
18947
18978
|
if (!args.ok) {
|
|
18948
18979
|
return args.result;
|
|
18949
18980
|
}
|
|
@@ -19043,11 +19074,30 @@ async function invokeSandboxClosure(callee, args, context, stack, span, thisValu
|
|
|
19043
19074
|
leaveCall();
|
|
19044
19075
|
}
|
|
19045
19076
|
}
|
|
19046
|
-
|
|
19047
|
-
const
|
|
19077
|
+
function createCallContinuation(node, callee, context, thisValue = void 0) {
|
|
19078
|
+
const kind = node.type === "NewExpression" ? "new" : "call";
|
|
19079
|
+
const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
19080
|
+
if (restored !== void 0 && (restored.kind !== "call" && restored.kind !== "new" || restored.kind !== kind || !Array.isArray(restored.args)))
|
|
19081
|
+
throw new TypeError("Invalid call expression continuation.");
|
|
19082
|
+
const state = {
|
|
19083
|
+
kind,
|
|
19084
|
+
callee,
|
|
19085
|
+
thisValue,
|
|
19086
|
+
args: restored?.kind === "call" || restored?.kind === "new" ? restored.args : [],
|
|
19087
|
+
index: restored?.kind === "call" || restored?.kind === "new" ? restored.index : 0
|
|
19088
|
+
};
|
|
19089
|
+
return { state, context: context.generatorYield === void 0 || node.nodeId === void 0 ? context : {
|
|
19090
|
+
...context,
|
|
19091
|
+
generatorExpressionStates: new Map([...context.generatorExpressionStates ?? [], [node.nodeId, state]])
|
|
19092
|
+
} };
|
|
19093
|
+
}
|
|
19094
|
+
async function evaluateCallArguments(args, context, continuation) {
|
|
19095
|
+
const values = continuation?.args ?? [];
|
|
19048
19096
|
const release = retainValues(context.budget, () => values);
|
|
19049
19097
|
try {
|
|
19050
|
-
for (
|
|
19098
|
+
for (let index = continuation?.index ?? 0; index < args.length; index++) {
|
|
19099
|
+
if (continuation !== void 0) continuation.index = index;
|
|
19100
|
+
const arg = args[index];
|
|
19051
19101
|
if (arg.type === "SpreadElement") {
|
|
19052
19102
|
const spreadValues = await evaluateSpreadElement(arg, context);
|
|
19053
19103
|
if (!spreadValues.ok) {
|
|
@@ -22309,6 +22359,16 @@ function validateGuestHeapNode(raw, heap) {
|
|
|
22309
22359
|
fields(expression, ["kind", "values", "index"]);
|
|
22310
22360
|
integer(expression.index);
|
|
22311
22361
|
reference(expression.values, ["array"]);
|
|
22362
|
+
} else if (expression.kind === "call" || expression.kind === "new") {
|
|
22363
|
+
fields(expression, ["kind", "callee", "thisValue", "args", "index"]);
|
|
22364
|
+
integer(expression.index);
|
|
22365
|
+
reference(expression.args, ["array"]);
|
|
22366
|
+
} else if (expression.kind === "array-call") {
|
|
22367
|
+
fields(expression, ["kind", "target", "method", "args", "index"]);
|
|
22368
|
+
if (typeof expression.method !== "string") throw new TypeError("Invalid array method.");
|
|
22369
|
+
integer(expression.index);
|
|
22370
|
+
reference(expression.args, ["array"]);
|
|
22371
|
+
reference(expression.target, ["array"]);
|
|
22312
22372
|
} else throw new TypeError("Invalid expression continuation.");
|
|
22313
22373
|
}
|
|
22314
22374
|
}
|
|
@@ -22413,12 +22473,17 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22413
22473
|
yieldExpressions = frame.expressions;
|
|
22414
22474
|
}
|
|
22415
22475
|
for (const [key, value] of Object.entries(node)) {
|
|
22416
|
-
if (node.type === "ArrayExpression" && key === "elements" && typeof node.nodeId === "number" && Array.isArray(value)) {
|
|
22476
|
+
if ((node.type === "ArrayExpression" && key === "elements" || (node.type === "CallExpression" || node.type === "NewExpression") && key === "arguments") && typeof node.nodeId === "number" && Array.isArray(value)) {
|
|
22477
|
+
const kind = node.type === "ArrayExpression" ? "array" : node.type === "CallExpression" ? "call" : "new";
|
|
22417
22478
|
value.forEach((element, index) => pending.push({
|
|
22418
22479
|
value: element,
|
|
22419
22480
|
blocks,
|
|
22420
22481
|
finalizers: frame.finalizers,
|
|
22421
|
-
expressions: new Map([...frame.expressions, [node.nodeId, {
|
|
22482
|
+
expressions: new Map([...frame.expressions, [node.nodeId, {
|
|
22483
|
+
kind,
|
|
22484
|
+
index,
|
|
22485
|
+
member: kind === "call" && node.callee?.type === "MemberExpression"
|
|
22486
|
+
}]])
|
|
22422
22487
|
}));
|
|
22423
22488
|
continue;
|
|
22424
22489
|
}
|
|
@@ -22450,7 +22515,8 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22450
22515
|
throw new TypeError("Invalid generator AST identity: missing expression continuation");
|
|
22451
22516
|
for (const [id, expression] of expressions) {
|
|
22452
22517
|
const expected = yieldExpressions?.get(Number(id));
|
|
22453
|
-
|
|
22518
|
+
const compatibleKind = expected?.kind === expression.kind || expected?.kind === "call" && expected.member === true && expression.kind === "array-call";
|
|
22519
|
+
if (expected === void 0 || !compatibleKind || expected.kind !== "binary" && expected.index !== expression.index)
|
|
22454
22520
|
throw new TypeError("Invalid generator AST identity: unrelated expression continuation");
|
|
22455
22521
|
}
|
|
22456
22522
|
}
|
|
@@ -38635,4 +38701,4 @@ export {
|
|
|
38635
38701
|
FileSnapshotBackend,
|
|
38636
38702
|
run
|
|
38637
38703
|
};
|
|
38638
|
-
//# sourceMappingURL=chunk-
|
|
38704
|
+
//# sourceMappingURL=chunk-F2O4RZOG.js.map
|