@poe-platform/safe-js 0.1.102 → 0.1.104

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-PCHV72VT.js";
30
+ } from "./chunk-WNZAFVXS.js";
31
31
 
32
32
  // packages/safe-js/src/migrate.ts
33
33
  import { createHash } from "node:crypto";
@@ -8245,4 +8245,4 @@ export {
8245
8245
  parseMcpConfig,
8246
8246
  makeMcpModule
8247
8247
  };
8248
- //# sourceMappingURL=chunk-4N5UNUJB.js.map
8248
+ //# sourceMappingURL=chunk-5T5TYHIX.js.map
@@ -28831,7 +28831,7 @@ async function executeClosure(node, args, thisValue, context, evaluateNode2) {
28831
28831
  const value = "hasValue" in result && result.hasValue ? result.value : void 0;
28832
28832
  reconcileCompiledValues(
28833
28833
  context.budget,
28834
- [...scope.retainedValues(), ...context.budget.retainedValues(), value],
28834
+ [...scope.retainedValues(), value],
28835
28835
  compilation,
28836
28836
  parent,
28837
28837
  [value]
@@ -30510,12 +30510,12 @@ function createObjectArrayGlobals(options) {
30510
30510
  }),
30511
30511
  fromEntries: createSandboxClosure({
30512
30512
  sandbox: true,
30513
- call: ([value]) => {
30513
+ call: ([value], context) => {
30514
30514
  const iterator = getSandboxIterator(value);
30515
30515
  if (iterator === void 0) {
30516
30516
  throw new TypeError("Object.fromEntries requires an iterable.");
30517
30517
  }
30518
- if (!iterator.generator) {
30518
+ if (context === void 0 && !iterator.generator) {
30519
30519
  return allocateProducedSandboxValue(
30520
30520
  Object.setPrototypeOf(
30521
30521
  Reflect.apply(Object.fromEntries, Object, [{ [Symbol.iterator]: () => iterator }]),
@@ -30524,7 +30524,7 @@ function createObjectArrayGlobals(options) {
30524
30524
  options.budget
30525
30525
  );
30526
30526
  }
30527
- return objectFromSandboxEntries(iterator, options.budget);
30527
+ return objectFromSandboxEntries(value, iterator, options.budget, context);
30528
30528
  },
30529
30529
  name: "fromEntries"
30530
30530
  }),
@@ -30647,37 +30647,59 @@ function createObjectArrayGlobals(options) {
30647
30647
  })
30648
30648
  };
30649
30649
  }
30650
- async function objectFromSandboxEntries(iterator, budget) {
30650
+ async function objectFromSandboxEntries(items, iterator, budget, context) {
30651
30651
  const object = /* @__PURE__ */ Object.create(null);
30652
+ let entry;
30653
+ let key;
30654
+ let value;
30655
+ let failure;
30656
+ const retained = {};
30657
+ budget.setRetainedValues(retained, () => [items, object, entry, key, value, failure]);
30658
+ const checkData = createDataCheckpoint(budget, context);
30659
+ const closeOnThrow = async (error) => {
30660
+ failure = isCapturedException(error) ? error.reason : error;
30661
+ try {
30662
+ await iterator.return?.();
30663
+ } catch (closeError) {
30664
+ if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
30665
+ }
30666
+ throw error;
30667
+ };
30652
30668
  try {
30669
+ checkData(object, 0, true);
30653
30670
  while (true) {
30671
+ try {
30672
+ budget.visitNode();
30673
+ } catch (error) {
30674
+ await closeOnThrow(error);
30675
+ }
30654
30676
  const result = await iterator.next();
30655
- if (typeof result !== "object" && typeof result !== "function" || result === null) {
30677
+ if (typeof result !== "object" || result === null) {
30656
30678
  throw new TypeError("Iterator result must be an object.");
30657
30679
  }
30658
30680
  if (result.done) break;
30659
- const entry = result.value;
30660
- if (typeof entry !== "object" && typeof entry !== "function" || entry === null) {
30661
- throw new TypeError("Object.fromEntries requires entry objects.");
30681
+ entry = result.value;
30682
+ try {
30683
+ if (typeof entry !== "object" || entry === null) {
30684
+ throw new TypeError("Object.fromEntries requires entry objects.");
30685
+ }
30686
+ key = context?.getProperty !== void 0 ? context.getProperty(entry, 0) : getSandboxDataProperty(entry, 0, budget);
30687
+ value = context?.getProperty !== void 0 ? context.getProperty(entry, 1) : getSandboxDataProperty(entry, 1, budget);
30688
+ const property = await sandboxString(key, budget, context);
30689
+ const growth = property.length + 1 + (budget.limits.dataSize === void 0 ? 0 : measureSandboxData([value]));
30690
+ budget.visitNode();
30691
+ defineOwnDataProperty(object, property, value);
30692
+ entry = key = value = void 0;
30693
+ checkData(object, growth);
30694
+ } catch (error) {
30695
+ await closeOnThrow(error);
30662
30696
  }
30663
- const key = entry[0];
30664
- const value = entry[1];
30665
- Object.defineProperty(object, key, {
30666
- configurable: true,
30667
- enumerable: true,
30668
- value,
30669
- writable: true
30670
- });
30671
- }
30672
- } catch (error) {
30673
- try {
30674
- await iterator.return?.();
30675
- } catch {
30676
- throw error;
30677
30697
  }
30678
- throw error;
30698
+ checkData(object, 0, true);
30699
+ return allocateProducedSandboxValue(object, budget);
30700
+ } finally {
30701
+ budget.setRetainedValues(retained, void 0);
30679
30702
  }
30680
- return allocateProducedSandboxValue(object, budget);
30681
30703
  }
30682
30704
  function assignSandboxValues(target, sources, budget) {
30683
30705
  if (target === null || target === void 0) {
@@ -30757,18 +30779,9 @@ async function arrayFromSandboxValues(args, budget, context) {
30757
30779
  let result;
30758
30780
  let currentValue;
30759
30781
  let failure;
30760
- let estimatedDataSize = 0;
30761
30782
  const retained = {};
30762
30783
  budget.setRetainedValues(retained, () => [items, mapFn, constructor, result, currentValue, failure]);
30763
- const checkData = (growth = 0, force = false) => {
30764
- const limit = budget.limits.dataSize;
30765
- if (limit === void 0) return;
30766
- estimatedDataSize = Math.max(estimatedDataSize, budget.currentDataSize) + growth;
30767
- if (!force && estimatedDataSize <= limit) return;
30768
- if (context?.reconcileData !== void 0) context.reconcileData(result);
30769
- else reconcileCompiledValues(budget, [], context?.compilation);
30770
- estimatedDataSize = budget.currentDataSize;
30771
- };
30784
+ const checkData = createDataCheckpoint(budget, context);
30772
30785
  const closeOnThrow = async (error) => {
30773
30786
  failure = isCapturedException(error) ? error.reason : error;
30774
30787
  try {
@@ -30785,7 +30798,7 @@ async function arrayFromSandboxValues(args, budget, context) {
30785
30798
  length = Number.isNaN(number) || number <= 0 ? 0 : Math.min(Math.trunc(number), Number.MAX_SAFE_INTEGER);
30786
30799
  }
30787
30800
  result = isSandboxClosure(constructor) && constructor.construct !== void 0 ? await invokeBuiltinClosure(constructor, iterator === void 0 ? [length] : [], budget, context, void 0, true) : createArrayFromConstructorArgs([length], budget);
30788
- checkData(0, true);
30801
+ checkData(result, 0, true);
30789
30802
  let index = 0;
30790
30803
  while (iterator !== void 0 || index < length) {
30791
30804
  try {
@@ -30811,19 +30824,31 @@ async function arrayFromSandboxValues(args, budget, context) {
30811
30824
  budget.visitNode();
30812
30825
  defineOwnDataProperty(objectProperties(result, true), key, currentValue);
30813
30826
  currentValue = void 0;
30814
- checkData(growth, graphChanged);
30827
+ checkData(result, growth, graphChanged);
30815
30828
  } catch (error) {
30816
30829
  await closeOnThrow(error);
30817
30830
  }
30818
30831
  index += 1;
30819
30832
  }
30820
30833
  setSandboxProperty(result, "length", index, budget);
30821
- checkData(0, true);
30834
+ checkData(result, 0, true);
30822
30835
  return allocateProducedSandboxValue(result, budget);
30823
30836
  } finally {
30824
30837
  budget.setRetainedValues(retained, void 0);
30825
30838
  }
30826
30839
  }
30840
+ function createDataCheckpoint(budget, context) {
30841
+ let estimatedDataSize = 0;
30842
+ return (value, growth = 0, force = false) => {
30843
+ const limit = budget.limits.dataSize;
30844
+ if (limit === void 0) return;
30845
+ estimatedDataSize = Math.max(estimatedDataSize, budget.currentDataSize) + growth;
30846
+ if (!force && estimatedDataSize <= limit) return;
30847
+ if (context?.reconcileData !== void 0) context.reconcileData(value);
30848
+ else reconcileCompiledValues(budget, [value], context?.compilation);
30849
+ estimatedDataSize = budget.currentDataSize;
30850
+ };
30851
+ }
30827
30852
  function createArrayFromConstructorArgs(args, budget) {
30828
30853
  if (args.length !== 1) {
30829
30854
  return budgetSandboxValue2(Reflect.apply(Array, Array, [...args]), budget);
@@ -32718,8 +32743,7 @@ function run(source, options = {}) {
32718
32743
  budget,
32719
32744
  [
32720
32745
  ...Object.values(result2.snapshot.bindings),
32721
- ...result2.ok && "returnValue" in result2 ? [result2.returnValue] : [],
32722
- ...budget.retainedValues()
32746
+ ...result2.ok && "returnValue" in result2 ? [result2.returnValue] : []
32723
32747
  ],
32724
32748
  compilation
32725
32749
  );
@@ -33000,4 +33024,4 @@ export {
33000
33024
  FileSnapshotBackend,
33001
33025
  run
33002
33026
  };
33003
- //# sourceMappingURL=chunk-PCHV72VT.js.map
33027
+ //# sourceMappingURL=chunk-WNZAFVXS.js.map