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/dist/index.js
CHANGED
|
@@ -144253,7 +144253,7 @@ async function replaceRegex(value, regex, replacement, replaceAll2, budget, call
|
|
|
144253
144253
|
let copiedThrough = 0;
|
|
144254
144254
|
for (const match of matches) {
|
|
144255
144255
|
result += value.slice(copiedThrough, match.index);
|
|
144256
|
-
result += typeof replacement === "string" ? expandReplacement(replacement, match.text, match.captures) : String(
|
|
144256
|
+
result += typeof replacement === "string" ? expandReplacement(replacement, match.text, match.captures, value, match.index) : String(
|
|
144257
144257
|
await callClosure(replacement, [match.text, ...match.captures, match.index, value])
|
|
144258
144258
|
);
|
|
144259
144259
|
copiedThrough = match.index + match.text.length;
|
|
@@ -144261,12 +144261,45 @@ async function replaceRegex(value, regex, replacement, replaceAll2, budget, call
|
|
|
144261
144261
|
result += value.slice(copiedThrough);
|
|
144262
144262
|
return budget.allocateString(result);
|
|
144263
144263
|
}
|
|
144264
|
-
function expandReplacement(replacement, match, captures) {
|
|
144265
|
-
|
|
144266
|
-
|
|
144267
|
-
|
|
144268
|
-
|
|
144269
|
-
|
|
144264
|
+
function expandReplacement(replacement, match, captures, input, matchIndex) {
|
|
144265
|
+
let result = "";
|
|
144266
|
+
for (let index = 0; index < replacement.length; index += 1) {
|
|
144267
|
+
const character2 = replacement.charAt(index);
|
|
144268
|
+
if (character2 !== "$") {
|
|
144269
|
+
result += character2;
|
|
144270
|
+
continue;
|
|
144271
|
+
}
|
|
144272
|
+
const token = replacement.charAt(index + 1);
|
|
144273
|
+
if (token === "$") {
|
|
144274
|
+
result += "$";
|
|
144275
|
+
} else if (token === "&") {
|
|
144276
|
+
result += match;
|
|
144277
|
+
} else if (token === "`") {
|
|
144278
|
+
result += input.slice(0, matchIndex);
|
|
144279
|
+
} else if (token === "'") {
|
|
144280
|
+
result += input.slice(matchIndex + match.length);
|
|
144281
|
+
} else if (token >= "0" && token <= "9") {
|
|
144282
|
+
let captureIndex = Number(token);
|
|
144283
|
+
const nextDigit = replacement.charAt(index + 2);
|
|
144284
|
+
if (nextDigit >= "0" && nextDigit <= "9") {
|
|
144285
|
+
const twoDigitIndex = Number(token + nextDigit);
|
|
144286
|
+
if (twoDigitIndex > 0 && twoDigitIndex <= captures.length) {
|
|
144287
|
+
captureIndex = twoDigitIndex;
|
|
144288
|
+
index += 1;
|
|
144289
|
+
}
|
|
144290
|
+
}
|
|
144291
|
+
if (captureIndex === 0 || captureIndex > captures.length) {
|
|
144292
|
+
result += "$";
|
|
144293
|
+
continue;
|
|
144294
|
+
}
|
|
144295
|
+
result += captures[captureIndex - 1] ?? "";
|
|
144296
|
+
} else {
|
|
144297
|
+
result += "$";
|
|
144298
|
+
continue;
|
|
144299
|
+
}
|
|
144300
|
+
index += 1;
|
|
144301
|
+
}
|
|
144302
|
+
return result;
|
|
144270
144303
|
}
|
|
144271
144304
|
async function replaceWithClosure(value, searchValue, replacer, replaceAll2, budget, callClosure) {
|
|
144272
144305
|
const offsets = findReplacementOffsets(value, searchValue, replaceAll2);
|
|
@@ -155459,7 +155492,7 @@ var init_package2 = __esm({
|
|
|
155459
155492
|
"package.json"() {
|
|
155460
155493
|
package_default2 = {
|
|
155461
155494
|
name: "poe-code",
|
|
155462
|
-
version: "11.0.
|
|
155495
|
+
version: "11.0.4",
|
|
155463
155496
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
155464
155497
|
license: "MIT",
|
|
155465
155498
|
type: "module",
|