@poe-platform/safe-js 0.1.256 → 0.1.257

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.
@@ -14845,11 +14845,16 @@ function createCollectionGlobals(options) {
14845
14845
  budget: options.budget,
14846
14846
  context,
14847
14847
  retainedValues: () => [key, value],
14848
- append: (entry) => {
14848
+ append: (entry, adder) => {
14849
14849
  if (typeof entry !== "object" || entry === null)
14850
14850
  throw new TypeError("Map constructor requires entry objects.");
14851
14851
  const store = (entryValue) => {
14852
14852
  value = entryValue;
14853
+ if (adder !== void 0)
14854
+ return invokeBuiltinClosure(adder, [key, value], options.budget, context, map).then(() => {
14855
+ key = value = void 0;
14856
+ return 0;
14857
+ });
14853
14858
  const added = map.entries.has(key) ? 0 : 1;
14854
14859
  const growth = added + (options.budget.limits.dataSize === void 0 ? 0 : measureSandboxData([key, value]));
14855
14860
  options.budget.allocateCollectionEntries(map.entries.size + added);
@@ -14882,7 +14887,9 @@ function createCollectionGlobals(options) {
14882
14887
  name: "Set",
14883
14888
  budget: options.budget,
14884
14889
  context,
14885
- append: (value) => {
14890
+ append: (value, adder) => {
14891
+ if (adder !== void 0)
14892
+ return invokeBuiltinClosure(adder, [value], options.budget, context, set).then(() => 0);
14886
14893
  const added = set.values.has(value) ? 0 : 1;
14887
14894
  const growth = added + (options.budget.limits.dataSize === void 0 ? 0 : measureSandboxData([value]));
14888
14895
  options.budget.allocateCollectionEntries(set.values.size + added);
@@ -14913,15 +14920,17 @@ function populateCollection(source, collection, {
14913
14920
  }) {
14914
14921
  budget.allocateCollectionEntries(0);
14915
14922
  if (source === void 0 || source === null) return collection;
14916
- const populate = (iterator2) => {
14917
- if (iterator2 === void 0) throw new TypeError(`${name} constructor requires an iterable.`);
14923
+ let adder;
14924
+ const populate = (iterator) => {
14925
+ if (iterator === void 0) throw new TypeError(`${name} constructor requires an iterable.`);
14918
14926
  let entry;
14919
14927
  let failure;
14920
14928
  const retained = {};
14921
14929
  budget.setRetainedValues(retained, () => [
14922
14930
  source,
14923
- iterator2.retainedValue,
14931
+ iterator.retainedValue,
14924
14932
  collection,
14933
+ adder,
14925
14934
  entry,
14926
14935
  failure,
14927
14936
  ...retainedValues?.() ?? []
@@ -14933,13 +14942,13 @@ function populateCollection(source, collection, {
14933
14942
  if (!isFatalSandboxError(error) && isFatalSandboxError(closeError)) throw closeError;
14934
14943
  throw error;
14935
14944
  };
14936
- if (iterator2.getOperation !== void 0)
14937
- return closeIterator(iterator2, true).then(() => {
14945
+ if (iterator.getOperation !== void 0)
14946
+ return closeIterator(iterator, true).then(() => {
14938
14947
  throw error;
14939
14948
  }, rethrow);
14940
14949
  try {
14941
- const closing = iterator2.return?.();
14942
- if (iterator2.generator || iterator2.asynchronous)
14950
+ const closing = iterator.return?.();
14951
+ if (iterator.generator || iterator.asynchronous)
14943
14952
  return Promise.resolve(closing).then(() => {
14944
14953
  throw error;
14945
14954
  }, rethrow);
@@ -14955,7 +14964,7 @@ function populateCollection(source, collection, {
14955
14964
  entry = result.value;
14956
14965
  try {
14957
14966
  budget.visitNode();
14958
- const growth = append(entry);
14967
+ const growth = append(entry, adder);
14959
14968
  if (growth instanceof Promise)
14960
14969
  return growth.then((size) => {
14961
14970
  entry = void 0;
@@ -14969,16 +14978,16 @@ function populateCollection(source, collection, {
14969
14978
  }
14970
14979
  return false;
14971
14980
  };
14972
- if (iterator2.generator || iterator2.asynchronous || context !== void 0) {
14981
+ if (iterator.generator || iterator.asynchronous || context !== void 0 || adder !== void 0) {
14973
14982
  return (async () => {
14974
14983
  try {
14975
14984
  checkData(collection, 0, true);
14976
14985
  while (true) {
14977
- const result = await iterator2.next();
14986
+ const result = await iterator.next();
14978
14987
  if (typeof result !== "object" || result === null)
14979
14988
  throw new TypeError("Iterator result must be an object.");
14980
- if ((await readIteratorResult(iterator2, result, "done")).value) break;
14981
- const value = (await readIteratorResult(iterator2, result, "value")).value;
14989
+ if ((await readIteratorResult(iterator, result, "done")).value) break;
14990
+ const value = (await readIteratorResult(iterator, result, "value")).value;
14982
14991
  await consume({ done: false, value });
14983
14992
  }
14984
14993
  checkData(collection, 0, true);
@@ -14990,7 +14999,7 @@ function populateCollection(source, collection, {
14990
14999
  }
14991
15000
  try {
14992
15001
  checkData(collection, 0, true);
14993
- while (!consume(iterator2.next())) {
15002
+ while (!consume(iterator.next())) {
14994
15003
  }
14995
15004
  checkData(collection, 0, true);
14996
15005
  return collection;
@@ -14998,8 +15007,16 @@ function populateCollection(source, collection, {
14998
15007
  budget.setRetainedValues(retained, void 0);
14999
15008
  }
15000
15009
  };
15001
- const iterator = context === void 0 ? getSandboxIterator(source, budget) : acquireSandboxIterator(source, budget, context);
15002
- return iterator instanceof Promise ? iterator.then(populate) : populate(iterator);
15010
+ const method = name === "Map" ? "set" : "add";
15011
+ const start = (candidate2) => {
15012
+ if (!isSandboxClosure(candidate2)) throw new TypeError(`${name} constructor adder must be callable.`);
15013
+ if (getIntrinsicIdentity(candidate2) !== JSON.stringify([name, "prototype", method])) adder = candidate2;
15014
+ const iterator = context === void 0 ? getSandboxIterator(source, budget) : acquireSandboxIterator(source, budget, context);
15015
+ return iterator instanceof Promise ? iterator.then(populate) : populate(iterator);
15016
+ };
15017
+ const descriptor = getSandboxPropertyDescriptor(collection, method, budget);
15018
+ const candidate = context?.getProperty !== void 0 ? context.getProperty(collection, method) : descriptor === void 0 ? void 0 : readPropertyDescriptor(descriptor, collection, context);
15019
+ return candidate instanceof Promise ? candidate.then(start) : start(candidate);
15003
15020
  }
15004
15021
 
15005
15022
  // packages/safe-js/src/interp/methods/collection-iterator.ts
@@ -39798,4 +39815,4 @@ export {
39798
39815
  FileSnapshotBackend,
39799
39816
  run
39800
39817
  };
39801
- //# sourceMappingURL=chunk-S2YTYPJP.js.map
39818
+ //# sourceMappingURL=chunk-A2FDFKJ6.js.map