@poe-platform/safe-js 0.1.192 → 0.1.193

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-SKWFZYFI.js";
30
+ } from "./chunk-IBLBXKUC.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-Q6OWZDNT.js.map
8252
+ //# sourceMappingURL=chunk-2N7Z7ETR.js.map
@@ -2391,6 +2391,7 @@ var RegexParser = class {
2391
2391
  function parseFlags(flags, guard) {
2392
2392
  guard.allocate(10);
2393
2393
  const parsed = {
2394
+ hasIndices: false,
2394
2395
  global: false,
2395
2396
  sticky: false,
2396
2397
  ignoreCase: false,
@@ -2398,6 +2399,7 @@ function parseFlags(flags, guard) {
2398
2399
  dotAll: false
2399
2400
  };
2400
2401
  const names = {
2402
+ d: "hasIndices",
2401
2403
  g: "global",
2402
2404
  i: "ignoreCase",
2403
2405
  m: "multiline",
@@ -9317,7 +9319,7 @@ function matchRegexFrom(pattern, input, startIndex) {
9317
9319
  };
9318
9320
  const result = matchNode(pattern.body, initialState, context).next();
9319
9321
  if (!result.done) {
9320
- return toRegexMatch(input, attempt, result.value);
9322
+ return toRegexMatch(input, attempt, result.value, pattern.flags.hasIndices);
9321
9323
  }
9322
9324
  if (pattern.flags.sticky) break;
9323
9325
  }
@@ -9450,14 +9452,18 @@ function matchesCharacterClassItem(character, item, ignoreCase) {
9450
9452
  const matched = item.kind === "digit" ? isDigit(character) : item.kind === "word" ? isWordCharacter(character) : isSpaceCharacter(character);
9451
9453
  return item.negated ? !matched : matched;
9452
9454
  }
9453
- function toRegexMatch(input, start, state) {
9454
- return {
9455
+ function toRegexMatch(input, start, state, hasIndices) {
9456
+ const match = {
9455
9457
  index: start,
9456
9458
  text: input.slice(start, state.position),
9457
9459
  captures: state.captures.map(
9458
9460
  (capture) => capture === void 0 ? void 0 : input.slice(capture.start, capture.end)
9459
9461
  )
9460
9462
  };
9463
+ if (hasIndices) {
9464
+ match.indices = [[start, state.position], ...state.captures.map((capture) => capture === void 0 ? void 0 : [capture.start, capture.end])];
9465
+ }
9466
+ return match;
9461
9467
  }
9462
9468
  function cloneState(state) {
9463
9469
  return { position: state.position, captures: state.captures.slice() };
@@ -10503,7 +10509,7 @@ function callMatchLikeMethod(value, methodName, args, compilation, lastIndex) {
10503
10509
  return match?.index ?? -1;
10504
10510
  }
10505
10511
  if (methodName === "match" && !regex.flags.includes("g"))
10506
- return toMatchArray(executeRegex(regex, value, lastIndex ?? Number(regex.lastIndex)), value);
10512
+ return toMatchArray(executeRegex(regex, value, lastIndex ?? Number(regex.lastIndex)), value, compilation.owner?.budget);
10507
10513
  if (methodName === "match") regex.lastIndex = 0;
10508
10514
  const matcher = methodName === "matchAll" ? createSandboxRegex(regex.source, regex.flags, normalizeLastIndex(lastIndex ?? Number(regex.lastIndex)), compilation) : regex;
10509
10515
  if (methodName === "matchAll")
@@ -16668,7 +16674,7 @@ async function callRegexMethod(target, methodName, args, budget, context) {
16668
16674
  cursor = target.lastIndex;
16669
16675
  const lastIndex = await sandboxNumber(cursor, budget, context);
16670
16676
  const match = executeRegex(target, input, lastIndex);
16671
- return toMatchArray(match, input);
16677
+ return toMatchArray(match, input, budget);
16672
16678
  } finally {
16673
16679
  budget.setRetainedValues(retained, void 0);
16674
16680
  }
@@ -16724,12 +16730,19 @@ function executeRegex(target, input, lastIndex) {
16724
16730
  }
16725
16731
  return match;
16726
16732
  }
16727
- function toMatchArray(match, input) {
16733
+ function toMatchArray(match, input, budget) {
16728
16734
  if (match === null) {
16729
16735
  return null;
16730
16736
  }
16737
+ budget?.allocateArrayLength(match.captures.length + 1);
16731
16738
  const result = [match.text, ...match.captures];
16732
16739
  Object.assign(result, { index: match.index, input, groups: void 0 });
16740
+ if (match.indices !== void 0) {
16741
+ budget?.allocateArrayLength(match.indices.length);
16742
+ budget?.allocateArrayLength(2);
16743
+ Object.assign(match.indices, { groups: void 0 });
16744
+ Object.assign(result, { indices: match.indices });
16745
+ }
16733
16746
  return result;
16734
16747
  }
16735
16748
 
@@ -16754,8 +16767,7 @@ function nextRegExpIterator(iterator, budget) {
16754
16767
  const codePoint = input.codePointAt(index);
16755
16768
  matcher.lastIndex = index + (unicode && codePoint !== void 0 && codePoint > 65535 ? 2 : 1);
16756
16769
  }
16757
- budget?.allocateArrayLength(match.captures.length + 1);
16758
- return { value: toMatchArray(match, input), done: false };
16770
+ return { value: toMatchArray(match, input, budget), done: false };
16759
16771
  }
16760
16772
  async function nextObservableRegExpIterator(iterator, budget, context) {
16761
16773
  const state = regexpIteratorState(iterator);
@@ -37071,4 +37083,4 @@ export {
37071
37083
  FileSnapshotBackend,
37072
37084
  run
37073
37085
  };
37074
- //# sourceMappingURL=chunk-SKWFZYFI.js.map
37086
+ //# sourceMappingURL=chunk-IBLBXKUC.js.map