@poe-platform/safe-js 0.1.177 → 0.1.178

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.
@@ -9511,11 +9511,33 @@ var regexFlagProperties = {
9511
9511
  function isRegexMethodName(property) {
9512
9512
  return typeof property === "string" && regexMethodNames.has(property);
9513
9513
  }
9514
- function getRegexMember(target, property, budget) {
9514
+ function getRegexMember(target, property, budget, context) {
9515
9515
  if (property === "source") return escapeRegexSource(target.source, budget);
9516
9516
  if (property === "flags") {
9517
- const flags = [..."gims"].filter((flag) => target.flags.includes(flag)).join("");
9518
- return budget === void 0 ? flags : budget.allocateString(flags);
9517
+ let flags = "";
9518
+ const entries = Object.entries(regexFlagProperties);
9519
+ const release = retainValues(budget, () => [target, flags]);
9520
+ const read = (index) => {
9521
+ if (index === entries.length) return budget.allocateString(flags);
9522
+ budget.visitNode();
9523
+ const [key, flag] = entries[index];
9524
+ const descriptor = context?.getProperty === void 0 ? getSandboxPropertyDescriptor(target, key, budget) : void 0;
9525
+ const value = context?.getProperty !== void 0 ? context.getProperty(target, key) : descriptor !== void 0 ? readPropertyDescriptor(descriptor, target, context) : target.flags.includes(flag);
9526
+ const append = (value2) => {
9527
+ if (value2) flags += flag;
9528
+ return read(index + 1);
9529
+ };
9530
+ return value instanceof Promise ? value.then(append) : append(value);
9531
+ };
9532
+ try {
9533
+ const result = read(0);
9534
+ if (result instanceof Promise) return result.finally(release);
9535
+ release();
9536
+ return result;
9537
+ } catch (error) {
9538
+ release();
9539
+ throw error;
9540
+ }
9519
9541
  }
9520
9542
  if (property === "lastIndex") return target.lastIndex;
9521
9543
  if (Object.hasOwn(regexFlagProperties, property)) return target.flags.includes(regexFlagProperties[property]);
@@ -9525,7 +9547,7 @@ function getRegexMember(target, property, budget) {
9525
9547
  return createSandboxClosure({
9526
9548
  sandbox: true,
9527
9549
  name: property === "toString" ? "toString" : `RegExp#${property}`,
9528
- call: (args, context) => callRegexMethod(context?.thisValue, property, args, budget, context)
9550
+ call: (args, context2) => callRegexMethod(context2?.thisValue, property, args, budget, context2)
9529
9551
  });
9530
9552
  }
9531
9553
  function escapeRegexSource(source, budget) {
@@ -9594,7 +9616,7 @@ async function regexToString(target, budget, context) {
9594
9616
  if (context?.getProperty !== void 0) return context.getProperty(target, key);
9595
9617
  const descriptor = getSandboxPropertyDescriptor(target, key, budget);
9596
9618
  if (descriptor !== void 0) return readPropertyDescriptor(descriptor, target, context);
9597
- return isSandboxRegex(target) ? getRegexMember(target, key, budget) : void 0;
9619
+ return isSandboxRegex(target) ? getRegexMember(target, key, budget, context) : void 0;
9598
9620
  };
9599
9621
  let sourceValue;
9600
9622
  let flagsValue;
@@ -15905,7 +15927,7 @@ function getPropertyValue(target, property, context, receiver = target) {
15905
15927
  if (isSandboxGenerator(target)) return getGeneratorMember(target, property, context.budget);
15906
15928
  if (isSandboxClosure(target)) return getClosureMemberValue(target, property, context);
15907
15929
  if (isSandboxPromise(target)) return getPromiseMember(property, context.budget);
15908
- if (isSandboxRegex(target)) return getRegexMember(target, property, context.budget);
15930
+ if (isSandboxRegex(target)) return getRegexMember(target, property, context.budget, createCoercionContext(context));
15909
15931
  if (!isIndexableSandboxValue(target)) {
15910
15932
  throw new TypeError("Attempted to read a property from a non-object value.");
15911
15933
  }
@@ -36436,4 +36458,4 @@ export {
36436
36458
  FileSnapshotBackend,
36437
36459
  run
36438
36460
  };
36439
- //# sourceMappingURL=chunk-B5ZSXQUJ.js.map
36461
+ //# sourceMappingURL=chunk-BM7QYQOS.js.map