@poe-platform/safe-js 0.1.175 → 0.1.176

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.
@@ -10512,7 +10512,15 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
10512
10512
  if (value === null || value === void 0)
10513
10513
  throw new TypeError(`String#${methodName} requires a non-null receiver.`);
10514
10514
  const fallback = (coercePattern = false) => {
10515
- const apply = (string) => coercePattern && (methodName === "match" || methodName === "matchAll" || methodName === "search") ? callStringPattern(string, methodName, args[0], budget, parent, context) : callStringMethodBody(string, methodName, args, budget, callClosure, parent, context);
10515
+ const apply = (string) => {
10516
+ if (coercePattern && (methodName === "match" || methodName === "matchAll" || methodName === "search"))
10517
+ return callStringPattern(string, methodName, args[0], budget, parent, context);
10518
+ const useRegex = isSandboxRegex(args[0]) && !coercePattern;
10519
+ if (methodName === "replace" || methodName === "replaceAll")
10520
+ return callReplaceLikeMethod(string, methodName, args, budget, callClosure, useRegex, context);
10521
+ if (methodName === "split") return callSplit(string, args, budget, useRegex, parent, context);
10522
+ return callStringMethodBody(string, methodName, args, budget, parent, context);
10523
+ };
10516
10524
  return typeof value === "string" ? apply(value) : Promise.resolve(sandboxString(value, budget, context)).then(apply);
10517
10525
  };
10518
10526
  const symbol = methodName === "match" ? Symbol.match : methodName === "search" ? Symbol.search : methodName === "matchAll" ? Symbol.matchAll : methodName === "replace" || methodName === "replaceAll" ? Symbol.replace : methodName === "split" ? Symbol.split : void 0;
@@ -10550,7 +10558,7 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
10550
10558
  }
10551
10559
  return dispatch();
10552
10560
  }
10553
- function callStringMethodBody(value, methodName, args, budget, callClosure = async (closure, closureArgs) => await closure.call(closureArgs), parent, context) {
10561
+ function callStringMethodBody(value, methodName, args, budget, parent, context) {
10554
10562
  if (methodName === "concat" && args.some((argument) => argument !== null && typeof argument === "object")) {
10555
10563
  return callConcat(value, args, budget, context);
10556
10564
  }
@@ -10589,10 +10597,6 @@ function callStringMethodBody(value, methodName, args, budget, callClosure = asy
10589
10597
  }
10590
10598
  return budget.allocateString(result + value.slice(spanStart));
10591
10599
  }
10592
- if (methodName === "replace" || methodName === "replaceAll") {
10593
- return callReplaceLikeMethod(value, methodName, args, budget, callClosure, context);
10594
- }
10595
- if (methodName === "split") return callSplit(value, args, budget, parent, context);
10596
10600
  const regex = args[0];
10597
10601
  if (isSandboxRegex(regex) && regex.lastIndex !== null && typeof regex.lastIndex === "object" && (methodName === "match" && !regex.flags.includes("g") || methodName === "matchAll")) {
10598
10602
  return callStringRegexCursor(value, methodName, regex, budget, parent, context);
@@ -10720,19 +10724,19 @@ async function callConcat(value, args, budget, context) {
10720
10724
  release();
10721
10725
  }
10722
10726
  }
10723
- function callReplaceLikeMethod(value, methodName, args, budget, callClosure, context) {
10727
+ function callReplaceLikeMethod(value, methodName, args, budget, callClosure, useRegex, context) {
10724
10728
  const search = args[0];
10725
10729
  const replacement = args[1];
10726
- const useRegex = isSandboxRegex(search) && getSandboxPropertyDescriptor(search, Symbol.replace, budget) === void 0;
10727
- if (!useRegex && typeof search !== "string" || typeof replacement !== "string" && !isSandboxClosure(replacement)) {
10730
+ const regexSearch = useRegex && isSandboxRegex(search);
10731
+ if (!regexSearch && typeof search !== "string" || typeof replacement !== "string" && !isSandboxClosure(replacement)) {
10728
10732
  return (async () => {
10729
10733
  let normalizedSearch;
10730
10734
  let normalizedReplacement;
10731
10735
  const release = retainValues(budget, () => [normalizedSearch, normalizedReplacement]);
10732
10736
  try {
10733
- normalizedSearch = useRegex ? search : await sandboxString(search, budget, context);
10737
+ normalizedSearch = regexSearch ? search : await sandboxString(search, budget, context);
10734
10738
  normalizedReplacement = isSandboxClosure(replacement) ? replacement : await sandboxString(replacement, budget, context);
10735
- return await callReplaceLikeMethod(value, methodName, [normalizedSearch, normalizedReplacement], budget, callClosure, context);
10739
+ return await callReplaceLikeMethod(value, methodName, [normalizedSearch, normalizedReplacement], budget, callClosure, useRegex, context);
10736
10740
  } finally {
10737
10741
  release();
10738
10742
  }
@@ -10856,9 +10860,8 @@ function findReplacementOffsets(value, searchValue, replaceAll) {
10856
10860
  }
10857
10861
  return offsets;
10858
10862
  }
10859
- function callSplit(value, args, budget, parent, context) {
10863
+ function callSplit(value, args, budget, useRegex, parent, context) {
10860
10864
  const pattern = args[0];
10861
- const useRegex = isSandboxRegex(pattern) && getSandboxPropertyDescriptor(pattern, Symbol.split, budget) === void 0;
10862
10865
  let separator;
10863
10866
  const release = retainValues(budget, () => [value, ...args, separator]);
10864
10867
  const withLimit = (number) => {
@@ -36410,4 +36413,4 @@ export {
36410
36413
  FileSnapshotBackend,
36411
36414
  run
36412
36415
  };
36413
- //# sourceMappingURL=chunk-PECCU43A.js.map
36416
+ //# sourceMappingURL=chunk-7CBZ6QP7.js.map