poe-code 11.0.2 → 11.0.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-code",
3
- "version": "11.0.2",
3
+ "version": "11.0.4",
4
4
  "description": "CLI tool to configure Poe API for developer workflows.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -5965,11 +5965,13 @@ var KNOWN_RUNTIME_GLOBALS = [
5965
5965
  "Array",
5966
5966
  "Boolean",
5967
5967
  "Error",
5968
+ "Infinity",
5968
5969
  "isFinite",
5969
5970
  "isNaN",
5970
5971
  "JSON",
5971
5972
  "Map",
5972
5973
  "Math",
5974
+ "NaN",
5973
5975
  "Number",
5974
5976
  "Object",
5975
5977
  "parseFloat",
@@ -25105,7 +25107,7 @@ async function replaceRegex(value, regex, replacement, replaceAll, budget, callC
25105
25107
  let copiedThrough = 0;
25106
25108
  for (const match of matches) {
25107
25109
  result += value.slice(copiedThrough, match.index);
25108
- result += typeof replacement === "string" ? expandReplacement(replacement, match.text, match.captures) : String(
25110
+ result += typeof replacement === "string" ? expandReplacement(replacement, match.text, match.captures, value, match.index) : String(
25109
25111
  await callClosure(replacement, [match.text, ...match.captures, match.index, value])
25110
25112
  );
25111
25113
  copiedThrough = match.index + match.text.length;
@@ -25113,12 +25115,45 @@ async function replaceRegex(value, regex, replacement, replaceAll, budget, callC
25113
25115
  result += value.slice(copiedThrough);
25114
25116
  return budget.allocateString(result);
25115
25117
  }
25116
- function expandReplacement(replacement, match, captures) {
25117
- return replacement.replace(/\$([$&]|[1-9][0-9]?)/g, (token, part) => {
25118
- if (part === "$") return "$";
25119
- if (part === "&") return match;
25120
- return captures[Number(part) - 1] ?? token;
25121
- });
25118
+ function expandReplacement(replacement, match, captures, input, matchIndex) {
25119
+ let result = "";
25120
+ for (let index = 0; index < replacement.length; index += 1) {
25121
+ const character = replacement.charAt(index);
25122
+ if (character !== "$") {
25123
+ result += character;
25124
+ continue;
25125
+ }
25126
+ const token = replacement.charAt(index + 1);
25127
+ if (token === "$") {
25128
+ result += "$";
25129
+ } else if (token === "&") {
25130
+ result += match;
25131
+ } else if (token === "`") {
25132
+ result += input.slice(0, matchIndex);
25133
+ } else if (token === "'") {
25134
+ result += input.slice(matchIndex + match.length);
25135
+ } else if (token >= "0" && token <= "9") {
25136
+ let captureIndex = Number(token);
25137
+ const nextDigit = replacement.charAt(index + 2);
25138
+ if (nextDigit >= "0" && nextDigit <= "9") {
25139
+ const twoDigitIndex = Number(token + nextDigit);
25140
+ if (twoDigitIndex > 0 && twoDigitIndex <= captures.length) {
25141
+ captureIndex = twoDigitIndex;
25142
+ index += 1;
25143
+ }
25144
+ }
25145
+ if (captureIndex === 0 || captureIndex > captures.length) {
25146
+ result += "$";
25147
+ continue;
25148
+ }
25149
+ result += captures[captureIndex - 1] ?? "";
25150
+ } else {
25151
+ result += "$";
25152
+ continue;
25153
+ }
25154
+ index += 1;
25155
+ }
25156
+ return result;
25122
25157
  }
25123
25158
  async function replaceWithClosure(value, searchValue, replacer, replaceAll, budget, callClosure) {
25124
25159
  const offsets = findReplacementOffsets(value, searchValue, replaceAll);
@@ -28879,4 +28914,4 @@ export {
28879
28914
  FileSnapshotBackend,
28880
28915
  run
28881
28916
  };
28882
- //# sourceMappingURL=chunk-XU36QFFX.js.map
28917
+ //# sourceMappingURL=chunk-CA342J7E.js.map