poe-code 14.0.58 → 14.0.60
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/index.js +253 -186
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-js/dist/chunks/{chunk-3VTLNK4E.js → chunk-C7UCTQDN.js} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-DHD453E5.js → chunk-MKJBQPBH.js} +254 -187
- package/packages/safe-js/dist/chunks/chunk-MKJBQPBH.js.map +7 -0
- package/packages/safe-js/dist/cli.js +2 -2
- package/packages/safe-js/dist/core.js +1 -1
- package/packages/safe-js/dist/index.js +2 -2
- package/packages/safe-js/dist/interp/interpreter.js +213 -147
- package/packages/safe-js/dist/parse/parser.js +45 -42
- package/packages/safe-js/dist/chunks/chunk-DHD453E5.js.map +0 -7
- /package/packages/safe-js/dist/chunks/{chunk-3VTLNK4E.js.map → chunk-C7UCTQDN.js.map} +0 -0
|
@@ -2525,23 +2525,21 @@ function parseTokens(tokens, compilation) {
|
|
|
2525
2525
|
function parseModuleTokens(tokens, compilation) {
|
|
2526
2526
|
return new Parser(tokens, compilation).parseModule();
|
|
2527
2527
|
}
|
|
2528
|
-
function parseExpressionTokens(tokens, compilation) {
|
|
2529
|
-
return new Parser(tokens, compilation).parseExpressionOnly();
|
|
2530
|
-
}
|
|
2531
2528
|
var Parser = class {
|
|
2532
|
-
constructor(tokens, compilation) {
|
|
2529
|
+
constructor(tokens, compilation, functionContext = "normal") {
|
|
2533
2530
|
this.tokens = tokens;
|
|
2534
2531
|
this.compilation = compilation;
|
|
2532
|
+
this.functionContext = functionContext;
|
|
2535
2533
|
this.functionScopes.add(this.scopes[0]);
|
|
2536
2534
|
}
|
|
2537
2535
|
tokens;
|
|
2538
2536
|
compilation;
|
|
2537
|
+
functionContext;
|
|
2539
2538
|
index = 0;
|
|
2540
2539
|
breakableDepth = 0;
|
|
2541
2540
|
conditionalExpressionDepth = 0;
|
|
2542
2541
|
ifStatementDepth = 0;
|
|
2543
2542
|
loopDepth = 0;
|
|
2544
|
-
generatorBody = false;
|
|
2545
2543
|
scopes = [/* @__PURE__ */ new Map()];
|
|
2546
2544
|
functionScopes = /* @__PURE__ */ new WeakSet();
|
|
2547
2545
|
varNames = /* @__PURE__ */ new WeakMap();
|
|
@@ -2727,9 +2725,9 @@ var Parser = class {
|
|
|
2727
2725
|
}
|
|
2728
2726
|
parseArrowFunctionBody(params) {
|
|
2729
2727
|
if (this.currentToken().type === "punctuator" && this.currentToken().value === "{") {
|
|
2730
|
-
return this.withFunctionContext(
|
|
2728
|
+
return this.withFunctionContext("normal", () => this.parseBlockStatement(params));
|
|
2731
2729
|
}
|
|
2732
|
-
return this.withFunctionContext(
|
|
2730
|
+
return this.withFunctionContext("normal", () => this.parseExpression().node);
|
|
2733
2731
|
}
|
|
2734
2732
|
parseBlockStatement(params, catchParam) {
|
|
2735
2733
|
const start = this.expectPunctuator("{");
|
|
@@ -3333,7 +3331,7 @@ var Parser = class {
|
|
|
3333
3331
|
return parsedParams;
|
|
3334
3332
|
});
|
|
3335
3333
|
const generator = generatorToken !== void 0;
|
|
3336
|
-
const body = this.withFunctionContext(generator, () => this.parseBlockStatement(params));
|
|
3334
|
+
const body = this.withFunctionContext(generator ? "generator" : "normal", () => this.parseBlockStatement(params));
|
|
3337
3335
|
return {
|
|
3338
3336
|
type: "FunctionDeclaration",
|
|
3339
3337
|
async: asyncToken !== void 0,
|
|
@@ -3368,32 +3366,34 @@ var Parser = class {
|
|
|
3368
3366
|
};
|
|
3369
3367
|
}
|
|
3370
3368
|
parseArrowParameters() {
|
|
3371
|
-
this.
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
while (true) {
|
|
3377
|
-
const param = this.parseBindingElement();
|
|
3378
|
-
params.push(param);
|
|
3379
|
-
const comma = this.consumePunctuator(",");
|
|
3380
|
-
if (comma === void 0) {
|
|
3381
|
-
break;
|
|
3369
|
+
return this.withFunctionContext("parameters", () => {
|
|
3370
|
+
this.expectPunctuator("(");
|
|
3371
|
+
const params = [];
|
|
3372
|
+
if (this.consumePunctuator(")") !== void 0) {
|
|
3373
|
+
return params;
|
|
3382
3374
|
}
|
|
3383
|
-
|
|
3375
|
+
while (true) {
|
|
3376
|
+
const param = this.parseBindingElement();
|
|
3377
|
+
params.push(param);
|
|
3378
|
+
const comma = this.consumePunctuator(",");
|
|
3379
|
+
if (comma === void 0) {
|
|
3380
|
+
break;
|
|
3381
|
+
}
|
|
3382
|
+
if (param.type === "RestElement") {
|
|
3383
|
+
if (this.currentToken().type === "punctuator" && this.currentToken().value === ")") {
|
|
3384
|
+
throw unexpectedTokenError(comma);
|
|
3385
|
+
}
|
|
3386
|
+
throw new Error(
|
|
3387
|
+
`Rest element must be the last parameter at line ${comma.start.line}, column ${comma.start.column}.`
|
|
3388
|
+
);
|
|
3389
|
+
}
|
|
3384
3390
|
if (this.currentToken().type === "punctuator" && this.currentToken().value === ")") {
|
|
3385
|
-
|
|
3391
|
+
break;
|
|
3386
3392
|
}
|
|
3387
|
-
throw new Error(
|
|
3388
|
-
`Rest element must be the last parameter at line ${comma.start.line}, column ${comma.start.column}.`
|
|
3389
|
-
);
|
|
3390
|
-
}
|
|
3391
|
-
if (this.currentToken().type === "punctuator" && this.currentToken().value === ")") {
|
|
3392
|
-
break;
|
|
3393
3393
|
}
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3394
|
+
this.expectPunctuator(")");
|
|
3395
|
+
return params;
|
|
3396
|
+
});
|
|
3397
3397
|
}
|
|
3398
3398
|
parseBindingElement() {
|
|
3399
3399
|
if (this.consumePunctuator("...") !== void 0) {
|
|
@@ -3947,7 +3947,7 @@ var Parser = class {
|
|
|
3947
3947
|
};
|
|
3948
3948
|
}
|
|
3949
3949
|
if (token.type === "keyword" && token.value === "yield") {
|
|
3950
|
-
if (
|
|
3950
|
+
if (this.functionContext !== "generator") {
|
|
3951
3951
|
throw new Error(
|
|
3952
3952
|
`yield is only valid inside a generator body at line ${token.start.line}, column ${token.start.column}.`
|
|
3953
3953
|
);
|
|
@@ -3974,11 +3974,16 @@ var Parser = class {
|
|
|
3974
3974
|
};
|
|
3975
3975
|
}
|
|
3976
3976
|
if (token.type === "keyword" && token.value === "await") {
|
|
3977
|
-
if (this.
|
|
3977
|
+
if (this.functionContext === "generator") {
|
|
3978
3978
|
throw new Error(
|
|
3979
3979
|
`generators cannot await; use a regular async function at line ${token.start.line}, column ${token.start.column}.`
|
|
3980
3980
|
);
|
|
3981
3981
|
}
|
|
3982
|
+
if (this.functionContext === "parameters") {
|
|
3983
|
+
throw new Error(
|
|
3984
|
+
`await is not valid in function parameters at line ${token.start.line}, column ${token.start.column}.`
|
|
3985
|
+
);
|
|
3986
|
+
}
|
|
3982
3987
|
this.index += 1;
|
|
3983
3988
|
const argument = this.parseUnaryExpression();
|
|
3984
3989
|
return {
|
|
@@ -4103,7 +4108,7 @@ var Parser = class {
|
|
|
4103
4108
|
if (this.currentToken().type === "template") {
|
|
4104
4109
|
const quasi = createTemplateLiteral(
|
|
4105
4110
|
this.currentToken(),
|
|
4106
|
-
{ allowMalformedEscapes: true },
|
|
4111
|
+
{ allowMalformedEscapes: true, functionContext: this.functionContext },
|
|
4107
4112
|
this.compilation
|
|
4108
4113
|
);
|
|
4109
4114
|
this.index += 1;
|
|
@@ -4190,7 +4195,11 @@ var Parser = class {
|
|
|
4190
4195
|
if (token.type === "template") {
|
|
4191
4196
|
this.index += 1;
|
|
4192
4197
|
return {
|
|
4193
|
-
node: createTemplateLiteral(
|
|
4198
|
+
node: createTemplateLiteral(
|
|
4199
|
+
token,
|
|
4200
|
+
{ allowMalformedEscapes: false, functionContext: this.functionContext },
|
|
4201
|
+
this.compilation
|
|
4202
|
+
),
|
|
4194
4203
|
parenthesized: false
|
|
4195
4204
|
};
|
|
4196
4205
|
}
|
|
@@ -4306,7 +4315,7 @@ var Parser = class {
|
|
|
4306
4315
|
return parsedParams;
|
|
4307
4316
|
});
|
|
4308
4317
|
const generator = generatorToken !== void 0;
|
|
4309
|
-
const body = this.withFunctionContext(generator, () => this.parseBlockStatement(params));
|
|
4318
|
+
const body = this.withFunctionContext(generator ? "generator" : "normal", () => this.parseBlockStatement(params));
|
|
4310
4319
|
return {
|
|
4311
4320
|
type: "FunctionExpression",
|
|
4312
4321
|
async: asyncToken !== void 0,
|
|
@@ -4550,7 +4559,7 @@ var Parser = class {
|
|
|
4550
4559
|
}
|
|
4551
4560
|
return parsedParams;
|
|
4552
4561
|
});
|
|
4553
|
-
const body = this.withFunctionContext(
|
|
4562
|
+
const body = this.withFunctionContext("normal", () => this.parseBlockStatement(params));
|
|
4554
4563
|
return {
|
|
4555
4564
|
type: "FunctionExpression",
|
|
4556
4565
|
async: asyncToken !== void 0,
|
|
@@ -4955,19 +4964,19 @@ var Parser = class {
|
|
|
4955
4964
|
hasReturnArgument(returnToken, nextToken) {
|
|
4956
4965
|
return !(hasLineBreakBetween(returnToken, nextToken) || nextToken.type === "punctuator" && (nextToken.value === ";" || nextToken.value === "}") || nextToken.type === "eof");
|
|
4957
4966
|
}
|
|
4958
|
-
withFunctionContext(
|
|
4967
|
+
withFunctionContext(functionContext, callback) {
|
|
4959
4968
|
const previousBreakableDepth = this.breakableDepth;
|
|
4960
4969
|
const previousLoopDepth = this.loopDepth;
|
|
4961
|
-
const
|
|
4970
|
+
const previousFunctionContext = this.functionContext;
|
|
4962
4971
|
this.breakableDepth = 0;
|
|
4963
4972
|
this.loopDepth = 0;
|
|
4964
|
-
this.
|
|
4973
|
+
this.functionContext = functionContext;
|
|
4965
4974
|
try {
|
|
4966
4975
|
return callback();
|
|
4967
4976
|
} finally {
|
|
4968
4977
|
this.breakableDepth = previousBreakableDepth;
|
|
4969
4978
|
this.loopDepth = previousLoopDepth;
|
|
4970
|
-
this.
|
|
4979
|
+
this.functionContext = previousFunctionContext;
|
|
4971
4980
|
}
|
|
4972
4981
|
}
|
|
4973
4982
|
withLoopContext(callback) {
|
|
@@ -5402,7 +5411,7 @@ function createLiteralFromToken(token) {
|
|
|
5402
5411
|
}
|
|
5403
5412
|
return createKeywordLiteral(token);
|
|
5404
5413
|
}
|
|
5405
|
-
function createTemplateLiteral(token, options
|
|
5414
|
+
function createTemplateLiteral(token, options, compilation) {
|
|
5406
5415
|
const raw = token.value;
|
|
5407
5416
|
const expressions = [];
|
|
5408
5417
|
const quasis = [];
|
|
@@ -5422,6 +5431,7 @@ function createTemplateLiteral(token, options = { allowMalformedEscapes: false }
|
|
|
5422
5431
|
parseEmbeddedExpression(
|
|
5423
5432
|
raw.slice(expressionStart, expressionEnd),
|
|
5424
5433
|
positionWithinRaw(token.start, raw, expressionStart),
|
|
5434
|
+
options.functionContext,
|
|
5425
5435
|
compilation
|
|
5426
5436
|
)
|
|
5427
5437
|
);
|
|
@@ -5784,13 +5794,13 @@ function decodeHexEscape(value, start) {
|
|
|
5784
5794
|
end: index + 2
|
|
5785
5795
|
};
|
|
5786
5796
|
}
|
|
5787
|
-
function parseEmbeddedExpression(source, base, compilation) {
|
|
5797
|
+
function parseEmbeddedExpression(source, base, functionContext, compilation) {
|
|
5788
5798
|
const tokens = tokenize(source, { allowRegexLiterals: true, compilation }).map((token) => ({
|
|
5789
5799
|
...token,
|
|
5790
5800
|
start: rebasePosition(token.start, base),
|
|
5791
5801
|
end: rebasePosition(token.end, base)
|
|
5792
5802
|
}));
|
|
5793
|
-
return
|
|
5803
|
+
return new Parser(tokens, compilation, functionContext).parseExpressionOnly();
|
|
5794
5804
|
}
|
|
5795
5805
|
function findRegexLiteral(node) {
|
|
5796
5806
|
if (node === null || node === void 0) {
|
|
@@ -26595,89 +26605,110 @@ async function evaluateEmptyStatement(_node, _context) {
|
|
|
26595
26605
|
}
|
|
26596
26606
|
async function evaluateArrayExpression(node, context) {
|
|
26597
26607
|
const values = [];
|
|
26598
|
-
|
|
26599
|
-
|
|
26600
|
-
|
|
26601
|
-
|
|
26602
|
-
|
|
26603
|
-
|
|
26604
|
-
|
|
26605
|
-
const spreadValues = await evaluateSpreadElement(element, context);
|
|
26606
|
-
if (!spreadValues.ok) {
|
|
26607
|
-
return spreadValues.result;
|
|
26608
|
+
const release = retainValues(context.budget, () => [values]);
|
|
26609
|
+
try {
|
|
26610
|
+
for (const element of node.elements) {
|
|
26611
|
+
if (element.type === "UndefinedLiteral" && element.elision === true) {
|
|
26612
|
+
values.length += 1;
|
|
26613
|
+
context.budget.allocateArrayLength(values.length);
|
|
26614
|
+
continue;
|
|
26608
26615
|
}
|
|
26609
|
-
|
|
26616
|
+
if (element.type === "SpreadElement") {
|
|
26617
|
+
const spreadValues = await evaluateSpreadElement(element, context);
|
|
26618
|
+
if (!spreadValues.ok) {
|
|
26619
|
+
return spreadValues.result;
|
|
26620
|
+
}
|
|
26621
|
+
appendArrayValues2(values, spreadValues.value);
|
|
26622
|
+
context.budget.allocateArrayLength(values.length);
|
|
26623
|
+
continue;
|
|
26624
|
+
}
|
|
26625
|
+
const result = await evaluateNode(element, context);
|
|
26626
|
+
if (result.kind !== "normal") {
|
|
26627
|
+
return result;
|
|
26628
|
+
}
|
|
26629
|
+
values.push(result.value);
|
|
26610
26630
|
context.budget.allocateArrayLength(values.length);
|
|
26611
|
-
continue;
|
|
26612
26631
|
}
|
|
26613
|
-
|
|
26614
|
-
|
|
26615
|
-
|
|
26616
|
-
|
|
26617
|
-
|
|
26618
|
-
|
|
26632
|
+
return {
|
|
26633
|
+
kind: "normal",
|
|
26634
|
+
hasValue: true,
|
|
26635
|
+
value: values
|
|
26636
|
+
};
|
|
26637
|
+
} finally {
|
|
26638
|
+
release();
|
|
26619
26639
|
}
|
|
26620
|
-
return {
|
|
26621
|
-
kind: "normal",
|
|
26622
|
-
hasValue: true,
|
|
26623
|
-
value: values
|
|
26624
|
-
};
|
|
26625
26640
|
}
|
|
26626
26641
|
async function evaluateObjectExpression(node, context) {
|
|
26627
26642
|
const object = /* @__PURE__ */ Object.create(null);
|
|
26628
|
-
|
|
26629
|
-
|
|
26630
|
-
|
|
26631
|
-
if (
|
|
26632
|
-
|
|
26643
|
+
const release = retainValues(context.budget, () => [object]);
|
|
26644
|
+
try {
|
|
26645
|
+
for (const property of node.properties) {
|
|
26646
|
+
if (property.type === "SpreadElement") {
|
|
26647
|
+
const spreadEntries = await evaluateObjectSpread(property, context);
|
|
26648
|
+
if (!spreadEntries.ok) {
|
|
26649
|
+
return spreadEntries.result;
|
|
26650
|
+
}
|
|
26651
|
+
for (const [key2, value2] of spreadEntries.value) {
|
|
26652
|
+
defineSandboxProperty(object, key2, value2);
|
|
26653
|
+
}
|
|
26654
|
+
continue;
|
|
26633
26655
|
}
|
|
26634
|
-
|
|
26635
|
-
|
|
26656
|
+
const key = await evaluateObjectPropertyKey(property, context);
|
|
26657
|
+
if (!key.ok) {
|
|
26658
|
+
return key.result;
|
|
26636
26659
|
}
|
|
26637
|
-
|
|
26638
|
-
|
|
26639
|
-
|
|
26640
|
-
|
|
26641
|
-
|
|
26642
|
-
|
|
26643
|
-
const value = await evaluateNode(property.value, context);
|
|
26644
|
-
if (value.kind !== "normal") {
|
|
26645
|
-
return value;
|
|
26646
|
-
}
|
|
26647
|
-
if (isObjectPrototypeSetterProperty(property, key.value)) {
|
|
26648
|
-
if (value.value === null || typeof value.value === "object") {
|
|
26649
|
-
setSandboxPrototype(object, value.value, context.budget);
|
|
26660
|
+
const releaseKey = retainValues(context.budget, () => [key.value]);
|
|
26661
|
+
let value;
|
|
26662
|
+
try {
|
|
26663
|
+
value = await evaluateNode(property.value, context);
|
|
26664
|
+
} finally {
|
|
26665
|
+
releaseKey();
|
|
26650
26666
|
}
|
|
26651
|
-
|
|
26667
|
+
if (value.kind !== "normal") {
|
|
26668
|
+
return value;
|
|
26669
|
+
}
|
|
26670
|
+
if (isObjectPrototypeSetterProperty(property, key.value)) {
|
|
26671
|
+
if (value.value === null || typeof value.value === "object") {
|
|
26672
|
+
setSandboxPrototype(object, value.value, context.budget);
|
|
26673
|
+
}
|
|
26674
|
+
continue;
|
|
26675
|
+
}
|
|
26676
|
+
defineSandboxProperty(object, String(key.value), value.value);
|
|
26652
26677
|
}
|
|
26653
|
-
|
|
26678
|
+
return {
|
|
26679
|
+
kind: "normal",
|
|
26680
|
+
hasValue: true,
|
|
26681
|
+
value: object
|
|
26682
|
+
};
|
|
26683
|
+
} finally {
|
|
26684
|
+
release();
|
|
26654
26685
|
}
|
|
26655
|
-
return {
|
|
26656
|
-
kind: "normal",
|
|
26657
|
-
hasValue: true,
|
|
26658
|
-
value: object
|
|
26659
|
-
};
|
|
26660
26686
|
}
|
|
26661
26687
|
function isObjectPrototypeSetterProperty(property, key) {
|
|
26662
26688
|
return !property.computed && !property.shorthand && key === "__proto__";
|
|
26663
26689
|
}
|
|
26664
26690
|
async function evaluateTemplateLiteral(node, context) {
|
|
26665
26691
|
let value = context.budget.allocateString(node.quasis[0]?.value.cooked ?? "");
|
|
26666
|
-
|
|
26667
|
-
|
|
26668
|
-
|
|
26669
|
-
|
|
26692
|
+
const release = retainValues(context.budget, () => [value]);
|
|
26693
|
+
try {
|
|
26694
|
+
for (let index = 0; index < node.expressions.length; index += 1) {
|
|
26695
|
+
const expression = await evaluateNode(node.expressions[index], context);
|
|
26696
|
+
if (expression.kind !== "normal") {
|
|
26697
|
+
return expression;
|
|
26698
|
+
}
|
|
26699
|
+
const expressionText = context.budget.allocateString(String(expression.value));
|
|
26700
|
+
value = context.budget.allocateString(value + expressionText);
|
|
26701
|
+
const quasiText = context.budget.allocateString(node.quasis[index + 1]?.value.cooked ?? "");
|
|
26702
|
+
value = context.budget.allocateString(value + quasiText);
|
|
26670
26703
|
}
|
|
26671
|
-
|
|
26672
|
-
|
|
26673
|
-
|
|
26674
|
-
|
|
26704
|
+
return {
|
|
26705
|
+
kind: "normal",
|
|
26706
|
+
hasValue: true,
|
|
26707
|
+
value
|
|
26708
|
+
};
|
|
26709
|
+
} finally {
|
|
26710
|
+
release();
|
|
26675
26711
|
}
|
|
26676
|
-
return {
|
|
26677
|
-
kind: "normal",
|
|
26678
|
-
hasValue: true,
|
|
26679
|
-
value
|
|
26680
|
-
};
|
|
26681
26712
|
}
|
|
26682
26713
|
async function evaluateTaggedTemplateExpression(node, context) {
|
|
26683
26714
|
const tag = await evaluateNode(node.tag, context);
|
|
@@ -26704,20 +26735,25 @@ async function evaluateTaggedTemplateExpression(node, context) {
|
|
|
26704
26735
|
}
|
|
26705
26736
|
async function evaluateTemplateExpressionValues(node, context) {
|
|
26706
26737
|
const values = [];
|
|
26707
|
-
|
|
26708
|
-
|
|
26709
|
-
|
|
26710
|
-
|
|
26711
|
-
|
|
26712
|
-
|
|
26713
|
-
|
|
26738
|
+
const release = retainValues(context.budget, () => values);
|
|
26739
|
+
try {
|
|
26740
|
+
for (const expressionNode of node.expressions) {
|
|
26741
|
+
const expression = await evaluateNode(expressionNode, context);
|
|
26742
|
+
if (expression.kind !== "normal") {
|
|
26743
|
+
return {
|
|
26744
|
+
ok: false,
|
|
26745
|
+
result: expression
|
|
26746
|
+
};
|
|
26747
|
+
}
|
|
26748
|
+
values.push(expression.value);
|
|
26714
26749
|
}
|
|
26715
|
-
|
|
26750
|
+
return {
|
|
26751
|
+
ok: true,
|
|
26752
|
+
value: values
|
|
26753
|
+
};
|
|
26754
|
+
} finally {
|
|
26755
|
+
release();
|
|
26716
26756
|
}
|
|
26717
|
-
return {
|
|
26718
|
-
ok: true,
|
|
26719
|
-
value: values
|
|
26720
|
-
};
|
|
26721
26757
|
}
|
|
26722
26758
|
function createTaggedTemplateStrings(node, context) {
|
|
26723
26759
|
context.budget.allocateArrayLength(node.quasis.length);
|
|
@@ -26765,23 +26801,30 @@ async function evaluateBinaryExpression(node, context) {
|
|
|
26765
26801
|
if (left.kind !== "normal") {
|
|
26766
26802
|
return left;
|
|
26767
26803
|
}
|
|
26768
|
-
|
|
26769
|
-
|
|
26770
|
-
|
|
26771
|
-
|
|
26772
|
-
|
|
26773
|
-
|
|
26774
|
-
|
|
26775
|
-
|
|
26804
|
+
let rightValue;
|
|
26805
|
+
const release = retainValues(context.budget, () => [left.value, rightValue]);
|
|
26806
|
+
try {
|
|
26807
|
+
const right = await evaluateNode(node.right, context);
|
|
26808
|
+
if (right.kind !== "normal") {
|
|
26809
|
+
return right;
|
|
26810
|
+
}
|
|
26811
|
+
rightValue = right.value;
|
|
26812
|
+
let leftValue = left.value;
|
|
26813
|
+
if (node.operator === "in") {
|
|
26814
|
+
if (typeof right.value !== "object" || right.value === null) {
|
|
26815
|
+
throw new TypeError("Right-hand side of 'in' must be an object.");
|
|
26816
|
+
}
|
|
26817
|
+
leftValue = await toPropertyKey(leftValue, context.budget, createCoercionContext(context));
|
|
26776
26818
|
}
|
|
26777
|
-
|
|
26819
|
+
const value = applyBinaryOperator(node, leftValue, right.value, context);
|
|
26820
|
+
return {
|
|
26821
|
+
kind: "normal",
|
|
26822
|
+
hasValue: true,
|
|
26823
|
+
value
|
|
26824
|
+
};
|
|
26825
|
+
} finally {
|
|
26826
|
+
release();
|
|
26778
26827
|
}
|
|
26779
|
-
const value = applyBinaryOperator(node, leftValue, right.value, context);
|
|
26780
|
-
return {
|
|
26781
|
-
kind: "normal",
|
|
26782
|
-
hasValue: true,
|
|
26783
|
-
value
|
|
26784
|
-
};
|
|
26785
26828
|
}
|
|
26786
26829
|
async function evaluateAssignmentExpression(node, context) {
|
|
26787
26830
|
if (node.left.type === "ArrayPattern" || node.left.type === "ObjectPattern") {
|
|
@@ -26888,21 +26931,29 @@ async function evaluateMemberAssignmentExpression(node, context) {
|
|
|
26888
26931
|
value: current
|
|
26889
26932
|
};
|
|
26890
26933
|
}
|
|
26891
|
-
|
|
26892
|
-
|
|
26893
|
-
|
|
26894
|
-
|
|
26895
|
-
|
|
26896
|
-
|
|
26897
|
-
|
|
26934
|
+
let operands = [current, property];
|
|
26935
|
+
const release = retainValues(context.budget, () => operands);
|
|
26936
|
+
try {
|
|
26937
|
+
const right = await evaluateNode(node.right, context);
|
|
26938
|
+
if (right.kind !== "normal") {
|
|
26939
|
+
return right;
|
|
26940
|
+
}
|
|
26941
|
+
operands.push(right.value);
|
|
26942
|
+
const value = node.operator === "=" || node.operator === "&&=" || node.operator === "||=" || node.operator === "??=" ? right.value : await applyCompoundAssignmentOperator(node.operator, current, right.value, context);
|
|
26943
|
+
if (member.object === null || member.object === void 0) {
|
|
26944
|
+
throw new TypeError("Cannot assign properties of null or undefined.");
|
|
26945
|
+
}
|
|
26946
|
+
operands = [value];
|
|
26947
|
+
property ??= await toPropertyKey(member.property, context.budget, createCoercionContext(context));
|
|
26948
|
+
setSandboxProperty(member.object, property, value, context.budget);
|
|
26949
|
+
return {
|
|
26950
|
+
kind: "normal",
|
|
26951
|
+
hasValue: true,
|
|
26952
|
+
value
|
|
26953
|
+
};
|
|
26954
|
+
} finally {
|
|
26955
|
+
release();
|
|
26898
26956
|
}
|
|
26899
|
-
property ??= await toPropertyKey(member.property, context.budget, createCoercionContext(context));
|
|
26900
|
-
setSandboxProperty(member.object, property, value, context.budget);
|
|
26901
|
-
return {
|
|
26902
|
-
kind: "normal",
|
|
26903
|
-
hasValue: true,
|
|
26904
|
-
value
|
|
26905
|
-
};
|
|
26906
26957
|
});
|
|
26907
26958
|
}
|
|
26908
26959
|
async function evaluateLogicalExpression(node, context) {
|
|
@@ -28081,12 +28132,8 @@ async function evaluateMemberAccess(node, context, consume) {
|
|
|
28081
28132
|
if ((object.value === null || object.value === void 0) && node.optional) {
|
|
28082
28133
|
return consume({ kind: "nullish" });
|
|
28083
28134
|
}
|
|
28084
|
-
const retained = {};
|
|
28085
28135
|
let property;
|
|
28086
|
-
context.budget
|
|
28087
|
-
const release = () => context.budget.setRetainedValues(retained, void 0);
|
|
28088
|
-
const pending = runResources.getStore()?.referenceReleases;
|
|
28089
|
-
pending?.add(release);
|
|
28136
|
+
const release = retainValues(context.budget, () => [object.value, property]);
|
|
28090
28137
|
try {
|
|
28091
28138
|
const result = node.computed ? await evaluateNode(node.property, context) : { kind: "normal", value: getStaticPropertyName2(node.property) };
|
|
28092
28139
|
if (result.kind !== "normal") return result;
|
|
@@ -28094,9 +28141,19 @@ async function evaluateMemberAccess(node, context, consume) {
|
|
|
28094
28141
|
return await consume({ kind: "resolved", object: object.value, property });
|
|
28095
28142
|
} finally {
|
|
28096
28143
|
release();
|
|
28097
|
-
pending?.delete(release);
|
|
28098
28144
|
}
|
|
28099
28145
|
}
|
|
28146
|
+
function retainValues(budget, values) {
|
|
28147
|
+
const retained = {};
|
|
28148
|
+
budget.setRetainedValues(retained, values);
|
|
28149
|
+
const pending = runResources.getStore()?.referenceReleases;
|
|
28150
|
+
const release = () => {
|
|
28151
|
+
budget.setRetainedValues(retained, void 0);
|
|
28152
|
+
pending?.delete(release);
|
|
28153
|
+
};
|
|
28154
|
+
pending?.add(release);
|
|
28155
|
+
return release;
|
|
28156
|
+
}
|
|
28100
28157
|
async function evaluateMemberProperty(node, context) {
|
|
28101
28158
|
const property = await evaluateNode(node, context);
|
|
28102
28159
|
if (property.kind !== "normal") {
|
|
@@ -28892,30 +28949,35 @@ async function invokeSandboxClosure(callee, args, context, stack, span, thisValu
|
|
|
28892
28949
|
}
|
|
28893
28950
|
async function evaluateCallArguments(args, context) {
|
|
28894
28951
|
const values = [];
|
|
28895
|
-
|
|
28896
|
-
|
|
28897
|
-
|
|
28898
|
-
if (
|
|
28899
|
-
|
|
28952
|
+
const release = retainValues(context.budget, () => values);
|
|
28953
|
+
try {
|
|
28954
|
+
for (const arg of args) {
|
|
28955
|
+
if (arg.type === "SpreadElement") {
|
|
28956
|
+
const spreadValues = await evaluateSpreadElement(arg, context);
|
|
28957
|
+
if (!spreadValues.ok) {
|
|
28958
|
+
return spreadValues;
|
|
28959
|
+
}
|
|
28960
|
+
appendArrayValues2(values, spreadValues.value);
|
|
28961
|
+
context.budget.allocateArrayLength(values.length);
|
|
28962
|
+
continue;
|
|
28900
28963
|
}
|
|
28901
|
-
|
|
28964
|
+
const result = await evaluateNode(arg, context);
|
|
28965
|
+
if (result.kind !== "normal") {
|
|
28966
|
+
return {
|
|
28967
|
+
ok: false,
|
|
28968
|
+
result
|
|
28969
|
+
};
|
|
28970
|
+
}
|
|
28971
|
+
values.push(result.value);
|
|
28902
28972
|
context.budget.allocateArrayLength(values.length);
|
|
28903
|
-
continue;
|
|
28904
|
-
}
|
|
28905
|
-
const result = await evaluateNode(arg, context);
|
|
28906
|
-
if (result.kind !== "normal") {
|
|
28907
|
-
return {
|
|
28908
|
-
ok: false,
|
|
28909
|
-
result
|
|
28910
|
-
};
|
|
28911
28973
|
}
|
|
28912
|
-
|
|
28913
|
-
|
|
28974
|
+
return {
|
|
28975
|
+
ok: true,
|
|
28976
|
+
value: values
|
|
28977
|
+
};
|
|
28978
|
+
} finally {
|
|
28979
|
+
release();
|
|
28914
28980
|
}
|
|
28915
|
-
return {
|
|
28916
|
-
ok: true,
|
|
28917
|
-
value: values
|
|
28918
|
-
};
|
|
28919
28981
|
}
|
|
28920
28982
|
async function evaluateSpreadElement(node, context) {
|
|
28921
28983
|
const value = await evaluateNode(node.argument, context);
|
|
@@ -28930,21 +28992,26 @@ async function evaluateSpreadElement(node, context) {
|
|
|
28930
28992
|
throw new TypeError("Spread arguments must evaluate to an iterable.");
|
|
28931
28993
|
}
|
|
28932
28994
|
const spreadValues = [];
|
|
28933
|
-
|
|
28934
|
-
|
|
28935
|
-
|
|
28936
|
-
|
|
28937
|
-
|
|
28938
|
-
|
|
28939
|
-
|
|
28995
|
+
const release = retainValues(context.budget, () => [value.value, ...spreadValues]);
|
|
28996
|
+
try {
|
|
28997
|
+
while (true) {
|
|
28998
|
+
const next = await iterator.next();
|
|
28999
|
+
if (typeof next !== "object" || next === null) {
|
|
29000
|
+
throw new TypeError("Iterator result must be an object.");
|
|
29001
|
+
}
|
|
29002
|
+
if (next.done === true) {
|
|
29003
|
+
break;
|
|
29004
|
+
}
|
|
29005
|
+
spreadValues.push(next.value);
|
|
29006
|
+
context.budget.allocateArrayLength(spreadValues.length);
|
|
28940
29007
|
}
|
|
28941
|
-
|
|
28942
|
-
|
|
29008
|
+
return {
|
|
29009
|
+
ok: true,
|
|
29010
|
+
value: spreadValues
|
|
29011
|
+
};
|
|
29012
|
+
} finally {
|
|
29013
|
+
release();
|
|
28943
29014
|
}
|
|
28944
|
-
return {
|
|
28945
|
-
ok: true,
|
|
28946
|
-
value: spreadValues
|
|
28947
|
-
};
|
|
28948
29015
|
}
|
|
28949
29016
|
async function evaluateObjectSpread(node, context) {
|
|
28950
29017
|
const value = await evaluateNode(node.argument, context);
|
|
@@ -33406,4 +33473,4 @@ export {
|
|
|
33406
33473
|
FileSnapshotBackend,
|
|
33407
33474
|
run
|
|
33408
33475
|
};
|
|
33409
|
-
//# sourceMappingURL=chunk-
|
|
33476
|
+
//# sourceMappingURL=chunk-MKJBQPBH.js.map
|