@poe-platform/safe-js 0.1.232 → 0.1.234
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-HRN2V5KG.js → chunk-HZZVOMG2.js} +2 -2
- package/dist/safe-js/chunks/{chunk-CCJSAZ73.js → chunk-PV36YBZS.js} +128 -50
- package/dist/safe-js/chunks/chunk-PV36YBZS.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-CCJSAZ73.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-HRN2V5KG.js.map → chunk-HZZVOMG2.js.map} +0 -0
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
validateMigrationSemantics,
|
|
28
28
|
validateSnapshotData,
|
|
29
29
|
validateSnapshotMigration
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-PV36YBZS.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-HZZVOMG2.js.map
|
|
@@ -10011,38 +10011,65 @@ async function bindObjectPattern2(pattern, value, target, scope, context) {
|
|
|
10011
10011
|
if (value === void 0 || value === null) {
|
|
10012
10012
|
throw new TypeError("Object destructuring requires a non-nullish value.");
|
|
10013
10013
|
}
|
|
10014
|
-
const
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
|
|
10014
|
+
const saved = pattern.nodeId === void 0 ? void 0 : context.restoredPatternState?.(pattern.nodeId);
|
|
10015
|
+
if (saved !== void 0 && saved.kind !== "object-pattern") throw new TypeError("Invalid object pattern continuation.");
|
|
10016
|
+
const excludedKeys = new Set(saved?.excludedKeys);
|
|
10017
|
+
const excludedKeyValues = [...excludedKeys];
|
|
10018
|
+
let state;
|
|
10019
|
+
const release = context.budget === void 0 ? () => void 0 : retainValues(
|
|
10020
|
+
context.budget,
|
|
10021
|
+
() => [value, state?.current, state?.key, state?.referenceObject, state?.referenceKey, ...state?.excludedKeys ?? []]
|
|
10022
|
+
);
|
|
10023
|
+
try {
|
|
10024
|
+
for (let index = saved?.index ?? 0; index < pattern.properties.length; index++) {
|
|
10025
|
+
const property = pattern.properties[index];
|
|
10026
|
+
state = saved !== void 0 && index === saved.index ? { ...saved, excludedKeys: excludedKeyValues } : {
|
|
10027
|
+
kind: "object-pattern",
|
|
10028
|
+
phase: property.type === "RestElement" ? "reference" : "key",
|
|
10029
|
+
index,
|
|
10030
|
+
excludedKeys: excludedKeyValues,
|
|
10031
|
+
key: void 0,
|
|
10032
|
+
current: void 0
|
|
10033
|
+
};
|
|
10034
|
+
const currentState = state;
|
|
10035
|
+
const propertyContext = pattern.nodeId === void 0 ? context : context.withPatternState?.(pattern.nodeId, state) ?? context;
|
|
10036
|
+
if (property.type !== "RestElement" && state.phase === "key") {
|
|
10037
|
+
const key = await evaluatePatternKey(property, propertyContext);
|
|
10038
|
+
if (!key.ok) return key;
|
|
10039
|
+
state.key = typeof key.value === "symbol" ? key.value : String(key.value);
|
|
10040
|
+
if (!excludedKeys.has(state.key)) excludedKeyValues.push(state.key);
|
|
10041
|
+
excludedKeys.add(state.key);
|
|
10042
|
+
state.phase = "reference";
|
|
10043
|
+
}
|
|
10044
|
+
const element = property.type === "RestElement" ? property : property.value;
|
|
10045
|
+
const binding = state.phase === "binding" ? await bindPattern2(
|
|
10046
|
+
element,
|
|
10047
|
+
state.current,
|
|
10020
10048
|
target,
|
|
10021
10049
|
scope,
|
|
10022
|
-
|
|
10050
|
+
propertyContext,
|
|
10051
|
+
Object.hasOwn(state, "referenceObject") ? { object: state.referenceObject, key: state.referenceKey } : void 0
|
|
10052
|
+
) : await bindPatternValue(
|
|
10053
|
+
element,
|
|
10054
|
+
async () => ({ value: property.type === "RestElement" ? await copyObjectRestValue(value, excludedKeys, propertyContext) : await propertyContext.getProperty(value, currentState.key) }),
|
|
10055
|
+
target,
|
|
10056
|
+
scope,
|
|
10057
|
+
propertyContext,
|
|
10058
|
+
(current, reference) => {
|
|
10059
|
+
currentState.current = current;
|
|
10060
|
+
currentState.phase = "binding";
|
|
10061
|
+
if (reference !== void 0) {
|
|
10062
|
+
currentState.referenceObject = reference.object;
|
|
10063
|
+
currentState.referenceKey = reference.key;
|
|
10064
|
+
}
|
|
10065
|
+
}
|
|
10023
10066
|
);
|
|
10024
|
-
if (!
|
|
10025
|
-
return binding2;
|
|
10026
|
-
}
|
|
10027
|
-
continue;
|
|
10028
|
-
}
|
|
10029
|
-
const key = await evaluatePatternKey(property, context);
|
|
10030
|
-
if (!key.ok) {
|
|
10031
|
-
return key;
|
|
10032
|
-
}
|
|
10033
|
-
excludedKeys.add(typeof key.value === "symbol" ? key.value : String(key.value));
|
|
10034
|
-
const binding = await bindPatternValue(
|
|
10035
|
-
property.value,
|
|
10036
|
-
async () => ({ value: await context.getProperty(value, key.value) }),
|
|
10037
|
-
target,
|
|
10038
|
-
scope,
|
|
10039
|
-
context
|
|
10040
|
-
);
|
|
10041
|
-
if (!binding.ok) {
|
|
10042
|
-
return binding;
|
|
10067
|
+
if (!binding.ok) return binding;
|
|
10043
10068
|
}
|
|
10069
|
+
return { ok: true };
|
|
10070
|
+
} finally {
|
|
10071
|
+
release();
|
|
10044
10072
|
}
|
|
10045
|
-
return { ok: true };
|
|
10046
10073
|
}
|
|
10047
10074
|
async function bindMemberExpression(pattern, value, context, reference) {
|
|
10048
10075
|
if (reference === void 0) {
|
|
@@ -15520,19 +15547,26 @@ async function evaluateBinaryExpression(node, context) {
|
|
|
15520
15547
|
}
|
|
15521
15548
|
async function evaluateAssignmentExpression(node, context) {
|
|
15522
15549
|
if (node.left.type === "ArrayPattern" || node.left.type === "ObjectPattern") {
|
|
15523
|
-
const
|
|
15550
|
+
const restored2 = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
15551
|
+
if (restored2 !== void 0 && restored2.kind !== "pattern-source") throw new TypeError("Invalid pattern source continuation.");
|
|
15552
|
+
const right = restored2 === void 0 ? await evaluateNode(node.right, context) : { kind: "normal", hasValue: true, value: restored2.value };
|
|
15524
15553
|
if (right.kind !== "normal") {
|
|
15525
15554
|
return right;
|
|
15526
15555
|
}
|
|
15527
|
-
|
|
15528
|
-
|
|
15529
|
-
|
|
15556
|
+
if (context.generatorYield !== void 0 && node.nodeId !== void 0) {
|
|
15557
|
+
context = { ...context, generatorExpressionStates: new Map([
|
|
15558
|
+
...context.generatorExpressionStates ?? [],
|
|
15559
|
+
[node.nodeId, { kind: "pattern-source", value: right.value }]
|
|
15560
|
+
]) };
|
|
15561
|
+
}
|
|
15562
|
+
const release2 = retainValues(context.budget, () => [right.value]);
|
|
15563
|
+
try {
|
|
15564
|
+
const binding2 = await bindPattern2(node.left, right.value, { assign: true }, context.scope, createPatternContext(context));
|
|
15565
|
+
if (!binding2.ok) return binding2.result;
|
|
15566
|
+
return { kind: "normal", hasValue: true, value: right.value };
|
|
15567
|
+
} finally {
|
|
15568
|
+
release2();
|
|
15530
15569
|
}
|
|
15531
|
-
return {
|
|
15532
|
-
kind: "normal",
|
|
15533
|
-
hasValue: true,
|
|
15534
|
-
value: right.value
|
|
15535
|
-
};
|
|
15536
15570
|
}
|
|
15537
15571
|
if (node.left.type === "MemberExpression") {
|
|
15538
15572
|
return evaluateMemberAssignmentExpression(node, context);
|
|
@@ -15842,8 +15876,10 @@ async function evaluateVariableDeclaration(node, context) {
|
|
|
15842
15876
|
continue;
|
|
15843
15877
|
}
|
|
15844
15878
|
}
|
|
15879
|
+
const restoredSource = context.generatorResume === void 0 || declarator.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(declarator.nodeId);
|
|
15880
|
+
if (restoredSource !== void 0 && restoredSource.kind !== "pattern-source") throw new TypeError("Invalid declaration source continuation.");
|
|
15845
15881
|
const restoredValue = declarator.id.type === "Identifier" ? context.scope.consumeRestoredBinding(declarator.id.name) : { found: false };
|
|
15846
|
-
const value = restoredValue.found && isRestorableBindingValue(restoredValue.value) ? {
|
|
15882
|
+
const value = restoredSource !== void 0 ? { kind: "normal", hasValue: true, value: restoredSource.value } : restoredValue.found && isRestorableBindingValue(restoredValue.value) ? {
|
|
15847
15883
|
kind: "normal",
|
|
15848
15884
|
hasValue: true,
|
|
15849
15885
|
value: restoredValue.value
|
|
@@ -15855,15 +15891,25 @@ async function evaluateVariableDeclaration(node, context) {
|
|
|
15855
15891
|
if (value.kind !== "normal") {
|
|
15856
15892
|
return value;
|
|
15857
15893
|
}
|
|
15858
|
-
const
|
|
15859
|
-
|
|
15860
|
-
|
|
15861
|
-
|
|
15862
|
-
|
|
15863
|
-
|
|
15864
|
-
|
|
15865
|
-
|
|
15866
|
-
|
|
15894
|
+
const bindingContext = context.generatorYield === void 0 || declarator.nodeId === void 0 || declarator.init === void 0 || declarator.id.type === "Identifier" ? context : {
|
|
15895
|
+
...context,
|
|
15896
|
+
generatorExpressionStates: new Map([
|
|
15897
|
+
...context.generatorExpressionStates ?? [],
|
|
15898
|
+
[declarator.nodeId, { kind: "pattern-source", value: value.value }]
|
|
15899
|
+
])
|
|
15900
|
+
};
|
|
15901
|
+
const release = retainValues(context.budget, () => [value.value]);
|
|
15902
|
+
try {
|
|
15903
|
+
const binding = await bindPattern2(
|
|
15904
|
+
declarator.id,
|
|
15905
|
+
value.value,
|
|
15906
|
+
{ kind: node.kind },
|
|
15907
|
+
context.scope,
|
|
15908
|
+
createPatternContext(bindingContext)
|
|
15909
|
+
);
|
|
15910
|
+
if (!binding.ok) return binding.result;
|
|
15911
|
+
} finally {
|
|
15912
|
+
release();
|
|
15867
15913
|
}
|
|
15868
15914
|
}
|
|
15869
15915
|
return {
|
|
@@ -20965,7 +21011,15 @@ function captureGuestHeapNode(value, encode) {
|
|
|
20965
21011
|
...value.state !== "suspended" || origin2.expressionStates === void 0 ? {} : {
|
|
20966
21012
|
expressionStates: Object.fromEntries([...origin2.expressionStates].map(([id, expression]) => [
|
|
20967
21013
|
String(id),
|
|
20968
|
-
expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "
|
|
21014
|
+
expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "pattern-source" ? { kind: "pattern-source", value: encode(expression.value) } : expression.kind === "object-pattern" ? {
|
|
21015
|
+
kind: "object-pattern",
|
|
21016
|
+
phase: expression.phase,
|
|
21017
|
+
index: expression.index,
|
|
21018
|
+
excludedKeys: expression.excludedKeys.map(encode),
|
|
21019
|
+
key: encode(expression.key),
|
|
21020
|
+
current: encode(expression.current),
|
|
21021
|
+
...Object.hasOwn(expression, "referenceObject") ? { referenceObject: encode(expression.referenceObject), referenceKey: encode(expression.referenceKey) } : {}
|
|
21022
|
+
} : expression.kind === "array-pattern" ? {
|
|
20969
21023
|
kind: "array-pattern",
|
|
20970
21024
|
phase: expression.phase,
|
|
20971
21025
|
index: expression.index,
|
|
@@ -22623,6 +22677,16 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
22623
22677
|
const expression = record2(raw2);
|
|
22624
22678
|
if (expression.kind === "binary") {
|
|
22625
22679
|
fields(expression, ["kind", "left"]);
|
|
22680
|
+
} else if (expression.kind === "pattern-source") {
|
|
22681
|
+
fields(expression, ["kind", "value"]);
|
|
22682
|
+
} else if (expression.kind === "object-pattern") {
|
|
22683
|
+
fields(expression, ["kind", "phase", "index", "excludedKeys", "key", "current"], ["referenceObject", "referenceKey"]);
|
|
22684
|
+
integer(expression.index);
|
|
22685
|
+
if (!["key", "reference", "binding"].includes(String(expression.phase)) || Object.hasOwn(expression, "referenceObject") !== Object.hasOwn(expression, "referenceKey")) throw new TypeError("Invalid object pattern state.");
|
|
22686
|
+
for (const key of array(expression.excludedKeys)) if (typeof key !== "string") reference(key, ["symbol"]);
|
|
22687
|
+
if (!absent(expression.key) && typeof expression.key !== "string") reference(expression.key, ["symbol"]);
|
|
22688
|
+
if (Object.hasOwn(expression, "referenceObject") && expression.phase !== "binding") throw new TypeError("Invalid prepared object pattern reference.");
|
|
22689
|
+
if (Object.hasOwn(expression, "referenceKey") && typeof expression.referenceKey !== "string") reference(expression.referenceKey, ["symbol"]);
|
|
22626
22690
|
} else if (expression.kind === "for-of-array" || expression.kind === "for-of-iterator" || expression.kind === "array-pattern") {
|
|
22627
22691
|
if (expression.kind === "array-pattern") {
|
|
22628
22692
|
fields(expression, ["kind", "phase", "index", "done", "current", "iterator"], ["referenceObject", "referenceKey"]);
|
|
@@ -22832,6 +22896,20 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22832
22896
|
});
|
|
22833
22897
|
continue;
|
|
22834
22898
|
}
|
|
22899
|
+
if (node.type === "ObjectPattern" && key === "properties" && typeof node.nodeId === "number" && Array.isArray(value)) {
|
|
22900
|
+
const id = node.nodeId;
|
|
22901
|
+
value.forEach((property, index) => {
|
|
22902
|
+
for (const part of property.type === "RestElement" ? ["argument"] : ["key", "value"]) {
|
|
22903
|
+
pending.push({
|
|
22904
|
+
value: property[part],
|
|
22905
|
+
blocks,
|
|
22906
|
+
finalizers: frame.finalizers,
|
|
22907
|
+
expressions: new Map([...frame.expressions, [id, { kind: "object-pattern", index, key: part === "key" }]])
|
|
22908
|
+
});
|
|
22909
|
+
}
|
|
22910
|
+
});
|
|
22911
|
+
continue;
|
|
22912
|
+
}
|
|
22835
22913
|
if (node.type === "ObjectExpression" && key === "properties" && typeof node.nodeId === "number" && Array.isArray(value)) {
|
|
22836
22914
|
const id = node.nodeId;
|
|
22837
22915
|
value.forEach((property, index) => {
|
|
@@ -22870,7 +22948,7 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22870
22948
|
pending.push({
|
|
22871
22949
|
value,
|
|
22872
22950
|
blocks,
|
|
22873
|
-
expressions: node.type === "ForOfStatement" && ["left", "body"].includes(key) && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "for-of", phase: key, async: node.await === true }]]) : node.type === "ForInStatement" && ["left", "body"].includes(key) && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "for-in", phase: key }]]) : node.type === "ForStatement" && ["init", "test", "body", "update"].includes(key) && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "for", phase: key }]]) : node.type === "BinaryExpression" && key === "right" && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "binary" }]]) : node.type === "AssignmentExpression" && key === "right" && typeof node.nodeId === "number" && node.left.type === "Identifier" ? new Map([...frame.expressions, [node.nodeId, { kind: "identifier-assignment" }]]) : node.type === "AssignmentExpression" && key === "right" && typeof node.nodeId === "number" && node.left.type === "MemberExpression" ? new Map([...frame.expressions, [node.nodeId, {
|
|
22951
|
+
expressions: (node.type === "VariableDeclarator" && key === "id" && node.init !== void 0 || node.type === "AssignmentExpression" && key === "left") && typeof node.nodeId === "number" && ["ArrayPattern", "ObjectPattern"].includes(String(value?.type)) ? new Map([...frame.expressions, [node.nodeId, { kind: "pattern-source" }]]) : node.type === "ForOfStatement" && ["left", "body"].includes(key) && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "for-of", phase: key, async: node.await === true }]]) : node.type === "ForInStatement" && ["left", "body"].includes(key) && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "for-in", phase: key }]]) : node.type === "ForStatement" && ["init", "test", "body", "update"].includes(key) && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "for", phase: key }]]) : node.type === "BinaryExpression" && key === "right" && typeof node.nodeId === "number" ? new Map([...frame.expressions, [node.nodeId, { kind: "binary" }]]) : node.type === "AssignmentExpression" && key === "right" && typeof node.nodeId === "number" && node.left.type === "Identifier" ? new Map([...frame.expressions, [node.nodeId, { kind: "identifier-assignment" }]]) : node.type === "AssignmentExpression" && key === "right" && typeof node.nodeId === "number" && node.left.type === "MemberExpression" ? new Map([...frame.expressions, [node.nodeId, {
|
|
22874
22952
|
kind: "member-assignment",
|
|
22875
22953
|
key: node.operator !== "=",
|
|
22876
22954
|
superReceiver: node.left.object.type === "Super"
|
|
@@ -22900,7 +22978,7 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22900
22978
|
for (const [id, expression] of expressions) {
|
|
22901
22979
|
const expected = yieldExpressions?.get(Number(id));
|
|
22902
22980
|
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";
|
|
22903
|
-
if (expected === void 0 || !compatibleKind || expected.kind !== "binary" && 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 === "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"))
|
|
22981
|
+
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"))
|
|
22904
22982
|
throw new TypeError("Invalid generator AST identity: unrelated expression continuation");
|
|
22905
22983
|
}
|
|
22906
22984
|
}
|
|
@@ -39146,4 +39224,4 @@ export {
|
|
|
39146
39224
|
FileSnapshotBackend,
|
|
39147
39225
|
run
|
|
39148
39226
|
};
|
|
39149
|
-
//# sourceMappingURL=chunk-
|
|
39227
|
+
//# sourceMappingURL=chunk-PV36YBZS.js.map
|