@poe-platform/safe-js 0.1.173 → 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-QR5MFF7T.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-UFDE4H2X.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
  };
@@ -10893,21 +10897,26 @@ function splitNormalized(value, separator, limit, budget, parent) {
10893
10897
  const result2 = [];
10894
10898
  let copiedThrough = 0;
10895
10899
  let endedWithZeroWidthMatch = false;
10896
- for (const match of collectRegexMatches(splitter, value, true)) {
10900
+ while (result2.length < limit) {
10901
+ const match = executeRegex(splitter, value, Number(splitter.lastIndex));
10902
+ if (match === null) break;
10903
+ if (match.text.length === 0) splitter.lastIndex = match.index + 1;
10897
10904
  endedWithZeroWidthMatch = match.text.length === 0 && match.index === value.length;
10898
10905
  if (match.text.length === 0 && (match.index === copiedThrough || match.index === value.length))
10899
10906
  continue;
10900
- if (result2.length >= limit) break;
10907
+ budget.allocateArrayLength(result2.length + 1);
10901
10908
  result2.push(budget.allocateString(value.slice(copiedThrough, match.index)));
10902
10909
  for (const capture of match.captures) {
10903
10910
  if (result2.length >= limit) break;
10911
+ budget.allocateArrayLength(result2.length + 1);
10904
10912
  result2.push(capture === void 0 ? void 0 : budget.allocateString(capture));
10905
10913
  }
10906
10914
  copiedThrough = match.index + match.text.length;
10907
10915
  }
10908
- if (result2.length < limit && (value.length > 0 || !endedWithZeroWidthMatch))
10916
+ if (result2.length < limit && (value.length > 0 || !endedWithZeroWidthMatch)) {
10917
+ budget.allocateArrayLength(result2.length + 1);
10909
10918
  result2.push(budget.allocateString(value.slice(copiedThrough)));
10910
- budget.allocateArrayLength(result2.length);
10919
+ }
10911
10920
  return result2;
10912
10921
  } finally {
10913
10922
  compilation.dispose();
@@ -18937,7 +18946,7 @@ function conversionHook(value, name, budget, context) {
18937
18946
  let current = value;
18938
18947
  let depth = 0;
18939
18948
  while (current !== null) {
18940
- const properties = isGuestClosure(current) ? getGuestFunctionProperties(current) : current;
18949
+ const properties = isGuestClosure(current) ? getGuestFunctionProperties(current) : isSandboxRegex(current) ? getRegexProperties(current) : current;
18941
18950
  const descriptor = properties === void 0 ? void 0 : Object.getOwnPropertyDescriptor(properties, name);
18942
18951
  if (descriptor !== void 0) {
18943
18952
  return readPropertyDescriptor(descriptor, value, context);
@@ -36401,4 +36410,4 @@ export {
36401
36410
  FileSnapshotBackend,
36402
36411
  run
36403
36412
  };
36404
- //# sourceMappingURL=chunk-QR5MFF7T.js.map
36413
+ //# sourceMappingURL=chunk-PECCU43A.js.map