@poe-platform/safe-js 0.1.118 → 0.1.119

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.
@@ -30612,32 +30612,43 @@ function defineDataProperty(target, key, value) {
30612
30612
  }
30613
30613
 
30614
30614
  // packages/safe-js/src/interp/globals/regex.ts
30615
- function createRegexGlobals(owner) {
30616
- const construct = (args, context) => {
30617
- const selected = owner ?? context?.compilation?.owner;
30615
+ function createRegexGlobals(options) {
30616
+ const invoke = (construct) => async (args, context) => {
30617
+ const selected = options.compileOwner ?? context?.compilation?.owner;
30618
30618
  if (context?.compilation?.owner !== void 0 && selected !== context.compilation.owner) {
30619
30619
  throw new SandboxError("reentry");
30620
30620
  }
30621
- const operation = selected?.budget.acquireCompileOwner(false, selected);
30622
- const compilation = context?.compilation ?? new CompileScope(selected);
30621
+ const operation = options.budget.acquireCompileOwner(false, selected);
30622
+ const compilation = context?.compilation?.owner === operation.owner ? context.compilation : new CompileScope(operation.owner);
30623
+ let source = "";
30624
+ const retained = {};
30625
+ options.budget.setRetainedValues(retained, () => [...args, source]);
30623
30626
  try {
30627
+ const pattern = args[0];
30628
+ const flags = args[1];
30629
+ if (!construct && isSandboxRegex(pattern) && flags === void 0) return pattern;
30630
+ const sourceValue = isSandboxRegex(pattern) ? pattern.source : pattern;
30631
+ const flagsValue = isSandboxRegex(pattern) && flags === void 0 ? pattern.flags : flags;
30632
+ source = sourceValue === void 0 ? "" : await sandboxString(sourceValue, options.budget, context);
30633
+ const flagText = flagsValue === void 0 ? "" : await sandboxString(flagsValue, options.budget, context);
30624
30634
  const regex = createSandboxRegex(
30625
- String(args[0] ?? ""),
30626
- String(args[1] ?? ""),
30635
+ source,
30636
+ flagText,
30627
30637
  0,
30628
30638
  compilation
30629
30639
  );
30630
- if (context?.compilation === void 0 && selected !== void 0) {
30631
- reconcileCompiledValues(selected.budget, [regex], compilation);
30640
+ if (compilation !== context?.compilation) {
30641
+ reconcileCompiledValues(options.budget, [regex], compilation);
30632
30642
  }
30633
30643
  return regex;
30634
30644
  } finally {
30635
- if (context?.compilation === void 0) compilation.dispose();
30636
- operation?.release();
30645
+ options.budget.setRetainedValues(retained, void 0);
30646
+ if (compilation !== context?.compilation) compilation.dispose();
30647
+ operation.release();
30637
30648
  }
30638
30649
  };
30639
30650
  return {
30640
- RegExp: createSandboxClosure({ sandbox: true, name: "RegExp", call: construct, construct })
30651
+ RegExp: createSandboxClosure({ sandbox: true, name: "RegExp", call: invoke(false), construct: invoke(true) })
30641
30652
  };
30642
30653
  }
30643
30654
 
@@ -31194,7 +31205,7 @@ function createBuiltinBindings(options) {
31194
31205
  ...createObjectArrayGlobals(options),
31195
31206
  ...createMiscGlobals(options),
31196
31207
  ...createPromiseGlobals(options),
31197
- ...createRegexGlobals(options.compileOwner)
31208
+ ...createRegexGlobals(options)
31198
31209
  };
31199
31210
  }
31200
31211
 
@@ -33317,4 +33328,4 @@ export {
33317
33328
  FileSnapshotBackend,
33318
33329
  run
33319
33330
  };
33320
- //# sourceMappingURL=chunk-7FCWZM6I.js.map
33331
+ //# sourceMappingURL=chunk-6LFWVA64.js.map