@poe-platform/safe-js 0.1.231 → 0.1.233
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-5SF3QHIJ.js → chunk-4EKZGMNU.js} +139 -78
- package/dist/safe-js/chunks/chunk-4EKZGMNU.js.map +7 -0
- package/dist/safe-js/chunks/{chunk-NOPEM57U.js → chunk-HQP4GXCO.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 +13 -0
- package/dist/safe-js/interp/patterns.d.ts +3 -0
- package/dist/safe-js/parse/parser.d.ts +1 -1
- package/package.json +2 -2
- package/dist/safe-js/chunks/chunk-5SF3QHIJ.js.map +0 -7
- /package/dist/safe-js/chunks/{chunk-NOPEM57U.js.map → chunk-HQP4GXCO.js.map} +0 -0
|
@@ -3466,7 +3466,7 @@ var Parser = class {
|
|
|
3466
3466
|
throw new Error("for await requires an of loop.");
|
|
3467
3467
|
}
|
|
3468
3468
|
if (iterationOperator?.value === "in") {
|
|
3469
|
-
const left = this.
|
|
3469
|
+
const left = this.parseForOfLeft();
|
|
3470
3470
|
this.expectKeyword("in");
|
|
3471
3471
|
const right = this.parseExpression().node;
|
|
3472
3472
|
this.expectPunctuator(")");
|
|
@@ -3520,14 +3520,6 @@ var Parser = class {
|
|
|
3520
3520
|
};
|
|
3521
3521
|
});
|
|
3522
3522
|
}
|
|
3523
|
-
parseForInLeft() {
|
|
3524
|
-
const left = this.parseForOfLeft();
|
|
3525
|
-
const target = left.type === "VariableDeclaration" ? left.declarations[0]?.id : left;
|
|
3526
|
-
if (target?.type !== "Identifier") {
|
|
3527
|
-
throw new Error("for...in keys are strings; destructure inside the body");
|
|
3528
|
-
}
|
|
3529
|
-
return left;
|
|
3530
|
-
}
|
|
3531
3523
|
parseForOfLeft() {
|
|
3532
3524
|
if ((this.currentToken().type === "keyword" || this.currentToken().type === "identifier") && (this.currentToken().value === "const" || this.currentToken().value === "let" || this.currentToken().value === "var")) {
|
|
3533
3525
|
return this.parseForOfDeclaration();
|
|
@@ -9885,7 +9877,7 @@ async function bindAssignmentPattern2(pattern, value, target, scope, context, re
|
|
|
9885
9877
|
}
|
|
9886
9878
|
return bindPattern2(pattern.left, defaultValue.value, target, scope, context, reference);
|
|
9887
9879
|
}
|
|
9888
|
-
async function bindPatternValue(pattern, readValue, target, scope, context) {
|
|
9880
|
+
async function bindPatternValue(pattern, readValue, target, scope, context, onRead) {
|
|
9889
9881
|
let member = pattern;
|
|
9890
9882
|
while (member.type === "AssignmentPattern" || member.type === "RestElement")
|
|
9891
9883
|
member = member.type === "AssignmentPattern" ? member.left : member.argument;
|
|
@@ -9899,6 +9891,7 @@ async function bindPatternValue(pattern, readValue, target, scope, context) {
|
|
|
9899
9891
|
const release = context.budget === void 0 ? () => void 0 : retainValues(context.budget, () => [reference?.object, reference?.key, value]);
|
|
9900
9892
|
try {
|
|
9901
9893
|
value = (await readValue()).value;
|
|
9894
|
+
onRead?.(value, reference);
|
|
9902
9895
|
return await bindPattern2(pattern, value, target, scope, context, reference);
|
|
9903
9896
|
} finally {
|
|
9904
9897
|
release();
|
|
@@ -9906,7 +9899,10 @@ async function bindPatternValue(pattern, readValue, target, scope, context) {
|
|
|
9906
9899
|
}
|
|
9907
9900
|
async function bindArrayPattern2(pattern, value, target, scope, context) {
|
|
9908
9901
|
const budget = context.budget ?? new Budget();
|
|
9909
|
-
const
|
|
9902
|
+
const saved = pattern.nodeId === void 0 ? void 0 : context.restoredPatternState?.(pattern.nodeId);
|
|
9903
|
+
if (saved !== void 0 && saved.kind !== "array-pattern") throw new TypeError("Invalid array pattern continuation.");
|
|
9904
|
+
const callContext = context.callContext ?? { stack: [], thisValue: void 0, getProperty: context.getProperty };
|
|
9905
|
+
const iterator = saved === void 0 ? await acquireSandboxIterator(
|
|
9910
9906
|
value,
|
|
9911
9907
|
budget,
|
|
9912
9908
|
context.callContext ?? {
|
|
@@ -9914,9 +9910,9 @@ async function bindArrayPattern2(pattern, value, target, scope, context) {
|
|
|
9914
9910
|
thisValue: void 0,
|
|
9915
9911
|
getProperty: context.getProperty
|
|
9916
9912
|
}
|
|
9917
|
-
);
|
|
9913
|
+
) : "kind" in saved.iterator ? await restoreSandboxIterator(saved.iterator, budget, callContext) : saved.iterator;
|
|
9918
9914
|
if (iterator === void 0) throw new TypeError("Array destructuring requires an iterable.");
|
|
9919
|
-
let done = false;
|
|
9915
|
+
let done = saved?.done ?? false;
|
|
9920
9916
|
const next = async (readValue = true) => {
|
|
9921
9917
|
if (done) return { value: void 0 };
|
|
9922
9918
|
try {
|
|
@@ -9931,15 +9927,42 @@ async function bindArrayPattern2(pattern, value, target, scope, context) {
|
|
|
9931
9927
|
}
|
|
9932
9928
|
};
|
|
9933
9929
|
let retained;
|
|
9934
|
-
|
|
9930
|
+
let continuation;
|
|
9931
|
+
const release = retainValues(budget, () => [
|
|
9932
|
+
value,
|
|
9933
|
+
iterator.retainedValue,
|
|
9934
|
+
retained,
|
|
9935
|
+
continuation?.current,
|
|
9936
|
+
continuation?.referenceObject,
|
|
9937
|
+
continuation?.referenceKey
|
|
9938
|
+
]);
|
|
9935
9939
|
try {
|
|
9936
|
-
for (let index = 0; index < pattern.elements.length; index += 1) {
|
|
9940
|
+
for (let index = saved?.index ?? 0; index < pattern.elements.length; index += 1) {
|
|
9937
9941
|
const element = pattern.elements[index];
|
|
9938
9942
|
if (element === null) {
|
|
9939
9943
|
await next(false);
|
|
9940
9944
|
continue;
|
|
9941
9945
|
}
|
|
9942
|
-
const
|
|
9946
|
+
const resuming = saved !== void 0 && index === saved.index;
|
|
9947
|
+
const state = {
|
|
9948
|
+
kind: "array-pattern",
|
|
9949
|
+
phase: "reference",
|
|
9950
|
+
index,
|
|
9951
|
+
done,
|
|
9952
|
+
current: void 0,
|
|
9953
|
+
iterator
|
|
9954
|
+
};
|
|
9955
|
+
if (resuming) Object.assign(state, saved, { iterator });
|
|
9956
|
+
continuation = state;
|
|
9957
|
+
const elementContext = pattern.nodeId === void 0 ? context : context.withPatternState?.(pattern.nodeId, state) ?? context;
|
|
9958
|
+
const binding = resuming && saved.phase === "binding" ? await bindPattern2(
|
|
9959
|
+
element,
|
|
9960
|
+
saved.current,
|
|
9961
|
+
target,
|
|
9962
|
+
scope,
|
|
9963
|
+
elementContext,
|
|
9964
|
+
Object.hasOwn(saved, "referenceObject") ? { object: saved.referenceObject, key: saved.referenceKey } : void 0
|
|
9965
|
+
) : await bindPatternValue(
|
|
9943
9966
|
element,
|
|
9944
9967
|
async () => {
|
|
9945
9968
|
if (element.type !== "RestElement") return next();
|
|
@@ -9953,7 +9976,16 @@ async function bindArrayPattern2(pattern, value, target, scope, context) {
|
|
|
9953
9976
|
},
|
|
9954
9977
|
target,
|
|
9955
9978
|
scope,
|
|
9956
|
-
|
|
9979
|
+
elementContext,
|
|
9980
|
+
(current, reference) => {
|
|
9981
|
+
state.phase = "binding";
|
|
9982
|
+
state.current = current;
|
|
9983
|
+
state.done = done;
|
|
9984
|
+
if (reference !== void 0) {
|
|
9985
|
+
state.referenceObject = reference.object;
|
|
9986
|
+
state.referenceKey = reference.key;
|
|
9987
|
+
}
|
|
9988
|
+
}
|
|
9957
9989
|
);
|
|
9958
9990
|
if (!binding.ok) {
|
|
9959
9991
|
if (!done) {
|
|
@@ -15488,19 +15520,26 @@ async function evaluateBinaryExpression(node, context) {
|
|
|
15488
15520
|
}
|
|
15489
15521
|
async function evaluateAssignmentExpression(node, context) {
|
|
15490
15522
|
if (node.left.type === "ArrayPattern" || node.left.type === "ObjectPattern") {
|
|
15491
|
-
const
|
|
15523
|
+
const restored2 = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
|
|
15524
|
+
if (restored2 !== void 0 && restored2.kind !== "pattern-source") throw new TypeError("Invalid pattern source continuation.");
|
|
15525
|
+
const right = restored2 === void 0 ? await evaluateNode(node.right, context) : { kind: "normal", hasValue: true, value: restored2.value };
|
|
15492
15526
|
if (right.kind !== "normal") {
|
|
15493
15527
|
return right;
|
|
15494
15528
|
}
|
|
15495
|
-
|
|
15496
|
-
|
|
15497
|
-
|
|
15529
|
+
if (context.generatorYield !== void 0 && node.nodeId !== void 0) {
|
|
15530
|
+
context = { ...context, generatorExpressionStates: new Map([
|
|
15531
|
+
...context.generatorExpressionStates ?? [],
|
|
15532
|
+
[node.nodeId, { kind: "pattern-source", value: right.value }]
|
|
15533
|
+
]) };
|
|
15534
|
+
}
|
|
15535
|
+
const release2 = retainValues(context.budget, () => [right.value]);
|
|
15536
|
+
try {
|
|
15537
|
+
const binding2 = await bindPattern2(node.left, right.value, { assign: true }, context.scope, createPatternContext(context));
|
|
15538
|
+
if (!binding2.ok) return binding2.result;
|
|
15539
|
+
return { kind: "normal", hasValue: true, value: right.value };
|
|
15540
|
+
} finally {
|
|
15541
|
+
release2();
|
|
15498
15542
|
}
|
|
15499
|
-
return {
|
|
15500
|
-
kind: "normal",
|
|
15501
|
-
hasValue: true,
|
|
15502
|
-
value: right.value
|
|
15503
|
-
};
|
|
15504
15543
|
}
|
|
15505
15544
|
if (node.left.type === "MemberExpression") {
|
|
15506
15545
|
return evaluateMemberAssignmentExpression(node, context);
|
|
@@ -15810,8 +15849,10 @@ async function evaluateVariableDeclaration(node, context) {
|
|
|
15810
15849
|
continue;
|
|
15811
15850
|
}
|
|
15812
15851
|
}
|
|
15852
|
+
const restoredSource = context.generatorResume === void 0 || declarator.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(declarator.nodeId);
|
|
15853
|
+
if (restoredSource !== void 0 && restoredSource.kind !== "pattern-source") throw new TypeError("Invalid declaration source continuation.");
|
|
15813
15854
|
const restoredValue = declarator.id.type === "Identifier" ? context.scope.consumeRestoredBinding(declarator.id.name) : { found: false };
|
|
15814
|
-
const value = restoredValue.found && isRestorableBindingValue(restoredValue.value) ? {
|
|
15855
|
+
const value = restoredSource !== void 0 ? { kind: "normal", hasValue: true, value: restoredSource.value } : restoredValue.found && isRestorableBindingValue(restoredValue.value) ? {
|
|
15815
15856
|
kind: "normal",
|
|
15816
15857
|
hasValue: true,
|
|
15817
15858
|
value: restoredValue.value
|
|
@@ -15823,15 +15864,25 @@ async function evaluateVariableDeclaration(node, context) {
|
|
|
15823
15864
|
if (value.kind !== "normal") {
|
|
15824
15865
|
return value;
|
|
15825
15866
|
}
|
|
15826
|
-
const
|
|
15827
|
-
|
|
15828
|
-
|
|
15829
|
-
|
|
15830
|
-
|
|
15831
|
-
|
|
15832
|
-
|
|
15833
|
-
|
|
15834
|
-
|
|
15867
|
+
const bindingContext = context.generatorYield === void 0 || declarator.nodeId === void 0 || declarator.init === void 0 || declarator.id.type === "Identifier" ? context : {
|
|
15868
|
+
...context,
|
|
15869
|
+
generatorExpressionStates: new Map([
|
|
15870
|
+
...context.generatorExpressionStates ?? [],
|
|
15871
|
+
[declarator.nodeId, { kind: "pattern-source", value: value.value }]
|
|
15872
|
+
])
|
|
15873
|
+
};
|
|
15874
|
+
const release = retainValues(context.budget, () => [value.value]);
|
|
15875
|
+
try {
|
|
15876
|
+
const binding = await bindPattern2(
|
|
15877
|
+
declarator.id,
|
|
15878
|
+
value.value,
|
|
15879
|
+
{ kind: node.kind },
|
|
15880
|
+
context.scope,
|
|
15881
|
+
createPatternContext(bindingContext)
|
|
15882
|
+
);
|
|
15883
|
+
if (!binding.ok) return binding.result;
|
|
15884
|
+
} finally {
|
|
15885
|
+
release();
|
|
15835
15886
|
}
|
|
15836
15887
|
}
|
|
15837
15888
|
return {
|
|
@@ -16116,7 +16167,7 @@ async function evaluateForOfStatement(node, context) {
|
|
|
16116
16167
|
}
|
|
16117
16168
|
});
|
|
16118
16169
|
if (!resuming || saved.phase === "left") {
|
|
16119
|
-
const binding = await
|
|
16170
|
+
const binding = await bindIterationVariable(node.left, current, scope, phaseContext("left"));
|
|
16120
16171
|
if (!binding.ok) return binding.result;
|
|
16121
16172
|
}
|
|
16122
16173
|
const iterationContext = createLoopIterationContext(phaseContext("body"), scope);
|
|
@@ -16211,7 +16262,7 @@ async function evaluateForOfIterator(node, value, context, restoredEntry) {
|
|
|
16211
16262
|
});
|
|
16212
16263
|
let binding;
|
|
16213
16264
|
try {
|
|
16214
|
-
binding = resuming && saved.phase === "body" ? { ok: true } : await
|
|
16265
|
+
binding = resuming && saved.phase === "body" ? { ok: true } : await bindIterationVariable(node.left, nextValue, scope, phaseContext("left"));
|
|
16215
16266
|
} catch (error) {
|
|
16216
16267
|
if (isFatalSandboxError(error) || error instanceof HostCallResumabilityError) throw error;
|
|
16217
16268
|
await closeIterator(iterator, true);
|
|
@@ -16266,22 +16317,23 @@ async function evaluateForInStatement(node, context) {
|
|
|
16266
16317
|
continue;
|
|
16267
16318
|
}
|
|
16268
16319
|
const scope = resuming ? restored.scope : context.scope.child();
|
|
16269
|
-
|
|
16270
|
-
const binding = await bindForInLoopVariable(node.left, key, scope, context);
|
|
16271
|
-
if (!binding.ok) {
|
|
16272
|
-
context.activeLoopIterations.delete(node.nodeId ?? -1);
|
|
16273
|
-
return binding.result;
|
|
16274
|
-
}
|
|
16275
|
-
}
|
|
16276
|
-
const iterationContext = createLoopIterationContext({
|
|
16320
|
+
const phaseContext = (phase) => ({
|
|
16277
16321
|
...context,
|
|
16278
16322
|
...context.generatorYield === void 0 || node.nodeId === void 0 ? {} : {
|
|
16279
16323
|
generatorExpressionStates: new Map([
|
|
16280
16324
|
...context.generatorExpressionStates ?? [],
|
|
16281
|
-
[node.nodeId, { kind: "for-in", object: right.value, keys, index, scope }]
|
|
16325
|
+
[node.nodeId, { kind: "for-in", phase, object: right.value, keys, index, scope }]
|
|
16282
16326
|
])
|
|
16283
16327
|
}
|
|
16284
|
-
}
|
|
16328
|
+
});
|
|
16329
|
+
if (!resuming || restored.phase === "left") {
|
|
16330
|
+
const binding = await bindIterationVariable(node.left, key, scope, phaseContext("left"));
|
|
16331
|
+
if (!binding.ok) {
|
|
16332
|
+
context.activeLoopIterations.delete(node.nodeId ?? -1);
|
|
16333
|
+
return binding.result;
|
|
16334
|
+
}
|
|
16335
|
+
}
|
|
16336
|
+
const iterationContext = createLoopIterationContext(phaseContext("body"), scope);
|
|
16285
16337
|
emitLoopIterationBreakpoint(node, iterationContext);
|
|
16286
16338
|
const result = await evaluateNode(node.body, iterationContext);
|
|
16287
16339
|
if (isMatchingBreak(result, loopLabels(node))) {
|
|
@@ -16349,16 +16401,6 @@ function isPlainForInObject(value) {
|
|
|
16349
16401
|
const prototype = Object.getPrototypeOf(value);
|
|
16350
16402
|
return prototype === Object.prototype || prototype === null;
|
|
16351
16403
|
}
|
|
16352
|
-
async function bindForInLoopVariable(left, key, scope, context) {
|
|
16353
|
-
if (left.type === "Identifier") {
|
|
16354
|
-
return bindPattern2(left, key, { assign: true }, scope, createPatternContext(context, scope));
|
|
16355
|
-
}
|
|
16356
|
-
const [declarator] = left.declarations;
|
|
16357
|
-
if (left.declarations.length !== 1 || declarator?.id.type !== "Identifier") {
|
|
16358
|
-
throw new TypeError("for...in keys are strings; destructure inside the body");
|
|
16359
|
-
}
|
|
16360
|
-
return bindPattern2(declarator.id, key, { kind: left.kind }, scope, createPatternContext(context, scope));
|
|
16361
|
-
}
|
|
16362
16404
|
function normalEmptyResult() {
|
|
16363
16405
|
return { kind: "normal", hasValue: false, value: void 0 };
|
|
16364
16406
|
}
|
|
@@ -16537,7 +16579,7 @@ function loopLabels(node) {
|
|
|
16537
16579
|
function hasLoopLabel(labels, target) {
|
|
16538
16580
|
return Array.isArray(labels) ? labels.includes(target) : labels === target;
|
|
16539
16581
|
}
|
|
16540
|
-
async function
|
|
16582
|
+
async function bindIterationVariable(left, value, scope, context) {
|
|
16541
16583
|
if (left.type !== "VariableDeclaration") {
|
|
16542
16584
|
return bindPattern2(left, value, { assign: true }, scope, createPatternContext(context, scope));
|
|
16543
16585
|
}
|
|
@@ -16880,6 +16922,8 @@ function getPropertyValue(target, property, context, receiver = target) {
|
|
|
16880
16922
|
function createPatternContext(context, scope = context.scope, evaluate = evaluateNode) {
|
|
16881
16923
|
const evaluationContext = { ...context, scope };
|
|
16882
16924
|
return {
|
|
16925
|
+
restoredPatternState: (id) => context.generatorResume === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(id),
|
|
16926
|
+
withPatternState: (id, state) => context.generatorYield === void 0 ? createPatternContext(context, scope, evaluate) : createPatternContext({ ...context, generatorExpressionStates: new Map([...context.generatorExpressionStates ?? [], [id, state]]) }, scope, evaluate),
|
|
16883
16927
|
prepareMemberReference: async (pattern) => {
|
|
16884
16928
|
let reference;
|
|
16885
16929
|
const result = await evaluateMemberAccess(pattern, evaluationContext, async (member) => {
|
|
@@ -20940,7 +20984,15 @@ function captureGuestHeapNode(value, encode) {
|
|
|
20940
20984
|
...value.state !== "suspended" || origin2.expressionStates === void 0 ? {} : {
|
|
20941
20985
|
expressionStates: Object.fromEntries([...origin2.expressionStates].map(([id, expression]) => [
|
|
20942
20986
|
String(id),
|
|
20943
|
-
expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "
|
|
20987
|
+
expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "pattern-source" ? { kind: "pattern-source", value: encode(expression.value) } : expression.kind === "array-pattern" ? {
|
|
20988
|
+
kind: "array-pattern",
|
|
20989
|
+
phase: expression.phase,
|
|
20990
|
+
index: expression.index,
|
|
20991
|
+
done: expression.done,
|
|
20992
|
+
current: encode(expression.current),
|
|
20993
|
+
iterator: mapIteratorSnapshot("kind" in expression.iterator ? expression.iterator : expression.iterator.snapshot?.() ?? { kind: "unsupported" }, encode),
|
|
20994
|
+
...Object.hasOwn(expression, "referenceObject") ? { referenceObject: encode(expression.referenceObject), referenceKey: encode(expression.referenceKey) } : {}
|
|
20995
|
+
} : expression.kind === "for-of-array" ? { ...expression, values: encode(expression.values), current: encode(expression.current), scope: encode(expression.scope) } : expression.kind === "for-of-iterator" ? {
|
|
20944
20996
|
...expression,
|
|
20945
20997
|
value: encode(expression.value),
|
|
20946
20998
|
current: encode(expression.current),
|
|
@@ -22590,18 +22642,26 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
22590
22642
|
const expression = record2(raw2);
|
|
22591
22643
|
if (expression.kind === "binary") {
|
|
22592
22644
|
fields(expression, ["kind", "left"]);
|
|
22593
|
-
} else if (expression.kind === "
|
|
22594
|
-
fields(expression, [
|
|
22595
|
-
|
|
22596
|
-
|
|
22597
|
-
"current",
|
|
22598
|
-
"
|
|
22599
|
-
"
|
|
22600
|
-
|
|
22601
|
-
|
|
22602
|
-
|
|
22645
|
+
} else if (expression.kind === "pattern-source") {
|
|
22646
|
+
fields(expression, ["kind", "value"]);
|
|
22647
|
+
} else if (expression.kind === "for-of-array" || expression.kind === "for-of-iterator" || expression.kind === "array-pattern") {
|
|
22648
|
+
if (expression.kind === "array-pattern") {
|
|
22649
|
+
fields(expression, ["kind", "phase", "index", "done", "current", "iterator"], ["referenceObject", "referenceKey"]);
|
|
22650
|
+
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.");
|
|
22651
|
+
if (Object.hasOwn(expression, "referenceKey") && typeof expression.referenceKey !== "string") reference(expression.referenceKey, ["symbol"]);
|
|
22652
|
+
} else {
|
|
22653
|
+
fields(expression, [
|
|
22654
|
+
"kind",
|
|
22655
|
+
"phase",
|
|
22656
|
+
"current",
|
|
22657
|
+
"index",
|
|
22658
|
+
"scope",
|
|
22659
|
+
...expression.kind === "for-of-array" ? ["values"] : ["value", "iterator", "async"]
|
|
22660
|
+
]);
|
|
22661
|
+
if (!["left", "body"].includes(String(expression.phase))) throw new TypeError("Invalid for-of phase.");
|
|
22662
|
+
reference(expression.scope, ["scope-frame"]);
|
|
22663
|
+
}
|
|
22603
22664
|
integer(expression.index);
|
|
22604
|
-
reference(expression.scope, ["scope-frame"]);
|
|
22605
22665
|
if (expression.kind === "for-of-array") reference(expression.values, ["array", "guest-array"]);
|
|
22606
22666
|
else {
|
|
22607
22667
|
let iterator = record2(expression.iterator);
|
|
@@ -22637,10 +22697,11 @@ function validateGuestHeapNode(raw, heap, maxArrayLength = 4294967295) {
|
|
|
22637
22697
|
}
|
|
22638
22698
|
}
|
|
22639
22699
|
} else throw new TypeError("Invalid iterator continuation.");
|
|
22640
|
-
if (expression.async !== protocol) throw new TypeError("Invalid
|
|
22700
|
+
if ((expression.kind === "array-pattern" ? false : expression.async) !== protocol) throw new TypeError("Invalid iterator protocol.");
|
|
22641
22701
|
}
|
|
22642
22702
|
} else if (expression.kind === "for-in") {
|
|
22643
|
-
fields(expression, ["kind", "object", "keys", "index", "scope"]);
|
|
22703
|
+
fields(expression, ["kind", "object", "keys", "index", "scope"], ["phase"]);
|
|
22704
|
+
if (Object.hasOwn(expression, "phase") && !["left", "body"].includes(String(expression.phase))) throw new TypeError("Invalid for-in phase.");
|
|
22644
22705
|
if (array(expression.keys).some((key) => typeof key !== "string") || integer(expression.index) >= array(expression.keys).length) throw new TypeError("Invalid for-in continuation.");
|
|
22645
22706
|
reference(expression.scope, ["scope-frame"]);
|
|
22646
22707
|
} else if (expression.kind === "for") {
|
|
@@ -22813,8 +22874,8 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22813
22874
|
});
|
|
22814
22875
|
continue;
|
|
22815
22876
|
}
|
|
22816
|
-
if ((node.type === "ArrayExpression" && key === "elements" || node.type === "TemplateLiteral" && key === "expressions" || (node.type === "CallExpression" || node.type === "NewExpression") && key === "arguments") && typeof node.nodeId === "number" && Array.isArray(value)) {
|
|
22817
|
-
const kind = node.type === "ArrayExpression" ? "array" : node.type === "TemplateLiteral" ? "template" : node.type === "CallExpression" ? "call" : "new";
|
|
22877
|
+
if (((node.type === "ArrayExpression" || node.type === "ArrayPattern") && key === "elements" || node.type === "TemplateLiteral" && key === "expressions" || (node.type === "CallExpression" || node.type === "NewExpression") && key === "arguments") && typeof node.nodeId === "number" && Array.isArray(value)) {
|
|
22878
|
+
const kind = node.type === "ArrayPattern" ? "array-pattern" : node.type === "ArrayExpression" ? "array" : node.type === "TemplateLiteral" ? "template" : node.type === "CallExpression" ? "call" : "new";
|
|
22818
22879
|
value.forEach((element, index) => pending.push({
|
|
22819
22880
|
value: element,
|
|
22820
22881
|
blocks,
|
|
@@ -22830,7 +22891,7 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22830
22891
|
pending.push({
|
|
22831
22892
|
value,
|
|
22832
22893
|
blocks,
|
|
22833
|
-
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" &&
|
|
22894
|
+
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, {
|
|
22834
22895
|
kind: "member-assignment",
|
|
22835
22896
|
key: node.operator !== "=",
|
|
22836
22897
|
superReceiver: node.left.object.type === "Super"
|
|
@@ -22860,7 +22921,7 @@ function validateGuestFunctionAst(record3, origin) {
|
|
|
22860
22921
|
for (const [id, expression] of expressions) {
|
|
22861
22922
|
const expected = yieldExpressions?.get(Number(id));
|
|
22862
22923
|
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";
|
|
22863
|
-
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-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"))
|
|
22924
|
+
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 === "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"))
|
|
22864
22925
|
throw new TypeError("Invalid generator AST identity: unrelated expression continuation");
|
|
22865
22926
|
}
|
|
22866
22927
|
}
|
|
@@ -39106,4 +39167,4 @@ export {
|
|
|
39106
39167
|
FileSnapshotBackend,
|
|
39107
39168
|
run
|
|
39108
39169
|
};
|
|
39109
|
-
//# sourceMappingURL=chunk-
|
|
39170
|
+
//# sourceMappingURL=chunk-4EKZGMNU.js.map
|