@poe-platform/safe-js 0.1.216 → 0.1.218
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-J5BFJAKX.js → chunk-7FIJ3D55.js} +134 -16
- package/dist/safe-js/chunks/chunk-7FIJ3D55.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-WS5ICU3W.js → chunk-Z3GR3FJR.js} +2 -2
- 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 +17 -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-Z3GR3FJR.js.map} +0 -0
|
@@ -8538,7 +8538,12 @@ 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) } :
|
|
8541
|
+
expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "object" ? {
|
|
8542
|
+
kind: "object",
|
|
8543
|
+
value: encode(expression.value),
|
|
8544
|
+
index: expression.index,
|
|
8545
|
+
...Object.hasOwn(expression, "key") ? { key: encode(expression.key) } : {}
|
|
8546
|
+
} : 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
8547
|
]))
|
|
8543
8548
|
},
|
|
8544
8549
|
sent: channel.sent.map((completion) => ({ type: completion.type, value: encode(completion.value) })),
|
|
@@ -9848,7 +9853,7 @@ function typeTag(value, builtinOnly = false) {
|
|
|
9848
9853
|
|
|
9849
9854
|
// packages/safe-js/src/interp/resume-target.ts
|
|
9850
9855
|
function containsResumeTarget(node, targetNodeIds) {
|
|
9851
|
-
if (node.nodeId !== void 0 && targetNodeIds.has(node.nodeId)) {
|
|
9856
|
+
if (targetNodeIds === void 0 ? node.type === "YieldExpression" : node.nodeId !== void 0 && targetNodeIds.has(node.nodeId)) {
|
|
9852
9857
|
return true;
|
|
9853
9858
|
}
|
|
9854
9859
|
if (node.type === "ArrowFunctionExpression" || node.type === "FunctionDeclaration" || node.type === "FunctionExpression") {
|
|
@@ -16508,10 +16513,31 @@ async function evaluateArrayExpression(node, context) {
|
|
|
16508
16513
|
}
|
|
16509
16514
|
}
|
|
16510
16515
|
async function evaluateObjectExpression(node, context) {
|
|
16511
|
-
const
|
|
16516
|
+
const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
16517
|
+
if (restored !== void 0 && (restored.kind !== "object" || restored.value === null || typeof restored.value !== "object" || Array.isArray(restored.value)))
|
|
16518
|
+
throw new TypeError("Invalid object expression continuation.");
|
|
16519
|
+
const object = restored?.kind === "object" ? restored.value : /* @__PURE__ */ Object.create(null);
|
|
16520
|
+
const state = {
|
|
16521
|
+
kind: "object",
|
|
16522
|
+
value: object,
|
|
16523
|
+
index: restored?.kind === "object" ? restored.index : 0
|
|
16524
|
+
};
|
|
16525
|
+
if (restored?.kind === "object" && Object.hasOwn(restored, "key")) {
|
|
16526
|
+
if (typeof restored.key !== "string" && typeof restored.key !== "number" && typeof restored.key !== "symbol")
|
|
16527
|
+
throw new TypeError("Invalid object expression key.");
|
|
16528
|
+
state.key = restored.key;
|
|
16529
|
+
}
|
|
16530
|
+
if (context.generatorYield !== void 0 && node.nodeId !== void 0) context = {
|
|
16531
|
+
...context,
|
|
16532
|
+
generatorExpressionStates: new Map([...context.generatorExpressionStates ?? [], [node.nodeId, state]])
|
|
16533
|
+
};
|
|
16512
16534
|
const release = retainValues(context.budget, () => [object]);
|
|
16513
16535
|
try {
|
|
16514
|
-
|
|
16536
|
+
const startIndex = state.index;
|
|
16537
|
+
for (let index = startIndex; index < node.properties.length; index++) {
|
|
16538
|
+
state.index = index;
|
|
16539
|
+
if (index !== startIndex) delete state.key;
|
|
16540
|
+
const property = node.properties[index];
|
|
16515
16541
|
if (property.type === "SpreadElement") {
|
|
16516
16542
|
const spreadEntries = await evaluateObjectSpread(property, context);
|
|
16517
16543
|
if (!spreadEntries.ok) {
|
|
@@ -16522,10 +16548,11 @@ async function evaluateObjectExpression(node, context) {
|
|
|
16522
16548
|
}
|
|
16523
16549
|
continue;
|
|
16524
16550
|
}
|
|
16525
|
-
const key = await evaluateObjectPropertyKey(property, context);
|
|
16551
|
+
const key = Object.hasOwn(state, "key") ? { ok: true, value: state.key } : await evaluateObjectPropertyKey(property, context);
|
|
16526
16552
|
if (!key.ok) {
|
|
16527
16553
|
return key.result;
|
|
16528
16554
|
}
|
|
16555
|
+
state.key = key.value;
|
|
16529
16556
|
const releaseKey = retainValues(context.budget, () => [key.value]);
|
|
16530
16557
|
let value;
|
|
16531
16558
|
try {
|
|
@@ -18075,6 +18102,12 @@ function createPatternContext(context, scope = context.scope, evaluate = evaluat
|
|
|
18075
18102
|
};
|
|
18076
18103
|
}
|
|
18077
18104
|
async function evaluateCallExpression(node, context) {
|
|
18105
|
+
const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
18106
|
+
if (restored?.kind === "call") return evaluateResolvedCallExpression(node, restored.callee, context, restored.thisValue);
|
|
18107
|
+
if (restored?.kind === "array-call") {
|
|
18108
|
+
if (!Array.isArray(restored.target) || !isArrayMethodName(restored.method)) throw new TypeError("Invalid array call continuation.");
|
|
18109
|
+
return evaluateArrayMethodCall(node, restored.target, restored.method, context);
|
|
18110
|
+
}
|
|
18078
18111
|
if (node.callee.type === "Super") {
|
|
18079
18112
|
const construction = context.functionEnvironment?.construction;
|
|
18080
18113
|
if (construction === void 0)
|
|
@@ -18095,12 +18128,15 @@ async function evaluateCallExpression(node, context) {
|
|
|
18095
18128
|
return evaluateResolvedCallExpression(node, callee.value, context);
|
|
18096
18129
|
}
|
|
18097
18130
|
async function evaluateNewExpression(node, context) {
|
|
18098
|
-
const
|
|
18131
|
+
const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
18132
|
+
const callee = restored?.kind === "new" ? { kind: "normal", value: restored.callee } : await evaluateNode(node.callee, context);
|
|
18099
18133
|
if (callee.kind !== "normal") {
|
|
18100
18134
|
return callee;
|
|
18101
18135
|
}
|
|
18102
18136
|
const name = getConstructorName(node.callee);
|
|
18103
|
-
const
|
|
18137
|
+
const call = createCallContinuation(node, callee.value, context);
|
|
18138
|
+
context = call.context;
|
|
18139
|
+
const args = await evaluateCallArguments(node.arguments, context, call.state);
|
|
18104
18140
|
if (!args.ok) {
|
|
18105
18141
|
return args.result;
|
|
18106
18142
|
}
|
|
@@ -18233,6 +18269,12 @@ async function evaluateMemberCallExpression(node, context) {
|
|
|
18233
18269
|
...reference,
|
|
18234
18270
|
property: await toPropertyKey(reference.property, context.budget, createCoercionContext(context))
|
|
18235
18271
|
};
|
|
18272
|
+
if (context.generatorYield !== void 0 && node.arguments.some((argument) => containsResumeTarget(argument.type === "SpreadElement" ? argument.argument : argument))) {
|
|
18273
|
+
if (Array.isArray(member.object) && !hasExplicitSandboxPrototype(member.object) && typeof member.property !== "symbol" && isArrayMethodName(member.property) && !Object.hasOwn(member.object, member.property))
|
|
18274
|
+
return evaluateArrayMethodCall(node, member.object, member.property, context);
|
|
18275
|
+
const receiver = member.superReceiver?.value ?? member.object;
|
|
18276
|
+
return evaluateResolvedCallExpression(node, await getPropertyValue(member.object, member.property, context, receiver), context, receiver);
|
|
18277
|
+
}
|
|
18236
18278
|
if (member.superReceiver !== void 0)
|
|
18237
18279
|
return evaluateResolvedCallExpression(node, await getPropertyValue(member.object, member.property, context, member.superReceiver.value), context, member.superReceiver.value);
|
|
18238
18280
|
if (typeof member.property === "symbol")
|
|
@@ -18397,7 +18439,21 @@ async function evaluateStringMethodCall(node, target, methodName, context) {
|
|
|
18397
18439
|
}
|
|
18398
18440
|
}
|
|
18399
18441
|
async function evaluateArrayMethodCall(node, target, methodName, context) {
|
|
18400
|
-
const
|
|
18442
|
+
const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
18443
|
+
if (restored !== void 0 && (restored.kind !== "array-call" || !Array.isArray(restored.args)))
|
|
18444
|
+
throw new TypeError("Invalid array call continuation.");
|
|
18445
|
+
const state = {
|
|
18446
|
+
kind: "array-call",
|
|
18447
|
+
target,
|
|
18448
|
+
method: methodName,
|
|
18449
|
+
args: restored?.kind === "array-call" ? restored.args : [],
|
|
18450
|
+
index: restored?.kind === "array-call" ? restored.index : 0
|
|
18451
|
+
};
|
|
18452
|
+
if (context.generatorYield !== void 0 && node.nodeId !== void 0) context = {
|
|
18453
|
+
...context,
|
|
18454
|
+
generatorExpressionStates: new Map([...context.generatorExpressionStates ?? [], [node.nodeId, state]])
|
|
18455
|
+
};
|
|
18456
|
+
const args = await evaluateCallArguments(node.arguments, context, state);
|
|
18401
18457
|
if (!args.ok) {
|
|
18402
18458
|
return args.result;
|
|
18403
18459
|
}
|
|
@@ -18943,7 +18999,9 @@ async function evaluateResolvedCallExpression(node, callee, context, thisValue =
|
|
|
18943
18999
|
value: void 0
|
|
18944
19000
|
};
|
|
18945
19001
|
}
|
|
18946
|
-
const
|
|
19002
|
+
const call = createCallContinuation(node, callee, context, thisValue);
|
|
19003
|
+
context = call.context;
|
|
19004
|
+
const args = await evaluateCallArguments(node.arguments, context, call.state);
|
|
18947
19005
|
if (!args.ok) {
|
|
18948
19006
|
return args.result;
|
|
18949
19007
|
}
|
|
@@ -19043,11 +19101,30 @@ async function invokeSandboxClosure(callee, args, context, stack, span, thisValu
|
|
|
19043
19101
|
leaveCall();
|
|
19044
19102
|
}
|
|
19045
19103
|
}
|
|
19046
|
-
|
|
19047
|
-
const
|
|
19104
|
+
function createCallContinuation(node, callee, context, thisValue = void 0) {
|
|
19105
|
+
const kind = node.type === "NewExpression" ? "new" : "call";
|
|
19106
|
+
const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
19107
|
+
if (restored !== void 0 && (restored.kind !== "call" && restored.kind !== "new" || restored.kind !== kind || !Array.isArray(restored.args)))
|
|
19108
|
+
throw new TypeError("Invalid call expression continuation.");
|
|
19109
|
+
const state = {
|
|
19110
|
+
kind,
|
|
19111
|
+
callee,
|
|
19112
|
+
thisValue,
|
|
19113
|
+
args: restored?.kind === "call" || restored?.kind === "new" ? restored.args : [],
|
|
19114
|
+
index: restored?.kind === "call" || restored?.kind === "new" ? restored.index : 0
|
|
19115
|
+
};
|
|
19116
|
+
return { state, context: context.generatorYield === void 0 || node.nodeId === void 0 ? context : {
|
|
19117
|
+
...context,
|
|
19118
|
+
generatorExpressionStates: new Map([...context.generatorExpressionStates ?? [], [node.nodeId, state]])
|
|
19119
|
+
} };
|
|
19120
|
+
}
|
|
19121
|
+
async function evaluateCallArguments(args, context, continuation) {
|
|
19122
|
+
const values = continuation?.args ?? [];
|
|
19048
19123
|
const release = retainValues(context.budget, () => values);
|
|
19049
19124
|
try {
|
|
19050
|
-
for (
|
|
19125
|
+
for (let index = continuation?.index ?? 0; index < args.length; index++) {
|
|
19126
|
+
if (continuation !== void 0) continuation.index = index;
|
|
19127
|
+
const arg = args[index];
|
|
19051
19128
|
if (arg.type === "SpreadElement") {
|
|
19052
19129
|
const spreadValues = await evaluateSpreadElement(arg, context);
|
|
19053
19130
|
if (!spreadValues.ok) {
|
|
@@ -22305,10 +22382,24 @@ function validateGuestHeapNode(raw, heap) {
|
|
|
22305
22382
|
const expression = record2(raw2);
|
|
22306
22383
|
if (expression.kind === "binary") {
|
|
22307
22384
|
fields(expression, ["kind", "left"]);
|
|
22385
|
+
} else if (expression.kind === "object") {
|
|
22386
|
+
fields(expression, ["kind", "value", "index"], ["key"]);
|
|
22387
|
+
integer(expression.index);
|
|
22388
|
+
reference(expression.value, ["object", "guest-object"]);
|
|
22308
22389
|
} else if (expression.kind === "array") {
|
|
22309
22390
|
fields(expression, ["kind", "values", "index"]);
|
|
22310
22391
|
integer(expression.index);
|
|
22311
22392
|
reference(expression.values, ["array"]);
|
|
22393
|
+
} else if (expression.kind === "call" || expression.kind === "new") {
|
|
22394
|
+
fields(expression, ["kind", "callee", "thisValue", "args", "index"]);
|
|
22395
|
+
integer(expression.index);
|
|
22396
|
+
reference(expression.args, ["array"]);
|
|
22397
|
+
} else if (expression.kind === "array-call") {
|
|
22398
|
+
fields(expression, ["kind", "target", "method", "args", "index"]);
|
|
22399
|
+
if (typeof expression.method !== "string") throw new TypeError("Invalid array method.");
|
|
22400
|
+
integer(expression.index);
|
|
22401
|
+
reference(expression.args, ["array"]);
|
|
22402
|
+
reference(expression.target, ["array"]);
|
|
22312
22403
|
} else throw new TypeError("Invalid expression continuation.");
|
|
22313
22404
|
}
|
|
22314
22405
|
}
|
|
@@ -22413,12 +22504,38 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22413
22504
|
yieldExpressions = frame.expressions;
|
|
22414
22505
|
}
|
|
22415
22506
|
for (const [key, value] of Object.entries(node)) {
|
|
22416
|
-
if (node.type === "
|
|
22507
|
+
if (node.type === "ObjectExpression" && key === "properties" && typeof node.nodeId === "number" && Array.isArray(value)) {
|
|
22508
|
+
const id = node.nodeId;
|
|
22509
|
+
value.forEach((property, index) => {
|
|
22510
|
+
if (property.type === "SpreadElement") {
|
|
22511
|
+
pending.push({
|
|
22512
|
+
value: property.argument,
|
|
22513
|
+
blocks,
|
|
22514
|
+
finalizers: frame.finalizers,
|
|
22515
|
+
expressions: new Map([...frame.expressions, [id, { kind: "object", index, key: false }]])
|
|
22516
|
+
});
|
|
22517
|
+
} else {
|
|
22518
|
+
for (const part of ["key", "value"]) pending.push({
|
|
22519
|
+
value: property[part],
|
|
22520
|
+
blocks,
|
|
22521
|
+
finalizers: frame.finalizers,
|
|
22522
|
+
expressions: new Map([...frame.expressions, [id, { kind: "object", index, key: part === "value" }]])
|
|
22523
|
+
});
|
|
22524
|
+
}
|
|
22525
|
+
});
|
|
22526
|
+
continue;
|
|
22527
|
+
}
|
|
22528
|
+
if ((node.type === "ArrayExpression" && key === "elements" || (node.type === "CallExpression" || node.type === "NewExpression") && key === "arguments") && typeof node.nodeId === "number" && Array.isArray(value)) {
|
|
22529
|
+
const kind = node.type === "ArrayExpression" ? "array" : node.type === "CallExpression" ? "call" : "new";
|
|
22417
22530
|
value.forEach((element, index) => pending.push({
|
|
22418
22531
|
value: element,
|
|
22419
22532
|
blocks,
|
|
22420
22533
|
finalizers: frame.finalizers,
|
|
22421
|
-
expressions: new Map([...frame.expressions, [node.nodeId, {
|
|
22534
|
+
expressions: new Map([...frame.expressions, [node.nodeId, {
|
|
22535
|
+
kind,
|
|
22536
|
+
index,
|
|
22537
|
+
member: kind === "call" && node.callee?.type === "MemberExpression"
|
|
22538
|
+
}]])
|
|
22422
22539
|
}));
|
|
22423
22540
|
continue;
|
|
22424
22541
|
}
|
|
@@ -22450,7 +22567,8 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22450
22567
|
throw new TypeError("Invalid generator AST identity: missing expression continuation");
|
|
22451
22568
|
for (const [id, expression] of expressions) {
|
|
22452
22569
|
const expected = yieldExpressions?.get(Number(id));
|
|
22453
|
-
|
|
22570
|
+
const compatibleKind = expected?.kind === expression.kind || expected?.kind === "call" && expected.member === true && expression.kind === "array-call";
|
|
22571
|
+
if (expected === void 0 || !compatibleKind || expected.kind !== "binary" && expected.index !== expression.index || expected.kind === "object" && expected.key !== Object.hasOwn(expression, "key"))
|
|
22454
22572
|
throw new TypeError("Invalid generator AST identity: unrelated expression continuation");
|
|
22455
22573
|
}
|
|
22456
22574
|
}
|
|
@@ -38635,4 +38753,4 @@ export {
|
|
|
38635
38753
|
FileSnapshotBackend,
|
|
38636
38754
|
run
|
|
38637
38755
|
};
|
|
38638
|
-
//# sourceMappingURL=chunk-
|
|
38756
|
+
//# sourceMappingURL=chunk-7FIJ3D55.js.map
|