@poe-platform/safe-js 0.1.218 → 0.1.220

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.
@@ -27,7 +27,7 @@ import {
27
27
  validateMigrationSemantics,
28
28
  validateSnapshotData,
29
29
  validateSnapshotMigration
30
- } from "./chunk-7FIJ3D55.js";
30
+ } from "./chunk-AYL6LSPV.js";
31
31
 
32
32
  // packages/safe-js/src/migrate.ts
33
33
  import { createHash } from "node:crypto";
@@ -8249,4 +8249,4 @@ export {
8249
8249
  parseMcpConfig,
8250
8250
  makeMcpModule
8251
8251
  };
8252
- //# sourceMappingURL=chunk-Z3GR3FJR.js.map
8252
+ //# sourceMappingURL=chunk-3IUIZXWX.js.map
@@ -8538,7 +8538,7 @@ function captureGuestHeapNode(value, encode) {
8538
8538
  ...value.state !== "suspended" || origin2.expressionStates === void 0 ? {} : {
8539
8539
  expressionStates: Object.fromEntries([...origin2.expressionStates].map(([id, expression]) => [
8540
8540
  String(id),
8541
- expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "object" ? {
8541
+ expression.kind === "binary" ? { kind: "binary", left: encode(expression.left) } : expression.kind === "template" ? { ...expression } : expression.kind === "object" ? {
8542
8542
  kind: "object",
8543
8543
  value: encode(expression.value),
8544
8544
  index: expression.index,
@@ -16600,11 +16600,20 @@ function isObjectPrototypeSetterProperty(property, key) {
16600
16600
  return !property.computed && !property.shorthand && key === "__proto__" && !(property.value.type === "FunctionExpression" && property.value.method === true);
16601
16601
  }
16602
16602
  async function evaluateTemplateLiteral(node, context) {
16603
- let value = context.budget.allocateString(node.quasis[0]?.value.cooked ?? "");
16603
+ const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
16604
+ if (restored !== void 0 && restored.kind !== "template") throw new TypeError("Invalid template continuation.");
16605
+ const state = { kind: "template", prefix: restored?.prefix ?? "", index: restored?.index ?? 0 };
16606
+ let value = context.budget.allocateString(restored?.prefix ?? node.quasis[0]?.value.cooked ?? "");
16607
+ if (context.generatorYield !== void 0 && node.nodeId !== void 0) context = {
16608
+ ...context,
16609
+ generatorExpressionStates: new Map([...context.generatorExpressionStates ?? [], [node.nodeId, state]])
16610
+ };
16604
16611
  let input = void 0;
16605
16612
  const release = retainValues(context.budget, () => [value, input]);
16606
16613
  try {
16607
- for (let index = 0; index < node.expressions.length; index += 1) {
16614
+ for (let index = state.index; index < node.expressions.length; index += 1) {
16615
+ state.index = index;
16616
+ state.prefix = value;
16608
16617
  const expression = await evaluateNode(node.expressions[index], context);
16609
16618
  if (expression.kind !== "normal") {
16610
16619
  return expression;
@@ -16629,9 +16638,11 @@ async function evaluateTemplateLiteral(node, context) {
16629
16638
  async function evaluateTaggedTemplateExpression(node, context) {
16630
16639
  const invokeTag = async (tag2, receiver) => {
16631
16640
  if (!isSandboxClosure(tag2)) throw new TypeError("Tagged template tag must be a function.");
16641
+ const call = createCallContinuation(node, tag2, context, receiver);
16642
+ context = call.context;
16632
16643
  const release = retainValues(context.budget, () => [tag2, receiver]);
16633
16644
  try {
16634
- const values = await evaluateTemplateExpressionValues(node.quasi, context);
16645
+ const values = await evaluateCallArguments(node.quasi.expressions, context, call.state);
16635
16646
  if (!values.ok) return values.result;
16636
16647
  return {
16637
16648
  kind: "normal",
@@ -16649,6 +16660,11 @@ async function evaluateTaggedTemplateExpression(node, context) {
16649
16660
  release();
16650
16661
  }
16651
16662
  };
16663
+ const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
16664
+ if (restored !== void 0) {
16665
+ if (restored.kind !== "tagged") throw new TypeError("Invalid tagged template continuation.");
16666
+ return invokeTag(restored.callee, restored.thisValue);
16667
+ }
16652
16668
  if (node.tag.type === "MemberExpression") return evaluateMemberAccess(node.tag, context, async (member) => {
16653
16669
  if (member.kind === "nullish") throw new TypeError("Tagged template tag must be a function.");
16654
16670
  const key = await toPropertyKey(member.property, context.budget, createCoercionContext(context));
@@ -16658,28 +16674,6 @@ async function evaluateTaggedTemplateExpression(node, context) {
16658
16674
  const tag = await evaluateNode(node.tag, context);
16659
16675
  return tag.kind === "normal" ? invokeTag(tag.value, void 0) : tag;
16660
16676
  }
16661
- async function evaluateTemplateExpressionValues(node, context) {
16662
- const values = [];
16663
- const release = retainValues(context.budget, () => values);
16664
- try {
16665
- for (const expressionNode of node.expressions) {
16666
- const expression = await evaluateNode(expressionNode, context);
16667
- if (expression.kind !== "normal") {
16668
- return {
16669
- ok: false,
16670
- result: expression
16671
- };
16672
- }
16673
- values.push(expression.value);
16674
- }
16675
- return {
16676
- ok: true,
16677
- value: values
16678
- };
16679
- } finally {
16680
- release();
16681
- }
16682
- }
16683
16677
  function createTaggedTemplateStrings(node, context) {
16684
16678
  context.budget.allocateArrayLength(node.quasis.length);
16685
16679
  const strings = node.quasis.map(
@@ -19102,16 +19096,16 @@ async function invokeSandboxClosure(callee, args, context, stack, span, thisValu
19102
19096
  }
19103
19097
  }
19104
19098
  function createCallContinuation(node, callee, context, thisValue = void 0) {
19105
- const kind = node.type === "NewExpression" ? "new" : "call";
19099
+ const kind = node.type === "NewExpression" ? "new" : node.type === "TaggedTemplateExpression" ? "tagged" : "call";
19106
19100
  const restored = context.generatorResume === void 0 || node.nodeId === void 0 ? void 0 : context.restoredGeneratorExpressionStates?.get(node.nodeId);
19107
- if (restored !== void 0 && (restored.kind !== "call" && restored.kind !== "new" || restored.kind !== kind || !Array.isArray(restored.args)))
19101
+ if (restored !== void 0 && (restored.kind !== "call" && restored.kind !== "new" && restored.kind !== "tagged" || restored.kind !== kind || !Array.isArray(restored.args)))
19108
19102
  throw new TypeError("Invalid call expression continuation.");
19109
19103
  const state = {
19110
19104
  kind,
19111
19105
  callee,
19112
19106
  thisValue,
19113
- args: restored?.kind === "call" || restored?.kind === "new" ? restored.args : [],
19114
- index: restored?.kind === "call" || restored?.kind === "new" ? restored.index : 0
19107
+ args: restored?.kind === "call" || restored?.kind === "new" || restored?.kind === "tagged" ? restored.args : [],
19108
+ index: restored?.kind === "call" || restored?.kind === "new" || restored?.kind === "tagged" ? restored.index : 0
19115
19109
  };
19116
19110
  return { state, context: context.generatorYield === void 0 || node.nodeId === void 0 ? context : {
19117
19111
  ...context,
@@ -22382,6 +22376,10 @@ function validateGuestHeapNode(raw, heap) {
22382
22376
  const expression = record2(raw2);
22383
22377
  if (expression.kind === "binary") {
22384
22378
  fields(expression, ["kind", "left"]);
22379
+ } else if (expression.kind === "template") {
22380
+ fields(expression, ["kind", "prefix", "index"]);
22381
+ integer(expression.index);
22382
+ if (typeof expression.prefix !== "string") throw new TypeError("Invalid template prefix.");
22385
22383
  } else if (expression.kind === "object") {
22386
22384
  fields(expression, ["kind", "value", "index"], ["key"]);
22387
22385
  integer(expression.index);
@@ -22390,7 +22388,7 @@ function validateGuestHeapNode(raw, heap) {
22390
22388
  fields(expression, ["kind", "values", "index"]);
22391
22389
  integer(expression.index);
22392
22390
  reference(expression.values, ["array"]);
22393
- } else if (expression.kind === "call" || expression.kind === "new") {
22391
+ } else if (expression.kind === "call" || expression.kind === "new" || expression.kind === "tagged") {
22394
22392
  fields(expression, ["kind", "callee", "thisValue", "args", "index"]);
22395
22393
  integer(expression.index);
22396
22394
  reference(expression.args, ["array"]);
@@ -22504,6 +22502,17 @@ function validateGuestFunctionAst(record3, origin) {
22504
22502
  yieldExpressions = frame.expressions;
22505
22503
  }
22506
22504
  for (const [key, value] of Object.entries(node)) {
22505
+ if (node.type === "TaggedTemplateExpression" && key === "quasi") {
22506
+ value.expressions.forEach((expression, index) => {
22507
+ pending.push({
22508
+ value: expression,
22509
+ blocks,
22510
+ finalizers: frame.finalizers,
22511
+ expressions: new Map([...frame.expressions, [node.nodeId, { kind: "tagged", index }]])
22512
+ });
22513
+ });
22514
+ continue;
22515
+ }
22507
22516
  if (node.type === "ObjectExpression" && key === "properties" && typeof node.nodeId === "number" && Array.isArray(value)) {
22508
22517
  const id = node.nodeId;
22509
22518
  value.forEach((property, index) => {
@@ -22525,8 +22534,8 @@ function validateGuestFunctionAst(record3, origin) {
22525
22534
  });
22526
22535
  continue;
22527
22536
  }
22528
- if ((node.type === "ArrayExpression" && key === "elements" || (node.type === "CallExpression" || node.type === "NewExpression") && key === "arguments") && typeof node.nodeId === "number" && Array.isArray(value)) {
22529
- const kind = node.type === "ArrayExpression" ? "array" : node.type === "CallExpression" ? "call" : "new";
22537
+ 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)) {
22538
+ const kind = node.type === "ArrayExpression" ? "array" : node.type === "TemplateLiteral" ? "template" : node.type === "CallExpression" ? "call" : "new";
22530
22539
  value.forEach((element, index) => pending.push({
22531
22540
  value: element,
22532
22541
  blocks,
@@ -38753,4 +38762,4 @@ export {
38753
38762
  FileSnapshotBackend,
38754
38763
  run
38755
38764
  };
38756
- //# sourceMappingURL=chunk-7FIJ3D55.js.map
38765
+ //# sourceMappingURL=chunk-AYL6LSPV.js.map