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/dist/index.js +43 -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-XU36QFFX.js → chunk-CA342J7E.js} +43 -8
- package/packages/safejs/dist/chunks/chunk-CA342J7E.js.map +7 -0
- package/packages/safejs/dist/chunks/{chunk-JUF273GA.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/lint/rules/known-globals.d.ts +1 -1
- package/packages/safejs/dist/lint/rules/known-globals.js +2 -0
- package/packages/safejs/dist/chunks/chunk-XU36QFFX.js.map +0 -7
- /package/packages/safejs/dist/chunks/{chunk-JUF273GA.js.map → chunk-NBVIHENC.js.map} +0 -0
package/package.json
CHANGED
|
@@ -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
|
-
|
|
25118
|
-
|
|
25119
|
-
|
|
25120
|
-
|
|
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-
|
|
28917
|
+
//# sourceMappingURL=chunk-CA342J7E.js.map
|