poe-code 14.0.58 → 14.0.59

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
@@ -146899,89 +146899,110 @@ async function evaluateEmptyStatement(_node, _context) {
146899
146899
  }
146900
146900
  async function evaluateArrayExpression(node, context) {
146901
146901
  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;
146902
+ const release2 = retainValues(context.budget, () => [values]);
146903
+ try {
146904
+ for (const element of node.elements) {
146905
+ if (element.type === "UndefinedLiteral" && element.elision === true) {
146906
+ values.length += 1;
146907
+ context.budget.allocateArrayLength(values.length);
146908
+ continue;
146909
+ }
146910
+ if (element.type === "SpreadElement") {
146911
+ const spreadValues = await evaluateSpreadElement(element, context);
146912
+ if (!spreadValues.ok) {
146913
+ return spreadValues.result;
146914
+ }
146915
+ appendArrayValues2(values, spreadValues.value);
146916
+ context.budget.allocateArrayLength(values.length);
146917
+ continue;
146918
+ }
146919
+ const result = await evaluateNode2(element, context);
146920
+ if (result.kind !== "normal") {
146921
+ return result;
146912
146922
  }
146913
- appendArrayValues2(values, spreadValues.value);
146923
+ values.push(result.value);
146914
146924
  context.budget.allocateArrayLength(values.length);
146915
- continue;
146916
- }
146917
- const result = await evaluateNode2(element, context);
146918
- if (result.kind !== "normal") {
146919
- return result;
146920
146925
  }
146921
- values.push(result.value);
146922
- context.budget.allocateArrayLength(values.length);
146926
+ return {
146927
+ kind: "normal",
146928
+ hasValue: true,
146929
+ value: values
146930
+ };
146931
+ } finally {
146932
+ release2();
146923
146933
  }
146924
- return {
146925
- kind: "normal",
146926
- hasValue: true,
146927
- value: values
146928
- };
146929
146934
  }
146930
146935
  async function evaluateObjectExpression(node, context) {
146931
146936
  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;
146937
+ const release2 = retainValues(context.budget, () => [object]);
146938
+ try {
146939
+ for (const property of node.properties) {
146940
+ if (property.type === "SpreadElement") {
146941
+ const spreadEntries = await evaluateObjectSpread(property, context);
146942
+ if (!spreadEntries.ok) {
146943
+ return spreadEntries.result;
146944
+ }
146945
+ for (const [key4, value2] of spreadEntries.value) {
146946
+ defineSandboxProperty(object, key4, value2);
146947
+ }
146948
+ continue;
146937
146949
  }
146938
- for (const [key4, value2] of spreadEntries.value) {
146939
- defineSandboxProperty(object, key4, value2);
146950
+ const key3 = await evaluateObjectPropertyKey(property, context);
146951
+ if (!key3.ok) {
146952
+ return key3.result;
146940
146953
  }
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);
146954
+ const releaseKey = retainValues(context.budget, () => [key3.value]);
146955
+ let value;
146956
+ try {
146957
+ value = await evaluateNode2(property.value, context);
146958
+ } finally {
146959
+ releaseKey();
146954
146960
  }
146955
- continue;
146961
+ if (value.kind !== "normal") {
146962
+ return value;
146963
+ }
146964
+ if (isObjectPrototypeSetterProperty(property, key3.value)) {
146965
+ if (value.value === null || typeof value.value === "object") {
146966
+ setSandboxPrototype(object, value.value, context.budget);
146967
+ }
146968
+ continue;
146969
+ }
146970
+ defineSandboxProperty(object, String(key3.value), value.value);
146956
146971
  }
146957
- defineSandboxProperty(object, String(key3.value), value.value);
146972
+ return {
146973
+ kind: "normal",
146974
+ hasValue: true,
146975
+ value: object
146976
+ };
146977
+ } finally {
146978
+ release2();
146958
146979
  }
146959
- return {
146960
- kind: "normal",
146961
- hasValue: true,
146962
- value: object
146963
- };
146964
146980
  }
146965
146981
  function isObjectPrototypeSetterProperty(property, key3) {
146966
146982
  return !property.computed && !property.shorthand && key3 === "__proto__";
146967
146983
  }
146968
146984
  async function evaluateTemplateLiteral(node, context) {
146969
146985
  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;
146986
+ const release2 = retainValues(context.budget, () => [value]);
146987
+ try {
146988
+ for (let index = 0; index < node.expressions.length; index += 1) {
146989
+ const expression = await evaluateNode2(node.expressions[index], context);
146990
+ if (expression.kind !== "normal") {
146991
+ return expression;
146992
+ }
146993
+ const expressionText = context.budget.allocateString(String(expression.value));
146994
+ value = context.budget.allocateString(value + expressionText);
146995
+ const quasiText = context.budget.allocateString(node.quasis[index + 1]?.value.cooked ?? "");
146996
+ value = context.budget.allocateString(value + quasiText);
146974
146997
  }
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);
146998
+ return {
146999
+ kind: "normal",
147000
+ hasValue: true,
147001
+ value
147002
+ };
147003
+ } finally {
147004
+ release2();
146979
147005
  }
146980
- return {
146981
- kind: "normal",
146982
- hasValue: true,
146983
- value
146984
- };
146985
147006
  }
146986
147007
  async function evaluateTaggedTemplateExpression(node, context) {
146987
147008
  const tag = await evaluateNode2(node.tag, context);
@@ -147008,20 +147029,25 @@ async function evaluateTaggedTemplateExpression(node, context) {
147008
147029
  }
147009
147030
  async function evaluateTemplateExpressionValues(node, context) {
147010
147031
  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
- };
147032
+ const release2 = retainValues(context.budget, () => values);
147033
+ try {
147034
+ for (const expressionNode of node.expressions) {
147035
+ const expression = await evaluateNode2(expressionNode, context);
147036
+ if (expression.kind !== "normal") {
147037
+ return {
147038
+ ok: false,
147039
+ result: expression
147040
+ };
147041
+ }
147042
+ values.push(expression.value);
147018
147043
  }
147019
- values.push(expression.value);
147044
+ return {
147045
+ ok: true,
147046
+ value: values
147047
+ };
147048
+ } finally {
147049
+ release2();
147020
147050
  }
147021
- return {
147022
- ok: true,
147023
- value: values
147024
- };
147025
147051
  }
147026
147052
  function createTaggedTemplateStrings(node, context) {
147027
147053
  context.budget.allocateArrayLength(node.quasis.length);
@@ -147069,23 +147095,30 @@ async function evaluateBinaryExpression(node, context) {
147069
147095
  if (left.kind !== "normal") {
147070
147096
  return left;
147071
147097
  }
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.");
147098
+ let rightValue;
147099
+ const release2 = retainValues(context.budget, () => [left.value, rightValue]);
147100
+ try {
147101
+ const right = await evaluateNode2(node.right, context);
147102
+ if (right.kind !== "normal") {
147103
+ return right;
147104
+ }
147105
+ rightValue = right.value;
147106
+ let leftValue = left.value;
147107
+ if (node.operator === "in") {
147108
+ if (typeof right.value !== "object" || right.value === null) {
147109
+ throw new TypeError("Right-hand side of 'in' must be an object.");
147110
+ }
147111
+ leftValue = await toPropertyKey(leftValue, context.budget, createCoercionContext(context));
147080
147112
  }
147081
- leftValue = await toPropertyKey(leftValue, context.budget, createCoercionContext(context));
147113
+ const value = applyBinaryOperator(node, leftValue, right.value, context);
147114
+ return {
147115
+ kind: "normal",
147116
+ hasValue: true,
147117
+ value
147118
+ };
147119
+ } finally {
147120
+ release2();
147082
147121
  }
147083
- const value = applyBinaryOperator(node, leftValue, right.value, context);
147084
- return {
147085
- kind: "normal",
147086
- hasValue: true,
147087
- value
147088
- };
147089
147122
  }
147090
147123
  async function evaluateAssignmentExpression(node, context) {
147091
147124
  if (node.left.type === "ArrayPattern" || node.left.type === "ObjectPattern") {
@@ -147192,21 +147225,29 @@ async function evaluateMemberAssignmentExpression(node, context) {
147192
147225
  value: current
147193
147226
  };
147194
147227
  }
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.");
147228
+ let operands = [current, property];
147229
+ const release2 = retainValues(context.budget, () => operands);
147230
+ try {
147231
+ const right = await evaluateNode2(node.right, context);
147232
+ if (right.kind !== "normal") {
147233
+ return right;
147234
+ }
147235
+ operands.push(right.value);
147236
+ const value = node.operator === "=" || node.operator === "&&=" || node.operator === "||=" || node.operator === "??=" ? right.value : await applyCompoundAssignmentOperator(node.operator, current, right.value, context);
147237
+ if (member.object === null || member.object === void 0) {
147238
+ throw new TypeError("Cannot assign properties of null or undefined.");
147239
+ }
147240
+ operands = [value];
147241
+ property ??= await toPropertyKey(member.property, context.budget, createCoercionContext(context));
147242
+ setSandboxProperty(member.object, property, value, context.budget);
147243
+ return {
147244
+ kind: "normal",
147245
+ hasValue: true,
147246
+ value
147247
+ };
147248
+ } finally {
147249
+ release2();
147202
147250
  }
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
147251
  });
147211
147252
  }
147212
147253
  async function evaluateLogicalExpression(node, context) {
@@ -148385,12 +148426,8 @@ async function evaluateMemberAccess(node, context, consume) {
148385
148426
  if ((object.value === null || object.value === void 0) && node.optional) {
148386
148427
  return consume({ kind: "nullish" });
148387
148428
  }
148388
- const retained = {};
148389
148429
  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);
148430
+ const release2 = retainValues(context.budget, () => [object.value, property]);
148394
148431
  try {
148395
148432
  const result = node.computed ? await evaluateNode2(node.property, context) : { kind: "normal", value: getStaticPropertyName2(node.property) };
148396
148433
  if (result.kind !== "normal") return result;
@@ -148398,9 +148435,19 @@ async function evaluateMemberAccess(node, context, consume) {
148398
148435
  return await consume({ kind: "resolved", object: object.value, property });
148399
148436
  } finally {
148400
148437
  release2();
148401
- pending?.delete(release2);
148402
148438
  }
148403
148439
  }
148440
+ function retainValues(budget, values) {
148441
+ const retained = {};
148442
+ budget.setRetainedValues(retained, values);
148443
+ const pending = runResources.getStore()?.referenceReleases;
148444
+ const release2 = () => {
148445
+ budget.setRetainedValues(retained, void 0);
148446
+ pending?.delete(release2);
148447
+ };
148448
+ pending?.add(release2);
148449
+ return release2;
148450
+ }
148404
148451
  async function evaluateMemberProperty(node, context) {
148405
148452
  const property = await evaluateNode2(node, context);
148406
148453
  if (property.kind !== "normal") {
@@ -149196,30 +149243,35 @@ async function invokeSandboxClosure(callee, args, context, stack, span, thisValu
149196
149243
  }
149197
149244
  async function evaluateCallArguments(args, context) {
149198
149245
  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;
149246
+ const release2 = retainValues(context.budget, () => values);
149247
+ try {
149248
+ for (const arg of args) {
149249
+ if (arg.type === "SpreadElement") {
149250
+ const spreadValues = await evaluateSpreadElement(arg, context);
149251
+ if (!spreadValues.ok) {
149252
+ return spreadValues;
149253
+ }
149254
+ appendArrayValues2(values, spreadValues.value);
149255
+ context.budget.allocateArrayLength(values.length);
149256
+ continue;
149257
+ }
149258
+ const result = await evaluateNode2(arg, context);
149259
+ if (result.kind !== "normal") {
149260
+ return {
149261
+ ok: false,
149262
+ result
149263
+ };
149204
149264
  }
149205
- appendArrayValues2(values, spreadValues.value);
149265
+ values.push(result.value);
149206
149266
  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
149267
  }
149216
- values.push(result.value);
149217
- context.budget.allocateArrayLength(values.length);
149268
+ return {
149269
+ ok: true,
149270
+ value: values
149271
+ };
149272
+ } finally {
149273
+ release2();
149218
149274
  }
149219
- return {
149220
- ok: true,
149221
- value: values
149222
- };
149223
149275
  }
149224
149276
  async function evaluateSpreadElement(node, context) {
149225
149277
  const value = await evaluateNode2(node.argument, context);
@@ -149234,21 +149286,26 @@ async function evaluateSpreadElement(node, context) {
149234
149286
  throw new TypeError("Spread arguments must evaluate to an iterable.");
149235
149287
  }
149236
149288
  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;
149289
+ const release2 = retainValues(context.budget, () => [value.value, ...spreadValues]);
149290
+ try {
149291
+ while (true) {
149292
+ const next = await iterator.next();
149293
+ if (typeof next !== "object" || next === null) {
149294
+ throw new TypeError("Iterator result must be an object.");
149295
+ }
149296
+ if (next.done === true) {
149297
+ break;
149298
+ }
149299
+ spreadValues.push(next.value);
149300
+ context.budget.allocateArrayLength(spreadValues.length);
149244
149301
  }
149245
- spreadValues.push(next.value);
149246
- context.budget.allocateArrayLength(spreadValues.length);
149302
+ return {
149303
+ ok: true,
149304
+ value: spreadValues
149305
+ };
149306
+ } finally {
149307
+ release2();
149247
149308
  }
149248
- return {
149249
- ok: true,
149250
- value: spreadValues
149251
- };
149252
149309
  }
149253
149310
  async function evaluateObjectSpread(node, context) {
149254
149311
  const value = await evaluateNode2(node.argument, context);