poe-code 11.0.3 → 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/dist/index.js +41 -8
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safejs/dist/chunks/{chunk-YETLO7L5.js → chunk-CA342J7E.js} +41 -8
- package/packages/safejs/dist/chunks/{chunk-YETLO7L5.js.map → chunk-CA342J7E.js.map} +2 -2
- package/packages/safejs/dist/chunks/{chunk-7AGANI6L.js → chunk-NBVIHENC.js} +2 -2
- package/packages/safejs/dist/cli.js +2 -2
- package/packages/safejs/dist/core.js +1 -1
- package/packages/safejs/dist/index.js +2 -2
- package/packages/safejs/dist/interp/methods/string.js +45 -9
- /package/packages/safejs/dist/chunks/{chunk-7AGANI6L.js.map → chunk-NBVIHENC.js.map} +0 -0
package/package.json
CHANGED
|
@@ -25107,7 +25107,7 @@ async function replaceRegex(value, regex, replacement, replaceAll, budget, callC
|
|
|
25107
25107
|
let copiedThrough = 0;
|
|
25108
25108
|
for (const match of matches) {
|
|
25109
25109
|
result += value.slice(copiedThrough, match.index);
|
|
25110
|
-
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(
|
|
25111
25111
|
await callClosure(replacement, [match.text, ...match.captures, match.index, value])
|
|
25112
25112
|
);
|
|
25113
25113
|
copiedThrough = match.index + match.text.length;
|
|
@@ -25115,12 +25115,45 @@ async function replaceRegex(value, regex, replacement, replaceAll, budget, callC
|
|
|
25115
25115
|
result += value.slice(copiedThrough);
|
|
25116
25116
|
return budget.allocateString(result);
|
|
25117
25117
|
}
|
|
25118
|
-
function expandReplacement(replacement, match, captures) {
|
|
25119
|
-
|
|
25120
|
-
|
|
25121
|
-
|
|
25122
|
-
|
|
25123
|
-
|
|
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;
|
|
25124
25157
|
}
|
|
25125
25158
|
async function replaceWithClosure(value, searchValue, replacer, replaceAll, budget, callClosure) {
|
|
25126
25159
|
const offsets = findReplacementOffsets(value, searchValue, replaceAll);
|
|
@@ -28881,4 +28914,4 @@ export {
|
|
|
28881
28914
|
FileSnapshotBackend,
|
|
28882
28915
|
run
|
|
28883
28916
|
};
|
|
28884
|
-
//# sourceMappingURL=chunk-
|
|
28917
|
+
//# sourceMappingURL=chunk-CA342J7E.js.map
|