@poe-platform/safe-js 0.1.189 → 0.1.190

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-LX5FI3OX.js";
30
+ } from "./chunk-YEZOXLY4.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-MIZBGOGS.js.map
8252
+ //# sourceMappingURL=chunk-JR2ZFJJM.js.map
@@ -10068,7 +10068,7 @@ function callReplaceLikeMethod(value, methodName, args, budget, callClosure, use
10068
10068
  }
10069
10069
  async function replaceRegex(value, regex, replacement, budget, callClosure, context) {
10070
10070
  if (hasRegexPropertyOverride(regex, ["exec", "flags", ...Object.keys(regexFlagProperties)], budget))
10071
- return replaceObservableRegex(value, regex, replacement, budget, callClosure, context);
10071
+ return regexReplace(value, regex, replacement, budget, callClosure, context);
10072
10072
  if (regex.flags.includes("g")) regex.lastIndex = 0;
10073
10073
  const cursor = regex.lastIndex;
10074
10074
  let result = "";
@@ -10099,7 +10099,10 @@ function readReplacementProperty(target, key, budget, context) {
10099
10099
  if (descriptor !== void 0) return readPropertyDescriptor(descriptor, target, context);
10100
10100
  return isSandboxRegex(target) ? getRegexMember(target, key, budget, context) : void 0;
10101
10101
  }
10102
- async function replaceObservableRegex(value, regex, replacement, budget, callClosure, context) {
10102
+ async function regexReplace(input, regex, replacementInput, budget, callClosure, context) {
10103
+ if (regex === null || typeof regex !== "object") throw new TypeError("RegExp replace requires an object receiver.");
10104
+ let value;
10105
+ let replacement;
10103
10106
  const matches = [];
10104
10107
  let current;
10105
10108
  let field;
@@ -10108,15 +10111,23 @@ async function replaceObservableRegex(value, regex, replacement, budget, callClo
10108
10111
  let captures = [];
10109
10112
  let result = "";
10110
10113
  let flags;
10111
- const release = retainValues(budget, () => [value, regex, replacement, matches, current, field, groups, matched, captures, result, flags]);
10114
+ const release = retainValues(budget, () => [input, value, regex, replacementInput, replacement, matches, current, field, groups, matched, captures, result, flags]);
10112
10115
  try {
10116
+ value = await sandboxString(input, budget, context);
10117
+ input = void 0;
10118
+ replacement = isSandboxClosure(replacementInput) ? replacementInput : await sandboxString(replacementInput, budget, context);
10119
+ replacementInput = void 0;
10120
+ if (isSandboxRegex(regex) && !hasRegexPropertyOverride(regex, ["exec", "flags", ...Object.keys(regexFlagProperties)], budget)) {
10121
+ release();
10122
+ return await replaceRegex(value, regex, replacement, budget, callClosure, context);
10123
+ }
10113
10124
  field = await readReplacementProperty(regex, "flags", budget, context);
10114
10125
  flags = await sandboxString(field, budget, context);
10115
10126
  field = void 0;
10116
10127
  const global = flags.includes("g");
10117
10128
  const fullUnicode = flags.includes("u") || flags.includes("v");
10118
10129
  flags = void 0;
10119
- if (global) regex.lastIndex = 0;
10130
+ if (global) await setSandboxProperty(regex, "lastIndex", 0, budget, true, context);
10120
10131
  while (true) {
10121
10132
  budget.visitNode();
10122
10133
  current = await regexExec(regex, value, budget, context);
@@ -10128,10 +10139,10 @@ async function replaceObservableRegex(value, regex, replacement, budget, callClo
10128
10139
  matched = await sandboxString(field, budget, context);
10129
10140
  field = void 0;
10130
10141
  if (matched.length === 0) {
10131
- field = regex.lastIndex;
10142
+ field = await readReplacementProperty(regex, "lastIndex", budget, context);
10132
10143
  const index = normalizeLastIndex(await sandboxNumber(field, budget, context));
10133
10144
  const point = fullUnicode ? value.codePointAt(index) : void 0;
10134
- regex.lastIndex = index + (point !== void 0 && point > 65535 ? 2 : 1);
10145
+ await setSandboxProperty(regex, "lastIndex", index + (point !== void 0 && point > 65535 ? 2 : 1), budget, true, context);
10135
10146
  field = void 0;
10136
10147
  }
10137
10148
  matched = void 0;
@@ -34466,6 +34477,24 @@ function createRegexGlobals(options) {
34466
34477
  writable: true,
34467
34478
  configurable: true
34468
34479
  });
34480
+ Object.defineProperty(prototype, Symbol.replace, {
34481
+ value: createSandboxClosure({
34482
+ guest: true,
34483
+ sandbox: true,
34484
+ name: "[Symbol.replace]",
34485
+ length: 2,
34486
+ call: (args, context) => regexReplace(
34487
+ args[0],
34488
+ context?.thisValue,
34489
+ args[1],
34490
+ options.budget,
34491
+ (closure, values) => invokeBuiltinClosure(closure, values, options.budget, context, void 0),
34492
+ context
34493
+ )
34494
+ }),
34495
+ writable: true,
34496
+ configurable: true
34497
+ });
34469
34498
  for (const name of ["exec", "test", "toString"]) {
34470
34499
  Object.defineProperty(prototype, name, {
34471
34500
  value: createSandboxClosure({
@@ -36810,4 +36839,4 @@ export {
36810
36839
  FileSnapshotBackend,
36811
36840
  run
36812
36841
  };
36813
- //# sourceMappingURL=chunk-LX5FI3OX.js.map
36842
+ //# sourceMappingURL=chunk-YEZOXLY4.js.map