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 CHANGED
@@ -122161,9 +122161,6 @@ function parseTokens(tokens, compilation) {
122161
122161
  function parseModuleTokens(tokens, compilation) {
122162
122162
  return new Parser(tokens, compilation).parseModule();
122163
122163
  }
122164
- function parseExpressionTokens(tokens, compilation) {
122165
- return new Parser(tokens, compilation).parseExpressionOnly();
122166
- }
122167
122164
  function createIdentifier2(token) {
122168
122165
  return {
122169
122166
  type: "Identifier",
@@ -122451,7 +122448,7 @@ function createLiteralFromToken(token) {
122451
122448
  }
122452
122449
  return createKeywordLiteral(token);
122453
122450
  }
122454
- function createTemplateLiteral(token, options = { allowMalformedEscapes: false }, compilation) {
122451
+ function createTemplateLiteral(token, options, compilation) {
122455
122452
  const raw = token.value;
122456
122453
  const expressions = [];
122457
122454
  const quasis = [];
@@ -122471,6 +122468,7 @@ function createTemplateLiteral(token, options = { allowMalformedEscapes: false }
122471
122468
  parseEmbeddedExpression(
122472
122469
  raw.slice(expressionStart, expressionEnd),
122473
122470
  positionWithinRaw(token.start, raw, expressionStart),
122471
+ options.functionContext,
122474
122472
  compilation
122475
122473
  )
122476
122474
  );
@@ -122833,13 +122831,13 @@ function decodeHexEscape(value, start) {
122833
122831
  end: index + 2
122834
122832
  };
122835
122833
  }
122836
- function parseEmbeddedExpression(source, base, compilation) {
122834
+ function parseEmbeddedExpression(source, base, functionContext, compilation) {
122837
122835
  const tokens = tokenize3(source, { allowRegexLiterals: true, compilation }).map((token) => ({
122838
122836
  ...token,
122839
122837
  start: rebasePosition(token.start, base),
122840
122838
  end: rebasePosition(token.end, base)
122841
122839
  }));
122842
- return parseExpressionTokens(tokens, compilation);
122840
+ return new Parser(tokens, compilation, functionContext).parseExpressionOnly();
122843
122841
  }
122844
122842
  function findRegexLiteral(node) {
122845
122843
  if (node === null || node === void 0) {
@@ -123024,19 +123022,20 @@ var init_parser3 = __esm({
123024
123022
  "while"
123025
123023
  ]);
123026
123024
  Parser = class {
123027
- constructor(tokens, compilation) {
123025
+ constructor(tokens, compilation, functionContext = "normal") {
123028
123026
  this.tokens = tokens;
123029
123027
  this.compilation = compilation;
123028
+ this.functionContext = functionContext;
123030
123029
  this.functionScopes.add(this.scopes[0]);
123031
123030
  }
123032
123031
  tokens;
123033
123032
  compilation;
123033
+ functionContext;
123034
123034
  index = 0;
123035
123035
  breakableDepth = 0;
123036
123036
  conditionalExpressionDepth = 0;
123037
123037
  ifStatementDepth = 0;
123038
123038
  loopDepth = 0;
123039
- generatorBody = false;
123040
123039
  scopes = [/* @__PURE__ */ new Map()];
123041
123040
  functionScopes = /* @__PURE__ */ new WeakSet();
123042
123041
  varNames = /* @__PURE__ */ new WeakMap();
@@ -123222,9 +123221,9 @@ var init_parser3 = __esm({
123222
123221
  }
123223
123222
  parseArrowFunctionBody(params) {
123224
123223
  if (this.currentToken().type === "punctuator" && this.currentToken().value === "{") {
123225
- return this.withFunctionContext(false, () => this.parseBlockStatement(params));
123224
+ return this.withFunctionContext("normal", () => this.parseBlockStatement(params));
123226
123225
  }
123227
- return this.withFunctionContext(false, () => this.parseExpression().node);
123226
+ return this.withFunctionContext("normal", () => this.parseExpression().node);
123228
123227
  }
123229
123228
  parseBlockStatement(params, catchParam) {
123230
123229
  const start = this.expectPunctuator("{");
@@ -123828,7 +123827,7 @@ var init_parser3 = __esm({
123828
123827
  return parsedParams;
123829
123828
  });
123830
123829
  const generator = generatorToken !== void 0;
123831
- const body = this.withFunctionContext(generator, () => this.parseBlockStatement(params));
123830
+ const body = this.withFunctionContext(generator ? "generator" : "normal", () => this.parseBlockStatement(params));
123832
123831
  return {
123833
123832
  type: "FunctionDeclaration",
123834
123833
  async: asyncToken !== void 0,
@@ -123863,32 +123862,34 @@ var init_parser3 = __esm({
123863
123862
  };
123864
123863
  }
123865
123864
  parseArrowParameters() {
123866
- this.expectPunctuator("(");
123867
- const params = [];
123868
- if (this.consumePunctuator(")") !== void 0) {
123869
- return params;
123870
- }
123871
- while (true) {
123872
- const param = this.parseBindingElement();
123873
- params.push(param);
123874
- const comma = this.consumePunctuator(",");
123875
- if (comma === void 0) {
123876
- break;
123865
+ return this.withFunctionContext("parameters", () => {
123866
+ this.expectPunctuator("(");
123867
+ const params = [];
123868
+ if (this.consumePunctuator(")") !== void 0) {
123869
+ return params;
123877
123870
  }
123878
- if (param.type === "RestElement") {
123871
+ while (true) {
123872
+ const param = this.parseBindingElement();
123873
+ params.push(param);
123874
+ const comma = this.consumePunctuator(",");
123875
+ if (comma === void 0) {
123876
+ break;
123877
+ }
123878
+ if (param.type === "RestElement") {
123879
+ if (this.currentToken().type === "punctuator" && this.currentToken().value === ")") {
123880
+ throw unexpectedTokenError(comma);
123881
+ }
123882
+ throw new Error(
123883
+ `Rest element must be the last parameter at line ${comma.start.line}, column ${comma.start.column}.`
123884
+ );
123885
+ }
123879
123886
  if (this.currentToken().type === "punctuator" && this.currentToken().value === ")") {
123880
- throw unexpectedTokenError(comma);
123887
+ break;
123881
123888
  }
123882
- throw new Error(
123883
- `Rest element must be the last parameter at line ${comma.start.line}, column ${comma.start.column}.`
123884
- );
123885
- }
123886
- if (this.currentToken().type === "punctuator" && this.currentToken().value === ")") {
123887
- break;
123888
123889
  }
123889
- }
123890
- this.expectPunctuator(")");
123891
- return params;
123890
+ this.expectPunctuator(")");
123891
+ return params;
123892
+ });
123892
123893
  }
123893
123894
  parseBindingElement() {
123894
123895
  if (this.consumePunctuator("...") !== void 0) {
@@ -124442,7 +124443,7 @@ var init_parser3 = __esm({
124442
124443
  };
124443
124444
  }
124444
124445
  if (token.type === "keyword" && token.value === "yield") {
124445
- if (!this.generatorBody) {
124446
+ if (this.functionContext !== "generator") {
124446
124447
  throw new Error(
124447
124448
  `yield is only valid inside a generator body at line ${token.start.line}, column ${token.start.column}.`
124448
124449
  );
@@ -124469,11 +124470,16 @@ var init_parser3 = __esm({
124469
124470
  };
124470
124471
  }
124471
124472
  if (token.type === "keyword" && token.value === "await") {
124472
- if (this.generatorBody) {
124473
+ if (this.functionContext === "generator") {
124473
124474
  throw new Error(
124474
124475
  `generators cannot await; use a regular async function at line ${token.start.line}, column ${token.start.column}.`
124475
124476
  );
124476
124477
  }
124478
+ if (this.functionContext === "parameters") {
124479
+ throw new Error(
124480
+ `await is not valid in function parameters at line ${token.start.line}, column ${token.start.column}.`
124481
+ );
124482
+ }
124477
124483
  this.index += 1;
124478
124484
  const argument = this.parseUnaryExpression();
124479
124485
  return {
@@ -124598,7 +124604,7 @@ var init_parser3 = __esm({
124598
124604
  if (this.currentToken().type === "template") {
124599
124605
  const quasi = createTemplateLiteral(
124600
124606
  this.currentToken(),
124601
- { allowMalformedEscapes: true },
124607
+ { allowMalformedEscapes: true, functionContext: this.functionContext },
124602
124608
  this.compilation
124603
124609
  );
124604
124610
  this.index += 1;
@@ -124685,7 +124691,11 @@ var init_parser3 = __esm({
124685
124691
  if (token.type === "template") {
124686
124692
  this.index += 1;
124687
124693
  return {
124688
- node: createTemplateLiteral(token, { allowMalformedEscapes: false }, this.compilation),
124694
+ node: createTemplateLiteral(
124695
+ token,
124696
+ { allowMalformedEscapes: false, functionContext: this.functionContext },
124697
+ this.compilation
124698
+ ),
124689
124699
  parenthesized: false
124690
124700
  };
124691
124701
  }
@@ -124801,7 +124811,7 @@ var init_parser3 = __esm({
124801
124811
  return parsedParams;
124802
124812
  });
124803
124813
  const generator = generatorToken !== void 0;
124804
- const body = this.withFunctionContext(generator, () => this.parseBlockStatement(params));
124814
+ const body = this.withFunctionContext(generator ? "generator" : "normal", () => this.parseBlockStatement(params));
124805
124815
  return {
124806
124816
  type: "FunctionExpression",
124807
124817
  async: asyncToken !== void 0,
@@ -125045,7 +125055,7 @@ var init_parser3 = __esm({
125045
125055
  }
125046
125056
  return parsedParams;
125047
125057
  });
125048
- const body = this.withFunctionContext(false, () => this.parseBlockStatement(params));
125058
+ const body = this.withFunctionContext("normal", () => this.parseBlockStatement(params));
125049
125059
  return {
125050
125060
  type: "FunctionExpression",
125051
125061
  async: asyncToken !== void 0,
@@ -125450,19 +125460,19 @@ var init_parser3 = __esm({
125450
125460
  hasReturnArgument(returnToken, nextToken) {
125451
125461
  return !(hasLineBreakBetween(returnToken, nextToken) || nextToken.type === "punctuator" && (nextToken.value === ";" || nextToken.value === "}") || nextToken.type === "eof");
125452
125462
  }
125453
- withFunctionContext(generatorBody, callback) {
125463
+ withFunctionContext(functionContext, callback) {
125454
125464
  const previousBreakableDepth = this.breakableDepth;
125455
125465
  const previousLoopDepth = this.loopDepth;
125456
- const previousGeneratorBody = this.generatorBody;
125466
+ const previousFunctionContext = this.functionContext;
125457
125467
  this.breakableDepth = 0;
125458
125468
  this.loopDepth = 0;
125459
- this.generatorBody = generatorBody;
125469
+ this.functionContext = functionContext;
125460
125470
  try {
125461
125471
  return callback();
125462
125472
  } finally {
125463
125473
  this.breakableDepth = previousBreakableDepth;
125464
125474
  this.loopDepth = previousLoopDepth;
125465
- this.generatorBody = previousGeneratorBody;
125475
+ this.functionContext = previousFunctionContext;
125466
125476
  }
125467
125477
  }
125468
125478
  withLoopContext(callback) {
@@ -146899,89 +146909,110 @@ async function evaluateEmptyStatement(_node, _context) {
146899
146909
  }
146900
146910
  async function evaluateArrayExpression(node, context) {
146901
146911
  const values = [];
146902
- for (const element of node.elements) {
146903
- if (element.type === "UndefinedLiteral" && element.elision === true) {
146904
- values.length += 1;
146905
- context.budget.allocateArrayLength(values.length);
146906
- continue;
146907
- }
146908
- if (element.type === "SpreadElement") {
146909
- const spreadValues = await evaluateSpreadElement(element, context);
146910
- if (!spreadValues.ok) {
146911
- return spreadValues.result;
146912
+ const release2 = retainValues(context.budget, () => [values]);
146913
+ try {
146914
+ for (const element of node.elements) {
146915
+ if (element.type === "UndefinedLiteral" && element.elision === true) {
146916
+ values.length += 1;
146917
+ context.budget.allocateArrayLength(values.length);
146918
+ continue;
146919
+ }
146920
+ if (element.type === "SpreadElement") {
146921
+ const spreadValues = await evaluateSpreadElement(element, context);
146922
+ if (!spreadValues.ok) {
146923
+ return spreadValues.result;
146924
+ }
146925
+ appendArrayValues2(values, spreadValues.value);
146926
+ context.budget.allocateArrayLength(values.length);
146927
+ continue;
146928
+ }
146929
+ const result = await evaluateNode2(element, context);
146930
+ if (result.kind !== "normal") {
146931
+ return result;
146912
146932
  }
146913
- appendArrayValues2(values, spreadValues.value);
146933
+ values.push(result.value);
146914
146934
  context.budget.allocateArrayLength(values.length);
146915
- continue;
146916
- }
146917
- const result = await evaluateNode2(element, context);
146918
- if (result.kind !== "normal") {
146919
- return result;
146920
146935
  }
146921
- values.push(result.value);
146922
- context.budget.allocateArrayLength(values.length);
146936
+ return {
146937
+ kind: "normal",
146938
+ hasValue: true,
146939
+ value: values
146940
+ };
146941
+ } finally {
146942
+ release2();
146923
146943
  }
146924
- return {
146925
- kind: "normal",
146926
- hasValue: true,
146927
- value: values
146928
- };
146929
146944
  }
146930
146945
  async function evaluateObjectExpression(node, context) {
146931
146946
  const object = /* @__PURE__ */ Object.create(null);
146932
- for (const property of node.properties) {
146933
- if (property.type === "SpreadElement") {
146934
- const spreadEntries = await evaluateObjectSpread(property, context);
146935
- if (!spreadEntries.ok) {
146936
- return spreadEntries.result;
146947
+ const release2 = retainValues(context.budget, () => [object]);
146948
+ try {
146949
+ for (const property of node.properties) {
146950
+ if (property.type === "SpreadElement") {
146951
+ const spreadEntries = await evaluateObjectSpread(property, context);
146952
+ if (!spreadEntries.ok) {
146953
+ return spreadEntries.result;
146954
+ }
146955
+ for (const [key4, value2] of spreadEntries.value) {
146956
+ defineSandboxProperty(object, key4, value2);
146957
+ }
146958
+ continue;
146937
146959
  }
146938
- for (const [key4, value2] of spreadEntries.value) {
146939
- defineSandboxProperty(object, key4, value2);
146960
+ const key3 = await evaluateObjectPropertyKey(property, context);
146961
+ if (!key3.ok) {
146962
+ return key3.result;
146940
146963
  }
146941
- continue;
146942
- }
146943
- const key3 = await evaluateObjectPropertyKey(property, context);
146944
- if (!key3.ok) {
146945
- return key3.result;
146946
- }
146947
- const value = await evaluateNode2(property.value, context);
146948
- if (value.kind !== "normal") {
146949
- return value;
146950
- }
146951
- if (isObjectPrototypeSetterProperty(property, key3.value)) {
146952
- if (value.value === null || typeof value.value === "object") {
146953
- setSandboxPrototype(object, value.value, context.budget);
146964
+ const releaseKey = retainValues(context.budget, () => [key3.value]);
146965
+ let value;
146966
+ try {
146967
+ value = await evaluateNode2(property.value, context);
146968
+ } finally {
146969
+ releaseKey();
146954
146970
  }
146955
- continue;
146971
+ if (value.kind !== "normal") {
146972
+ return value;
146973
+ }
146974
+ if (isObjectPrototypeSetterProperty(property, key3.value)) {
146975
+ if (value.value === null || typeof value.value === "object") {
146976
+ setSandboxPrototype(object, value.value, context.budget);
146977
+ }
146978
+ continue;
146979
+ }
146980
+ defineSandboxProperty(object, String(key3.value), value.value);
146956
146981
  }
146957
- defineSandboxProperty(object, String(key3.value), value.value);
146982
+ return {
146983
+ kind: "normal",
146984
+ hasValue: true,
146985
+ value: object
146986
+ };
146987
+ } finally {
146988
+ release2();
146958
146989
  }
146959
- return {
146960
- kind: "normal",
146961
- hasValue: true,
146962
- value: object
146963
- };
146964
146990
  }
146965
146991
  function isObjectPrototypeSetterProperty(property, key3) {
146966
146992
  return !property.computed && !property.shorthand && key3 === "__proto__";
146967
146993
  }
146968
146994
  async function evaluateTemplateLiteral(node, context) {
146969
146995
  let value = context.budget.allocateString(node.quasis[0]?.value.cooked ?? "");
146970
- for (let index = 0; index < node.expressions.length; index += 1) {
146971
- const expression = await evaluateNode2(node.expressions[index], context);
146972
- if (expression.kind !== "normal") {
146973
- return expression;
146996
+ const release2 = retainValues(context.budget, () => [value]);
146997
+ try {
146998
+ for (let index = 0; index < node.expressions.length; index += 1) {
146999
+ const expression = await evaluateNode2(node.expressions[index], context);
147000
+ if (expression.kind !== "normal") {
147001
+ return expression;
147002
+ }
147003
+ const expressionText = context.budget.allocateString(String(expression.value));
147004
+ value = context.budget.allocateString(value + expressionText);
147005
+ const quasiText = context.budget.allocateString(node.quasis[index + 1]?.value.cooked ?? "");
147006
+ value = context.budget.allocateString(value + quasiText);
146974
147007
  }
146975
- const expressionText = context.budget.allocateString(String(expression.value));
146976
- value = context.budget.allocateString(value + expressionText);
146977
- const quasiText = context.budget.allocateString(node.quasis[index + 1]?.value.cooked ?? "");
146978
- value = context.budget.allocateString(value + quasiText);
147008
+ return {
147009
+ kind: "normal",
147010
+ hasValue: true,
147011
+ value
147012
+ };
147013
+ } finally {
147014
+ release2();
146979
147015
  }
146980
- return {
146981
- kind: "normal",
146982
- hasValue: true,
146983
- value
146984
- };
146985
147016
  }
146986
147017
  async function evaluateTaggedTemplateExpression(node, context) {
146987
147018
  const tag = await evaluateNode2(node.tag, context);
@@ -147008,20 +147039,25 @@ async function evaluateTaggedTemplateExpression(node, context) {
147008
147039
  }
147009
147040
  async function evaluateTemplateExpressionValues(node, context) {
147010
147041
  const values = [];
147011
- for (const expressionNode of node.expressions) {
147012
- const expression = await evaluateNode2(expressionNode, context);
147013
- if (expression.kind !== "normal") {
147014
- return {
147015
- ok: false,
147016
- result: expression
147017
- };
147042
+ const release2 = retainValues(context.budget, () => values);
147043
+ try {
147044
+ for (const expressionNode of node.expressions) {
147045
+ const expression = await evaluateNode2(expressionNode, context);
147046
+ if (expression.kind !== "normal") {
147047
+ return {
147048
+ ok: false,
147049
+ result: expression
147050
+ };
147051
+ }
147052
+ values.push(expression.value);
147018
147053
  }
147019
- values.push(expression.value);
147054
+ return {
147055
+ ok: true,
147056
+ value: values
147057
+ };
147058
+ } finally {
147059
+ release2();
147020
147060
  }
147021
- return {
147022
- ok: true,
147023
- value: values
147024
- };
147025
147061
  }
147026
147062
  function createTaggedTemplateStrings(node, context) {
147027
147063
  context.budget.allocateArrayLength(node.quasis.length);
@@ -147069,23 +147105,30 @@ async function evaluateBinaryExpression(node, context) {
147069
147105
  if (left.kind !== "normal") {
147070
147106
  return left;
147071
147107
  }
147072
- const right = await evaluateNode2(node.right, context);
147073
- if (right.kind !== "normal") {
147074
- return right;
147075
- }
147076
- let leftValue = left.value;
147077
- if (node.operator === "in") {
147078
- if (typeof right.value !== "object" || right.value === null) {
147079
- throw new TypeError("Right-hand side of 'in' must be an object.");
147108
+ let rightValue;
147109
+ const release2 = retainValues(context.budget, () => [left.value, rightValue]);
147110
+ try {
147111
+ const right = await evaluateNode2(node.right, context);
147112
+ if (right.kind !== "normal") {
147113
+ return right;
147080
147114
  }
147081
- leftValue = await toPropertyKey(leftValue, context.budget, createCoercionContext(context));
147115
+ rightValue = right.value;
147116
+ let leftValue = left.value;
147117
+ if (node.operator === "in") {
147118
+ if (typeof right.value !== "object" || right.value === null) {
147119
+ throw new TypeError("Right-hand side of 'in' must be an object.");
147120
+ }
147121
+ leftValue = await toPropertyKey(leftValue, context.budget, createCoercionContext(context));
147122
+ }
147123
+ const value = applyBinaryOperator(node, leftValue, right.value, context);
147124
+ return {
147125
+ kind: "normal",
147126
+ hasValue: true,
147127
+ value
147128
+ };
147129
+ } finally {
147130
+ release2();
147082
147131
  }
147083
- const value = applyBinaryOperator(node, leftValue, right.value, context);
147084
- return {
147085
- kind: "normal",
147086
- hasValue: true,
147087
- value
147088
- };
147089
147132
  }
147090
147133
  async function evaluateAssignmentExpression(node, context) {
147091
147134
  if (node.left.type === "ArrayPattern" || node.left.type === "ObjectPattern") {
@@ -147192,21 +147235,29 @@ async function evaluateMemberAssignmentExpression(node, context) {
147192
147235
  value: current
147193
147236
  };
147194
147237
  }
147195
- const right = await evaluateNode2(node.right, context);
147196
- if (right.kind !== "normal") {
147197
- return right;
147198
- }
147199
- const value = node.operator === "=" || node.operator === "&&=" || node.operator === "||=" || node.operator === "??=" ? right.value : await applyCompoundAssignmentOperator(node.operator, current, right.value, context);
147200
- if (member.object === null || member.object === void 0) {
147201
- throw new TypeError("Cannot assign properties of null or undefined.");
147238
+ let operands = [current, property];
147239
+ const release2 = retainValues(context.budget, () => operands);
147240
+ try {
147241
+ const right = await evaluateNode2(node.right, context);
147242
+ if (right.kind !== "normal") {
147243
+ return right;
147244
+ }
147245
+ operands.push(right.value);
147246
+ const value = node.operator === "=" || node.operator === "&&=" || node.operator === "||=" || node.operator === "??=" ? right.value : await applyCompoundAssignmentOperator(node.operator, current, right.value, context);
147247
+ if (member.object === null || member.object === void 0) {
147248
+ throw new TypeError("Cannot assign properties of null or undefined.");
147249
+ }
147250
+ operands = [value];
147251
+ property ??= await toPropertyKey(member.property, context.budget, createCoercionContext(context));
147252
+ setSandboxProperty(member.object, property, value, context.budget);
147253
+ return {
147254
+ kind: "normal",
147255
+ hasValue: true,
147256
+ value
147257
+ };
147258
+ } finally {
147259
+ release2();
147202
147260
  }
147203
- property ??= await toPropertyKey(member.property, context.budget, createCoercionContext(context));
147204
- setSandboxProperty(member.object, property, value, context.budget);
147205
- return {
147206
- kind: "normal",
147207
- hasValue: true,
147208
- value
147209
- };
147210
147261
  });
147211
147262
  }
147212
147263
  async function evaluateLogicalExpression(node, context) {
@@ -148385,12 +148436,8 @@ async function evaluateMemberAccess(node, context, consume) {
148385
148436
  if ((object.value === null || object.value === void 0) && node.optional) {
148386
148437
  return consume({ kind: "nullish" });
148387
148438
  }
148388
- const retained = {};
148389
148439
  let property;
148390
- context.budget.setRetainedValues(retained, () => [object.value, property]);
148391
- const release2 = () => context.budget.setRetainedValues(retained, void 0);
148392
- const pending = runResources.getStore()?.referenceReleases;
148393
- pending?.add(release2);
148440
+ const release2 = retainValues(context.budget, () => [object.value, property]);
148394
148441
  try {
148395
148442
  const result = node.computed ? await evaluateNode2(node.property, context) : { kind: "normal", value: getStaticPropertyName2(node.property) };
148396
148443
  if (result.kind !== "normal") return result;
@@ -148398,9 +148445,19 @@ async function evaluateMemberAccess(node, context, consume) {
148398
148445
  return await consume({ kind: "resolved", object: object.value, property });
148399
148446
  } finally {
148400
148447
  release2();
148401
- pending?.delete(release2);
148402
148448
  }
148403
148449
  }
148450
+ function retainValues(budget, values) {
148451
+ const retained = {};
148452
+ budget.setRetainedValues(retained, values);
148453
+ const pending = runResources.getStore()?.referenceReleases;
148454
+ const release2 = () => {
148455
+ budget.setRetainedValues(retained, void 0);
148456
+ pending?.delete(release2);
148457
+ };
148458
+ pending?.add(release2);
148459
+ return release2;
148460
+ }
148404
148461
  async function evaluateMemberProperty(node, context) {
148405
148462
  const property = await evaluateNode2(node, context);
148406
148463
  if (property.kind !== "normal") {
@@ -149196,30 +149253,35 @@ async function invokeSandboxClosure(callee, args, context, stack, span, thisValu
149196
149253
  }
149197
149254
  async function evaluateCallArguments(args, context) {
149198
149255
  const values = [];
149199
- for (const arg of args) {
149200
- if (arg.type === "SpreadElement") {
149201
- const spreadValues = await evaluateSpreadElement(arg, context);
149202
- if (!spreadValues.ok) {
149203
- return spreadValues;
149256
+ const release2 = retainValues(context.budget, () => values);
149257
+ try {
149258
+ for (const arg of args) {
149259
+ if (arg.type === "SpreadElement") {
149260
+ const spreadValues = await evaluateSpreadElement(arg, context);
149261
+ if (!spreadValues.ok) {
149262
+ return spreadValues;
149263
+ }
149264
+ appendArrayValues2(values, spreadValues.value);
149265
+ context.budget.allocateArrayLength(values.length);
149266
+ continue;
149267
+ }
149268
+ const result = await evaluateNode2(arg, context);
149269
+ if (result.kind !== "normal") {
149270
+ return {
149271
+ ok: false,
149272
+ result
149273
+ };
149204
149274
  }
149205
- appendArrayValues2(values, spreadValues.value);
149275
+ values.push(result.value);
149206
149276
  context.budget.allocateArrayLength(values.length);
149207
- continue;
149208
- }
149209
- const result = await evaluateNode2(arg, context);
149210
- if (result.kind !== "normal") {
149211
- return {
149212
- ok: false,
149213
- result
149214
- };
149215
149277
  }
149216
- values.push(result.value);
149217
- context.budget.allocateArrayLength(values.length);
149278
+ return {
149279
+ ok: true,
149280
+ value: values
149281
+ };
149282
+ } finally {
149283
+ release2();
149218
149284
  }
149219
- return {
149220
- ok: true,
149221
- value: values
149222
- };
149223
149285
  }
149224
149286
  async function evaluateSpreadElement(node, context) {
149225
149287
  const value = await evaluateNode2(node.argument, context);
@@ -149234,21 +149296,26 @@ async function evaluateSpreadElement(node, context) {
149234
149296
  throw new TypeError("Spread arguments must evaluate to an iterable.");
149235
149297
  }
149236
149298
  const spreadValues = [];
149237
- while (true) {
149238
- const next = await iterator.next();
149239
- if (typeof next !== "object" || next === null) {
149240
- throw new TypeError("Iterator result must be an object.");
149241
- }
149242
- if (next.done === true) {
149243
- break;
149299
+ const release2 = retainValues(context.budget, () => [value.value, ...spreadValues]);
149300
+ try {
149301
+ while (true) {
149302
+ const next = await iterator.next();
149303
+ if (typeof next !== "object" || next === null) {
149304
+ throw new TypeError("Iterator result must be an object.");
149305
+ }
149306
+ if (next.done === true) {
149307
+ break;
149308
+ }
149309
+ spreadValues.push(next.value);
149310
+ context.budget.allocateArrayLength(spreadValues.length);
149244
149311
  }
149245
- spreadValues.push(next.value);
149246
- context.budget.allocateArrayLength(spreadValues.length);
149312
+ return {
149313
+ ok: true,
149314
+ value: spreadValues
149315
+ };
149316
+ } finally {
149317
+ release2();
149247
149318
  }
149248
- return {
149249
- ok: true,
149250
- value: spreadValues
149251
- };
149252
149319
  }
149253
149320
  async function evaluateObjectSpread(node, context) {
149254
149321
  const value = await evaluateNode2(node.argument, context);