@poe-platform/safe-js 0.1.174 → 0.1.175

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-KWMGOGFY.js";
30
+ } from "./chunk-PECCU43A.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-ECW7ILI7.js.map
8252
+ //# sourceMappingURL=chunk-6YLWKHF7.js.map
@@ -10511,19 +10511,23 @@ function validateStringMethodArguments(_methodName, _args) {
10511
10511
  function callStringMethod(value, methodName, args, budget, callClosure = async (closure, closureArgs) => await closure.call(closureArgs), parent, context) {
10512
10512
  if (value === null || value === void 0)
10513
10513
  throw new TypeError(`String#${methodName} requires a non-null receiver.`);
10514
- const fallback = () => typeof value === "string" ? callStringMethodBody(value, methodName, args, budget, callClosure, parent, context) : Promise.resolve(sandboxString(value, budget, context)).then((string) => callStringMethodBody(string, methodName, args, budget, callClosure, parent, context));
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);
10516
+ return typeof value === "string" ? apply(value) : Promise.resolve(sandboxString(value, budget, context)).then(apply);
10517
+ };
10515
10518
  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;
10516
10519
  const pattern = args[0];
10517
10520
  if (symbol !== void 0 && types6.isRegExp(pattern))
10518
10521
  throw new TypeError(`String#${methodName} does not accept unbranded host RegExp values.`);
10519
10522
  if (symbol === void 0 || pattern === null || pattern === void 0) return fallback();
10520
- const applyHook = (hook) => {
10521
- if (hook === null || hook === void 0) return fallback();
10522
- if (!isSandboxClosure(hook)) throw new TypeError(`String#${methodName} symbol hook must be callable.`);
10523
- return invokeBuiltinClosure(hook, symbol === Symbol.split || symbol === Symbol.replace ? [value, args[1]] : [value], budget, context, pattern);
10524
- };
10525
10523
  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);
10526
10524
  const dispatch = () => {
10525
+ const overriddenRegex = isSandboxRegex(pattern) && getSandboxPropertyDescriptor(pattern, symbol, budget) !== void 0;
10526
+ const applyHook = (hook2) => {
10527
+ if (hook2 === null || hook2 === void 0) return fallback(overriddenRegex);
10528
+ if (!isSandboxClosure(hook2)) throw new TypeError(`String#${methodName} symbol hook must be callable.`);
10529
+ return invokeBuiltinClosure(hook2, symbol === Symbol.split || symbol === Symbol.replace ? [value, args[1]] : [value], budget, context, pattern);
10530
+ };
10527
10531
  const hook = readProperty(symbol);
10528
10532
  return hook instanceof Promise ? hook.then(applyHook) : applyHook(hook);
10529
10533
  };
@@ -18942,7 +18946,7 @@ function conversionHook(value, name, budget, context) {
18942
18946
  let current = value;
18943
18947
  let depth = 0;
18944
18948
  while (current !== null) {
18945
- const properties = isGuestClosure(current) ? getGuestFunctionProperties(current) : current;
18949
+ const properties = isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : current;
18946
18950
  const descriptor = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, name);
18947
18951
  if (descriptor !== void 0) {
18948
18952
  return readPropertyDescriptor(descriptor, value, context);
@@ -36406,4 +36410,4 @@ export {
36406
36410
  FileSnapshotBackend,
36407
36411
  run
36408
36412
  };
36409
- //# sourceMappingURL=chunk-KWMGOGFY.js.map
36413
+ //# sourceMappingURL=chunk-PECCU43A.js.map