@poe-platform/safe-js 0.1.236 → 0.1.238
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-YXXCUBTE.js → chunk-74HTYPJQ.js} +40 -12
- package/dist/safe-js/chunks/{chunk-YXXCUBTE.js.map → chunk-74HTYPJQ.js.map} +2 -2
- package/dist/safe-js/chunks/{chunk-IMG6SFST.js → chunk-QTSCRXUU.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 +6 -0
- package/package.json +2 -2
- /package/dist/safe-js/chunks/{chunk-IMG6SFST.js.map → chunk-QTSCRXUU.js.map} +0 -0
|
@@ -16716,31 +16716,50 @@ async function yieldGeneratorValue(value, node, context) {
|
|
|
16716
16716
|
return completion;
|
|
16717
16717
|
}
|
|
16718
16718
|
async function evaluateYieldDelegate(node, context) {
|
|
16719
|
-
const
|
|
16719
|
+
const saved = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
16720
|
+
if (saved !== void 0 && saved.kind !== "yield-delegate") throw new TypeError("Invalid delegated yield continuation.");
|
|
16721
|
+
const argument = saved === void 0 ? await evaluateNode(node.argument, context) : { kind: "normal", hasValue: true, value: saved.value };
|
|
16720
16722
|
if (argument.kind !== "normal") {
|
|
16721
16723
|
return argument;
|
|
16722
16724
|
}
|
|
16723
|
-
const iterator = await acquireSandboxIterator(
|
|
16725
|
+
const iterator = saved === void 0 ? await acquireSandboxIterator(
|
|
16724
16726
|
argument.value,
|
|
16725
16727
|
context.budget,
|
|
16726
16728
|
createCoercionContext(context),
|
|
16727
16729
|
context.asyncGenerator,
|
|
16728
16730
|
context.signal
|
|
16729
|
-
);
|
|
16731
|
+
) : "kind" in saved.iterator ? await restoreSandboxIterator(saved.iterator, context.budget, createCoercionContext(context), context.signal) : saved.iterator;
|
|
16730
16732
|
if (iterator === void 0) {
|
|
16731
16733
|
throw new TypeError(`${String(argument.value)} is not a supported iterable`);
|
|
16732
16734
|
}
|
|
16735
|
+
const state = {
|
|
16736
|
+
kind: "yield-delegate",
|
|
16737
|
+
async: context.asyncGenerator === true,
|
|
16738
|
+
value: argument.value,
|
|
16739
|
+
current: saved?.current,
|
|
16740
|
+
iterator
|
|
16741
|
+
};
|
|
16742
|
+
if (node.nodeId !== void 0) context = {
|
|
16743
|
+
...context,
|
|
16744
|
+
generatorExpressionStates: new Map([...context.generatorExpressionStates ?? [], [node.nodeId, state]])
|
|
16745
|
+
};
|
|
16733
16746
|
const releaseIterator = retainValues(context.budget, () => [
|
|
16734
16747
|
argument.value,
|
|
16735
|
-
iterator.retainedValue
|
|
16748
|
+
iterator.retainedValue,
|
|
16749
|
+
state.current
|
|
16736
16750
|
]);
|
|
16737
16751
|
try {
|
|
16738
16752
|
let completion = {
|
|
16739
16753
|
type: "normal",
|
|
16740
16754
|
value: void 0
|
|
16741
16755
|
};
|
|
16742
|
-
const replay = context.generatorResume?.sent ?? [];
|
|
16756
|
+
const replay = saved === void 0 ? context.generatorResume?.sent ?? [] : [];
|
|
16743
16757
|
let replayIndex = 0;
|
|
16758
|
+
if (saved !== void 0) {
|
|
16759
|
+
completion = await yieldGeneratorValue(saved.current, node, context);
|
|
16760
|
+
if (context.generatorResume !== void 0) context.generatorResume.completed = true;
|
|
16761
|
+
context.generatorResume = void 0;
|
|
16762
|
+
}
|
|
16744
16763
|
while (true) {
|
|
16745
16764
|
const method = completion.type === "normal" ? "next" : completion.type;
|
|
16746
16765
|
const iteratorMethod = iterator.getOperation === void 0 ? iterator[method] : await iterator.getOperation(method);
|
|
@@ -16773,6 +16792,7 @@ async function evaluateYieldDelegate(node, context) {
|
|
|
16773
16792
|
replayIndex += 1;
|
|
16774
16793
|
continue;
|
|
16775
16794
|
}
|
|
16795
|
+
state.current = value;
|
|
16776
16796
|
completion = await yieldGeneratorValue(value, node, context);
|
|
16777
16797
|
context.generatorResume = void 0;
|
|
16778
16798
|
}
|
|
@@ -21033,7 +21053,12 @@ function captureGuestHeapNode(value, encode) {
|
|
|
21033
21053
|
...value.state !== "suspended" || origin2.expressionStates === void 0 ? {} : {
|
|
21034
21054
|
expressionStates: Object.fromEntries([...origin2.expressionStates].map(([id, expression]) => [
|
|
21035
21055
|
String(id),
|
|
21036
|
-
expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "declaration" ? { ...expression } : expression.kind === "
|
|
21056
|
+
expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "declaration" ? { ...expression } : expression.kind === "yield-delegate" ? {
|
|
21057
|
+
...expression,
|
|
21058
|
+
value: encode(expression.value),
|
|
21059
|
+
current: encode(expression.current),
|
|
21060
|
+
iterator: mapIteratorSnapshot("kind" in expression.iterator ? expression.iterator : expression.iterator.snapshot?.() ?? { kind: "unsupported" }, encode)
|
|
21061
|
+
} : expression.kind === "pattern-source" ? { kind: "pattern-source", value: encode(expression.value) } : expression.kind === "object-pattern" ? {
|
|
21037
21062
|
kind: "object-pattern",
|
|
21038
21063
|
phase: expression.phase,
|
|
21039
21064
|
index: expression.index,
|
|
@@ -22712,8 +22737,11 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
22712
22737
|
if (!absent(expression.key) && typeof expression.key !== "string") reference(expression.key, ["symbol"]);
|
|
22713
22738
|
if (Object.hasOwn(expression, "referenceObject") && expression.phase !== "binding") throw new TypeError("Invalid prepared object pattern reference.");
|
|
22714
22739
|
if (Object.hasOwn(expression, "referenceKey") && typeof expression.referenceKey !== "string") reference(expression.referenceKey, ["symbol"]);
|
|
22715
|
-
} else if (expression.kind === "for-of-array" || expression.kind === "for-of-iterator" || expression.kind === "array-pattern") {
|
|
22716
|
-
if (expression.kind === "
|
|
22740
|
+
} else if (expression.kind === "for-of-array" || expression.kind === "for-of-iterator" || expression.kind === "array-pattern" || expression.kind === "yield-delegate") {
|
|
22741
|
+
if (expression.kind === "yield-delegate") {
|
|
22742
|
+
fields(expression, ["kind", "async", "value", "current", "iterator"]);
|
|
22743
|
+
if (typeof expression.async !== "boolean") throw new TypeError("Invalid delegated yield protocol.");
|
|
22744
|
+
} else if (expression.kind === "array-pattern") {
|
|
22717
22745
|
fields(expression, ["kind", "phase", "index", "done", "current", "iterator"], ["referenceObject", "referenceKey"]);
|
|
22718
22746
|
if (!["reference", "binding"].includes(String(expression.phase)) || typeof expression.done !== "boolean" || Object.hasOwn(expression, "referenceObject") !== Object.hasOwn(expression, "referenceKey")) throw new TypeError("Invalid array pattern state.");
|
|
22719
22747
|
if (Object.hasOwn(expression, "referenceKey") && typeof expression.referenceKey !== "string") reference(expression.referenceKey, ["symbol"]);
|
|
@@ -22729,7 +22757,7 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
22729
22757
|
if (!["left", "body"].includes(String(expression.phase))) throw new TypeError("Invalid for-of phase.");
|
|
22730
22758
|
reference(expression.scope, ["scope-frame"]);
|
|
22731
22759
|
}
|
|
22732
|
-
integer(expression.index);
|
|
22760
|
+
if (expression.kind !== "yield-delegate") integer(expression.index);
|
|
22733
22761
|
if (expression.kind === "for-of-array") reference(expression.values, ["array", "guest-array"]);
|
|
22734
22762
|
else {
|
|
22735
22763
|
let iterator = record2(expression.iterator);
|
|
@@ -22907,7 +22935,7 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22907
22935
|
if (node.type === "YieldExpression" && node.nodeId === record3.yieldNodeId) {
|
|
22908
22936
|
yieldBlocks = blocks;
|
|
22909
22937
|
yieldFinalizers = frame.finalizers;
|
|
22910
|
-
yieldExpressions = frame.expressions;
|
|
22938
|
+
yieldExpressions = node.delegate === true && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "yield-delegate", async: record3.async === true }]]) : frame.expressions;
|
|
22911
22939
|
}
|
|
22912
22940
|
for (const [key, value] of Object.entries(node)) {
|
|
22913
22941
|
if (node.type === "VariableDeclaration" && key === "declarations" && typeof node.nodeId === "number" && Array.isArray(value)) {
|
|
@@ -23012,7 +23040,7 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
23012
23040
|
for (const [id, expression] of expressions) {
|
|
23013
23041
|
const expected = yieldExpressions?.get(Number(id));
|
|
23014
23042
|
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";
|
|
23015
|
-
if (expected === void 0 || !compatibleKind || expected.kind !== "binary" && 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 === "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"))
|
|
23043
|
+
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"))
|
|
23016
23044
|
throw new TypeError("Invalid generator AST identity: unrelated expression continuation");
|
|
23017
23045
|
}
|
|
23018
23046
|
}
|
|
@@ -39258,4 +39286,4 @@ export {
|
|
|
39258
39286
|
FileSnapshotBackend,
|
|
39259
39287
|
run
|
|
39260
39288
|
};
|
|
39261
|
-
//# sourceMappingURL=chunk-
|
|
39289
|
+
//# sourceMappingURL=chunk-74HTYPJQ.js.map
|