@poe-platform/safe-js 0.1.178 → 0.1.179

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-BM7QYQOS.js";
30
+ } from "./chunk-GF7KHTVI.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-S43OS5GO.js.map
8252
+ //# sourceMappingURL=chunk-AQQ5HET5.js.map
@@ -10577,7 +10577,7 @@ function callStringMethod(value, methodName, args, budget, callClosure = async (
10577
10577
  if (symbol !== void 0 && types6.isRegExp(pattern))
10578
10578
  throw new TypeError(`String#${methodName} does not accept unbranded host RegExp values.`);
10579
10579
  if (symbol === void 0 || pattern === null || pattern === void 0) return fallback();
10580
- const readProperty = (key) => context?.getProperty !== void 0 ? context.getProperty(pattern, key) : key === "flags" && isSandboxRegex(pattern) && getSandboxPropertyDescriptor(pattern, key, budget) === void 0 ? pattern.flags : getSandboxDataProperty(pattern, key, budget);
10580
+ const readProperty = (key) => context?.getProperty !== void 0 ? context.getProperty(pattern, key) : key === "flags" && isSandboxRegex(pattern) && getSandboxPropertyDescriptor(pattern, key, budget) === void 0 ? getRegexMember(pattern, key, budget, context) : getSandboxDataProperty(pattern, key, budget);
10581
10581
  const dispatch = () => {
10582
10582
  const overriddenRegex = isSandboxRegex(pattern) && getSandboxPropertyDescriptor(pattern, symbol, budget) !== void 0;
10583
10583
  const applyHook = (hook2) => {
@@ -10647,7 +10647,7 @@ function callStringMethodBody(value, methodName, args, budget, parent, context)
10647
10647
  return budget.allocateString(result + value.slice(spanStart));
10648
10648
  }
10649
10649
  const regex = args[0];
10650
- if (isSandboxRegex(regex) && regex.lastIndex !== null && typeof regex.lastIndex === "object" && (methodName === "match" && !regex.flags.includes("g") || methodName === "matchAll")) {
10650
+ if (isSandboxRegex(regex) && (methodName === "matchAll" || methodName === "match" && !regex.flags.includes("g") && regex.lastIndex !== null && typeof regex.lastIndex === "object")) {
10651
10651
  return callStringRegexCursor(value, methodName, regex, budget, parent, context);
10652
10652
  }
10653
10653
  if ((methodName === "match" || methodName === "matchAll" || methodName === "search") && !isSandboxRegex(args[0])) {
@@ -10994,19 +10994,57 @@ async function callStringPattern(value, methodName, pattern, budget, parent, con
10994
10994
  operation.release();
10995
10995
  }
10996
10996
  }
10997
- async function callStringRegexCursor(value, methodName, regex, budget, parent, context) {
10997
+ function callStringRegexCursor(value, methodName, regex, budget, parent, context) {
10998
10998
  const operation = budget.acquireCompileOwner(false, parent?.owner);
10999
10999
  const compilation = new CompileScope(operation.owner);
11000
- const cursor = regex.lastIndex;
11000
+ let cursor;
11001
+ let flagsValue;
11002
+ let flags;
11003
+ let matcher;
11001
11004
  const retained = {};
11002
- budget.setRetainedValues(retained, () => [value, regex, cursor]);
11003
- try {
11004
- const lastIndex = await sandboxNumber(cursor, budget, context);
11005
- return callMatchLikeMethod(value, methodName, [regex], compilation, lastIndex);
11006
- } finally {
11005
+ budget.setRetainedValues(retained, () => [value, regex, cursor, flagsValue, flags, matcher]);
11006
+ const release = () => {
11007
11007
  budget.setRetainedValues(retained, void 0);
11008
11008
  compilation.dispose();
11009
11009
  operation.release();
11010
+ };
11011
+ const readCursor = () => {
11012
+ cursor = regex.lastIndex;
11013
+ const finish = (lastIndex2) => {
11014
+ if (matcher !== void 0) {
11015
+ matcher.lastIndex = normalizeLastIndex(lastIndex2);
11016
+ return restoreSandboxRegExpIterator({ matcher, input: value, exhausted: false });
11017
+ }
11018
+ return callMatchLikeMethod(value, methodName, [regex], compilation, lastIndex2);
11019
+ };
11020
+ const lastIndex = sandboxNumber(cursor, budget, context);
11021
+ return lastIndex instanceof Promise ? lastIndex.then(finish) : finish(lastIndex);
11022
+ };
11023
+ const clone = (text) => {
11024
+ flags = text;
11025
+ flagsValue = void 0;
11026
+ matcher = createSandboxRegex(regex.source, flags, 0, compilation);
11027
+ flags = void 0;
11028
+ return readCursor();
11029
+ };
11030
+ const convertFlags = (value2) => {
11031
+ flagsValue = value2;
11032
+ const text = sandboxString(value2, budget, context);
11033
+ return text instanceof Promise ? text.then(clone) : clone(text);
11034
+ };
11035
+ try {
11036
+ let result;
11037
+ if (methodName === "matchAll") {
11038
+ const descriptor = context?.getProperty === void 0 ? getSandboxPropertyDescriptor(regex, "flags", budget) : void 0;
11039
+ const value2 = context?.getProperty !== void 0 ? context.getProperty(regex, "flags") : descriptor !== void 0 ? readPropertyDescriptor(descriptor, regex, context) : getRegexMember(regex, "flags", budget, context);
11040
+ result = value2 instanceof Promise ? value2.then(convertFlags) : convertFlags(value2);
11041
+ } else result = readCursor();
11042
+ if (result instanceof Promise) return result.finally(release);
11043
+ release();
11044
+ return result;
11045
+ } catch (error) {
11046
+ release();
11047
+ throw error;
11010
11048
  }
11011
11049
  }
11012
11050
  function callMatchLikeMethod(value, methodName, args, compilation, lastIndex) {
@@ -36458,4 +36496,4 @@ export {
36458
36496
  FileSnapshotBackend,
36459
36497
  run
36460
36498
  };
36461
- //# sourceMappingURL=chunk-BM7QYQOS.js.map
36499
+ //# sourceMappingURL=chunk-GF7KHTVI.js.map